diff options
Diffstat (limited to 'gdb/infrun.c')
-rw-r--r-- | gdb/infrun.c | 49 |
1 files changed, 25 insertions, 24 deletions
diff --git a/gdb/infrun.c b/gdb/infrun.c index 1e5e9f1..a55acdf 100644 --- a/gdb/infrun.c +++ b/gdb/infrun.c @@ -64,6 +64,7 @@ #include "event-loop.h" #include "thread-fsm.h" #include "common/enum-flags.h" +#include "user-selection.h" /* Prototypes for local functions */ @@ -152,12 +153,6 @@ show_step_stop_if_no_debug (struct ui_file *file, int from_tty, fprintf_filtered (file, _("Mode of the step operation is %s.\n"), value); } -/* proceed and normal_stop use this to notify the user when the - inferior stopped in a different thread than it had been running - in. */ - -static ptid_t previous_inferior_ptid; - /* If set (default for legacy reasons), when following a fork, GDB will detach from one of the fork branches, child or parent. Exactly which branch is detached depends on 'set follow-fork-mode' @@ -779,6 +774,11 @@ follow_fork (void) { switch_to_thread (child); + /* Switch the user-selected thread as well. */ + struct thread_info *child_tp = find_thread_ptid (child); + gdb_assert (child_tp != nullptr); + global_user_selection ()->select_thread (child_tp, false); + /* ... and preserve the stepping state, in case the user was stepping over the fork call. */ if (should_resume) @@ -809,7 +809,14 @@ follow_fork (void) follow_inferior_reset_breakpoints (); } else - switch_to_thread (parent); + { + switch_to_thread (parent); + + /* Switch the user-selected thread as well. */ + struct thread_info *parent_tp = find_thread_ptid (parent); + gdb_assert (parent_tp != nullptr); + global_user_selection ()->select_thread (parent_tp, false); + } } } break; @@ -2999,9 +3006,6 @@ proceed (CORE_ADDR addr, enum gdb_signal siggnal) return; } - /* We'll update this if & when we switch to a new thread. */ - previous_inferior_ptid = inferior_ptid; - regcache = get_current_regcache (); gdbarch = get_regcache_arch (regcache); aspace = get_regcache_aspace (regcache); @@ -3252,8 +3256,6 @@ init_wait_for_inferior (void) target_last_wait_ptid = minus_one_ptid; - previous_inferior_ptid = inferior_ptid; - /* Discard any skipped inlined frames. */ clear_inline_frame_state (minus_one_ptid); } @@ -8157,7 +8159,7 @@ save_stop_context (void) /* Take a strong reference so that the thread can't be deleted yet. */ sc->thread = inferior_thread (); - sc->thread->refcount++; + sc->thread->get (); } else sc->thread = NULL; @@ -8174,7 +8176,8 @@ release_stop_context_cleanup (void *arg) struct stop_context *sc = (struct stop_context *) arg; if (sc->thread != NULL) - sc->thread->refcount--; + sc->thread->put (); + xfree (sc); } @@ -8262,20 +8265,16 @@ normal_stop (void) after this event is handled, so we're not really switching, only informing of a stop. */ if (!non_stop - && !ptid_equal (previous_inferior_ptid, inferior_ptid) && target_has_execution && last.kind != TARGET_WAITKIND_SIGNALLED && last.kind != TARGET_WAITKIND_EXITED && last.kind != TARGET_WAITKIND_NO_RESUMED) { - SWITCH_THRU_ALL_UIS () - { - target_terminal_ours_for_output (); - printf_filtered (_("[Switching to %s]\n"), - target_pid_to_str (inferior_ptid)); - annotate_thread_changed (); - } - previous_inferior_ptid = inferior_ptid; + struct thread_info *thread = find_thread_ptid (inferior_ptid); + + gdb_assert (thread != nullptr); + + global_user_selection ()->select_thread (thread, false); } if (last.kind == TARGET_WAITKIND_NO_RESUMED) @@ -8986,7 +8985,7 @@ struct infcall_control_state enum stop_stack_kind stop_stack_dummy; int stopped_by_random_signal; - /* ID if the selected frame when the inferior function call was made. */ + /* ID of the selected frame when the inferior function call was made. */ struct frame_id selected_frame_id; }; @@ -9080,6 +9079,8 @@ restore_infcall_control_state (struct infcall_control_state *inf_status) /* Error in restoring the selected frame. Select the innermost frame. */ select_frame (get_current_frame ()); + + global_user_selection ()->select_frame (get_selected_frame (NULL), false); } xfree (inf_status); |