gdb/2250: Linux, multi-threaded, single-stepping, internal breakpoints
emi-suzuki@tjsys.co.jp
emi-suzuki@tjsys.co.jp
Tue Apr 10 08:48:00 GMT 2007
>Number: 2250
>Category: gdb
>Synopsis: Linux, multi-threaded, single-stepping, internal breakpoints
>Confidential: no
>Severity: serious
>Priority: medium
>Responsible: unassigned
>State: open
>Class: sw-bug
>Submitter-Id: net
>Arrival-Date: Tue Apr 10 09:48:01 BST 2007
>Closed-Date:
>Last-Modified:
>Originator: emi-suzuki@tjsys.co.jp
>Release: GNU gdb 6.6.50.20070330-cvs
>Organization:
>Environment:
FC5 or 6 running on X86 or PPC64
built with GCC 4.1.0 or 4.1.1 (packaged in the disto)
>Description:
When the multi-threaded target get stopped by a internal breakpoint hit (ex. thread creation, thread death, shared library loading) during singe-stepping, GDB unconditionally resume all the thread and it result in running over the range of single-stepping.
>How-To-Repeat:
The attached program makes two sub threads, and we do single-stepping on one of them.
The session log below shows one of the phenomena reproduced on X86 FC6; the problem occured when the second thread was created.
----
GNU gdb 6.6.50.20070330-cvs
Copyright (C) 2007 Free Software Foundation, Inc.
GDB is free software, covered by the GNU General Public License, and you are
welcome to change it and/or distribute copies of it under certain conditions.
Type "show copying" to see the conditions.
There is absolutely no warranty for GDB. Type "show warranty" for details.
This GDB was configured as "i686-pc-linux-gnu"...
Using host libthread_db library "/lib/libthread_db.so.1".
(gdb) b 14
Breakpoint 1 at 0x80484fa: file mt.c, line 14.
(gdb) l 14
9 {
10 int i;
11 int cnt = *((int *) arg);
12 pid_t pid = getpid();
13
14 for (i=0; i<cnt; i++)
15 printf ("[%d]counter: %d\n", pid, i);
16
17 return NULL;
18 }
(gdb) r
Starting program: /project/07/user/suzuki/test/mt/mt
[Thread debugging using libthread_db enabled]
[New Thread -1208011072 (LWP 28472)]
[28472]start
[New Thread -1208013936 (LWP 28475)]
[Switching to Thread -1208013936 (LWP 28475)]
Breakpoint 1, counter (arg=0xbfd491b0) at mt.c:14
14 for (i=0; i<cnt; i++)
(gdb) s
[New Thread -1218503792 (LWP 28476)]
[28472]no_counter
[Thread -1218503792 (LWP 28476) exited]
[28472]counter: 0
[28472]counter: 1
[28472]counter: 2
[28472]counter: 3
[28472]counter: 4
[28472]counter: 5
[28472]counter: 6
[28472]counter: 7
[28472]counter: 8
[28472]counter: 9
[Thread -1208013936 (LWP 28475) exited]
Thread Event Breakpoint: gdb should not stop!
(gdb)
>Fix:
>Release-Note:
>Audit-Trail:
>Unformatted:
----gnatsweb-attachment----
Content-Type: application/octet-stream; name="mt.c"
Content-Transfer-Encoding: base64
Content-Disposition: attachment; filename="mt.c"
I2luY2x1ZGUgPHN0ZGlvLmg+CiNpbmNsdWRlIDxzeXMvdHlwZXMuaD4KI2luY2x1ZGUgPHB0aHJl
YWQuaD4KI2luY2x1ZGUgPHVuaXN0ZC5oPgojaW5jbHVkZSA8c3RyaW5nLmg+Cgp2b2lkICoKY291
bnRlcih2b2lkICphcmcpCnsKICBpbnQgaTsKICBpbnQgY250ID0gKigoaW50ICopIGFyZyk7CiAg
cGlkX3QgcGlkID0gZ2V0cGlkKCk7CgogIGZvciAoaT0wOyBpPGNudDsgaSsrKQogICAgcHJpbnRm
ICgiWyVkXWNvdW50ZXI6ICVkXG4iLCBwaWQsIGkpOwoKICByZXR1cm4gTlVMTDsKfQoKdm9pZCAq
Cm5vX2NvdW50ZXIgKHZvaWQgKmFyZykKewogIHBpZF90IHBpZCA9IGdldHBpZCgpOwoKICBwcmlu
dGYgKCJbJWRdbm9fY291bnRlclxuIiwgcGlkKTsKCiAgcmV0dXJuIE5VTEw7Cn0KCmludAptYWlu
ICh2b2lkKQp7CiAgcGlkX3QgcF9waWQ7CiAgcHRocmVhZF90IHRocmVhZF9pZDEsIHRocmVhZF9p
ZDI7CiAgaW50IHN0YXR1czsKICBpbnQgY291bnQgPSAxMDsKCiAgcF9waWQgPSBnZXRwaWQgKCk7
CiAgcHJpbnRmICgiWyVkXXN0YXJ0XG4iLCBwX3BpZCk7CgogIHN0YXR1cyA9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