old-cross-binutils/gdb/testsuite/gdb.threads
Pedro Alves 28bf096c62 PR threads/18127 - threads spawned by infcall end up stuck in "running" state
Refs:
 https://sourceware.org/ml/gdb/2015-03/msg00024.html
 https://sourceware.org/ml/gdb/2015-06/msg00005.html

On GNU/Linux, if an infcall spawns a thread, that thread ends up with
stuck running state.  This happens because:

 - when linux-nat.c detects a new thread, it marks them as running,
   and does not report anything to the core.

 - we skip finish_thread_state when the thread that is running the
   infcall stops.

As result, that new thread ends up with stuck "running" state, even
though it really is stopped.

On Windows, _all_ threads end up stuck in running state, not just the
one that was spawned.  That happens because when a new thread is
detected, unlike linux-nat.c, windows-nat.c reports
TARGET_WAITKIND_SPURIOUS to infrun.  It's the fact that that event
does not cause a user-visible stop that triggers the problem.  When
the target is re-resumed, we call set_running with a wildcard ptid,
which marks all thread as running.  That set_running is not suppressed
because the (leader) thread being resumed does not have in_infcall
set.  Later, when the infcall finally finishes successfully, nothing
marks all threads back to stopped.

We can trigger the same problem on all targets by having a thread
other than the one that is running the infcall report a breakpoint hit
to infrun, and then have that breakpoint not cause a stop.  That's
what the included test does.

