Add dwarf2_per_objfile parameter to get_die_type_at_offset
authorSimon Marchi <simon.marchi@polymtl.ca>
Wed, 27 May 2020 15:14:05 +0000 (11:14 -0400)
committerSimon Marchi <simon.marchi@efficios.com>
Wed, 27 May 2020 15:15:58 +0000 (11:15 -0400)
This allows removing some dwarf2_per_cu_data::dwarf2_per_objfile
references.

gdb/ChangeLog:

* dwarf2/read.h (dwarf2_get_die_type): Add dwarf2_per_objfile
parameter.
* dwarf2/read.c (get_die_type_at_offset): Likewise.
(read_namespace_alias): Update.
(lookup_die_type): Update.
(dwarf2_get_die_type): Add dwarf2_per_objfile parameter.
* dwarf2/loc.c (class dwarf_evaluate_loc_desc) <get_base_type>:
Update.
(disassemble_dwarf_expression): Update.

Change-Id: Ibaf5b684cb0a8eb8f0b23e62bd0283c295410aa5

gdb/ChangeLog
gdb/dwarf2/loc.c
gdb/dwarf2/read.c
gdb/dwarf2/read.h

index 56745dd66c2f7c8b19cbd56fa5834975edfd359f..45d267bdb42da37f6dc1c23816883eabfb666287 100644 (file)
@@ -1,3 +1,15 @@
+2020-05-27  Simon Marchi  <simon.marchi@polymtl.ca>
+
+       * dwarf2/read.h (dwarf2_get_die_type): Add dwarf2_per_objfile
+       parameter.
+       * dwarf2/read.c (get_die_type_at_offset): Likewise.
+       (read_namespace_alias): Update.
+       (lookup_die_type): Update.
+       (dwarf2_get_die_type): Add dwarf2_per_objfile parameter.
+       * dwarf2/loc.c (class dwarf_evaluate_loc_desc) <get_base_type>:
+       Update.
+       (disassemble_dwarf_expression): Update.
+
 2020-05-27  Simon Marchi  <simon.marchi@efficios.com>
 
        * dwarf2/read.h (struct dwarf2_queue_item): Add
