public inbox for gdb@sourceware.org
 help / color / mirror / Atom feed
* subclass of gdb.Breakpoint - Is it possible to show an internal condition to the user?
@ 2021-06-27 18:57 Simon Sobisch
  0 siblings, 0 replies; only message in thread
From: Simon Sobisch @ 2021-06-27 18:57 UTC (permalink / raw)
  To: gdb

The GDB manual describes quite well how to subvlass gdb.Breakpoint and 
overwrite the stop method. This is very useful to implement conditions 
that need python code to execute, but it is something that is 
_additionally_ checked after the Breakpoint.condition was checked from GDB.

Using "info breakpoints" the user sees this condition, but not the 
internal one.

Comparision:

(gdb) b 36
Breakpoint 2 at 0x5555555562c5: file TESTB.c, line 36.
(gdb) info breakpoints
Num     Type           Disp Enb Address            What
2       breakpoint     keep y   0x00005555555562c5 in main at TESTB.c:36
(gdb) condition 2 argv=2
(gdb) info breakpoints
Num     Type           Disp Enb Address            What
2       breakpoint     keep y   0x00005555555562c5 in main at TESTB.c:36
         stop only if argv=2
(gdb) py
 >class MyBreakpoint (gdb.Breakpoint):
 >      def stop (self):
 >        inf_val = gdb.parse_and_eval("argv")
 >        if inf_val == 2:
 >          return True
 >        return False
 >end
(gdb) py MyBreakpoint("36")
Breakpoint 3 at 0x5555555562c5: file TESTB.c, line 36.
(gdb) info breakpoints
Num     Type           Disp Enb Address            What
2       breakpoint     keep y   0x00005555555562c5 in main at TESTB.c:36
         stop only if argv=2
3       breakpoint     keep y   0x00005555555562c5 in main at TESTB.c:36


So with the subclass of gdb.Breakpoint:

1 the user possibly creates a condition that will never work (like 
ccondition 3 argv=3 - > if that is true then the stop method would be 
called and return false, so that it will never stop)

2 the user has no option to see which class of a breakpoint it is (could 
he, other than iterating over the breakpoints and check their class via 
python?)

3 the user cannot see what possibly complex condition (which is the 
reasonable use case to subclass and overwrite stop) is actually checke


Question: Is it possible from the subclass to change the output of "info 
breakpoints" to show a note to the user, for example what complex 
condition is checked?
If not: Can I suggest a new writable attribute "Breakpoint.note" that 
would be shown after "stop only if"? This way the subclass could present 
the user with something, for example ["stop only if 
easy-looking-condition"].

Thanks for thoughts and answers,
Simon

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2021-06-27 18:57 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-06-27 18:57 subclass of gdb.Breakpoint - Is it possible to show an internal condition to the user? Simon Sobisch

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).