[PATCH 08/43] Move read_mem to dwarf_expr_context

Zoran Zaric via Gdb-patches
2021-03-01T14:46:59Z

From: Zoran Zaric <zoran.zaric@amd.com>

Following the idea of merging the evaluators, the read_mem method can
be moved from dwarf_expr_executor and dwarf_evaluate_loc_desc classes
to their base class dwarf_expr_context.

gdb/ChangeLog:

* dwarf2/expr.c (dwarf_expr_context::read_mem): Move from
dwarf_evaluate_loc_desc.
* dwarf2/frame.c (dwarf_expr_executor::read_mem): Remove
method.
* dwarf2/loc.c (dwarf_evaluate_loc_desc::read_mem): Move to
dwarf_expr_context.
---
gdb/dwarf2/expr.c | 9 +++++++++
gdb/dwarf2/expr.h | 2 +-
gdb/dwarf2/frame.c | 5 -----
gdb/dwarf2/loc.c | 7 -------
4 files changed, 10 insertions(+), 13 deletions(-)

diff --git a/gdb/dwarf2/expr.c b/gdb/dwarf2/expr.c
index 9b2c7485720..872de16cd70 100644
--- a/gdb/dwarf2/expr.c
+++ b/gdb/dwarf2/expr.c
@@ -259,6 +259,15 @@ dwarf_expr_context::dwarf_call (cu_offset die_cu_off)
this->eval (block.data, block.size);
}

+/* See expr.h. */
+
+void
+dwarf_expr_context::read_mem (gdb_byte *buf, CORE_ADDR addr,
+ size_t length)
+{
+ read_memory (addr, buf, length);
+}
+
/* Require that TYPE be an integral type; throw an exception if not. */

static void
diff --git a/gdb/dwarf2/expr.h b/gdb/dwarf2/expr.h
index b25b2315dd9..713bdd94f27 100644
--- a/gdb/dwarf2/expr.h
+++ b/gdb/dwarf2/expr.h
@@ -196,7 +196,7 @@ struct dwarf_expr_context
CORE_ADDR obj_address = 0;

/* Read LENGTH bytes at ADDR into BUF. */
- virtual void read_mem (gdb_byte *buf, CORE_ADDR addr, size_t length) = 0;
+ virtual void read_mem (gdb_byte *buf, CORE_ADDR addr, size_t length);

/* Push on DWARF stack an entry evaluated for DW_TAG_call_site's
parameter matching KIND and KIND_U at the caller of specified BATON.
diff --git a/gdb/dwarf2/frame.c b/gdb/dwarf2/frame.c
index b3f0888e239..ce95a811abd 100644
--- a/gdb/dwarf2/frame.c
+++ b/gdb/dwarf2/frame.c
@@ -231,11 +231,6 @@ class dwarf_expr_executor : public dwarf_expr_context
: dwarf_expr_context (per_objfile)
{}

- void read_mem (gdb_byte *buf, CORE_ADDR addr, size_t len) override
- {
- read_memory (addr, buf, len);
- }
-
void push_dwarf_reg_entry_value (enum call_site_parameter_kind kind,
union call_site_parameter_u kind_u,
int deref_size) override
diff --git a/gdb/dwarf2/loc.c b/gdb/dwarf2/loc.c
index c716c3a7858..9c4872436d7 100644
--- a/gdb/dwarf2/loc.c
+++ b/gdb/dwarf2/loc.c
@@ -686,13 +686,6 @@ class dwarf_evaluate_loc_desc : public dwarf_expr_context

this->eval (data_src, size);
}
-
- /* Read memory at ADDR (length LEN) into BUF. */
-
- void read_mem (gdb_byte *buf, CORE_ADDR addr, size_t len) override
- {
- read_memory (addr, buf, len);
- }
};

/* See dwarf2loc.h. */
--
2.17.1