]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commitdiff
gdbserver: by-pass regcache to access tdesc only
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)
The `get_thread_regcache` function has a `fetch` option to skip
fetching the registers from the target.  It seems this option is set
to false only at uses where we just need to access the tdesc through
the regcache of the current thread, as in

  struct regcache *regcache = get_thread_regcache (current_thread, 0);
  ... regcache->tdesc ...

Since the tdesc of a regcache is set from the process of the thread
that owns the regcache, we can simplify the code to access the tdesc
via the process, as in

  ... current_process ()->tdesc ...

This is intended to be a refactoring with no behavioral change.

Tested only for the linux-x86-low target.

Approved-By: Simon Marchi <simon.marchi@efficios.com>
gdbserver/linux-ppc-low.cc
gdbserver/linux-s390-low.cc
gdbserver/linux-x86-low.cc

index b9d00b1b67fe60bceab912baf96d9ab2c39c0d20..d3c8667114865cb9621cb9611cf751f48a4152fb 100644 (file)
@@ -1607,8 +1607,7 @@ ppc_target::install_fast_tracepoint_jump_pad (CORE_ADDR tpoint,
   const CORE_ADDR entryaddr = *jump_entry;
   int rsz, min_frame, frame_size, tp_reg;
 #ifdef __powerpc64__
-  struct regcache *regcache = get_thread_regcache (current_thread, 0);
-  int is_64 = register_size (regcache->tdesc, 0) == 8;
+  int is_64 = register_size (current_process ()->tdesc, 0) == 8;
   int is_opd = is_64 && !is_elfv2_inferior ();
 #else
   int is_64 = 0, is_opd = 0;
@@ -3379,9 +3378,7 @@ emit_ops *
 ppc_target::emit_ops ()
 {
 #ifdef __powerpc64__
-  struct regcache *regcache = get_thread_regcache (current_thread, 0);
-
-  if (register_size (regcache->tdesc, 0) == 8)
+  if (register_size (current_process ()->tdesc, 0) == 8)
     {
       if (is_elfv2_inferior ())
        return &ppc64v2_emit_ops_impl;
@@ -3397,8 +3394,7 @@ ppc_target::emit_ops ()
 int
 ppc_target::get_ipa_tdesc_idx ()
 {
-  struct regcache *regcache = get_thread_regcache (current_thread, 0);
-  const struct target_desc *tdesc = regcache->tdesc;
+  const target_desc *tdesc = current_process ()->tdesc;
 
 #ifdef __powerpc64__
   if (tdesc == tdesc_powerpc_64l)
index a91c77f66c9728e6178e68f914cd7f3ae6d6e418..cd874f6d89cde1bbb81cad47662401789e620cee 100644 (file)
@@ -796,9 +796,7 @@ s390_target::low_get_thread_area (int lwpid, CORE_ADDR *addrp)
 {
   CORE_ADDR res = ptrace (PTRACE_PEEKUSER, lwpid, (long) PT_ACR0, (long) 0);
 #ifdef __s390x__
-  struct regcache *regcache = get_thread_regcache (current_thread, 0);
-
-  if (register_size (regcache->tdesc, 0) == 4)
+  if (register_size (current_process ()->tdesc, 0) == 4)
     res &= 0xffffffffull;
 #endif
   *addrp = res;
@@ -1286,8 +1284,7 @@ s390_target::install_fast_tracepoint_jump_pad
   unsigned char jbuf[6] = { 0xc0, 0xf4, 0, 0, 0, 0 };  /* jg ... */
   CORE_ADDR buildaddr = *jump_entry;
 #ifdef __s390x__
-  struct regcache *regcache = get_thread_regcache (current_thread, 0);
-  int is_64 = register_size (regcache->tdesc, 0) == 8;
+  int is_64 = register_size (current_process ()->tdesc, 0) == 8;
   int is_zarch = is_64 || have_hwcap_s390_high_gprs;
   int has_vx = have_hwcap_s390_vx;
 #else
@@ -1451,8 +1448,7 @@ s390_target::get_min_fast_tracepoint_insn_len ()
 int
 s390_target::get_ipa_tdesc_idx ()
 {
-  struct regcache *regcache = get_thread_regcache (current_thread, 0);
-  const struct target_desc *tdesc = regcache->tdesc;
+  const target_desc *tdesc = current_process ()->tdesc;
 
 #ifdef __s390x__
   if (tdesc == tdesc_s390x_linux64)
@@ -2839,9 +2835,7 @@ emit_ops *
 s390_target::emit_ops ()
 {
 #ifdef __s390x__
-  struct regcache *regcache = get_thread_regcache (current_thread, 0);
-
-  if (register_size (regcache->tdesc, 0) == 8)
+  if (register_size (current_process ()->tdesc, 0) == 8)
     return &s390x_emit_ops;
   else
 #endif
index d955a7187b7b0bc79f60e95a0dacd852462912ae..ad7ed1ce0ad56a8326aa9fbb8d2c2b8759490f95 100644 (file)
@@ -284,9 +284,7 @@ static /*const*/ int i386_regmap[] =
 static int
 is_64bit_tdesc (thread_info *thread)
 {
-  struct regcache *regcache = get_thread_regcache (thread, 0);
-
-  return register_size (regcache->tdesc, 0) == 8;
+  return register_size (thread->process ()->tdesc, 0) == 8;
 }
 
 #endif
@@ -2876,8 +2874,7 @@ x86_target::low_supports_range_stepping ()
 int
 x86_target::get_ipa_tdesc_idx ()
 {
-  struct regcache *regcache = get_thread_regcache (current_thread, 0);
-  const struct target_desc *tdesc = regcache->tdesc;
+  const target_desc *tdesc = current_process ()->tdesc;
 
   if (!use_xml)
     {