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: Luis Machado <luis.machado@arm.com>,
	John Baldwin <jhb@freebsd.org>,
	"Aktemur, Tankut Baris" <tankut.baris.aktemur@intel.com>,
	Simon Marchi <simon.marchi@efficios.com>,
	John Baldwin <jhb@FreeBSD.org>
Subject: [PATCH 10/24] gdb: make put_frame_register take the next frame
Date: Fri,  1 Dec 2023 11:27:23 -0500	[thread overview]
Message-ID: <20231201162751.741751-11-simon.marchi@efficios.com> (raw)
In-Reply-To: <20231201162751.741751-1-simon.marchi@efficios.com>

Similar to the previous patches, change put_frame_register to take the
"next frame" instead of "this frame".

Change-Id: I062fd4663b8f54f0fc7bbf39c860b7341363821b
Reviewed-By: John Baldwin <jhb@FreeBSD.org>
---
 gdb/alpha-tdep.c  |  3 ++-
 gdb/frame.c       | 16 +++++++++-------
 gdb/frame.h       |  8 ++++----
 gdb/i386-tdep.c   |  3 ++-
 gdb/i387-tdep.c   |  2 +-
 gdb/ia64-tdep.c   |  2 +-
 gdb/m68k-tdep.c   |  2 +-
 gdb/mips-tdep.c   |  5 +++--
 gdb/rs6000-tdep.c |  2 +-
 9 files changed, 24 insertions(+), 19 deletions(-)

diff --git a/gdb/alpha-tdep.c b/gdb/alpha-tdep.c
index eaf2a7e97949..799441758103 100644
--- a/gdb/alpha-tdep.c
+++ b/gdb/alpha-tdep.c
@@ -269,8 +269,9 @@ alpha_value_to_register (frame_info_ptr frame, int regnum,
 
   gdb_byte out[ALPHA_REGISTER_SIZE];
   alpha_lds (get_frame_arch (frame), out, in);
+
   auto out_view = gdb::make_array_view (out, reg_size);
-  put_frame_register (frame, regnum, out_view);
+  put_frame_register (get_next_frame_sentinel_okay (frame), regnum, out_view);
 }
 
 \f
diff --git a/gdb/frame.c b/gdb/frame.c
index 61d6822ecc1a..44c4906e9cc1 100644
--- a/gdb/frame.c
+++ b/gdb/frame.c
@@ -1398,10 +1398,10 @@ read_frame_register_unsigned (frame_info_ptr frame, int regnum,
 }
 
 void
