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

@@ -1164,7 +1164,7 @@ frame_pop (frame_info_ptr this_frame)
definition can lead to targets writing back bogus values
(arguably a bug in the target code mind). */
/* Now copy those saved registers into the current regcache. */
get_current_regcache ()->restore (scratch.get ());
get_thread_regcache (inferior_thread ())->restore (scratch.get ());
/* We've made right mess of GDB's local state, just discard
everything. */
@@ -1445,7 +1445,7 @@ put_frame_register (frame_info_ptr frame, int regnum,
break;
}
case lval_register:
get_current_regcache ()->cooked_write (realnum, buf);
get_thread_regcache (inferior_thread ())->cooked_write (realnum, buf);
break;
default:
error (_("Attempt to assign to an unmodifiable value."));
@@ -1690,7 +1690,8 @@ get_current_frame (void)
if (sentinel_frame == NULL)
sentinel_frame =
create_sentinel_frame (current_program_space, current_inferior ()->aspace,
get_current_regcache (), 0, 0).get ();
get_thread_regcache (inferior_thread ()),
0, 0).get ();
/* Set the current frame before computing the frame id, to avoid
recursion inside compute_frame_id, in case the frame's
@@ -2024,7 +2025,7 @@ create_new_frame (frame_id id)
fi->next = create_sentinel_frame (current_program_space,
current_inferior ()->aspace,
get_current_regcache (),
get_thread_regcache (inferior_thread ()),
id.stack_addr, id.code_addr).get ();
/* Set/update this frame's cached PC value, found in the next frame.