Remove deprecated_throw_reason.
[deliverable/binutils-gdb.git] / gdb / dwarf2read.c
index 62e42ca19fe704aa70e023d0238b5f63fbbaafc4..d18eaed51e05e6c76710e71d64188083af3d033f 100644 (file)
@@ -1452,10 +1452,10 @@ static struct symbol *new_symbol (struct die_info *, struct type *,
 static struct symbol *new_symbol_full (struct die_info *, struct type *,
                                       struct dwarf2_cu *, struct symbol *);
 
-static void dwarf2_const_value (struct attribute *, struct symbol *,
+static void dwarf2_const_value (const struct attribute *, struct symbol *,
                                struct dwarf2_cu *);
 
-static void dwarf2_const_value_attr (struct attribute *attr,
+static void dwarf2_const_value_attr (const struct attribute *attr,
                                     struct type *type,
                                     const char *name,
                                     struct obstack *obstack,
@@ -1476,7 +1476,7 @@ static void set_descriptive_type (struct type *, struct die_info *,
 static struct type *die_containing_type (struct die_info *,
                                         struct dwarf2_cu *);
 
-static struct type *lookup_die_type (struct die_info *, struct attribute *,
+static struct type *lookup_die_type (struct die_info *, const struct attribute *,
                                     struct dwarf2_cu *);
 
 static struct type *read_type_die (struct die_info *, struct dwarf2_cu *);
@@ -1608,29 +1608,27 @@ static void dump_die_1 (struct ui_file *, int level, int max_level,
 static void store_in_ref_table (struct die_info *,
                                struct dwarf2_cu *);
 
-static int is_ref_attr (struct attribute *);
+static sect_offset dwarf2_get_ref_die_offset (const struct attribute *);
 
-static sect_offset dwarf2_get_ref_die_offset (struct attribute *);
-
-static LONGEST dwarf2_get_attr_constant_value (struct attribute *, int);
+static LONGEST dwarf2_get_attr_constant_value (const struct attribute *, int);
 
 static struct die_info *follow_die_ref_or_sig (struct die_info *,
-                                              struct attribute *,
+                                              const struct attribute *,
                                               struct dwarf2_cu **);
 
 static struct die_info *follow_die_ref (struct die_info *,
-                                       struct attribute *,
+                                       const struct attribute *,
                                        struct dwarf2_cu **);
 
 static struct die_info *follow_die_sig (struct die_info *,
-                                       struct attribute *,
+                                       const struct attribute *,
                                        struct dwarf2_cu **);
 
 static struct type *get_signatured_type (struct die_info *, ULONGEST,
                                         struct dwarf2_cu *);
 
 static struct type *get_DW_AT_signature_type (struct die_info *,
-                                             struct attribute *,
+                                             const struct attribute *,
                                              struct dwarf2_cu *);
 
 static void load_full_type_unit (struct dwarf2_per_cu_data *per_cu);
@@ -1638,7 +1636,7 @@ static void load_full_type_unit (struct dwarf2_per_cu_data *per_cu);
 static void read_signatured_type (struct signatured_type *);
 
 static struct type_unit_group *get_type_unit_group
-    (struct dwarf2_cu *, struct attribute *);
+    (struct dwarf2_cu *, const struct attribute *);
 
 static void build_type_unit_groups (die_reader_func_ftype *, void *);
 
@@ -1651,17 +1649,19 @@ static struct die_info *dwarf_alloc_die (struct dwarf2_cu *, int);
 static void dwarf_decode_macros (struct dwarf2_cu *, unsigned int,
                                 const char *, int);
 
-static int attr_form_is_block (struct attribute *);
+static int attr_form_is_block (const struct attribute *);
+
+static int attr_form_is_section_offset (const struct attribute *);
 
-static int attr_form_is_section_offset (struct attribute *);
+static int attr_form_is_constant (const struct attribute *);
 
-static int attr_form_is_constant (struct attribute *);
+static int attr_form_is_ref (const struct attribute *);
 
 static void fill_in_loclist_baton (struct dwarf2_cu *cu,
                                   struct dwarf2_loclist_baton *baton,
-                                  struct attribute *attr);
+                                  const struct attribute *attr);
 
-static void dwarf2_symbol_mark_computed (struct attribute *attr,
+static void dwarf2_symbol_mark_computed (const struct attribute *attr,
                                         struct symbol *sym,
                                         struct dwarf2_cu *cu,
                                         int is_block);
@@ -5414,7 +5414,7 @@ create_type_unit_group (struct dwarf2_cu *cu, sect_offset line_offset_struct)
    STMT_LIST is a DW_AT_stmt_list attribute.  */
 
 static struct type_unit_group *
-get_type_unit_group (struct dwarf2_cu *cu, struct attribute *stmt_list)
+get_type_unit_group (struct dwarf2_cu *cu, const struct attribute *stmt_list)
 {
   struct tu_stats *tu_stats = &dwarf2_per_objfile->tu_stats;
   struct type_unit_group *tu_group;
@@ -7028,14 +7028,21 @@ process_queue (void)
          : (item->per_cu->v.psymtab && !item->per_cu->v.psymtab->readin))
        {
          struct dwarf2_per_cu_data *per_cu = item->per_cu;
+         char buf[100];
 
-         if (dwarf2_read_debug)
+         if (per_cu->is_debug_types)
            {
-             fprintf_unfiltered (gdb_stdlog,
-                                 "Expanding symtab of %s at offset 0x%x\n",
-                                 per_cu->is_debug_types ? "TU" : "CU",
-                                 per_cu->offset.sect_off);
+             struct signatured_type *sig_type =
+               (struct signatured_type *) per_cu;
+
+             sprintf (buf, "TU %s at offset 0x%x",
+                      hex_string (sig_type->signature), per_cu->offset.sect_off);
            }
+         else
+           sprintf (buf, "CU at offset 0x%x", per_cu->offset.sect_off);
+
+         if (dwarf2_read_debug)
+           fprintf_unfiltered (gdb_stdlog, "Expanding symtab of %s\n", buf);
 
          if (per_cu->is_debug_types)
            process_full_type_unit (per_cu, item->pretend_language);
@@ -7043,12 +7050,7 @@ process_queue (void)
            process_full_comp_unit (per_cu, item->pretend_language);
 
          if (dwarf2_read_debug)
-           {
-             fprintf_unfiltered (gdb_stdlog,
-                                 "Done expanding %s at offset 0x%x\n",
-                                 per_cu->is_debug_types ? "TU" : "CU",
-                                 per_cu->offset.sect_off);
-           }
+           fprintf_unfiltered (gdb_stdlog, "Done expanding %s\n", buf);
        }
 
       item->per_cu->queued = 0;
@@ -9783,12 +9785,13 @@ lookup_dwo_cutu (struct dwarf2_per_cu_data *this_unit,
                          kind, dwo_name, hex_string (signature));
     }
 
-  complaint (&symfile_complaints,
-            _("Could not find DWO %s %s(%s) referenced by %s at offset 0x%x"
-              " [in module %s]"),
-            kind, dwo_name, hex_string (signature),
-            this_unit->is_debug_types ? "TU" : "CU",
-            this_unit->offset.sect_off, objfile->name);
+  /* This is a warning and not a complaint because it can be caused by
+     pilot error (e.g., user accidentally deleting the DWO).  */
+  warning (_("Could not find DWO %s %s(%s) referenced by %s at offset 0x%x"
+            " [in module %s]"),
+          kind, dwo_name, hex_string (signature),
+          this_unit->is_debug_types ? "TU" : "CU",
+          this_unit->offset.sect_off, objfile->name);
   return NULL;
 }
 
@@ -10364,7 +10367,7 @@ read_call_site_scope (struct die_info *die, struct dwarf2_cu *cu)
 
       SET_FIELD_DWARF_BLOCK (call_site->target, dlbaton);
     }
-  else if (is_ref_attr (attr))
+  else if (attr_form_is_ref (attr))
     {
       struct dwarf2_cu *target_cu = cu;
       struct die_info *target_die;
@@ -10437,7 +10440,7 @@ read_call_site_scope (struct die_info *die, struct dwarf2_cu *cu)
 
       loc = dwarf2_attr (child_die, DW_AT_location, cu);
       origin = dwarf2_attr (child_die, DW_AT_abstract_origin, cu);
-      if (loc == NULL && origin != NULL && is_ref_attr (origin))
+      if (loc == NULL && origin != NULL && attr_form_is_ref (origin))
        {
          sect_offset offset;
 
@@ -13379,7 +13382,7 @@ read_subrange_type (struct die_info *die, struct dwarf2_cu *cu)
   attr = dwarf2_attr (die, DW_AT_upper_bound, cu);
   if (attr)
     {
-      if (attr_form_is_block (attr) || is_ref_attr (attr))
+      if (attr_form_is_block (attr) || attr_form_is_ref (attr))
         {
           /* GCC encodes arrays with unspecified or dynamic length
              with a DW_FORM_block1 attribute or a reference attribute.
@@ -14820,7 +14823,7 @@ read_attribute_value (const struct die_reader_specs *reader,
     }
 
   /* Super hack.  */
-  if (cu->per_cu->is_dwz && is_ref_attr (attr))
+  if (cu->per_cu->is_dwz && attr_form_is_ref (attr))
     attr->form = DW_FORM_GNU_ref_alt;
 
   /* We have seen instances where the compiler tried to emit a byte
@@ -15704,6 +15707,7 @@ dwarf_decode_line_header (unsigned int offset, struct dwarf2_cu *cu)
   if (line_ptr + lh->total_length > (section->buffer + section->size))
     {
       dwarf2_statement_list_fits_in_line_number_section_complaint ();
+      do_cleanups (back_to);
       return 0;
     }
   lh->statement_program_end = line_ptr + lh->total_length;
@@ -16784,7 +16788,7 @@ new_symbol (struct die_info *die, struct type *type, struct dwarf2_cu *cu)
    because that is the interpretation long in use by GCC.  */
 
 static gdb_byte *
-dwarf2_const_value_data (struct attribute *attr, struct obstack *obstack,
+dwarf2_const_value_data (const struct attribute *attr, struct obstack *obstack,
                         struct dwarf2_cu *cu, LONGEST *value, int bits)
 {
   struct objfile *objfile = cu->objfile;
@@ -16816,7 +16820,7 @@ dwarf2_const_value_data (struct attribute *attr, struct obstack *obstack,
    expression.  */
 
 static void
-dwarf2_const_value_attr (struct attribute *attr, struct type *type,
+dwarf2_const_value_attr (const struct attribute *attr, struct type *type,
                         const char *name, struct obstack *obstack,
                         struct dwarf2_cu *cu,
                         LONGEST *value, const gdb_byte **bytes,
@@ -16919,7 +16923,7 @@ dwarf2_const_value_attr (struct attribute *attr, struct type *type,
 /* Copy constant value from an attribute to a symbol.  */
 
 static void
-dwarf2_const_value (struct attribute *attr, struct symbol *sym,
+dwarf2_const_value (const struct attribute *attr, struct symbol *sym,
                    struct dwarf2_cu *cu)
 {
   struct objfile *objfile = cu->objfile;
@@ -17058,7 +17062,7 @@ build_error_marker_type (struct dwarf2_cu *cu, struct die_info *die)
    If there is no type substitute an error marker.  */
 
 static struct type *
-lookup_die_type (struct die_info *die, struct attribute *attr,
+lookup_die_type (struct die_info *die, const struct attribute *attr,
                 struct dwarf2_cu *cu)
 {
   struct objfile *objfile = cu->objfile;
@@ -17078,7 +17082,7 @@ lookup_die_type (struct die_info *die, struct attribute *attr,
       per_cu = dwarf2_find_containing_comp_unit (offset, 1, cu->objfile);
       this_type = get_die_type_at_offset (offset, per_cu);
     }
-  else if (is_ref_attr (attr))
+  else if (attr_form_is_ref (attr))
     {
       sect_offset offset = dwarf2_get_ref_die_offset (attr);
 
@@ -17107,7 +17111,7 @@ lookup_die_type (struct die_info *die, struct attribute *attr,
       struct die_info *type_die = NULL;
       struct dwarf2_cu *type_cu = cu;
 
-      if (is_ref_attr (attr))
+      if (attr_form_is_ref (attr))
        type_die = follow_die_ref (die, attr, &type_cu);
       if (type_die == NULL)
        return build_error_marker_type (cu, die);
@@ -17950,36 +17954,15 @@ store_in_ref_table (struct die_info *die, struct dwarf2_cu *cu)
   *slot = die;
 }
 
-/* DW_ADDR is always stored already as sect_offset; despite for the forms
-   besides DW_FORM_ref_addr it is stored as cu_offset in the DWARF file.  */
-
-static int
-is_ref_attr (struct attribute *attr)
-{
-  switch (attr->form)
-    {
-    case DW_FORM_ref_addr:
-    case DW_FORM_ref1:
-    case DW_FORM_ref2:
-    case DW_FORM_ref4:
-    case DW_FORM_ref8:
-    case DW_FORM_ref_udata:
-    case DW_FORM_GNU_ref_alt:
-      return 1;
-    default:
-      return 0;
-    }
-}
-
 /* Return DIE offset of ATTR.  Return 0 with complaint if ATTR is not of the
    required kind.  */
 
 static sect_offset
-dwarf2_get_ref_die_offset (struct attribute *attr)
+dwarf2_get_ref_die_offset (const struct attribute *attr)
 {
   sect_offset retval = { DW_UNSND (attr) };
 
-  if (is_ref_attr (attr))
+  if (attr_form_is_ref (attr))
     return retval;
 
   retval.sect_off = 0;
@@ -17993,7 +17976,7 @@ dwarf2_get_ref_die_offset (struct attribute *attr)
  * the value held by the attribute is not constant.  */
 
 static LONGEST
-dwarf2_get_attr_constant_value (struct attribute *attr, int default_value)
+dwarf2_get_attr_constant_value (const struct attribute *attr, int default_value)
 {
   if (attr->form == DW_FORM_sdata)
     return DW_SND (attr);
@@ -18017,12 +18000,12 @@ dwarf2_get_attr_constant_value (struct attribute *attr, int default_value)
    On exit *REF_CU is the CU of the result.  */
 
 static struct die_info *
-follow_die_ref_or_sig (struct die_info *src_die, struct attribute *attr,
+follow_die_ref_or_sig (struct die_info *src_die, const struct attribute *attr,
                       struct dwarf2_cu **ref_cu)
 {
   struct die_info *die;
 
-  if (is_ref_attr (attr))
+  if (attr_form_is_ref (attr))
     die = follow_die_ref (src_die, attr, ref_cu);
   else if (attr->form == DW_FORM_ref_sig8)
     die = follow_die_sig (src_die, attr, ref_cu);
@@ -18091,7 +18074,7 @@ follow_die_offset (sect_offset offset, int offset_in_dwz,
    On exit *REF_CU is the CU of the result.  */
 
 static struct die_info *
-follow_die_ref (struct die_info *src_die, struct attribute *attr,
+follow_die_ref (struct die_info *src_die, const struct attribute *attr,
                struct dwarf2_cu **ref_cu)
 {
   sect_offset offset = dwarf2_get_ref_die_offset (attr);
@@ -18403,7 +18386,7 @@ follow_die_sig_1 (struct die_info *src_die, struct signatured_type *sig_type,
    If the referenced type cannot be found an error is thrown.  */
 
 static struct die_info *
-follow_die_sig (struct die_info *src_die, struct attribute *attr,
+follow_die_sig (struct die_info *src_die, const struct attribute *attr,
                struct dwarf2_cu **ref_cu)
 {
   ULONGEST signature = DW_SIGNATURE (attr);
@@ -18501,11 +18484,11 @@ get_signatured_type (struct die_info *die, ULONGEST signature,
    reading in and processing the type unit if necessary.  */
 
 static struct type *
-get_DW_AT_signature_type (struct die_info *die, struct attribute *attr,
+get_DW_AT_signature_type (struct die_info *die, const struct attribute *attr,
                          struct dwarf2_cu *cu) /* ARI: editCase function */
 {
   /* Yes, DW_AT_signature can use a non-ref_sig8 reference.  */
-  if (is_ref_attr (attr))
+  if (attr_form_is_ref (attr))
     {
       struct dwarf2_cu *type_cu = cu;
       struct die_info *type_die = follow_die_ref (die, attr, &type_cu);
@@ -19816,7 +19799,7 @@ dwarf_decode_macros (struct dwarf2_cu *cu, unsigned int offset,
    if so return true else false.  */
 
 static int
-attr_form_is_block (struct attribute *attr)
+attr_form_is_block (const struct attribute *attr)
 {
   return (attr == NULL ? 0 :
       attr->form == DW_FORM_block1
@@ -19836,7 +19819,7 @@ attr_form_is_block (struct attribute *attr)
    of them.  */
 
 static int
-attr_form_is_section_offset (struct attribute *attr)
+attr_form_is_section_offset (const struct attribute *attr)
 {
   return (attr->form == DW_FORM_data4
           || attr->form == DW_FORM_data8
@@ -19857,7 +19840,7 @@ attr_form_is_section_offset (struct attribute *attr)
    taken as section offsets, not constants.  */
 
 static int
-attr_form_is_constant (struct attribute *attr)
+attr_form_is_constant (const struct attribute *attr)
 {
   switch (attr->form)
     {
@@ -19873,6 +19856,28 @@ attr_form_is_constant (struct attribute *attr)
     }
 }
 
+
+/* DW_ADDR is always stored already as sect_offset; despite for the forms
+   besides DW_FORM_ref_addr it is stored as cu_offset in the DWARF file.  */
+
+static int
+attr_form_is_ref (const struct attribute *attr)
+{
+  switch (attr->form)
+    {
+    case DW_FORM_ref_addr:
+    case DW_FORM_ref1:
+    case DW_FORM_ref2:
+    case DW_FORM_ref4:
+    case DW_FORM_ref8:
+    case DW_FORM_ref_udata:
+    case DW_FORM_GNU_ref_alt:
+      return 1;
+    default:
+      return 0;
+    }
+}
+
 /* Return the .debug_loc section to use for CU.
    For DWO files use .debug_loc.dwo.  */
 
@@ -19889,7 +19894,7 @@ cu_debug_loc_section (struct dwarf2_cu *cu)
 static void
 fill_in_loclist_baton (struct dwarf2_cu *cu,
                       struct dwarf2_loclist_baton *baton,
-                      struct attribute *attr)
+                      const struct attribute *attr)
 {
   struct dwarf2_section_info *section = cu_debug_loc_section (cu);
 
@@ -19906,7 +19911,7 @@ fill_in_loclist_baton (struct dwarf2_cu *cu,
 }
 
 static void
-dwarf2_symbol_mark_computed (struct attribute *attr, struct symbol *sym,
+dwarf2_symbol_mark_computed (const struct attribute *attr, struct symbol *sym,
                             struct dwarf2_cu *cu, int is_block)
 {
   struct objfile *objfile = dwarf2_per_objfile->objfile;
@@ -20546,6 +20551,10 @@ dwarf2_per_objfile_free (struct objfile *objfile, void *d)
   struct dwarf2_per_objfile *data = d;
   int ix;
 
+  /* Make sure we don't accidentally use dwarf2_per_objfile while
+     cleaning up.  */
+  dwarf2_per_objfile = NULL;
+
   for (ix = 0; ix < data->n_comp_units; ++ix)
    VEC_free (dwarf2_per_cu_ptr, data->all_comp_units[ix]->imported_symtabs);
 
This page took 0.045876 seconds and 4 git commands to generate.