The fix is to stop GDB from suppressing the set_running calls while
doing an infcall, and then set the threads back to stopped when the
call finishes, iff they were originally stopped before the infcall
started.  (Note the MI *running/*stopped event suppression isn't
affected.)

Tested on x86_64 GNU/Linux.

gdb/ChangeLog:
2015-06-29  Pedro Alves  <palves@redhat.com>

	PR threads/18127
	* infcall.c (run_inferior_call): On infcall success, if the thread
	was marked stopped before, reset it back to stopped.
	* infrun.c (resume): Don't suppress the set_running calls when
	doing an infcall.
	(normal_stop): Only discard the finish_thread_state cleanup if the
	infcall succeeded.

gdb/testsuite/ChangeLog:
2015-06-29  Pedro Alves  <palves@redhat.com>

	PR threads/18127
	* gdb.threads/hand-call-new-thread.c: New file.
	* gdb.threads/hand-call-new-thread.c: New file.
2015-06-29 16:07:57 +01:00
..
attach-into-signal.c Update year range in copyright notice of all files owned by the GDB project. 2015-01-01 13:32:14 +04:00
attach-into-signal.exp Update year range in copyright notice of all files owned by the GDB project. 2015-01-01 13:32:14 +04:00
attach-many-short-lived-threads.c Improve gdb.threads/attach-many-short-lived-threads.exp timeout handling 2015-02-06 13:24:32 +01:00
attach-many-short-lived-threads.exp Improve gdb.threads/attach-many-short-lived-threads.exp timeout handling 2015-02-06 13:24:32 +01:00
attach-stopped.c Update year range in copyright notice of all files owned by the GDB project. 2015-01-01 13:32:14 +04:00
attach-stopped.exp Update year range in copyright notice of all files owned by the GDB project. 2015-01-01 13:32:14 +04:00
bp_in_thread.c Update year range in copyright notice of all files owned by the GDB project. 2015-01-01 13:32:14 +04:00
bp_in_thread.exp Update year range in copyright notice of all files owned by the GDB project. 2015-01-01 13:32:14 +04:00
break-while-running.c Update year range in copyright notice of all files owned by the GDB project. 2015-01-01 13:32:14 +04:00
break-while-running.exp Update year range in copyright notice of all files owned by the GDB project. 2015-01-01 13:32:14 +04:00
clone-new-thread-event.c Update year range in copyright notice of all files owned by the GDB project. 2015-01-01 13:32:14 +04:00
clone-new-thread-event.exp Update year range in copyright notice of all files owned by the GDB project. 2015-01-01 13:32:14 +04:00
clone-thread_db.c gdb.threads/clone-thread_db.c: Add missing includes and fix pthread_join call 2015-03-04 09:13:49 +00:00
clone-thread_db.exp PR18006: internal error if threaded program calls clone(CLONE_VM) 2015-02-20 19:00:21 +00:00
continue-pending-after-query.c Linux: make target_is_async_p return false when async is off 2015-01-23 11:12:39 +00:00
continue-pending-after-query.exp Linux: make target_is_async_p return false when async is off 2015-01-23 11:12:39 +00:00
continue-pending-status.c native/Linux: internal error if resume is short-circuited 2015-03-19 12:26:49 +00:00
continue-pending-status.exp gdbserver/Linux: unbreak thread event randomization 2015-03-19 12:38:05 +00:00
corethreads.c Update year range in copyright notice of all files owned by the GDB project. 2015-01-01 13:32:14 +04:00
corethreads.exp Update year range in copyright notice of all files owned by the GDB project. 2015-01-01 13:32:14 +04:00
create-fail.c Remove testsuite compile errors with GCC5. 2015-01-25 18:50:56 +01:00
create-fail.exp Update year range in copyright notice of all files owned by the GDB project. 2015-01-01 13:32:14 +04:00
current-lwp-dead.c Update year range in copyright notice of all files owned by the GDB project. 2015-01-01 13:32:14 +04:00
current-lwp-dead.exp Update year range in copyright notice of all files owned by the GDB project. 2015-01-01 13:32:14 +04:00
dlopen-libpthread-lib.c Update year range in copyright notice of all files owned by the GDB project. 2015-01-01 13:32:14 +04:00
dlopen-libpthread.c Update year range in copyright notice of all files owned by the GDB project. 2015-01-01 13:32:14 +04:00
dlopen-libpthread.exp Update year range in copyright notice of all files owned by the GDB project. 2015-01-01 13:32:14 +04:00
execl.c Update year range in copyright notice of all files owned by the GDB project. 2015-01-01 13:32:14 +04:00
execl.exp Update year range in copyright notice of all files owned by the GDB project. 2015-01-01 13:32:14 +04:00
execl1.c Update year range in copyright notice of all files owned by the GDB project. 2015-01-01 13:32:14 +04:00
fork-child-threads.c Update year range in copyright notice of all files owned by the GDB project. 2015-01-01 13:32:14 +04:00
fork-child-threads.exp Update year range in copyright notice of all files owned by the GDB project. 2015-01-01 13:32:14 +04:00
fork-thread-pending.c Update year range in copyright notice of all files owned by the GDB project. 2015-01-01 13:32:14 +04:00
fork-thread-pending.exp Linux: Skip thread_db thread event reporting if PTRACE_EVENT_CLONE is supported 2015-01-09 11:42:57 +00:00
gcore-stale-thread.c Update year range in copyright notice of all files owned by the GDB project. 2015-01-01 13:32:14 +04:00
gcore-stale-thread.exp Update year range in copyright notice of all files owned by the GDB project. 2015-01-01 13:32:14 +04:00
gcore-thread.exp Update year range in copyright notice of all files owned by the GDB project. 2015-01-01 13:32:14 +04:00
hand-call-in-threads.c Update year range in copyright notice of all files owned by the GDB project. 2015-01-01 13:32:14 +04:00
hand-call-in-threads.exp Update year range in copyright notice of all files owned by the GDB project. 2015-01-01 13:32:14 +04:00
hand-call-new-thread.c PR threads/18127 - threads spawned by infcall end up stuck in "running" state 2015-06-29 16:07:57 +01:00
hand-call-new-thread.exp PR threads/18127 - threads spawned by infcall end up stuck in "running" state 2015-06-29 16:07:57 +01:00
ia64-sigill.c gdb.threads/{siginfo-thread.c,watchthreads-reorder.c,ia64-sigill.c} races with GDB 2015-01-09 13:58:29 +00:00
ia64-sigill.exp Update year range in copyright notice of all files owned by the GDB project. 2015-01-01 13:32:14 +04:00
info-threads-cur-sal-2.c Update year range in copyright notice of all files owned by the GDB project. 2015-01-01 13:32:14 +04:00
info-threads-cur-sal.c Update year range in copyright notice of all files owned by the GDB project. 2015-01-01 13:32:14 +04:00
info-threads-cur-sal.exp Update year range in copyright notice of all files owned by the GDB project. 2015-01-01 13:32:14 +04:00
interrupted-hand-call.c Update year range in copyright notice of all files owned by the GDB project. 2015-01-01 13:32:14 +04:00
interrupted-hand-call.exp Update year range in copyright notice of all files owned by the GDB project. 2015-01-01 13:32:14 +04:00
kill.c Update year range in copyright notice of all files owned by the GDB project. 2015-01-01 13:32:14 +04:00
kill.exp Update year range in copyright notice of all files owned by the GDB project. 2015-01-01 13:32:14 +04:00
killed.c Remove testsuite compile errors with GCC5. 2015-01-25 18:50:56 +01:00
killed.exp Update year range in copyright notice of all files owned by the GDB project. 2015-01-01 13:32:14 +04:00
leader-exit.c Update year range in copyright notice of all files owned by the GDB project. 2015-01-01 13:32:14 +04:00
leader-exit.exp Update year range in copyright notice of all files owned by the GDB project. 2015-01-01 13:32:14 +04:00
linux-dp.c Remove testsuite compile errors with GCC5. 2015-01-25 18:50:56 +01:00
linux-dp.exp Update year range in copyright notice of all files owned by the GDB project. 2015-01-01 13:32:14 +04:00
local-watch-wrong-thread.c Update year range in copyright notice of all files owned by the GDB project. 2015-01-01 13:32:14 +04:00
local-watch-wrong-thread.exp Update year range in copyright notice of all files owned by the GDB project. 2015-01-01 13:32:14 +04:00
Makefile.in
manythreads.c Update year range in copyright notice of all files owned by the GDB project. 2015-01-01 13:32:14 +04:00
manythreads.exp gdb.threads/manythreads.exp: can't read "test": no such variable 2015-04-01 15:30:13 +01:00
multi-create-ns-info-thr.exp gdb.threads/multi-create-ns-info-thr.exp and native-extended-remote board 2015-02-21 12:03:23 +00:00
multi-create.c Update year range in copyright notice of all files owned by the GDB project. 2015-01-01 13:32:14 +04:00
multi-create.exp Update year range in copyright notice of all files owned by the GDB project. 2015-01-01 13:32:14 +04:00
multiple-step-overs.c Add test for PR18214 and PR18216 - multiple step-overs with queued signals 2015-04-08 19:59:03 +01:00
multiple-step-overs.exp gdb/18216: displaced step+deliver signal, a thread needs step-over, crash 2015-04-10 10:36:23 +01:00
next-bp-other-thread.c Update year range in copyright notice of all files owned by the GDB project. 2015-01-01 13:32:14 +04:00
next-bp-other-thread.exp Update year range in copyright notice of all files owned by the GDB project. 2015-01-01 13:32:14 +04:00
no-unwaited-for-left.c Update year range in copyright notice of all files owned by the GDB project. 2015-01-01 13:32:14 +04:00
no-unwaited-for-left.exp kfail two tests in no-unwaited-for-left.exp for remote target 2015-04-02 13:51:31 +01:00
non-ldr-exc-1.c Remove testsuite compile errors with GCC5. 2015-01-25 18:50:56 +01:00
non-ldr-exc-1.exp Update year range in copyright notice of all files owned by the GDB project. 2015-01-01 13:32:14 +04:00
non-ldr-exc-2.c Remove testsuite compile errors with GCC5. 2015-01-25 18:50:56 +01:00
non-ldr-exc-2.exp Update year range in copyright notice of all files owned by the GDB project. 2015-01-01 13:32:14 +04:00
non-ldr-exc-3.c Remove testsuite compile errors with GCC5. 2015-01-25 18:50:56 +01:00
non-ldr-exc-3.exp Update year range in copyright notice of all files owned by the GDB project. 2015-01-01 13:32:14 +04:00
non-ldr-exc-4.c Remove testsuite compile errors with GCC5. 2015-01-25 18:50:56 +01:00
non-ldr-exc-4.exp Update year range in copyright notice of all files owned by the GDB project. 2015-01-01 13:32:14 +04:00
non-stop-fair-events.c Properly set alarm value in gdb.threads/non-stop-fair-events.exp 2015-04-07 11:30:07 +01:00
non-stop-fair-events.exp Properly set alarm value in gdb.threads/non-stop-fair-events.exp 2015-04-07 11:30:07 +01:00
pending-step.c Update year range in copyright notice of all files owned by the GDB project. 2015-01-01 13:32:14 +04:00
pending-step.exp Update year range in copyright notice of all files owned by the GDB project. 2015-01-01 13:32:14 +04:00
print-threads.c
print-threads.exp Update year range in copyright notice of all files owned by the GDB project. 2015-01-01 13:32:14 +04:00
pthread_cond_wait.c Remove testsuite compile errors with GCC5. 2015-01-25 18:50:56 +01:00
pthread_cond_wait.exp Update year range in copyright notice of all files owned by the GDB project. 2015-01-01 13:32:14 +04:00
pthreads.c Remove testsuite compile errors with GCC5. 2015-01-25 18:50:56 +01:00
pthreads.exp Update year range in copyright notice of all files owned by the GDB project. 2015-01-01 13:32:14 +04:00
queue-signal.c Update year range in copyright notice of all files owned by the GDB project. 2015-01-01 13:32:14 +04:00
queue-signal.exp Update year range in copyright notice of all files owned by the GDB project. 2015-01-01 13:32:14 +04:00
reconnect-signal.c Update year range in copyright notice of all files owned by the GDB project. 2015-01-01 13:32:14 +04:00
reconnect-signal.exp Update year range in copyright notice of all files owned by the GDB project. 2015-01-01 13:32:14 +04:00
schedlock.c Update year range in copyright notice of all files owned by the GDB project. 2015-01-01 13:32:14 +04:00
schedlock.exp Make "set scheduler-locking step" depend on user intention, only 2015-03-24 17:50:31 +00:00
siginfo-threads.c gdb.threads/{siginfo-thread.c,watchthreads-reorder.c,ia64-sigill.c} races with GDB 2015-01-09 13:58:29 +00:00
siginfo-threads.exp Update year range in copyright notice of all files owned by the GDB project. 2015-01-01 13:32:14 +04:00
signal-command-handle-nopass.c Update year range in copyright notice of all files owned by the GDB project. 2015-01-01 13:32:14 +04:00
signal-command-handle-nopass.exp Update year range in copyright notice of all files owned by the GDB project. 2015-01-01 13:32:14 +04:00
signal-command-multiple-signals-pending.c Linux: Skip thread_db thread event reporting if PTRACE_EVENT_CLONE is supported 2015-01-09 11:42:57 +00:00
signal-command-multiple-signals-pending.exp Linux: Skip thread_db thread event reporting if PTRACE_EVENT_CLONE is supported 2015-01-09 11:42:57 +00:00
signal-delivered-right-thread.c Update year range in copyright notice of all files owned by the GDB project. 2015-01-01 13:32:14 +04:00
signal-delivered-right-thread.exp Update year range in copyright notice of all files owned by the GDB project. 2015-01-01 13:32:14 +04:00
signal-sigtrap.c Add "signal SIGTRAP" test 2015-02-10 19:30:55 +00:00
signal-sigtrap.exp Add "signal SIGTRAP" test 2015-02-10 19:30:55 +00:00
signal-while-stepping-over-bp-other-thread.c Update year range in copyright notice of all files owned by the GDB project. 2015-01-01 13:32:14 +04:00
signal-while-stepping-over-bp-other-thread.exp Cleanup signal-while-stepping-over-bp-other-thread.exp 2015-04-10 19:49:00 +01:00
sigstep-threads.c Update year range in copyright notice of all files owned by the GDB project. 2015-01-01 13:32:14 +04:00
sigstep-threads.exp Update year range in copyright notice of all files owned by the GDB project. 2015-01-01 13:32:14 +04:00
sigthread.c
sigthread.exp Update year range in copyright notice of all files owned by the GDB project. 2015-01-01 13:32:14 +04:00
staticthreads.c Update year range in copyright notice of all files owned by the GDB project. 2015-01-01 13:32:14 +04:00
staticthreads.exp Update year range in copyright notice of all files owned by the GDB project. 2015-01-01 13:32:14 +04:00
step-bg-decr-pc-switch-thread.c Fix adjust_pc_after_break, remove still current thread check 2015-02-11 09:45:41 +00:00
step-bg-decr-pc-switch-thread.exp Fix adjust_pc_after_break, remove still current thread check 2015-02-11 09:45:41 +00:00
step-over-lands-on-breakpoint.c Update year range in copyright notice of all files owned by the GDB project. 2015-01-01 13:32:14 +04:00
step-over-lands-on-breakpoint.exp Test step-over-{lands-on-breakpoint|trips-on-watchpoint}.exp with displaced stepping 2015-04-10 13:31:59 +01:00
step-over-trips-on-watchpoint.c Make gdb.threads/step-over-trips-on-watchpoint.exp effective on !x86 2015-04-10 13:11:32 +01:00
step-over-trips-on-watchpoint.exp step-over-trips-on-watchpoint.exp: Don't put addresses in test messages 2015-04-10 19:23:24 +01:00
stepi-random-signal.c Update year range in copyright notice of all files owned by the GDB project. 2015-01-01 13:32:14 +04:00
stepi-random-signal.exp Update year range in copyright notice of all files owned by the GDB project. 2015-01-01 13:32:14 +04:00
switch-threads.c Update year range in copyright notice of all files owned by the GDB project. 2015-01-01 13:32:14 +04:00
switch-threads.exp Update year range in copyright notice of all files owned by the GDB project. 2015-01-01 13:32:14 +04:00
thread-execl.c Update year range in copyright notice of all files owned by the GDB project. 2015-01-01 13:32:14 +04:00
thread-execl.exp follow-exec: delete all non-execing threads 2015-03-03 01:25:17 +00:00
thread-find.exp Update year range in copyright notice of all files owned by the GDB project. 2015-01-01 13:32:14 +04:00
thread-specific-bp.c Update year range in copyright notice of all files owned by the GDB project. 2015-01-01 13:32:14 +04:00
thread-specific-bp.exp Fix gdb.threads/thread-specific-bp.exp race 2015-03-04 17:23:55 +00:00
thread-specific.c Update year range in copyright notice of all files owned by the GDB project. 2015-01-01 13:32:14 +04:00
thread-specific.exp Update year range in copyright notice of all files owned by the GDB project. 2015-01-01 13:32:14 +04:00
thread-unwindonsignal.exp Update year range in copyright notice of all files owned by the GDB project. 2015-01-01 13:32:14 +04:00
thread_check.c Update year range in copyright notice of all files owned by the GDB project. 2015-01-01 13:32:14 +04:00
thread_check.exp Update year range in copyright notice of all files owned by the GDB project. 2015-01-01 13:32:14 +04:00
thread_events.c Update year range in copyright notice of all files owned by the GDB project. 2015-01-01 13:32:14 +04:00
thread_events.exp Update year range in copyright notice of all files owned by the GDB project. 2015-01-01 13:32:14 +04:00
threadapply.c Update year range in copyright notice of all files owned by the GDB project. 2015-01-01 13:32:14 +04:00
threadapply.exp Update year range in copyright notice of all files owned by the GDB project. 2015-01-01 13:32:14 +04:00
threxit-hop-specific.c Update year range in copyright notice of all files owned by the GDB project. 2015-01-01 13:32:14 +04:00
threxit-hop-specific.exp Update year range in copyright notice of all files owned by the GDB project. 2015-01-01 13:32:14 +04:00
tid-reuse.c Crash on thread id wrap around 2015-04-01 13:38:06 +01:00
tid-reuse.exp Crash on thread id wrap around 2015-04-01 13:38:06 +01:00
tls-main.c Remove testsuite compile errors with GCC5. 2015-01-25 18:50:56 +01:00
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 year range in copyright notice of all files owned by the GDB project. 2015-01-01 13:32:14 +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 year range in copyright notice of all files owned by the GDB project. 2015-01-01 13:32:14 +04:00
tls-var-main.c Update year range in copyright notice of all files owned by the GDB project. 2015-01-01 13:32:14 +04:00
tls-var.c Update year range in copyright notice of all files owned by the GDB project. 2015-01-01 13:32:14 +04:00
tls-var.exp Update year range in copyright notice of all files owned by the GDB project. 2015-01-01 13:32:14 +04:00
tls.c
tls.exp Update year range in copyright notice of all files owned by the GDB project. 2015-01-01 13:32:14 +04:00
tls2.c Update year range in copyright notice of all files owned by the GDB project. 2015-01-01 13:32:14 +04:00
watchpoint-fork-child.c Update year range in copyright notice of all files owned by the GDB project. 2015-01-01 13:32:14 +04:00
watchpoint-fork-mt.c Remove testsuite compile errors with GCC5. 2015-01-25 18:50:56 +01:00
watchpoint-fork-parent.c Update year range in copyright notice of all files owned by the GDB project. 2015-01-01 13:32:14 +04:00
watchpoint-fork-st.c Update year range in copyright notice of all files owned by the GDB project. 2015-01-01 13:32:14 +04:00
watchpoint-fork.exp Update year range in copyright notice of all files owned by the GDB project. 2015-01-01 13:32:14 +04:00
watchpoint-fork.h Update year range in copyright notice of all files owned by the GDB project. 2015-01-01 13:32:14 +04:00
watchthreads-reorder.c gdb.threads/{siginfo-thread.c,watchthreads-reorder.c,ia64-sigill.c} races with GDB 2015-01-09 13:58:29 +00:00
watchthreads-reorder.exp Update year range in copyright notice of all files owned by the GDB project. 2015-01-01 13:32:14 +04:00
watchthreads.c Update year range in copyright notice of all files owned by the GDB project. 2015-01-01 13:32:14 +04:00
watchthreads.exp Update year range in copyright notice of all files owned by the GDB project. 2015-01-01 13:32:14 +04:00
watchthreads2.c Update year range in copyright notice of all files owned by the GDB project. 2015-01-01 13:32:14 +04:00
watchthreads2.exp Update year range in copyright notice of all files owned by the GDB project. 2015-01-01 13:32:14 +04:00
wp-replication.c Update year range in copyright notice of all files owned by the GDB project. 2015-01-01 13:32:14 +04:00
wp-replication.exp Update year range in copyright notice of all files owned by the GDB project. 2015-01-01 13:32:14 +04:00