From: Tom Tromey Date: Fri, 7 Aug 2020 16:26:45 +0000 (-0600) Subject: Fix remaining Ravenscar regressions X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=a52b3ae2b101b0fefcfa8c4534472525bcbfdf3d;p=binutils-gdb.git Fix remaining Ravenscar regressions Testing showed a few more Ravenscar regressions arising from upstream. In particular, gdb now uses the current thread in some places where inferior_ptid was previously used. This patch fixes the problem by arranging to save and restore the thread now. gdb/ChangeLog 2020-08-07 Tom Tromey * ravenscar-thread.c (ravenscar_thread_target::set_base_thread_from_ravenscar_task): New method. (ravenscar_thread_target::wait): Check runtime_initialized. (ravenscar_thread_target::prepare_to_store) (ravenscar_thread_target::stopped_by_sw_breakpoint) (ravenscar_thread_target::stopped_by_hw_breakpoint) (ravenscar_thread_target::stopped_by_watchpoint) (ravenscar_thread_target::stopped_data_address) (ravenscar_thread_target::core_of_thread): Use scoped_restore_current_thread and set_base_thread_from_ravenscar_task. --- diff --git a/gdb/ChangeLog b/gdb/ChangeLog index 6ae8d7bc1ad..c3dcd680795 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,3 +1,19 @@ +2020-08-07 Tom Tromey + + * ravenscar-thread.c + (ravenscar_thread_target::set_base_thread_from_ravenscar_task): + New method. + (ravenscar_thread_target::wait): Check + runtime_initialized. + (ravenscar_thread_target::prepare_to_store) + (ravenscar_thread_target::stopped_by_sw_breakpoint) + (ravenscar_thread_target::stopped_by_hw_breakpoint) + (ravenscar_thread_target::stopped_by_watchpoint) + (ravenscar_thread_target::stopped_data_address) + (ravenscar_thread_target::core_of_thread): Use + scoped_restore_current_thread and + set_base_thread_from_ravenscar_task. + 2020-08-07 Tom Tromey * ravenscar-thread.c (update_thread_list): Set inferior_ptid. diff --git a/gdb/ravenscar-thread.c b/gdb/ravenscar-thread.c index 37df2188cf3..387ebcb32e9 100644 --- a/gdb/ravenscar-thread.c +++ b/gdb/ravenscar-thread.c @@ -151,6 +151,15 @@ private: ptid_t get_base_thread_from_ravenscar_task (ptid_t ptid); void add_thread (struct ada_task_info *task); + /* Like switch_to_thread, but uses the base ptid for the thread. */ + void set_base_thread_from_ravenscar_task (ptid_t ptid) + { + process_stratum_target *proc_target + = as_process_stratum_target (this->beneath ()); + ptid_t underlying = get_base_thread_from_ravenscar_task (ptid); + switch_to_thread (find_thread_ptid (proc_target, underlying)); + } + /* This maps a TID to the CPU on which it was running. This is needed because sometimes the runtime will report an active task that hasn't yet been put on the list of tasks that is read by @@ -571,8 +580,8 @@ ravenscar_thread_target::prepare_to_store (struct regcache *regcache) bool ravenscar_thread_target::stopped_by_sw_breakpoint () { - scoped_restore save_ptid = make_scoped_restore (&inferior_ptid); - inferior_ptid = get_base_thread_from_ravenscar_task (inferior_ptid); + scoped_restore_current_thread saver; + set_base_thread_from_ravenscar_task (inferior_ptid); return beneath ()->stopped_by_sw_breakpoint (); } @@ -581,8 +590,8 @@ ravenscar_thread_target::stopped_by_sw_breakpoint () bool ravenscar_thread_target::stopped_by_hw_breakpoint () { - scoped_restore save_ptid = make_scoped_restore (&inferior_ptid); - inferior_ptid = get_base_thread_from_ravenscar_task (inferior_ptid); + scoped_restore_current_thread saver; + set_base_thread_from_ravenscar_task (inferior_ptid); return beneath ()->stopped_by_hw_breakpoint (); } @@ -591,8 +600,8 @@ ravenscar_thread_target::stopped_by_hw_breakpoint () bool ravenscar_thread_target::stopped_by_watchpoint () { - scoped_restore save_ptid = make_scoped_restore (&inferior_ptid); - inferior_ptid = get_base_thread_from_ravenscar_task (inferior_ptid); + scoped_restore_current_thread saver; + set_base_thread_from_ravenscar_task (inferior_ptid); return beneath ()->stopped_by_watchpoint (); } @@ -601,8 +610,8 @@ ravenscar_thread_target::stopped_by_watchpoint () bool ravenscar_thread_target::stopped_data_address (CORE_ADDR *addr_p) { - scoped_restore save_ptid = make_scoped_restore (&inferior_ptid); - inferior_ptid = get_base_thread_from_ravenscar_task (inferior_ptid); + scoped_restore_current_thread saver; + set_base_thread_from_ravenscar_task (inferior_ptid); return beneath ()->stopped_data_address (addr_p); } @@ -620,8 +629,8 @@ ravenscar_thread_target::mourn_inferior () int ravenscar_thread_target::core_of_thread (ptid_t ptid) { - scoped_restore save_ptid = make_scoped_restore (&inferior_ptid); - inferior_ptid = get_base_thread_from_ravenscar_task (inferior_ptid); + scoped_restore_current_thread saver; + set_base_thread_from_ravenscar_task (inferior_ptid); return beneath ()->core_of_thread (inferior_ptid); }