-put_frame_register (frame_info_ptr frame, int regnum,
-		    gdb::array_view<const gdb_byte> buf)
+put_frame_register (frame_info_ptr next_frame, int regnum,
+		     gdb::array_view<const gdb_byte> buf)
 {
-  struct gdbarch *gdbarch = get_frame_arch (frame);
+  gdbarch *gdbarch = frame_unwind_arch (next_frame);
   int realnum;
   int optim;
   int unavail;
@@ -1411,8 +1411,8 @@ put_frame_register (frame_info_ptr frame, int regnum,
 
   gdb_assert (buf.size () == size);
 
-  frame_register_unwind (get_next_frame_sentinel_okay (frame), regnum, &optim,
-			 &unavail, &lval, &addr, &realnum, nullptr);
+  frame_register_unwind (next_frame, regnum, &optim, &unavail, &lval, &addr,
+			 &realnum, nullptr);
   if (optim)
     error (_("Attempt to assign to a register that was not saved."));
   switch (lval)
@@ -1557,7 +1557,8 @@ put_frame_register_bytes (frame_info_ptr frame, int regnum,
 				    buffer.size ());
 
       if (curr_len == register_size (gdbarch, regnum))
-	put_frame_register (frame, regnum, buffer.slice (0, curr_len));
+	put_frame_register (get_next_frame_sentinel_okay (frame), regnum,
+			    buffer.slice (0, curr_len));
       else
 	{
 	  value *value
@@ -1567,7 +1568,8 @@ put_frame_register_bytes (frame_info_ptr frame, int regnum,
 
 	  copy (buffer.slice (0, curr_len),
 		value->contents_writeable ().slice (offset, curr_len));
-	  put_frame_register (frame, regnum, value->contents_raw ());
+	  put_frame_register (get_next_frame_sentinel_okay (frame), regnum,
+			      value->contents_raw ());
 	  release_value (value);
 	}
 
diff --git a/gdb/frame.h b/gdb/frame.h
index 4117e169379a..1d870d619ca5 100644
--- a/gdb/frame.h
+++ b/gdb/frame.h
@@ -727,10 +727,10 @@ extern ULONGEST get_frame_register_unsigned (frame_info_ptr frame,
 extern bool read_frame_register_unsigned (frame_info_ptr frame,
 					  int regnum, ULONGEST *val);
 
-/* The reverse.  Store a register value relative to the specified
-   frame.  Note: this call makes the frame's state undefined.  The
-   register and frame caches must be flushed.  */
-extern void put_frame_register (frame_info_ptr frame, int regnum,
+/* The reverse.  Store a register value relative to NEXT_FRAME's previous frame.
+   Note: this call makes the frame's state undefined.  The register and frame
+   caches must be flushed.  */
+extern void put_frame_register (frame_info_ptr next_frame, int regnum,
 				gdb::array_view<const gdb_byte> buf);
 
 /* Read LEN bytes from one or multiple registers starting with REGNUM
diff --git a/gdb/i386-tdep.c b/gdb/i386-tdep.c
index 3afa902767e5..f188f83de6f3 100644
--- a/gdb/i386-tdep.c
+++ b/gdb/i386-tdep.c
@@ -3918,7 +3918,8 @@ i386_value_to_register (frame_info_ptr frame, int regnum,
       gdb_assert (register_size (get_frame_arch (frame), regnum) == 4);
 
       auto from_view = gdb::make_array_view (from, 4);
-      put_frame_register (frame, regnum, from_view);
+      put_frame_register (get_next_frame_sentinel_okay (frame), regnum,
+			  from_view);
       regnum = i386_next_regnum (regnum);
       len -= 4;
       from += 4;
diff --git a/gdb/i387-tdep.c b/gdb/i387-tdep.c
index b39ca2adef55..77dc5a008d5f 100644
--- a/gdb/i387-tdep.c
+++ b/gdb/i387-tdep.c
@@ -400,7 +400,7 @@ i387_value_to_register (frame_info_ptr frame, int regnum,
   struct type *to_type = i387_ext_type (gdbarch);
   target_float_convert (from, type, to, to_type);
   auto to_view = gdb::make_array_view (to, to_type->length ());
-  put_frame_register (frame, regnum, to_view);
+  put_frame_register (get_next_frame_sentinel_okay (frame), regnum, to_view);
 }
 \f
 
diff --git a/gdb/ia64-tdep.c b/gdb/ia64-tdep.c
index f778c092537b..3bede2644c03 100644
--- a/gdb/ia64-tdep.c
+++ b/gdb/ia64-tdep.c
@@ -1248,7 +1248,7 @@ ia64_value_to_register (frame_info_ptr frame, int regnum,
   type *to_type = ia64_ext_type (gdbarch);
   target_float_convert (in, valtype, out, to_type);
   auto out_view = gdb::make_array_view (out, to_type->length ());
-  put_frame_register (frame, regnum, out_view);
+  put_frame_register (get_next_frame_sentinel_okay (frame), regnum, out_view);
 }
 
 
diff --git a/gdb/m68k-tdep.c b/gdb/m68k-tdep.c
index 2e8043af0e06..8bbfa4bd0b10 100644
--- a/gdb/m68k-tdep.c
+++ b/gdb/m68k-tdep.c
@@ -250,7 +250,7 @@ m68k_value_to_register (frame_info_ptr frame, int regnum,
   /* Convert from TYPE.  */
   target_float_convert (from, type, to, fpreg_type);
   auto to_view = gdb::make_array_view (to, fpreg_type->length ());
-  put_frame_register (frame, regnum, to_view);
+  put_frame_register (get_next_frame_sentinel_okay (frame), regnum, to_view);
 }
 
 \f
diff --git a/gdb/mips-tdep.c b/gdb/mips-tdep.c
index adaa091bda14..dbdf8a668b8f 100644
--- a/gdb/mips-tdep.c
+++ b/gdb/mips-tdep.c
@@ -991,8 +991,9 @@ mips_value_to_register (frame_info_ptr frame, int regnum,
   if (mips_convert_register_float_case_p (gdbarch, regnum, type))
     {
       auto from_view = gdb::make_array_view (from, 8);
-      put_frame_register (frame, regnum, from_view.slice (4));
-      put_frame_register (frame, regnum + 1, from_view.slice (0, 4));
+      frame_info_ptr next_frame = get_next_frame_sentinel_okay (frame);
+      put_frame_register (next_frame, regnum, from_view.slice (4));
+      put_frame_register (next_frame, regnum + 1, from_view.slice (0, 4));
     }
   else if (mips_convert_register_gpreg_case_p (gdbarch, regnum, type))
     {
diff --git a/gdb/rs6000-tdep.c b/gdb/rs6000-tdep.c
index cbbaf6d83a19..c43039302bc3 100644
--- a/gdb/rs6000-tdep.c
+++ b/gdb/rs6000-tdep.c
@@ -2744,7 +2744,7 @@ rs6000_value_to_register (frame_info_ptr frame,
   struct type *to_type = builtin_type (gdbarch)->builtin_double;
   target_float_convert (from, type, to, to_type);
   auto to_view = gdb::make_array_view (to, to_type->length ());
-  put_frame_register (frame, regnum, to_view);
+  put_frame_register (get_next_frame_sentinel_okay (frame), regnum, to_view);
 }
 
 static struct value *
-- 
2.43.0


  parent reply	other threads:[~2023-12-01 16:29 UTC|newest]

Thread overview: 34+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-12-01 16:27 [PATCH 00/24] Fix reading and writing pseudo registers in non-current frames Simon Marchi
2023-12-01 16:27 ` [PATCH 01/24] gdb: don't handle i386 k registers as pseudo registers Simon Marchi
2023-12-01 16:27 ` [PATCH 02/24] gdb: use reg_buffer_common throughout gdbsupport/common-regcache.h Simon Marchi
2023-12-01 16:27 ` [PATCH 03/24] gdb: make store_integer take an array_view Simon Marchi
2023-12-01 16:27 ` [PATCH 04/24] gdb: simplify conditions in regcache::{read,write,raw_collect,raw_supply}_part Simon Marchi
2023-12-01 16:27 ` [PATCH 05/24] gdb: change regcache interface to use array_view Simon Marchi
2023-12-01 16:27 ` [PATCH 06/24] gdb: fix bugs in {get,put}_frame_register_bytes Simon Marchi
2023-12-01 16:27 ` [PATCH 07/24] gdb: make put_frame_register take an array_view Simon Marchi
2023-12-01 16:27 ` [PATCH 08/24] gdb: change value_of_register and value_of_register_lazy to take the next frame Simon Marchi
2023-12-01 16:27 ` [PATCH 09/24] gdb: remove frame_register Simon Marchi
2023-12-01 16:27 ` Simon Marchi [this message]
2023-12-01 16:27 ` [PATCH 11/24] gdb: make put_frame_register_bytes take the next frame Simon Marchi
2023-12-01 16:27 ` [PATCH 12/24] gdb: make get_frame_register_bytes " Simon Marchi
2023-12-22 13:33   ` Kévin Le Gouguec
2023-12-22 15:31     ` Simon Marchi
2023-12-22 16:22       ` Kévin Le Gouguec
2023-12-01 16:27 ` [PATCH 13/24] gdb: add value::allocate_register Simon Marchi
2023-12-01 16:27 ` [PATCH 14/24] gdb: read pseudo register through frame Simon Marchi
2023-12-01 16:27 ` [PATCH 15/24] gdb: change parameter name in frame_unwind_register_unsigned declaration Simon Marchi
2023-12-01 16:27 ` [PATCH 16/24] gdb: rename gdbarch_pseudo_register_write to gdbarch_deprecated_pseudo_register_write Simon Marchi
2023-12-01 16:27 ` [PATCH 17/24] gdb: add gdbarch_pseudo_register_write that takes a frame Simon Marchi
2023-12-01 16:27 ` [PATCH 18/24] gdb: migrate i386 and amd64 to the new gdbarch_pseudo_register_write Simon Marchi
2023-12-01 16:27 ` [PATCH 19/24] gdb: make aarch64_za_offsets_from_regnum return za_offsets Simon Marchi
2023-12-01 16:27 ` [PATCH 20/24] gdb: add missing raw register read in aarch64_sme_pseudo_register_write Simon Marchi
2023-12-01 16:27 ` [PATCH 21/24] gdb: migrate aarch64 to new gdbarch_pseudo_register_write Simon Marchi
2023-12-14 14:53   ` Luis Machado
2023-12-01 16:27 ` [PATCH 22/24] gdb: migrate arm to gdbarch_pseudo_register_read_value Simon Marchi
2023-12-01 16:27 ` [PATCH 23/24] gdb: migrate arm to new gdbarch_pseudo_register_write Simon Marchi
2023-12-01 16:27 ` [PATCH 24/24] gdb/testsuite: add tests for unwinding of pseudo registers Simon Marchi
2023-12-14 14:54   ` Luis Machado
2023-12-01 16:56 ` [PATCH 00/24] Fix reading and writing pseudo registers in non-current frames Simon Marchi
2023-12-14 14:51 ` Luis Machado
2023-12-14 16:20   ` Simon Marchi
  -- strict thread matches above, loose matches on Subject: below --
2023-11-08  5:00 Simon Marchi
2023-11-08  5:00 ` [PATCH 10/24] gdb: make put_frame_register take the next frame 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=20231201162751.741751-11-simon.marchi@efficios.com \
    --to=simon.marchi@efficios.com \
    --cc=gdb-patches@sourceware.org \
    --cc=jhb@freebsd.org \
    --cc=luis.machado@arm.com \
    --cc=tankut.baris.aktemur@intel.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;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).