This is the mail archive of the gdb-patches@sourceware.org mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[RFC] dwarf2read.c die_info -> cu backpointer


For reference sake, here is a prototype of the change I was talking
about in irc today.  It's not without merit.  Having to keep die and cu
in sync from function call to function call has been the source of at least
one bug, and the simplicity of only passing die when that's all one
intuitively expects to pass (e.g. dwarf2_name (die) vs dwarf2_name (die, cu))
is nice.  I offer it for reference sake.  A next step might be to collect
some before/after data of cpu, memory usage.  Well, that and further testing.
It doesn't cause any regressions in the testsuite, but ....

2008-09-12  Doug Evans  <dje@google.com>

	* dwarf2read.c (die_info): New member `cu';
	(read_full_die): Initialize it.
	(process_die,dwarf2_full_name,read_file_scope,read_func_scope,
	read_lexical_block_scope,dwarf2_get_pc_bounds,get_scope_pc_bounds,
	dwarf2_record_block_ranges,dwarf2_add_field,dwarf2_add_member_fn,
	quirk_gcc_member_function_pointer,read_structure_type,
	process_structure_scope,read_enumeration_type,determine_class_name,
	process_enumeration_scope,read_array_type,read_array_order,
	read_set_type,read_common_block,read_namespace_type,read_namespace,
	namespace_name,read_tag_pointer_type,read_tag_ptr_to_member_type,
	read_tag_reference_type,read_tag_const_type,read_tag_volatile_type,
	read_tag_string_type,read_subroutine_type,read_typedef,read_base_type,
	read_subrange_type,read_unspecified_type,dwarf2_attr,
	dwarf2_flag_true_p,die_is_declaration,new_symbol,die_type,
	die_containing_type,tag_type_to_type,read_type_die,determine_prefix,
	dwarf2_linkage_name,dwarf2_name,store_in_ref_table,set_die_type,
	get_die_type): Remove `cu' parameter.  All callers updated.
	(die_specification): Remove `spec_cu' parameter.  All callers updated.
	(dwarf2_extension): Remove `ext_cu' parameter.  All callers updated.
	(follow_die_ref): Remove `ref_cu' parameter.  All callers updated.

Index: dwarf2read.c
===================================================================
RCS file: /cvs/src/src/gdb/dwarf2read.c,v
retrieving revision 1.280
diff -u -p -u -p -r1.280 dwarf2read.c
--- dwarf2read.c	12 Sep 2008 20:06:25 -0000	1.280
+++ dwarf2read.c	13 Sep 2008 05:34:55 -0000
@@ -541,6 +541,9 @@ struct die_info
     unsigned int offset;	/* Offset in .debug_info section */
     unsigned int num_attrs;	/* Number of attributes */
 
+    /* Backpointer to containing CU.  */
+    struct dwarf2_cu *cu;
+
     /* The dies in a compilation unit form an n-ary tree.  PARENT
        points to this die's parent; CHILD points to the first child of
        this node; and all the children of a given node are chained
@@ -835,16 +838,13 @@ static gdb_byte *skip_leb128 (bfd *, gdb
 
 static void set_cu_language (unsigned int, struct dwarf2_cu *);
 
-static struct attribute *dwarf2_attr (struct die_info *, unsigned int,
-				      struct dwarf2_cu *);
+static struct attribute *dwarf2_attr (struct die_info *, unsigned int);
 
-static int dwarf2_flag_true_p (struct die_info *die, unsigned name,
-                               struct dwarf2_cu *cu);
+static int dwarf2_flag_true_p (struct die_info *die, unsigned name);
 
-static int die_is_declaration (struct die_info *, struct dwarf2_cu *cu);
+static int die_is_declaration (struct die_info *);
 
-static struct die_info *die_specification (struct die_info *die,
-					   struct dwarf2_cu **);
+static struct die_info *die_specification (struct die_info *die);
 
 static void free_line_header (struct line_header *lh);
 
@@ -860,8 +860,7 @@ static void dwarf_decode_lines (struct l
 
 static void dwarf2_start_subfile (char *, char *, char *);
 
-static struct symbol *new_symbol (struct die_info *, struct type *,
-				  struct dwarf2_cu *);
+static struct symbol *new_symbol (struct die_info *, struct type *);
 
 static void dwarf2_const_value (struct attribute *, struct symbol *,
 				struct dwarf2_cu *);
@@ -870,72 +869,66 @@ static void dwarf2_const_value_data (str
 				     struct symbol *sym,
 				     int bits);
 
-static struct type *die_type (struct die_info *, struct dwarf2_cu *);
+static struct type *die_type (struct die_info *);
 
-static struct type *die_containing_type (struct die_info *,
-					 struct dwarf2_cu *);
+static struct type *die_containing_type (struct die_info *);
 
-static struct type *tag_type_to_type (struct die_info *, struct dwarf2_cu *);
+static struct type *tag_type_to_type (struct die_info *);
 
-static struct type *read_type_die (struct die_info *, struct dwarf2_cu *);
+static struct type *read_type_die (struct die_info *);
 
-static char *determine_prefix (struct die_info *die, struct dwarf2_cu *);
+static char *determine_prefix (struct die_info *die);
 
 static char *typename_concat (struct obstack *,
                               const char *prefix, 
                               const char *suffix,
 			      struct dwarf2_cu *);
 
-static void read_file_scope (struct die_info *, struct dwarf2_cu *);
+static void read_file_scope (struct die_info *);
 
-static void read_func_scope (struct die_info *, struct dwarf2_cu *);
+static void read_func_scope (struct die_info *);
 
-static void read_lexical_block_scope (struct die_info *, struct dwarf2_cu *);
+static void read_lexical_block_scope (struct die_info *);
 
 static int dwarf2_ranges_read (unsigned, CORE_ADDR *, CORE_ADDR *,
 			       struct dwarf2_cu *, struct partial_symtab *);
 
 static int dwarf2_get_pc_bounds (struct die_info *,
-				 CORE_ADDR *, CORE_ADDR *, struct dwarf2_cu *);
+				 CORE_ADDR *, CORE_ADDR *);
 
 static void get_scope_pc_bounds (struct die_info *,
-				 CORE_ADDR *, CORE_ADDR *,
-				 struct dwarf2_cu *);
+				 CORE_ADDR *, CORE_ADDR *);
 
 static void dwarf2_record_block_ranges (struct die_info *, struct block *,
-                                        CORE_ADDR, struct dwarf2_cu *);
+                                        CORE_ADDR);
 
-static void dwarf2_add_field (struct field_info *, struct die_info *,
-			      struct dwarf2_cu *);
+static void dwarf2_add_field (struct field_info *, struct die_info *);
 
 static void dwarf2_attach_fields_to_type (struct field_info *,
 					  struct type *, struct dwarf2_cu *);
 
 static void dwarf2_add_member_fn (struct field_info *,
-				  struct die_info *, struct type *,
-				  struct dwarf2_cu *);
+				  struct die_info *, struct type *);
 
 static void dwarf2_attach_fn_fields_to_type (struct field_info *,
 					     struct type *, struct dwarf2_cu *);
 
-static void process_structure_scope (struct die_info *, struct dwarf2_cu *);
+static void process_structure_scope (struct die_info *);
 
-static const char *determine_class_name (struct die_info *die,
-					 struct dwarf2_cu *cu);
+static const char *determine_class_name (struct die_info *die);
 
-static void read_common_block (struct die_info *, struct dwarf2_cu *);
+static void read_common_block (struct die_info *);
 
-static void read_namespace (struct die_info *die, struct dwarf2_cu *);
+static void read_namespace (struct die_info *die);
 
 static const char *namespace_name (struct die_info *die,
-				   int *is_anonymous, struct dwarf2_cu *);
+				   int *is_anonymous);
 
-static void process_enumeration_scope (struct die_info *, struct dwarf2_cu *);
+static void process_enumeration_scope (struct die_info *);
 
 static CORE_ADDR decode_locdesc (struct dwarf_block *, struct dwarf2_cu *);
 
-static enum dwarf_array_dim_ordering read_array_order (struct die_info *, 
-						       struct dwarf2_cu *);
+static enum dwarf_array_dim_ordering read_array_order (struct die_info *);
 
 static struct die_info *read_comp_unit (gdb_byte *, bfd *, struct dwarf2_cu *);
 
@@ -949,14 +942,13 @@ static struct die_info *read_die_and_sib
 					       gdb_byte **new_info_ptr,
 					       struct die_info *parent);
 
-static void process_die (struct die_info *, struct dwarf2_cu *);
+static void process_die (struct die_info *);
 
-static char *dwarf2_linkage_name (struct die_info *, struct dwarf2_cu *);
+static char *dwarf2_linkage_name (struct die_info *);
 
-static char *dwarf2_name (struct die_info *die, struct dwarf2_cu *);
+static char *dwarf2_name (struct die_info *die);
 
-static struct die_info *dwarf2_extension (struct die_info *die,
-					  struct dwarf2_cu **);
+static struct die_info *dwarf2_extension (struct die_info *die);
 
 static char *dwarf_tag_name (unsigned int);
 
@@ -980,8 +972,7 @@ static void dump_die (struct die_info *)
 
 static void dump_die_list (struct die_info *);
 
-static void store_in_ref_table (struct die_info *,
-				struct dwarf2_cu *);
+static void store_in_ref_table (struct die_info *);
 
 static unsigned int dwarf2_get_ref_die_offset (struct attribute *,
 					       struct dwarf2_cu *);
@@ -989,8 +980,7 @@ static unsigned int dwarf2_get_ref_die_o
 static int dwarf2_get_attr_constant_value (struct attribute *, int);
 
 static struct die_info *follow_die_ref (struct die_info *,
-					struct attribute *,
-					struct dwarf2_cu **);
+					struct attribute *);
 
 /* memory allocation interface */
 
@@ -1041,8 +1031,7 @@ static void age_cached_comp_units (void)
 
 static void free_one_cached_comp_unit (void *);
 
-static struct type *set_die_type (struct die_info *, struct type *,
-				  struct dwarf2_cu *);
+static struct type *set_die_type (struct die_info *, struct type *);
 
 static void create_all_comp_units (struct objfile *);
 
@@ -1058,7 +1047,7 @@ static void dwarf2_mark (struct dwarf2_c
 
 static void dwarf2_clear_marks (struct dwarf2_per_cu_data *);
 
-static struct type *get_die_type (struct die_info *die, struct dwarf2_cu *cu);
+static struct type *get_die_type (struct die_info *die);
 
 /* Try to locate the sections we need for DWARF 2 debugging
    information and return true if we have enough to do something.  */
@@ -2593,7 +2582,7 @@ load_full_comp_unit (struct dwarf2_per_c
      all objfiles needed for references have been loaded yet, and symbol
      table processing isn't initialized.  But we have to set the CU language,
      or we won't be able to build types correctly.  */
-  attr = dwarf2_attr (cu->dies, DW_AT_language, cu);
+  attr = dwarf2_attr (cu->dies, DW_AT_language);
   if (attr)
     set_cu_language (DW_UNSND (attr), cu);
   else
@@ -2640,7 +2629,7 @@ process_full_comp_unit (struct dwarf2_pe
   cu->base_known = 0;
   cu->base_address = 0;
 
-  attr = dwarf2_attr (cu->dies, DW_AT_entry_pc, cu);
+  attr = dwarf2_attr (cu->dies, DW_AT_entry_pc);
   if (attr)
     {
       cu->base_address = DW_ADDR (attr);
@@ -2648,7 +2637,7 @@ process_full_comp_unit (struct dwarf2_pe
     }
   else
     {
-      attr = dwarf2_attr (cu->dies, DW_AT_low_pc, cu);
+      attr = dwarf2_attr (cu->dies, DW_AT_low_pc);
       if (attr)
 	{
 	  cu->base_address = DW_ADDR (attr);
@@ -2657,12 +2646,12 @@ process_full_comp_unit (struct dwarf2_pe
     }
 
   /* Do line number decoding in read_file_scope () */
-  process_die (cu->dies, cu);
+  process_die (cu->dies);
 
   /* Some compilers don't define a DW_AT_high_pc attribute for the
      compilation unit.  If the DW_AT_high_pc is missing, synthesize
      it, by scanning the DIE's below the compilation unit.  */
-  get_scope_pc_bounds (cu->dies, &lowpc, &highpc, cu);
+  get_scope_pc_bounds (cu->dies, &lowpc, &highpc);
 
   symtab = end_symtab (highpc + baseaddr, objfile, SECT_OFF_TEXT (objfile));
 
@@ -2683,17 +2672,17 @@ process_full_comp_unit (struct dwarf2_pe
 /* Process a die and its children.  */
 
 static void
-process_die (struct die_info *die, struct dwarf2_cu *cu)
+process_die (struct die_info *die)
 {
   switch (die->tag)
     {
     case DW_TAG_padding:
       break;
     case DW_TAG_compile_unit:
-      read_file_scope (die, cu);
+      read_file_scope (die);
       break;
     case DW_TAG_subprogram:
-      read_func_scope (die, cu);
+      read_func_scope (die);
       break;
     case DW_TAG_inlined_subroutine:
       /* FIXME:  These are ignored for now.
@@ -2703,16 +2692,16 @@ process_die (struct die_info *die, struc
     case DW_TAG_lexical_block:
     case DW_TAG_try_block:
     case DW_TAG_catch_block:
-      read_lexical_block_scope (die, cu);
+      read_lexical_block_scope (die);
       break;
     case DW_TAG_class_type:
     case DW_TAG_interface_type:
     case DW_TAG_structure_type:
     case DW_TAG_union_type:
-      process_structure_scope (die, cu);
+      process_structure_scope (die);
       break;
     case DW_TAG_enumeration_type:
-      process_enumeration_scope (die, cu);
+      process_enumeration_scope (die);
       break;
 
     /* These dies have a type, but processing them does not create
@@ -2731,16 +2720,16 @@ process_die (struct die_info *die, struc
     case DW_TAG_subrange_type:
       /* Add a typedef symbol for the type definition, if it has a
          DW_AT_name.  */
-      new_symbol (die, read_type_die (die, cu), cu);
+      new_symbol (die, read_type_die (die));
       break;
     case DW_TAG_common_block:
-      read_common_block (die, cu);
+      read_common_block (die);
       break;
     case DW_TAG_common_inclusion:
       break;
     case DW_TAG_namespace:
       processing_has_namespace_info = 1;
-      read_namespace (die, cu);
+      read_namespace (die);
       break;
     case DW_TAG_imported_declaration:
     case DW_TAG_imported_module:
@@ -2754,7 +2743,7 @@ process_die (struct die_info *die, struc
 		 dwarf_tag_name (die->tag));
       break;
     default:
-      new_symbol (die, NULL, cu);
+      new_symbol (die, NULL);
       break;
     }
 }
@@ -2765,13 +2754,14 @@ process_die (struct die_info *die, struc
    not have a name.  */
 
 static const char *
-dwarf2_full_name (struct die_info *die, struct dwarf2_cu *cu)
+dwarf2_full_name (struct die_info *die)
 {
+  struct dwarf2_cu *cu = die->cu;
   struct attribute *attr;
   char *prefix, *name;
   struct ui_file *buf = NULL;
 
-  name = dwarf2_name (die, cu);
+  name = dwarf2_name (die);
   if (!name)
     return NULL;
 
@@ -2789,7 +2779,7 @@ dwarf2_full_name (struct die_info *die, 
       && die->tag != DW_TAG_member)
     return name;
 
-  prefix = determine_prefix (die, cu);
+  prefix = determine_prefix (die);
   if (*prefix != '\0')
     name = typename_concat (&cu->objfile->objfile_obstack, prefix,
 			    name, cu);
@@ -2813,8 +2803,9 @@ free_cu_line_header (void *arg)
 }
 
 static void
-read_file_scope (struct die_info *die, struct dwarf2_cu *cu)
+read_file_scope (struct die_info *die)
 {
+  struct dwarf2_cu *cu = die->cu;
   struct objfile *objfile = cu->objfile;
   struct comp_unit_head *cu_header = &cu->header;
   struct cleanup *back_to = make_cleanup (null_cleanup, 0);
@@ -2830,7 +2821,7 @@ read_file_scope (struct die_info *die, s
   
   baseaddr = ANOFFSET (objfile->section_offsets, SECT_OFF_TEXT (objfile));
 
-  get_scope_pc_bounds (die, &lowpc, &highpc, cu);
+  get_scope_pc_bounds (die, &lowpc, &highpc);
 
   /* If we didn't find a lowpc, set it to highpc to avoid complaints
      from finish_block.  */
@@ -2841,13 +2832,13 @@ read_file_scope (struct die_info *die, s
 
   /* Find the filename.  Do not use dwarf2_name here, since the filename
      is not a source language identifier.  */
-  attr = dwarf2_attr (die, DW_AT_name, cu);
+  attr = dwarf2_attr (die, DW_AT_name);
   if (attr)
     {
       name = DW_STRING (attr);
     }
 
-  attr = dwarf2_attr (die, DW_AT_comp_dir, cu);
+  attr = dwarf2_attr (die, DW_AT_comp_dir);
   if (attr)
     comp_dir = DW_STRING (attr);
   else if (name != NULL && IS_ABSOLUTE_PATH (name))
@@ -2869,13 +2860,13 @@ read_file_scope (struct die_info *die, s
   if (name == NULL)
     name = "<unknown>";
 
-  attr = dwarf2_attr (die, DW_AT_language, cu);
+  attr = dwarf2_attr (die, DW_AT_language);
   if (attr)
     {
       set_cu_language (DW_UNSND (attr), cu);
     }
 
-  attr = dwarf2_attr (die, DW_AT_producer, cu);
+  attr = dwarf2_attr (die, DW_AT_producer);
   if (attr) 
     cu->producer = DW_STRING (attr);
 
@@ -2893,7 +2884,7 @@ read_file_scope (struct die_info *die, s
   /* Decode line number information if present.  We do this before
      processing child DIEs, so that the line header table is available
      for DW_AT_decl_file.  */
-  attr = dwarf2_attr (die, DW_AT_stmt_list, cu);
+  attr = dwarf2_attr (die, DW_AT_stmt_list);
   if (attr)
     {
       unsigned int line_offset = DW_UNSND (attr);
@@ -2912,7 +2903,7 @@ read_file_scope (struct die_info *die, s
       child_die = die->child;
       while (child_die && child_die->tag)
 	{
-	  process_die (child_die, cu);
+	  process_die (child_die);
 	  child_die = sibling_die (child_die);
 	}
     }
@@ -2921,7 +2912,7 @@ read_file_scope (struct die_info *die, s
      refers to information in the line number info statement program
      header, so we can only read it if we've read the header
      successfully.  */
-  attr = dwarf2_attr (die, DW_AT_macro_info, cu);
+  attr = dwarf2_attr (die, DW_AT_macro_info);
   if (attr && line_header)
     {
       unsigned int macro_offset = DW_UNSND (attr);
@@ -2954,8 +2945,9 @@ add_to_cu_func_list (const char *name, C
 }
 
 static void
-read_func_scope (struct die_info *die, struct dwarf2_cu *cu)
+read_func_scope (struct die_info *die)
 {
+  struct dwarf2_cu *cu = die->cu;
   struct objfile *objfile = cu->objfile;
   struct context_stack *new;
   CORE_ADDR lowpc;
@@ -2968,11 +2960,11 @@ read_func_scope (struct die_info *die, s
 
   baseaddr = ANOFFSET (objfile->section_offsets, SECT_OFF_TEXT (objfile));
 
-  name = dwarf2_linkage_name (die, cu);
+  name = dwarf2_linkage_name (die);
 
   /* Ignore functions with missing or empty names and functions with
      missing or invalid low and high pc attributes.  */
-  if (name == NULL || !dwarf2_get_pc_bounds (die, &lowpc, &highpc, cu))
+  if (name == NULL || !dwarf2_get_pc_bounds (die, &lowpc, &highpc))
     return;
 
   lowpc += baseaddr;
@@ -2982,11 +2974,11 @@ read_func_scope (struct die_info *die, s
   add_to_cu_func_list (name, lowpc, highpc, cu);
 
   new = push_context (0, lowpc);
-  new->name = new_symbol (die, read_type_die (die, cu), cu);
+  new->name = new_symbol (die, read_type_die (die));
 
   /* If there is a location expression for DW_AT_frame_base, record
      it.  */
-  attr = dwarf2_attr (die, DW_AT_frame_base, cu);
+  attr = dwarf2_attr (die, DW_AT_frame_base);
   if (attr)
     /* FIXME: cagney/2004-01-26: The DW_AT_frame_base's location
        expression is being recorded directly in the function's symbol
@@ -3006,7 +2998,7 @@ read_func_scope (struct die_info *die, s
       child_die = die->child;
       while (child_die && child_die->tag)
 	{
-	  process_die (child_die, cu);
+	  process_die (child_die);
 	  child_die = sibling_die (child_die);
 	}
     }
@@ -3019,11 +3011,11 @@ read_func_scope (struct die_info *die, s
   /* For C++, set the block's scope.  */
   if (cu->language == language_cplus)
     cp_set_block_scope (new->name, block, &objfile->objfile_obstack,
-			determine_prefix (die, cu),
+			determine_prefix (die),
 			processing_has_namespace_info);
 
   /* If we have address ranges, record them.  */
-  dwarf2_record_block_ranges (die, block, baseaddr, cu);
+  dwarf2_record_block_ranges (die, block, baseaddr);
   
   /* In C++, we can have functions nested inside functions (e.g., when
      a function declares a class that has methods).  This means that
@@ -3042,8 +3034,9 @@ read_func_scope (struct die_info *die, s
    a new scope, process the dies, and then close the scope.  */
 
 static void
-read_lexical_block_scope (struct die_info *die, struct dwarf2_cu *cu)
+read_lexical_block_scope (struct die_info *die)
 {
+  struct dwarf2_cu *cu = die->cu;
   struct objfile *objfile = cu->objfile;
   struct context_stack *new;
   CORE_ADDR lowpc, highpc;
@@ -3057,7 +3050,7 @@ read_lexical_block_scope (struct die_inf
      as multiple lexical blocks?  Handling children in a sane way would
      be nasty.  Might be easier to properly extend generic blocks to 
      describe ranges.  */
-  if (!dwarf2_get_pc_bounds (die, &lowpc, &highpc, cu))
+  if (!dwarf2_get_pc_bounds (die, &lowpc, &highpc))
     return;
   lowpc += baseaddr;
   highpc += baseaddr;
@@ -3068,7 +3061,7 @@ read_lexical_block_scope (struct die_inf
       child_die = die->child;
       while (child_die && child_die->tag)
 	{
-	  process_die (child_die, cu);
+	  process_die (child_die);
 	  child_die = sibling_die (child_die);
 	}
     }
@@ -3090,7 +3083,7 @@ read_lexical_block_scope (struct die_inf
          there.  But since we don't even decide whether to create a
          block until after we've traversed its children, that's hard
          to do.  */
-      dwarf2_record_block_ranges (die, block, baseaddr, cu);
+      dwarf2_record_block_ranges (die, block, baseaddr);
     }
   local_symbols = new->locals;
 }
@@ -3228,18 +3221,19 @@ dwarf2_ranges_read (unsigned offset, COR
    discontinuous, i.e. derived from DW_AT_ranges information.  */
 static int
 dwarf2_get_pc_bounds (struct die_info *die, CORE_ADDR *lowpc,
-		      CORE_ADDR *highpc, struct dwarf2_cu *cu)
+		      CORE_ADDR *highpc)
 {
+  struct dwarf2_cu *cu = die->cu;
   struct attribute *attr;
   CORE_ADDR low = 0;
   CORE_ADDR high = 0;
   int ret = 0;
 
-  attr = dwarf2_attr (die, DW_AT_high_pc, cu);
+  attr = dwarf2_attr (die, DW_AT_high_pc);
   if (attr)
     {
       high = DW_ADDR (attr);
-      attr = dwarf2_attr (die, DW_AT_low_pc, cu);
+      attr = dwarf2_attr (die, DW_AT_low_pc);
       if (attr)
 	low = DW_ADDR (attr);
       else
@@ -3251,7 +3245,7 @@ dwarf2_get_pc_bounds (struct die_info *d
     }
   else
     {
-      attr = dwarf2_attr (die, DW_AT_ranges, cu);
+      attr = dwarf2_attr (die, DW_AT_ranges);
       if (attr != NULL)
 	{
 	  /* Value of the DW_AT_ranges attribute is the offset in the
@@ -3288,14 +3282,13 @@ dwarf2_get_pc_bounds (struct die_info *d
 
 static void
 get_scope_pc_bounds (struct die_info *die,
-		     CORE_ADDR *lowpc, CORE_ADDR *highpc,
-		     struct dwarf2_cu *cu)
+		     CORE_ADDR *lowpc, CORE_ADDR *highpc)
 {
   CORE_ADDR best_low = (CORE_ADDR) -1;
   CORE_ADDR best_high = (CORE_ADDR) 0;
   CORE_ADDR current_low, current_high;
 
-  if (dwarf2_get_pc_bounds (die, &current_low, &current_high, cu))
+  if (dwarf2_get_pc_bounds (die, &current_low, &current_high))
     {
       best_low = current_low;
       best_high = current_high;
@@ -3308,7 +3301,7 @@ get_scope_pc_bounds (struct die_info *di
 	{
 	  switch (child->tag) {
 	  case DW_TAG_subprogram:
-	    if (dwarf2_get_pc_bounds (child, &current_low, &current_high, cu))
+	    if (dwarf2_get_pc_bounds (child, &current_low, &current_high))
 	      {
 		best_low = min (best_low, current_low);
 		best_high = max (best_high, current_high);
@@ -3323,7 +3316,7 @@ get_scope_pc_bounds (struct die_info *di
 	       the DIEs giving the declarations, which could be
 	       anywhere).  But I don't see any reason why the
 	       standards says that they have to be there.  */
-	    get_scope_pc_bounds (child, &current_low, &current_high, cu);
+	    get_scope_pc_bounds (child, &current_low, &current_high);
 
 	    if (current_low != ((CORE_ADDR) -1))
 	      {
@@ -3348,15 +3341,16 @@ get_scope_pc_bounds (struct die_info *di
    in DIE.  */
 static void
 dwarf2_record_block_ranges (struct die_info *die, struct block *block,
-                            CORE_ADDR baseaddr, struct dwarf2_cu *cu)
+                            CORE_ADDR baseaddr)
 {
+  struct dwarf2_cu *cu = die->cu;
   struct attribute *attr;
 
-  attr = dwarf2_attr (die, DW_AT_high_pc, cu);
+  attr = dwarf2_attr (die, DW_AT_high_pc);
   if (attr)
     {
       CORE_ADDR high = DW_ADDR (attr);
-      attr = dwarf2_attr (die, DW_AT_low_pc, cu);
+      attr = dwarf2_attr (die, DW_AT_low_pc);
       if (attr)
         {
           CORE_ADDR low = DW_ADDR (attr);
@@ -3364,7 +3358,7 @@ dwarf2_record_block_ranges (struct die_i
         }
     }
 
-  attr = dwarf2_attr (die, DW_AT_ranges, cu);
+  attr = dwarf2_attr (die, DW_AT_ranges);
   if (attr)
     {
       bfd *obfd = cu->objfile->obfd;
@@ -3441,9 +3435,9 @@ dwarf2_record_block_ranges (struct die_i
 /* Add an aggregate field to the field list.  */
 
 static void
-dwarf2_add_field (struct field_info *fip, struct die_info *die,
-		  struct dwarf2_cu *cu)
+dwarf2_add_field (struct field_info *fip, struct die_info *die)
 { 
+  struct dwarf2_cu *cu = die->cu;
   struct objfile *objfile = cu->objfile;
   struct gdbarch *gdbarch = get_objfile_arch (objfile);
   struct nextfield *new_field;
@@ -3468,28 +3462,28 @@ dwarf2_add_field (struct field_info *fip
     new_field->accessibility = DW_ACCESS_private;
   new_field->virtuality = DW_VIRTUALITY_none;
 
-  attr = dwarf2_attr (die, DW_AT_accessibility, cu);
+  attr = dwarf2_attr (die, DW_AT_accessibility);
   if (attr)
     new_field->accessibility = DW_UNSND (attr);
   if (new_field->accessibility != DW_ACCESS_public)
     fip->non_public_fields = 1;
-  attr = dwarf2_attr (die, DW_AT_virtuality, cu);
+  attr = dwarf2_attr (die, DW_AT_virtuality);
   if (attr)
     new_field->virtuality = DW_UNSND (attr);
 
   fp = &new_field->field;
 
-  if (die->tag == DW_TAG_member && ! die_is_declaration (die, cu))
+  if (die->tag == DW_TAG_member && ! die_is_declaration (die))
     {
       /* Data member other than a C++ static data member.  */
       
       /* Get type of field.  */
-      fp->type = die_type (die, cu);
+      fp->type = die_type (die);
 
       FIELD_STATIC_KIND (*fp) = 0;
 
       /* Get bit size of field (zero if none).  */
-      attr = dwarf2_attr (die, DW_AT_bit_size, cu);
+      attr = dwarf2_attr (die, DW_AT_bit_size);
       if (attr)
 	{
 	  FIELD_BITSIZE (*fp) = DW_UNSND (attr);
@@ -3500,7 +3494,7 @@ dwarf2_add_field (struct field_info *fip
 	}
 
       /* Get bit offset of field.  */
-      attr = dwarf2_attr (die, DW_AT_data_member_location, cu);
+      attr = dwarf2_attr (die, DW_AT_data_member_location);
       if (attr)
 	{
           int byte_offset;
@@ -3519,7 +3513,7 @@ dwarf2_add_field (struct field_info *fip
 	}
       else
 	FIELD_BITPOS (*fp) = 0;
-      attr = dwarf2_attr (die, DW_AT_bit_offset, cu);
+      attr = dwarf2_attr (die, DW_AT_bit_offset);
       if (attr)
 	{
 	  if (gdbarch_bits_big_endian (gdbarch))
@@ -3542,7 +3536,7 @@ dwarf2_add_field (struct field_info *fip
 	      int anonymous_size;
 	      int bit_offset = DW_UNSND (attr);
 
-	      attr = dwarf2_attr (die, DW_AT_byte_size, cu);
+	      attr = dwarf2_attr (die, DW_AT_byte_size);
 	      if (attr)
 		{
 		  /* The size of the anonymous object containing
@@ -3564,7 +3558,7 @@ dwarf2_add_field (struct field_info *fip
 	}
 
       /* Get name of field.  */
-      fieldname = dwarf2_name (die, cu);
+      fieldname = dwarf2_name (die);
       if (fieldname == NULL)
 	fieldname = "";
 
@@ -3574,7 +3568,7 @@ dwarf2_add_field (struct field_info *fip
 
       /* Change accessibility for artificial fields (e.g. virtual table
          pointer or virtual base class pointer) to private.  */
-      if (dwarf2_attr (die, DW_AT_artificial, cu))
+      if (dwarf2_attr (die, DW_AT_artificial))
 	{
 	  new_field->accessibility = DW_ACCESS_private;
 	  fip->non_public_fields = 1;
@@ -3592,29 +3586,29 @@ dwarf2_add_field (struct field_info *fip
       char *physname;
 
       /* Get name of field.  */
-      fieldname = dwarf2_name (die, cu);
+      fieldname = dwarf2_name (die);
       if (fieldname == NULL)
 	return;
 
       /* Get physical name.  */
-      physname = dwarf2_linkage_name (die, cu);
+      physname = dwarf2_linkage_name (die);
 
       /* The name is already allocated along with this objfile, so we don't
 	 need to duplicate it for the type.  */
       SET_FIELD_PHYSNAME (*fp, physname ? physname : "");
-      FIELD_TYPE (*fp) = die_type (die, cu);
+      FIELD_TYPE (*fp) = die_type (die);
       FIELD_NAME (*fp) = fieldname;
     }
   else if (die->tag == DW_TAG_inheritance)
     {
       /* C++ base class field.  */
-      attr = dwarf2_attr (die, DW_AT_data_member_location, cu);
+      attr = dwarf2_attr (die, DW_AT_data_member_location);
       if (attr)
 	FIELD_BITPOS (*fp) = (decode_locdesc (DW_BLOCK (attr), cu)
 			      * bits_per_byte);
       FIELD_BITSIZE (*fp) = 0;
       FIELD_STATIC_KIND (*fp) = 0;
-      FIELD_TYPE (*fp) = die_type (die, cu);
+      FIELD_TYPE (*fp) = die_type (die);
       FIELD_NAME (*fp) = type_name_no_tag (fp->type);
       fip->nbaseclasses++;
     }
@@ -3711,8 +3705,9 @@ dwarf2_attach_fields_to_type (struct fie
 
 static void
 dwarf2_add_member_fn (struct field_info *fip, struct die_info *die,
-		      struct type *type, struct dwarf2_cu *cu)
+		      struct type *type)
 {
+  struct dwarf2_cu *cu = die->cu;
   struct objfile *objfile = cu->objfile;
   struct attribute *attr;
   struct fnfieldlist *flp;
@@ -3724,12 +3719,12 @@ dwarf2_add_member_fn (struct field_info 
   struct type *this_type;
 
   /* Get name of member function.  */
-  fieldname = dwarf2_name (die, cu);
+  fieldname = dwarf2_name (die);
   if (fieldname == NULL)
     return;
 
   /* Get the mangled name.  */
-  physname = dwarf2_linkage_name (die, cu);
+  physname = dwarf2_linkage_name (die);
 
   /* Look up member function name in fieldlist.  */
   for (i = 0; i < fip->nfnfields; i++)
@@ -3774,7 +3769,7 @@ dwarf2_add_member_fn (struct field_info 
      need to duplicate it for the type.  */
   fnp->physname = physname ? physname : "";
   fnp->type = alloc_type (objfile);
-  this_type = read_type_die (die, cu);
+  this_type = read_type_die (die);
   if (this_type && TYPE_CODE (this_type) == TYPE_CODE_FUNC)
     {
       int nparams = TYPE_NFIELDS (this_type);
@@ -3801,14 +3796,14 @@ dwarf2_add_member_fn (struct field_info 
 	       physname);
 
   /* Get fcontext from DW_AT_containing_type if present.  */
-  if (dwarf2_attr (die, DW_AT_containing_type, cu) != NULL)
-    fnp->fcontext = die_containing_type (die, cu);
+  if (dwarf2_attr (die, DW_AT_containing_type) != NULL)
+    fnp->fcontext = die_containing_type (die);
 
   /* dwarf2 doesn't have stubbed physical names, so the setting of is_const
      and is_volatile is irrelevant, as it is needed by gdb_mangle_name only.  */
 
   /* Get accessibility.  */
-  attr = dwarf2_attr (die, DW_AT_accessibility, cu);
+  attr = dwarf2_attr (die, DW_AT_accessibility);
   if (attr)
     {
       switch (DW_UNSND (attr))
@@ -3823,12 +3818,12 @@ dwarf2_add_member_fn (struct field_info 
     }
 
   /* Check for artificial methods.  */
-  attr = dwarf2_attr (die, DW_AT_artificial, cu);
+  attr = dwarf2_attr (die, DW_AT_artificial);
   if (attr && DW_UNSND (attr) != 0)
     fnp->is_artificial = 1;
 
   /* Get index in virtual function table if it is a virtual member function.  */
-  attr = dwarf2_attr (die, DW_AT_vtable_elem_location, cu);
+  attr = dwarf2_attr (die, DW_AT_vtable_elem_location);
   if (attr)
     {
       /* Support the .debug_loc offsets */
@@ -3909,8 +3904,9 @@ is_vtable_name (const char *name, struct
    This is GCC PR debug/28767.  */
 
 static struct type *
-quirk_gcc_member_function_pointer (struct die_info *die, struct dwarf2_cu *cu)
+quirk_gcc_member_function_pointer (struct die_info *die)
 {
+  struct dwarf2_cu *cu = die->cu;
   struct objfile *objfile = cu->objfile;
   struct type *type;
   struct die_info *pfn_die, *delta_die;
@@ -3919,7 +3915,7 @@ quirk_gcc_member_function_pointer (struc
 
   /* Check for a structure with no name and two children.  */
   if (die->tag != DW_TAG_structure_type
-      || dwarf2_attr (die, DW_AT_name, cu) != NULL
+      || dwarf2_attr (die, DW_AT_name) != NULL
       || die->child == NULL
       || die->child->sibling == NULL
       || (die->child->sibling->sibling != NULL
@@ -3928,7 +3924,7 @@ quirk_gcc_member_function_pointer (struc
 
   /* Check for __pfn and __delta members.  */
   pfn_die = die->child;
-  pfn_name = dwarf2_attr (pfn_die, DW_AT_name, cu);
+  pfn_name = dwarf2_attr (pfn_die, DW_AT_name);
   if (pfn_die->tag != DW_TAG_member
       || pfn_name == NULL
       || DW_STRING (pfn_name) == NULL
@@ -3936,7 +3932,7 @@ quirk_gcc_member_function_pointer (struc
     return NULL;
 
   delta_die = pfn_die->sibling;
-  delta_name = dwarf2_attr (delta_die, DW_AT_name, cu);
+  delta_name = dwarf2_attr (delta_die, DW_AT_name);
   if (delta_die->tag != DW_TAG_member
       || delta_name == NULL
       || DW_STRING (delta_name) == NULL
@@ -3944,7 +3940,7 @@ quirk_gcc_member_function_pointer (struc
     return NULL;
 
   /* Find the type of the method.  */
-  pfn_type = die_type (pfn_die, cu);
+  pfn_type = die_type (pfn_die);
   if (pfn_type == NULL
       || TYPE_CODE (pfn_type) != TYPE_CODE_PTR
       || TYPE_CODE (TYPE_TARGET_TYPE (pfn_type)) != TYPE_CODE_FUNC)
@@ -3962,7 +3958,7 @@ quirk_gcc_member_function_pointer (struc
 			TYPE_FIELDS (pfn_type), TYPE_NFIELDS (pfn_type),
 			TYPE_VARARGS (pfn_type));
   type = lookup_methodptr_type (type);
-  return set_die_type (die, type, cu);
+  return set_die_type (die, type);
 }
 
 /* Called when we find the DIE that starts a structure or union scope
@@ -3982,27 +3978,28 @@ quirk_gcc_member_function_pointer (struc
    suppresses creating a symbol table entry itself).  */
 
 static struct type *
-read_structure_type (struct die_info *die, struct dwarf2_cu *cu)
+read_structure_type (struct die_info *die)
 {
+  struct dwarf2_cu *cu = die->cu;
   struct objfile *objfile = cu->objfile;
   struct type *type;
   struct attribute *attr;
   char *name;
   struct cleanup *back_to = make_cleanup (null_cleanup, 0);
 
-  type = quirk_gcc_member_function_pointer (die, cu);
+  type = quirk_gcc_member_function_pointer (die);
   if (type)
     return type;
 
   type = alloc_type (objfile);
   INIT_CPLUS_SPECIFIC (type);
-  name = dwarf2_name (die, cu);
+  name = dwarf2_name (die);
   if (name != NULL)
     {
       if (cu->language == language_cplus
 	  || cu->language == language_java)
 	{
-	  const char *new_prefix = determine_class_name (die, cu);
+	  const char *new_prefix = determine_class_name (die);
 	  TYPE_TAG_NAME (type) = (char *) new_prefix;
 	}
       else
@@ -4028,7 +4025,7 @@ read_structure_type (struct die_info *di
       TYPE_CODE (type) = TYPE_CODE_CLASS;
     }
 
-  attr = dwarf2_attr (die, DW_AT_byte_size, cu);
+  attr = dwarf2_attr (die, DW_AT_byte_size);
   if (attr)
     {
       TYPE_LENGTH (type) = DW_UNSND (attr);
@@ -4039,15 +4036,15 @@ read_structure_type (struct die_info *di
     }
 
   TYPE_STUB_SUPPORTED (type) = 1;
-  if (die_is_declaration (die, cu))
+  if (die_is_declaration (die))
     TYPE_STUB (type) = 1;
 
   /* We need to add the type field to the die immediately so we don't
      infinitely recurse when dealing with pointers to the structure
      type within the structure itself. */
-  set_die_type (die, type, cu);
+  set_die_type (die, type);
 
-  if (die->child != NULL && ! die_is_declaration (die, cu))
+  if (die->child != NULL && ! die_is_declaration (die))
     {
       struct field_info fi;
       struct die_info *child_die;
@@ -4066,17 +4063,17 @@ read_structure_type (struct die_info *di
 		 all versions of G++ as of this writing (so through at
 		 least 3.2.1) incorrectly generate DW_TAG_variable
 		 tags for them instead.  */
-	      dwarf2_add_field (&fi, child_die, cu);
+	      dwarf2_add_field (&fi, child_die);
 	    }
 	  else if (child_die->tag == DW_TAG_subprogram)
 	    {
 	      /* C++ member function. */
-	      dwarf2_add_member_fn (&fi, child_die, type, cu);
+	      dwarf2_add_member_fn (&fi, child_die, type);
 	    }
 	  else if (child_die->tag == DW_TAG_inheritance)
 	    {
 	      /* C++ base class field.  */
-	      dwarf2_add_field (&fi, child_die, cu);
+	      dwarf2_add_field (&fi, child_die);
 	    }
 	  child_die = sibling_die (child_die);
 	}
@@ -4092,9 +4089,9 @@ read_structure_type (struct die_info *di
 	     class itself) which contains the vtable pointer for the current
 	     class from the DW_AT_containing_type attribute.  */
 
-	  if (dwarf2_attr (die, DW_AT_containing_type, cu) != NULL)
+	  if (dwarf2_attr (die, DW_AT_containing_type) != NULL)
 	    {
-	      struct type *t = die_containing_type (die, cu);
+	      struct type *t = die_containing_type (die);
 
 	      TYPE_VPTR_BASETYPE (type) = t;
 	      if (type == t)
@@ -4157,15 +4154,16 @@ read_structure_type (struct die_info *di
 }
 
 static void
-process_structure_scope (struct die_info *die, struct dwarf2_cu *cu)
+process_structure_scope (struct die_info *die)
 {
+  struct dwarf2_cu *cu = die->cu;
   struct objfile *objfile = cu->objfile;
   struct die_info *child_die = die->child;
   struct type *this_type;
 
-  this_type = get_die_type (die, cu);
+  this_type = get_die_type (die);
   if (this_type == NULL)
-    this_type = read_structure_type (die, cu);
+    this_type = read_structure_type (die);
 
   /* NOTE: carlton/2004-03-16: GCC 3.4 (or at least one of its
      snapshots) has been known to create a die giving a declaration
@@ -4183,7 +4181,7 @@ process_structure_scope (struct die_info
 	  /* Do nothing.  */
 	}
       else
-	process_die (child_die, cu);
+	process_die (child_die);
 
       child_die = sibling_die (child_die);
     }
@@ -4191,17 +4189,18 @@ process_structure_scope (struct die_info
   /* Do not consider external references.  According to the DWARF standard,
      these DIEs are identified by the fact that they have no byte_size
      attribute, and a declaration attribute.  */
-  if (dwarf2_attr (die, DW_AT_byte_size, cu) != NULL
-      || !die_is_declaration (die, cu))
-    new_symbol (die, this_type, cu);
+  if (dwarf2_attr (die, DW_AT_byte_size) != NULL
+      || !die_is_declaration (die))
+    new_symbol (die, this_type);
 }
 
 /* Given a DW_AT_enumeration_type die, set its type.  We do not
    complete the type's fields yet, or create any symbols.  */
 
 static struct type *
-read_enumeration_type (struct die_info *die, struct dwarf2_cu *cu)
+read_enumeration_type (struct die_info *die)
 {
+  struct dwarf2_cu *cu = die->cu;
   struct objfile *objfile = cu->objfile;
   struct type *type;
   struct attribute *attr;
@@ -4210,11 +4209,11 @@ read_enumeration_type (struct die_info *
   type = alloc_type (objfile);
 
   TYPE_CODE (type) = TYPE_CODE_ENUM;
-  name = dwarf2_full_name (die, cu);
+  name = dwarf2_full_name (die);
   if (name != NULL)
     TYPE_TAG_NAME (type) = (char *) name;
 
-  attr = dwarf2_attr (die, DW_AT_byte_size, cu);
+  attr = dwarf2_attr (die, DW_AT_byte_size);
   if (attr)
     {
       TYPE_LENGTH (type) = DW_UNSND (attr);
@@ -4229,10 +4228,10 @@ read_enumeration_type (struct die_info *
      inside the package body.  Such types are known as Taft Amendment
      Types.  When another package uses such a type, an incomplete DIE
      may be generated by the compiler.  */
-  if (die_is_declaration (die, cu))
+  if (die_is_declaration (die))
     TYPE_STUB (type) = 1;
 
-  return set_die_type (die, type, cu);
+  return set_die_type (die, type);
 }
 
 /* Determine the name of the type represented by DIE, which should be
@@ -4240,8 +4239,9 @@ read_enumeration_type (struct die_info *
    allocated on the objfile obstack.  */
 
 static const char *
-determine_class_name (struct die_info *die, struct dwarf2_cu *cu)
+determine_class_name (struct die_info *die)
 {
+  struct dwarf2_cu *cu = die->cu;
   const char *new_prefix = NULL;
 
   /* If we don't have namespace debug info, guess the name by trying
@@ -4260,7 +4260,7 @@ determine_class_name (struct die_info *d
 	      char *phys_prefix
 		= language_class_name_from_physname (cu->language_defn,
 						     dwarf2_linkage_name
-						     (child, cu));
+						     (child));
 
 	      if (phys_prefix != NULL)
 		{
@@ -4275,7 +4275,7 @@ determine_class_name (struct die_info *d
     }
 
   if (new_prefix == NULL)
-    new_prefix = dwarf2_full_name (die, cu);
+    new_prefix = dwarf2_full_name (die);
 
   return new_prefix;
 }
@@ -4287,8 +4287,9 @@ determine_class_name (struct die_info *d
    NOTE: We reverse the order of the element list.  */
 
 static void
-process_enumeration_scope (struct die_info *die, struct dwarf2_cu *cu)
+process_enumeration_scope (struct die_info *die)
 {
+  struct dwarf2_cu *cu = die->cu;
   struct objfile *objfile = cu->objfile;
   struct die_info *child_die;
   struct field *fields;
@@ -4300,9 +4301,9 @@ process_enumeration_scope (struct die_in
 
   num_fields = 0;
   fields = NULL;
-  this_type = get_die_type (die, cu);
+  this_type = get_die_type (die);
   if (this_type == NULL)
-    this_type = read_enumeration_type (die, cu);
+    this_type = read_enumeration_type (die);
   if (die->child != NULL)
     {
       child_die = die->child;
@@ -4310,14 +4311,14 @@ process_enumeration_scope (struct die_in
 	{
 	  if (child_die->tag != DW_TAG_enumerator)
 	    {
-	      process_die (child_die, cu);
+	      process_die (child_die);
 	    }
 	  else
 	    {
-	      name = dwarf2_name (child_die, cu);
+	      name = dwarf2_name (child_die);
 	      if (name)
 		{
-		  sym = new_symbol (child_die, this_type, cu);
+		  sym = new_symbol (child_die, this_type);
 		  if (SYMBOL_VALUE (sym) < 0)
 		    unsigned_enum = 0;
 
@@ -4355,7 +4356,7 @@ process_enumeration_scope (struct die_in
 	TYPE_UNSIGNED (this_type) = 1;
     }
 
-  new_symbol (die, this_type, cu);
+  new_symbol (die, this_type);
 }
 
 /* Extract all information from a DW_TAG_array_type DIE and put it in
@@ -4363,8 +4364,9 @@ process_enumeration_scope (struct die_in
    arrays.  */
 
 static struct type *
-read_array_type (struct die_info *die, struct dwarf2_cu *cu)
+read_array_type (struct die_info *die)
 {
+  struct dwarf2_cu *cu = die->cu;
   struct objfile *objfile = cu->objfile;
   struct die_info *child_die;
   struct type *type = NULL;
@@ -4375,7 +4377,7 @@ read_array_type (struct die_info *die, s
   struct cleanup *back_to;
   char *name;
 
-  element_type = die_type (die, cu);
+  element_type = die_type (die);
 
   /* Irix 6.2 native cc creates array types without children for
      arrays with unspecified length.  */
@@ -4384,7 +4386,7 @@ read_array_type (struct die_info *die, s
       index_type = builtin_type_int32;
       range_type = create_range_type (NULL, index_type, 0, -1);
       type = create_array_type (NULL, element_type, range_type);
-      return set_die_type (die, type, cu);
+      return set_die_type (die, type);
     }
 
   back_to = make_cleanup (null_cleanup, NULL);
@@ -4393,7 +4395,7 @@ read_array_type (struct die_info *die, s
     {
       if (child_die->tag == DW_TAG_subrange_type)
 	{
-	  struct type *child_type = read_type_die (child_die, cu);
+	  struct type *child_type = read_type_die (child_die);
           if (child_type != NULL)
             {
 	      /* The range type was succesfully read. Save it for
@@ -4417,7 +4419,7 @@ read_array_type (struct die_info *die, s
 
   type = element_type;
 
-  if (read_array_order (die, cu) == DW_ORD_col_major)
+  if (read_array_order (die) == DW_ORD_col_major)
     {
       int i = 0;
       while (i < ndim)
@@ -4435,26 +4437,27 @@ read_array_type (struct die_info *die, s
      custom vendor extension.  The main difference between a regular
      array and the vector variant is that vectors are passed by value
      to functions.  */
-  attr = dwarf2_attr (die, DW_AT_GNU_vector, cu);
+  attr = dwarf2_attr (die, DW_AT_GNU_vector);
   if (attr)
     make_vector_type (type);
 
-  name = dwarf2_name (die, cu);
+  name = dwarf2_name (die);
   if (name)
     TYPE_NAME (type) = name;
   
   do_cleanups (back_to);
 
   /* Install the type in the die. */
-  return set_die_type (die, type, cu);
+  return set_die_type (die, type);
 }
 
 static enum dwarf_array_dim_ordering
-read_array_order (struct die_info *die, struct dwarf2_cu *cu) 
+read_array_order (struct die_info *die)
 {
+  struct dwarf2_cu *cu = die->cu;
   struct attribute *attr;
 
-  attr = dwarf2_attr (die, DW_AT_ordering, cu);
+  attr = dwarf2_attr (die, DW_AT_ordering);
 
   if (attr) return DW_SND (attr);
 
@@ -4487,24 +4490,25 @@ read_array_order (struct die_info *die, 
    the DIE's type field. */
 
 static struct type *
-read_set_type (struct die_info *die, struct dwarf2_cu *cu)
+read_set_type (struct die_info *die)
 {
-  struct type *set_type = create_set_type (NULL, die_type (die, cu));
+  struct type *set_type = create_set_type (NULL, die_type (die));
 
-  return set_die_type (die, set_type, cu);
+  return set_die_type (die, set_type);
 }
 
 /* First cut: install each common block member as a global variable.  */
 
 static void
-read_common_block (struct die_info *die, struct dwarf2_cu *cu)
+read_common_block (struct die_info *die)
 {
+  struct dwarf2_cu *cu = die->cu;
   struct die_info *child_die;
   struct attribute *attr;
   struct symbol *sym;
   CORE_ADDR base = (CORE_ADDR) 0;
 
-  attr = dwarf2_attr (die, DW_AT_location, cu);
+  attr = dwarf2_attr (die, DW_AT_location);
   if (attr)
     {
       /* Support the .debug_loc offsets */
@@ -4527,8 +4531,8 @@ read_common_block (struct die_info *die,
       child_die = die->child;
       while (child_die && child_die->tag)
 	{
-	  sym = new_symbol (child_die, NULL, cu);
-	  attr = dwarf2_attr (child_die, DW_AT_data_member_location, cu);
+	  sym = new_symbol (child_die, NULL);
+	  attr = dwarf2_attr (child_die, DW_AT_data_member_location);
 	  if (attr)
 	    {
 	      SYMBOL_VALUE_ADDRESS (sym) =
@@ -4543,28 +4547,28 @@ read_common_block (struct die_info *die,
 /* Create a type for a C++ namespace.  */
 
 static struct type *
-read_namespace_type (struct die_info *die, struct dwarf2_cu *cu)
+read_namespace_type (struct die_info *die)
 {
+  struct dwarf2_cu *cu = die->cu;
   struct objfile *objfile = cu->objfile;
   const char *previous_prefix, *name;
   int is_anonymous;
   struct type *type;
 
   /* For extensions, reuse the type of the original namespace.  */
-  if (dwarf2_attr (die, DW_AT_extension, cu) != NULL)
+  if (dwarf2_attr (die, DW_AT_extension) != NULL)
     {
       struct die_info *ext_die;
-      struct dwarf2_cu *ext_cu = cu;
-      ext_die = dwarf2_extension (die, &ext_cu);
-      type = read_type_die (ext_die, ext_cu);
-      return set_die_type (die, type, cu);
+      ext_die = dwarf2_extension (die);
+      type = read_type_die (ext_die);
+      return set_die_type (die, type);
     }
 
-  name = namespace_name (die, &is_anonymous, cu);
+  name = namespace_name (die, &is_anonymous);
 
   /* Now build the name of the current namespace.  */
 
-  previous_prefix = determine_prefix (die, cu);
+  previous_prefix = determine_prefix (die);
   if (previous_prefix[0] != '\0')
     name = typename_concat (&objfile->objfile_obstack,
 			    previous_prefix, name, cu);
@@ -4575,7 +4579,7 @@ read_namespace_type (struct die_info *di
   TYPE_NAME (type) = (char *) name;
   TYPE_TAG_NAME (type) = TYPE_NAME (type);
 
-  set_die_type (die, type, cu);
+  set_die_type (die, type);
 
   return type;
 }
@@ -4583,8 +4587,9 @@ read_namespace_type (struct die_info *di
 /* Read a C++ namespace.  */
 
 static void
-read_namespace (struct die_info *die, struct dwarf2_cu *cu)
+read_namespace (struct die_info *die)
 {
+  struct dwarf2_cu *cu = die->cu;
   struct objfile *objfile = cu->objfile;
   const char *name;
   int is_anonymous;
@@ -4593,17 +4598,17 @@ read_namespace (struct die_info *die, st
      before.  Also, add a using directive if it's an anonymous
      namespace.  */
 
-  if (dwarf2_attr (die, DW_AT_extension, cu) == NULL)
+  if (dwarf2_attr (die, DW_AT_extension) == NULL)
     {
       struct type *type;
 
-      type = read_type_die (die, cu);
-      new_symbol (die, type, cu);
+      type = read_type_die (die);
+      new_symbol (die, type);
 
-      name = namespace_name (die, &is_anonymous, cu);
+      name = namespace_name (die, &is_anonymous);
       if (is_anonymous)
 	{
-	  const char *previous_prefix = determine_prefix (die, cu);
+	  const char *previous_prefix = determine_prefix (die);
 	  cp_add_using_directive (TYPE_NAME (type),
 				  strlen (previous_prefix),
 				  strlen (TYPE_NAME (type)));
@@ -4616,7 +4621,7 @@ read_namespace (struct die_info *die, st
       
       while (child_die && child_die->tag)
 	{
-	  process_die (child_die, cu);
+	  process_die (child_die);
 	  child_die = sibling_die (child_die);
 	}
     }
@@ -4627,7 +4632,7 @@ read_namespace (struct die_info *die, st
    namespace.  */
 
 static const char *
-namespace_name (struct die_info *die, int *is_anonymous, struct dwarf2_cu *cu)
+namespace_name (struct die_info *die, int *is_anonymous)
 {
   struct die_info *current_die;
   const char *name = NULL;
@@ -4636,9 +4641,9 @@ namespace_name (struct die_info *die, in
 
   for (current_die = die;
        current_die != NULL;
-       current_die = dwarf2_extension (die, &cu))
+       current_die = dwarf2_extension (die))
     {
-      name = dwarf2_name (current_die, cu);
+      name = dwarf2_name (current_die);
       if (name != NULL)
 	break;
     }
@@ -4656,8 +4661,9 @@ namespace_name (struct die_info *die, in
    the user defined type vector.  */
 
 static struct type *
-read_tag_pointer_type (struct die_info *die, struct dwarf2_cu *cu)
+read_tag_pointer_type (struct die_info *die)
 {
+  struct dwarf2_cu *cu = die->cu;
   struct gdbarch *gdbarch = get_objfile_arch (cu->objfile);
   struct comp_unit_head *cu_header = &cu->header;
   struct type *type;
@@ -4665,15 +4671,15 @@ read_tag_pointer_type (struct die_info *
   struct attribute *attr_address_class;
   int byte_size, addr_class;
 
-  type = lookup_pointer_type (die_type (die, cu));
+  type = lookup_pointer_type (die_type (die));
 
-  attr_byte_size = dwarf2_attr (die, DW_AT_byte_size, cu);
+  attr_byte_size = dwarf2_attr (die, DW_AT_byte_size);
   if (attr_byte_size)
     byte_size = DW_UNSND (attr_byte_size);
   else
     byte_size = cu_header->addr_size;
 
-  attr_address_class = dwarf2_attr (die, DW_AT_address_class, cu);
+  attr_address_class = dwarf2_attr (die, DW_AT_address_class);
   if (attr_address_class)
     addr_class = DW_UNSND (attr_address_class);
   else
@@ -4704,43 +4710,45 @@ read_tag_pointer_type (struct die_info *
     }
 
   TYPE_LENGTH (type) = byte_size;
-  return set_die_type (die, type, cu);
+  return set_die_type (die, type);
 }
 
 /* Extract all information from a DW_TAG_ptr_to_member_type DIE and add to
    the user defined type vector.  */
 
 static struct type *
-read_tag_ptr_to_member_type (struct die_info *die, struct dwarf2_cu *cu)
+read_tag_ptr_to_member_type (struct die_info *die)
 {
+  struct dwarf2_cu *cu = die->cu;
   struct objfile *objfile = cu->objfile;
   struct type *type;
   struct type *to_type;
   struct type *domain;
 
-  to_type = die_type (die, cu);
-  domain = die_containing_type (die, cu);
+  to_type = die_type (die);
+  domain = die_containing_type (die);
 
   if (TYPE_CODE (check_typedef (to_type)) == TYPE_CODE_METHOD)
     type = lookup_methodptr_type (to_type);
   else
     type = lookup_memberptr_type (to_type, domain);
 
-  return set_die_type (die, type, cu);
+  return set_die_type (die, type);
 }
 
 /* Extract all information from a DW_TAG_reference_type DIE and add to
    the user defined type vector.  */
 
 static struct type *
-read_tag_reference_type (struct die_info *die, struct dwarf2_cu *cu)
+read_tag_reference_type (struct die_info *die)
 {
+  struct dwarf2_cu *cu = die->cu;
   struct comp_unit_head *cu_header = &cu->header;
   struct type *type;
   struct attribute *attr;
 
-  type = lookup_reference_type (die_type (die, cu));
-  attr = dwarf2_attr (die, DW_AT_byte_size, cu);
+  type = lookup_reference_type (die_type (die));
+  attr = dwarf2_attr (die, DW_AT_byte_size);
   if (attr)
     {
       TYPE_LENGTH (type) = DW_UNSND (attr);
@@ -4749,27 +4757,27 @@ read_tag_reference_type (struct die_info
     {
       TYPE_LENGTH (type) = cu_header->addr_size;
     }
-  return set_die_type (die, type, cu);
+  return set_die_type (die, type);
 }
 
 static struct type *
-read_tag_const_type (struct die_info *die, struct dwarf2_cu *cu)
+read_tag_const_type (struct die_info *die)
 {
   struct type *base_type, *cv_type;
 
-  base_type = die_type (die, cu);
+  base_type = die_type (die);
   cv_type = make_cv_type (1, TYPE_VOLATILE (base_type), base_type, 0);
-  return set_die_type (die, cv_type, cu);
+  return set_die_type (die, cv_type);
 }
 
 static struct type *
-read_tag_volatile_type (struct die_info *die, struct dwarf2_cu *cu)
+read_tag_volatile_type (struct die_info *die)
 {
   struct type *base_type, *cv_type;
 
-  base_type = die_type (die, cu);
+  base_type = die_type (die);
   cv_type = make_cv_type (TYPE_CONST (base_type), 1, base_type, 0);
-  return set_die_type (die, cv_type, cu);
+  return set_die_type (die, cv_type);
 }
 
 /* Extract all information from a DW_TAG_string_type DIE and add to
@@ -4778,14 +4786,15 @@ read_tag_volatile_type (struct die_info 
    attribute to reference it.  */
 
 static struct type *
-read_tag_string_type (struct die_info *die, struct dwarf2_cu *cu)
+read_tag_string_type (struct die_info *die)
 {
+  struct dwarf2_cu *cu = die->cu;
   struct objfile *objfile = cu->objfile;
   struct type *type, *range_type, *index_type, *char_type;
   struct attribute *attr;
   unsigned int length;
 
-  attr = dwarf2_attr (die, DW_AT_string_length, cu);
+  attr = dwarf2_attr (die, DW_AT_string_length);
   if (attr)
     {
       length = DW_UNSND (attr);
@@ -4793,7 +4802,7 @@ read_tag_string_type (struct die_info *d
   else
     {
       /* check for the DW_AT_byte_size attribute */
-      attr = dwarf2_attr (die, DW_AT_byte_size, cu);
+      attr = dwarf2_attr (die, DW_AT_byte_size);
       if (attr)
         {
           length = DW_UNSND (attr);
@@ -4808,7 +4817,7 @@ read_tag_string_type (struct die_info *d
   range_type = create_range_type (NULL, index_type, 1, length);
   type = create_string_type (NULL, range_type);
 
-  return set_die_type (die, type, cu);
+  return set_die_type (die, type);
 }
 
 /* Handle DIES due to C code like:
@@ -4823,17 +4832,18 @@ read_tag_string_type (struct die_info *d
  */
 
 static struct type *
-read_subroutine_type (struct die_info *die, struct dwarf2_cu *cu)
+read_subroutine_type (struct die_info *die)
 {
+  struct dwarf2_cu *cu = die->cu;
   struct type *type;		/* Type that this function returns */
   struct type *ftype;		/* Function that returns above type */
   struct attribute *attr;
 
-  type = die_type (die, cu);
+  type = die_type (die);
   ftype = make_function_type (type, (struct type **) 0);
 
   /* All functions in C++, Pascal and Java have prototypes.  */
-  attr = dwarf2_attr (die, DW_AT_prototyped, cu);
+  attr = dwarf2_attr (die, DW_AT_prototyped);
   if ((attr && (DW_UNSND (attr) != 0))
       || cu->language == language_cplus
       || cu->language == language_java
@@ -4843,7 +4853,7 @@ read_subroutine_type (struct die_info *d
   /* Store the calling convention in the type if it's available in
      the subroutine die.  Otherwise set the calling convention to
      the default value DW_CC_normal.  */
-  attr = dwarf2_attr (die, DW_AT_calling_convention, cu);
+  attr = dwarf2_attr (die, DW_AT_calling_convention);
   TYPE_CALLING_CONVENTION (ftype) = attr ? DW_UNSND (attr) : DW_CC_normal;
   
   if (die->child != NULL)
@@ -4880,35 +4890,36 @@ read_subroutine_type (struct die_info *d
 	         parameter for non-static member functions (which is the
 	         this pointer) as artificial. We pass this information
 	         to dwarf2_add_member_fn via TYPE_FIELD_ARTIFICIAL.  */
-	      attr = dwarf2_attr (child_die, DW_AT_artificial, cu);
+	      attr = dwarf2_attr (child_die, DW_AT_artificial);
 	      if (attr)
 		TYPE_FIELD_ARTIFICIAL (ftype, iparams) = DW_UNSND (attr);
 	      else
 		TYPE_FIELD_ARTIFICIAL (ftype, iparams) = 0;
-	      TYPE_FIELD_TYPE (ftype, iparams) = die_type (child_die, cu);
+	      TYPE_FIELD_TYPE (ftype, iparams) = die_type (child_die);
 	      iparams++;
 	    }
 	  child_die = sibling_die (child_die);
 	}
     }
 
-  return set_die_type (die, ftype, cu);
+  return set_die_type (die, ftype);
 }
 
 static struct type *
-read_typedef (struct die_info *die, struct dwarf2_cu *cu)
+read_typedef (struct die_info *die)
 {
+  struct dwarf2_cu *cu = die->cu;
   struct objfile *objfile = cu->objfile;
   struct attribute *attr;
   const char *name = NULL;
   struct type *this_type;
 
-  name = dwarf2_full_name (die, cu);
+  name = dwarf2_full_name (die);
   this_type = init_type (TYPE_CODE_TYPEDEF, 0,
 			 TYPE_FLAG_TARGET_STUB, NULL, objfile);
   TYPE_NAME (this_type) = (char *) name;
-  set_die_type (die, this_type, cu);
-  TYPE_TARGET_TYPE (this_type) = die_type (die, cu);
+  set_die_type (die, this_type);
+  TYPE_TARGET_TYPE (this_type) = die_type (die);
   return this_type;
 }
 
@@ -4916,8 +4927,9 @@ read_typedef (struct die_info *die, stru
    it in the TYPE field of the die.  */
 
 static struct type *
-read_base_type (struct die_info *die, struct dwarf2_cu *cu)
+read_base_type (struct die_info *die)
 {
+  struct dwarf2_cu *cu = die->cu;
   struct objfile *objfile = cu->objfile;
   struct type *type;
   struct attribute *attr;
@@ -4927,17 +4939,17 @@ read_base_type (struct die_info *die, st
   int type_flags = 0;
   struct type *target_type = NULL;
 
-  attr = dwarf2_attr (die, DW_AT_encoding, cu);
+  attr = dwarf2_attr (die, DW_AT_encoding);
   if (attr)
     {
       encoding = DW_UNSND (attr);
     }
-  attr = dwarf2_attr (die, DW_AT_byte_size, cu);
+  attr = dwarf2_attr (die, DW_AT_byte_size);
   if (attr)
     {
       size = DW_UNSND (attr);
     }
-  name = dwarf2_name (die, cu);
+  name = dwarf2_name (die);
   if (!name)
     {
       complaint (&symfile_complaints,
@@ -4993,14 +5005,15 @@ read_base_type (struct die_info *die, st
   if (name && strcmp (name, "char") == 0)
     TYPE_NOSIGN (type) = 1;
 
-  return set_die_type (die, type, cu);
+  return set_die_type (die, type);
 }
 
 /* Read the given DW_AT_subrange DIE.  */
 
 static struct type *
-read_subrange_type (struct die_info *die, struct dwarf2_cu *cu)
+read_subrange_type (struct die_info *die)
 {
+  struct dwarf2_cu *cu = die->cu;
   struct gdbarch *gdbarch = get_objfile_arch (cu->objfile);
   struct type *base_type;
   struct type *range_type;
@@ -5009,7 +5022,7 @@ read_subrange_type (struct die_info *die
   int high = -1;
   char *name;
   
-  base_type = die_type (die, cu);
+  base_type = die_type (die);
   if (TYPE_CODE (base_type) == TYPE_CODE_VOID)
     {
       complaint (&symfile_complaints,
@@ -5028,11 +5041,11 @@ read_subrange_type (struct die_info *die
   /* FIXME: For variable sized arrays either of these could be
      a variable rather than a constant value.  We'll allow it,
      but we don't know how to handle it.  */
-  attr = dwarf2_attr (die, DW_AT_lower_bound, cu);
+  attr = dwarf2_attr (die, DW_AT_lower_bound);
   if (attr)
     low = dwarf2_get_attr_constant_value (attr, 0);
 
-  attr = dwarf2_attr (die, DW_AT_upper_bound, cu);
+  attr = dwarf2_attr (die, DW_AT_upper_bound);
   if (attr)
     {       
       if (attr->form == DW_FORM_block1)
@@ -5056,28 +5069,29 @@ read_subrange_type (struct die_info *die
 
   range_type = create_range_type (NULL, base_type, low, high);
 
-  name = dwarf2_name (die, cu);
+  name = dwarf2_name (die);
   if (name)
     TYPE_NAME (range_type) = name;
   
-  attr = dwarf2_attr (die, DW_AT_byte_size, cu);
+  attr = dwarf2_attr (die, DW_AT_byte_size);
   if (attr)
     TYPE_LENGTH (range_type) = DW_UNSND (attr);
 
-  return set_die_type (die, range_type, cu);
+  return set_die_type (die, range_type);
 }
   
 static struct type *
-read_unspecified_type (struct die_info *die, struct dwarf2_cu *cu)
+read_unspecified_type (struct die_info *die)
 {
+  struct dwarf2_cu *cu = die->cu;
   struct type *type;
 
   /* For now, we only support the C meaning of an unspecified type: void.  */
 
   type = init_type (TYPE_CODE_VOID, 0, 0, NULL, cu->objfile);
-  TYPE_NAME (type) = dwarf2_name (die, cu);
+  TYPE_NAME (type) = dwarf2_name (die);
 
-  return set_die_type (die, type, cu);
+  return set_die_type (die, type);
 }
 
 /* Trivial hash function for die_info: the hash value of a DIE
@@ -5140,7 +5154,7 @@ read_die_and_children (gdb_byte *info_pt
       *new_info_ptr = cur_ptr;
       return NULL;
     }
-  store_in_ref_table (die, cu);
+  store_in_ref_table (die);
 
   if (has_children)
     {
@@ -6037,6 +6051,7 @@ read_full_die (struct die_info **diep, b
 	     bfd_get_filename (abfd));
     }
   die = dwarf_alloc_die (cu, abbrev->num_attrs);
+  die->cu = cu;
   die->offset = offset;
   die->tag = abbrev->tag;
   die->abbrev = abbrev_number;
@@ -6581,7 +6596,7 @@ set_cu_language (unsigned int lang, stru
 /* Return the named attribute or NULL if not there.  */
 
 static struct attribute *
-dwarf2_attr (struct die_info *die, unsigned int name, struct dwarf2_cu *cu)
+dwarf2_attr (struct die_info *die, unsigned int name)
 {
   unsigned int i;
   struct attribute *spec = NULL;
@@ -6597,8 +6612,8 @@ dwarf2_attr (struct die_info *die, unsig
 
   if (spec)
     {
-      die = follow_die_ref (die, spec, &cu);
-      return dwarf2_attr (die, name, cu);
+      die = follow_die_ref (die, spec);
+      return dwarf2_attr (die, name);
     }
 
   return NULL;
@@ -6609,15 +6624,15 @@ dwarf2_attr (struct die_info *die, unsig
    DW_FORM_flag attributes.  */
 
 static int
-dwarf2_flag_true_p (struct die_info *die, unsigned name, struct dwarf2_cu *cu)
+dwarf2_flag_true_p (struct die_info *die, unsigned name)
 {
-  struct attribute *attr = dwarf2_attr (die, name, cu);
+  struct attribute *attr = dwarf2_attr (die, name);
 
   return (attr && DW_UNSND (attr));
 }
 
 static int
-die_is_declaration (struct die_info *die, struct dwarf2_cu *cu)
+die_is_declaration (struct die_info *die)
 {
   /* A DIE is a declaration if it has a DW_AT_declaration attribute
      which value is non-zero.  However, we have to be careful with
@@ -6626,8 +6641,8 @@ die_is_declaration (struct die_info *die
      end up accidently finding a declaration attribute that belongs
      to a different DIE referenced by the specification attribute,
      even though the given DIE does not have a declaration attribute.  */
-  return (dwarf2_flag_true_p (die, DW_AT_declaration, cu)
-	  && dwarf2_attr (die, DW_AT_specification, cu) == NULL);
+  return (dwarf2_flag_true_p (die, DW_AT_declaration)
+	  && dwarf2_attr (die, DW_AT_specification) == NULL);
 }
 
 /* Return the die giving the specification for DIE, if there is
@@ -6635,15 +6650,14 @@ die_is_declaration (struct die_info *die
    containing the return value on output.  */
 
 static struct die_info *
-die_specification (struct die_info *die, struct dwarf2_cu **spec_cu)
+die_specification (struct die_info *die)
 {
-  struct attribute *spec_attr = dwarf2_attr (die, DW_AT_specification,
-					     *spec_cu);
+  struct attribute *spec_attr = dwarf2_attr (die, DW_AT_specification);
 
   if (spec_attr == NULL)
     return NULL;
   else
-    return follow_die_ref (die, spec_attr, spec_cu);
+    return follow_die_ref (die, spec_attr);
 }
 
 /* Free the line_header structure *LH, and any arrays and strings it
@@ -7308,8 +7322,9 @@ var_decode_location (struct attribute *a
    used the passed type.  */
 
 static struct symbol *
-new_symbol (struct die_info *die, struct type *type, struct dwarf2_cu *cu)
+new_symbol (struct die_info *die, struct type *type)
 {
+  struct dwarf2_cu *cu = die->cu;
   struct objfile *objfile = cu->objfile;
   struct gdbarch *gdbarch = get_objfile_arch (objfile);
   struct symbol *sym = NULL;
@@ -7321,7 +7336,7 @@ new_symbol (struct die_info *die, struct
   baseaddr = ANOFFSET (objfile->section_offsets, SECT_OFF_TEXT (objfile));
 
   if (die->tag != DW_TAG_namespace)
-    name = dwarf2_linkage_name (die, cu);
+    name = dwarf2_linkage_name (die);
   else
     name = TYPE_NAME (type);
 
@@ -7343,14 +7358,14 @@ new_symbol (struct die_info *die, struct
       if (type != NULL)
 	SYMBOL_TYPE (sym) = type;
       else
-	SYMBOL_TYPE (sym) = die_type (die, cu);
-      attr = dwarf2_attr (die, DW_AT_decl_line, cu);
+	SYMBOL_TYPE (sym) = die_type (die);
+      attr = dwarf2_attr (die, DW_AT_decl_line);
       if (attr)
 	{
 	  SYMBOL_LINE (sym) = DW_UNSND (attr);
 	}
 
-      attr = dwarf2_attr (die, DW_AT_decl_file, cu);
+      attr = dwarf2_attr (die, DW_AT_decl_file);
       if (attr)
 	{
 	  int file_index = DW_UNSND (attr);
@@ -7369,7 +7384,7 @@ new_symbol (struct die_info *die, struct
       switch (die->tag)
 	{
 	case DW_TAG_label:
-	  attr = dwarf2_attr (die, DW_AT_low_pc, cu);
+	  attr = dwarf2_attr (die, DW_AT_low_pc);
 	  if (attr)
 	    {
 	      SYMBOL_VALUE_ADDRESS (sym) = DW_ADDR (attr) + baseaddr;
@@ -7380,7 +7395,7 @@ new_symbol (struct die_info *die, struct
 	  /* SYMBOL_BLOCK_VALUE (sym) will be filled in later by
 	     finish_block.  */
 	  SYMBOL_CLASS (sym) = LOC_BLOCK;
-	  attr2 = dwarf2_attr (die, DW_AT_external, cu);
+	  attr2 = dwarf2_attr (die, DW_AT_external);
 	  if ((attr2 && (DW_UNSND (attr2) != 0))
               || cu->language == language_ada)
 	    {
@@ -7405,22 +7420,22 @@ new_symbol (struct die_info *die, struct
 	    SYMBOL_TYPE (sym)
 	      = builtin_type (gdbarch)->nodebug_data_symbol;
 
-	  attr = dwarf2_attr (die, DW_AT_const_value, cu);
+	  attr = dwarf2_attr (die, DW_AT_const_value);
 	  if (attr)
 	    {
 	      dwarf2_const_value (attr, sym, cu);
-	      attr2 = dwarf2_attr (die, DW_AT_external, cu);
+	      attr2 = dwarf2_attr (die, DW_AT_external);
 	      if (attr2 && (DW_UNSND (attr2) != 0))
 		add_symbol_to_list (sym, &global_symbols);
 	      else
 		add_symbol_to_list (sym, cu->list_in_scope);
 	      break;
 	    }
-	  attr = dwarf2_attr (die, DW_AT_location, cu);
+	  attr = dwarf2_attr (die, DW_AT_location);
 	  if (attr)
 	    {
 	      var_decode_location (attr, sym, cu);
-	      attr2 = dwarf2_attr (die, DW_AT_external, cu);
+	      attr2 = dwarf2_attr (die, DW_AT_external);
 	      if (attr2 && (DW_UNSND (attr2) != 0))
 		add_symbol_to_list (sym, &global_symbols);
 	      else
@@ -7434,9 +7449,9 @@ new_symbol (struct die_info *die, struct
 	         The address of the variable will then be determined from
 	         the minimal symbol table whenever the variable is
 	         referenced.  */
-	      attr2 = dwarf2_attr (die, DW_AT_external, cu);
+	      attr2 = dwarf2_attr (die, DW_AT_external);
 	      if (attr2 && (DW_UNSND (attr2) != 0)
-		  && dwarf2_attr (die, DW_AT_type, cu) != NULL)
+		  && dwarf2_attr (die, DW_AT_type) != NULL)
 		{
 		  SYMBOL_CLASS (sym) = LOC_UNRESOLVED;
 		  add_symbol_to_list (sym, &global_symbols);
@@ -7445,12 +7460,12 @@ new_symbol (struct die_info *die, struct
 	  break;
 	case DW_TAG_formal_parameter:
 	  SYMBOL_IS_ARGUMENT (sym) = 1;
-	  attr = dwarf2_attr (die, DW_AT_location, cu);
+	  attr = dwarf2_attr (die, DW_AT_location);
 	  if (attr)
 	    {
 	      var_decode_location (attr, sym, cu);
 	    }
-	  attr = dwarf2_attr (die, DW_AT_const_value, cu);
+	  attr = dwarf2_attr (die, DW_AT_const_value);
 	  if (attr)
 	    {
 	      dwarf2_const_value (attr, sym, cu);
@@ -7527,7 +7542,7 @@ new_symbol (struct die_info *die, struct
 	  }
 	  break;
 	case DW_TAG_typedef:
-	  SYMBOL_LINKAGE_NAME (sym) = (char *) dwarf2_full_name (die, cu);
+	  SYMBOL_LINKAGE_NAME (sym) = (char *) dwarf2_full_name (die);
 	  SYMBOL_CLASS (sym) = LOC_TYPEDEF;
 	  SYMBOL_DOMAIN (sym) = VAR_DOMAIN;
 	  add_symbol_to_list (sym, cu->list_in_scope);
@@ -7539,8 +7554,8 @@ new_symbol (struct die_info *die, struct
 	  add_symbol_to_list (sym, cu->list_in_scope);
 	  break;
 	case DW_TAG_enumerator:
-	  SYMBOL_LINKAGE_NAME (sym) = (char *) dwarf2_full_name (die, cu);
-	  attr = dwarf2_attr (die, DW_AT_const_value, cu);
+	  SYMBOL_LINKAGE_NAME (sym) = (char *) dwarf2_full_name (die);
+	  attr = dwarf2_attr (die, DW_AT_const_value);
 	  if (attr)
 	    {
 	      dwarf2_const_value (attr, sym, cu);
@@ -7577,7 +7592,7 @@ new_symbol (struct die_info *die, struct
 	 namespaces based on the demangled name.  */
       if (!processing_has_namespace_info
 	  && cu->language == language_cplus
-	  && dwarf2_attr (die, DW_AT_MIPS_linkage_name, cu) != NULL)
+	  && dwarf2_attr (die, DW_AT_MIPS_linkage_name) != NULL)
 	cp_scan_for_anonymous_namespaces (sym);
     }
   return (sym);
@@ -7695,23 +7710,24 @@ dwarf2_const_value_data (struct attribut
 /* Return the type of the die in question using its DW_AT_type attribute.  */
 
 static struct type *
-die_type (struct die_info *die, struct dwarf2_cu *cu)
+die_type (struct die_info *die)
 {
+  struct dwarf2_cu *cu = die->cu;
   struct gdbarch *gdbarch = get_objfile_arch (cu->objfile);
   struct type *type;
   struct attribute *type_attr;
   struct die_info *type_die;
 
-  type_attr = dwarf2_attr (die, DW_AT_type, cu);
+  type_attr = dwarf2_attr (die, DW_AT_type);
   if (!type_attr)
     {
       /* A missing DW_AT_type represents a void type.  */
       return builtin_type (gdbarch)->builtin_void;
     }
   else
-    type_die = follow_die_ref (die, type_attr, &cu);
+    type_die = follow_die_ref (die, type_attr);
 
-  type = tag_type_to_type (type_die, cu);
+  type = tag_type_to_type (type_die);
   if (!type)
     {
       dump_die (type_die);
@@ -7725,17 +7741,18 @@ die_type (struct die_info *die, struct d
    DW_AT_containing_type attribute.  */
 
 static struct type *
-die_containing_type (struct die_info *die, struct dwarf2_cu *cu)
+die_containing_type (struct die_info *die)
 {
+  struct dwarf2_cu *cu = die->cu;
   struct type *type = NULL;
   struct attribute *type_attr;
   struct die_info *type_die = NULL;
 
-  type_attr = dwarf2_attr (die, DW_AT_containing_type, cu);
+  type_attr = dwarf2_attr (die, DW_AT_containing_type);
   if (type_attr)
     {
-      type_die = follow_die_ref (die, type_attr, &cu);
-      type = tag_type_to_type (type_die, cu);
+      type_die = follow_die_ref (die, type_attr);
+      type = tag_type_to_type (type_die);
     }
   if (!type)
     {
@@ -7748,11 +7765,12 @@ die_containing_type (struct die_info *di
 }
 
 static struct type *
-tag_type_to_type (struct die_info *die, struct dwarf2_cu *cu)
+tag_type_to_type (struct die_info *die)
 {
+  struct dwarf2_cu *cu = die->cu;
   struct type *this_type;
 
-  this_type = read_type_die (die, cu);
+  this_type = read_type_die (die);
   if (!this_type)
     {
       dump_die (die);
@@ -7763,11 +7781,11 @@ tag_type_to_type (struct die_info *die, 
 }
 
 static struct type *
-read_type_die (struct die_info *die, struct dwarf2_cu *cu)
+read_type_die (struct die_info *die)
 {
   struct type *this_type;
 
-  this_type = get_die_type (die, cu);
+  this_type = get_die_type (die);
   if (this_type)
     return this_type;
 
@@ -7777,53 +7795,53 @@ read_type_die (struct die_info *die, str
     case DW_TAG_interface_type:
     case DW_TAG_structure_type:
     case DW_TAG_union_type:
-      this_type = read_structure_type (die, cu);
+      this_type = read_structure_type (die);
       break;
     case DW_TAG_enumeration_type:
-      this_type = read_enumeration_type (die, cu);
+      this_type = read_enumeration_type (die);
       break;
     case DW_TAG_subprogram:
     case DW_TAG_subroutine_type:
-      this_type = read_subroutine_type (die, cu);
+      this_type = read_subroutine_type (die);
       break;
     case DW_TAG_array_type:
-      this_type = read_array_type (die, cu);
+      this_type = read_array_type (die);
       break;
     case DW_TAG_set_type:
-      this_type = read_set_type (die, cu);
+      this_type = read_set_type (die);
       break;
     case DW_TAG_pointer_type:
-      this_type = read_tag_pointer_type (die, cu);
+      this_type = read_tag_pointer_type (die);
       break;
     case DW_TAG_ptr_to_member_type:
-      this_type = read_tag_ptr_to_member_type (die, cu);
+      this_type = read_tag_ptr_to_member_type (die);
       break;
     case DW_TAG_reference_type:
-      this_type = read_tag_reference_type (die, cu);
+      this_type = read_tag_reference_type (die);
       break;
     case DW_TAG_const_type:
-      this_type = read_tag_const_type (die, cu);
+      this_type = read_tag_const_type (die);
       break;
     case DW_TAG_volatile_type:
-      this_type = read_tag_volatile_type (die, cu);
+      this_type = read_tag_volatile_type (die);
       break;
     case DW_TAG_string_type:
-      this_type = read_tag_string_type (die, cu);
+      this_type = read_tag_string_type (die);
       break;
     case DW_TAG_typedef:
-      this_type = read_typedef (die, cu);
+      this_type = read_typedef (die);
       break;
     case DW_TAG_subrange_type:
-      this_type = read_subrange_type (die, cu);
+      this_type = read_subrange_type (die);
       break;
     case DW_TAG_base_type:
-      this_type = read_base_type (die, cu);
+      this_type = read_base_type (die);
       break;
     case DW_TAG_unspecified_type:
-      this_type = read_unspecified_type (die, cu);
+      this_type = read_unspecified_type (die);
       break;
     case DW_TAG_namespace:
-      this_type = read_namespace_type (die, cu);
+      this_type = read_namespace_type (die);
       break;
     default:
       complaint (&symfile_complaints, _("unexpected tag in read_type_die: '%s'"),
@@ -7850,8 +7868,9 @@ read_type_die (struct die_info *die, str
    then determine_prefix on foo's die will return "N::C".  */
 
 static char *
-determine_prefix (struct die_info *die, struct dwarf2_cu *cu)
+determine_prefix (struct die_info *die)
 {
+  struct dwarf2_cu *cu = die->cu;
   struct die_info *parent, *spec_die;
   struct dwarf2_cu *spec_cu;
   struct type *parent_type;
@@ -7880,15 +7899,11 @@ determine_prefix (struct die_info *die, 
      Thus, when processing die #4, we have to pretend that we're in
      the context of its DW_AT_specification, namely the contex of die
      #3.  */
-  spec_cu = cu;
-  spec_die = die_specification (die, &spec_cu);
+  spec_die = die_specification (die);
   if (spec_die == NULL)
     parent = die->parent;
   else
-    {
-      parent = spec_die->parent;
-      cu = spec_cu;
-    }
+    parent = spec_die->parent;
 
   if (parent == NULL)
     return "";
@@ -7896,14 +7911,14 @@ determine_prefix (struct die_info *die, 
     switch (parent->tag)
       {
       case DW_TAG_namespace:
-	parent_type = read_type_die (parent, cu);
+	parent_type = read_type_die (parent);
 	/* We give a name to even anonymous namespaces.  */
 	return TYPE_TAG_NAME (parent_type);
       case DW_TAG_class_type:
       case DW_TAG_interface_type:
       case DW_TAG_structure_type:
       case DW_TAG_union_type:
-	parent_type = read_type_die (parent, cu);
+	parent_type = read_type_die (parent);
 	if (TYPE_TAG_NAME (parent_type) != NULL)
 	  return TYPE_TAG_NAME (parent_type);
 	else
@@ -7912,7 +7927,7 @@ determine_prefix (struct die_info *die, 
 	     So it does not need a prefix.  */
 	  return "";
       default:
-	return determine_prefix (parent, cu);
+	return determine_prefix (parent);
       }
 }
 
@@ -7970,14 +7985,14 @@ sibling_die (struct die_info *die)
 /* Get linkage name of a die, return NULL if not found.  */
 
 static char *
-dwarf2_linkage_name (struct die_info *die, struct dwarf2_cu *cu)
+dwarf2_linkage_name (struct die_info *die)
 {
   struct attribute *attr;
 
-  attr = dwarf2_attr (die, DW_AT_MIPS_linkage_name, cu);
+  attr = dwarf2_attr (die, DW_AT_MIPS_linkage_name);
   if (attr && DW_STRING (attr))
     return DW_STRING (attr);
-  attr = dwarf2_attr (die, DW_AT_name, cu);
+  attr = dwarf2_attr (die, DW_AT_name);
   if (attr && DW_STRING (attr))
     return DW_STRING (attr);
   return NULL;
@@ -7986,30 +8001,29 @@ dwarf2_linkage_name (struct die_info *di
 /* Get name of a die, return NULL if not found.  */
 
 static char *
-dwarf2_name (struct die_info *die, struct dwarf2_cu *cu)
+dwarf2_name (struct die_info *die)
 {
   struct attribute *attr;
 
-  attr = dwarf2_attr (die, DW_AT_name, cu);
+  attr = dwarf2_attr (die, DW_AT_name);
   if (attr && DW_STRING (attr))
     return DW_STRING (attr);
   return NULL;
 }
 
 /* Return the die that this die in an extension of, or NULL if there
-   is none.  *EXT_CU is the CU containing DIE on input, and the CU
-   containing the return value on output.  */
+   is none.  */
 
 static struct die_info *
-dwarf2_extension (struct die_info *die, struct dwarf2_cu **ext_cu)
+dwarf2_extension (struct die_info *die)
 {
   struct attribute *attr;
 
-  attr = dwarf2_attr (die, DW_AT_extension, *ext_cu);
+  attr = dwarf2_attr (die, DW_AT_extension);
   if (attr == NULL)
     return NULL;
 
-  return follow_die_ref (die, attr, ext_cu);
+  return follow_die_ref (die, attr);
 }
 
 /* Convert a DIE tag into its string name.  */
@@ -9054,8 +9068,9 @@ dump_die_list (struct die_info *die)
 }
 
 static void
-store_in_ref_table (struct die_info *die, struct dwarf2_cu *cu)
+store_in_ref_table (struct die_info *die)
 {
+  struct dwarf2_cu *cu = die->cu;
   void **slot;
 
   slot = htab_find_slot_with_hash (cu->die_hash, die, die->offset, INSERT);
@@ -9136,13 +9151,12 @@ maybe_queue_comp_unit (struct dwarf2_cu 
 }
 
 static struct die_info *
-follow_die_ref (struct die_info *src_die, struct attribute *attr,
-		struct dwarf2_cu **ref_cu)
+follow_die_ref (struct die_info *src_die, struct attribute *attr)
 {
   struct die_info *die;
   unsigned int offset;
   struct die_info temp_die;
-  struct dwarf2_cu *target_cu, *cu = *ref_cu;
+  struct dwarf2_cu *target_cu, *cu = src_die->cu;
 
   offset = dwarf2_get_ref_die_offset (attr, cu);
 
@@ -9161,7 +9175,6 @@ follow_die_ref (struct die_info *src_die
   else
     target_cu = cu;
 
-  *ref_cu = target_cu;
   temp_die.offset = offset;
   die = htab_find_with_hash (target_cu->die_hash, &temp_die, offset);
   if (die)
@@ -10217,12 +10230,13 @@ offset_and_type_eq (const void *item_lhs
   return ofs_lhs->offset == ofs_rhs->offset;
 }
 
-/* Set the type associated with DIE to TYPE.  Save it in CU's hash
+/* Set the type associated with DIE to TYPE.  Save it in the DIE's CU's hash
    table if necessary.  For convenience, return TYPE.  */
 
 static struct type *
-set_die_type (struct die_info *die, struct type *type, struct dwarf2_cu *cu)
+set_die_type (struct die_info *die, struct type *type)
 {
+  struct dwarf2_cu *cu = die->cu;
   struct dwarf2_offset_and_type **slot, ofs;
 
   if (cu->type_hash == NULL)
@@ -10252,8 +10266,9 @@ set_die_type (struct die_info *die, stru
    not have a saved type.  */
 
 static struct type *
-get_die_type (struct die_info *die, struct dwarf2_cu *cu)
+get_die_type (struct die_info *die)
 {
+  struct dwarf2_cu *cu = die->cu;
   struct dwarf2_offset_and_type *slot, ofs;
   htab_t type_hash = cu->type_hash;
 


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]