Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
* [RFA] Rethrow exception properly.
@ 2008-01-27  2:19 Vladimir Prus
  2008-01-27  7:53 ` Nick Roberts
  2008-01-31 22:21 ` Daniel Jacobowitz
  0 siblings, 2 replies; 4+ messages in thread
From: Vladimir Prus @ 2008-01-27  2:19 UTC (permalink / raw)
  To: gdb-patches


Nick has reported that my recent changes regressed MI
error messages, and now we get:

  (gdb) 
  -break-insert sqrt
  &"Function \"sqrt\" not defined.\n"
  ^error,msg="unknown error"
  (gdb) 

The problem is in rather old code in  break_command_really -- 
when we can't parse breakpoint location, and pending breakpoints 
are off, we rethrow the exception using the deprecated_throw_reason.
Unfortunately, that strips the message from the exception, 
so MI code gets rather useless exception.

Such rethrowing is just wrong -- if we fully delegate handling of
the error to our caller, we should just throw the original exception.

The attached patch switches to using throw_exception and gets us
back to sane MI error message. OK?

- Volodya


	[gdb]
        Properly rethrow exception.  This fixes errors
	about non-existent functions for -break-insert.

	* breakpoint.c (break_command_really): Use throw_exception
	for rethrowing.  If rethrowing, don't print the exception.

	[gdb/testsuite]
	* gdb.mi/mi-break.exp (test_error): New.
	Call it.
---
 gdb/breakpoint.c                  |    6 +++---
 gdb/testsuite/gdb.mi/mi-break.exp |   10 ++++++++++
 2 files changed, 13 insertions(+), 3 deletions(-)

diff --git a/gdb/breakpoint.c b/gdb/breakpoint.c
index 9551bd5..d5de3e7 100644
--- a/gdb/breakpoint.c
+++ b/gdb/breakpoint.c
@@ -5280,13 +5280,13 @@ break_command_really (char *arg, char *cond_string, int thread,
 	{
 	case NOT_FOUND_ERROR:
 
-	  exception_print (gdb_stderr, e);
-
 	  /* If pending breakpoint support is turned off, throw
 	     error.  */
 
 	  if (pending_break_support == AUTO_BOOLEAN_FALSE)
-	    deprecated_throw_reason (RETURN_ERROR);
+	    throw_exception (e);
+
+	  exception_print (gdb_stderr, e);
 
           /* If pending breakpoint support is auto query and the user
 	     selects no, then simply return the error code.  */
diff --git a/gdb/testsuite/gdb.mi/mi-break.exp b/gdb/testsuite/gdb.mi/mi-break.exp
index af438b9..ca59348 100644
--- a/gdb/testsuite/gdb.mi/mi-break.exp
+++ b/gdb/testsuite/gdb.mi/mi-break.exp
@@ -175,10 +175,20 @@ proc test_ignore_count {} {
     }  
 }
 
+proc test_error {} {
+    global mi_gdb_prompt
+
+    mi_gdb_test "-break-insert function_that_does_not_exit" \
+        ".*\\^error,msg=\"Function \\\\\"function_that_does_not_exit\\\\\" not defined.\"" \
+        "breakpoint at nonexistent function"
+}
+
 test_tbreak_creation_and_listing
 test_rbreak_creation_and_listing
 
 test_ignore_count
 
+test_error
+
 mi_gdb_exit
 return 0
-- 
1.5.3.5


^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2008-01-31 22:12 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2008-01-27  2:19 [RFA] Rethrow exception properly Vladimir Prus
2008-01-27  7:53 ` Nick Roberts
2008-01-27 14:15   ` Vladimir Prus
2008-01-31 22:21 ` Daniel Jacobowitz

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox