old-cross-binutils/gdb/testsuite/gdb.threads
Pedro Alves 49fa26b041 PR gdb/11568 - delete thread-specific breakpoints on thread exit
PR gdb/11568 is about thread-specific breakpoints being left behind
when the corresponding thread exits.

Currently:

 (gdb) b start thread 2
 Breakpoint 3 at 0x400614: file thread-specific-bp.c, line 23.
 (gdb) b end
 Breakpoint 4 at 0x40061f: file thread-specific-bp.c, line 29.
 (gdb) c
 Continuing.
 [Thread 0x7ffff7fcb700 (LWP 14925) exited]
 [Switching to Thread 0x7ffff7fcc740 (LWP 14921)]

 Breakpoint 4, end () at thread-specific-bp.c:29
 29      }
 (gdb) info threads
   Id   Target Id         Frame
 * 1    Thread 0x7ffff7fcc740 (LWP 14921) "thread-specific" end () at thread-specific-bp.c:29
 (gdb) info breakpoints
 Num     Type           Disp Enb Address            What
 2       breakpoint     keep y   0x0000000000400614 in start at thread-specific-bp.c:23
         breakpoint already hit 1 time
 3       breakpoint     keep y   0x0000000000400614 in start at thread-specific-bp.c:23 thread 2
         stop only in thread 2
 4       breakpoint     keep y   0x000000000040061f in end at thread-specific-bp.c:29
         breakpoint already hit 1 time

Note that the thread-specific breakpoint 3 stayed around, even though
thread 2 is gone.

There's no way that breakpoint can trigger again (*), so the PR argues
that the breakpoint should just be removed, like local watchpoints.
I'm ambivalent on this -- it could be reasonable to disable the
breakpoint (kind of like breakpoint in shared library code when the
DSO is unloaded), so the user could still use it as visual template
for creating other breakpoints (copy/paste command lists, etc.), or we
could have a way to change to which thread a breakpoint applies.  But,
several people pushed this direction, and I don't plan on arguing...

(*) - actually, there is ...  thread numbers are reset on "run", so
the user could do "break foo thread 2", "run", and expect the
breakpoint to hit again on the second thread.  But given gdb's thread
numbering can't really be stable, that'd only work sufficiently well
for thread 1, so we'd better call it unsupported.

So with the patch, whenever a thread is deleted from GDB's list, GDB
goes through the thread-specific breakpoints and deletes corresponding
breakpoints.  Since this is user-visible, GDB prints out:

  Thread-specific breakpoint 3 deleted - thread 2 is gone.

And of course, we end up with:

 (gdb) info breakpoints
 Num     Type           Disp Enb Address            What
 2       breakpoint     keep y   0x0000000000400614 in start at thread-specific-bp.c:23
         breakpoint already hit 1 time
 4       breakpoint     keep y   0x000000000040061f in end at thread-specific-bp.c:29
         breakpoint already hit 1 time

2013-09-17  Muhammad Waqas <mwaqas@codesourcery.com>
	    Pedro Alves  <palves@redhat.com>

	PR gdb/11568
	* breakpoint.c (remove_threaded_breakpoints): New function.
	(_initialize_breakpoint): Attach remove_threaded_breakpoints
	as thread_exit observer.

2013-09-17  Muhammad Waqas  <mwaqas@codesourccery.com>
	    Jan Kratochvil  <jan.kartochvil@redhat.com>
	    Pedro Alves  <palves@redhat.com>

	PR gdb/11568
	* gdb.thread/thread-specific-bp.c: New file.
	* gdb.thread/thread-specific-bp.exp: New file.
