gdb/
[deliverable/binutils-gdb.git] / gdb / dwarf2read.c
index e2088f139d9d91f63f9856d5c8ee7c79214b77e7..7a58c455a9b8f76f78fdba2919a7760802ecefcd 100644 (file)
@@ -1284,8 +1284,8 @@ static void add_partial_subprogram (struct partial_die_info *pdi,
                                    CORE_ADDR *lowpc, CORE_ADDR *highpc,
                                    int need_pc, struct dwarf2_cu *cu);
 
-static void dwarf2_psymtab_to_symtab (struct objfile *,
-                                     struct partial_symtab *);
+static void dwarf2_read_symtab (struct partial_symtab *,
+                               struct objfile *);
 
 static void psymtab_to_symtab_1 (struct partial_symtab *);
 
@@ -2814,40 +2814,6 @@ dw2_setup (struct objfile *objfile)
   gdb_assert (dwarf2_per_objfile);
 }
 
-/* Reader function for dw2_build_type_unit_groups.  */
-
-static void
-dw2_build_type_unit_groups_reader (const struct die_reader_specs *reader,
-                                  gdb_byte *info_ptr,
-                                  struct die_info *type_unit_die,
-                                  int has_children,
-                                  void *data)
-{
-  struct dwarf2_cu *cu = reader->cu;
-  struct attribute *attr;
-  struct type_unit_group *tu_group;
-
-  gdb_assert (data == NULL);
-
-  if (! has_children)
-    return;
-
-  attr = dwarf2_attr_no_follow (type_unit_die, DW_AT_stmt_list);
-  /* Call this for its side-effect of creating the associated
-     struct type_unit_group if it doesn't already exist.  */
-  tu_group = get_type_unit_group (cu, attr);
-}
-
-/* Build dwarf2_per_objfile->type_unit_groups.
-   This function may be called multiple times.  */
-
-static void
-dw2_build_type_unit_groups (void)
-{
-  if (dwarf2_per_objfile->type_unit_groups == NULL)
-    build_type_unit_groups (dw2_build_type_unit_groups_reader, NULL);
-}
-
 /* die_reader_func for dw2_get_file_names.  */
 
 static void
