[RFC] Python Finish Breakpoints
Kevin Pouget
kevin.pouget@gmail.com
Fri Jan 27 17:01:00 GMT 2012
On Mon, Jan 9, 2012 at 10:20 AM, Kevin Pouget <kevin.pouget@gmail.com> wrote:
> On Wed, Jan 4, 2012 at 6:12 PM, Ulrich Weigand <uweigand@de.ibm.com> wrote:
>> Tom Tromey wrote:
>>
>>> We have support for "finish", and other operations in the presence of
>>> exceptions. Search for _Unwind_DebugHook (in breakpoint.c and infrun.c).
>>> This code only works if you are using a new-enough version of GCC and
>>> have debuginfo for libgcc (but once the stap probe patches are in, you
>>> will no longer need debuginfo).
>>
>> Ah, I see -- that's what I was missing. Yes, this looks like the
>> way to handle this situation ...
>
> Hello,
>
> I would like to discuss this patch which intends to fix and improve
> the handling for c++ exceptions with the Python FinishBreakpoint.
>
> Based on what I understood of the existing mechanisms which handle
> longjmps and and exception, I extended the "momentary breakpoints"
> with a "nostop" flag. Indeed, their initial behavior/goal was to stop
> unconditionally the execution, whereas I just wanted to receive a
> notification when the relevant code location was hit (namely
> infrun.c::BPSTAT_WHAT_CLEAR_LONGJMP_RESUME). The nostop flag is
> propagated step by step (bp by bp) from the exception throw to its
> catchpoint, where I check if the FinishBreakpoint have ran out of
> their scope.
>
> As Tom mentioned, c++ debug info are needed for this machinery to work
> (otherwise, FinishBreakpoint will fail the same way GDB fails: stop at
> the beginning of the catch(), never stop, ...) -- I used xfail in the
> testsuite to refer to this situation, I'm not sure that's correct).
>
> I've also fixed a bug which triggered twice the out_of_scope
> notification in case of inferior exit (observer_attach_normal_stop and
> observer_attach_inferior_exit are both triggered when the inferior
> exits)
>
> (This is just a preliminary patch, I'll would like to prepare some
> more tests with exceptions and longjmps)
>
> Tested with no regression on f15/X86_64
>
> ( these always fail on my system:
> Running PATH/git/gdb/gdb/testsuite/gdb.base/longjmp.exp ...
> FAIL: gdb.base/longjmp.exp: next over longjmp(1)
> FAIL: gdb.base/longjmp.exp: next over call_longjmp (2)
> FAIL: gdb.base/longjmp.exp: next over patt3
> )
>
> Thanks for your comments,
>
> Kevin
>
> --
>
> 2012-01-09 Kevin Pouget <kevin.pouget@st.com>
>
> * breakpoint.c (momentary_nostop_breakpoint_ops): New variable.
> (bpstat_what): Set field retval.is_nostop when necessary.
> (set_longjmp_breakpoint): Add parameter nostop and create nostop
> momentary breakpoint ops if necessary.
> (set_momentary_breakpoint): Likewise.
> (set_momentary_breakpoint_at_pc): Likewise.
> (momentary_breakpoint_is_nostop): New function.
> (until_break_command): Call set_momentary_breakpoint and
> set_longjmp_breakpoint with nostop not set.
> (momentary_stop_bkpt_check_status): Rename from
> momentary_bkpt_check_status.
> (momentary_bkpt_check_status): Remove.
> (momentary_nostop_bkpt_check_status): New function.
> (initialize_breakpoint_ops): Initialize
> momentary_breakpoint_ops.check_status to
> momentary_stop_bkpt_check_status, initialize
> momentary_nostop_breakpoint_ops.
> * breakpoint.h (struct bpstat_what): New field: is_nostop.
> (set_momentary_breakpoint): New parameter: nostop.
> (set_momentary_breakpoint_at_pc): Liklewise.
> (set_longjmp_breakpoint): Likewise.
> (momentary_breakpoint_is_nostop): New prototype.
> * arm-linux-tdep.c (arm_linux_copy_svc): Add nostop parameter to
> set_momentary_breakpoint call.
> * elfread.c: (elf_gnu_ifunc_resolver_stop): Likewise
> * infcall.c (call_function_by_hand): Likewise.
> * infcmd.c: (finish_forward): Likewise, add nostop parameter to
> set_longjmp_breakpoint call.
> (step_1): Add nostop parameter to set_longjmp_breakpoint call.
> (until_next_command): Likewise.
> * infrun.c: Include python/python.h.
> (insert_step_resume_breakpoint_at_sal_1): Add nostop parameter to
> set_momentary_breakpoint call.
> (insert_longjmp_resume_breakpoint): Add nostop parameter to prototype.
> Add nostop parameter to set_momentary_breakpoint_at_pc call.
> (insert_exception_resume_breakpoint): Likewise.
> (check_exception_resume): Add nostop parameter to prototype. Add nostop
> parameter to insert_exception_resume_breakpoint call.
> (process_event_stop_test): Set and use nostop to prevent GDB from
> stopping the execution, trigger gdbpy_bpfinish_handle_exception when
> necessary.
> * python/py-finishbreakpoint.c (bpfinishpy_init): Call
> set_longjmp_breakpoint.
> (bpfinishpy_detect_out_scope): Renamed from
> bpfinishpy_detect_out_scope_cb. Cleaned up. Add inc_current parameter.
> (bpfinishpy_detect_out_scope_cb): Removed.
> (bpfinishpy_detect_out_scope_bp_cb): New function.
> (bpfinishpy_detect_out_scope_exception_cb): New function.
> (bpfinishpy_handle_stop): Update with function name
> bpfinishpy_detect_out_scope_bp_cb.
> (bpfinishpy_handle_exit): Removed.
> (gdbpy_bpfinish_handle_exception): New function.
> (gdbpy_initialize_finishbreakpoints): Remove call to
> bpfinishpy_handle_exit.
> * python/python.c (gdbpy_bpfinish_handle_exception): New function.
> * python/python.h (gdbpy_bpfinish_handle_exception): New prototype.
>
> testsuite/
> * gdb.python/py-finish-breakpoint2.exp: Strengthen the exception tests.
ping
More information about the Gdb-patches
mailing list