[PATCH 1/2] Replace objfile field in dwarf2_cu and dwarf2_per_cu_data with dwarf2_per_objfile

Simon Marchi simon.marchi@polymtl.ca
Sun Dec 10 18:09:00 GMT 2017


From: Simon Marchi <simon.marchi@ericsson.com>

The next patch aims to remove the dwarf2_per_objfile global.  In many
functions, we need to find a way to get a reference to the current
dwarf2_per_objfile through the objects passed in parameters.  Often, we have
access to a dwarf2_cu or a dwarf2_per_cu_data.  These objects have a reference
to the objfile, through which we can get the dwarf2_per_objfile:

  dwarf2_per_objfile = ((struct dwarf2_per_objfile *)
		        objfile_data (objfile, dwarf2_objfile_data_key));

However, this is a bit cumbersome to do all over the place.  It would be
more logical if the dwarf2_cu and dwarf2_per_cu_data had a reference to
their dwarf2_per_objfile, which would then have a reference to the
objfile.  It would be more in line with the object hierarchy, where
dwarf2_per_objfile owns the dwarf2_per_cu_data instances.  We could
even remove the reference dwarf2_cu has to dwarf2_per_objfile, since we
can access dwarf2_per_objfile through dwarf2_cu::per_cu.

In a graphical way, references would look like this after the current
patch:

  objfile <--- dwarf2_per_objfile <--- dwarf2_per_cu_data
                                    |      ^
				    |      |
                                    `- dwarf2_cu

This patch has been tested on the buildbot.

gdb/ChangeLog:

	* dwarf2read.c (struct dwarf2_cu) <objfile>: Remove.
	<dwarf2_per_objfile>: New field.
	(struct dwarf2_per_cu_data) <objfile>: Remove.
	<dwarf2_per_objfile>: New field.
	(create_cu_from_index_list): Assign dwarf2_per_objfile instead
	of objfile.
	(create_signatured_type_table_from_index): Likewise.
	(create_debug_type_hash_table): Likewise.
	(fill_in_sig_entry_from_dwo_entry): Likewise.
	(lookup_dwo_unit): Access objfile through dwarf2_per_objfile.
	(create_type_unit_group): Assign dwarf2_per_objfile instead of
	objfile.
	(create_partial_symtab): Access objfile through
	dwarf2_per_objfile.
	(process_psymtab_comp_unit_reader): Likewise.
	(read_comp_units_from_section): Likewise.
	(scan_partial_symbols): Likewise.
	(add_partial_symbol): Likewise.
	(add_partial_subprogram): Likewise.
	(peek_die_abbrev): Likewise.
	(fixup_go_packaging): Likewise.
	(process_full_comp_unit): Likewise.
	(process_full_type_unit): Likewise.
	(process_imported_unit_die): Likewise.
	(dwarf2_compute_name): Likewise.
	(dwarf2_physname): Likewise.
	(read_import_statement): Likewise.
	(create_cus_hash_table): Assign dwarf2_physname instead of
	objfile.
	(read_func_scope): Access objfile through dwarf2_per_objfile.
	(read_lexical_block_scope): Likewise.
	(read_call_site_scope): Likewise.
	(read_variable): Likewise.
	(dwarf2_rnglists_process): Likewise.
	(dwarf2_ranges_process): Likewise.
	(dwarf2_ranges_read): Likewise.
	(dwarf2_record_block_ranges): Likewise.
	(dwarf2_add_field): Likewise.
	(dwarf2_add_member_fn): Likewise.
	(read_structure_type): Likewise.
	(process_structure_scope): Likewise.
	(read_enumeration_type): Likewise.
	(read_array_type): Likewise.
	(read_common_block): Likewise.
	(read_namespace_type): Likewise.
	(read_namespace): Likewise.
	(read_module_type): Likewise.
	(read_tag_pointer_type): Likewise.
	(read_tag_ptr_to_member_type): Likewise.
	(read_tag_string_type): Likewise.
	(read_subroutine_type): Likewise.
	(read_typedef): Likewise.
	(read_base_type): Likewise.
	(attr_to_dynamic_prop): Likewise.
	(read_subrange_type): Likewise.
	(read_unspecified_type): Likewise.
	(load_partial_dies): Likewise.
	(read_partial_die): Likewise.
	(find_partial_die): Likewise.
	(guess_partial_die_structure_name): Likewise.
	(fixup_partial_die): Likewise.
	(read_attribute_value): Likewise.
	(read_addr_index_from_leb128): Likewise.
	(dwarf2_read_addr_index): Likewise.
	(dwarf2_string_attr): Likewise.
	(lnp_state_machine::check_line_address): Likewise.
	(dwarf_decode_lines_1): Likewise.
	(dwarf_decode_lines): Likewise.
	(dwarf2_start_symtab): Likewise.
	(var_decode_location): Likewise.
	(new_symbol_full): Likewise.
	(dwarf2_const_value_data): Likewise.
	(dwarf2_const_value_attr): Likewise.
	(dwarf2_const_value): Likewise.
	(die_type): Likewise.
	(die_containing_type): Likewise.
	(lookup_die_type): Likewise.
	(guess_full_die_structure_name): Likewise.
	(anonymous_struct_prefix): Likewise.
	(dwarf2_name): Likewise.
	(follow_die_ref_or_sig): Likewise.
	(follow_die_offset): Likewise.
	(follow_die_ref): Likewise.
	(dwarf2_fetch_die_loc_sect_off): Likewise.
	(dwarf2_fetch_constant_bytes): Likewise.
	(dwarf2_fetch_die_type_sect_off): Likewise.
	(dwarf2_get_die_type): Likewise.
	(follow_die_sig): Likewise.
	(decode_locdesc): Likewise.
	(dwarf2_per_cu_objfile): Likewise.
	(dwarf2_per_cu_text_offset): Likewise.
	(init_one_comp_unit): Assign dwarf2_per_objfile instead of
	objfile.
	(set_die_type): Access objfile through
	dwarf2_per_objfile.
---
 gdb/dwarf2read.c | 231 +++++++++++++++++++++++++++++--------------------------
 1 file changed, 121 insertions(+), 110 deletions(-)

diff --git a/gdb/dwarf2read.c b/gdb/dwarf2read.c
index 2aeb506fc1..804febd723 100644
--- a/gdb/dwarf2read.c
+++ b/gdb/dwarf2read.c
@@ -639,8 +639,8 @@ DEF_VEC_O (delayed_method_info);
 /* Internal state when decoding a particular compilation unit.  */
 struct dwarf2_cu
 {
-  /* The objfile containing this compilation unit.  */
-  struct objfile *objfile;
+  /* The dwarf2_per_objfile containing this compilation unit.  */
+  struct dwarf2_per_objfile *dwarf2_per_objfile;
 
   /* The header of the compilation unit.  */
   struct comp_unit_head header;
@@ -835,10 +835,8 @@ struct dwarf2_per_cu_data
      dummy CUs (a CU header, but nothing else).  */
   struct dwarf2_cu *cu;
 
-  /* The corresponding objfile.
-     Normally we can get the objfile from dwarf2_per_objfile.
-     However we can enter this file with just a "per_cu" handle.  */
-  struct objfile *objfile;
+  /* The corresponding dwarf2_per_objfile.  */
+  struct dwarf2_per_objfile *dwarf2_per_objfile;
 
   /* When dwarf2_per_objfile->using_index is true, the 'quick' field
      is active.  Otherwise, the 'psymtab' field is active.  */
@@ -3183,7 +3181,7 @@ create_cu_from_index_list (struct objfile *objfile,
                      struct dwarf2_per_cu_data);
   the_cu->sect_off = sect_off;
   the_cu->length = length;
-  the_cu->objfile = objfile;
+  the_cu->dwarf2_per_objfile = dwarf2_per_objfile;
   the_cu->section = section;
   the_cu->v.quick = OBSTACK_ZALLOC (&objfile->objfile_obstack,
                                    struct dwarf2_per_cu_quick_data);
@@ -3285,7 +3283,7 @@ create_signatured_type_table_from_index (struct objfile *objfile,
       sig_type->per_cu.is_debug_types = 1;
       sig_type->per_cu.section = section;
       sig_type->per_cu.sect_off = sect_off;
-      sig_type->per_cu.objfile = objfile;
+      sig_type->per_cu.dwarf2_per_objfile = dwarf2_per_objfile;
       sig_type->per_cu.v.quick
 	= OBSTACK_ZALLOC (&objfile->objfile_obstack,
 			  struct dwarf2_per_cu_quick_data);
@@ -3344,7 +3342,7 @@ create_signatured_type_table_from_debug_names
       sig_type->per_cu.is_debug_types = 1;
       sig_type->per_cu.section = section;
       sig_type->per_cu.sect_off = sect_off;
-      sig_type->per_cu.objfile = objfile;
+      sig_type->per_cu.dwarf2_per_objfile = dwarf2_per_objfile;
       sig_type->per_cu.v.quick
 	= OBSTACK_ZALLOC (&objfile->objfile_obstack,
 			  struct dwarf2_per_cu_quick_data);
@@ -6974,7 +6972,7 @@ create_debug_type_hash_table (struct dwo_file *dwo_file,
 				     struct signatured_type);
 	  sig_type->signature = header.signature;
 	  sig_type->type_offset_in_tu = header.type_cu_offset_in_tu;
-	  sig_type->per_cu.objfile = objfile;
+	  sig_type->per_cu.dwarf2_per_objfile = dwarf2_per_objfile;
 	  sig_type->per_cu.is_debug_types = 1;
 	  sig_type->per_cu.section = section;
 	  sig_type->per_cu.sect_off = sect_off;
@@ -7159,7 +7157,7 @@ fill_in_sig_entry_from_dwo_entry (struct objfile *objfile,
   sig_entry->per_cu.sect_off = dwo_entry->sect_off;
   sig_entry->per_cu.length = dwo_entry->length;
   sig_entry->per_cu.reading_dwo_directly = 1;
-  sig_entry->per_cu.objfile = objfile;
+  sig_entry->per_cu.dwarf2_per_objfile = dwarf2_per_objfile;
   sig_entry->type_offset_in_tu = dwo_entry->type_offset_in_tu;
   sig_entry->dwo_unit = dwo_entry;
 }
@@ -7585,7 +7583,7 @@ lookup_dwo_unit (struct dwarf2_per_cu_data *this_cu,
       if (! attr)
 	error (_("Dwarf Error: missing dwo_id for dwo_name %s"
 		 " [in module %s]"),
-	       dwo_name, objfile_name (this_cu->objfile));
+	       dwo_name, objfile_name (this_cu->dwarf2_per_objfile->objfile));
       signature = DW_UNSND (attr);
       dwo_unit = lookup_dwo_comp_unit (this_cu, dwo_name, comp_dir,
 				       signature);
@@ -8082,7 +8080,7 @@ create_type_unit_group (struct dwarf2_cu *cu, sect_offset line_offset_struct)
   tu_group = OBSTACK_ZALLOC (&objfile->objfile_obstack,
 			     struct type_unit_group);
   per_cu = &tu_group->per_cu;
-  per_cu->objfile = objfile;
+  per_cu->dwarf2_per_objfile = cu->dwarf2_per_objfile;
 
   if (dwarf2_per_objfile->using_index)
     {
@@ -8182,7 +8180,7 @@ get_type_unit_group (struct dwarf2_cu *cu, const struct attribute *stmt_list)
 static struct partial_symtab *
 create_partial_symtab (struct dwarf2_per_cu_data *per_cu, const char *name)
 {
-  struct objfile *objfile = per_cu->objfile;
+  struct objfile *objfile = per_cu->dwarf2_per_objfile->objfile;
   struct partial_symtab *pst;
 
   pst = start_psymtab_common (objfile, name, 0,
@@ -8224,7 +8222,7 @@ process_psymtab_comp_unit_reader (const struct die_reader_specs *reader,
 				  void *data)
 {
   struct dwarf2_cu *cu = reader->cu;
-  struct objfile *objfile = cu->objfile;
+  struct objfile *objfile = cu->dwarf2_per_objfile->objfile;
   struct gdbarch *gdbarch = get_objfile_arch (objfile);
   struct dwarf2_per_cu_data *per_cu = cu->per_cu;
   CORE_ADDR baseaddr;
@@ -8864,7 +8862,7 @@ read_comp_units_from_section (struct objfile *objfile,
       this_cu->sect_off = sect_off;
       this_cu->length = cu_header.length + cu_header.initial_length_size;
       this_cu->is_dwz = is_dwz;
-      this_cu->objfile = objfile;
+      this_cu->dwarf2_per_objfile = dwarf2_per_objfile;
       this_cu->section = section;
 
       if (*n_comp_units == *n_allocated)
@@ -8995,12 +8993,12 @@ scan_partial_symbols (struct partial_die_info *first_die, CORE_ADDR *lowpc,
 		  {
 		    error (_("Dwarf Error: DW_TAG_imported_unit is not"
 			     " supported in type units [in module %s]"),
-			   objfile_name (cu->objfile));
+			   objfile_name (cu->dwarf2_per_objfile->objfile));
 		  }
 
-		per_cu = dwarf2_find_containing_comp_unit (pdi->d.sect_off,
-							   pdi->is_dwz,
-							   cu->objfile);
+		per_cu = dwarf2_find_containing_comp_unit
+			   (pdi->d.sect_off, pdi->is_dwz,
+			    cu->dwarf2_per_objfile->objfile);
 
 		/* Go read the partial unit, if needed.  */
 		if (per_cu->v.psymtab == NULL)
@@ -9162,7 +9160,7 @@ partial_die_full_name (struct partial_die_info *pdi,
 static void
 add_partial_symbol (struct partial_die_info *pdi, struct dwarf2_cu *cu)
 {
-  struct objfile *objfile = cu->objfile;
+  struct objfile *objfile = cu->dwarf2_per_objfile->objfile;
   struct gdbarch *gdbarch = get_objfile_arch (objfile);
   CORE_ADDR addr = 0;
   const char *actual_name = NULL;
@@ -9404,7 +9402,7 @@ add_partial_subprogram (struct partial_die_info *pdi,
             *highpc = pdi->highpc;
 	  if (set_addrmap)
 	    {
-	      struct objfile *objfile = cu->objfile;
+	      struct objfile *objfile = cu->dwarf2_per_objfile->objfile;
 	      struct gdbarch *gdbarch = get_objfile_arch (objfile);
 	      CORE_ADDR baseaddr;
 	      CORE_ADDR highpc;
@@ -9490,7 +9488,7 @@ static struct abbrev_info *
 peek_die_abbrev (const gdb_byte *info_ptr, unsigned int *bytes_read,
 		 struct dwarf2_cu *cu)
 {
-  bfd *abfd = cu->objfile->obfd;
+  bfd *abfd = cu->dwarf2_per_objfile->objfile->obfd;
   unsigned int abbrev_number;
   struct abbrev_info *abbrev;
 
@@ -10163,13 +10161,14 @@ fixup_go_packaging (struct dwarf2_cu *cu)
 		package_name = this_package_name;
 	      else
 		{
+		  struct objfile *objfile = cu->dwarf2_per_objfile->objfile;
 		  if (strcmp (package_name, this_package_name) != 0)
 		    complaint (&symfile_complaints,
 			       _("Symtab %s has objects from two different Go packages: %s and %s"),
 			       (symbol_symtab (sym) != NULL
 				? symtab_to_filename_for_display
 				    (symbol_symtab (sym))
-				: objfile_name (cu->objfile)),
+				: objfile_name (objfile)),
 			       this_package_name, package_name);
 		  xfree (this_package_name);
 		}
@@ -10179,7 +10178,7 @@ fixup_go_packaging (struct dwarf2_cu *cu)
 
   if (package_name != NULL)
     {
-      struct objfile *objfile = cu->objfile;
+      struct objfile *objfile = cu->dwarf2_per_objfile->objfile;
       const char *saved_package_name
 	= (const char *) obstack_copy0 (&objfile->per_bfd->storage_obstack,
 					package_name,
@@ -10356,7 +10355,7 @@ process_full_comp_unit (struct dwarf2_per_cu_data *per_cu,
 			enum language pretend_language)
 {
   struct dwarf2_cu *cu = per_cu->cu;
-  struct objfile *objfile = per_cu->objfile;
+  struct objfile *objfile = per_cu->dwarf2_per_objfile->objfile;
   struct gdbarch *gdbarch = get_objfile_arch (objfile);
   CORE_ADDR lowpc, highpc;
   struct compunit_symtab *cust;
@@ -10460,7 +10459,7 @@ process_full_type_unit (struct dwarf2_per_cu_data *per_cu,
 			enum language pretend_language)
 {
   struct dwarf2_cu *cu = per_cu->cu;
-  struct objfile *objfile = per_cu->objfile;
+  struct objfile *objfile = per_cu->dwarf2_per_objfile->objfile;
   struct compunit_symtab *cust;
   struct cleanup *delayed_list_cleanup;
   struct signatured_type *sig_type;
@@ -10538,7 +10537,7 @@ process_imported_unit_die (struct die_info *die, struct dwarf2_cu *cu)
     {
       error (_("Dwarf Error: DW_TAG_imported_unit is not"
 	       " supported in type units [in module %s]"),
-	     objfile_name (cu->objfile));
+	     objfile_name (cu->dwarf2_per_objfile->objfile));
     }
 
   attr = dwarf2_attr (die, DW_AT_import, cu);
@@ -10547,7 +10546,8 @@ process_imported_unit_die (struct die_info *die, struct dwarf2_cu *cu)
       sect_offset sect_off = dwarf2_get_ref_die_offset (attr);
       bool is_dwz = (attr->form == DW_FORM_GNU_ref_alt || cu->per_cu->is_dwz);
       dwarf2_per_cu_data *per_cu
-	= dwarf2_find_containing_comp_unit (sect_off, is_dwz, cu->objfile);
+	= dwarf2_find_containing_comp_unit (sect_off, is_dwz,
+					    cu->dwarf2_per_objfile->objfile);
 
       /* If necessary, add it to the queue and load its DIEs.  */
       if (maybe_queue_comp_unit (cu, per_cu, cu->language))
@@ -10804,7 +10804,7 @@ dwarf2_compute_name (const char *name,
 		     struct die_info *die, struct dwarf2_cu *cu,
 		     int physname)
 {
-  struct objfile *objfile = cu->objfile;
+  struct objfile *objfile = cu->dwarf2_per_objfile->objfile;
 
   if (name == NULL)
     name = dwarf2_name (die, cu);
@@ -11053,7 +11053,7 @@ dwarf2_full_name (const char *name, struct die_info *die, struct dwarf2_cu *cu)
 static const char *
 dwarf2_physname (const char *name, struct die_info *die, struct dwarf2_cu *cu)
 {
-  struct objfile *objfile = cu->objfile;
+  struct objfile *objfile = cu->dwarf2_per_objfile->objfile;
   const char *retval, *mangled = NULL, *canon = NULL;
   int need_copy = 1;
 
@@ -11227,7 +11227,7 @@ using_directives (enum language language)
 static void
 read_import_statement (struct die_info *die, struct dwarf2_cu *cu)
 {
-  struct objfile *objfile = cu->objfile;
+  struct objfile *objfile = cu->dwarf2_per_objfile->objfile;
   struct attribute *import_attr;
   struct die_info *imported_die, *child_die;
   struct dwarf2_cu *imported_cu;
@@ -11936,7 +11936,7 @@ create_cus_hash_table (struct dwo_file &dwo_file, dwarf2_section_info &section,
       memset (&create_dwo_cu_data.dwo_unit, 0,
 	      sizeof (create_dwo_cu_data.dwo_unit));
       memset (&per_cu, 0, sizeof (per_cu));
-      per_cu.objfile = objfile;
+      per_cu.dwarf2_per_objfile = dwarf2_per_objfile;
       per_cu.is_debug_types = 0;
       per_cu.sect_off = sect_offset (info_ptr - section.buffer);
       per_cu.section = §ion;
@@ -13641,7 +13641,7 @@ inherit_abstract_dies (struct die_info *die, struct dwarf2_cu *cu)
 static void
 read_func_scope (struct die_info *die, struct dwarf2_cu *cu)
 {
-  struct objfile *objfile = cu->objfile;
+  struct objfile *objfile = cu->dwarf2_per_objfile->objfile;
   struct gdbarch *gdbarch = get_objfile_arch (objfile);
   struct context_stack *newobj;
   CORE_ADDR lowpc;
@@ -13832,7 +13832,7 @@ read_func_scope (struct die_info *die, struct dwarf2_cu *cu)
 static void
 read_lexical_block_scope (struct die_info *die, struct dwarf2_cu *cu)
 {
-  struct objfile *objfile = cu->objfile;
+  struct objfile *objfile = cu->dwarf2_per_objfile->objfile;
   struct gdbarch *gdbarch = get_objfile_arch (objfile);
   struct context_stack *newobj;
   CORE_ADDR lowpc, highpc;
@@ -13903,7 +13903,7 @@ read_lexical_block_scope (struct die_info *die, struct dwarf2_cu *cu)
 static void
 read_call_site_scope (struct die_info *die, struct dwarf2_cu *cu)
 {
-  struct objfile *objfile = cu->objfile;
+  struct objfile *objfile = cu->dwarf2_per_objfile->objfile;
   struct gdbarch *gdbarch = get_objfile_arch (objfile);
   CORE_ADDR pc, baseaddr;
   struct attribute *attr;
@@ -14057,7 +14057,7 @@ read_call_site_scope (struct die_info *die, struct dwarf2_cu *cu)
       struct die_info *target_die;
 
       target_die = follow_die_ref (die, attr, &target_cu);
-      gdb_assert (target_cu->objfile == objfile);
+      gdb_assert (target_cu->dwarf2_per_objfile->objfile == objfile);
       if (die_is_declaration (target_die, target_cu))
 	{
 	  const char *target_physname;
@@ -14259,7 +14259,7 @@ read_variable (struct die_info *die, struct dwarf2_cu *cu)
 
       if (containing_type != NULL)
 	{
-	  struct objfile *objfile = cu->objfile;
+	  struct objfile *objfile = cu->dwarf2_per_objfile->objfile;
 
 	  storage = OBSTACK_ZALLOC (&objfile->objfile_obstack,
 				    struct rust_vtable_symbol);
@@ -14284,7 +14284,7 @@ static bool
 dwarf2_rnglists_process (unsigned offset, struct dwarf2_cu *cu,
 			 Callback &&callback)
 {
-  struct objfile *objfile = cu->objfile;
+  struct objfile *objfile = cu->dwarf2_per_objfile->objfile;
   bfd *obfd = objfile->obfd;
   /* Base address selection entry.  */
   CORE_ADDR base;
@@ -14450,7 +14450,7 @@ static int
 dwarf2_ranges_process (unsigned offset, struct dwarf2_cu *cu,
 		       Callback &&callback)
 {
-  struct objfile *objfile = cu->objfile;
+  struct objfile *objfile = cu->dwarf2_per_objfile->objfile;
   struct comp_unit_head *cu_header = &cu->header;
   bfd *obfd = objfile->obfd;
   unsigned int addr_size = cu_header->addr_size;
@@ -14557,7 +14557,7 @@ dwarf2_ranges_read (unsigned offset, CORE_ADDR *low_return,
 		    CORE_ADDR *high_return, struct dwarf2_cu *cu,
 		    struct partial_symtab *ranges_pst)
 {
-  struct objfile *objfile = cu->objfile;
+  struct objfile *objfile = cu->dwarf2_per_objfile->objfile;
   struct gdbarch *gdbarch = get_objfile_arch (objfile);
   const CORE_ADDR baseaddr = ANOFFSET (objfile->section_offsets,
 				       SECT_OFF_TEXT (objfile));
@@ -14798,7 +14798,7 @@ static void
 dwarf2_record_block_ranges (struct die_info *die, struct block *block,
                             CORE_ADDR baseaddr, struct dwarf2_cu *cu)
 {
-  struct objfile *objfile = cu->objfile;
+  struct objfile *objfile = cu->dwarf2_per_objfile->objfile;
   struct gdbarch *gdbarch = get_objfile_arch (objfile);
   struct attribute *attr;
   struct attribute *attr_high;
@@ -14982,7 +14982,7 @@ static void
 dwarf2_add_field (struct field_info *fip, struct die_info *die,
 		  struct dwarf2_cu *cu)
 {
-  struct objfile *objfile = cu->objfile;
+  struct objfile *objfile = cu->dwarf2_per_objfile->objfile;
   struct gdbarch *gdbarch = get_objfile_arch (objfile);
   struct nextfield *new_field;
   struct attribute *attr;
@@ -15381,7 +15381,7 @@ static void
 dwarf2_add_member_fn (struct field_info *fip, struct die_info *die,
 		      struct type *type, struct dwarf2_cu *cu)
 {
-  struct objfile *objfile = cu->objfile;
+  struct objfile *objfile = cu->dwarf2_per_objfile->objfile;
   struct attribute *attr;
   struct fnfieldlist *flp;
   int i;
@@ -15693,7 +15693,7 @@ quirk_gcc_member_function_pointer (struct type *type, struct objfile *objfile)
 static struct type *
 read_structure_type (struct die_info *die, struct dwarf2_cu *cu)
 {
-  struct objfile *objfile = cu->objfile;
+  struct objfile *objfile = cu->dwarf2_per_objfile->objfile;
   struct type *type;
   struct attribute *attr;
   const char *name;
@@ -15816,7 +15816,7 @@ read_structure_type (struct die_info *die, struct dwarf2_cu *cu)
 static void
 process_structure_scope (struct die_info *die, struct dwarf2_cu *cu)
 {
-  struct objfile *objfile = cu->objfile;
+  struct objfile *objfile = cu->dwarf2_per_objfile->objfile;
   struct die_info *child_die;
   struct type *type;
 
@@ -16116,7 +16116,7 @@ update_enumeration_type_from_children (struct die_info *die,
 static struct type *
 read_enumeration_type (struct die_info *die, struct dwarf2_cu *cu)
 {
-  struct objfile *objfile = cu->objfile;
+  struct objfile *objfile = cu->dwarf2_per_objfile->objfile;
   struct type *type;
   struct attribute *attr;
   const char *name;
@@ -16288,7 +16288,7 @@ process_enumeration_scope (struct die_info *die, struct dwarf2_cu *cu)
 static struct type *
 read_array_type (struct die_info *die, struct dwarf2_cu *cu)
 {
-  struct objfile *objfile = cu->objfile;
+  struct objfile *objfile = cu->dwarf2_per_objfile->objfile;
   struct die_info *child_die;
   struct type *type;
   struct type *element_type, *range_type, *index_type;
@@ -16561,7 +16561,7 @@ read_common_block (struct die_info *die, struct dwarf2_cu *cu)
 
   if (die->child != NULL)
     {
-      struct objfile *objfile = cu->objfile;
+      struct objfile *objfile = cu->dwarf2_per_objfile->objfile;
       struct die_info *child_die;
       size_t n_entries = 0, size;
       struct common_block *common_block;
@@ -16606,7 +16606,7 @@ read_common_block (struct die_info *die, struct dwarf2_cu *cu)
 			       "DW_AT_data_member_location "
 			       "- DIE at 0x%x [in module %s]"),
 			     to_underlying (child_die->sect_off),
-			     objfile_name (cu->objfile));
+			     objfile_name (cu->dwarf2_per_objfile->objfile));
 
 		  if (attr_form_is_section_offset (member_loc))
 		    dwarf2_complex_location_expr_complaint ();
@@ -16633,7 +16633,7 @@ read_common_block (struct die_info *die, struct dwarf2_cu *cu)
 static struct type *
 read_namespace_type (struct die_info *die, struct dwarf2_cu *cu)
 {
-  struct objfile *objfile = cu->objfile;
+  struct objfile *objfile = cu->dwarf2_per_objfile->objfile;
   const char *previous_prefix, *name;
   int is_anonymous;
   struct type *type;
@@ -16673,7 +16673,7 @@ read_namespace_type (struct die_info *die, struct dwarf2_cu *cu)
 static void
 read_namespace (struct die_info *die, struct dwarf2_cu *cu)
 {
-  struct objfile *objfile = cu->objfile;
+  struct objfile *objfile = cu->dwarf2_per_objfile->objfile;
   int is_anonymous;
 
   /* Add a symbol associated to this if we haven't seen the namespace
@@ -16718,7 +16718,7 @@ read_namespace (struct die_info *die, struct dwarf2_cu *cu)
 static struct type *
 read_module_type (struct die_info *die, struct dwarf2_cu *cu)
 {
-  struct objfile *objfile = cu->objfile;
+  struct objfile *objfile = cu->dwarf2_per_objfile->objfile;
   const char *module_name;
   struct type *type;
 
@@ -16792,7 +16792,7 @@ namespace_name (struct die_info *die, int *is_anonymous, struct dwarf2_cu *cu)
 static struct type *
 read_tag_pointer_type (struct die_info *die, struct dwarf2_cu *cu)
 {
-  struct gdbarch *gdbarch = get_objfile_arch (cu->objfile);
+  struct gdbarch *gdbarch = get_objfile_arch (cu->dwarf2_per_objfile->objfile);
   struct comp_unit_head *cu_header = &cu->header;
   struct type *type;
   struct attribute *attr_byte_size;
@@ -16873,7 +16873,7 @@ read_tag_ptr_to_member_type (struct die_info *die, struct dwarf2_cu *cu)
     type = lookup_methodptr_type (to_type);
   else if (TYPE_CODE (check_typedef (to_type)) == TYPE_CODE_FUNC)
     {
-      struct type *new_type = alloc_type (cu->objfile);
+      struct type *new_type = alloc_type (cu->dwarf2_per_objfile->objfile);
 
       smash_to_method_type (new_type, domain, TYPE_TARGET_TYPE (to_type),
 			    TYPE_FIELDS (to_type), TYPE_NFIELDS (to_type),
@@ -17036,7 +17036,7 @@ read_tag_atomic_type (struct die_info *die, struct dwarf2_cu *cu)
 static struct type *
 read_tag_string_type (struct die_info *die, struct dwarf2_cu *cu)
 {
-  struct objfile *objfile = cu->objfile;
+  struct objfile *objfile = cu->dwarf2_per_objfile->objfile;
   struct gdbarch *gdbarch = get_objfile_arch (objfile);
   struct type *type, *range_type, *index_type, *char_type;
   struct attribute *attr;
@@ -17114,7 +17114,7 @@ prototyped_function_p (struct die_info *die, struct dwarf2_cu *cu)
 static struct type *
 read_subroutine_type (struct die_info *die, struct dwarf2_cu *cu)
 {
-  struct objfile *objfile = cu->objfile;
+  struct objfile *objfile = cu->dwarf2_per_objfile->objfile;
   struct type *type;		/* Type that this function returns.  */
   struct type *ftype;		/* Function that returns above type.  */
   struct attribute *attr;
@@ -17251,7 +17251,7 @@ read_subroutine_type (struct die_info *die, struct dwarf2_cu *cu)
 static struct type *
 read_typedef (struct die_info *die, struct dwarf2_cu *cu)
 {
-  struct objfile *objfile = cu->objfile;
+  struct objfile *objfile = cu->dwarf2_per_objfile->objfile;
   const char *name = NULL;
   struct type *this_type, *target_type;
 
@@ -17302,7 +17302,7 @@ dwarf2_init_float_type (struct objfile *objfile, int bits, const char *name,
 static struct type *
 read_base_type (struct die_info *die, struct dwarf2_cu *cu)
 {
-  struct objfile *objfile = cu->objfile;
+  struct objfile *objfile = cu->dwarf2_per_objfile->objfile;
   struct type *type;
   struct attribute *attr;
   int encoding = 0, bits = 0;
@@ -17414,7 +17414,7 @@ attr_to_dynamic_prop (const struct attribute *attr, struct die_info *die,
 		      struct dwarf2_cu *cu, struct dynamic_prop *prop)
 {
   struct dwarf2_property_baton *baton;
-  struct obstack *obstack = &cu->objfile->objfile_obstack;
+  struct obstack *obstack = &cu->dwarf2_per_objfile->objfile->objfile_obstack;
 
   if (attr == NULL || prop == NULL)
     return 0;
@@ -17575,7 +17575,8 @@ read_subrange_type (struct die_info *die, struct dwarf2_cu *cu)
   else if (!low_default_is_valid)
     complaint (&symfile_complaints, _("Missing DW_AT_lower_bound "
 				      "- DIE at 0x%x [in module %s]"),
-	       to_underlying (die->sect_off), objfile_name (cu->objfile));
+	       to_underlying (die->sect_off),
+	       objfile_name (cu->dwarf2_per_objfile->objfile));
 
   attr = dwarf2_attr (die, DW_AT_upper_bound, cu);
   if (!attr_to_dynamic_prop (attr, die, cu, &high))
@@ -17605,7 +17606,7 @@ read_subrange_type (struct die_info *die, struct dwarf2_cu *cu)
      high bound or count are not yet handled by this code.  */
   if (TYPE_CODE (base_type) == TYPE_CODE_VOID)
     {
-      struct objfile *objfile = cu->objfile;
+      struct objfile *objfile = cu->dwarf2_per_objfile->objfile;
       struct gdbarch *gdbarch = get_objfile_arch (objfile);
       int addr_size = gdbarch_addr_bit (gdbarch) /8;
       struct type *int_type = objfile_type (objfile)->builtin_int;
@@ -17677,7 +17678,7 @@ read_unspecified_type (struct die_info *die, struct dwarf2_cu *cu)
 
   /* For now, we only support the C meaning of an unspecified type: void.  */
 
-  type = init_type (cu->objfile, TYPE_CODE_VOID, 0, NULL);
+  type = init_type (cu->dwarf2_per_objfile->objfile, TYPE_CODE_VOID, 0, NULL);
   TYPE_NAME (type) = dwarf2_name (die, cu);
 
   return set_die_type (die, type, cu);
@@ -18119,7 +18120,7 @@ load_partial_dies (const struct die_reader_specs *reader,
 		   const gdb_byte *info_ptr, int building_psymtab)
 {
   struct dwarf2_cu *cu = reader->cu;
-  struct objfile *objfile = cu->objfile;
+  struct objfile *objfile = cu->dwarf2_per_objfile->objfile;
   struct partial_die_info *part_die;
   struct partial_die_info *parent_die, *last_die, *first_die = NULL;
   struct abbrev_info *abbrev;
@@ -18396,7 +18397,7 @@ read_partial_die (const struct die_reader_specs *reader,
 		  const gdb_byte *info_ptr)
 {
   struct dwarf2_cu *cu = reader->cu;
-  struct objfile *objfile = cu->objfile;
+  struct objfile *objfile = cu->dwarf2_per_objfile->objfile;
   const gdb_byte *buffer = reader->buffer;
   unsigned int i;
   struct attribute attr;
@@ -18633,7 +18634,7 @@ find_partial_die_in_comp_unit (sect_offset sect_off, struct dwarf2_cu *cu)
 static struct partial_die_info *
 find_partial_die (sect_offset sect_off, int offset_in_dwz, struct dwarf2_cu *cu)
 {
-  struct objfile *objfile = cu->objfile;
+  struct objfile *objfile = cu->dwarf2_per_objfile->objfile;
   struct dwarf2_per_cu_data *per_cu = NULL;
   struct partial_die_info *pd = NULL;
 
@@ -18734,9 +18735,10 @@ guess_partial_die_structure_name (struct partial_die_info *struct_pdi,
 						 child_pdi->linkage_name);
 	  if (actual_class_name != NULL)
 	    {
+	      struct objfile *objfile = cu->dwarf2_per_objfile->objfile;
 	      struct_pdi->name
 		= ((const char *)
-		   obstack_copy0 (&cu->objfile->per_bfd->storage_obstack,
+		   obstack_copy0 (&objfile->per_bfd->storage_obstack,
 				  actual_class_name,
 				  strlen (actual_class_name)));
 	      xfree (actual_class_name);
@@ -18822,9 +18824,10 @@ fixup_partial_die (struct partial_die_info *part_die,
 	  else
 	    base = demangled;
 
+	  struct objfile *objfile = cu->dwarf2_per_objfile->objfile;
 	  part_die->name
 	    = ((const char *)
-	       obstack_copy0 (&cu->objfile->per_bfd->storage_obstack,
+	       obstack_copy0 (&objfile->per_bfd->storage_obstack,
 			      base, strlen (base)));
 	  xfree (demangled);
 	}
@@ -18841,7 +18844,7 @@ read_attribute_value (const struct die_reader_specs *reader,
 		      LONGEST implicit_const, const gdb_byte *info_ptr)
 {
   struct dwarf2_cu *cu = reader->cu;
-  struct objfile *objfile = cu->objfile;
+  struct objfile *objfile = cu->dwarf2_per_objfile->objfile;
   struct gdbarch *gdbarch = get_objfile_arch (objfile);
   bfd *abfd = reader->abfd;
   struct comp_unit_head *cu_header = &cu->header;
@@ -19537,7 +19540,7 @@ static CORE_ADDR
 read_addr_index_from_leb128 (struct dwarf2_cu *cu, const gdb_byte *info_ptr,
 			     unsigned int *bytes_read)
 {
-  bfd *abfd = cu->objfile->obfd;
+  bfd *abfd = cu->dwarf2_per_objfile->objfile->obfd;
   unsigned int addr_index = read_unsigned_leb128 (abfd, info_ptr, bytes_read);
 
   return read_addr_index (cu, addr_index);
@@ -19578,7 +19581,7 @@ CORE_ADDR
 dwarf2_read_addr_index (struct dwarf2_per_cu_data *per_cu,
 			unsigned int addr_index)
 {
-  struct objfile *objfile = per_cu->objfile;
+  struct objfile *objfile = per_cu->dwarf2_per_objfile->objfile;
   struct dwarf2_cu *cu = per_cu->cu;
   ULONGEST addr_base;
   int addr_size;
@@ -19811,7 +19814,7 @@ dwarf2_string_attr (struct die_info *die, unsigned int name, struct dwarf2_cu *c
 	           _("string type expected for attribute %s for "
 		     "DIE at 0x%x in module %s"),
 		   dwarf_attr_name (name), to_underlying (die->sect_off),
-		   objfile_name (cu->objfile));
+		   objfile_name (cu->dwarf2_per_objfile->objfile));
     }
 
   return str;
@@ -20697,7 +20700,7 @@ lnp_state_machine::check_line_address (struct dwarf2_cu *cu,
       /* This line table is for a function which has been
 	 GCd by the linker.  Ignore it.  PR gdb/12528 */
 
-      struct objfile *objfile = cu->objfile;
+      struct objfile *objfile = cu->dwarf2_per_objfile->objfile;
       long line_offset = line_ptr - get_debug_line_section (cu)->buffer;
 
       complaint (&symfile_complaints,
@@ -20723,7 +20726,7 @@ dwarf_decode_lines_1 (struct line_header *lh, struct dwarf2_cu *cu,
   unsigned int bytes_read, extended_len;
   unsigned char op_code, extended_op;
   CORE_ADDR baseaddr;
-  struct objfile *objfile = cu->objfile;
+  struct objfile *objfile = cu->dwarf2_per_objfile->objfile;
   bfd *abfd = objfile->obfd;
   struct gdbarch *gdbarch = get_objfile_arch (objfile);
   /* True if we're recording line info (as opposed to building partial
@@ -20954,7 +20957,7 @@ dwarf_decode_lines (struct line_header *lh, const char *comp_dir,
 		    struct dwarf2_cu *cu, struct partial_symtab *pst,
 		    CORE_ADDR lowpc, int decode_mapping)
 {
-  struct objfile *objfile = cu->objfile;
+  struct objfile *objfile = cu->dwarf2_per_objfile->objfile;
   const int decode_for_pst_p = (pst != NULL);
 
   if (decode_mapping)
@@ -21054,7 +21057,8 @@ dwarf2_start_symtab (struct dwarf2_cu *cu,
 		     const char *name, const char *comp_dir, CORE_ADDR low_pc)
 {
   struct compunit_symtab *cust
-    = start_symtab (cu->objfile, name, comp_dir, low_pc, cu->language);
+    = start_symtab (cu->dwarf2_per_objfile->objfile, name, comp_dir, low_pc,
+		    cu->language);
 
   record_debugformat ("DWARF 2");
   record_producer (cu->producer);
@@ -21071,7 +21075,7 @@ static void
 var_decode_location (struct attribute *attr, struct symbol *sym,
 		     struct dwarf2_cu *cu)
 {
-  struct objfile *objfile = cu->objfile;
+  struct objfile *objfile = cu->dwarf2_per_objfile->objfile;
   struct comp_unit_head *cu_header = &cu->header;
 
   /* NOTE drow/2003-01-30: There used to be a comment and some special
@@ -21144,7 +21148,7 @@ static struct symbol *
 new_symbol_full (struct die_info *die, struct type *type, struct dwarf2_cu *cu,
 		 struct symbol *space)
 {
-  struct objfile *objfile = cu->objfile;
+  struct objfile *objfile = cu->dwarf2_per_objfile->objfile;
   struct gdbarch *gdbarch = get_objfile_arch (objfile);
   struct symbol *sym = NULL;
   const char *name;
@@ -21542,7 +21546,7 @@ static gdb_byte *
 dwarf2_const_value_data (const struct attribute *attr, struct obstack *obstack,
 			 struct dwarf2_cu *cu, LONGEST *value, int bits)
 {
-  struct objfile *objfile = cu->objfile;
+  struct objfile *objfile = cu->dwarf2_per_objfile->objfile;
   enum bfd_endian byte_order = bfd_big_endian (objfile->obfd) ?
 				BFD_ENDIAN_BIG : BFD_ENDIAN_LITTLE;
   LONGEST l = DW_UNSND (attr);
@@ -21577,7 +21581,7 @@ dwarf2_const_value_attr (const struct attribute *attr, struct type *type,
 			 LONGEST *value, const gdb_byte **bytes,
 			 struct dwarf2_locexpr_baton **baton)
 {
-  struct objfile *objfile = cu->objfile;
+  struct objfile *objfile = cu->dwarf2_per_objfile->objfile;
   struct comp_unit_head *cu_header = &cu->header;
   struct dwarf_block *blk;
   enum bfd_endian byte_order = (bfd_big_endian (objfile->obfd) ?
@@ -21679,7 +21683,7 @@ static void
 dwarf2_const_value (const struct attribute *attr, struct symbol *sym,
 		    struct dwarf2_cu *cu)
 {
-  struct objfile *objfile = cu->objfile;
+  struct objfile *objfile = cu->dwarf2_per_objfile->objfile;
   LONGEST value;
   const gdb_byte *bytes;
   struct dwarf2_locexpr_baton *baton;
@@ -21717,7 +21721,7 @@ die_type (struct die_info *die, struct dwarf2_cu *cu)
   if (!type_attr)
     {
       /* A missing DW_AT_type represents a void type.  */
-      return objfile_type (cu->objfile)->builtin_void;
+      return objfile_type (cu->dwarf2_per_objfile->objfile)->builtin_void;
     }
 
   return lookup_die_type (die, type_attr, cu);
@@ -21784,7 +21788,7 @@ die_containing_type (struct die_info *die, struct dwarf2_cu *cu)
   type_attr = dwarf2_attr (die, DW_AT_containing_type, cu);
   if (!type_attr)
     error (_("Dwarf Error: Problem turning containing type into gdb type "
-	     "[in module %s]"), objfile_name (cu->objfile));
+	     "[in module %s]"), objfile_name (cu->dwarf2_per_objfile->objfile));
 
   return lookup_die_type (die, type_attr, cu);
 }
@@ -21817,7 +21821,7 @@ static struct type *
 lookup_die_type (struct die_info *die, const struct attribute *attr,
 		 struct dwarf2_cu *cu)
 {
-  struct objfile *objfile = cu->objfile;
+  struct objfile *objfile = cu->dwarf2_per_objfile->objfile;
   struct type *this_type;
 
   gdb_assert (attr->name == DW_AT_type
@@ -21831,7 +21835,7 @@ lookup_die_type (struct die_info *die, const struct attribute *attr,
       struct dwarf2_per_cu_data *per_cu;
       sect_offset sect_off = dwarf2_get_ref_die_offset (attr);
 
-      per_cu = dwarf2_find_containing_comp_unit (sect_off, 1, cu->objfile);
+      per_cu = dwarf2_find_containing_comp_unit (sect_off, 1, objfile);
       this_type = get_die_type_at_offset (sect_off, per_cu);
     }
   else if (attr_form_is_ref (attr))
@@ -22000,6 +22004,7 @@ guess_full_die_structure_name (struct die_info *die, struct dwarf2_cu *cu)
   struct die_info *spec_die;
   struct dwarf2_cu *spec_cu;
   struct die_info *child;
+  struct objfile *objfile = cu->dwarf2_per_objfile->objfile;
 
   spec_cu = cu;
   spec_die = die_specification (die, &spec_cu);
@@ -22041,7 +22046,7 @@ guess_full_die_structure_name (struct die_info *die, struct dwarf2_cu *cu)
 			  && actual_name[actual_name_len
 					 - die_name_len - 1] == ':')
 			name = (char *) obstack_copy0 (
-			  &cu->objfile->per_bfd->storage_obstack,
+			  &objfile->per_bfd->storage_obstack,
 			  actual_name, actual_name_len - die_name_len - 2);
 		    }
 		}
@@ -22083,7 +22088,8 @@ anonymous_struct_prefix (struct die_info *die, struct dwarf2_cu *cu)
   if (base == NULL || base == DW_STRING (attr) || base[-1] != ':')
     return "";
 
-  return (char *) obstack_copy0 (&cu->objfile->per_bfd->storage_obstack,
+  struct objfile *objfile = cu->dwarf2_per_objfile->objfile;
+  return (char *) obstack_copy0 (&objfile->per_bfd->storage_obstack,
 				 DW_STRING (attr),
 				 &base[-1] - DW_STRING (attr));
 }
@@ -22351,6 +22357,7 @@ static const char *
 dwarf2_name (struct die_info *die, struct dwarf2_cu *cu)
 {
   struct attribute *attr;
+  struct objfile *objfile = cu->dwarf2_per_objfile->objfile;
 
   attr = dwarf2_attr (die, DW_AT_name, cu);
   if ((!attr || !DW_STRING (attr))
@@ -22413,7 +22420,7 @@ dwarf2_name (struct die_info *die, struct dwarf2_cu *cu)
 	      /* FIXME: we already did this for the partial symbol... */
 	      DW_STRING (attr)
 		= ((const char *)
-		   obstack_copy0 (&cu->objfile->per_bfd->storage_obstack,
+		   obstack_copy0 (&objfile->per_bfd->storage_obstack,
 				  demangled, strlen (demangled)));
 	      DW_STRING_IS_CANONICAL (attr) = 1;
 	      xfree (demangled);
@@ -22437,7 +22444,7 @@ dwarf2_name (struct die_info *die, struct dwarf2_cu *cu)
     {
       DW_STRING (attr)
 	= dwarf2_canonicalize_name (DW_STRING (attr), cu,
-				    &cu->objfile->per_bfd->storage_obstack);
+				    &objfile->per_bfd->storage_obstack);
       DW_STRING_IS_CANONICAL (attr) = 1;
     }
   return DW_STRING (attr);
@@ -22771,7 +22778,7 @@ follow_die_ref_or_sig (struct die_info *src_die, const struct attribute *attr,
     {
       dump_die_for_error (src_die);
       error (_("Dwarf Error: Expected reference attribute [in module %s]"),
-	     objfile_name ((*ref_cu)->objfile));
+	     objfile_name ((*ref_cu)->dwarf2_per_objfile->objfile));
     }
 
   return die;
@@ -22788,6 +22795,7 @@ follow_die_offset (sect_offset sect_off, int offset_in_dwz,
 {
   struct die_info temp_die;
   struct dwarf2_cu *target_cu, *cu = *ref_cu;
+  struct objfile *objfile = cu->dwarf2_per_objfile->objfile;
 
   gdb_assert (cu->per_cu != NULL);
 
@@ -22807,7 +22815,7 @@ follow_die_offset (sect_offset sect_off, int offset_in_dwz,
       struct dwarf2_per_cu_data *per_cu;
 
       per_cu = dwarf2_find_containing_comp_unit (sect_off, offset_in_dwz,
-						 cu->objfile);
+						 objfile);
 
       /* If necessary, add it to the queue and load its DIEs.  */
       if (maybe_queue_comp_unit (cu, per_cu, cu->language))
@@ -22849,14 +22857,15 @@ follow_die_ref (struct die_info *src_die, const struct attribute *attr,
     error (_("Dwarf Error: Cannot find DIE at 0x%x referenced from DIE "
 	   "at 0x%x [in module %s]"),
 	   to_underlying (sect_off), to_underlying (src_die->sect_off),
-	   objfile_name (cu->objfile));
+	   objfile_name (cu->dwarf2_per_objfile->objfile));
 
   return die;
 }
 
 /* Return DWARF block referenced by DW_AT_location of DIE at SECT_OFF at PER_CU.
    Returned value is intended for DW_OP_call*.  Returned
-   dwarf2_locexpr_baton->data has lifetime of PER_CU->OBJFILE.  */
+   dwarf2_locexpr_baton->data has lifetime of
+   PER_CU->DWARF2_PER_OBJFILE->OBJFILE.  */
 
 struct dwarf2_locexpr_baton
 dwarf2_fetch_die_loc_sect_off (sect_offset sect_off,
@@ -22868,8 +22877,9 @@ dwarf2_fetch_die_loc_sect_off (sect_offset sect_off,
   struct die_info *die;
   struct attribute *attr;
   struct dwarf2_locexpr_baton retval;
+  struct objfile *objfile = per_cu->dwarf2_per_objfile->objfile;
 
-  dw2_setup (per_cu->objfile);
+  dw2_setup (objfile);
 
   if (per_cu->cu == NULL)
     load_cu (per_cu);
@@ -22879,13 +22889,13 @@ dwarf2_fetch_die_loc_sect_off (sect_offset sect_off,
       /* We shouldn't get here for a dummy CU, but don't crash on the user.
 	 Instead just throw an error, not much else we can do.  */
       error (_("Dwarf Error: Dummy CU at 0x%x referenced in module %s"),
-	     to_underlying (sect_off), objfile_name (per_cu->objfile));
+	     to_underlying (sect_off), objfile_name (objfile));
     }
 
   die = follow_die_offset (sect_off, per_cu->is_dwz, &cu);
   if (!die)
     error (_("Dwarf Error: Cannot find DIE at 0x%x referenced in module %s"),
-	   to_underlying (sect_off), objfile_name (per_cu->objfile));
+	   to_underlying (sect_off), objfile_name (objfile));
 
   attr = dwarf2_attr (die, DW_AT_location, cu);
   if (!attr)
@@ -22913,7 +22923,7 @@ dwarf2_fetch_die_loc_sect_off (sect_offset sect_off,
       if (!attr_form_is_block (attr))
 	error (_("Dwarf Error: DIE at 0x%x referenced in module %s "
 		 "is neither DW_FORM_block* nor DW_FORM_exprloc"),
-	       to_underlying (sect_off), objfile_name (per_cu->objfile));
+	       to_underlying (sect_off), objfile_name (objfile));
 
       retval.data = DW_BLOCK (attr)->data;
       retval.size = DW_BLOCK (attr)->size;
@@ -22976,8 +22986,9 @@ dwarf2_fetch_constant_bytes (sect_offset sect_off,
   struct type *type;
   LONGEST value;
   enum bfd_endian byte_order;
+  struct objfile *objfile = per_cu->dwarf2_per_objfile->objfile;
 
-  dw2_setup (per_cu->objfile);
+  dw2_setup (objfile);
 
   if (per_cu->cu == NULL)
     load_cu (per_cu);
@@ -22987,20 +22998,20 @@ dwarf2_fetch_constant_bytes (sect_offset sect_off,
       /* We shouldn't get here for a dummy CU, but don't crash on the user.
 	 Instead just throw an error, not much else we can do.  */
       error (_("Dwarf Error: Dummy CU at 0x%x referenced in module %s"),
-	     to_underlying (sect_off), objfile_name (per_cu->objfile));
+	     to_underlying (sect_off), objfile_name (objfile));
     }
 
   die = follow_die_offset (sect_off, per_cu->is_dwz, &cu);
   if (!die)
     error (_("Dwarf Error: Cannot find DIE at 0x%x referenced in module %s"),
-	   to_underlying (sect_off), objfile_name (per_cu->objfile));
+	   to_underlying (sect_off), objfile_name (objfile));
 
 
   attr = dwarf2_attr (die, DW_AT_const_value, cu);
   if (attr == NULL)
     return NULL;
 
-  byte_order = (bfd_big_endian (per_cu->objfile->obfd)
+  byte_order = (bfd_big_endian (objfile->obfd)
 		? BFD_ENDIAN_BIG : BFD_ENDIAN_LITTLE);
 
   switch (attr->form)
@@ -23102,7 +23113,7 @@ dwarf2_fetch_die_type_sect_off (sect_offset sect_off,
   struct dwarf2_cu *cu;
   struct die_info *die;
 
-  dw2_setup (per_cu->objfile);
+  dw2_setup (per_cu->dwarf2_per_objfile->objfile);
 
   if (per_cu->cu == NULL)
     load_cu (per_cu);
@@ -23124,7 +23135,7 @@ struct type *
 dwarf2_get_die_type (cu_offset die_offset,
 		     struct dwarf2_per_cu_data *per_cu)
 {
-  dw2_setup (per_cu->objfile);
+  dw2_setup (per_cu->dwarf2_per_objfile->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);
@@ -23201,7 +23212,7 @@ follow_die_sig (struct die_info *src_die, const struct attribute *attr,
       error (_("Dwarf Error: Cannot find signatured DIE %s referenced"
                " from DIE at 0x%x [in module %s]"),
              hex_string (signature), to_underlying (src_die->sect_off),
-	     objfile_name ((*ref_cu)->objfile));
+	     objfile_name ((*ref_cu)->dwarf2_per_objfile->objfile));
     }
 
   die = follow_die_sig_1 (src_die, sig_type, ref_cu);
@@ -23211,7 +23222,7 @@ follow_die_sig (struct die_info *src_die, const struct attribute *attr,
       error (_("Dwarf Error: Problem reading signatured DIE %s referenced"
 	       " from DIE at 0x%x [in module %s]"),
 	     hex_string (signature), to_underlying (src_die->sect_off),
-	     objfile_name ((*ref_cu)->objfile));
+	     objfile_name ((*ref_cu)->dwarf2_per_objfile->objfile));
     }
 
   return die;
@@ -23409,7 +23420,7 @@ read_signatured_type (struct signatured_type *sig_type)
 static CORE_ADDR
 decode_locdesc (struct dwarf_block *blk, struct dwarf2_cu *cu)
 {
-  struct objfile *objfile = cu->objfile;
+  struct objfile *objfile = cu->dwarf2_per_objfile->objfile;
   size_t i;
   size_t size = blk->size;
   const gdb_byte *data = blk->data;
@@ -24769,7 +24780,7 @@ dwarf2_symbol_mark_computed (const struct attribute *attr, struct symbol *sym,
 struct objfile *
 dwarf2_per_cu_objfile (struct dwarf2_per_cu_data *per_cu)
 {
-  struct objfile *objfile = per_cu->objfile;
+  struct objfile *objfile = per_cu->dwarf2_per_objfile->objfile;
 
   /* Return the master objfile, so that we can report and look up the
      correct file containing this variable.  */
@@ -24851,7 +24862,7 @@ dwarf2_per_cu_ref_addr_size (struct dwarf2_per_cu_data *per_cu)
 CORE_ADDR
 dwarf2_per_cu_text_offset (struct dwarf2_per_cu_data *per_cu)
 {
-  struct objfile *objfile = per_cu->objfile;
+  struct objfile *objfile = per_cu->dwarf2_per_objfile->objfile;
 
   return ANOFFSET (objfile->section_offsets, SECT_OFF_TEXT (objfile));
 }
@@ -24924,7 +24935,7 @@ init_one_comp_unit (struct dwarf2_cu *cu, struct dwarf2_per_cu_data *per_cu)
   memset (cu, 0, sizeof (*cu));
   per_cu->cu = cu;
   cu->per_cu = per_cu;
-  cu->objfile = per_cu->objfile;
+  cu->dwarf2_per_objfile = per_cu->dwarf2_per_objfile;
   obstack_init (&cu->comp_unit_obstack);
 }
 
@@ -25144,7 +25155,7 @@ static struct type *
 set_die_type (struct die_info *die, struct type *type, struct dwarf2_cu *cu)
 {
   struct dwarf2_per_cu_offset_and_type **slot, ofs;
-  struct objfile *objfile = cu->objfile;
+  struct objfile *objfile = cu->dwarf2_per_objfile->objfile;
   struct attribute *attr;
   struct dynamic_prop prop;
 
-- 
2.15.1



More information about the Gdb-patches mailing list