From: Phil Muldoon <pmuldoon@redhat.com>
To: Eli Zaretskii <eliz@gnu.org>
Cc: gdb-patches@sourceware.org
Subject: Re: [patch] Add an evaluation function hook to Python breakpoints.
Date: Mon, 13 Dec 2010 14:47:00 -0000 [thread overview]
Message-ID: <m3bp4p686y.fsf@redhat.com> (raw)
In-Reply-To: <8362uxiwmc.fsf@gnu.org> (Eli Zaretskii's message of "Mon, 13 Dec 2010 16:19:07 +0200")
Eli Zaretskii <eliz@gnu.org> writes:
>> From: Phil Muldoon <pmuldoon@redhat.com>
>> Date: Mon, 13 Dec 2010 13:50:36 +0000
>> +class. The @code{gdb.Breakpoint} class can be sub-classed and, in
>> +particular, you may choose to implement the @code{evaluate} function.
>> +If this function is defined it will be called when the inferior reaches
>> +that breakpoint.
>
> Which "that breakpoint" are you talking about here? Perhaps you meant
> this:
>
> If this function is defined for a breakpoint, it will be called when
> the inferior reaches that breakpoint.
>
> ? If so, the text is clear, but then this interpretation doesn't seem
> to be consistent with the example you give.
I'm not sure what you mean here. Given the example in the patch, you
can instantiate any number of those breakpoints.
So
+class MyBreakpoint (gdb.Breakpoint):
+ def evaluate (self):
+ inf_val = gdb.parse_and_eval("foo")
+ if inf_val == 3:
+ return True
+ return False
There are two scenarios where the breakpoints would be executed. The first
is where you would end up instantiating two instances of the above
breakpoint at the same location:
python bp1 = MyBreakPoint("myfile.c:42")
python bp2 = MyBreakpoint("myfile.c:42", internal=True)
And the other where you would have two dissimilar breakpoints at the same
location:
e.g,
+class MyBreakpoint2 (gdb.Breakpoint):
+ def evaluate (self):
+ inf_val = gdb.parse_and_eval("bar")
+ if inf_val == 5:
+ return True
+ return False
python bp1 = MyBreakPoint("myfile.c:42")
python bp2 = MyBreakpoint2("myfile.c:42")
Does that help explain? I'm opening to wording it however makes the most
sense.
>> +@code{True}, the inferior will be stopped at the location of the
>> +breakpoint. Otherwise if the function returns @code{False} the
>> +inferior will continue.
>
> Either "otherwise", or "if it returns False"; using both is redundant.
Ok, thanks.
>> + The @code{evaluate} function should not
>> +attempt to influence the state of the inferior (e.g., step) or
>> +otherwise alter its data.
>
> Sounds like a non-trivial limitation; is it really necessary?
I mentioned it as it was a non-trivial limitation? It is something the user
should not do in the evaluate function. The most pressing reason is
that there may be other breakpoints to be checked at that location so
the state of the inferior should remain. The other is it is just bad
business influencing the inferior position (i.e., stepping) when
breakpoint evaluation is being performed. At least to me. This is all
well and good, but we cannot prevent the user from doing it; just tell
them it is very bad idea. ;)
>> +If there are multiple breakpoints at the same location with an
>> +@code{evaluate} function, each one will be called regardless of the
>> +return status of the previous.
>
> Do we have anything to say regarding the order of the calls?
I'm not sure, as there is no mention I could find in the manual
regarding the conditional evaluation order of breakpoints. I believe
they are called in the order of creation. Maybe Pedro knows. But as
breakpoint ordering is not mentioned anywhere else, and as all the
evaluation functions at that location will be called regardless, I
decided not to mention it.
Cheers,
Phil
next prev parent reply other threads:[~2010-12-13 14:47 UTC|newest]
Thread overview: 36+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-12-13 13:50 Phil Muldoon
2010-12-13 14:19 ` Eli Zaretskii
2010-12-13 14:47 ` Phil Muldoon [this message]
2010-12-13 15:07 ` Eli Zaretskii
2010-12-13 17:21 ` Phil Muldoon
2010-12-13 17:46 ` Eli Zaretskii
2010-12-13 14:33 ` Pedro Alves
2010-12-13 14:56 ` Phil Muldoon
2010-12-13 15:07 ` Pedro Alves
2010-12-13 20:45 ` Doug Evans
2010-12-13 21:02 ` Phil Muldoon
2010-12-14 3:31 ` Doug Evans
2010-12-14 17:18 ` Phil Muldoon
2010-12-14 17:28 ` Tom Tromey
2010-12-14 19:51 ` Phil Muldoon
2010-12-14 20:00 ` Phil Muldoon
2010-12-15 15:34 ` Phil Muldoon
2010-12-15 20:51 ` Tom Tromey
2011-01-27 12:44 ` Phil Muldoon
[not found] ` <AANLkTimi6ugruNAqUGHni8Kvkz+B5-s2aAkEoTY2D_gT@mail.gmail.com>
2011-01-27 21:40 ` Phil Muldoon
2011-01-28 10:42 ` Tom Tromey
2010-12-15 16:21 ` Doug Evans
2010-12-15 20:57 ` Tom Tromey
2010-12-21 17:33 ` Doug Evans
2010-12-21 20:02 ` Tom Tromey
2010-12-22 16:34 ` Doug Evans
2010-12-22 17:35 ` Tom Tromey
2010-12-28 5:53 ` Doug Evans
2011-01-05 18:35 ` Tom Tromey
2011-01-05 20:23 ` Phil Muldoon
2011-01-09 20:32 ` Doug Evans
2010-12-14 17:46 ` Pedro Alves
2010-12-14 16:35 ` Tom Tromey
2010-12-14 17:02 ` Phil Muldoon
2010-12-14 17:48 ` Tom Tromey
2010-12-14 16:42 ` Tom Tromey
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=m3bp4p686y.fsf@redhat.com \
--to=pmuldoon@redhat.com \
--cc=eliz@gnu.org \
--cc=gdb-patches@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