Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
* RFC: finish_command_continuation and errors
@ 2010-03-18 17:07 Tom Tromey
  2010-03-18 17:35 ` Pedro Alves
  0 siblings, 1 reply; 6+ messages in thread
From: Tom Tromey @ 2010-03-18 17:07 UTC (permalink / raw)
  To: gdb-patches

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


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

end of thread, other threads:[~2010-03-18 18:22 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-03-18 17:07 RFC: finish_command_continuation and errors Tom Tromey
2010-03-18 17:35 ` Pedro Alves
2010-03-18 17:59   ` Tom Tromey
2010-03-18 18:08     ` Joel Brobecker
2010-03-18 18:14     ` Pedro Alves
2010-03-18 18:22       ` Tom Tromey

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