This is the mail archive of the
gdb-patches@sourceware.org
mailing list for the GDB project.
RFC: finish_command_continuation and errors
- From: Tom Tromey <tromey at redhat dot com>
- To: gdb-patches at sourceware dot org
- Date: Thu, 18 Mar 2010 11:07:06 -0600
- Subject: RFC: finish_command_continuation and errors
- Reply-to: tromey at redhat dot com
I'd appreciate comments on this patch, particularly from Pedro.
While debugging a gcj-compiled program yesterday, I got this error while
trying to re-run:
Cannot insert breakpoint 0.
Error accessing memory address 0x3e1dc5: Input/output error.
Looking at "maint info b" showed:
(gdb) maint info b
Num Type Disp Enb Address What
0 finish keep y 0x003ea395 ../../../../../trunk/libjava/classpath/tools/gnu/classpath/tools/javah/Main.java:414 inf 1 thread 1
stop only in thread 1
This can happen if gdb calls error while printing the return value.
In this case, the finish breakpoint is never deleted.
This patch fixes the problem by wrapping the call to print_return_value
in a TRY_CATCH. Other fixes are possible, but I chose this one because
it is small and occurs at the point in the code that must be
exception-safe.
Built and regtested on x86-64 (compile farm).
I also tried it again on my test case, provoked the error, and used
"maint info b" to verify that the finish breakpoint was deleted.
I also glanced at the other continuation functions in infcmd.c, but none
of them appeared to have a similar problem.
Tom
2010-03-18 Tom Tromey <tromey@redhat.com>
* infcmd.c (finish_command_continuation): Wrap print_return_value
in TRY_CATCH.
Index: infcmd.c
===================================================================
RCS file: /cvs/src/src/gdb/infcmd.c,v
retrieving revision 1.259
diff -u -r1.259 infcmd.c
--- infcmd.c 16 Feb 2010 21:18:46 -0000 1.259
+++ infcmd.c 18 Mar 2010 17:00:51 -0000
@@ -1420,7 +1420,19 @@
_("finish_command: function has no target type"));
if (TYPE_CODE (value_type) != TYPE_CODE_VOID)
- print_return_value (SYMBOL_TYPE (a->function), value_type);
+ {
+ volatile struct gdb_exception ex;
+
+ TRY_CATCH (ex, RETURN_MASK_ALL)
+ {
+ /* print_return_value can throw an exception in some
+ circumstances. We need to catch this so that we still
+ delete the breakpoint. */
+ print_return_value (SYMBOL_TYPE (a->function), value_type);
+ }
+ if (ex.reason < 0)
+ exception_print (gdb_stdout, ex);
+ }
}
/* We suppress normal call of normal_stop observer and do it here so