Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
* [patch] Add cleanup branch for std::terminate breakpoints in call_function_by_hand
@ 2009-10-01 16:05 Phil Muldoon
  2009-10-01 16:44 ` Joel Brobecker
  0 siblings, 1 reply; 3+ messages in thread
From: Phil Muldoon @ 2009-10-01 16:05 UTC (permalink / raw)
  To: gdb-patches ml

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);
+


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

* Re: [patch] Add cleanup branch for std::terminate breakpoints in  call_function_by_hand
  2009-10-01 16:05 [patch] Add cleanup branch for std::terminate breakpoints in call_function_by_hand Phil Muldoon
@ 2009-10-01 16:44 ` Joel Brobecker
  2009-10-01 20:12   ` committed: " Phil Muldoon
  0 siblings, 1 reply; 3+ messages in thread
From: Joel Brobecker @ 2009-10-01 16:44 UTC (permalink / raw)
  To: Phil Muldoon; +Cc: gdb-patches ml

> 2009-10-01  Phil Muldoon <pmuldoon@redhat.com>
>
>     * infcall.c (call_function_by_hand): Add a new cleanup branch for
>     std::terminate breakpoint.

This is OK for the HEAD, except for one minor tiny comment:

> +  struct cleanup *terminate_bp_cleanup;

Can you initialize this to NULL? I know from code inspection that
you cannot use it uninitialized, but you never know. Plus some compilers
may not be smart enough to detect that...

Thanks,
-- 
Joel


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

* committed: Re: [patch] Add cleanup branch for std::terminate breakpoints  in  call_function_by_hand
  2009-10-01 16:44 ` Joel Brobecker
@ 2009-10-01 20:12   ` Phil Muldoon
  0 siblings, 0 replies; 3+ messages in thread
From: Phil Muldoon @ 2009-10-01 20:12 UTC (permalink / raw)
  To: Joel Brobecker; +Cc: gdb-patches ml

On 10/01/2009 05:44 PM, Joel Brobecker wrote:

Hi Joel,


>> 2009-10-01  Phil Muldoon<pmuldoon@redhat.com>
>>
>>      * infcall.c (call_function_by_hand): Add a new cleanup branch for
>>      std::terminate breakpoint.
>>      
> This is OK for the HEAD, except for one minor tiny comment:
>
>    
>> +  struct cleanup *terminate_bp_cleanup;
>>      
> Can you initialize this to NULL?
>    

Done, and committed. Thanks for the prompt review!

Regards

Phil


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

end of thread, other threads:[~2009-10-01 20:12 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2009-10-01 16:05 [patch] Add cleanup branch for std::terminate breakpoints in call_function_by_hand Phil Muldoon
2009-10-01 16:44 ` Joel Brobecker
2009-10-01 20:12   ` committed: " Phil Muldoon

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