[v3,02/17] Cleanup of the dwarf_expr_context constructor

Message ID 20210528154648.60881-3-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>


Move the initial values for dwarf_expr_context class data members
to the class declaration in expr.h.

gdb/ChangeLog:

        * dwarf2/expr.c (dwarf_expr_context::dwarf_expr_context):
        Remove initial data members values.
        * dwarf2/expr.h (dwarf_expr_context): Add initial values
        to the class data members.
---
 gdb/dwarf2/expr.c | 11 +----------
 gdb/dwarf2/expr.h | 16 ++++++++--------
 2 files changed, 9 insertions(+), 18 deletions(-)

-- 
2.17.1

Patch

diff --git a/gdb/dwarf2/expr.c b/gdb/dwarf2/expr.c
index 107b9cdbd5d..aa166b22d9c 100644
--- a/gdb/dwarf2/expr.c
+++ b/gdb/dwarf2/expr.c
@@ -90,16 +90,7 @@  dwarf_expr_context::address_type () const
 /* Create a new context for the expression evaluator.  */
 
 dwarf_expr_context::dwarf_expr_context (dwarf2_per_objfile *per_objfile)
-: gdbarch (NULL),
-  addr_size (0),
-  ref_addr_size (0),
-  recursion_depth (0),
-  max_recursion_depth (0x100),
-  location (DWARF_VALUE_MEMORY),
-  len (0),
-  data (NULL),
-  initialized (0),
-  per_objfile (per_objfile)
+: per_objfile (per_objfile)
 {
 }
 
diff --git a/gdb/dwarf2/expr.h b/gdb/dwarf2/expr.h
index b28a0775602..fc31be31a4d 100644
--- a/gdb/dwarf2/expr.h
+++ b/gdb/dwarf2/expr.h
@@ -132,32 +132,32 @@  struct dwarf_expr_context
   std::vector<dwarf_stack_value> stack;
 
   /* Target architecture to use for address operations.  */
-  struct gdbarch *gdbarch;
+  struct gdbarch *gdbarch = nullptr;
 
   /* Target address size in bytes.  */
-  int addr_size;
+  int addr_size = 0;
 
   /* DW_FORM_ref_addr size in bytes.  If -1 DWARF is executed from a frame
      context and operations depending on DW_FORM_ref_addr are not allowed.  */
-  int ref_addr_size;
+  int ref_addr_size = 0;
 
   /* The current depth of dwarf expression recursion, via DW_OP_call*,
      DW_OP_fbreg, DW_OP_push_object_address, etc., and the maximum
      depth we'll tolerate before raising an error.  */
-  int recursion_depth, max_recursion_depth;
+  int recursion_depth = 0, max_recursion_depth = 0x100;
 
   /* Location of the value.  */
-  enum dwarf_value_location location;
+  enum dwarf_value_location location = DWARF_VALUE_MEMORY;
 
   /* For DWARF_VALUE_LITERAL, the current literal value's length and
      data.  For DWARF_VALUE_IMPLICIT_POINTER, LEN is the offset of the
      target DIE of sect_offset kind.  */
-  ULONGEST len;
-  const gdb_byte *data;
+  ULONGEST len = 0;
+  const gdb_byte *data = nullptr;
 
   /* Initialization status of variable: Non-zero if variable has been
      initialized; zero otherwise.  */
-  int initialized;
+  int initialized = 0;
 
   /* A vector of pieces.