From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 24721 invoked by alias); 24 Jul 2010 22:26:16 -0000 Received: (qmail 24710 invoked by uid 22791); 24 Jul 2010 22:26:15 -0000 X-SWARE-Spam-Status: No, hits=-2.0 required=5.0 tests=AWL,BAYES_00,T_RP_MATCHES_RCVD X-Spam-Check-By: sourceware.org Received: from mail.codesourcery.com (HELO mail.codesourcery.com) (38.113.113.100) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Sat, 24 Jul 2010 22:26:10 +0000 Received: (qmail 24023 invoked from network); 24 Jul 2010 22:26:08 -0000 Received: from unknown (HELO orlando.localnet) (pedro@127.0.0.2) by mail.codesourcery.com with ESMTPA; 24 Jul 2010 22:26:08 -0000 From: Pedro Alves To: Jan Kratochvil Subject: Re: [patch] Fix linux-ia64 on SIGILL for deleted breakpoint Date: Sat, 24 Jul 2010 22:26:00 -0000 User-Agent: KMail/1.13.2 (Linux/2.6.31-11-rt; KDE/4.4.2; x86_64; ; ) Cc: gdb-patches@sourceware.org References: <20100719085817.GA24395@host1.dyn.jankratochvil.net> <201007201428.59184.pedro@codesourcery.com> <20100723221935.GA7020@host1.dyn.jankratochvil.net> In-Reply-To: <20100723221935.GA7020@host1.dyn.jankratochvil.net> MIME-Version: 1.0 Content-Type: Text/Plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit Message-Id: <201007242326.05269.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: 2010-07/txt/msg00381.txt.bz2 On Friday 23 July 2010 23:19:35, Jan Kratochvil wrote: > This SIGTRAP->SIGILL case happens only on ia64 and ia64 does not use any > set_gdbarch_decr_pc_after_break at all, PC stays on the breakpoint bundle+slot > in both the SIGTRAP and SIGILL case. > > You are right it is arch-specific. On i386 I checked SIGILL is never > generated (only in some fpu-emulated code). So I checked s390x-linux-gnu:: > SIGILL on opcode 0xb29e > si_addr = 0x800009a4 > .psw.addr = 0x800009a8 > instr at = 0x800009a4 > .psw.addr - instr == 4 Oh? Does this mean the PC is left pointing _after_ the instruction that caused the SIGILL? I think you still need to audit other bits in linux-nat.c for SIGTRAP bkpts handling. E.g., see stop_wait_callback. (For extra correctness, count_events_callback, and the select_event_lwp_callback functions would be relaxed too.) I wasn't previously suggesting to make this ia64 arch specific, which made fixing these other places too easier. Notice how gdbserver/linux-low.c also considers non-sigtrap bkpts (and it was a recent change, needed for ARM thumb2 kernels that hadn't learned about the breakpoint insns yet, IIRC). > --- a/gdb/ia64-linux-nat.c > +++ b/gdb/ia64-linux-nat.c > @@ -809,6 +809,26 @@ ia64_linux_xfer_partial (struct target_ops *ops, > offset, len); > } > > +/* For break.b instruction ia64 CPU forgets the immediate value and generates > + SIGILL with ILL_ILLOPC instead of more common SIGTRAP with TRAP_BRKPT. */ > + > +static int > +ia64_linux_cancel_breakpoint (struct lwp_info *lp) > +{ > + /* We check for lp->waitstatus in addition to lp->status, because we can > + have pending process exits recorded in lp->status > + and W_EXITCODE(0,0) == 0. We should probably have an additional > + lp->status_p flag. */ > + > + if (! (lp->waitstatus.kind == TARGET_WAITKIND_IGNORE > + && WIFSTOPPED (lp->status) > + && (WSTOPSIG (lp->status) == SIGTRAP > + || WSTOPSIG (lp->status) == SIGILL))) > + return 0; > + > + return linux_nat_cancel_breakpoint_when_signalled (lp); If this stays, please add a comment above this call mentioning that we can safely call this function even for SIGILL, since decr_pc_after_break is 0 on ia64. (Alternatively, recode to avoid the assumption) The point I'm making is that PC adjustment is always only necessary for sigtraps, never other signals (and is in fact wrong for other signals). -- Pedro Alves