[PATCH 36/43] Move read_addr_from_reg function to frame.c

Zoran Zaric via Gdb-patches
2021-03-01T14:47:57Z

read_addr_from_reg function is now only called from frame.c file, this
means that the function can safely be moved there.

gdb/ChangeLog:

* dwarf2/expr.c (read_addr_from_reg): Move function to frame.c.
* dwarf2/expr.h (read_addr_from_reg): Remove function.
* dwarf2/frame.c (read_addr_from_reg): Add function from
expr.c.
---
gdb/dwarf2/expr.c | 11 -----------
gdb/dwarf2/expr.h | 4 ----
gdb/dwarf2/frame.c | 12 ++++++++++++
3 files changed, 12 insertions(+), 15 deletions(-)

diff --git a/gdb/dwarf2/expr.c b/gdb/dwarf2/expr.c
index 7a091e74ce5..b5f408fead1 100644
--- a/gdb/dwarf2/expr.c
+++ b/gdb/dwarf2/expr.c
@@ -105,17 +105,6 @@ ill_formed_expression ()
error (_("Ill-formed DWARF expression"));
}

-/* See expr.h. */
-
-CORE_ADDR
-read_addr_from_reg (struct frame_info *frame, int reg)
-{
- struct gdbarch *gdbarch = get_frame_arch (frame);
- int regnum = dwarf_reg_to_regnum_or_error (gdbarch, reg);
-
- return address_from_register (regnum, frame);
-}
-
/* Read register REGNUM's contents in a given FRAME context.

The data read is offsetted by OFFSET, and the number of bytes read
diff --git a/gdb/dwarf2/expr.h b/gdb/dwarf2/expr.h
index 132f924014f..b64bffc58c1 100644
--- a/gdb/dwarf2/expr.h
+++ b/gdb/dwarf2/expr.h
@@ -51,10 +51,6 @@ struct value *dwarf2_evaluate (const gdb_byte *addr, size_t len, bool as_lval,
ADDR_SIZE is expected size of the type. */
struct type *address_type (struct gdbarch *gdbarch, int addr_size);

-/* Return the value of register number REG (a DWARF register number),
- read as an address in a given FRAME. */
-CORE_ADDR read_addr_from_reg (struct frame_info *, int);
-
/* Check that the current operator is either at the end of an
expression, or that it is followed by a composition operator or by
DW_OP_GNU_uninit (which should terminate the expression). */
diff --git a/gdb/dwarf2/frame.c b/gdb/dwarf2/frame.c
index 97bd0d35319..46cbf7016c2 100644
--- a/gdb/dwarf2/frame.c
+++ b/gdb/dwarf2/frame.c
@@ -192,6 +192,18 @@ dwarf2_frame_state::dwarf2_frame_state (CORE_ADDR pc_, struct dwarf2_cie *cie)
{
}

+/* Return the value of register number REG (a DWARF register number),
+ read as an address in a given FRAME. */
+
+static CORE_ADDR
+read_addr_from_reg (struct frame_info *frame, int reg)
+{
+ struct gdbarch *gdbarch = get_frame_arch (frame);
+ int regnum = dwarf_reg_to_regnum_or_error (gdbarch, reg);
+
+ return address_from_register (regnum, frame);
+}
+
/* Execute the required actions for both the DW_CFA_restore and
DW_CFA_restore_extended instructions. */
static void
--
2.17.1