]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commitdiff
gdbserver: boolify and defaultize the 'fetch' parameter of get_thread_regcache
authorTankut Baris Aktemur <tankut.baris.aktemur@intel.com>
Tue, 17 Dec 2024 07:48:02 +0000 (08:48 +0100)
committerTankut Baris Aktemur <tankut.baris.aktemur@intel.com>
Tue, 17 Dec 2024 07:48:02 +0000 (08:48 +0100)
Boolify the 'fetch' parameter of the get_thread_regcache function.

All of the current uses pass true for this parameter.  Therefore, define
its default value as true and remove the argument from the uses.

We still keep the parameter, though, to give downstream targets the
option to obtain a regcache without having to fetch the whole
contents.  Our (Intel) downstream target is an example.

Approved-By: Simon Marchi <simon.marchi@efficios.com>
12 files changed:
gdbserver/linux-aarch32-low.cc
gdbserver/linux-low.cc
gdbserver/linux-ppc-low.cc
gdbserver/linux-x86-low.cc
gdbserver/mem-break.cc
gdbserver/proc-service.cc
gdbserver/regcache.cc
gdbserver/regcache.h
gdbserver/remote-utils.cc
gdbserver/server.cc
gdbserver/tracepoint.cc
gdbserver/win32-low.cc

index ca66e7f8fbc595103f669e575990f5bfc0589fb6..a70cc4ac4039b64157dc977a1cff6505934f93cf 100644 (file)
@@ -170,7 +170,7 @@ struct regs_info regs_info_aarch32 =
 int
 arm_is_thumb_mode (void)
 {
-  struct regcache *regcache = get_thread_regcache (current_thread, 1);
+  regcache *regcache = get_thread_regcache (current_thread);
   unsigned long cpsr;
 
   collect_register_by_name (regcache, "cpsr", &cpsr);
index dfe4c6a39a0b3a6eaaf8aea71d45f2025bf09471..50ce2b449270465c97d734b1310e26885dd18feb 100644 (file)
@@ -788,7 +788,7 @@ linux_process_target::get_pc (lwp_info *lwp)
   scoped_restore_current_thread restore_thread;
   switch_to_thread (lwp->thread);
 
-  struct regcache *regcache = get_thread_regcache (current_thread, 1);
+  regcache *regcache = get_thread_regcache (current_thread);
   CORE_ADDR pc = low_get_pc (regcache);
 
   threads_debug_printf ("pc is 0x%lx", (long) pc);
@@ -804,7 +804,7 @@ linux_process_target::get_syscall_trapinfo (lwp_info *lwp, int *sysno)
   scoped_restore_current_thread restore_thread;
   switch_to_thread (lwp->thread);
 
-  regcache = get_thread_regcache (current_thread, 1);
+  regcache = get_thread_regcache (current_thread);
   low_get_syscall_trapinfo (regcache, sysno);
 
   threads_debug_printf ("get_syscall_trapinfo sysno %d", *sysno);
@@ -894,7 +894,7 @@ linux_process_target::save_stop_reason (lwp_info *lwp)
       if (pc != sw_breakpoint_pc)
        {
          struct regcache *regcache
-           = get_thread_regcache (current_thread, 1);
+           = get_thread_regcache (current_thread);
          low_set_pc (regcache, sw_breakpoint_pc);
        }
 
@@ -2074,7 +2074,7 @@ linux_process_target::maybe_move_out_of_jump_pad (lwp_info *lwp, int *wstat)
                          (PTRACE_TYPE_ARG3) 0, &info);
                }
 
-             regcache = get_thread_regcache (current_thread, 1);
+             regcache = get_thread_regcache (current_thread);
              low_set_pc (regcache, status.tpoint_addr);
              lwp->stop_pc = status.tpoint_addr;
 
