Hi, I noticed that the moribund breakpoints support wasn't activated, presumably, because it was written before non-stop was. :-) Things that were missing: - In breakpoint.c, we weren't putting the moribund locations in the moribund vector. They were just being released immediately. - infrun.c:adjust_pc_after_break wasn't taking moribund locations into account, hence on decr_pc_after_break architectures, we would never realise a moribund breakpoint was hit, as the stop pc was offset from what was recorded in the moribund location. While fixing this, I noticed that we'd displaced step a thread even if the breakpoint it was sitting under got removed while the thread was waiting in the displaced stepping queue. I added a check there, so we resume the thread immediately in that case, although this isn't strictly necessary. I've written an MI testcase that triggers the problem. Does it (and the code) look OK? Tested on x86-pc-linux-gnu, no regressions. gdb/ 2008-10-15 Pedro Alves * breakpoint.c (breakpoint_init_inferior): Clean up the moribund locations list. (moribund_breakpoint_here_p): Record the moribund location in the moribund_locations vector. * breakpoint.h (moribund_breakpoint_here_p): Declare. (displaced_step_fixup): Check if the breakpoint the thread was trying to step over has been removed since having been placed in the displaced stepping queue. (adjust_pc_after_break): In non-stop mode, check for a moribund breakpoint at the stop pc. (handle_inferior_event): Don't retire moribund breakpoints on TARGET_WAITKIND_IGNORE. gdb/testsuite/ 2008-10-15 Pedro Alves * gdb.mi/mi-nsmoribund.exp, gdb.mi/nsmoribund.c: New test. The new test is MI based, but let me show a full CLI log of good and bad runs, as it may help else someone working on non-stop and googling for this in the future: Good run, after patch: >./gdb -ex "set pagination off" -ex "set target-async 1" -ex "set non-stop 1" --args /home/pedro/gdb/multi_process/build32/gdb/testsuite/gdb.mi/mi-nsmoribund GNU gdb (GDB) 6.8.50.20081014-cvs [...] (gdb) b 38 Breakpoint 1 at 0x8048525: file ../../../src/gdb/testsuite/gdb.mi/nsmoribund.c, line 38. (gdb) r Starting program: /home/pedro/gdb/multi_process/build32/gdb/testsuite/gdb.mi/mi-nsmoribund [Thread debugging using libthread_db enabled] [New Thread 0xf7e2fb90 (LWP 16330)] Breakpoint 1, thread_function (arg=0x0) at ../../../src/gdb/testsuite/gdb.mi/nsmoribund.c:38 38 (*myp)++; /* set breakpoint here */ (gdb) [New Thread 0xf762eb90 (LWP 16331)] [New Thread 0xf6e2db90 (LWP 16332)] Breakpoint 1, thread_function (arg=0x1) at ../../../src/gdb/testsuite/gdb.mi/nsmoribund.c:38 38 (*myp)++; /* set breakpoint here */ [New Thread 0xf662cb90 (LWP 16333)] Breakpoint 1, thread_function (arg=0x2) at ../../../src/gdb/testsuite/gdb.mi/nsmoribund.c:38 38 (*myp)++; /* set breakpoint here */ [New Thread 0xf5e2bb90 (LWP 16334)] Breakpoint 1, thread_function (arg=0x3) at ../../../src/gdb/testsuite/gdb.mi/nsmoribund.c:38 38 (*myp)++; /* set breakpoint here */ [New Thread 0xf562ab90 (LWP 16335)] Breakpoint 1, thread_function (arg=0x4) at ../../../src/gdb/testsuite/gdb.mi/nsmoribund.c:38 38 (*myp)++; /* set breakpoint here */ [New Thread 0xf4e29b90 (LWP 16336)] Breakpoint 1, thread_function (arg=0x5) at ../../../src/gdb/testsuite/gdb.mi/nsmoribund.c:38 38 (*myp)++; /* set breakpoint here */ [New Thread 0xf4628b90 (LWP 16337)] Breakpoint 1, thread_function (arg=0x6) at ../../../src/gdb/testsuite/gdb.mi/nsmoribund.c:38 38 (*myp)++; /* set breakpoint here */ [New Thread 0xf3e27b90 (LWP 16338)] Breakpoint 1, thread_function (arg=0x7) at ../../../src/gdb/testsuite/gdb.mi/nsmoribund.c:38 38 (*myp)++; /* set breakpoint here */ [New Thread 0xf3626b90 (LWP 16339)] Breakpoint 1, thread_function (arg=0x8) at ../../../src/gdb/testsuite/gdb.mi/nsmoribund.c:38 38 (*myp)++; /* set breakpoint here */ Breakpoint 1, thread_function (arg=0x9) at ../../../src/gdb/testsuite/gdb.mi/nsmoribund.c:38 38 (*myp)++; /* set breakpoint here */ info threads 11 Thread 0xf3626b90 (LWP 16339) thread_function (arg=0x9) at ../../../src/gdb/testsuite/gdb.mi/nsmoribund.c:38 10 Thread 0xf3e27b90 (LWP 16338) thread_function (arg=0x8) at ../../../src/gdb/testsuite/gdb.mi/nsmoribund.c:38 9 Thread 0xf4628b90 (LWP 16337) thread_function (arg=0x7) at ../../../src/gdb/testsuite/gdb.mi/nsmoribund.c:38 8 Thread 0xf4e29b90 (LWP 16336) thread_function (arg=0x6) at ../../../src/gdb/testsuite/gdb.mi/nsmoribund.c:38 7 Thread 0xf562ab90 (LWP 16335) thread_function (arg=0x5) at ../../../src/gdb/testsuite/gdb.mi/nsmoribund.c:38 6 Thread 0xf5e2bb90 (LWP 16334) thread_function (arg=0x4) at ../../../src/gdb/testsuite/gdb.mi/nsmoribund.c:38 5 Thread 0xf662cb90 (LWP 16333) thread_function (arg=0x3) at ../../../src/gdb/testsuite/gdb.mi/nsmoribund.c:38 4 Thread 0xf6e2db90 (LWP 16332) thread_function (arg=0x2) at ../../../src/gdb/testsuite/gdb.mi/nsmoribund.c:38 3 Thread 0xf762eb90 (LWP 16331) thread_function (arg=0x1) at ../../../src/gdb/testsuite/gdb.mi/nsmoribund.c:38 2 Thread 0xf7e2fb90 (LWP 16330) thread_function (arg=0x0) at ../../../src/gdb/testsuite/gdb.mi/nsmoribund.c:38 * 1 Thread 0xf7e306b0 (LWP 16327) (running) (gdb) t 5 [Switching to thread 5 (Thread 0xf662cb90 (LWP 16333))]#0 thread_function (arg=0x3) at ../../../src/gdb/testsuite/gdb.mi/nsmoribund.c:38 38 (*myp)++; /* set breakpoint here */ (gdb) del Delete all breakpoints? (y or n) y (gdb) b 37 thread 5 Breakpoint 2 at 0x8048525: file ../../../src/gdb/testsuite/gdb.mi/nsmoribund.c, line 37. (gdb) c -a& Continuing. (gdb) Breakpoint 2, thread_function (arg=0x3) at ../../../src/gdb/testsuite/gdb.mi/nsmoribund.c:38 38 (*myp)++; /* set breakpoint here */ info threads 11 Thread 0xf3626b90 (LWP 16339) (running) 10 Thread 0xf3e27b90 (LWP 16338) (running) 9 Thread 0xf4628b90 (LWP 16337) (running) 8 Thread 0xf4e29b90 (LWP 16336) (running) 7 Thread 0xf562ab90 (LWP 16335) (running) 6 Thread 0xf5e2bb90 (LWP 16334) (running) * 5 Thread 0xf662cb90 (LWP 16333) thread_function (arg=0x3) at ../../../src/gdb/testsuite/gdb.mi/nsmoribund.c:38 4 Thread 0xf6e2db90 (LWP 16332) (running) 3 Thread 0xf762eb90 (LWP 16331) (running) 2 Thread 0xf7e2fb90 (LWP 16330) (running) 1 Thread 0xf7e306b0 (LWP 16327) (running) (gdb) del Delete all breakpoints? (y or n) y (gdb) p done = 1 $1 = 1 (gdb) During symbol reading, incomplete CFI data; unspecified registers (e.g., eax) at 0x8048507. [Thread 0xf4628b90 (LWP 16337) exited] [Thread 0xf5e2bb90 (LWP 16334) exited] [Thread 0xf4e29b90 (LWP 16336) exited] [Thread 0xf762eb90 (LWP 16331) exited] [Thread 0xf6e2db90 (LWP 16332) exited] [Thread 0xf7e2fb90 (LWP 16330) exited] [Thread 0xf3626b90 (LWP 16339) exited] [Thread 0xf3e27b90 (LWP 16338) exited] [Thread 0xf562ab90 (LWP 16335) exited] c -a& Continuing. (gdb) [Thread 0xf662cb90 (LWP 16333) exited] Program exited normally. Here's a bad run, before the patch is applied: >./gdb -ex "set pagination off" -ex "set target-async 1" -ex "set non-stop 1" --args /home/pedro/gdb/multi_process/build32/gdb/testsuite/gdb.mi/mi-nsmoribund GNU gdb (GDB) 6.8.50.20081014-cvs [... all the same as above ...] (gdb) b 38 thread 5 Breakpoint 2 at 0x8048525: file ../../../src/gdb/testsuite/gdb.mi/nsmoribund.c, line 38. (gdb) c -a& Continuing. (gdb) Breakpoint 2, thread_function (arg=0x3) at ../../../src/gdb/testsuite/gdb.mi/nsmoribund.c:38 38 (*myp)++; /* set breakpoint here */ info threads 11 Thread 0xf3626b90 (LWP 17386) (running) 10 Thread 0xf3e27b90 (LWP 17385) (running) 9 Thread 0xf4628b90 (LWP 17384) (running) 8 Thread 0xf4e29b90 (LWP 17383) (running) 7 Thread 0xf562ab90 (LWP 17382) (running) 6 Thread 0xf5e2bb90 (LWP 17381) (running) * 5 Thread 0xf662cb90 (LWP 17380) thread_function (arg=0x3) at ../../../src/gdb/testsuite/gdb.mi/nsmoribund.c:38 4 Thread 0xf6e2db90 (LWP 17379) (running) 3 Thread 0xf762eb90 (LWP 17378) (running) 2 Thread 0xf7e2fb90 (LWP 17377) (running) 1 Thread 0xf7e306b0 (LWP 17374) (running) (gdb) del Delete all breakpoints? (y or n) y (gdb) Program received signal SIGTRAP, Trace/breakpoint trap. 0x08048526 in thread_function (arg=0x8) at ../../../src/gdb/testsuite/gdb.mi/nsmoribund.c:38 38 (*myp)++; /* set breakpoint here */ p done $1 = 0 (gdb) p done = 1 $2 = 1 (gdb) During symbol reading, incomplete CFI data; unspecified registers (e.g., eax) at 0x8048507. [Thread 0xf762eb90 (LWP 17378) exited] [Thread 0xf7e2fb90 (LWP 17377) exited] [Thread 0xf6e2db90 (LWP 17379) exited] [Thread 0xf4e29b90 (LWP 17383) exited] [Thread 0xf562ab90 (LWP 17382) exited] [Thread 0xf3626b90 (LWP 17386) exited] [Thread 0xf4628b90 (LWP 17384) exited] [Thread 0xf5e2bb90 (LWP 17381) exited] c -a& Continuing. (gdb) Program received signal SIGSEGV, Segmentation fault. 0x08048528 in thread_function (arg=0x2000000) at ../../../src/gdb/testsuite/gdb.mi/nsmoribund.c:38 38 (*myp)++; /* set breakpoint here */ [Thread 0xf662cb90 (LWP 17380) exited] The SIGSEGV is due to decr_pc_after_break not beind done, so we resumed at the wrong address (+1 on x86: notice that the breakopoint was set at 0x08048525, and SIGTRAP was reported at 0x08048526. In this case, we resumed in the middle of an multi-byte instruction). -- Pedro Alves