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 *);
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
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);
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);
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);
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);
}
}
- 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);
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. */
/* 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;
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 ();
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
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,
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;