From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 10107 invoked by alias); 17 Nov 2008 23:22:41 -0000 Received: (qmail 10018 invoked by uid 22791); 17 Nov 2008 23:22:40 -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; Mon, 17 Nov 2008 23:22:05 +0000 Received: (qmail 17188 invoked from network); 17 Nov 2008 23:22:03 -0000 Received: from unknown (HELO orlando.local) (pedro@127.0.0.2) by mail.codesourcery.com with ESMTPA; 17 Nov 2008 23:22:03 -0000 From: Pedro Alves To: gdb-patches@sourceware.org Subject: Re: RFC: Do not call write_pc for "signal SIGINT" Date: Tue, 18 Nov 2008 05:46:00 -0000 User-Agent: KMail/1.9.10 Cc: Daniel Jacobowitz , Michael Snyder References: <20080828155520.GA23110@caradoc.them.org> <20080828223232.GA6407@caradoc.them.org> <20081117215501.GA19975@caradoc.them.org> In-Reply-To: <20081117215501.GA19975@caradoc.them.org> MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit Content-Disposition: inline Message-Id: <200811172322.32422.pedro@codesourcery.com> 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/msg00453.txt.bz2 On Monday 17 November 2008 21:55:01, Daniel Jacobowitz wrote: > 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. This may help explain it better: /* Set the program counter for process PTID to PC. */ static void i386_linux_write_pc (struct regcache *regcache, CORE_ADDR pc) { regcache_cooked_write_unsigned (regcache, I386_EIP_REGNUM, pc); /* We must be careful with modifying the program counter. If we just interrupted a system call, the kernel might try to restart it when we resume the inferior. On restarting the system call, the kernel will try backing up the program counter even though it no longer points at the system call. This typically results in a SIGSEGV or SIGILL. We can prevent this by writing `-1' in the "orig_eax" pseudo-register. Note that "orig_eax" is saved when setting up a dummy call frame. This means that it is properly restored when that frame is popped, and that the interrupted system call will be restarted when we resume the inferior on return from a function call from within GDB. In all other cases the system call will not be restarted. */ regcache_cooked_write_unsigned (regcache, I386_LINUX_ORIG_EAX_REGNUM, -1); } -- Pedro Alves