public inbox for gdb@sourceware.org
 help / color / mirror / Atom feed
From: Simon Sobisch <simonsobisch@gnu.org>
To: gdb@sourceware.org
Subject: subclass of gdb.Breakpoint - Is it possible to show an internal condition to the user?
Date: Sun, 27 Jun 2021 20:57:03 +0200	[thread overview]
Message-ID: <aa0f1c28-097b-5444-c788-bba05587601f@gnu.org> (raw)

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

                 reply	other threads:[~2021-06-27 18:57 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=aa0f1c28-097b-5444-c788-bba05587601f@gnu.org \
    --to=simonsobisch@gnu.org \
    --cc=gdb@sourceware.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).