From: Pedro Alves <alves.ped@gmail.com>
To: gdb@sourceware.org
Cc: Michael Snyder <msnyder@vmware.com>,
"raja.saleru@iap-online.com" <raja.saleru@iap-online.com>
Subject: Re: command Ctrll-C
Date: Wed, 05 Nov 2008 12:03:00 -0000 [thread overview]
Message-ID: <200811051203.24490.alves.ped@gmail.com> (raw)
In-Reply-To: <49112B26.1090109@vmware.com>
On Wednesday 05 November 2008 05:12:06, Michael Snyder wrote:
> raja.saleru@iap-online.com wrote:
> > Hi,
> >
> > During program execution thought GDB, the execution can be stopped by
> > command Ctrll-C
> >
> > How it works internally in GDB source? Which function will be called after
> > user enters the command Ctrl-C ?
> >
> > Thanks in Advance
> > Raja Saleru
>
> Have a look at "handle_sigint" and "async_request_quit"
> in gdb/event-top.c.
Nope, sorry, that's used when there's no execution. It calls
quit(), doesn't interrupt the target at all.
If you're talking about native debugging, running a program
under GDB, not attached, then GDB "gives the terminal"
to the inferior (debuggee) (see target_terminal_inferior and friends)
whenever it is going to run it, so the ctrl-c hit while the inferior
is running is sent directly to the debuggee --- GDB is then informed
by ptrace that the inferior got a SIGINT (waitpid returns) (that is
the inferior sees the ctrl-c before gdb does in this case).
If talking about native debugging, attached to a program,
GDB installs a SIGINT handler that forwards the SIGINT to the inferior.
See set_sigint_trap/pass_signal in inflow.c/linux-nat.c for example.
If you go the to attachee's terminal and do a ctrl-c there, GDB will
be reported about a SIGINT just like the in native,non-attached case.
If talking about remote debugging, there are more steps involved depending
on the mode you're talking about, but, in the simplest and standard
mode (all-stop, sync), the idea is that GDB installs a SIGINT signal
handler that ends up passing an "out-of-band" interrupt "packet" to the
remote side (\\03). Then, when seeing this packet, the remote stub interrupts
its inferior (e.g., sends it a SIGINT) and then informs GDB that the remote
was interrupted with a regular stop reply. See remote_wait_as installing
remote_interrupt as SIGINT handler. When ctrl-c is done on GDB, this
handler then calls through async_remote_interrupt -> remote_stop_as -> serial_write (\\03).
--
Pedro Alves
next prev parent reply other threads:[~2008-11-05 12:03 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-11-05 4:40 raja.saleru
2008-11-05 5:19 ` Michael Snyder
2008-11-05 12:03 ` Pedro Alves [this message]
2008-11-05 16:59 ` Roland Puntaier
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=200811051203.24490.alves.ped@gmail.com \
--to=alves.ped@gmail.com \
--cc=gdb@sourceware.org \
--cc=msnyder@vmware.com \
--cc=raja.saleru@iap-online.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