aboutsummaryrefslogtreecommitdiff
path: root/gdb/infrun.c
diff options
context:
space:
mode:
authorPedro Alves <palves@redhat.com>2015-06-29 16:07:57 +0100
committerPedro Alves <palves@redhat.com>2015-06-29 16:07:57 +0100
commit28bf096c62d7da6b349605f3940f4c586a850f78 (patch)
tree65c0704ba57a22a29c866b96b3bcd7b08211ca43 /gdb/infrun.c
parent2880b51c25b055013c2f4939a5d0c0779b972bb3 (diff)
downloadfsf-binutils-gdb-28bf096c62d7da6b349605f3940f4c586a850f78.zip
fsf-binutils-gdb-28bf096c62d7da6b349605f3940f4c586a850f78.tar.gz
fsf-binutils-gdb-28bf096c62d7da6b349605f3940f4c586a850f78.tar.bz2
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.
Diffstat (limited to 'gdb/infrun.c')
-rw-r--r--gdb/infrun.c31
1 files changed, 13 insertions, 18 deletions
diff --git a/gdb/infrun.c b/gdb/infrun.c
index 792f847..445a612 100644
--- a/gdb/infrun.c
+++ b/gdb/infrun.c
@@ -2264,11 +2264,8 @@ resume (enum gdb_signal sig)
requests finish. The thread is not executing at this
point, and the call to set_executing will be made later.
But we need to call set_running here, since from the
- user/frontend's point of view, threads were set running.
- Unless we're calling an inferior function, as in that
- case we pretend the inferior doesn't run at all. */
- if (!tp->control.in_infcall)
- set_running (user_visible_resume_ptid (user_step), 1);
+ user/frontend's point of view, threads were set running. */
+ set_running (user_visible_resume_ptid (user_step), 1);
discard_cleanups (old_cleanups);
return;
}
@@ -2346,10 +2343,8 @@ resume (enum gdb_signal sig)
/* Even if RESUME_PTID is a wildcard, and we end up resuming less
(e.g., we might need to step over a breakpoint), from the
user/frontend's point of view, all threads in RESUME_PTID are now
- running. Unless we're calling an inferior function, as in that
- case pretend we inferior doesn't run at all. */
- if (!tp->control.in_infcall)
- set_running (resume_ptid, 1);
+ running. */
+ set_running (resume_ptid, 1);
/* Maybe resume a single thread after all. */
if ((step || thread_has_single_step_breakpoints_set (tp))
@@ -6664,15 +6659,15 @@ normal_stop (void)
if (has_stack_frames () && !stop_stack_dummy)
set_current_sal_from_frame (get_current_frame ());
- /* Let the user/frontend see the threads as stopped, but do nothing
- if the thread was running an infcall. We may be e.g., evaluating
- a breakpoint condition. In that case, the thread had state
- THREAD_RUNNING before the infcall, and shall remain set to
- running, all without informing the user/frontend about state
- transition changes. If this is actually a call command, then the
- thread was originally already stopped, so there's no state to
- finish either. */
- if (target_has_execution && inferior_thread ()->control.in_infcall)
+ /* Let the user/frontend see the threads as stopped, but defer to
+ call_function_by_hand if the thread finished an infcall
+ successfully. We may be e.g., evaluating a breakpoint condition.
+ In that case, the thread had state THREAD_RUNNING before the
+ infcall, and shall remain marked running, all without informing
+ the user/frontend about state transition changes. */
+ if (target_has_execution
+ && inferior_thread ()->control.in_infcall
+ && stop_stack_dummy == STOP_STACK_DUMMY)
discard_cleanups (old_chain);
else
do_cleanups (old_chain);