binutils-gdb/gdb/testsuite/gdb.threads
Pedro Alves 034f788c5e Fix next over threaded execl with "set scheduler-locking step".
Running gdb.threads/thread-execl.exp with scheduler-locking set to
"step" reveals a problem:

 (gdb) next^M
 [Thread 0x7ffff7fda700 (LWP 27168) exited]^M
 [New LWP 27168]^M
 [Thread 0x7ffff74ee700 (LWP 27174) exited]^M
 process 27168 is executing new program: /home/jkratoch/redhat/gdb-clean/gdb/testsuite/gdb.threads/thread-execl^M
 [Thread debugging using libthread_db enabled]^M
 Using host libthread_db library "/lib64/libthread_db.so.1".^M
 infrun.c:5225: internal-error: switch_back_to_stepped_thread: Assertion `!schedlock_applies (1)' failed.^M
 A problem internal to GDB has been detected,^M
 further debugging may prove unreliable.^M
 Quit this debugging session? (y or n) FAIL: gdb.threads/thread-execl.exp: schedlock step: get to main in new image (GDB internal error)

The assertion is correct.  The issue is that GDB is mistakenly trying
to switch back to an exited thread, that was previously stepping when
it exited.  This is exactly the sort of thing the test wants to make
sure doesn't happen:

	# Now set a breakpoint at `main', and step over the execl call.  The
	# breakpoint at main should be reached.  GDB should not try to revert
	# back to the old thread from the old image and resume stepping it

We don't see this bug with schedlock off only because a different
sequence of events makes GDB manage to delete the thread instead of
marking it exited.

This particular internal error can be fixed by making the loop over
all threads in switch_back_to_stepped_thread skip exited threads.
But, looking over other ALL_THREADS users, all either can or should be
skipping exited threads too.  So for simplicity, this patch replaces
ALL_THREADS with a new macro that skips exited threads itself, and
updates everything to use it.

Tested on x86_64 Fedora 20.

gdb/
2014-06-19  Pedro Alves  <palves@redhat.com>

	* gdbthread.h (ALL_THREADS): Delete.
	(ALL_NON_EXITED_THREADS): New macro.
	* btrace.c (btrace_free_objfile): Use ALL_NON_EXITED_THREADS
	instead of ALL_THREADS.
	* infrun.c (find_thread_needs_step_over)
	(switch_back_to_stepped_thread): Use ALL_NON_EXITED_THREADS
	instead of ALL_THREADS.
	* record-btrace.c (record_btrace_open)
	(record_btrace_stop_recording, record_btrace_close)
	(record_btrace_is_replaying, record_btrace_resume)
	(record_btrace_find_thread_to_move, record_btrace_wait): Likewise.
	* remote.c (append_pending_thread_resumptions): Likewise.
	* thread.c (thread_apply_all_command): Likewise.

gdb/testsuite/
2014-06-19  Pedro Alves  <palves@redhat.com>

	* gdb.threads/thread-execl.exp (do_test): New procedure, factored
	out from ...
	(top level): ... here.  Iterate running tests under different
	scheduler-locking settings.
