]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commitdiff
gdb: remove get_current_regcache
authorSimon Marchi <simon.marchi@efficios.com>
Sun, 5 Nov 2023 04:47:26 +0000 (04:47 +0000)
committerSimon Marchi <simon.marchi@efficios.com>
Fri, 17 Nov 2023 20:01:37 +0000 (20:01 +0000)
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

31 files changed:
gdb/arc-tdep.c
gdb/breakpoint.c
gdb/bsd-kvm.c
gdb/corelow.c
gdb/frame.c
gdb/frv-tdep.c
gdb/i386-fbsd-nat.c
gdb/i386-tdep.c
gdb/ia64-linux-nat.c
gdb/infcall.c
gdb/infcmd.c
gdb/infrun.c
gdb/linux-fork.c
gdb/m32c-tdep.c
gdb/mep-tdep.c
gdb/mi/mi-main.c
gdb/or1k-tdep.c
gdb/procfs.c
gdb/record-btrace.c
gdb/record-full.c
gdb/regcache-dump.c
gdb/regcache.c
gdb/regcache.h
gdb/reverse.c
gdb/solib-darwin.c
gdb/solib-svr4.c
gdb/stack.c
gdb/symfile.c
gdb/tracepoint.c
gdb/windows-nat.c
gdb/xtensa-tdep.c

