[PATCH 09/24] gdb: remove frame_register

Simon Marchi
2023-11-08T05:14:52Z

From: Simon Marchi <simon.marchi@efficios.com>

I was going to change frame_register to take the "next frame", but I
realized that doing so would make it a useless wrapper around
frame_register_unwind. So, just remove frame_register and replace uses
with frame_register_unwind.

Change-Id: I185868bc69f8e098124775d0550d069220a4678a
---
gdb/frame.c | 39 ++++++++-------------------------------
1 file changed, 8 insertions(+), 31 deletions(-)

diff --git a/gdb/frame.c b/gdb/frame.c
index 84ef8461b835..5d8ecb52fe2f 100644
--- a/gdb/frame.c
+++ b/gdb/frame.c
@@ -1213,31 +1213,6 @@ frame_register_unwind (frame_info_ptr next_frame, int regnum,
release_value (value);
}

-/* Get the value of the register that belongs to this FRAME. This
- function is a wrapper to the call sequence ``frame_register_unwind
- (get_next_frame (FRAME))''. As per frame_register_unwind(), if
- VALUEP is NULL, the registers value is not fetched/computed. */
-
-static void
-frame_register (frame_info_ptr frame, int regnum,
- int *optimizedp, int *unavailablep, enum lval_type *lvalp,
- CORE_ADDR *addrp, int *realnump, gdb_byte *bufferp)
-{
- /* Require all but BUFFERP to be valid. A NULL BUFFERP indicates
- that the value proper does not need to be fetched. */
- gdb_assert (optimizedp != NULL);
- gdb_assert (lvalp != NULL);
- gdb_assert (addrp != NULL);
- gdb_assert (realnump != NULL);
- /* gdb_assert (bufferp != NULL); */
-
- /* Obtain the register value by unwinding the register from the next
- (more inner frame). */
- gdb_assert (frame != NULL && frame->next != NULL);
- frame_register_unwind (frame_info_ptr (frame->next), regnum, optimizedp,
- unavailablep, lvalp, addrp, realnump, bufferp);
-}
-
void
frame_unwind_register (frame_info_ptr next_frame, int regnum, gdb_byte *buf)
{
@@ -1435,8 +1410,8 @@ put_frame_register (frame_info_ptr frame, int regnum,

gdb_assert (buf.size () == size);

- frame_register (frame, regnum, &optim, &unavail,
- &lval, &addr, &realnum, NULL);
+ frame_register_unwind (get_next_frame_sentinel_okay (frame), regnum, &optim,
+ &unavail, &lval, &addr, &realnum, nullptr);
if (optim)
error (_("Attempt to assign to a register that was not saved."));
switch (lval)
@@ -1472,8 +1447,9 @@ deprecated_frame_register_read (frame_info_ptr frame, int regnum,
CORE_ADDR addr;
int realnum;

- frame_register (frame, regnum, &optimized, &unavailable,
- &lval, &addr, &realnum, myaddr);
+ frame_register_unwind (get_next_frame_sentinel_okay (frame), regnum,
+ &optimized, &unavailable, &lval, &addr, &realnum,
+ myaddr);

return !optimized && !unavailable;
}
@@ -1522,8 +1498,9 @@ get_frame_register_bytes (frame_info_ptr frame, int regnum,
CORE_ADDR addr;
int realnum;

- frame_register (frame, regnum, optimizedp, unavailablep, &lval,
- &addr, &realnum, buffer.data ());
+ frame_register_unwind (get_next_frame_sentinel_okay (frame), regnum,
+ optimizedp, unavailablep, &lval, &addr,
+ &realnum, buffer.data ());
if (*optimizedp || *unavailablep)
return false;
}
--
2.42.1