@@ -3072,10 +3038,10 @@ dw2_map_symtabs_matching_filename (struct objfile *objfile, const char *name,
 
   dw2_setup (objfile);
 
-  dw2_build_type_unit_groups ();
+  /* The rule is CUs specify all the files, including those used by
+     any TU, so there's no need to scan TUs here.  */
 
-  for (i = 0; i < (dwarf2_per_objfile->n_comp_units
-                  + dwarf2_per_objfile->n_type_unit_groups); ++i)
+  for (i = 0; i < dwarf2_per_objfile->n_comp_units; ++i)
     {
       int j;
       struct dwarf2_per_cu_data *per_cu = dw2_get_primary_cu (i);
@@ -3528,8 +3494,6 @@ dw2_expand_symtabs_matching
       struct cleanup *cleanup;
       htab_t visited_found, visited_not_found;
 
-      dw2_build_type_unit_groups ();
-
       visited_found = htab_create_alloc (10,
                                         htab_hash_pointer, htab_eq_pointer,
                                         NULL, xcalloc, xfree);
@@ -3539,8 +3503,10 @@ dw2_expand_symtabs_matching
                                             NULL, xcalloc, xfree);
       make_cleanup_htab_delete (visited_not_found);
 
-      for (i = 0; i < (dwarf2_per_objfile->n_comp_units
-                      + dwarf2_per_objfile->n_type_unit_groups); ++i)
+      /* The rule is CUs specify all the files, including those used by
+        any TU, so there's no need to scan TUs here.  */
+
+      for (i = 0; i < dwarf2_per_objfile->n_comp_units; ++i)
        {
          int j;
          struct dwarf2_per_cu_data *per_cu = dw2_get_primary_cu (i);
@@ -3713,11 +3679,11 @@ dw2_map_symbol_filenames (struct objfile *objfile, symbol_filename_ftype *fun,
   cleanup = make_cleanup_htab_delete (visited);
   dw2_setup (objfile);
 
-  dw2_build_type_unit_groups ();
+  /* The rule is CUs specify all the files, including those used by
+     any TU, so there's no need to scan TUs here.
+     We can ignore file names coming from already-expanded CUs.  */
 
-  /* We can ignore file names coming from already-expanded CUs.  */
-  for (i = 0; i < (dwarf2_per_objfile->n_comp_units
-                  + dwarf2_per_objfile->n_type_units); ++i)
+  for (i = 0; i < dwarf2_per_objfile->n_comp_units; ++i)
     {
       struct dwarf2_per_cu_data *per_cu = dw2_get_cu (i);
 
@@ -3730,8 +3696,7 @@ dw2_map_symbol_filenames (struct objfile *objfile, symbol_filename_ftype *fun,
        }
     }
 
-  for (i = 0; i < (dwarf2_per_objfile->n_comp_units
-                  + dwarf2_per_objfile->n_type_unit_groups); ++i)
+  for (i = 0; i < dwarf2_per_objfile->n_comp_units; ++i)
     {
       int j;
       struct dwarf2_per_cu_data *per_cu = dw2_get_primary_cu (i);
@@ -3843,12 +3808,25 @@ dwarf2_initialize_objfile (struct objfile *objfile)
 void
 dwarf2_build_psymtabs (struct objfile *objfile)
 {
+  volatile struct gdb_exception except;
+
   if (objfile->global_psymbols.size == 0 && objfile->static_psymbols.size == 0)
     {
       init_psymbol_list (objfile, 1024);
     }
 
-  dwarf2_build_psymtabs_hard (objfile);
+  TRY_CATCH (except, RETURN_MASK_ERROR)
+    {
+      /* This isn't really ideal: all the data we allocate on the
+        objfile's obstack is still uselessly kept around.  However,
+        freeing it seems unsafe.  */
+      struct cleanup *cleanups = make_cleanup_discard_psymtabs (objfile);
+
+      dwarf2_build_psymtabs_hard (objfile);
+      discard_cleanups (cleanups);
+    }
+  if (except.reason < 0)
+    exception_print (gdb_stderr, except);
 }
 
 /* Return the total length of the CU described by HEADER.  */
@@ -4877,7 +4855,7 @@ create_partial_symtab (struct dwarf2_per_cu_data *per_cu, const char *name)
 
   /* This is the glue that links PST into GDB's symbol API.  */
   pst->read_symtab_private = per_cu;
-  pst->read_symtab = dwarf2_psymtab_to_symtab;
+  pst->read_symtab = dwarf2_read_symtab;
   per_cu->v.psymtab = pst;
 
   return pst;
@@ -6405,52 +6383,51 @@ locate_pdi_sibling (const struct die_reader_specs *reader,
   return skip_children (reader, info_ptr);
 }
 
-/* Expand this partial symbol table into a full symbol table.  */
+/* Expand this partial symbol table into a full symbol table.  SELF is
+   not NULL.  */
 
 static void
-dwarf2_psymtab_to_symtab (struct objfile *objfile, struct partial_symtab *pst)
+dwarf2_read_symtab (struct partial_symtab *self,
+                   struct objfile *objfile)
 {
-  if (pst != NULL)
+  if (self->readin)
     {
-      if (pst->readin)
+      warning (_("bug: psymtab for %s is already read in."),
+              self->filename);
+    }
+  else
+    {
+      if (info_verbose)
        {
-         warning (_("bug: psymtab for %s is already read in."),
-                  pst->filename);
+         printf_filtered (_("Reading in symbols for %s..."),
+                          self->filename);
+         gdb_flush (gdb_stdout);
        }
-      else
-       {
-         if (info_verbose)
-           {
-             printf_filtered (_("Reading in symbols for %s..."),
-                              pst->filename);
-             gdb_flush (gdb_stdout);
-           }
 
-         /* Restore our global data.  */
-         dwarf2_per_objfile = objfile_data (objfile, dwarf2_objfile_data_key);
+      /* Restore our global data.  */
+      dwarf2_per_objfile = objfile_data (objfile, dwarf2_objfile_data_key);
 
-         /* If this psymtab is constructed from a debug-only objfile, the
-            has_section_at_zero flag will not necessarily be correct.  We
-            can get the correct value for this flag by looking at the data
-            associated with the (presumably stripped) associated objfile.  */
-         if (objfile->separate_debug_objfile_backlink)
-           {
-             struct dwarf2_per_objfile *dpo_backlink
-               = objfile_data (objfile->separate_debug_objfile_backlink,
-                               dwarf2_objfile_data_key);
+      /* If this psymtab is constructed from a debug-only objfile, the
+        has_section_at_zero flag will not necessarily be correct.  We
+        can get the correct value for this flag by looking at the data
+        associated with the (presumably stripped) associated objfile.  */
+      if (objfile->separate_debug_objfile_backlink)
+       {
+         struct dwarf2_per_objfile *dpo_backlink
+           = objfile_data (objfile->separate_debug_objfile_backlink,
+                           dwarf2_objfile_data_key);
 
-             dwarf2_per_objfile->has_section_at_zero
-               = dpo_backlink->has_section_at_zero;
-           }
+         dwarf2_per_objfile->has_section_at_zero
+           = dpo_backlink->has_section_at_zero;
+       }
 
-         dwarf2_per_objfile->reading_partial_symbols = 0;
+      dwarf2_per_objfile->reading_partial_symbols = 0;
 
-         psymtab_to_symtab_1 (pst);
+      psymtab_to_symtab_1 (self);
 
-         /* Finish up the debug error message.  */
-         if (info_verbose)
-           printf_filtered (_("done.\n"));
-       }
+      /* Finish up the debug error message.  */
+      if (info_verbose)
+       printf_filtered (_("done.\n"));
     }
 
   process_cu_includes ();
@@ -12372,6 +12349,24 @@ read_tag_volatile_type (struct die_info *die, struct dwarf2_cu *cu)
   return set_die_type (die, cv_type, cu);
 }
 
+/* Handle DW_TAG_restrict_type.  */
+
+static struct type *
+read_tag_restrict_type (struct die_info *die, struct dwarf2_cu *cu)
+{
+  struct type *base_type, *cv_type;
+
+  base_type = die_type (die, cu);
+
+  /* The die_type call above may have already set the type for this DIE.  */
+  cv_type = get_die_type (die, cu);
+  if (cv_type)
+    return cv_type;
+
+  cv_type = make_restrict_type (base_type);
+  return set_die_type (die, cv_type, cu);
+}
+
 /* Extract all information from a DW_TAG_string_type DIE and add to
    the user defined type vector.  It isn't really a user defined type,
    but it behaves like one, with other DIE's using an AT_user_def_type
@@ -15132,7 +15127,9 @@ dwarf_decode_line_header (unsigned int offset, struct dwarf2_cu *cu)
    in line header LH of PST.
    COMP_DIR is the compilation directory (DW_AT_comp_dir) or NULL if unknown.
    If space for the result is malloc'd, it will be freed by a cleanup.
-   Returns NULL if FILE_INDEX should be ignored, i.e., it is pst->filename.  */
+   Returns NULL if FILE_INDEX should be ignored, i.e., it is pst->filename.
+
+   The function creates dangling cleanup registration.  */
 
 static char *
 psymtab_include_file_name (const struct line_header *lh, int file_index,
@@ -16537,6 +16534,9 @@ read_type_die_1 (struct die_info *die, struct dwarf2_cu *cu)
     case DW_TAG_volatile_type:
       this_type = read_tag_volatile_type (die, cu);
       break;
+    case DW_TAG_restrict_type:
+      this_type = read_tag_restrict_type (die, cu);
+      break;
     case DW_TAG_string_type:
       this_type = read_tag_string_type (die, cu);
       break;
This page took 0.03524 seconds and 4 git commands to generate.