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
This commit is contained in:
Simon Marchi
2023-11-05 04:47:26 +00:00
parent 7438771288
commit 9c742269ec
31 changed files with 80 additions and 83 deletions

View File

@@ -136,7 +136,7 @@ bsd_kvm_target_open (const char *arg, int from_tty)
thread_info *thr = add_thread_silent (&bsd_kvm_ops, bsd_kvm_ptid);
switch_to_thread (thr);
target_fetch_registers (get_current_regcache (), -1);
target_fetch_registers (get_thread_regcache (thr), -1);
reinit_frame_cache ();
print_stack_frame (get_selected_frame (NULL), 0, SRC_AND_LOC, 1);
@@ -334,7 +334,7 @@ bsd_kvm_proc_cmd (const char *arg, int fromtty)
if (kvm_read (core_kd, addr, &bsd_kvm_paddr, sizeof bsd_kvm_paddr) == -1)
error (("%s"), kvm_geterr (core_kd));
target_fetch_registers (get_current_regcache (), -1);
target_fetch_registers (get_thread_regcache (inferior_thread ()), -1);
reinit_frame_cache ();
print_stack_frame (get_selected_frame (NULL), 0, SRC_AND_LOC, 1);
@@ -354,7 +354,7 @@ bsd_kvm_pcb_cmd (const char *arg, int fromtty)
bsd_kvm_paddr = (struct pcb *)(u_long) parse_and_eval_address (arg);
target_fetch_registers (get_current_regcache (), -1);
target_fetch_registers (get_thread_regcache (inferior_thread ()), -1);
reinit_frame_cache ();
print_stack_frame (get_selected_frame (NULL), 0, SRC_AND_LOC, 1);