From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 18361 invoked by alias); 17 Nov 2008 21:55:46 -0000 Received: (qmail 18261 invoked by uid 22791); 17 Nov 2008 21:55:45 -0000 X-Spam-Check-By: sourceware.org Received: from NaN.false.org (HELO nan.false.org) (208.75.86.248) by sourceware.org (qpsmtpd/0.31) with ESMTP; Mon, 17 Nov 2008 21:55:06 +0000 Received: from nan.false.org (localhost [127.0.0.1]) by nan.false.org (Postfix) with ESMTP id 511D610DB0; Mon, 17 Nov 2008 21:55:03 +0000 (GMT) Received: from caradoc.them.org (209.195.188.212.nauticom.net [209.195.188.212]) by nan.false.org (Postfix) with ESMTP id E9CC010D50; Mon, 17 Nov 2008 21:55:02 +0000 (GMT) Received: from drow by caradoc.them.org with local (Exim 4.69) (envelope-from ) id 1L2C3h-0000L4-Rq; Mon, 17 Nov 2008 16:55:01 -0500 Date: Tue, 18 Nov 2008 04:18:00 -0000 From: Daniel Jacobowitz To: Michael Snyder , gdb-patches@sourceware.org Subject: Re: RFC: Do not call write_pc for "signal SIGINT" Message-ID: <20081117215501.GA19975@caradoc.them.org> Mail-Followup-To: Michael Snyder , gdb-patches@sourceware.org References: <20080828155520.GA23110@caradoc.them.org> <48B6E9F4.5080403@vmware.com> <20080828181841.GA30866@caradoc.them.org> <48B6EFBD.2090203@vmware.com> <20080828223232.GA6407@caradoc.them.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20080828223232.GA6407@caradoc.them.org> User-Agent: Mutt/1.5.17 (2008-05-11) X-IsSubscribed: yes Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org X-SW-Source: 2008-11/txt/msg00448.txt.bz2 On Thu, Aug 28, 2008 at 06:32:32PM -0400, Daniel Jacobowitz wrote: > On Thu, Aug 28, 2008 at 11:34:37AM -0700, Michael Snyder wrote: > > More than a testcase. This isn't very well explained. > > You didn't reference the PR in your original post, and > > It was in the ChangeLog entry, sorry. Here it is with a testcase. To recap: there is a tricky bug in signal_command. If any non-zero signal is specified, it performs a jump to the current address instead of just resuming there. This causes any pending system call to be interrupted, in a way that leaves a kernel-internal value in the return value register. If we just delete that code, and the FIXME that goes with it, the right thing happens: instead of "Unknown error 514", the system call returns EINTR and the loop continues. Michael, is that clearer? -- Daniel Jacobowitz CodeSourcery 2008-11-17 Daniel Jacobowitz PR gdb/2241 * infcmd.c (signal_command): Do not specify a resume PC. 2008-11-17 Daniel Jacobowitz PR gdb/2241 * gdb.base/interrupt.c (sigint_handler): New. (main): Install a SIGINT handler if SIGNALS is defined. Exit on error. * gdb.base/interrupt.exp: Define SIGNALS unless gdb,nosignals. Test "signal SIGINT". Index: infcmd.c =================================================================== RCS file: /cvs/src/src/gdb/infcmd.c,v retrieving revision 1.222 diff -u -p -r1.222 infcmd.c --- infcmd.c 5 Nov 2008 20:23:07 -0000 1.222 +++ infcmd.c 17 Nov 2008 21:27:58 -0000 @@ -1147,11 +1147,7 @@ signal_command (char *signum_exp, int fr } clear_proceed_status (); - /* "signal 0" should not get stuck if we are stopped at a breakpoint. - FIXME: Neither should "signal foo" but when I tried passing - (CORE_ADDR)-1 unconditionally I got a testsuite failure which I haven't - tried to track down yet. */ - proceed (oursig == TARGET_SIGNAL_0 ? (CORE_ADDR) -1 : stop_pc, oursig, 0); + proceed ((CORE_ADDR) -1, oursig, 0); } /* Proceed until we reach a different source line with pc greater than Index: testsuite/gdb.base/interrupt.c =================================================================== RCS file: /cvs/src/src/gdb/testsuite/gdb.base/interrupt.c,v retrieving revision 1.1.1.2 diff -u -p -r1.1.1.2 interrupt.c --- testsuite/gdb.base/interrupt.c 28 Jun 1999 16:03:16 -0000 1.1.1.2 +++ testsuite/gdb.base/interrupt.c 17 Nov 2008 21:29:38 -0000 @@ -2,6 +2,16 @@ #include #include #include + +#ifdef SIGNALS +#include + +static void +sigint_handler (int signo) +{ +} +#endif + int main () { @@ -11,6 +21,9 @@ main () set_debug_traps(); breakpoint(); #endif +#ifdef SIGNALS + signal (SIGINT, sigint_handler); +#endif printf ("talk to me baby\n"); while (1) { @@ -20,7 +33,10 @@ main () #ifdef EINTR if (errno != EINTR) #endif - perror (""); + { + perror (""); + return 1; + } } else if (nbytes == 0) { Index: testsuite/gdb.base/interrupt.exp =================================================================== RCS file: /cvs/src/src/gdb/testsuite/gdb.base/interrupt.exp,v retrieving revision 1.12 diff -u -p -r1.12 interrupt.exp --- testsuite/gdb.base/interrupt.exp 6 Aug 2008 12:52:07 -0000 1.12 +++ testsuite/gdb.base/interrupt.exp 17 Nov 2008 21:29:38 -0000 @@ -34,7 +34,13 @@ set bug_id 0 set testfile interrupt set srcfile ${testfile}.c set binfile ${objdir}/${subdir}/${testfile} -if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug}] != "" } { + +set options { debug } +if { ! [target_info exists gdb,nosignals] } { + lappend options "additional_flags=-DSIGNALS" +} + +if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable $options] != "" } { untested interrupt.exp return -1 } @@ -165,7 +171,35 @@ if ![file exists $binfile] then { eof { fail "echo data (eof)" } } - setup_xfail "i*86-pc-linux*-gnu*" + if { ! [target_info exists gdb,nosignals] } { + # Wait until the program is in the read system call again. + sleep 2 + + # Stop the program for another test. + set msg "Send Control-C, second time" + send_gdb "\003" + gdb_test_multiple "" "$msg" { + -re "Program received signal SIGINT.*$gdb_prompt $" { + pass "$msg" + } + } + + # The "signal" command should deliver the correctg signal and + # return to the loop. + set msg "signal SIGINT" + gdb_test_multiple "signal SIGINT" "$msg" { + -re "^signal SIGINT\r\nContinuing with signal SIGINT.\r\n(\r\n|)$" { pass "$msg" } + } + + # We should be back in the loop. + send_gdb "more data\n" + gdb_expect { + -re "^(\r\n|)more data\r\n(|more data\r\n)$" { pass "echo more data" } + timeout { fail "echo more data (timeout)" } + eof { fail "echo more data (eof)" } + } + } + send_gdb "\004" gdb_expect { -re "end of file.*Program exited normally.*$gdb_prompt $" {