@@ -3088,7 +3088,7 @@ linux_process_target::wait_1 (ptid_t ptid, target_waitstatus *ourstatus,
       if (increment_pc != 0)
        {
          struct regcache *regcache
-           = get_thread_regcache (current_thread, 1);
+           = get_thread_regcache (current_thread);
 
          event_child->stop_pc += increment_pc;
          low_set_pc (regcache, event_child->stop_pc);
@@ -3376,7 +3376,7 @@ linux_process_target::wait_1 (ptid_t ptid, target_waitstatus *ourstatus,
       if (low_supports_breakpoints ())
        {
          struct regcache *regcache
-           = get_thread_regcache (current_thread, 1);
+           = get_thread_regcache (current_thread);
          low_set_pc (regcache, event_child->stop_pc);
        }
 
@@ -3611,7 +3611,7 @@ linux_process_target::wait_1 (ptid_t ptid, target_waitstatus *ourstatus,
       if (decr_pc != 0)
        {
          struct regcache *regcache
-           = get_thread_regcache (current_thread, 1);
+           = get_thread_regcache (current_thread);
          low_set_pc (regcache, event_child->stop_pc + decr_pc);
        }
     }
@@ -3957,7 +3957,7 @@ void
 linux_process_target::install_software_single_step_breakpoints (lwp_info *lwp)
 {
   thread_info *thread = lwp->thread;
-  struct regcache *regcache = get_thread_regcache (thread, 1);
+  regcache *regcache = get_thread_regcache (thread);
 
   scoped_restore_current_thread restore_thread;
 
@@ -4131,7 +4131,7 @@ linux_process_target::resume_one_lwp_throw (lwp_info *lwp, int step,
 
   if (thread->process ()->tdesc != nullptr && low_supports_breakpoints ())
     {
-      struct regcache *regcache = get_thread_regcache (current_thread, 1);
+      regcache *regcache = get_thread_regcache (current_thread);
 
       lwp->stop_pc = low_get_pc (regcache);
 
index d3c8667114865cb9621cb9611cf751f48a4152fb..3ce978f4c7cf64ab1199143107b7f677fc3c2376 100644 (file)
@@ -1053,7 +1053,7 @@ ppc_target::low_get_thread_area (int lwpid, CORE_ADDR *addr)
 {
   struct lwp_info *lwp = find_lwp_pid (ptid_t (lwpid));
   thread_info *thr = lwp->thread;
-  struct regcache *regcache = get_thread_regcache (thr, 1);
+  regcache *regcache = get_thread_regcache (thr);
   ULONGEST tp = 0;
 
 #ifdef __powerpc64__
index ad7ed1ce0ad56a8326aa9fbb8d2c2b8759490f95..6c2688d36783ed6f492a960682b641002dcc2923 100644 (file)
@@ -361,7 +361,7 @@ x86_target::low_get_thread_area (int lwpid, CORE_ADDR *addr)
 
   {
     thread_info *thr = lwp->thread;
-    struct regcache *regcache = get_thread_regcache (thr, 1);
+    regcache *regcache = get_thread_regcache (thr);
     unsigned int desc[4];
     ULONGEST gs = 0;
     const int reg_thread_area = 3; /* bits to scale down register value.  */
index 971734d3532f10d804ab01bcfaa534a0e02b164f..134e2431370f4170f02942bd27feffeac5f906c3 100644 (file)
@@ -1238,7 +1238,7 @@ gdb_condition_true_at_breakpoint_z_type (char z_type, CORE_ADDR addr)
   if (bp->cond_list == NULL)
     return 1;
 
-  ctx.regcache = get_thread_regcache (current_thread, 1);
+  ctx.regcache = get_thread_regcache (current_thread);
   ctx.tframe = NULL;
   ctx.tpoint = NULL;
 
@@ -1360,7 +1360,7 @@ run_breakpoint_commands_z_type (char z_type, CORE_ADDR addr)
   if (bp == NULL)
     return 1;
 
-  ctx.regcache = get_thread_regcache (current_thread, 1);
+  ctx.regcache = get_thread_regcache (current_thread);
   ctx.tframe = NULL;
   ctx.tpoint = NULL;
 
index 9896f7168f0f733cc2f85790c8231bcabbd694a0..198a6f24eabf99b14fca98357e0c2fb62037b35f 100644 (file)
@@ -112,7 +112,7 @@ ps_lgetregs (gdb_ps_prochandle_t ph, lwpid_t lwpid, prgregset_t gregset)
 
   scoped_restore_current_thread restore_thread;
   switch_to_thread (lwp->thread);
-  regcache = get_thread_regcache (current_thread, 1);
+  regcache = get_thread_regcache (current_thread);
   gregset_info ()->fill_function (regcache, gregset);
 
   return PS_OK;
index f1d63eac0ba4c2dccfb3c54910e6cdb768931f61..5ae922ec0be40fdaecad29aa522ff90ed6d8afca 100644 (file)
@@ -25,7 +25,7 @@
 #ifndef IN_PROCESS_AGENT
 
 struct regcache *
-get_thread_regcache (thread_info *thread, int fetch)
+get_thread_regcache (thread_info *thread, bool fetch)
 {
   regcache *regcache = thread->regcache ();
 
@@ -66,7 +66,7 @@ get_thread_regcache (thread_info *thread, int fetch)
 reg_buffer_common *
 get_thread_regcache_for_ptid (ptid_t ptid)
 {
-  return get_thread_regcache (find_thread_ptid (ptid), 1);
+  return get_thread_regcache (find_thread_ptid (ptid));
 }
 
 void
index 16ee4d0a2e7127127225b72d8e9ef3eab71ce88e..068f9e8df3d90ba2fbf8781901a2ad03519e312e 100644 (file)
@@ -72,7 +72,7 @@ void regcache_cpy (struct regcache *dst, struct regcache *src);
 
 struct regcache *new_register_cache (const struct target_desc *tdesc);
 
-struct regcache *get_thread_regcache (thread_info *thread, int fetch);
+regcache *get_thread_regcache (thread_info *thread, bool fetch = true);
 
 /* Release all memory associated with the register cache for INFERIOR.  */
 
index 42252bad78f0dec91f887102d8a3baebb952c5ae..3584697b2abb92fc7a8e658e702262c9c70bc160 100644 (file)
@@ -1175,7 +1175,7 @@ prepare_resume_reply (char *buf, ptid_t ptid, const target_waitstatus &status)
 
        switch_to_thread (the_target, ptid);
 
-       regcache = get_thread_regcache (current_thread, 1);
+       regcache = get_thread_regcache (current_thread);
 
        if (the_target->stopped_by_watchpoint ())
          {
index 264fac44b74db69746fdecb1cdd1fd748139cc4f..e5bdb3792348828a387cea947214dffe193305da 100644 (file)
@@ -4721,7 +4721,7 @@ process_serial_event (void)
            write_enn (cs.own_buf);
          else
            {
-             regcache = get_thread_regcache (current_thread, 1);
+             regcache = get_thread_regcache (current_thread);
              registers_to_string (regcache, cs.own_buf);
            }
        }
@@ -4738,7 +4738,7 @@ process_serial_event (void)
            write_enn (cs.own_buf);
          else
            {
-             regcache = get_thread_regcache (current_thread, 1);
+             regcache = get_thread_regcache (current_thread);
              registers_from_string (regcache, &cs.own_buf[1]);
              write_ok (cs.own_buf);
            }
index ab68984330a2cd5033c70200aa30d0287b0b0ff3..6b5541b5fbff921dc48786e194a980a473d5b2de 100644 (file)
@@ -4376,7 +4376,7 @@ tracepoint_finished_step (thread_info *tinfo, CORE_ADDR stop_pc)
               wstep->tp_number, paddress (wstep->tp_address));
 
   ctx.base.type = trap_tracepoint;
-  ctx.regcache = get_thread_regcache (tinfo, 1);
+  ctx.regcache = get_thread_regcache (tinfo);
 
   while (wstep != NULL)
     {
@@ -4537,7 +4537,7 @@ tracepoint_was_hit (thread_info *tinfo, CORE_ADDR stop_pc)
     return 0;
 
   ctx.base.type = trap_tracepoint;
-  ctx.regcache = get_thread_regcache (tinfo, 1);
+  ctx.regcache = get_thread_regcache (tinfo);
 
   for (tpoint = tracepoints; tpoint; tpoint = tpoint->next)
     {
index 49f0ed3b1f4d2b2ac1d1c194d3910e4918568241..da858b65e6f7fba5501153e56430d567c1753a20 100644 (file)
@@ -943,7 +943,7 @@ gdbserver_windows_process::handle_access_violation
 static void
 maybe_adjust_pc ()
 {
-  struct regcache *regcache = get_thread_regcache (current_thread, 1);
+  regcache *regcache = get_thread_regcache (current_thread);
   child_fetch_inferior_registers (regcache, -1);
 
   windows_thread_info *th