[patch] try 2 - Do not allow unwinder to terminate inferior in an inferior function call if a C++ exception handler cannot be found.

Phil Muldoon pmuldoon@redhat.com
Tue Jun 9 10:56:00 GMT 2009


All,
> This patch addresses the bug detailed in gnats pr 2495 and after the 
> conversion to bugzilla: pr 9600
>
> Due to the method that GDB uses to construct a frame for an inferior 
> function call, the unwinder can terminate the inferior if it raises an 
> exception and relies on an out-of-frame handler to normally handle 
> that exception. For most systems GCC uses the exception handling 
> strategy documented here:  http://www.codesourcery.com/public/cxx-abi/ 
> . If the function that raises the exception relies on an out-of-frame 
> handler, the single dummy frame constructed by GDB for the inferior 
> function call does not allow the unwinder to walk the stack looking 
> for an appropriate handler. Briefly, if this happens the unwinder 
> terminates the inferior via a call to the default exception handler on 
> the (wrong) assumption that there is no user-created handler for the 
> exception.
>
> This patch addresses that by gating access to std::terminate in an 
> inferior function call. If it enters that function, it is popped back 
> to the calling state and "rescues" the inferior. This patch also adds 
> the functionality to turn this gating behaviour on or off. The default 
> is on.
>
> This patch applies cleanly to CVS GDB head. Tested on x8664 with no 
> regressions.

Further to Eli's and Joel's requested changes I am submitting this patch 
again for review. What do you think?

Regards

Phil

gdb/ChangeLog

2009-06-09  Phil Muldoon  <pmuldoon@redhat.com>

        * infcall.c (show_unwind_on_terminating_exception_p): New
        function.
        (call_function_by_hand): Create breakpoint and clean-up call for
        std::terminate.breakpoint. Add unwind_on_terminating_exception_p
        gate. Pop frame on breakpoint hit.
        (_initialize_infcall): Add add_setshow_boolean_cmd for
        unwind-on-terminating-exception.

gdb/testsuite/ChangeLog

2009-06-09  Phil Muldoon  <pmuldoon@redhat.com>

        * gdb.cp/gdb2495.cc: New file.
        * gdb.cp/gdb2495.exp: New file.

gdb/doc/ChangeLog

2009-06-09  Phil Muldoon  <pmuldoon@redhat.com>

        * doc/gdb.texinfo (Calling): Document
        set-unwind-on-terminating-exception usage.



-------------- next part --------------
A non-text attachment was scrubbed...
Name: unwind-terminating-excp.patch
Type: text/x-patch
Size: 16499 bytes
Desc: not available
URL: <http://sourceware.org/pipermail/gdb-patches/attachments/20090609/723c8567/attachment.bin>


More information about the Gdb-patches mailing list