[PATCH] improve python finish breakpoint for exceptions/longjmp case.

Jan Kratochvil jan.kratochvil@redhat.com
Tue Oct 30 17:41:00 GMT 2012

On Thu, 25 Oct 2012 21:23:19 +0200, Andrew Burgess wrote:
> On 17/10/2012 5:27 PM, Jan Kratochvil wrote:
> > A countercase - I did not try to reproduce it in real:
> > 
> >  * You have breakpoint installed at TRACEDFUNC and you automatically use
> >    Python finish breakpoint to trace return values of TRACEDFUNC.
> >  * User at CALLERFUNC will type in GDB CLI "finish".
> >  * CALLERFUNC does a lot of processing and it also calls TRACEDFUNC.
> >  * Now you overwide tp->INITIATING_FRAME of the user "finish" command by
> >    null_frame_id which breaks the behavior in some way.
> I don't think this is a problem, the first finish will be cancelled when
> we stop for the second time in TRACEDFUNC. So, I think the chain of
> events will be:
>  - Stop in TRACEDFUNC, create a finish breakpoint setting
> tp->INITIATING_FRAME to null_frame_id.
>  - From the cli use "finish" command, change tp->INITIATING_FRAME.
>  - User continues.
>  - Recursively enter TRACEDFUNC, stopping.  The finish breakpoint is now
> cancelled.  At this point the first finish breakpoint is also cancelled,
> but this is a known bug at this point that I plan to work on later; and
> is no worse than current behaviour.
>  - User creates new finish breakpoint, setting tp->INITIATING_FRAME, but
> that's fine as we have no "finish" in play at this point.
> Let me know if I've got this wrong and you can see a problem, especially
> if you think I've broken /other/ commands, that would be worse than just
> leaving the finish breakpoint stuff with a few broken edge cases.

OK, I see my countercase was not right.

Anyway we agree it is not transparent to "finish" anyway but this is more
a problem there are no observer-like breakpoints:

==> finish.c <==
void g (void) {}
void f (void) {
  g ();
int main (void) {
  f ();
  return 0;

==> finish.cmd <==
file ./finish
break g
 echo hook-g\n


[Inferior 1 (process 13204) exited normally]
(gdb) _
main () at finish.c:7
7	  return 0;
(gdb) _

> > You want to install the "longjmp breakpoint" there by
> > set_longjmp_breakpoint_for_call_dummy.  You want to hook there
> > check_longjmp_breakpoint_for_call_dummy to call bpfinishpy_detect_out_scope_cb
> > in some way.  Currently you do it on stop but that is too late, breakpoint may
> > may have been for example placed at stack trampoline function (code at the
> > stack) and the breakpoint instruction now corrupts live stack data there.
> Hmmm, I see the problem, I'll work on that one.

Anyway the example above was given to convince you to the cleaner
check_longjmp_breakpoint_for_call_dummy solution.


More information about the Gdb-patches mailing list