index e98c67384877a65f9485b378d217d6297744e104..7953361adeed0b5a9c633417f6c60efe0a83c439 100644 (file)
@@ -673,7 +673,7 @@ public:
 
   struct type *get_base_type (cu_offset die_offset, int size) override
   {
-    struct type *result = dwarf2_get_die_type (die_offset, per_cu);
+    struct type *result = dwarf2_get_die_type (die_offset, per_cu, per_objfile);
     if (result == NULL)
       error (_("Could not find type for DW_OP_const_type"));
     if (size != 0 && TYPE_LENGTH (result) != size)
@@ -4162,7 +4162,7 @@ disassemble_dwarf_expression (struct ui_file *stream,
 
            data = safe_read_uleb128 (data, end, &ul);
            cu_offset offset = (cu_offset) ul;
-           type = dwarf2_get_die_type (offset, per_cu);
+           type = dwarf2_get_die_type (offset, per_cu, per_objfile);
            fprintf_filtered (stream, "<");
            type_print (type, "", stream, -1);
            fprintf_filtered (stream, " [0x%s]> %d",
@@ -4178,7 +4178,7 @@ disassemble_dwarf_expression (struct ui_file *stream,
 
            data = safe_read_uleb128 (data, end, &ul);
            cu_offset type_die = (cu_offset) ul;
-           type = dwarf2_get_die_type (type_die, per_cu);
+           type = dwarf2_get_die_type (type_die, per_cu, per_objfile);
            fprintf_filtered (stream, "<");
            type_print (type, "", stream, -1);
            fprintf_filtered (stream, " [0x%s]>",
@@ -4202,7 +4202,7 @@ disassemble_dwarf_expression (struct ui_file *stream,
            data = safe_read_uleb128 (data, end, &ul);
            cu_offset type_die = (cu_offset) ul;
 
-           type = dwarf2_get_die_type (type_die, per_cu);
+           type = dwarf2_get_die_type (type_die, per_cu, per_objfile);
            fprintf_filtered (stream, "<");
            type_print (type, "", stream, -1);
            fprintf_filtered (stream, " [0x%s]> [$%s]",
@@ -4225,7 +4225,7 @@ disassemble_dwarf_expression (struct ui_file *stream,
              {
                struct type *type;
 
-               type = dwarf2_get_die_type (type_die, per_cu);
+               type = dwarf2_get_die_type (type_die, per_cu, per_objfile);
                fprintf_filtered (stream, "<");
                type_print (type, "", stream, -1);
                fprintf_filtered (stream, " [0x%s]>",
index 433d90e42fc866a26d9a00e7a92a18483d0a26aa..06e843aeb82917ca83db7caa9b2cf6e9afa3d62a 100644 (file)
@@ -1599,7 +1599,8 @@ static void dwarf2_mark (struct dwarf2_cu *);
 static void dwarf2_clear_marks (struct dwarf2_per_cu_data *);
 
 static struct type *get_die_type_at_offset (sect_offset,
-                                           struct dwarf2_per_cu_data *);
+                                           dwarf2_per_cu_data *per_cu,
+                                           dwarf2_per_objfile *per_objfile);
 
 static struct type *get_die_type (struct die_info *die, struct dwarf2_cu *cu);
 
@@ -10594,7 +10595,7 @@ read_namespace_alias (struct die_info *die, struct dwarf2_cu *cu)
          struct type *type;
          sect_offset sect_off = attr->get_ref_die_offset ();
 
-         type = get_die_type_at_offset (sect_off, cu->per_cu);
+         type = get_die_type_at_offset (sect_off, cu->per_cu, cu->per_objfile);
          if (type != NULL && type->code () == TYPE_CODE_NAMESPACE)
            {
              /* This declaration is a global namespace alias.  Add
@@ -21390,13 +21391,14 @@ lookup_die_type (struct die_info *die, const struct attribute *attr,
 
       per_cu = dwarf2_find_containing_comp_unit (sect_off, 1,
                                                 dwarf2_per_objfile);
-      this_type = get_die_type_at_offset (sect_off, per_cu);
+      this_type = get_die_type_at_offset (sect_off, per_cu, dwarf2_per_objfile);
     }
   else if (attr->form_is_ref ())
     {
       sect_offset sect_off = attr->get_ref_die_offset ();
 
-      this_type = get_die_type_at_offset (sect_off, cu->per_cu);
+      this_type = get_die_type_at_offset (sect_off, cu->per_cu,
+                                         dwarf2_per_objfile);
     }
   else if (attr->form == DW_FORM_ref_sig8)
     {
@@ -22596,10 +22598,11 @@ dwarf2_fetch_die_type_sect_off (sect_offset sect_off,
 
 struct type *
 dwarf2_get_die_type (cu_offset die_offset,
-                    struct dwarf2_per_cu_data *per_cu)
+                    dwarf2_per_cu_data *per_cu,
+                    dwarf2_per_objfile *per_objfile)
 {
   sect_offset die_offset_sect = per_cu->sect_off + to_underlying (die_offset);
-  return get_die_type_at_offset (die_offset_sect, per_cu);
+  return get_die_type_at_offset (die_offset_sect, per_cu, per_objfile);
 }
 
 /* Follow type unit SIG_TYPE referenced by SRC_DIE.
@@ -23789,10 +23792,10 @@ set_die_type (struct die_info *die, struct type *type, struct dwarf2_cu *cu)
 
 static struct type *
 get_die_type_at_offset (sect_offset sect_off,
-                       struct dwarf2_per_cu_data *per_cu)
+                       dwarf2_per_cu_data *per_cu,
+                       dwarf2_per_objfile *dwarf2_per_objfile)
 {
   struct dwarf2_per_cu_offset_and_type *slot, ofs;
-  struct dwarf2_per_objfile *dwarf2_per_objfile = per_cu->dwarf2_per_objfile;
 
   if (dwarf2_per_objfile->die_type_hash == NULL)
     return NULL;
@@ -23813,7 +23816,7 @@ get_die_type_at_offset (sect_offset sect_off,
 static struct type *
 get_die_type (struct die_info *die, struct dwarf2_cu *cu)
 {
-  return get_die_type_at_offset (die->sect_off, cu->per_cu);
+  return get_die_type_at_offset (die->sect_off, cu->per_cu, cu->per_objfile);
 }
 
 /* Add a dependence relationship from CU to REF_PER_CU.  */
index 3dada4852d79f6b59621b12d8972a6970d74dc9b..cc1fd914b6f085c70dc5b7973d052d66283bb6b6 100644 (file)
@@ -569,7 +569,8 @@ extern dwz_file *dwarf2_get_dwz_file (dwarf2_per_bfd *per_bfd);
    PER_CU.  */
 
 struct type *dwarf2_get_die_type (cu_offset die_offset,
-                                 struct dwarf2_per_cu_data *per_cu);
+                                 dwarf2_per_cu_data *per_cu,
+                                 dwarf2_per_objfile *per_objfile);
 
 /* Given an index in .debug_addr, fetch the value.
    NOTE: This can be called during dwarf expression evaluation,