an internal error occurs when you try to `delete' a breakpoint during `stop' callback: class MyBP(gdb.Breakpoint): def stop(self): self.delete() (gdb) python MyBP(spec="main") (gdb) run Starting program: /home/kevin/a.out /home/kevin/travail/srcs/git/gdb/gdb/breakpoint.c:4573: internal-error: bpstat_what: unhandled bptype -1120308712 A problem internal to GDB has been detected, further debugging may prove unreliable. Quit this debugging session? (y or n)
I cannot replicate this, can you still replicate it Kevin? (gdb) file ~/simple (gdb) python >class b(gdb.Breakpoint): > def stop(self): > print "hello" > self.delete() >end (gdb) py bp = b("main") Breakpoint 1 at 0x400c48: file simple.c, line 4. (gdb) r hello [Inferior 1 (process 715) exited normally] (gdb) info breakpoints No breakpoints or watchpoints.
> I cannot replicate this, can you still replicate it Kevin? no :) I double checked, GNU gdb (GDB) Fedora (7.3-43.fc15) does have the bug, so it was solved by the magic of time! Thanks for looking at it
I'm going to change this to wontfix. Because there may be other stop() callbacks yet to be processed on that breakpoint, you should not alter or delete the state of breakpoints. I've submitted a manual patch to explain what you can, or cannot do.
is this a good alternative ? class MyBP(gdb.Breakpoint): def stop(self): gdb.post_event(self.delete) the documentation of gdb.post_event seems not very clear if you don't look at what is done internally -- I didn't -- but I think it should be safe to do it this way
CVSROOT: /cvs/src Module name: src Changes by: pmuldoon@sourceware.org 2011-10-07 13:23:19 Modified files: gdb/doc : ChangeLog gdb.texinfo Log message: 2011-10-07 Phil Muldoon <pmuldoon@redhat.com> PR python/12930 PR python/12802 * gdb.texinfo (Breakpoints In Python): Clarify behavior in the stop method. Patches: http://sourceware.org/cgi-bin/cvsweb.cgi/src/gdb/doc/ChangeLog.diff?cvsroot=src&r1=1.1221&r2=1.1222 http://sourceware.org/cgi-bin/cvsweb.cgi/src/gdb/doc/gdb.texinfo.diff?cvsroot=src&r1=1.870&r2=1.871
Yes, I believe so. But you are still in very dangerous waters. What happened if you deleted the breakpoint, but returned "True" from that function. At the very least any breakpoint event notification would be broken. GDB would call breakpoint stopped observers, but would not have a breakpoint to reference. There is nothing to stop you doing it in your scripts, but I would really be very careful.
(In reply to comment #4) > is this a good alternative ? > > class MyBP(gdb.Breakpoint): > def stop(self): > gdb.post_event(self.delete) I think so. > the documentation of gdb.post_event seems not very clear if you don't look at > what is done internally -- I didn't -- but I think it should be safe to do it > this way Can you suggest how to fix the docs?