diff options
author | Simon Marchi <simon.marchi@efficios.com> | 2023-11-05 04:47:26 +0000 |
---|---|---|
committer | Simon Marchi <simon.marchi@efficios.com> | 2023-11-17 20:01:37 +0000 |
commit | 9c742269ec8507d924d7a0c815155ca5aa21467a (patch) | |
tree | 311e5334f6a80b23a0b361e8f916a5df9a57ab0e /gdb/infrun.c | |
parent | 7438771288f1acd5ab25277188a75ce9e48e256c (diff) | |
download | binutils-9c742269ec8507d924d7a0c815155ca5aa21467a.zip binutils-9c742269ec8507d924d7a0c815155ca5aa21467a.tar.gz binutils-9c742269ec8507d924d7a0c815155ca5aa21467a.tar.bz2 |
gdb: remove get_current_regcache
Remove get_current_regcache, inlining the call to get_thread_regcache in
callers. When possible, pass the right thread_info object known from
the local context. Otherwise, fall back to passing `inferior_thread ()`.
This makes the reference to global context bubble up one level, a small
step towards the long term goal of reducing the number of references to
global context (or rather, moving those references as close as possible
to the top of the call tree).
No behavior change expected.
Change-Id: Ifa6980c88825d803ea586546b6b4c633c33be8d6
Diffstat (limited to 'gdb/infrun.c')
-rw-r--r-- | gdb/infrun.c | 23 |
1 files changed, 10 insertions, 13 deletions
diff --git a/gdb/infrun.c b/gdb/infrun.c index 785a4e1..4138d00 100644 --- a/gdb/infrun.c +++ b/gdb/infrun.c @@ -2621,9 +2621,9 @@ do_target_resume (ptid_t resume_ptid, bool step, enum gdb_signal sig) static void resume_1 (enum gdb_signal sig) { - struct regcache *regcache = get_current_regcache (); - struct gdbarch *gdbarch = regcache->arch (); struct thread_info *tp = inferior_thread (); + regcache *regcache = get_thread_regcache (tp); + struct gdbarch *gdbarch = regcache->arch (); ptid_t resume_ptid; /* This represents the user's step vs continue request. When deciding whether "set scheduler-locking step" applies, it's the @@ -3566,7 +3566,6 @@ proceed (CORE_ADDR addr, enum gdb_signal siggnal) { INFRUN_SCOPED_DEBUG_ENTER_EXIT; - struct regcache *regcache; struct gdbarch *gdbarch; CORE_ADDR pc; @@ -3587,15 +3586,13 @@ proceed (CORE_ADDR addr, enum gdb_signal siggnal) /* We'll update this if & when we switch to a new thread. */ update_previous_thread (); - regcache = get_current_regcache (); - gdbarch = regcache->arch (); - - pc = regcache_read_pc_protected (regcache); - thread_info *cur_thr = inferior_thread (); - infrun_debug_printf ("cur_thr = %s", cur_thr->ptid.to_string ().c_str ()); + regcache *regcache = get_thread_regcache (cur_thr); + gdbarch = regcache->arch (); + pc = regcache_read_pc_protected (regcache); + /* Fill in with reasonable starting values. */ init_thread_stepping_state (cur_thr); @@ -8894,7 +8891,7 @@ keep_going_pass_signal (struct execution_control_state *ecs) } else { - struct regcache *regcache = get_current_regcache (); + regcache *regcache = get_thread_regcache (ecs->event_thread); int remove_bp; int remove_wps; step_over_what step_what; @@ -9112,7 +9109,7 @@ print_signal_received_reason (struct ui_out *uiout, enum gdb_signal siggnal) annotate_signal_string (); uiout->field_string ("signal-meaning", gdb_signal_to_string (siggnal)); - struct regcache *regcache = get_current_regcache (); + regcache *regcache = get_thread_regcache (thr); struct gdbarch *gdbarch = regcache->arch (); if (gdbarch_report_signal_info_p (gdbarch)) gdbarch_report_signal_info (gdbarch, uiout, siggnal); @@ -10026,7 +10023,7 @@ infcall_suspend_state_up save_infcall_suspend_state () { struct thread_info *tp = inferior_thread (); - struct regcache *regcache = get_current_regcache (); + regcache *regcache = get_thread_regcache (tp); struct gdbarch *gdbarch = regcache->arch (); infcall_suspend_state_up inf_state @@ -10047,7 +10044,7 @@ void restore_infcall_suspend_state (struct infcall_suspend_state *inf_state) { struct thread_info *tp = inferior_thread (); - struct regcache *regcache = get_current_regcache (); + regcache *regcache = get_thread_regcache (inferior_thread ()); struct gdbarch *gdbarch = regcache->arch (); inf_state->restore (gdbarch, tp, regcache); |