2014-06-19 11:59:03 +01:00
..
Makefile.in
attach-into-signal.c Update Copyright year range in all files maintained by GDB. 2014-01-01 07:54:24 +04:00
attach-into-signal.exp Update Copyright year range in all files maintained by GDB. 2014-01-01 07:54:24 +04:00
attach-stopped.c Update Copyright year range in all files maintained by GDB. 2014-01-01 07:54:24 +04:00
attach-stopped.exp Update Copyright year range in all files maintained by GDB. 2014-01-01 07:54:24 +04:00
bp_in_thread.c Update Copyright year range in all files maintained by GDB. 2014-01-01 07:54:24 +04:00
bp_in_thread.exp Update Copyright year range in all files maintained by GDB. 2014-01-01 07:54:24 +04:00
clone-new-thread-event.c Update Copyright year range in all files maintained by GDB. 2014-01-01 07:54:24 +04:00
clone-new-thread-event.exp Update Copyright year range in all files maintained by GDB. 2014-01-01 07:54:24 +04:00
corethreads.c Update Copyright year range in all files maintained by GDB. 2014-01-01 07:54:24 +04:00
corethreads.exp Update Copyright year range in all files maintained by GDB. 2014-01-01 07:54:24 +04:00
create-fail.c Update Copyright year range in all files maintained by GDB. 2014-01-01 07:54:24 +04:00
create-fail.exp Update Copyright year range in all files maintained by GDB. 2014-01-01 07:54:24 +04:00
current-lwp-dead.c Update Copyright year range in all files maintained by GDB. 2014-01-01 07:54:24 +04:00
current-lwp-dead.exp Update Copyright year range in all files maintained by GDB. 2014-01-01 07:54:24 +04:00
dlopen-libpthread-lib.c Update Copyright year range in all files maintained by GDB. 2014-01-01 07:54:24 +04:00
dlopen-libpthread.c Update Copyright year range in all files maintained by GDB. 2014-01-01 07:54:24 +04:00
dlopen-libpthread.exp Update Copyright year range in all files maintained by GDB. 2014-01-01 07:54:24 +04:00
execl.c Update Copyright year range in all files maintained by GDB. 2014-01-01 07:54:24 +04:00
execl.exp Update Copyright year range in all files maintained by GDB. 2014-01-01 07:54:24 +04:00
execl1.c Update Copyright year range in all files maintained by GDB. 2014-01-01 07:54:24 +04:00
fork-child-threads.c Update Copyright year range in all files maintained by GDB. 2014-01-01 07:54:24 +04:00
fork-child-threads.exp Update Copyright year range in all files maintained by GDB. 2014-01-01 07:54:24 +04:00
fork-thread-pending.c Update Copyright year range in all files maintained by GDB. 2014-01-01 07:54:24 +04:00
fork-thread-pending.exp Update Copyright year range in all files maintained by GDB. 2014-01-01 07:54:24 +04:00
gcore-thread.exp Update Copyright year range in all files maintained by GDB. 2014-01-01 07:54:24 +04:00
hand-call-in-threads.c Update Copyright year range in all files maintained by GDB. 2014-01-01 07:54:24 +04:00
hand-call-in-threads.exp Update Copyright year range in all files maintained by GDB. 2014-01-01 07:54:24 +04:00
ia64-sigill.c Update Copyright year range in all files maintained by GDB. 2014-01-01 07:54:24 +04:00
ia64-sigill.exp Update Copyright year range in all files maintained by GDB. 2014-01-01 07:54:24 +04:00
info-threads-cur-sal-2.c Update Copyright year range in all files maintained by GDB. 2014-01-01 07:54:24 +04:00
info-threads-cur-sal.c Update Copyright year range in all files maintained by GDB. 2014-01-01 07:54:24 +04:00
info-threads-cur-sal.exp Update Copyright year range in all files maintained by GDB. 2014-01-01 07:54:24 +04:00
interrupted-hand-call.c Update Copyright year range in all files maintained by GDB. 2014-01-01 07:54:24 +04:00
interrupted-hand-call.exp Update Copyright year range in all files maintained by GDB. 2014-01-01 07:54:24 +04:00
killed.c Update Copyright year range in all files maintained by GDB. 2014-01-01 07:54:24 +04:00
killed.exp Update Copyright year range in all files maintained by GDB. 2014-01-01 07:54:24 +04:00
leader-exit.c Update Copyright year range in all files maintained by GDB. 2014-01-01 07:54:24 +04:00
leader-exit.exp Update Copyright year range in all files maintained by GDB. 2014-01-01 07:54:24 +04:00
linux-dp.c
linux-dp.exp Update Copyright year range in all files maintained by GDB. 2014-01-01 07:54:24 +04:00
local-watch-wrong-thread.c Update Copyright year range in all files maintained by GDB. 2014-01-01 07:54:24 +04:00
local-watch-wrong-thread.exp Update Copyright year range in all files maintained by GDB. 2014-01-01 07:54:24 +04:00
manythreads.c Update Copyright year range in all files maintained by GDB. 2014-01-01 07:54:24 +04:00
manythreads.exp Update Copyright year range in all files maintained by GDB. 2014-01-01 07:54:24 +04:00
multi-create.c Update Copyright year range in all files maintained by GDB. 2014-01-01 07:54:24 +04:00
multi-create.exp Update Copyright year range in all files maintained by GDB. 2014-01-01 07:54:24 +04:00
multiple-step-overs.c Handle multiple step-overs. 2014-03-20 13:43:28 +00:00
multiple-step-overs.exp Handle multiple step-overs. 2014-03-20 13:43:28 +00:00
no-unwaited-for-left.c Update Copyright year range in all files maintained by GDB. 2014-01-01 07:54:24 +04:00
no-unwaited-for-left.exp Update Copyright year range in all files maintained by GDB. 2014-01-01 07:54:24 +04:00
non-ldr-exc-1.c Update Copyright year range in all files maintained by GDB. 2014-01-01 07:54:24 +04:00
non-ldr-exc-1.exp Update Copyright year range in all files maintained by GDB. 2014-01-01 07:54:24 +04:00
non-ldr-exc-2.c Update Copyright year range in all files maintained by GDB. 2014-01-01 07:54:24 +04:00
non-ldr-exc-2.exp Update Copyright year range in all files maintained by GDB. 2014-01-01 07:54:24 +04:00
non-ldr-exc-3.c Update Copyright year range in all files maintained by GDB. 2014-01-01 07:54:24 +04:00
non-ldr-exc-3.exp Update Copyright year range in all files maintained by GDB. 2014-01-01 07:54:24 +04:00
non-ldr-exc-4.c Update Copyright year range in all files maintained by GDB. 2014-01-01 07:54:24 +04:00
non-ldr-exc-4.exp Update Copyright year range in all files maintained by GDB. 2014-01-01 07:54:24 +04:00
pending-step.c Update Copyright year range in all files maintained by GDB. 2014-01-01 07:54:24 +04:00
pending-step.exp Update Copyright year range in all files maintained by GDB. 2014-01-01 07:54:24 +04:00
print-threads.c
print-threads.exp Update Copyright year range in all files maintained by GDB. 2014-01-01 07:54:24 +04:00
pthread_cond_wait.c Update Copyright year range in all files maintained by GDB. 2014-01-01 07:54:24 +04:00
pthread_cond_wait.exp Update Copyright year range in all files maintained by GDB. 2014-01-01 07:54:24 +04:00
pthreads.c Update Copyright year range in all files maintained by GDB. 2014-01-01 07:54:24 +04:00
pthreads.exp Update Copyright year range in all files maintained by GDB. 2014-01-01 07:54:24 +04:00
reconnect-signal.c [remote/gdbserver] Don't lose signals when reconnecting. 2014-01-08 18:55:51 +00:00
reconnect-signal.exp [remote/gdbserver] Don't lose signals when reconnecting. 2014-01-08 18:55:51 +00:00
schedlock.c Update Copyright year range in all files maintained by GDB. 2014-01-01 07:54:24 +04:00
schedlock.exp Update Copyright year range in all files maintained by GDB. 2014-01-01 07:54:24 +04:00
siginfo-threads.c Update Copyright year range in all files maintained by GDB. 2014-01-01 07:54:24 +04:00
siginfo-threads.exp Update Copyright year range in all files maintained by GDB. 2014-01-01 07:54:24 +04:00
signal-while-stepping-over-bp-other-thread.c Further cleanup of signal-while-stepping-over-bp-other-thread.c. 2014-03-20 14:09:53 +00:00
signal-while-stepping-over-bp-other-thread.exp Make signal-while-stepping-over-bp-other-thread.exp run against remote targets too. 2014-03-20 13:44:32 +00:00
sigstep-threads.c Update Copyright year range in all files maintained by GDB. 2014-01-01 07:54:24 +04:00
sigstep-threads.exp Update Copyright year range in all files maintained by GDB. 2014-01-01 07:54:24 +04:00
sigthread.c
sigthread.exp Update Copyright year range in all files maintained by GDB. 2014-01-01 07:54:24 +04:00
staticthreads.c Fix the race in gdb.threads/staticthreads.exp 2014-06-06 09:45:22 +08:00
staticthreads.exp Fix the race in gdb.threads/staticthreads.exp 2014-06-06 09:45:22 +08:00
step-over-lands-on-breakpoint.c Fix missing breakpoint/watchpoint hits, eliminate deferred_step_ptid. 2014-03-20 13:26:31 +00:00
step-over-lands-on-breakpoint.exp Fix missing breakpoint/watchpoint hits, eliminate deferred_step_ptid. 2014-03-20 13:26:31 +00:00
step-over-trips-on-watchpoint.c Fix for even more missed events; eliminate thread-hop code. 2014-03-20 13:42:23 +00:00
step-over-trips-on-watchpoint.exp Fix for even more missed events; eliminate thread-hop code. 2014-03-20 13:42:23 +00:00
stepi-random-signal.c Update Copyright year range in all files maintained by GDB. 2014-01-01 07:54:24 +04:00
stepi-random-signal.exp Fix gdb.threads/stepi-random-signal.exp on software single-step targets. 2014-02-07 19:04:10 +00:00
switch-threads.c Update Copyright year range in all files maintained by GDB. 2014-01-01 07:54:24 +04:00
switch-threads.exp Update Copyright year range in all files maintained by GDB. 2014-01-01 07:54:24 +04:00
thread-execl.c Update Copyright year range in all files maintained by GDB. 2014-01-01 07:54:24 +04:00
thread-execl.exp Fix next over threaded execl with "set scheduler-locking step". 2014-06-19 11:59:03 +01:00
thread-find.exp Update Copyright year range in all files maintained by GDB. 2014-01-01 07:54:24 +04:00
thread-specific-bp.c Update Copyright year range in all files maintained by GDB. 2014-01-01 07:54:24 +04:00
thread-specific-bp.exp enable target async by default; separate MI and target notions of async 2014-05-29 14:38:02 +01:00
thread-specific.c Update Copyright year range in all files maintained by GDB. 2014-01-01 07:54:24 +04:00
thread-specific.exp gdb.threads/thread-specific.exp: Fix uninitialized variable references 2014-03-21 23:51:16 +00:00
thread-unwindonsignal.exp Update Copyright year range in all files maintained by GDB. 2014-01-01 07:54:24 +04:00
thread_check.c Update Copyright year range in all files maintained by GDB. 2014-01-01 07:54:24 +04:00
thread_check.exp Update Copyright year range in all files maintained by GDB. 2014-01-01 07:54:24 +04:00
thread_events.c Update Copyright year range in all files maintained by GDB. 2014-01-01 07:54:24 +04:00
thread_events.exp Update Copyright year range in all files maintained by GDB. 2014-01-01 07:54:24 +04:00
threadapply.c Update Copyright year range in all files maintained by GDB. 2014-01-01 07:54:24 +04:00
threadapply.exp Update Copyright year range in all files maintained by GDB. 2014-01-01 07:54:24 +04:00
threxit-hop-specific.c Update Copyright year range in all files maintained by GDB. 2014-01-01 07:54:24 +04:00
threxit-hop-specific.exp Update Copyright year range in all files maintained by GDB. 2014-01-01 07:54:24 +04:00
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 Update Copyright year range in all files maintained by GDB. 2014-01-01 07:54:24 +04:00
tls-shared.c gdb/testsuite/gdb.threads: Ensure TLS tests link against pthreads. 2013-07-18 15:49:22 +00:00
tls-shared.exp Update Copyright year range in all files maintained by GDB. 2014-01-01 07:54:24 +04:00
tls-var-main.c Update Copyright year range in all files maintained by GDB. 2014-01-01 07:54:24 +04:00
tls-var.c Update Copyright year range in all files maintained by GDB. 2014-01-01 07:54:24 +04:00
tls-var.exp Update Copyright year range in all files maintained by GDB. 2014-01-01 07:54:24 +04:00
tls.c
tls.exp Update Copyright year range in all files maintained by GDB. 2014-01-01 07:54:24 +04:00
tls2.c Update Copyright year range in all files maintained by GDB. 2014-01-01 07:54:24 +04:00
watchpoint-fork-child.c Update Copyright year range in all files maintained by GDB. 2014-01-01 07:54:24 +04:00
watchpoint-fork-mt.c Update Copyright year range in all files maintained by GDB. 2014-01-01 07:54:24 +04:00
watchpoint-fork-parent.c Update Copyright year range in all files maintained by GDB. 2014-01-01 07:54:24 +04:00
watchpoint-fork-st.c Update Copyright year range in all files maintained by GDB. 2014-01-01 07:54:24 +04:00
watchpoint-fork.exp Update Copyright year range in all files maintained by GDB. 2014-01-01 07:54:24 +04:00
watchpoint-fork.h Update Copyright year range in all files maintained by GDB. 2014-01-01 07:54:24 +04:00
watchthreads-reorder.c Update Copyright year range in all files maintained by GDB. 2014-01-01 07:54:24 +04:00
watchthreads-reorder.exp Update Copyright year range in all files maintained by GDB. 2014-01-01 07:54:24 +04:00
watchthreads.c Update Copyright year range in all files maintained by GDB. 2014-01-01 07:54:24 +04:00
watchthreads.exp Update Copyright year range in all files maintained by GDB. 2014-01-01 07:54:24 +04:00
watchthreads2.c Update Copyright year range in all files maintained by GDB. 2014-01-01 07:54:24 +04:00
watchthreads2.exp Update Copyright year range in all files maintained by GDB. 2014-01-01 07:54:24 +04:00
wp-replication.c Update Copyright year range in all files maintained by GDB. 2014-01-01 07:54:24 +04:00
wp-replication.exp Update Copyright year range in all files maintained by GDB. 2014-01-01 07:54:24 +04:00