2013-09-17 19:32:47 +00:00
..
attach-into-signal.c
attach-into-signal.exp Remove superfluous semicolons from testsuite throughout. 2013-06-07 17:31:09 +00:00
attach-stopped.c
attach-stopped.exp
bp_in_thread.c
bp_in_thread.exp
clone-new-thread-event.c
clone-new-thread-event.exp
corethreads.c
corethreads.exp
create-fail.c
create-fail.exp
current-lwp-dead.c
current-lwp-dead.exp
dlopen-libpthread-lib.c 2013-06-04 Jan Kratochvil <jan.kratochvil@redhat.com> 2013-06-04 13:23:32 +00:00
dlopen-libpthread.c 2013-06-04 Jan Kratochvil <jan.kratochvil@redhat.com> 2013-06-04 13:23:32 +00:00
dlopen-libpthread.exp 2013-06-04 Jan Kratochvil <jan.kratochvil@redhat.com> 2013-06-04 13:23:32 +00:00
execl.c Fix formating in copyright headers. 2013-06-07 14:39:33 +00:00
execl.exp
execl1.c Fix formating in copyright headers. 2013-06-07 14:39:33 +00:00
fork-child-threads.c
fork-child-threads.exp
fork-thread-pending.c
fork-thread-pending.exp
gcore-thread.exp
hand-call-in-threads.c
hand-call-in-threads.exp
ia64-sigill.c
ia64-sigill.exp
info-threads-cur-sal-2.c PR gdb/15911: "info threads" changes the default source and line (for "break", "list") 2013-09-17 18:26:41 +00:00
info-threads-cur-sal.c PR gdb/15911: "info threads" changes the default source and line (for "break", "list") 2013-09-17 18:26:41 +00:00
info-threads-cur-sal.exp PR gdb/15911: "info threads" changes the default source and line (for "break", "list") 2013-09-17 18:26:41 +00:00
interrupted-hand-call.c
interrupted-hand-call.exp
killed.c
killed.exp
leader-exit.c
leader-exit.exp
linux-dp.c
linux-dp.exp
local-watch-wrong-thread.c
local-watch-wrong-thread.exp
Makefile.in
manythreads.c
manythreads.exp
multi-create.c
multi-create.exp
no-unwaited-for-left.c
no-unwaited-for-left.exp
non-ldr-exc-1.c
non-ldr-exc-1.exp
non-ldr-exc-2.c
non-ldr-exc-2.exp
non-ldr-exc-3.c
non-ldr-exc-3.exp
non-ldr-exc-4.c
non-ldr-exc-4.exp
pending-step.c
pending-step.exp
print-threads.c
print-threads.exp
pthread_cond_wait.c
pthread_cond_wait.exp
pthreads.c
pthreads.exp Remove superfluous semicolons from testsuite throughout. 2013-06-07 17:31:09 +00:00
schedlock.c
schedlock.exp
siginfo-threads.c
siginfo-threads.exp
sigstep-threads.c
sigstep-threads.exp
sigthread.c
sigthread.exp
staticthreads.c
staticthreads.exp
switch-threads.c
switch-threads.exp
thread-execl.c
thread-execl.exp
thread-find.exp
thread-specific-bp.c PR gdb/11568 - delete thread-specific breakpoints on thread exit 2013-09-17 19:32:47 +00:00
thread-specific-bp.exp PR gdb/11568 - delete thread-specific breakpoints on thread exit 2013-09-17 19:32:47 +00:00
thread-specific.c
thread-specific.exp
thread-unwindonsignal.exp
thread_check.c
thread_check.exp
thread_events.c
thread_events.exp Remove superfluous semicolons from testsuite throughout. 2013-06-07 17:31:09 +00:00
threadapply.c
threadapply.exp 2013-07-15 Ali Anwar <ali_anwar@codesourcery.com> 2013-07-15 11:14:32 +00:00
threxit-hop-specific.c
threxit-hop-specific.exp
tls-main.c
tls-nodebug.c gdb/testsuite/gdb.threads: Ensure TLS tests link against pthreads. 2013-07-18 15:49:22 +00:00
tls-nodebug.exp
tls-shared.c gdb/testsuite/gdb.threads: Ensure TLS tests link against pthreads. 2013-07-18 15:49:22 +00:00
tls-shared.exp
tls-var-main.c gdb/testsuite/gdb.threads: Ensure TLS tests link against pthreads. 2013-07-18 15:49:22 +00:00
tls-var.c
tls-var.exp
tls.c
tls.exp
tls2.c
watchpoint-fork-child.c
watchpoint-fork-mt.c
watchpoint-fork-parent.c
watchpoint-fork-st.c
watchpoint-fork.exp
watchpoint-fork.h
watchthreads-reorder.c
watchthreads-reorder.exp
watchthreads.c
watchthreads.exp Remove superfluous semicolons from testsuite throughout. 2013-06-07 17:31:09 +00:00
watchthreads2.c
watchthreads2.exp
wp-replication.c * gdb.threads/wp-replication.c (main): Insert some code at the start 2013-05-22 16:30:24 +00:00
wp-replication.exp 2013-07-08 Andreas Arnez <arnez@linux.vnet.ibm.com> 2013-07-08 11:35:49 +00:00