public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
From: Simon Marchi <simon.marchi@efficios.com>
To: gdb-patches@sourceware.org
Cc: Simon Marchi <simon.marchi@efficios.com>
Subject: [PATCH 5/9] gdb: remove read_frame_register_value's frame parameter
Date: Thu, 21 Dec 2023 14:16:26 -0500	[thread overview]
Message-ID: <20231221191716.257256-6-simon.marchi@efficios.com> (raw)
In-Reply-To: <20231221191716.257256-1-simon.marchi@efficios.com>

By now, all register struct values should have a valid next frame id
(assuming they are created using value::allocate_register or
value::allocate_register_lazy), so there should be no need to pass a
frame alongside the value to read_frame_register_value.  Remove the
frame parameter and adjust read_frame_register_value accordingly.

While at it, make read_frame_register_value static, it's only used in
findvar.c.

Change-Id: I118959ef8c628499297c67810916e8ba9934bfac
---
 gdb/findvar.c | 23 +++++++++++++----------
 gdb/value.h   |  3 ---
 2 files changed, 13 insertions(+), 13 deletions(-)

diff --git a/gdb/findvar.c b/gdb/findvar.c
index 7c6c837ae12e..838d850e821d 100644
--- a/gdb/findvar.c
+++ b/gdb/findvar.c
@@ -767,24 +767,27 @@ default_value_from_register (gdbarch *gdbarch, type *type, int regnum,
 }
 
 /* VALUE must be an lval_register value.  If regnum is the value's
-   associated register number, and len the length of the values type,
-   read one or more registers in FRAME, starting with register REGNUM,
+   associated register number, and len the length of the value's type,
+   read one or more registers in VALUE's frame, starting with register REGNUM,
    until we've read LEN bytes.
 
    If any of the registers we try to read are optimized out, then mark the
    complete resulting value as optimized out.  */
 
-void
-read_frame_register_value (struct value *value, frame_info_ptr frame)
+static void
+read_frame_register_value (value *value)
 {
-  struct gdbarch *gdbarch = get_frame_arch (frame);
+  gdb_assert (value->lval () == lval_register);
+
+  frame_info_ptr next_frame = frame_find_by_id (VALUE_NEXT_FRAME_ID (value));
+  gdb_assert (next_frame != nullptr);
+
+  gdbarch *gdbarch = frame_unwind_arch (next_frame);
   LONGEST offset = 0;
   LONGEST reg_offset = value->offset ();
   int regnum = VALUE_REGNUM (value);
   int len = type_length_units (check_typedef (value->type ()));
 
-  gdb_assert (value->lval () == lval_register);
-
   /* Skip registers wholly inside of REG_OFFSET.  */
   while (reg_offset >= register_size (gdbarch, regnum))
     {
@@ -795,7 +798,7 @@ read_frame_register_value (struct value *value, frame_info_ptr frame)
   /* Copy the data.  */
   while (len > 0)
     {
-      struct value *regval = get_frame_register_value (frame, regnum);
+      struct value *regval = frame_unwind_register_value (next_frame, regnum);
       int reg_len = type_length_units (regval->type ()) - reg_offset;
 
       /* If the register length is larger than the number of bytes
@@ -852,7 +855,7 @@ value_from_register (struct type *type, int regnum, frame_info_ptr frame)
       v = gdbarch_value_from_register (gdbarch, type, regnum, frame);
 
       /* Get the data.  */
-      read_frame_register_value (v, frame);
+      read_frame_register_value (v);
     }
 
   return v;
@@ -895,7 +898,7 @@ address_from_register (int regnum, frame_info_ptr frame)
     }
 
   value *value = gdbarch_value_from_register (gdbarch, type, regnum, frame);
-  read_frame_register_value (value, frame);
+  read_frame_register_value (value);
 
   if (value->optimized_out ())
     {
diff --git a/gdb/value.h b/gdb/value.h
index 78abcac7e739..9d7630ef07b3 100644
--- a/gdb/value.h
+++ b/gdb/value.h
@@ -1119,9 +1119,6 @@ extern value *default_value_from_register (gdbarch *gdbarch, type *type,
 					   int regnum,
 					   frame_info_ptr this_frame);
 
-extern void read_frame_register_value (struct value *value,
-				       frame_info_ptr frame);
-
 extern struct value *value_from_register (struct type *type, int regnum,
 					  frame_info_ptr frame);
 
-- 
2.43.0


  parent reply	other threads:[~2023-12-21 19:17 UTC|newest]

Thread overview: 24+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-12-21 19:16 [PATCH 0/9] Some register value cleanups Simon Marchi
2023-12-21 19:16 ` [PATCH 1/9] gdb: don't set frame id after calling cooked_read_value Simon Marchi
2023-12-21 19:16 ` [PATCH 2/9] gdb: pass frame_info_ptr to gdbarch_value_from_register Simon Marchi
2023-12-22 16:40   ` Tom Tromey
2023-12-22 16:53     ` Simon Marchi
2023-12-22 16:56       ` Tom Tromey
2023-12-21 19:16 ` [PATCH 3/9] gdb: pass non-nullptr frame to gdbarch_value_from_register in address_from_register Simon Marchi
2023-12-21 19:16 ` [PATCH 4/9] gdb: add type parameter to value::allocate_register and add value::allocate_register_lazy Simon Marchi
2023-12-21 19:16 ` Simon Marchi [this message]
2023-12-21 19:16 ` [PATCH 6/9] gdb: implement address_from_register using value_from_register Simon Marchi
2023-12-21 19:16 ` [PATCH 7/9] gdb: remove VALUE_NEXT_FRAME_ID, add value::next_frame_id Simon Marchi
2023-12-22 16:51   ` Tom Tromey
2023-12-22 16:56     ` Simon Marchi
2023-12-22 17:02       ` Tom Tromey
2023-12-22 17:06         ` Simon Marchi
2023-12-24 15:35           ` Simon Marchi
2023-12-21 19:16 ` [PATCH 8/9] gdb: remove VALUE_REGNUM, add value::regnum Simon Marchi
2023-12-22 16:52   ` Tom Tromey
2023-12-22 16:57     ` Simon Marchi
2023-12-21 19:16 ` [PATCH 9/9] gdb: make value::allocate_register_lazy store id of next non-inline frame Simon Marchi
2023-12-22 16:53 ` [PATCH 0/9] Some register value cleanups Tom Tromey
2023-12-22 16:58   ` Simon Marchi
2023-12-22 17:02     ` Tom Tromey
2023-12-24 18:28       ` 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=20231221191716.257256-6-simon.marchi@efficios.com \
    --to=simon.marchi@efficios.com \
    --cc=gdb-patches@sourceware.org \
    /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;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).