index 0740eff02e456661a09c17813693e6c39951fada..a22b5bff246b3f39a7ce45d4add2ca4575026a2a 100644 (file)
@@ -322,7 +322,7 @@ arc_insn_get_operand_value (const struct arc_instruction &insn,
       return insn.operands[operand_num].value;
     default:
       /* Value in instruction is a register number.  */
-      struct regcache *regcache = get_current_regcache ();
+      regcache *regcache = get_thread_regcache (inferior_thread ());
       ULONGEST value;
       regcache_cooked_read_unsigned (regcache,
                                     insn.operands[operand_num].value,
@@ -351,7 +351,7 @@ arc_insn_get_operand_value_signed (const struct arc_instruction &insn,
       return insn.operands[operand_num].value;
     default:
       /* Value in instruction is a register number.  */
-      struct regcache *regcache = get_current_regcache ();
+      regcache *regcache = get_thread_regcache (inferior_thread ());
       LONGEST value;
       regcache_cooked_read_signed (regcache,
                                   insn.operands[operand_num].value,
@@ -449,7 +449,7 @@ arc_insn_get_branch_target (const struct arc_instruction &insn)
   /* LEAVE_S: PC = BLINK.  */
   else if (insn.insn_class == LEAVE)
     {
-      struct regcache *regcache = get_current_regcache ();
+      regcache *regcache = get_thread_regcache (inferior_thread ());
       ULONGEST value;
       regcache_cooked_read_unsigned (regcache, ARC_BLINK_REGNUM, &value);
       return value;
index a6b9b2402edb42b2c9d9183e0c105b00886eba97..cd8f36fbf05e19f9a2847b518e33f1f7efdfd636 100644 (file)
@@ -13946,7 +13946,7 @@ insert_single_step_breakpoint (struct gdbarch *gdbarch,
 int
 insert_single_step_breakpoints (struct gdbarch *gdbarch)
 {
-  struct regcache *regcache = get_current_regcache ();
+  regcache *regcache = get_thread_regcache (inferior_thread ());
   std::vector<CORE_ADDR> next_pcs;
 
   next_pcs = gdbarch_software_single_step (gdbarch, regcache);
index 0ed95f6246c9f2239a155dd3667895b69abcee9f..bb2d038b2ce25fea09cc848ed6de865da2061f09 100644 (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);
index 91b442b4426faf18a11d57463460f2efee407949..a38d9622f390473832dbf6a8d76d8e9c5c62ffa2 100644 (file)
@@ -773,7 +773,7 @@ core_target_open (const char *arg, int from_tty)
     }
 
   /* Fetch all registers from core file.  */
-  target_fetch_registers (get_current_regcache (), -1);
+  target_fetch_registers (get_thread_regcache (inferior_thread ()), -1);
 
   /* Now, set up the frame cache, and print the top of stack.  */
   reinit_frame_cache ();
index dfd92991d99a03f7a30beb653176ae72333c3bf7..5ac84a8d0cd8dd6b1ad827f960eeffbd123b92b6 100644 (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.
index 3656f6fcb663c0f3eb2f617cb693a30ed404e1ee..6528cf3e405efd721f66b3a6f591f5fb3bc80ff3 100644 (file)
@@ -114,7 +114,7 @@ frv_fdpic_loadmap_addresses (struct gdbarch *gdbarch, CORE_ADDR *interp_addr,
     return -1;
   else
     {
-      struct regcache *regcache = get_current_regcache ();
+      regcache *regcache = get_thread_regcache (inferior_thread ());
 
       if (interp_addr != NULL)
        {
index e2c0e611717141ca18ba0823ca65d899bac8220c..7eb3b40e36953714b833f16ae39810a2e8c42fcd 100644 (file)
@@ -233,7 +233,7 @@ i386_fbsd_nat_target::resume (ptid_t ptid, int step, enum gdb_signal signal)
 
   if (!step)
     {
-      struct regcache *regcache = get_current_regcache ();
+      regcache *regcache = get_thread_regcache (inferior_thread ());
       ULONGEST eflags;
 
       /* Workaround for a bug in FreeBSD.  Make sure that the trace
index 1ddca2410fdf7e2f92093b627646430ce4d1cadf..f5ff55de47ac496d9b96b347da7aa2930eb261a1 100644 (file)
@@ -8907,11 +8907,10 @@ i386_target_description (uint64_t xcr0, bool segments)
 static unsigned long
 i386_mpx_bd_base (void)
 {
-  struct regcache *rcache;
   ULONGEST ret;
   enum register_status regstatus;
 
-  rcache = get_current_regcache ();
+  regcache *rcache = get_thread_regcache (inferior_thread ());
   gdbarch *arch = rcache->arch ();
   i386_gdbarch_tdep *tdep = gdbarch_tdep<i386_gdbarch_tdep> (arch);
 
index f9f21d8e067d3bab556ed93658397be7580e7e88..a610de60d4469675ae6499ac6b71ca14404aa8fd 100644 (file)
@@ -693,7 +693,7 @@ ia64_linux_nat_target::stopped_data_address (CORE_ADDR *addr_p)
 {
   CORE_ADDR psr;
   siginfo_t siginfo;
-  struct regcache *regcache = get_current_regcache ();
+  regcache *regcache = get_thread_regcache (inferior_thread ());
 
   if (!linux_nat_get_siginfo (inferior_ptid, &siginfo))
     return false;
index e62c2205808a729b2db1ce4415b73afe8b497bb2..8252feea0749892848fdea65ac4f15d1e65c08b1 100644 (file)
@@ -482,7 +482,7 @@ get_call_return_value (struct call_return_meta_info *ri)
   else
     {
       gdbarch_return_value_as_value (ri->gdbarch, ri->function, ri->value_type,
-                                    get_current_regcache (),
+                                    get_thread_regcache (inferior_thread ()),
                                     &retval, NULL);
       if (stack_temporaries && class_or_union_p (ri->value_type))
        {
@@ -1068,7 +1068,7 @@ call_function_by_hand_dummy (struct value *function,
 
        sp = push_dummy_code (gdbarch, sp, funaddr, args,
                              target_values_type, &real_pc, &bp_addr,
-                             get_current_regcache ());
+                             get_thread_regcache (inferior_thread ()));
 
        /* Write a legitimate instruction at the point where the infcall
           breakpoint is going to be inserted.  While this instruction
@@ -1270,7 +1270,8 @@ call_function_by_hand_dummy (struct value *function,
   /* Create the dummy stack frame.  Pass in the call dummy address as,
      presumably, the ABI code knows where, in the call dummy, the
      return address should be pointed.  */
-  sp = gdbarch_push_dummy_call (gdbarch, function, get_current_regcache (),
+  sp = gdbarch_push_dummy_call (gdbarch, function,
+                               get_thread_regcache (inferior_thread ()),
                                bp_addr, args.size (), args.data (),
                                sp, return_method, struct_addr);
 
index cf8cd52795584f638dbb92cbbef2db41a26d2e8c..8890a16eade2ded860eeb9a055460a61dac59185 100644 (file)
@@ -496,7 +496,8 @@ run_command_1 (const char *args, int from_tty, enum run_how run_how)
 
   /* Start the target running.  Do not use -1 continuation as it would skip
      breakpoint right at the entry point.  */
-  proceed (regcache_read_pc (get_current_regcache ()), GDB_SIGNAL_0);
+  proceed (regcache_read_pc (get_thread_regcache (inferior_thread ())),
+          GDB_SIGNAL_0);
 
   /* Since there was no error, there's no need to finish the thread
      states here.  */
@@ -1466,7 +1467,7 @@ advance_command (const char *arg, int from_tty)
 struct value *
 get_return_value (struct symbol *func_symbol, struct value *function)
 {
-  regcache *stop_regs = get_current_regcache ();
+  regcache *stop_regs = get_thread_regcache (inferior_thread ());
   struct gdbarch *gdbarch = stop_regs->arch ();
   struct value *value;
 
index 785a4e198ec2bb969baa48dbb3260c234a5950b8..4138d00b0f440b1330c1a553ce9b24a990e89220 100644 (file)
@@ -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);
index 52e385411c7e656b51fca270c649e21620ebb98f..39c3a6b34489b0eabb9388190e1744d7ed2b9cd8 100644 (file)
@@ -219,12 +219,13 @@ fork_load_infrun_state (struct fork_info *fp)
   linux_nat_switch_fork (fp->ptid);
 
   if (fp->savedregs)
-    get_current_regcache ()->restore (fp->savedregs);
+    get_thread_regcache (inferior_thread ())->restore (fp->savedregs);
 
   registers_changed ();
   reinit_frame_cache ();
 
-  inferior_thread ()->set_stop_pc (regcache_read_pc (get_current_regcache ()));
+  inferior_thread ()->set_stop_pc
+    (regcache_read_pc (get_thread_regcache (inferior_thread ())));
   nullify_last_target_wait_ptid ();
 
   /* Now restore the file positions of open file descriptors.  */
@@ -251,8 +252,9 @@ fork_save_infrun_state (struct fork_info *fp)
   if (fp->savedregs)
     delete fp->savedregs;
 
-  fp->savedregs = new readonly_detached_regcache (*get_current_regcache ());
-  fp->pc = regcache_read_pc (get_current_regcache ());
+  fp->savedregs = new readonly_detached_regcache
+    (*get_thread_regcache (inferior_thread ()));
+  fp->pc = regcache_read_pc (get_thread_regcache (inferior_thread ()));
 
   /* Now save the 'state' (file position) of all open file descriptors.
      Unfortunately fork does not take care of that for us...  */
index e06dbbe12bfffa63026b6f6ae07bbeb8b68a505d..a0f1779c41b03de9dc4d7a5e0c28acc3f2cde8d0 100644 (file)
@@ -2556,7 +2556,7 @@ m32c_virtual_frame_pointer (struct gdbarch *gdbarch, CORE_ADDR pc,
   CORE_ADDR func_addr, func_end;
   struct m32c_prologue p;
 
-  struct regcache *regcache = get_current_regcache ();
+  regcache *regcache = get_thread_regcache (inferior_thread ());
   m32c_gdbarch_tdep *tdep = gdbarch_tdep<m32c_gdbarch_tdep> (gdbarch);
   
   if (!find_pc_partial_function (pc, &name, &func_addr, &func_end))
index a84df4e1f53ccc5fbd12ce478ba8e644df9d18c1..6210b929f9d0d27f3dfd5235e34fc1a9180ffe4d 100644 (file)
@@ -852,7 +852,7 @@ current_me_module (void)
   if (target_has_registers ())
     {
       ULONGEST regval;
-      regcache_cooked_read_unsigned (get_current_regcache (),
+      regcache_cooked_read_unsigned (get_thread_regcache (inferior_thread ()),
                                     MEP_MODULE_REGNUM, &regval);
       return (CONFIG_ATTR) regval;
     }
@@ -879,7 +879,7 @@ current_options (void)
   if (target_has_registers ())
     {
       ULONGEST regval;
-      regcache_cooked_read_unsigned (get_current_regcache (),
+      regcache_cooked_read_unsigned (get_thread_regcache (inferior_thread ()),
                                     MEP_OPT_REGNUM, &regval);
       return regval;
     }
index 944c9116731fc5e24c4ecbe266c0f0eec4643eaa..abcd0d392ba11cf3d33c5474d4a4074f82bee287 100644 (file)
@@ -1132,7 +1132,6 @@ void
 mi_cmd_data_write_register_values (const char *command,
                                   const char *const *argv, int argc)
 {
-  struct regcache *regcache;
   struct gdbarch *gdbarch;
   int numregs, i;
 
@@ -1143,7 +1142,7 @@ mi_cmd_data_write_register_values (const char *command,
      will change depending upon the particular processor being
      debugged.  */
 
-  regcache = get_current_regcache ();
+  regcache *regcache = get_thread_regcache (inferior_thread ());
   gdbarch = regcache->arch ();
   numregs = gdbarch_num_cooked_regs (gdbarch);
 
index a472a766959c0f6879f2e3e98ce2c714bac56cc7..74d56d9a8bd53a76adb11451261d7b5558c68356 100644 (file)
@@ -383,7 +383,7 @@ or1k_single_step_through_delay (struct gdbarch *gdbarch,
   ULONGEST val;
   CORE_ADDR ppc;
   CORE_ADDR npc;
-  struct regcache *regcache = get_current_regcache ();
+  regcache *regcache = get_thread_regcache (inferior_thread ());
 
   /* Get the previous and current instruction addresses.  If they are not
     adjacent, we cannot be in a delay slot.  */
index 0e8a08f99d3091afcab32d56762b05c82800a8a7..3a5d173ee429ccffd44363b9c155ce84dac7b8e1 100644 (file)
@@ -3605,7 +3605,7 @@ procfs_target::make_corefile_notes (bfd *obfd, int *note_size)
 
   stop_signal = find_stop_signal ();
 
-  fill_gregset (get_current_regcache (), &gregs, -1);
+  fill_gregset (get_thread_regcache (inferior_thread ()), &gregs, -1);
   note_data.reset (elfcore_write_pstatus (obfd, note_data.release (), note_size,
                                          inferior_ptid.pid (),
                                          stop_signal, &gregs));
index abab79f3132cf8bef82e4e35f9e91ec59b65d1dd..f0e190f9bf7a0e560acdb2fc0737971c198a57f4 100644 (file)
@@ -2782,7 +2782,7 @@ record_btrace_set_replay (struct thread_info *tp,
   /* Start anew from the new replay position.  */
   record_btrace_clear_histories (btinfo);
 
-  inferior_thread ()->set_stop_pc (regcache_read_pc (get_current_regcache ()));
+  tp->set_stop_pc (regcache_read_pc (get_thread_regcache (tp)));
   print_stack_frame (get_selected_frame (NULL), 1, SRC_AND_LOC, 1);
 }
 
index 1cea869e88bb1c7162f15aa8c6acc89e3f44646b..0ce6862f819d1c32c18c319fe239d6b668b090bf 100644 (file)
@@ -913,7 +913,7 @@ record_full_async_inferior_event_handler (gdb_client_data data)
 static void
 record_full_core_open_1 (const char *name, int from_tty)
 {
-  struct regcache *regcache = get_current_regcache ();
+  regcache *regcache = get_thread_regcache (inferior_thread ());
   int regnum = gdbarch_num_regs (regcache->arch ());
   int i;
 
@@ -1069,7 +1069,7 @@ record_full_target::resume (ptid_t ptid, int step, enum gdb_signal signal)
     {
       struct gdbarch *gdbarch = target_thread_architecture (ptid);
 
-      record_full_message (get_current_regcache (), signal);
+      record_full_message (get_thread_regcache (inferior_thread ()), signal);
 
       if (!step)
        {
@@ -1216,7 +1216,7 @@ record_full_wait_1 (struct target_ops *ops,
                  registers_changed ();
                  switch_to_thread (current_inferior ()->process_target (),
                                    ret);
-                 regcache = get_current_regcache ();
+                 regcache = get_thread_regcache (inferior_thread ());
                  tmp_pc = regcache_read_pc (regcache);
                  const address_space *aspace = current_inferior ()->aspace;
 
@@ -1286,7 +1286,7 @@ record_full_wait_1 (struct target_ops *ops,
     {
       switch_to_thread (current_inferior ()->process_target (),
                        record_full_resume_ptid);
-      struct regcache *regcache = get_current_regcache ();
+      regcache *regcache = get_thread_regcache (inferior_thread ());
       struct gdbarch *gdbarch = regcache->arch ();
       const address_space *aspace = current_inferior ()->aspace;
       int continue_flag = 1;
@@ -2001,7 +2001,9 @@ record_full_goto_entry (struct record_full_entry *p)
 
   registers_changed ();
   reinit_frame_cache ();
-  inferior_thread ()->set_stop_pc (regcache_read_pc (get_current_regcache ()));
+  
+  thread_info *thr = inferior_thread ();
+  thr->set_stop_pc (regcache_read_pc (get_thread_regcache (thr)));
   print_stack_frame (get_selected_frame (NULL), 1, SRC_AND_LOC, 1);
 }
 
@@ -2322,7 +2324,6 @@ record_full_restore (void)
   asection *osec;
   uint32_t osec_size;
   int bfd_offset = 0;
-  struct regcache *regcache;
 
   /* We restore the execution log from the open core bfd,
      if there is one.  */
@@ -2365,7 +2366,7 @@ record_full_restore (void)
 
   try
     {
-      regcache = get_current_regcache ();
+      regcache *regcache = get_thread_regcache (inferior_thread ());
 
       while (1)
        {
@@ -2525,7 +2526,6 @@ record_full_base_target::save_record (const char *recfilename)
 {
   struct record_full_entry *cur_record_full_list;
   uint32_t magic;
-  struct regcache *regcache;
   struct gdbarch *gdbarch;
   int save_size = 0;
   asection *osec = NULL;
@@ -2546,7 +2546,7 @@ record_full_base_target::save_record (const char *recfilename)
   cur_record_full_list = record_full_list;
 
   /* Get the values of regcache and gdbarch.  */
-  regcache = get_current_regcache ();
+  regcache *regcache = get_thread_regcache (inferior_thread ());
   gdbarch = regcache->arch ();
 
   /* Disable the GDB operation record.  */
@@ -2731,7 +2731,7 @@ record_full_goto_insn (struct record_full_entry *entry,
 {
   scoped_restore restore_operation_disable
     = record_full_gdb_operation_disable_set ();
-  struct regcache *regcache = get_current_regcache ();
+  regcache *regcache = get_thread_regcache (inferior_thread ());
   struct gdbarch *gdbarch = regcache->arch ();
 
   /* Assume everything is valid: we will hit the entry,
index 585e02eefed5efa7f3e518df14582ec2df0388e7..4b9be859157ff6d2949c22313748e86a8110388b 100644 (file)
@@ -233,7 +233,7 @@ regcache_print (const char *args, enum regcache_dump_what what_to_dump)
   gdbarch *gdbarch;
 
   if (target_has_registers ())
-    gdbarch = get_current_regcache ()->arch ();
+    gdbarch = get_thread_regcache (inferior_thread ())->arch ();
   else
     gdbarch = current_inferior ()->arch ();
 
@@ -254,7 +254,8 @@ regcache_print (const char *args, enum regcache_dump_what what_to_dump)
        auto dump_pseudo = (what_to_dump == regcache_dump_cooked);
 
        if (target_has_registers ())
-         dump.reset (new register_dump_regcache (get_current_regcache (),
+         dump.reset (new register_dump_regcache (get_thread_regcache
+                                                   (inferior_thread ()),
                                                  dump_pseudo));
        else
          {
index 48a926ed44832d626ab435c7cce1275ca5d34bfe..48d7db47c06eb9104902cb06611c1aad9d1220e9 100644 (file)
@@ -415,12 +415,6 @@ get_thread_regcache (thread_info *thread)
                              thread->ptid);
 }
 
-struct regcache *
-get_current_regcache (void)
-{
-  return get_thread_regcache (inferior_thread ());
-}
-
 /* See gdbsupport/common-regcache.h.  */
 
 struct regcache *
index f73f08a44ab7beb8008b0cb8706cf716bb7ccc56..7922a5c5ae213dc183455ca69a0d30b3be8e3bcc 100644 (file)
@@ -30,7 +30,6 @@ class thread_info;
 struct process_stratum_target;
 struct inferior;
 
-extern struct regcache *get_current_regcache (void);
 extern struct regcache *get_thread_regcache (process_stratum_target *target,
                                             ptid_t ptid);
 
index 0a9cc298aeb9a4abd3c9c1f0425b443d6cd91787..30d621f25a0ddb11aa42cae2307ec0d647387efc 100644 (file)
@@ -113,7 +113,8 @@ save_bookmark_command (const char *args, int from_tty)
 {
   /* Get target's idea of a bookmark.  */
   gdb_byte *bookmark_id = target_get_bookmark (args, from_tty);
-  struct gdbarch *gdbarch = get_current_regcache ()->arch ();
+  regcache *regcache = get_thread_regcache (inferior_thread ());
+  gdbarch *gdbarch = regcache->arch ();
 
   /* CR should not cause another identical bookmark.  */
   dont_repeat ();
@@ -125,7 +126,7 @@ save_bookmark_command (const char *args, int from_tty)
   all_bookmarks.emplace_back ();
   bookmark &b = all_bookmarks.back ();
   b.number = ++bookmark_count;
-  b.pc = regcache_read_pc (get_current_regcache ());
+  b.pc = regcache_read_pc (regcache);
   b.sal = find_pc_line (b.pc, 0);
   b.sal.pspace = get_frame_program_space (get_current_frame ());
   b.opaque_data.reset (bookmark_id);
@@ -237,7 +238,7 @@ goto_bookmark_command (const char *args, int from_tty)
 static int
 bookmark_1 (int bnum)
 {
-  struct gdbarch *gdbarch = get_current_regcache ()->arch ();
+  gdbarch *gdbarch = get_thread_regcache (inferior_thread ())->arch ();
   int matched = 0;
 
   for (const bookmark &iter : all_bookmarks)
index 4f9ba9945ce0939e9c7b4942e9ac48a17d5baa21..c18791cd7c2c8a891e9b6f0c196f26a326e4bb41 100644 (file)
@@ -362,7 +362,7 @@ darwin_read_exec_load_addr_at_init (struct darwin_info *info)
   gdb_byte buf[8];
 
   /* Get SP.  */
-  if (regcache_cooked_read_unsigned (get_current_regcache (),
+  if (regcache_cooked_read_unsigned (get_thread_regcache (inferior_thread ()),
                                     gdbarch_sp_regnum (gdbarch),
                                     &load_ptr_addr) != REG_VALID)
     return 0;
@@ -450,7 +450,7 @@ darwin_solib_get_all_image_info_addr_at_init (struct darwin_info *info)
   /* We find the dynamic linker's base address by examining
      the current pc (which should point at the entry point for the
      dynamic linker) and subtracting the offset of the entry point.  */
-  load_addr = (regcache_read_pc (get_current_regcache ())
+  load_addr = (regcache_read_pc (get_thread_regcache (inferior_thread ()))
               - bfd_get_start_address (dyld_bfd.get ()));
 
   /* Now try to set a breakpoint in the dynamic linker.  */
@@ -574,7 +574,7 @@ darwin_solib_create_inferior_hook (int from_tty)
                 for the dynamic linker) and subtracting the offset of
                 the entry point.  */
 
-             pc = regcache_read_pc (get_current_regcache ());
+             pc = regcache_read_pc (get_thread_regcache (inferior_thread ()));
              dyld_relocated_base_address = pc - dyld_bfd_start_address;
 
              /* We get the proper notifier relocated address by
index b02e8094ac6b25d54524c0a98ca2f7354e95dd16..8a5ad590f6f9be3614b0442c5174aef0b1d14c09 100644 (file)
@@ -1867,7 +1867,7 @@ svr4_handle_solib_event (void)
   if (info->probes_table == NULL)
     return;
 
-  pc = regcache_read_pc (get_current_regcache ());
+  pc = regcache_read_pc (get_thread_regcache (inferior_thread ()));
   pa = solib_event_probe_at (info, pc);
   if (pa == nullptr)
     {
index 39dcefa87b88ab183669e555c05abafecc273021..ef565445c164c8415b6f3fe3508647aca2945d89 100644 (file)
@@ -2798,13 +2798,13 @@ return_command (const char *retval_exp, int from_tty)
   if (return_value != NULL)
     {
       struct type *return_type = return_value->type ();
-      struct gdbarch *cache_arch = get_current_regcache ()->arch ();
+      regcache *regcache = get_thread_regcache (inferior_thread ());
+      struct gdbarch *cache_arch = regcache->arch ();
 
       gdb_assert (rv_conv != RETURN_VALUE_STRUCT_CONVENTION
                  && rv_conv != RETURN_VALUE_ABI_RETURNS_ADDRESS);
       gdbarch_return_value_as_value
-       (cache_arch, function, return_type,
-        get_current_regcache (), NULL /*read*/,
+       (cache_arch, function, return_type, regcache, NULL /*read*/,
         return_value->contents ().data () /*write*/);
     }
 
index eebc5ea44b9b327d35aa14a204f0c7cb2560db1a..7f7ac3378061c4ca6e0aea83b3bb0d49e0f77e92 100644 (file)
@@ -2098,7 +2098,7 @@ generic_load (const char *args, int from_tty)
   uiout->text (", load size ");
   uiout->field_unsigned ("load-size", total_progress.data_count);
   uiout->text ("\n");
-  regcache_write_pc (get_current_regcache (), entry);
+  regcache_write_pc (get_thread_regcache (inferior_thread ()), entry);
 
   /* Reset breakpoints, now that we have changed the load image.  For
      instance, breakpoints may have been set (or reset, by
index 2c5486885700b032a24316d1102251c0d171046b..d5f29eb8b108522bbfde03c739507ead65fe4762 100644 (file)
@@ -2283,7 +2283,7 @@ tfind_pc_command (const char *args, int from_tty)
   check_trace_running (current_trace_status ());
 
   if (args == 0 || *args == 0)
-    pc = regcache_read_pc (get_current_regcache ());
+    pc = regcache_read_pc (get_thread_regcache (inferior_thread ()));
   else
     pc = parse_and_eval_address (args);
 
@@ -2731,7 +2731,7 @@ get_traceframe_location (int *stepping_frame_p)
   /* The current frame is a trap frame if the frame PC is equal to the
      tracepoint PC.  If not, then the current frame was collected
      during single-stepping.  */
-  regcache = get_current_regcache ();
+  regcache = get_thread_regcache (inferior_thread ());
 
   /* If the traceframe's address matches any of the tracepoint's
      locations, assume it is a direct hit rather than a while-stepping
index b98efe8afa705ea49927d3d5c3dabb101c7403d7..205bf01174fe67f32c53b93e746d4d1ade6edd86 100644 (file)
@@ -1441,7 +1441,7 @@ windows_nat_target::resume (ptid_t ptid, int step, enum gdb_signal sig)
          if (step)
            {
              /* Single step by setting t bit.  */
-             struct regcache *regcache = get_current_regcache ();
+             regcache *regcache = get_thread_regcache (inferior_thread ());
              struct gdbarch *gdbarch = regcache->arch ();
              fetch_registers (regcache, gdbarch_ps_regnum (gdbarch));
              th->wow64_context.EFlags |= FLAG_TRACE_BIT;
@@ -1469,7 +1469,7 @@ windows_nat_target::resume (ptid_t ptid, int step, enum gdb_signal sig)
          if (step)
            {
              /* Single step by setting t bit.  */
-             struct regcache *regcache = get_current_regcache ();
+             regcache *regcache = get_thread_regcache (inferior_thread ());
              struct gdbarch *gdbarch = regcache->arch ();
              fetch_registers (regcache, gdbarch_ps_regnum (gdbarch));
              th->context.EFlags |= FLAG_TRACE_BIT;
index c9935d15264106c346def744fd8a460bebbbbee0..9e7bfde193fc8b6785e087158052ffaa91dd0e68 100644 (file)
@@ -161,7 +161,8 @@ xtensa_read_register (int regnum)
 {
   ULONGEST value;
 
-  regcache_raw_read_unsigned (get_current_regcache (), regnum, &value);
+  regcache_raw_read_unsigned (get_thread_regcache (inferior_thread ()), regnum,
+                             &value);
   return (unsigned long) value;
 }
 
@@ -169,7 +170,8 @@ xtensa_read_register (int regnum)
 static void
 xtensa_write_register (int regnum, ULONGEST value)
 {
-  regcache_raw_write_unsigned (get_current_regcache (), regnum, value);
+  regcache_raw_write_unsigned (get_thread_regcache (inferior_thread ()), regnum,
+                              value);
 }
 
 /* Return the window size of the previous call to the function from which we