From: Pedro Alves <pedro@codesourcery.com>
To: gdb-patches@sourceware.org
Cc: Tom Tromey <tromey@redhat.com>
Subject: Re: [RFC/WIP PATCH 09/14] I/T set support for breakpoints - trigger set, and stop set
Date: Fri, 16 Dec 2011 19:29:00 -0000 [thread overview]
Message-ID: <201112161924.12152.pedro@codesourcery.com> (raw)
In-Reply-To: <m37h2ik2os.fsf@fleche.redhat.com>
On Tuesday 29 November 2011 22:02:11, Tom Tromey wrote:
> >>>>> "Pedro" == Pedro Alves <pedro@codesourcery.com> writes:
>
> Pedro> This adds support for setting a breakpoint that only triggers on a
> Pedro> given set (a superset of the current thread specific breakpoints
> Pedro> support). In addition, it adds support for specifying the set of
> Pedro> threads that are suspended when the breakpoint is triggered.
>
> Pedro> Breakpoints need two sets. The trigger set, which is a generalization
> Pedro> of the "break foo thread N", meaning the set of inferiors/threads
> Pedro> where the breakpoint should fire, and, a suspend/stop set, which is
> Pedro> the set of inferiors/threads that should be suspended when the
> Pedro> breakpoint fires.
>
> What happens if the user types:
>
> [1.*] break function thread 3
The breakpoint triggers if the thread that hits it is both
in [1.*], and is thread 3.
> How about something contradictory like
>
> [.2] break function thread 3
Breakpoint never triggers. Given that the trigger set may well
be a dynamic set, it seems futile to try to detect such cases. Just
don't do it.
>
> Pedro> The trigger set of breakpoints is set from the current set at the time
> Pedro> the breakpoint is created. The stop set is passed explicitly as
> Pedro> optional switch. E.g.,:
>
> Pedro> [TRIGGER-SET] break [-stop [STOP-SET]] LINESPEC
>
> Pedro> This leaves LINESPEC last, so that we can keep supporting the current
> Pedro> form, but avoid more hacks in linespecs like the special termination
> Pedro> for "thread/task/if" in the lexers --- that wouldn't work for `['.
>
> Looks good to me. Overdue, even :-)
>
> Pedro> and, the stop set is inferred from the "set non-stop" global option.
> Pedro> If non-stop is on, only the thread that triggers the breakpoint should
> Pedro> be suspended; if non-stop is off, then all threads will be suspended
> Pedro> when the breakpoint fires.
>
> It seems to me that the stop set has to be a superset of the trigger
> set. Otherwise you get into a funny situation where a thread hits a
> breakpoint, causing only other threads to stop.
I've defined it such that the thread that triggered the breakpoint
always stops, even if it is not in the stop set. That meant that
and empty stop set is the same behavior as a breakpoint hit in
non-stop mode. The alternative, and because we can't know upfront
which thread will hit the breakpoint, is to have a special set
for the thread that triggered (or more generaly, the current thread),
e.g.:
[all] break -stop [@] LINESPEC
OTOH, `break -stop []' resuming the thread that hit the
breakpoint make the breakpoint look like a tracepoint. Hmm.
>
> Or maybe this is intentional? I can't picture a use for it myself,
> though.
E.g., when the event handling thread triggers this breakpoint (an
incoming event), stop everything in the DSP core. Or all in the
inferior that sent the event.
> Anyway, if this is a requirement, I think it should be enforced.
>
> Pedro> +static int
> Pedro> +bpstat_check_trigger_set (const struct breakpoint *b, struct thread_info *thread)
> Pedro> +{
> Pedro> + if (b->trigger_set == NULL)
> Pedro> + return 1;
> Pedro> +
> Pedro> + if (itset_contains_thread (b->trigger_set, thread))
> Pedro> + return 1;
> Pedro> +
> Pedro> + return 0;
>
> Delightfully simple. A couple notes though...
>
> First, I've been thinking we should probably make breakpoint re-setting
> more fine-grained. The idea would be to classify the events that
> current cause a re-set, giving them separate APIs in breakpoint.c, so
> that we can make re-setting more efficient.
Yeah, we've talked about that in the context of the objfile
sharing discussion, even IIRC.
> E.g., a new inferior should
> not cause a breakpoint to reset if the breakpoint cannot possibly match
> that inferior. I'm just trolling for your reaction to this.
Well, the reaction is "yes". :-)
> Second, a while back on gdb@ there was some talk of pushing
> thread-specific breakpoints to the target. This still seems like a good
> idea to me. I just wonder how this would interact with trigger sets,
> which are fairly general and which can depend on information known only
> to gdb, like the inferior numbering. I suppose one answer is, "use the
> 'thread' syntax for that".
Thread-specific breakpoints on the target would necessarily get the
GDB thread number translated to the target thread number. The target
never sees GDB thread numbers in any circunstance. Thread-specific
breakpoints are already specified with the GDB generic thread number
(break foo thread N). sets could be translated similarly. Even if
the translation isn't 1-1, it's sufficient that the stop set as
sent to the target is larger and includes the whole of the set
specified by the user. E.g., say we only support passing down one
thread id associated with a breakpoint. If the set is unambiguously
for that thread, great, pass that thread id down to the target along
with the breakpoint. If the breakpoint is set with a trigger set
that includes e.g., two threads, threads 1 and 2 of inferior 1,
select the next best target set that includes both of those threads.
That'd be, planting the breakpoint on the process of inferior 1 only,
but not in any other process, and have gdb transparently re-resume all
other threads if they trip on the breakpoint, just like thread-specific
breakpoints are handled today.
--
Pedro Alves
next prev parent reply other threads:[~2011-12-16 19:24 UTC|newest]
Thread overview: 53+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-11-28 15:39 [RFC/WIP PATCH 00/14] I/T sets Pedro Alves
2011-11-28 15:39 ` [RFC/WIP PATCH 01/14] Breakpoints always-inserted and the record target Pedro Alves
2011-11-29 21:09 ` Tom Tromey
2011-12-05 17:04 ` Pedro Alves
2011-11-28 15:39 ` [RFC/WIP PATCH 02/14] Mask software breakpoints from memory writes too Pedro Alves
2011-12-06 20:40 ` Pedro Alves
2011-12-13 21:26 ` Andreas Schwab
2011-12-13 21:38 ` Pedro Alves
2011-12-14 2:08 ` Andreas Schwab
2011-12-14 12:53 ` Pedro Alves
2011-12-14 12:53 ` Andreas Schwab
2011-12-14 15:06 ` Pedro Alves
2011-12-14 15:38 ` Joel Brobecker
2011-11-28 15:39 ` [RFC/WIP PATCH 03/14] Flip to set target-async on by default Pedro Alves
2011-11-29 21:18 ` Tom Tromey
2011-12-02 19:16 ` Marc Khouzam
2011-11-28 15:39 ` [RFC/WIP PATCH 05/14] Add a small helper to get at a thread's inferior Pedro Alves
2011-11-29 21:19 ` Tom Tromey
2011-11-28 15:40 ` [RFC/WIP PATCH 04/14] Implement all-stop on top of a target running non-stop mode Pedro Alves
2011-11-28 15:40 ` [RFC/WIP PATCH 13/14] Make "thread apply all" only loop over threads in the current set Pedro Alves
2011-11-28 18:40 ` Eli Zaretskii
2011-11-28 18:56 ` Pedro Alves
2011-11-29 21:47 ` Tom Tromey
2011-12-16 18:47 ` Pedro Alves
2011-11-28 15:40 ` [RFC/WIP PATCH 09/14] I/T set support for breakpoints - trigger set, and stop set Pedro Alves
2011-11-29 22:02 ` Tom Tromey
2011-11-30 19:38 ` Tom Tromey
2011-12-16 19:29 ` Pedro Alves [this message]
2011-11-28 15:40 ` [RFC/WIP PATCH 08/14] Add support for the '@' core operator Pedro Alves
2011-11-30 17:29 ` Tom Tromey
2011-11-28 15:40 ` [RFC/WIP PATCH 10/14] Comment out new info breakpoints output, in order to not break the test suite Pedro Alves
2011-11-28 15:40 ` [RFC/WIP PATCH 12/14] Fix deref of stale pointer Pedro Alves
2011-11-28 15:40 ` [RFC/WIP PATCH 07/14] Expand %ITSET% in the prompt to the current I/T set Pedro Alves
2011-11-29 21:22 ` Tom Tromey
2011-12-16 19:07 ` Pedro Alves
2011-12-16 19:09 ` Tom Tromey
2011-12-16 19:38 ` Pedro Alves
2011-11-28 15:45 ` [RFC/WIP PATCH 06/14] Add base itsets support Pedro Alves
2011-11-28 18:47 ` Eli Zaretskii
2011-11-28 18:56 ` Pedro Alves
2011-11-29 22:07 ` Tom Tromey
2011-11-30 18:54 ` Tom Tromey
2011-12-16 17:26 ` Pedro Alves
2011-11-28 15:45 ` [RFC/WIP PATCH 14/14] Fix manythreads.exp test Pedro Alves
2011-11-28 15:46 ` [RFC/WIP PATCH 11/14] Add I/T set support to most execution commands Pedro Alves
2011-11-30 19:27 ` Tom Tromey
2011-11-28 18:10 ` [RFC/WIP PATCH 00/14] I/T sets Pedro Alves
2011-11-30 19:35 ` Tom Tromey
2011-12-16 19:40 ` Pedro Alves
2012-02-09 7:51 ` Tomas Östlund
2012-02-09 8:19 ` [RFC/WIP PATCH 00/14] I/T sets (resend) Tomas Östlund
2012-02-09 14:36 ` Pedro Alves
2012-02-15 9:48 ` Tomas Östlund
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=201112161924.12152.pedro@codesourcery.com \
--to=pedro@codesourcery.com \
--cc=gdb-patches@sourceware.org \
--cc=tromey@redhat.com \
/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).