[v3,08/17] Move read_mem to dwarf_expr_context

Message ID 20210528154648.60881-9-zoran.zaric@amd.com
State New
Headers show
Series
  • DWARF expression evaluator design cleanup
Related show

Commit Message

Simon Marchi via Gdb-patches May 28, 2021, 3:46 p.m.
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(-)

-- 
2.17.1

Patch

diff --git a/gdb/dwarf2/expr.c b/gdb/dwarf2/expr.c
index 689224b63a3..b2d58ff4afe 100644
--- a/gdb/dwarf2/expr.c
+++ b/gdb/dwarf2/expr.c
@@ -257,6 +257,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 ad1918eb18c..7e2aed07ed7 100644
--- a/gdb/dwarf2/expr.h
+++ b/gdb/dwarf2/expr.h
@@ -192,7 +192,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 52b09809ccb..99330092c12 100644
--- a/gdb/dwarf2/frame.c
+++ b/gdb/dwarf2/frame.c
@@ -232,11 +232,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 07b7ececff5..34dd3a55fdd 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.  */