From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 22687 invoked by alias); 28 Nov 2006 19:01:51 -0000 Received: (qmail 22671 invoked by uid 22791); 28 Nov 2006 19:01:50 -0000 X-Spam-Check-By: sourceware.org Received: from mtagate4.de.ibm.com (HELO mtagate4.de.ibm.com) (195.212.29.153) by sourceware.org (qpsmtpd/0.31) with ESMTP; Tue, 28 Nov 2006 19:01:42 +0000 Received: from d12nrmr1607.megacenter.de.ibm.com (d12nrmr1607.megacenter.de.ibm.com [9.149.167.49]) by mtagate4.de.ibm.com (8.13.8/8.13.8) with ESMTP id kASJ1dJ1169778 for ; Tue, 28 Nov 2006 19:01:39 GMT Received: from d12av02.megacenter.de.ibm.com (d12av02.megacenter.de.ibm.com [9.149.165.228]) by d12nrmr1607.megacenter.de.ibm.com (8.13.6/8.13.6/NCO v8.1.1) with ESMTP id kASJ5Gcv2850946 for ; Tue, 28 Nov 2006 20:05:16 +0100 Received: from d12av02.megacenter.de.ibm.com (loopback [127.0.0.1]) by d12av02.megacenter.de.ibm.com (8.12.11.20060308/8.13.3) with ESMTP id kASJ1cZD016845 for ; Tue, 28 Nov 2006 20:01:38 +0100 Received: from tuxmaker.boeblingen.de.ibm.com (tuxmaker.boeblingen.de.ibm.com [9.152.85.9]) by d12av02.megacenter.de.ibm.com (8.12.11.20060308/8.12.11) with SMTP id kASJ1cld016839; Tue, 28 Nov 2006 20:01:38 +0100 Message-Id: <200611281901.kASJ1cld016839@d12av02.megacenter.de.ibm.com> Received: by tuxmaker.boeblingen.de.ibm.com (sSMTP sendmail emulation); Tue, 28 Nov 2006 20:01:38 +0100 Subject: Re: [PATCH] Fix for thread debugging in the presence of software single step To: drow@false.org (Daniel Jacobowitz) Date: Tue, 28 Nov 2006 19:01:00 -0000 From: "Ulrich Weigand" Cc: ngupta@mvista.com (Nitin Gupta), gdb@sourceware.org, jimb@codesourcery.com (Jim Blandy), rob.quill@gmail.com (Rob Quill) In-Reply-To: <20061128184749.GA26707@nevyn.them.org> from "Daniel Jacobowitz" at Nov 28, 2006 01:47:49 PM X-Mailer: ELM [version 2.5 PL2] MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit 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: 2006-11/txt/msg00199.txt.bz2 Daniel Jacobowitz wrote: > On Tue, Nov 28, 2006 at 10:41:59AM -0800, Nitin Gupta wrote: > > Following patch fixes for thread debugging in the presence of software > > single step: > > Only allow one thread to single-step if SOFTWARE_SINGLE_STEP_P () > > Patches go to the gdb-patches list, and should include a changelog > entry, please. What does this fix? I know some work's been done on > software single step plus threads. This is an interesting coincidence since we've been struggling with software single-step vs. threads issues in the Cell BE combined debugger over the last couple of weeks as well ;-) One problem we found is the following: if in addition to using software single-step, the platform also requires a non-zero decr_pc_after_break, things go wrong. In particular, if -while single-stepping- *another* thread hits a breakpoint, or some other event occurs, it may happen that the single-stepped thread runs onto the single-step breakpoint, but GDB never performs the PC adjustment. This leads to instructions simply being skipped in the inferior. The code in infrun.c only ever adjusts the PC for the current thread (which may be the other thread that was not single-stepped), and while there is code in linux-nat.c (cancel_breakpoints_callback) that does the PC adjustment for the non-current threads, this routine only handles regular breakpoints, not single-step breakpoints. I've fixed this in our local build by basically adding to the if (lp->status != 0 && WIFSTOPPED (lp->status) && WSTOPSIG (lp->status) == SIGTRAP && breakpoint_inserted_here_p (read_pc_pid (lp->ptid) - DECR_PC_AFTER_BREAK)) { condition a check whether a *software single-step* breakpoint is inserted at the PC location. However, this required adding a new function to breakpoint.c since there is currently no way to actually query that information ... Bye, Ulrich -- Dr. Ulrich Weigand GNU Toolchain for Linux on System z and Cell BE Ulrich.Weigand@de.ibm.com