From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 27425 invoked by alias); 5 Nov 2008 12:03:53 -0000 Received: (qmail 27342 invoked by uid 22791); 5 Nov 2008 12:03:53 -0000 X-Spam-Check-By: sourceware.org Received: from mail.codesourcery.com (HELO mail.codesourcery.com) (65.74.133.4) by sourceware.org (qpsmtpd/0.31) with ESMTP; Wed, 05 Nov 2008 12:03:16 +0000 Received: (qmail 7476 invoked from network); 5 Nov 2008 12:03:14 -0000 Received: from unknown (HELO orlando.local) (pedro@127.0.0.2) by mail.codesourcery.com with ESMTPA; 5 Nov 2008 12:03:14 -0000 From: Pedro Alves To: gdb@sourceware.org Subject: Re: command Ctrll-C Date: Wed, 05 Nov 2008 12:03:00 -0000 User-Agent: KMail/1.9.10 Cc: Michael Snyder , "raja.saleru@iap-online.com" References: <33036.210.143.35.19.1225860009.squirrel@www.iap-online.com> <49112B26.1090109@vmware.com> In-Reply-To: <49112B26.1090109@vmware.com> MIME-Version: 1.0 Content-Type: text/plain; charset="iso-2022-jp" Content-Transfer-Encoding: 7bit Content-Disposition: inline Message-Id: <200811051203.24490.alves.ped@gmail.com> X-IsSubscribed: yes Mailing-List: contact gdb-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-owner@sourceware.org X-SW-Source: 2008-11/txt/msg00035.txt.bz2 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