This is the mail archive of the
gdb-patches@sourceware.org
mailing list for the GDB project.
[patch] Add cleanup branch for std::terminate breakpoints in call_function_by_hand
- From: Phil Muldoon <pmuldoon at redhat dot com>
- To: gdb-patches ml <gdb-patches at sourceware dot org>
- Date: Thu, 01 Oct 2009 17:05:39 +0100
- Subject: [patch] Add cleanup branch for std::terminate breakpoints in call_function_by_hand
This patches fixes a breakpoint leak that may occur when an inferior
function call is performed within a C++ executable. It adds a do_cleanup
call at one of the function exit entry points. (call_function_by_hand
can exit in several different scenarios, depending on the result of the
inferior call).
I decided to place a condition around the do_cleanup over a null_cleanup
just to save endless null_cleanup calls when the inferior is a C
executable (the cleanup is never needed there, as the breakpoint is not
set).
Apologies for introducing this bug a few months back, and finding and
fixing it during this busy (release) time!
I tested this on x86_64 with no regressions.
Regards
Phil
ChangeLog
2009-10-01 Phil Muldoon <pmuldoon@redhat.com>
* infcall.c (call_function_by_hand): Add a new cleanup branch for
std::terminate breakpoint.
--
Index: infcall.c
===================================================================
RCS file: /cvs/src/src/gdb/infcall.c,v
retrieving revision 1.121
diff -u -r1.121 infcall.c
--- infcall.c 28 Jul 2009 16:39:06 -0000 1.121
+++ infcall.c 1 Oct 2009 15:00:38 -0000
@@ -441,6 +441,7 @@
struct gdbarch *gdbarch;
struct breakpoint *terminate_bp = NULL;
struct minimal_symbol *tm;
+ struct cleanup *terminate_bp_cleanup;
ptid_t call_thread_ptid;
struct gdb_exception e;
const char *name;
@@ -772,7 +773,7 @@
/* Register a clean-up for
unwind_on_terminating_exception_breakpoint. */
if (terminate_bp)
- make_cleanup_delete_breakpoint (terminate_bp);
+ terminate_bp_cleanup = make_cleanup_delete_breakpoint (terminate_bp);
/* - SNIP - SNIP - SNIP - SNIP - SNIP - SNIP - SNIP - SNIP - SNIP -
If you're looking to implement asynchronous dummy-frames, then
@@ -987,6 +988,11 @@
internal_error (__FILE__, __LINE__, _("... should not be here"));
}
+ /* If we get here and the std::terminate() breakpoint has been set,
+ it has to be cleaned manually. */
+ if (terminate_bp)
+ do_cleanups (terminate_bp_cleanup);
+