From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 19291 invoked by alias); 8 Jul 2008 02:49:48 -0000 Received: (qmail 19283 invoked by uid 22791); 8 Jul 2008 02:49:47 -0000 X-Spam-Check-By: sourceware.org Received: from inet-tsb5.toshiba.co.jp (HELO imx2.toshiba.co.jp) (202.33.96.24) by sourceware.org (qpsmtpd/0.31) with ESMTP; Tue, 08 Jul 2008 02:49:17 +0000 Received: from arc1.toshiba.co.jp ([133.199.194.235]) by imx2.toshiba.co.jp with ESMTP id m682nEqC007753 for ; Tue, 8 Jul 2008 11:49:14 +0900 (JST) Received: (from root@localhost) by arc1.toshiba.co.jp id m682nEcn015314 for gdb-patches@sourceware.org; Tue, 8 Jul 2008 11:49:14 +0900 (JST) Received: from unknown [133.199.192.144] by arc1.toshiba.co.jp with ESMTP id MAA15313; Tue, 8 Jul 2008 11:49:14 +0900 Received: from mx.toshiba.co.jp (localhost [127.0.0.1]) by ovp2.toshiba.co.jp with ESMTP id m682nETA011256 for ; Tue, 8 Jul 2008 11:49:14 +0900 (JST) Received: from mx.tjsys.co.jp by toshiba.co.jp id m682nBgI006078; Tue, 8 Jul 2008 11:49:11 +0900 (JST) Received: from voltage-out.tjsys.co.jp (voltage-out.tjsys.co.jp [157.79.3.51]) by mx.tjsys.co.jp (8.12.11/8.12.11) with ESMTP id m682nAeV006726 for ; Tue, 8 Jul 2008 11:49:10 +0900 (JST) Received: from is-com10 ([157.79.3.71]) by voltage-out.tjsys.co.jp (8.13.1/8.13.1) with SMTP id m682n5uU000476 for ; Tue, 8 Jul 2008 11:49:05 +0900 Received: from localhost ([157.79.30.231]) by ims.tjsys.co.jp (iPlanet Messaging Server 5.2 HotFix 2.10 (built Dec 26 2005)) with ESMTP id <0K3O00JCU2HSCH@ims.tjsys.co.jp> for gdb-patches@sourceware.org; Tue, 08 Jul 2008 11:49:04 +0900 (JST) Date: Tue, 08 Jul 2008 02:49:00 -0000 From: Ems SUZUKI Subject: [RFA] thread specific breakpoints and single stepping To: gdb-patches@sourceware.org Message-id: <20080708.114916.68479315.emi-suzuki@tjsys.co.jp> MIME-version: 1.0 X-Mailer: Mew version 6.1 on Emacs 22.1 / Mule 5.0 (SAKAKI) Content-type: Multipart/Mixed; boundary="--Next_Part(Tue_Jul_08_11_49_16_2008_040)--" Content-transfer-encoding: 7bit X-WAuditID: 0807081149040000020949 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-07/txt/msg00108.txt.bz2 ----Next_Part(Tue_Jul_08_11_49_16_2008_040)-- Content-Type: Text/Plain; charset=us-ascii Content-Transfer-Encoding: 7bit Content-length: 2298 Hello, I've seen the following session log while GDB is stepping over a thread specific breakpoint: -------- GNU gdb (GDB) 6.8.50.20080707-cvs Copyright (C) 2008 Free Software Foundation, Inc. License GPLv3+: GNU GPL version 3 or later This is free software: you are free to change and redistribute it. There is NO WARRANTY, to the extent permitted by law. Type "show copying" and "show warranty" for details. This GDB was configured as "i686-pc-linux-gnu". For bug reporting instructions, please see: ... (gdb) b 9 Breakpoint 1 at 0x80484a1: file main.c, line 9. (gdb) run Starting program: /home/suzuki/test/thread [Thread debugging using libthread_db enabled] [New Thread 0xb7f9db90 (LWP 5271)] [Switching to Thread 0xb7f9db90 (LWP 5271)] Breakpoint 1, thread_entry (args=0x0) at main.c:9 9 i+=1; (gdb) l 4 void * 5 thread_entry (void* args) 6 { 7 int i = 0; 8 9 i+=1; 10 i+=2; 11 i+=3; 12 13 return NULL; (gdb) info threads * 2 Thread 0xb7f9db90 (LWP 5271) thread_entry (args=0x0) at main.c:9 1 Thread 0xb7f9e940 (LWP 5268) 0x0012b402 in __kernel_vsyscall () (gdb) b 10 thread 1 Breakpoint 2 at 0x80484a5: file main.c, line 10. (gdb) step 11 i+=3; (gdb) -------- After the program reached to line 9, I set a breakpoint for only thread 1 at line 10. And I invoked step for thread 2. I expected thread 2 would stop at line 10, but it hopped over there and stopped at line 11. (I've attached the program I used to this mail.) The cause is in the below: infrun.c:2117 if (regular_breakpoint_inserted_here_p (stop_pc)) { ecs->random_signal = 0; if (!breakpoint_thread_match (stop_pc, ecs->ptid)) thread_hop_needed = 1; } thread_hop_needed would be set as 1, in the case that the stopped thread does not match the condition of the breakpoint. The thread which is currently single-stepping would also go into here. But the stepping thread should not hop over the breakpoints unconditionally, but check if it has reached the location where stepping would end. I think I've add a check for it with the attached diff. Does it make sense? -- Emi SUZUKI / emi-suzuki at tjsys.co.jp ----Next_Part(Tue_Jul_08_11_49_16_2008_040)-- Content-Type: Text/Plain; charset=us-ascii Content-Transfer-Encoding: 7bit Content-Disposition: inline; filename="main.c" Content-length: 387 #include #include void * thread_entry (void* args) { int i = 0; i += 1; i += 2; i += 3; return NULL; } int main (int argc, char *argv[]) { pthread_t pid; void* status; pthread_create (&pid, NULL, (void *) thread_entry, NULL); if (pthread_join (pid, &status)) { perror ("Failed pthread_join"); return -1; } return 0; } ----Next_Part(Tue_Jul_08_11_49_16_2008_040)-- Content-Type: Text/X-Diff; charset=us-ascii Content-Transfer-Encoding: 7bit Content-Disposition: inline; filename="thread_specific_break_and_step.diff" Content-length: 722 Index: gdb/infrun.c =================================================================== RCS file: /cvs/src/src/gdb/infrun.c,v retrieving revision 1.284 diff -u -r1.284 infrun.c --- gdb/infrun.c 28 Jun 2008 09:42:15 -0000 1.284 +++ gdb/infrun.c 8 Jul 2008 02:34:39 -0000 @@ -2118,7 +2118,11 @@ { ecs->random_signal = 0; if (!breakpoint_thread_match (stop_pc, ecs->ptid)) - thread_hop_needed = 1; + /* If the thread is currently single-stepping, whether it will + step over the breakpoint or not should be determined later. */ + if (!ptid_equal (ecs->ptid, inferior_ptid) + || !currently_stepping (ecs)) + thread_hop_needed = 1; } else if (singlestep_breakpoints_inserted_p) { ----Next_Part(Tue_Jul_08_11_49_16_2008_040)----