From: Joel Brobecker <brobecker@adacore.com>
To: "Amker.Cheng" <amker.cheng@gmail.com>
Cc: gdb@sourceware.org, paawan1982@yahoo.com, teawater <teawater@gmail.com>
Subject: Re: What happened in gdb between handle_sigint and async_request_quit?
Date: Fri, 06 Feb 2009 16:43:00 -0000 [thread overview]
Message-ID: <20090206164254.GZ3683@adacore.com> (raw)
In-Reply-To: <e8b251c80902060714k36a67d84neb5a63862430ed07@mail.gmail.com>
> both of GDB and Debuggee will get the event. Windows will report DBG_CONTROL_C
> exception to GDB, which was turned into TARGET_SIGNAL_INT in GDB.
> According to MSDN, this is the First Chance Exception!
The situation on Windows is different from the situation on Unix.
On Unix, we give the terminal back to the inferior while the inferior
is running. So, when a user presses Ctrl-c, only the inferior gets
the signal. This signal triggers a debug event to GDB and suspends
the inferior, and GDB treats this signal as it would treat any other
signal. On Windows, things are a little trickier, because the inferior
and GDB might be running in the same console. This means that, when
the user presses Ctrl-c, then *both* GDB and the inferior get the
associated signal. But we don't actually want GDB to receive the signal,
so we simply temporarily ignore all Ctrl-C signals in GDB while the
inferior is waiting:
/* Ignore CTRL+C signals while waiting for a debug event.
FIXME: brobecker/2008-05-20: When the user presses CTRL+C while
the inferior is running, both the inferior and GDB receive the
associated signal. If the inferior receives the signal first
and the delay until GDB receives that signal is sufficiently long,
GDB can sometimes receive the SIGINT after we have unblocked
the CTRL+C handler. This would lead to the debugger to stop
prematurely while handling the new-thread event that comes
with the handling of the SIGINT inside the inferior, and then
stop again immediately when the user tries to resume the execution
in the inferior. This is a classic race, and it would be nice
to find a better solution to that problem. But in the meantime,
the current approach already greatly mitigate this issue. */
SetConsoleCtrlHandler (NULL, TRUE);
retval = get_windows_debug_event (pid, ourstatus);
SetConsoleCtrlHandler (NULL, FALSE);
The code above assumes that the inferior and GDB are running in
the same console, which is not always the case. Currently, when
this is the case, the only way to interrupt your program is by
pressing Ctrl-c in the console where your program is running.
There is patch pending that enhances GDB to handle the case when
the inferior is running in a separate console.
--
Joel
next prev parent reply other threads:[~2009-02-06 16:43 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-02-05 12:31 Amker.Cheng
2009-02-05 16:13 ` teawater
2009-02-05 16:25 ` paawan oza
2009-02-06 9:14 ` Amker.Cheng
2009-02-06 15:14 ` Amker.Cheng
2009-02-06 16:43 ` Joel Brobecker [this message]
2009-02-07 10:08 ` Amker.Cheng
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=20090206164254.GZ3683@adacore.com \
--to=brobecker@adacore.com \
--cc=amker.cheng@gmail.com \
--cc=gdb@sourceware.org \
--cc=paawan1982@yahoo.com \
--cc=teawater@gmail.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