Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Tankut Baris Aktemur <tankut.baris.aktemur@intel.com>
To: gdb-patches@sourceware.org
Cc: simon.marchi@efficios.com
Subject: [PUSHED 1/8] gdbserver: by-pass regcache to access tdesc only
Date: Tue, 17 Dec 2024 09:18:23 +0100	[thread overview]
Message-ID: <2903d618081ac1897beca4ef5cfdb0550f2569e1.1734422729.git.tankut.baris.aktemur@intel.com> (raw)
In-Reply-To: <cover.1734422729.git.tankut.baris.aktemur@intel.com>

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  | 10 +++-------
 gdbserver/linux-s390-low.cc | 14 ++++----------
 gdbserver/linux-x86-low.cc  |  7 ++-----
 3 files changed, 9 insertions(+), 22 deletions(-)

diff --git a/gdbserver/linux-ppc-low.cc b/gdbserver/linux-ppc-low.cc
index b9d00b1b67f..d3c86671148 100644
--- a/gdbserver/linux-ppc-low.cc
+++ b/gdbserver/linux-ppc-low.cc
@@ -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)
diff --git a/gdbserver/linux-s390-low.cc b/gdbserver/linux-s390-low.cc
index a91c77f66c9..cd874f6d89c 100644
--- a/gdbserver/linux-s390-low.cc
+++ b/gdbserver/linux-s390-low.cc
@@ -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
diff --git a/gdbserver/linux-x86-low.cc b/gdbserver/linux-x86-low.cc
index d955a7187b7..ad7ed1ce0ad 100644
--- a/gdbserver/linux-x86-low.cc
+++ b/gdbserver/linux-x86-low.cc
@@ -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)
     {
-- 
2.34.1

Intel Deutschland GmbH
Registered Address: Am Campeon 10, 85579 Neubiberg, Germany
Tel: +49 89 99 8853-0, www.intel.de
Managing Directors: Sean Fennelly, Jeffrey Schneiderman, Tiffany Doon Silva
Chairperson of the Supervisory Board: Nicole Lau
Registered Office: Munich
Commercial Register: Amtsgericht Muenchen HRB 186928


  reply	other threads:[~2024-12-17  8:21 UTC|newest]

Thread overview: 93+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-02-28 11:27 [PATCH 00/26] gdbserver: refactor regcache and allow gradually populating Tankut Baris Aktemur via Gdb-patches
2023-02-28 11:27 ` [PATCH 01/26] gdbserver: convert init_register_cache into regcache::initialize Tankut Baris Aktemur via Gdb-patches
2023-12-21 20:12   ` Simon Marchi
2023-02-28 11:28 ` [PATCH 02/26] gdbserver: convert new_register_cache into a regcache constructor Tankut Baris Aktemur via Gdb-patches
2023-12-21 20:19   ` Simon Marchi
2023-02-28 11:28 ` [PATCH 03/26] gdbserver: by-pass regcache to access tdesc only Tankut Baris Aktemur via Gdb-patches
2023-12-21 20:22   ` Simon Marchi
2023-02-28 11:28 ` [PATCH 04/26] gdbserver: boolify and defaultize the 'fetch' parameter of get_thread_regcache Tankut Baris Aktemur via Gdb-patches
2023-12-21 20:24   ` Simon Marchi
2023-02-28 11:28 ` [PATCH 05/26] gdbserver: add a pointer to the owner thread in regcache Tankut Baris Aktemur via Gdb-patches
2023-12-21 20:28   ` Simon Marchi
2023-02-28 11:28 ` [PATCH 06/26] gdbserver: turn part of get_thread_regcache into regcache::fetch Tankut Baris Aktemur via Gdb-patches
2023-12-21 20:48   ` Simon Marchi
2023-02-28 11:28 ` [PATCH 07/26] gdbserver: convert regcache_cpy into regcache::copy_from Tankut Baris Aktemur via Gdb-patches
2023-12-21 20:50   ` Simon Marchi
2023-02-28 11:28 ` [PATCH 08/26] gdbserver: convert free_register_cache into a destructor of regcache Tankut Baris Aktemur via Gdb-patches
2023-12-21 20:57   ` Simon Marchi
2023-02-28 11:28 ` [PATCH 09/26] gdbserver: extract out regcache::invalidate and regcache::discard Tankut Baris Aktemur via Gdb-patches
2023-12-21 21:08   ` Simon Marchi
2023-02-28 11:28 ` [PATCH 10/26] gdbserver: convert registers_to_string into regcache::registers_to_string Tankut Baris Aktemur via Gdb-patches
2023-12-21 21:13   ` Simon Marchi
2023-12-21 21:19     ` Simon Marchi
2023-02-28 11:28 ` [PATCH 11/26] gdbserver: convert registers_from_string into regcache::registers_from_string Tankut Baris Aktemur via Gdb-patches
2023-02-28 11:28 ` [PATCH 12/26] gdbserver: convert supply_regblock to regcache::supply_regblock Tankut Baris Aktemur via Gdb-patches
2023-12-21 21:23   ` Simon Marchi
2023-02-28 11:28 ` [PATCH 13/26] gdbserver: convert register_data into regcache::register_data Tankut Baris Aktemur via Gdb-patches
2023-12-21 21:26   ` Simon Marchi
2023-02-28 11:28 ` [PATCH 14/26] gdbserver: introduce and use regcache::set_register_status Tankut Baris Aktemur via Gdb-patches
2023-12-21 21:30   ` Simon Marchi
2023-02-28 11:28 ` [PATCH 15/26] gdbserver: check for nullptr condition in regcache::get_register_status Tankut Baris Aktemur via Gdb-patches
2023-12-21 21:32   ` Simon Marchi
2023-12-21 21:34   ` Simon Marchi
2023-02-28 11:28 ` [PATCH 16/26] gdbserver: boolify regcache fields Tankut Baris Aktemur via Gdb-patches
2023-12-22  3:20   ` Simon Marchi
2023-02-28 11:28 ` [PATCH 17/26] gdbserver: rename regcache's registers_valid to registers_fetched Tankut Baris Aktemur via Gdb-patches
2023-12-22  3:23   ` Simon Marchi
2023-02-28 11:28 ` [PATCH 18/26] gdbsupport: fix a typo in a comment in common-regcache.h Tankut Baris Aktemur via Gdb-patches
2023-12-22  3:24   ` Simon Marchi
2023-02-28 11:28 ` [PATCH 19/26] gdbserver: fix the declared type of register_status in regcache Tankut Baris Aktemur via Gdb-patches
2023-12-22  3:35   ` Simon Marchi
2023-02-28 11:28 ` [PATCH 20/26] gdbserver: make some regcache fields private Tankut Baris Aktemur via Gdb-patches
2023-12-22  3:39   ` Simon Marchi
2023-02-28 11:28 ` [PATCH 21/26] gdbserver: use REG_UNKNOWN for a regcache's register statuses Tankut Baris Aktemur via Gdb-patches
2023-12-22  4:32   ` Simon Marchi
2023-02-28 11:28 ` [PATCH 22/26] gdbserver: zero-out register values in regcache-discard Tankut Baris Aktemur via Gdb-patches
2023-12-22  4:36   ` Simon Marchi
2023-02-28 11:28 ` [PATCH 23/26] gdbserver: set register statuses in registers_from_string Tankut Baris Aktemur via Gdb-patches
2023-12-22  4:40   ` Simon Marchi
2023-02-28 11:28 ` [PATCH 24/26] gdbserver: return tracked register status in regcache_raw_read_unsigned Tankut Baris Aktemur via Gdb-patches
2023-12-22  4:42   ` Simon Marchi
2023-02-28 11:28 ` [PATCH 25/26] gdbserver: refuse null argument in regcache::supply_regblock Tankut Baris Aktemur via Gdb-patches
2023-12-22  4:54   ` Simon Marchi
2023-02-28 11:28 ` [PATCH 26/26] gdbserver: allow gradually populating and selectively storing a regcache Tankut Baris Aktemur via Gdb-patches
2023-12-22 16:25   ` Simon Marchi
2024-06-28 12:17     ` Aktemur, Tankut Baris
2023-03-07 20:39 ` [PATCH 00/26] gdbserver: refactor regcache and allow gradually populating Tom Tromey
2023-03-13 14:33   ` Aktemur, Tankut Baris via Gdb-patches
2023-03-28 13:42 ` Aktemur, Tankut Baris via Gdb-patches
2023-06-20 12:58 ` Aktemur, Tankut Baris via Gdb-patches
2024-12-17  8:18 ` [PUSHED 0/8] Some gdbserver regcache cleanup Tankut Baris Aktemur
2024-12-17  8:18   ` Tankut Baris Aktemur [this message]
2024-12-17  8:18   ` [PUSHED 2/8] gdbserver: boolify and defaultize the 'fetch' parameter of get_thread_regcache Tankut Baris Aktemur
2024-12-17  8:18   ` [PUSHED 3/8] gdbserver: convert regcache_cpy into regcache::copy_from Tankut Baris Aktemur
2024-12-17  8:18   ` [PUSHED 4/8] gdbserver: check for nullptr condition in regcache::get_register_status Tankut Baris Aktemur
2024-12-17  8:18   ` [PUSHED 5/8] gdbserver: boolify regcache fields Tankut Baris Aktemur
2024-12-17  8:18   ` [PUSHED 6/8] gdbserver: rename regcache's registers_valid to registers_fetched Tankut Baris Aktemur
2024-12-17  8:18   ` [PUSHED 7/8] gdbsupport: fix a typo in a comment in common-regcache.h Tankut Baris Aktemur
2024-12-17  8:18   ` [PUSHED 8/8] gdbserver: return tracked register status in regcache_raw_read_unsigned Tankut Baris Aktemur
2024-12-30 10:49 ` [PATCH v2 00/11] gdbserver: refactor regcache Tankut Baris Aktemur
2024-12-30 10:49   ` [PATCH v2 01/11] gdbserver: dump 'xx...x' in collect_register_as_string for unavailable register Tankut Baris Aktemur
2025-01-06 21:28     ` Simon Marchi
2025-01-09  8:35       ` Aktemur, Tankut Baris
2024-12-30 10:49   ` [PATCH v2 02/11] gdbserver: use inheritance to define tracepoint contexts Tankut Baris Aktemur
2025-01-06 21:46     ` Simon Marchi
2024-12-30 10:49   ` [PATCH v2 03/11] gdbserver: use inheritance more " Tankut Baris Aktemur
2025-01-07  4:40     ` Simon Marchi
2024-12-30 10:49   ` [PATCH v2 04/11] gdbserver: convert init_register_cache and new_register_cache into constructors Tankut Baris Aktemur
2025-01-07  4:51     ` Simon Marchi
2024-12-30 10:49   ` [PATCH v2 05/11] gdbserver: convert free_register_cache into a destructor of regcache Tankut Baris Aktemur
2025-01-07  4:53     ` Simon Marchi
2025-01-07  4:54     ` Simon Marchi
2024-12-30 10:49   ` [PATCH v2 06/11] gdbserver: use unique_ptr for thread_info's regcache Tankut Baris Aktemur
2024-12-30 10:49   ` [PATCH v2 07/11] gdbserver: introduce and use regcache::set_register_status Tankut Baris Aktemur
2025-01-07  5:01     ` Simon Marchi
2025-01-09 12:49       ` Aktemur, Tankut Baris
2024-12-30 10:49   ` [PATCH v2 08/11] gdbserver: use REG_UNKNOWN for a regcache's register statuses Tankut Baris Aktemur
2025-01-07  5:17     ` Simon Marchi
2024-12-30 10:49   ` [PATCH v2 09/11] gdbserver: define and use regcache::reset Tankut Baris Aktemur
2025-01-07  5:27     ` Simon Marchi
2024-12-30 10:49   ` [PATCH v2 10/11] gdbserver: refactor the definition and uses of supply_regblock Tankut Baris Aktemur
2025-01-07  5:34     ` Simon Marchi
2024-12-30 10:49   ` [PATCH v2 11/11] gdbserver: fix the declared type of register_status in regcache Tankut Baris Aktemur
2025-01-07  5:40     ` Simon Marchi

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=2903d618081ac1897beca4ef5cfdb0550f2569e1.1734422729.git.tankut.baris.aktemur@intel.com \
    --to=tankut.baris.aktemur@intel.com \
    --cc=gdb-patches@sourceware.org \
    --cc=simon.marchi@efficios.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox