]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commitdiff
Move get_object_address to dwarf_expr_context
authorZoran Zaric <Zoran.Zaric@amd.com>
Mon, 7 Dec 2020 19:00:07 +0000 (19:00 +0000)
committerSimon Marchi <simon.marchi@polymtl.ca>
Tue, 8 Dec 2020 16:16:18 +0000 (11:16 -0500)
Following the idea of merging the evaluators, the get_object_address
and 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::get_object_address): Move
from dwarf_evaluate_loc_desc.
(class dwarf_expr_context): Add object address member to
dwarf_expr_context.
* dwarf2/expr.h (dwarf_expr_context::get_frame_pc): Remove
method.
* dwarf2/frame.c (dwarf_expr_executor::get_object_address):
Remove method.
* dwarf2/loc.c (dwarf_evaluate_loc_desc::get_object_address):
move to dwarf_expr_context.
(class dwarf_evaluate_loc_desc): Move object address member to
dwarf_expr_context.

Change-Id: I67ee9e004af1f0d513d8832f10948c7cf22dd422

gdb/dwarf2/expr.c
gdb/dwarf2/expr.h
gdb/dwarf2/frame.c
gdb/dwarf2/loc.c

index a5144b692dfcbe1fc95684f301f7bdc757ee19b4..e6a9e877e4395455a9bc6f9445539444a2abd02b 100644 (file)
@@ -134,7 +134,8 @@ dwarf_expr_context::dwarf_expr_context (dwarf2_per_objfile *per_objfile)
   initialized (0),
   per_objfile (per_objfile),
   frame (nullptr),
-  per_cu (nullptr)
+  per_cu (nullptr),
+  obj_address (0)
 {
 }
 
index eb765a28a26d630aacb1997a31029bc65c23bbf3..e3e8bf8ae53e443d88ffa4087bdee07ad7ab1157 100644 (file)
@@ -192,6 +192,9 @@ struct dwarf_expr_context
   /* Compilation unit used for the evaluation.  */
   struct dwarf2_per_cu_data *per_cu;
 
+  /* Object address used for the evaluation.  */
+  CORE_ADDR obj_address;
+
   /* Read LENGTH bytes at ADDR into BUF.  */
   virtual void read_mem (gdb_byte *buf, CORE_ADDR addr, size_t length) = 0;
 
@@ -204,7 +207,12 @@ struct dwarf_expr_context
                                           int deref_size) = 0;
 
   /* Return the `object address' for DW_OP_push_object_address.  */
-  virtual CORE_ADDR get_object_address () = 0;
+  virtual CORE_ADDR get_object_address ()
+  {
+    if (obj_address == 0)
+      error (_("Location address is not set."));
+    return obj_address;
+  }
 
 private:
 
index af5302bd980bb356cb8ef9889b47fe2ad94be009..96bfdc145219c681cdad828c286cf9fc95829b6e 100644 (file)
@@ -243,11 +243,6 @@ public:
     invalid ("DW_OP_entry_value");
   }
 
-  CORE_ADDR get_object_address () override
-  {
-    invalid ("DW_OP_push_object_address");
-  }
-
  private:
 
   void invalid (const char *op) ATTRIBUTE_NORETURN
index 5a2b1b2851ccb1a78902ee170e40013109ad48f7..c1f5457e1de398cddc0505badafc78421edc578d 100644 (file)
@@ -632,18 +632,6 @@ public:
     : dwarf_expr_context (per_objfile)
   {}
 
-  CORE_ADDR obj_address;
-
-  /* Callback function for get_object_address. Return the address of the VLA
-     object.  */
-
-  CORE_ADDR get_object_address () override
-  {
-    if (obj_address == 0)
-      error (_("Location address is not set."));
-    return obj_address;
-  }
-
   /* Execute DWARF block of call_site_parameter which matches KIND and
      KIND_U.  Choose DEREF_SIZE value of that parameter.  Search
      caller of this objects's frame.