From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 21229 invoked by alias); 10 May 2007 21:31:06 -0000 Received: (qmail 21216 invoked by uid 22791); 10 May 2007 21:31:03 -0000 X-Spam-Check-By: sourceware.org Received: from mtagate3.de.ibm.com (HELO mtagate3.de.ibm.com) (195.212.29.152) by sourceware.org (qpsmtpd/0.31) with ESMTP; Thu, 10 May 2007 21:30:57 +0000 Received: from d12nrmr1607.megacenter.de.ibm.com (d12nrmr1607.megacenter.de.ibm.com [9.149.167.49]) by mtagate3.de.ibm.com (8.13.8/8.13.8) with ESMTP id l4ALUs2o128716 for ; Thu, 10 May 2007 21:30:54 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.8/8.13.8/NCO v8.3) with ESMTP id l4ALUsmQ4165682 for ; Thu, 10 May 2007 23:30:54 +0200 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 l4ALUrgN017720 for ; Thu, 10 May 2007 23:30:54 +0200 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 l4ALUrjf017717; Thu, 10 May 2007 23:30:53 +0200 Message-Id: <200705102130.l4ALUrjf017717@d12av02.megacenter.de.ibm.com> Received: by tuxmaker.boeblingen.de.ibm.com (sSMTP sendmail emulation); Thu, 10 May 2007 23:30:53 +0200 Subject: Re: [RFC] "single step" atomic instruction sequences as a whole on PPC To: emi-suzuki@tjsys.co.jp (Emi SUZUKI) Date: Thu, 10 May 2007 21:31:00 -0000 From: "Ulrich Weigand" Cc: jan.kratochvil@redhat.com, luisgpm@linux.vnet.ibm.com, gdb-patches@sourceware.org In-Reply-To: <20070510.195725.01365398.emi-suzuki@tjsys.co.jp> from "Emi SUZUKI" at May 10, 2007 07:57:25 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-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: 2007-05/txt/msg00167.txt.bz2 Hello Emi-san, > When that multiple SIGTRAP events occured, GDB selects one event and > cancels the other if the cause of SIGTRAP is a breakpoint hit, or just > leave it pended. The procedure will be done by `cancel_breakpoints_callback' > in linux-nat.c. And the pended events will be deteced and noticed > when the next time the target resumes. > > The probrem is that GDB doesn't check if the breakpoint is inserted > for software single stepping when cancelling the trap event: when the > event occured by a software single step breakpoint is not selected, > GDB would not cancel it but leave it pended. This is cancel_breakpoints_callback in linux-nat.c, right? > When the next time the target resumes, GDB restores the pended event. > But if you have removed the watchpoint that the target get stopped by > before resuming, GDB can never decide the cause of SIGTRAP anymore. > The session log above shows the phenomenon. This looks just like a problem we fixed for the combined debugger; cancel_breakpoints_callback should cancel SIGTRAP events caused by software single-step breakpoints just the same as those caused by other breakpoints. Can you try whether the following patch fixes the problem for you? Bye, Ulrich ChangeLog: * breakpoint.c (single_step_breakpoint_inserted_here_p): New function. * breakpoint.h (single_step_breakpoint_inserted_here_p): New prototype. * linux-nat.c (cancel_breakpoints_callback): Treat software single- step breakpoints the same way as regular software breakpoints. diff -urNp gdb-orig/gdb/breakpoint.c gdb-head/gdb/breakpoint.c --- gdb-orig/gdb/breakpoint.c 2007-05-08 14:37:32.000000000 +0200 +++ gdb-head/gdb/breakpoint.c 2007-05-10 22:34:36.776868666 +0200 @@ -7951,6 +7951,21 @@ remove_single_step_breakpoints (void) } } +int +single_step_breakpoint_inserted_here_p (CORE_ADDR pc) +{ + int i; + + for (i = 0; i < 2; i++) + { + struct bp_target_info *bp_tgt = single_step_breakpoints[i]; + if (bp_tgt && bp_tgt->placed_address == pc) + return 1; + } + + return 0; +} + /* This help string is used for the break, hbreak, tbreak and thbreak commands. It is defined as a macro to prevent duplication. diff -urNp gdb-orig/gdb/breakpoint.h gdb-head/gdb/breakpoint.h --- gdb-orig/gdb/breakpoint.h 2007-04-13 19:13:45.000000000 +0200 +++ gdb-head/gdb/breakpoint.h 2007-05-10 22:34:36.829861036 +0200 @@ -832,6 +832,8 @@ extern int remove_hw_watchpoints (void); twice before remove is called. */ extern void insert_single_step_breakpoint (CORE_ADDR); extern void remove_single_step_breakpoints (void); +extern int single_step_breakpoint_inserted_here_p (CORE_ADDR pc); + /* Manage manual breakpoints, separate from the normal chain of breakpoints. These functions are used in murky target-specific diff -urNp gdb-orig/gdb/linux-nat.c gdb-head/gdb/linux-nat.c --- gdb-orig/gdb/linux-nat.c 2007-05-07 02:18:12.000000000 +0200 +++ gdb-head/gdb/linux-nat.c 2007-05-10 22:34:36.860856573 +0200 @@ -1765,21 +1765,26 @@ cancel_breakpoints_callback (struct lwp_ tripped on it. */ if (lp->status != 0 - && WIFSTOPPED (lp->status) && WSTOPSIG (lp->status) == SIGTRAP - && breakpoint_inserted_here_p (read_pc_pid (lp->ptid) - - DECR_PC_AFTER_BREAK)) + && WIFSTOPPED (lp->status) && WSTOPSIG (lp->status) == SIGTRAP) { - if (debug_linux_nat) - fprintf_unfiltered (gdb_stdlog, - "CBC: Push back breakpoint for %s\n", - target_pid_to_str (lp->ptid)); + CORE_ADDR break_pc; + break_pc = read_pc_pid (lp->ptid) - DECR_PC_AFTER_BREAK; - /* Back up the PC if necessary. */ - if (DECR_PC_AFTER_BREAK) - write_pc_pid (read_pc_pid (lp->ptid) - DECR_PC_AFTER_BREAK, lp->ptid); + if (breakpoint_inserted_here_p (break_pc) + || single_step_breakpoint_inserted_here_p (break_pc)) + { + if (debug_linux_nat) + fprintf_unfiltered (gdb_stdlog, + "CBC: Push back breakpoint for %s\n", + target_pid_to_str (lp->ptid)); - /* Throw away the SIGTRAP. */ - lp->status = 0; + /* Back up the PC if necessary. */ + if (DECR_PC_AFTER_BREAK) + write_pc_pid (break_pc, lp->ptid); + + /* Throw away the SIGTRAP. */ + lp->status = 0; + } } return 0; -- Dr. Ulrich Weigand GNU Toolchain for Linux on System z and Cell BE Ulrich.Weigand@de.ibm.com