From: Joel Brobecker <brobecker@adacore.com>
To: Eli Zaretskii <eliz@gnu.org>
Cc: gdb@sources.redhat.com
Subject: Re: Switching to thread
Date: Fri, 09 May 2008 16:43:00 -0000 [thread overview]
Message-ID: <20080509164248.GR7421@adacore.com> (raw)
In-Reply-To: <uej8bnccs.fsf@gnu.org>
> The announcements can be controlled by "set print thread-events", but
> what about the switching to the new thread? can I tell GDB not to
> switch to it, but rather stay with the one it was before, or is this
> somehow hard-wired in the code?
I don't think the debugger is actually switching to the new thread
when reacting to a new-thread event (while doing the target_wait).
When the new thread is created, win32_wait indeed returns the pid
of the new thread, but handle_for_inferior_event immediately resumes
the execution without changing inferior_ptid.
> The specific use case where this is important is interrupting an
> inferior that appears to be hung with Ctrl-C: on Windows, this creates
> a new thread which runs the SIGINT handler, but I don't normally want
> to see this thread; instead, I want to know where is the mainline code
> looping. Of course, "thread 1" is all I need to do, but it's easy to
> forget, especially if you did a lot of debugging on something other
> than Windows before that ;-)
What happens in this case is that, after the new thread was created
(and GDB resumed it without having switched to that thread), this new
thread receives the SIGINT. Check case EXCEPTION_DEBUG_EVENT inside
get_win32_debug_event():
switch (handle_exception (ourstatus))
{
[...]
case 1:
retval = current_event.dwThreadId;
The retval is the thread_id that we then use in win32_nat
to build the ptid returned to the infrun module.
We might be able to avoid that thread switch during Control-C
event by tweaking current_event.dwThreadId to use the thread
id of the inferior_ptid - so as a result, GDB will think that
the SIGINT was received by the current thread rather than
the handler thread. But I'm really not sure about that. Although
practical, it feels like we're lying a little to the user, since
the SIGINT was received by the handler thread, right?
--
Joel
next prev parent reply other threads:[~2008-05-09 16:43 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-05-09 7:53 Eli Zaretskii
2008-05-09 16:43 ` Joel Brobecker [this message]
2008-05-09 20:44 ` Eli Zaretskii
2008-05-09 19:20 ` Michael Snyder
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=20080509164248.GR7421@adacore.com \
--to=brobecker@adacore.com \
--cc=eliz@gnu.org \
--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