From: Vladimir Prus <vladimir@codesourcery.com>
To: gdb@sources.redhat.com
Subject: Re: "thread", "thread apply" and "step" ?
Date: Wed, 06 Aug 2008 05:17:00 -0000 [thread overview]
Message-ID: <g7bc45$jes$1@ger.gmane.org> (raw)
In-Reply-To: <1217997625.3549.662.camel@localhost.localdomain>
Michael Snyder wrote:
> On Tue, 2008-08-05 at 16:11 -0400, Rich Wagner wrote:
>> I haven't been able to find an "official" GDB spec which answers a
>> question I have, relating to threads and stepping, so...
>>
>>
>> Say your program has two threads, A and B, and that B most recently hit
>> a breakpoint.
>>
>> It's pretty clear (and my experiments have shown) that if you then
>> simply execute "step", then the step occurs in B. That is, both threads
>> resume execution, with both threads suspending again when B reaches the
>> "end-of-step" boundary. So far, so good...
>>
>> However, things become less clear, and non-intuitive, if after B hits a
>> breakpoint, and I then use:
>>
>> thread A
>> step
>
> The short answer is "don't do that".
>
> What I *wanted* to say is "you can't do that".
> The problem is, as you have discovered, you can --
> it just doesn't have the effect that you think it should.
>
> GDB's "thread" command will specify a thread to which
> subsequent state queries will apply (eg. "info register").
>
> But GDB does not exercise any control over the operating
> system's thread scheduling, therefore GDB has no control
> over which thread will actually run when you say "step"
> or "continue". You might think it should be the thread
> that you last selected -- but it won't. It will be the
> thread that the operating system chooses (generally the
> one that was most recently running).
Well, with scheduler locking on, it should be the thread that
is selected. More specifically, the call to target_resume should
be passed the ptid of the selected thread. For native linux, this
indeed has the effect of resuming the right thread. Further, in
non-stop mode scheduler locking is implicitly on, so:
-exec-continue --thread N
will always resume just thread N, without changing the state of any
other thread.
A target that is neither linux nor remote can, in theory, ignore the ptid
passed to target_resume. I don't know if such targets exist or not.
- Volodya
prev parent reply other threads:[~2008-08-06 5:17 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-08-05 20:11 Rich Wagner
2008-08-05 20:24 ` Daniel Jacobowitz
2008-08-06 4:42 ` Michael Snyder
2008-08-06 11:20 ` Daniel Jacobowitz
2008-08-06 12:45 ` Pedro Alves
2008-08-06 17:38 ` Rich Wagner
2008-08-06 4:41 ` Michael Snyder
2008-08-06 5:17 ` Vladimir Prus [this message]
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='g7bc45$jes$1@ger.gmane.org' \
--to=vladimir@codesourcery.com \
--cc=gdb@sources.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