[v3,10/17] Inline get_reg_value method of dwarf_expr_context

Message ID 20210528154648.60881-11-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.
From: Zoran Zaric <Zoran.Zaric@amd.com>


The get_reg_value method is a small function that is only called once,
so it can be inlined to simplify the dwarf_expr_context class.

gdb/ChangeLog:

	* dwarf2/expr.c (dwarf_expr_context::get_reg_value): Remove
	method.
	(dwarf_expr_context::execute_stack_op): Inline get_reg_value
	method.
	* dwarf2/expr.h (dwarf_expr_context::get_reg_value): Remove
	method.
---
 gdb/dwarf2/expr.c | 24 +++++++-----------------
 gdb/dwarf2/expr.h |  6 ------
 2 files changed, 7 insertions(+), 23 deletions(-)

-- 
2.17.1

Patch

diff --git a/gdb/dwarf2/expr.c b/gdb/dwarf2/expr.c
index 303b2b5ba14..1a068741894 100644
--- a/gdb/dwarf2/expr.c
+++ b/gdb/dwarf2/expr.c
@@ -176,19 +176,6 @@  dwarf_expr_context::fetch (int n)
 
 /* See expr.h.  */
 
-struct value *
-dwarf_expr_context::get_reg_value (struct type *type, int reg)
-{
-  ensure_have_frame (this->frame, "DW_OP_regval_type");
-
-  struct gdbarch *gdbarch = get_frame_arch (this->frame);
-  int regnum = dwarf_reg_to_regnum_or_error (gdbarch, reg);
-
-  return value_from_register (type, regnum, this->frame);
-}
-
-/* See expr.h.  */
-
 void
 dwarf_expr_context::get_frame_base (const gdb_byte **start,
 				    size_t * length)
@@ -1544,14 +1531,17 @@  dwarf_expr_context::execute_stack_op (const gdb_byte *op_ptr,
 	case DW_OP_regval_type:
 	case DW_OP_GNU_regval_type:
 	  {
-	    struct type *type;
-
 	    op_ptr = safe_read_uleb128 (op_ptr, op_end, &reg);
 	    op_ptr = safe_read_uleb128 (op_ptr, op_end, &uoffset);
 	    cu_offset type_die_cu_off = (cu_offset) uoffset;
 
-	    type = get_base_type (type_die_cu_off);
-	    result_val = this->get_reg_value (type, reg);
+	    ensure_have_frame (this->frame, "DW_OP_regval_type");
+
+	    struct type *type = get_base_type (type_die_cu_off);
+	    int regnum
+	      = dwarf_reg_to_regnum_or_error (get_frame_arch (this->frame),
+					      reg);
+	    result_val = value_from_register (type, regnum, this->frame);
 	  }
 	  break;
 
diff --git a/gdb/dwarf2/expr.h b/gdb/dwarf2/expr.h
index 72cf14abcfc..aa80d1f31cb 100644
--- a/gdb/dwarf2/expr.h
+++ b/gdb/dwarf2/expr.h
@@ -211,12 +211,6 @@  struct dwarf_expr_context
   void execute_stack_op (const gdb_byte *op_ptr, const gdb_byte *op_end);
   void pop ();
 
-  /* Return a value of type TYPE, stored in register number REGNUM
-     in a current context.
-
-     REGNUM is a DWARF register number.  */
-  struct value *get_reg_value (struct type *type, int regnum);
-
   /* Return the location expression for the frame base attribute, in
      START and LENGTH.  The result must be live until the current
      expression evaluation is complete.  */