[PATCH v2 17/42] Add dwarf2_per_objfile parameter to create_partial_symtab

Simon Marchi
2020-05-12T21:12:28Z

This allows removing a dwarf2_per_cu_data::dwarf2_per_objfile reference.

gdb/ChangeLog:

* dwarf2/read.c (create_partial_symtab): Add dwarf2_per_objfile
parameter.
(create_type_unit_group): Update.
(process_psymtab_comp_unit_reader): Update.
(build_type_psymtabs_reader): Update.
---
gdb/dwarf2/read.c | 18 +++++++++++-------
1 file changed, 11 insertions(+), 7 deletions(-)

diff --git a/gdb/dwarf2/read.c b/gdb/dwarf2/read.c
index d028e86c356..68e5d987443 100644
--- a/gdb/dwarf2/read.c
+++ b/gdb/dwarf2/read.c
@@ -1204,7 +1204,8 @@ static void dwarf2_find_base_address (struct die_info *die,
struct dwarf2_cu *cu);

static dwarf2_psymtab *create_partial_symtab
- (struct dwarf2_per_cu_data *per_cu, const char *name);
+ (dwarf2_per_cu_data *per_cu, dwarf2_per_objfile *per_objfile,
+ const char *name);

static void build_type_psymtabs_reader (const struct die_reader_specs *reader,
const gdb_byte *info_ptr,
@@ -7293,7 +7294,7 @@ create_type_unit_group (struct dwarf2_cu *cu, sect_offset line_offset_struct)
else
name = string_printf ("<type_units_at_0x%x>", line_offset);

- pst = create_partial_symtab (per_cu, name.c_str ());
+ pst = create_partial_symtab (per_cu, dwarf2_per_objfile, name.c_str ());
pst->anonymous = true;
}

@@ -7367,9 +7368,11 @@ get_type_unit_group (struct dwarf2_cu *cu, const struct attribute *stmt_list)
dirname, textlow, texthigh. */

static dwarf2_psymtab *
-create_partial_symtab (struct dwarf2_per_cu_data *per_cu, const char *name)
+create_partial_symtab (dwarf2_per_cu_data *per_cu,
+ dwarf2_per_objfile *per_objfile,
+ const char *name)
{
- struct objfile *objfile = per_cu->dwarf2_per_objfile->objfile;
+ struct objfile *objfile = per_objfile->objfile;
dwarf2_psymtab *pst;

pst = new dwarf2_psymtab (name, objfile, per_cu);
@@ -7391,7 +7394,8 @@ process_psymtab_comp_unit_reader (const struct die_reader_specs *reader,
enum language pretend_language)
{
struct dwarf2_cu *cu = reader->cu;
- struct objfile *objfile = cu->per_objfile->objfile;
+ dwarf2_per_objfile *per_objfile = cu->per_objfile;
+ struct objfile *objfile = per_objfile->objfile;
struct gdbarch *gdbarch = objfile->arch ();
struct dwarf2_per_cu_data *per_cu = cu->per_cu;
CORE_ADDR baseaddr;
@@ -7418,7 +7422,7 @@ process_psymtab_comp_unit_reader (const struct die_reader_specs *reader,
filename = debug_filename.get ();
}

- pst = create_partial_symtab (per_cu, filename);
+ pst = create_partial_symtab (per_cu, per_objfile, filename);

/* This must be done before calling dwarf2_build_include_psymtabs. */
pst->dirname = dwarf2_string_attr (comp_unit_die, DW_AT_comp_dir, cu);
@@ -7599,7 +7603,7 @@ build_type_psymtabs_reader (const struct die_reader_specs *reader,
tu_group->tus->push_back (sig_type);

prepare_one_comp_unit (cu, type_unit_die, language_minimal);
- pst = create_partial_symtab (per_cu, "");
+ pst = create_partial_symtab (per_cu, dwarf2_per_objfile, "");
pst->anonymous = true;

first_die = load_partial_dies (reader, info_ptr, 1);
--
2.26.2