/* The number of .debug_types-related CUs. */
int n_type_units;
+ /* The number of elements allocated in all_type_units.
+ If there are skeleton-less TUs, we add them to all_type_units lazily. */
+ int n_allocated_type_units;
+
/* The .debug_types-related CUs (TUs).
This is stored in malloc space because we may realloc it. */
struct signatured_type **all_type_units;
- /* The number of entries in all_type_unit_groups. */
- int n_type_unit_groups;
-
- /* Table of type unit groups.
- This exists to make it easy to iterate over all CUs and TU groups. */
- struct type_unit_group **all_type_unit_groups;
-
/* Table of struct type_unit_group objects.
The hash key is the DW_AT_stmt_list value. */
htab_t type_unit_groups;
int nr_symtabs;
int nr_symtab_sharers;
int nr_stmt_less_type_units;
+ int nr_all_type_units_reallocs;
} tu_stats;
/* A chain of compilation units that are currently read in, so that
static void read_signatured_type (struct signatured_type *);
-static struct type_unit_group *get_type_unit_group
- (struct dwarf2_cu *, const struct attribute *);
-
-static void build_type_unit_groups (die_reader_func_ftype *, void *);
-
/* memory allocation interface */
static struct dwarf_block *dwarf_alloc_block (struct dwarf2_cu *);
return per_cu->v.quick->symtab;
}
-/* Return the CU given its index.
+/* Return the CU/TU given its index.
This is intended for loops like:
for (i = 0; i < (dwarf2_per_objfile->n_comp_units
+ dwarf2_per_objfile->n_type_units); ++i)
{
- struct dwarf2_per_cu_data *per_cu = dw2_get_cu (i);
+ struct dwarf2_per_cu_data *per_cu = dw2_get_cutu (i);
...;
}
*/
static struct dwarf2_per_cu_data *
-dw2_get_cu (int index)
+dw2_get_cutu (int index)
{
if (index >= dwarf2_per_objfile->n_comp_units)
{
return dwarf2_per_objfile->all_comp_units[index];
}
-/* Return the primary CU given its index.
- The difference between this function and dw2_get_cu is in the handling
- of type units (TUs). Here we return the type_unit_group object.
-
- This is intended for loops like:
-
- for (i = 0; i < (dwarf2_per_objfile->n_comp_units
- + dwarf2_per_objfile->n_type_unit_groups); ++i)
- {
- struct dwarf2_per_cu_data *per_cu = dw2_get_primary_cu (i);
-
- ...;
- }
-*/
+/* Return the CU given its index.
+ This differs from dw2_get_cutu in that it's for when you know INDEX
+ refers to a CU. */
static struct dwarf2_per_cu_data *
-dw2_get_primary_cu (int index)
+dw2_get_cu (int index)
{
- if (index >= dwarf2_per_objfile->n_comp_units)
- {
- index -= dwarf2_per_objfile->n_comp_units;
- gdb_assert (index < dwarf2_per_objfile->n_type_unit_groups);
- return &dwarf2_per_objfile->all_type_unit_groups[index]->per_cu;
- }
+ gdb_assert (index >= 0 && index < dwarf2_per_objfile->n_comp_units);
return dwarf2_per_objfile->all_comp_units[index];
}
offset_type i;
htab_t sig_types_hash;
- dwarf2_per_objfile->n_type_units = elements / 3;
+ dwarf2_per_objfile->n_type_units
+ = dwarf2_per_objfile->n_allocated_type_units
+ = elements / 3;
dwarf2_per_objfile->all_type_units
= xmalloc (dwarf2_per_objfile->n_type_units
* sizeof (struct signatured_type *));
}
addrmap_set_empty (mutable_map, lo + baseaddr, hi + baseaddr - 1,
- dw2_get_cu (cu_index));
+ dw2_get_cutu (cu_index));
}
objfile->psymtabs_addrmap = addrmap_create_fixed (mutable_map,
dw2_setup (objfile);
index = dwarf2_per_objfile->n_comp_units - 1;
- return dw2_instantiate_symtab (dw2_get_cu (index));
+ return dw2_instantiate_symtab (dw2_get_cutu (index));
}
/* Traversal function for dw2_forget_cached_source_info. */
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 dwarf2_per_cu_data *per_cu = dw2_get_cu (i);
struct quick_file_names *file_data;
/* We only need to look at symtabs not already expanded. */
continue;
}
- per_cu = dw2_get_cu (cu_index);
+ per_cu = dw2_get_cutu (cu_index);
/* Skip if already read in. */
if (per_cu->v.quick->symtab)
count = 0;
for (i = 0; i < total; ++i)
{
- struct dwarf2_per_cu_data *per_cu = dw2_get_cu (i);
+ struct dwarf2_per_cu_data *per_cu = dw2_get_cutu (i);
if (!per_cu->v.quick->symtab)
++count;
for (i = 0; i < (dwarf2_per_objfile->n_comp_units
+ dwarf2_per_objfile->n_type_units); ++i)
{
- struct dwarf2_per_cu_data *per_cu = dw2_get_cu (i);
+ struct dwarf2_per_cu_data *per_cu = dw2_get_cutu (i);
dw2_instantiate_symtab (per_cu);
}
for (i = 0; i < dwarf2_per_objfile->n_comp_units; ++i)
{
int j;
- struct dwarf2_per_cu_data *per_cu = dw2_get_cu (i);
+ struct dwarf2_per_cu_data *per_cu = dw2_get_cutu (i);
struct quick_file_names *file_data;
/* We only need to look at symtabs not already expanded. */
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 dwarf2_per_cu_data *per_cu = dw2_get_cu (i);
struct quick_file_names *file_data;
void **slot;
continue;
}
- per_cu = dw2_get_cu (cu_index);
+ per_cu = dw2_get_cutu (cu_index);
if (file_matcher == NULL || per_cu->v.quick->mark)
dw2_instantiate_symtab (per_cu);
}
for (i = 0; i < dwarf2_per_objfile->n_comp_units; ++i)
{
- struct dwarf2_per_cu_data *per_cu = dw2_get_cu (i);
+ struct dwarf2_per_cu_data *per_cu = dw2_get_cutu (i);
if (per_cu->v.quick->symtab)
{
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 dwarf2_per_cu_data *per_cu = dw2_get_cu (i);
struct quick_file_names *file_data;
void **slot;
for (i = 0; i < (dwarf2_per_objfile->n_comp_units
+ dwarf2_per_objfile->n_type_units); ++i)
{
- struct dwarf2_per_cu_data *per_cu = dw2_get_cu (i);
+ struct dwarf2_per_cu_data *per_cu = dw2_get_cutu (i);
per_cu->v.quick = OBSTACK_ZALLOC (&objfile->objfile_obstack,
struct dwarf2_per_cu_quick_data);
dwarf2_per_objfile->signatured_types = types_htab;
- dwarf2_per_objfile->n_type_units = htab_elements (types_htab);
+ dwarf2_per_objfile->n_type_units
+ = dwarf2_per_objfile->n_allocated_type_units
+ = htab_elements (types_htab);
dwarf2_per_objfile->all_type_units
= xmalloc (dwarf2_per_objfile->n_type_units
* sizeof (struct signatured_type *));
return 1;
}
+/* Add an entry for signature SIG to dwarf2_per_objfile->signatured_types.
+ If SLOT is non-NULL, it is the entry to use in the hash table.
+ Otherwise we find one. */
+
+static struct signatured_type *
+add_type_unit (ULONGEST sig, void **slot)
+{
+ struct objfile *objfile = dwarf2_per_objfile->objfile;
+ int n_type_units = dwarf2_per_objfile->n_type_units;
+ struct signatured_type *sig_type;
+
+ gdb_assert (n_type_units <= dwarf2_per_objfile->n_allocated_type_units);
+ ++n_type_units;
+ if (n_type_units > dwarf2_per_objfile->n_allocated_type_units)
+ {
+ if (dwarf2_per_objfile->n_allocated_type_units == 0)
+ dwarf2_per_objfile->n_allocated_type_units = 1;
+ dwarf2_per_objfile->n_allocated_type_units *= 2;
+ dwarf2_per_objfile->all_type_units
+ = xrealloc (dwarf2_per_objfile->all_type_units,
+ dwarf2_per_objfile->n_allocated_type_units
+ * sizeof (struct signatured_type *));
+ ++dwarf2_per_objfile->tu_stats.nr_all_type_units_reallocs;
+ }
+ dwarf2_per_objfile->n_type_units = n_type_units;
+
+ sig_type = OBSTACK_ZALLOC (&objfile->objfile_obstack,
+ struct signatured_type);
+ dwarf2_per_objfile->all_type_units[n_type_units - 1] = sig_type;
+ sig_type->signature = sig;
+ sig_type->per_cu.is_debug_types = 1;
+ if (dwarf2_per_objfile->using_index)
+ {
+ sig_type->per_cu.v.quick =
+ OBSTACK_ZALLOC (&objfile->objfile_obstack,
+ struct dwarf2_per_cu_quick_data);
+ }
+
+ if (slot == NULL)
+ {
+ slot = htab_find_slot (dwarf2_per_objfile->signatured_types,
+ sig_type, INSERT);
+ }
+ gdb_assert (*slot == NULL);
+ *slot = sig_type;
+ /* The rest of sig_type must be filled in by the caller. */
+ return sig_type;
+}
+
/* Subroutine of lookup_dwo_signatured_type and lookup_dwp_signatured_type.
Fill in SIG_ENTRY with DWO_ENTRY. */
/* Make sure we're not clobbering something we don't expect to. */
gdb_assert (! sig_entry->per_cu.queued);
gdb_assert (sig_entry->per_cu.cu == NULL);
- gdb_assert (sig_entry->per_cu.v.quick != NULL);
- gdb_assert (sig_entry->per_cu.v.quick->symtab == NULL);
+ if (dwarf2_per_objfile->using_index)
+ {
+ gdb_assert (sig_entry->per_cu.v.quick != NULL);
+ gdb_assert (sig_entry->per_cu.v.quick->symtab == NULL);
+ }
+ else
+ gdb_assert (sig_entry->per_cu.v.psymtab == NULL);
gdb_assert (sig_entry->signature == dwo_entry->signature);
gdb_assert (sig_entry->type_offset_in_section.sect_off == 0);
gdb_assert (sig_entry->type_unit_group == NULL);
struct dwo_file *dwo_file;
struct dwo_unit find_dwo_entry, *dwo_entry;
struct signatured_type find_sig_entry, *sig_entry;
+ void **slot;
gdb_assert (cu->dwo_unit && dwarf2_per_objfile->using_index);
- /* Note: cu->dwo_unit is the dwo_unit that references this TU, not the
- dwo_unit of the TU itself. */
- dwo_file = cu->dwo_unit->dwo_file;
+ /* If TU skeletons have been removed then we may not have read in any
+ TUs yet. */
+ if (dwarf2_per_objfile->signatured_types == NULL)
+ {
+ dwarf2_per_objfile->signatured_types
+ = allocate_signatured_type_table (objfile);
+ }
/* We only ever need to read in one copy of a signatured type.
- Just use the global signatured_types array. If this is the first time
- we're reading this type, replace the recorded data from .gdb_index with
- this TU. */
+ Use the global signatured_types array to do our own comdat-folding
+ of types. If this is the first time we're reading this TU, and
+ the TU has an entry in .gdb_index, replace the recorded data from
+ .gdb_index with this TU. */
- if (dwarf2_per_objfile->signatured_types == NULL)
- return NULL;
find_sig_entry.signature = sig;
- sig_entry = htab_find (dwarf2_per_objfile->signatured_types, &find_sig_entry);
- if (sig_entry == NULL)
- return NULL;
+ slot = htab_find_slot (dwarf2_per_objfile->signatured_types,
+ &find_sig_entry, INSERT);
+ sig_entry = *slot;
/* We can get here with the TU already read, *or* in the process of being
- read. Don't reassign it if that's the case. Also note that if the TU is
- already being read, it may not have come from a DWO, the program may be
- a mix of Fission-compiled code and non-Fission-compiled code. */
- /* Have we already tried to read this TU? */
- if (sig_entry->per_cu.tu_read)
+ read. Don't reassign the global entry to point to this DWO if that's
+ the case. Also note that if the TU is already being read, it may not
+ have come from a DWO, the program may be a mix of Fission-compiled
+ code and non-Fission-compiled code. */
+
+ /* Have we already tried to read this TU?
+ Note: sig_entry can be NULL if the skeleton TU was removed (thus it
+ needn't exist in the global table yet). */
+ if (sig_entry != NULL && sig_entry->per_cu.tu_read)
return sig_entry;
+ /* Note: cu->dwo_unit is the dwo_unit that references this TU, not the
+ dwo_unit of the TU itself. */
+ dwo_file = cu->dwo_unit->dwo_file;
+
/* Ok, this is the first time we're reading this TU. */
if (dwo_file->tus == NULL)
return NULL;
if (dwo_entry == NULL)
return NULL;
+ /* If the global table doesn't have an entry for this TU, add one. */
+ if (sig_entry == NULL)
+ sig_entry = add_type_unit (sig, slot);
+
fill_in_sig_entry_from_dwo_entry (objfile, sig_entry, dwo_entry);
sig_entry->per_cu.tu_read = 1;
return sig_entry;
}
-/* Subroutine of lookup_dwp_signatured_type.
- Add an entry for signature SIG to dwarf2_per_objfile->signatured_types. */
-
-static struct signatured_type *
-add_type_unit (ULONGEST sig)
-{
- struct objfile *objfile = dwarf2_per_objfile->objfile;
- int n_type_units = dwarf2_per_objfile->n_type_units;
- struct signatured_type *sig_type;
- void **slot;
-
- ++n_type_units;
- dwarf2_per_objfile->all_type_units =
- xrealloc (dwarf2_per_objfile->all_type_units,
- n_type_units * sizeof (struct signatured_type *));
- dwarf2_per_objfile->n_type_units = n_type_units;
- sig_type = OBSTACK_ZALLOC (&objfile->objfile_obstack,
- struct signatured_type);
- dwarf2_per_objfile->all_type_units[n_type_units - 1] = sig_type;
- sig_type->signature = sig;
- sig_type->per_cu.is_debug_types = 1;
- sig_type->per_cu.v.quick =
- OBSTACK_ZALLOC (&objfile->objfile_obstack,
- struct dwarf2_per_cu_quick_data);
- slot = htab_find_slot (dwarf2_per_objfile->signatured_types,
- sig_type, INSERT);
- gdb_assert (*slot == NULL);
- *slot = sig_type;
- /* The rest of sig_type must be filled in by the caller. */
- return sig_type;
-}
-
/* Subroutine of lookup_signatured_type.
Look up the type for signature SIG, and if we can't find SIG in .gdb_index
- then try the DWP file.
- Normally this "can't happen", but if there's a bug in signature
- generation and/or the DWP file is built incorrectly, it can happen.
- Using the type directly from the DWP file means we don't have the stub
- which has some useful attributes (e.g., DW_AT_comp_dir), but they're
- not critical. [Eventually the stub may go away for type units anyway.] */
+ then try the DWP file. If the TU stub (skeleton) has been removed then
+ it won't be in .gdb_index. */
static struct signatured_type *
lookup_dwp_signatured_type (struct dwarf2_cu *cu, ULONGEST sig)
struct dwp_file *dwp_file = get_dwp_file ();
struct dwo_unit *dwo_entry;
struct signatured_type find_sig_entry, *sig_entry;
+ void **slot;
gdb_assert (cu->dwo_unit && dwarf2_per_objfile->using_index);
gdb_assert (dwp_file != NULL);
- if (dwarf2_per_objfile->signatured_types != NULL)
+ /* If TU skeletons have been removed then we may not have read in any
+ TUs yet. */
+ if (dwarf2_per_objfile->signatured_types == NULL)
{
- find_sig_entry.signature = sig;
- sig_entry = htab_find (dwarf2_per_objfile->signatured_types,
- &find_sig_entry);
- if (sig_entry != NULL)
- return sig_entry;
+ dwarf2_per_objfile->signatured_types
+ = allocate_signatured_type_table (objfile);
}
- /* This is the "shouldn't happen" case.
- Try the DWP file and hope for the best. */
+ find_sig_entry.signature = sig;
+ slot = htab_find_slot (dwarf2_per_objfile->signatured_types,
+ &find_sig_entry, INSERT);
+ sig_entry = *slot;
+
+ /* Have we already tried to read this TU?
+ Note: sig_entry can be NULL if the skeleton TU was removed (thus it
+ needn't exist in the global table yet). */
+ if (sig_entry != NULL)
+ return sig_entry;
+
if (dwp_file->tus == NULL)
return NULL;
dwo_entry = lookup_dwo_unit_in_dwp (dwp_file, NULL,
if (dwo_entry == NULL)
return NULL;
- sig_entry = add_type_unit (sig);
+ sig_entry = add_type_unit (sig, slot);
fill_in_sig_entry_from_dwo_entry (objfile, sig_entry, dwo_entry);
- /* The caller will signal a complaint if we return NULL.
- Here we don't return NULL but we still want to complain. */
- complaint (&symfile_complaints,
- _("Bad type signature %s referenced by %s at 0x%x,"
- " coping by using copy in DWP [in module %s]"),
- hex_string (sig),
- cu->per_cu->is_debug_types ? "TU" : "CU",
- cu->per_cu->offset.sect_off,
- objfile_name (objfile));
-
return sig_entry;
}
}
/* Subroutine of init_cutu_and_read_dies to simplify it.
- Read a TU directly from a DWO file, bypassing the stub. */
+ See it for a description of the parameters.
+ Read a TU directly from a DWO file, bypassing the stub.
+
+ Note: This function could be a little bit simpler if we shared cleanups
+ with our caller, init_cutu_and_read_dies. That's generally a fragile thing
+ to do, so we keep this function self-contained. Or we could move this
+ into our caller, but it's complex enough already. */
static void
-init_tu_and_read_dwo_dies (struct dwarf2_per_cu_data *this_cu, int keep,
+init_tu_and_read_dwo_dies (struct dwarf2_per_cu_data *this_cu,
+ int use_existing_cu, int keep,
die_reader_func_ftype *die_reader_func,
void *data)
{
struct dwarf2_cu *cu;
struct signatured_type *sig_type;
- struct cleanup *cleanups, *free_cu_cleanup;
+ struct cleanup *cleanups, *free_cu_cleanup = NULL;
struct die_reader_specs reader;
const gdb_byte *info_ptr;
struct die_info *comp_unit_die;
cleanups = make_cleanup (null_cleanup, NULL);
- gdb_assert (this_cu->cu == NULL);
- cu = xmalloc (sizeof (*cu));
- init_one_comp_unit (cu, this_cu);
- /* If an error occurs while loading, release our storage. */
- free_cu_cleanup = make_cleanup (free_heap_comp_unit, cu);
+ if (use_existing_cu && this_cu->cu != NULL)
+ {
+ gdb_assert (this_cu->cu->dwo_unit == sig_type->dwo_unit);
+ cu = this_cu->cu;
+ /* There's no need to do the rereading_dwo_cu handling that
+ init_cutu_and_read_dies does since we don't read the stub. */
+ }
+ else
+ {
+ /* If !use_existing_cu, this_cu->cu must be NULL. */
+ gdb_assert (this_cu->cu == NULL);
+ cu = xmalloc (sizeof (*cu));
+ init_one_comp_unit (cu, this_cu);
+ /* If an error occurs while loading, release our storage. */
+ free_cu_cleanup = make_cleanup (free_heap_comp_unit, cu);
+ }
+
+ /* A future optimization, if needed, would be to use an existing
+ abbrev table. When reading DWOs with skeletonless TUs, all the TUs
+ could share abbrev tables. */
if (read_cutu_die_from_dwo (this_cu, sig_type->dwo_unit,
0 /* abbrev_table_provided */,
/* All the "real" work is done here. */
die_reader_func (&reader, info_ptr, comp_unit_die, has_children, data);
- /* This duplicates some code in init_cutu_and_read_dies,
+ /* This duplicates the code in init_cutu_and_read_dies,
but the alternative is making the latter more complex.
This function is only for the special case of using DWO files directly:
no point in overly complicating the general case just to handle this. */
- if (keep)
+ if (free_cu_cleanup != NULL)
{
- /* We've successfully allocated this compilation unit. Let our
- caller clean it up when finished with it. */
- discard_cleanups (free_cu_cleanup);
+ if (keep)
+ {
+ /* We've successfully allocated this compilation unit. Let our
+ caller clean it up when finished with it. */
+ discard_cleanups (free_cu_cleanup);
- /* We can only discard free_cu_cleanup and all subsequent cleanups.
- So we have to manually free the abbrev table. */
- dwarf2_free_abbrev_table (cu);
+ /* We can only discard free_cu_cleanup and all subsequent cleanups.
+ So we have to manually free the abbrev table. */
+ dwarf2_free_abbrev_table (cu);
- /* Link this CU into read_in_chain. */
- this_cu->cu->read_in_chain = dwarf2_per_objfile->read_in_chain;
- dwarf2_per_objfile->read_in_chain = this_cu;
+ /* Link this CU into read_in_chain. */
+ this_cu->cu->read_in_chain = dwarf2_per_objfile->read_in_chain;
+ dwarf2_per_objfile->read_in_chain = this_cu;
+ }
+ else
+ do_cleanups (free_cu_cleanup);
}
- else
- do_cleanups (free_cu_cleanup);
do_cleanups (cleanups);
}
/* Narrow down the scope of possibilities to have to understand. */
gdb_assert (this_cu->is_debug_types);
gdb_assert (abbrev_table == NULL);
- gdb_assert (!use_existing_cu);
- init_tu_and_read_dwo_dies (this_cu, keep, die_reader_func, data);
+ init_tu_and_read_dwo_dies (this_cu, use_existing_cu, keep,
+ die_reader_func, data);
return;
}
if (use_existing_cu && this_cu->cu != NULL)
{
cu = this_cu->cu;
-
/* If this CU is from a DWO file we need to start over, we need to
refetch the attributes from the skeleton CU.
This could be optimized by retrieving those attributes from when we
{
/* If !use_existing_cu, this_cu->cu must be NULL. */
gdb_assert (this_cu->cu == NULL);
-
cu = xmalloc (sizeof (*cu));
init_one_comp_unit (cu, this_cu);
-
/* If an error occurs while loading, release our storage. */
free_cu_cleanup = make_cleanup (free_heap_comp_unit, cu);
}
if (*slot != NULL)
{
tu_group = *slot;
- gdb_assert (tu_group != NULL);
- }
- else
- {
- sect_offset line_offset_struct;
-
- line_offset_struct.sect_off = line_offset;
- tu_group = create_type_unit_group (cu, line_offset_struct);
- *slot = tu_group;
- ++tu_stats->nr_symtabs;
- }
-
- return tu_group;
-}
-
-/* Struct used to sort TUs by their abbreviation table offset. */
-
-struct tu_abbrev_offset
-{
- struct signatured_type *sig_type;
- sect_offset abbrev_offset;
-};
-
-/* Helper routine for build_type_unit_groups, passed to qsort. */
-
-static int
-sort_tu_by_abbrev_offset (const void *ap, const void *bp)
-{
- const struct tu_abbrev_offset * const *a = ap;
- const struct tu_abbrev_offset * const *b = bp;
- unsigned int aoff = (*a)->abbrev_offset.sect_off;
- unsigned int boff = (*b)->abbrev_offset.sect_off;
-
- return (aoff > boff) - (aoff < boff);
-}
-
-/* A helper function to add a type_unit_group to a table. */
-
-static int
-add_type_unit_group_to_table (void **slot, void *datum)
-{
- struct type_unit_group *tu_group = *slot;
- struct type_unit_group ***datap = datum;
-
- **datap = tu_group;
- ++*datap;
-
- return 1;
-}
-
-/* Efficiently read all the type units, calling init_cutu_and_read_dies on
- each one passing FUNC,DATA.
-
- The efficiency is because we sort TUs by the abbrev table they use and
- only read each abbrev table once. In one program there are 200K TUs
- sharing 8K abbrev tables.
-
- The main purpose of this function is to support building the
- dwarf2_per_objfile->type_unit_groups table.
- TUs typically share the DW_AT_stmt_list of the CU they came from, so we
- can collapse the search space by grouping them by stmt_list.
- The savings can be significant, in the same program from above the 200K TUs
- share 8K stmt_list tables.
-
- FUNC is expected to call get_type_unit_group, which will create the
- struct type_unit_group if necessary and add it to
- dwarf2_per_objfile->type_unit_groups. */
-
-static void
-build_type_unit_groups (die_reader_func_ftype *func, void *data)
-{
- struct objfile *objfile = dwarf2_per_objfile->objfile;
- struct tu_stats *tu_stats = &dwarf2_per_objfile->tu_stats;
- struct cleanup *cleanups;
- struct abbrev_table *abbrev_table;
- sect_offset abbrev_offset;
- struct tu_abbrev_offset *sorted_by_abbrev;
- struct type_unit_group **iter;
- int i;
-
- /* It's up to the caller to not call us multiple times. */
- gdb_assert (dwarf2_per_objfile->type_unit_groups == NULL);
-
- if (dwarf2_per_objfile->n_type_units == 0)
- return;
-
- /* TUs typically share abbrev tables, and there can be way more TUs than
- abbrev tables. Sort by abbrev table to reduce the number of times we
- read each abbrev table in.
- Alternatives are to punt or to maintain a cache of abbrev tables.
- This is simpler and efficient enough for now.
-
- Later we group TUs by their DW_AT_stmt_list value (as this defines the
- symtab to use). Typically TUs with the same abbrev offset have the same
- stmt_list value too so in practice this should work well.
-
- The basic algorithm here is:
-
- sort TUs by abbrev table
- for each TU with same abbrev table:
- read abbrev table if first user
- read TU top level DIE
- [IWBN if DWO skeletons had DW_AT_stmt_list]
- call FUNC */
-
- if (dwarf2_read_debug)
- fprintf_unfiltered (gdb_stdlog, "Building type unit groups ...\n");
-
- /* Sort in a separate table to maintain the order of all_type_units
- for .gdb_index: TU indices directly index all_type_units. */
- sorted_by_abbrev = XNEWVEC (struct tu_abbrev_offset,
- dwarf2_per_objfile->n_type_units);
- for (i = 0; i < dwarf2_per_objfile->n_type_units; ++i)
- {
- struct signatured_type *sig_type = dwarf2_per_objfile->all_type_units[i];
-
- sorted_by_abbrev[i].sig_type = sig_type;
- sorted_by_abbrev[i].abbrev_offset =
- read_abbrev_offset (sig_type->per_cu.section,
- sig_type->per_cu.offset);
- }
- cleanups = make_cleanup (xfree, sorted_by_abbrev);
- qsort (sorted_by_abbrev, dwarf2_per_objfile->n_type_units,
- sizeof (struct tu_abbrev_offset), sort_tu_by_abbrev_offset);
-
- /* Note: In the .gdb_index case, get_type_unit_group may have already been
- called any number of times, so we don't reset tu_stats here. */
-
- abbrev_offset.sect_off = ~(unsigned) 0;
- abbrev_table = NULL;
- make_cleanup (abbrev_table_free_cleanup, &abbrev_table);
-
- for (i = 0; i < dwarf2_per_objfile->n_type_units; ++i)
- {
- const struct tu_abbrev_offset *tu = &sorted_by_abbrev[i];
-
- /* Switch to the next abbrev table if necessary. */
- if (abbrev_table == NULL
- || tu->abbrev_offset.sect_off != abbrev_offset.sect_off)
- {
- if (abbrev_table != NULL)
- {
- abbrev_table_free (abbrev_table);
- /* Reset to NULL in case abbrev_table_read_table throws
- an error: abbrev_table_free_cleanup will get called. */
- abbrev_table = NULL;
- }
- abbrev_offset = tu->abbrev_offset;
- abbrev_table =
- abbrev_table_read_table (&dwarf2_per_objfile->abbrev,
- abbrev_offset);
- ++tu_stats->nr_uniq_abbrev_tables;
- }
-
- init_cutu_and_read_dies (&tu->sig_type->per_cu, abbrev_table, 0, 0,
- func, data);
- }
-
- /* type_unit_groups can be NULL if there is an error in the debug info.
- Just create an empty table so the rest of gdb doesn't have to watch
- for this error case. */
- if (dwarf2_per_objfile->type_unit_groups == NULL)
- {
- dwarf2_per_objfile->type_unit_groups =
- allocate_type_unit_groups_table ();
- dwarf2_per_objfile->n_type_unit_groups = 0;
+ gdb_assert (tu_group != NULL);
}
-
- /* Create a vector of pointers to primary type units to make it easy to
- iterate over them and CUs. See dw2_get_primary_cu. */
- dwarf2_per_objfile->n_type_unit_groups =
- htab_elements (dwarf2_per_objfile->type_unit_groups);
- dwarf2_per_objfile->all_type_unit_groups =
- obstack_alloc (&objfile->objfile_obstack,
- dwarf2_per_objfile->n_type_unit_groups
- * sizeof (struct type_unit_group *));
- iter = &dwarf2_per_objfile->all_type_unit_groups[0];
- htab_traverse_noresize (dwarf2_per_objfile->type_unit_groups,
- add_type_unit_group_to_table, &iter);
- gdb_assert (iter - &dwarf2_per_objfile->all_type_unit_groups[0]
- == dwarf2_per_objfile->n_type_unit_groups);
-
- do_cleanups (cleanups);
-
- if (dwarf2_read_debug)
+ else
{
- fprintf_unfiltered (gdb_stdlog, "Done building type unit groups:\n");
- fprintf_unfiltered (gdb_stdlog, " %d TUs\n",
- dwarf2_per_objfile->n_type_units);
- fprintf_unfiltered (gdb_stdlog, " %d uniq abbrev tables\n",
- tu_stats->nr_uniq_abbrev_tables);
- fprintf_unfiltered (gdb_stdlog, " %d symtabs from stmt_list entries\n",
- tu_stats->nr_symtabs);
- fprintf_unfiltered (gdb_stdlog, " %d symtab sharers\n",
- tu_stats->nr_symtab_sharers);
- fprintf_unfiltered (gdb_stdlog, " %d type units without a stmt_list\n",
- tu_stats->nr_stmt_less_type_units);
+ sect_offset line_offset_struct;
+
+ line_offset_struct.sect_off = line_offset;
+ tu_group = create_type_unit_group (cu, line_offset_struct);
+ *slot = tu_group;
+ ++tu_stats->nr_symtabs;
}
+
+ return tu_group;
}
\f
/* Partial symbol tables. */
sort_pst_symbols (objfile, pst);
}
+/* Struct used to sort TUs by their abbreviation table offset. */
+
+struct tu_abbrev_offset
+{
+ struct signatured_type *sig_type;
+ sect_offset abbrev_offset;
+};
+
+/* Helper routine for build_type_psymtabs_1, passed to qsort. */
+
+static int
+sort_tu_by_abbrev_offset (const void *ap, const void *bp)
+{
+ const struct tu_abbrev_offset * const *a = ap;
+ const struct tu_abbrev_offset * const *b = bp;
+ unsigned int aoff = (*a)->abbrev_offset.sect_off;
+ unsigned int boff = (*b)->abbrev_offset.sect_off;
+
+ return (aoff > boff) - (aoff < boff);
+}
+
+/* Efficiently read all the type units.
+ This does the bulk of the work for build_type_psymtabs.
+
+ The efficiency is because we sort TUs by the abbrev table they use and
+ only read each abbrev table once. In one program there are 200K TUs
+ sharing 8K abbrev tables.
+
+ The main purpose of this function is to support building the
+ dwarf2_per_objfile->type_unit_groups table.
+ TUs typically share the DW_AT_stmt_list of the CU they came from, so we
+ can collapse the search space by grouping them by stmt_list.
+ The savings can be significant, in the same program from above the 200K TUs
+ share 8K stmt_list tables.
+
+ FUNC is expected to call get_type_unit_group, which will create the
+ struct type_unit_group if necessary and add it to
+ dwarf2_per_objfile->type_unit_groups. */
+
+static void
+build_type_psymtabs_1 (void)
+{
+ struct objfile *objfile = dwarf2_per_objfile->objfile;
+ struct tu_stats *tu_stats = &dwarf2_per_objfile->tu_stats;
+ struct cleanup *cleanups;
+ struct abbrev_table *abbrev_table;
+ sect_offset abbrev_offset;
+ struct tu_abbrev_offset *sorted_by_abbrev;
+ struct type_unit_group **iter;
+ int i;
+
+ /* It's up to the caller to not call us multiple times. */
+ gdb_assert (dwarf2_per_objfile->type_unit_groups == NULL);
+
+ if (dwarf2_per_objfile->n_type_units == 0)
+ return;
+
+ /* TUs typically share abbrev tables, and there can be way more TUs than
+ abbrev tables. Sort by abbrev table to reduce the number of times we
+ read each abbrev table in.
+ Alternatives are to punt or to maintain a cache of abbrev tables.
+ This is simpler and efficient enough for now.
+
+ Later we group TUs by their DW_AT_stmt_list value (as this defines the
+ symtab to use). Typically TUs with the same abbrev offset have the same
+ stmt_list value too so in practice this should work well.
+
+ The basic algorithm here is:
+
+ sort TUs by abbrev table
+ for each TU with same abbrev table:
+ read abbrev table if first user
+ read TU top level DIE
+ [IWBN if DWO skeletons had DW_AT_stmt_list]
+ call FUNC */
+
+ if (dwarf2_read_debug)
+ fprintf_unfiltered (gdb_stdlog, "Building type unit groups ...\n");
+
+ /* Sort in a separate table to maintain the order of all_type_units
+ for .gdb_index: TU indices directly index all_type_units. */
+ sorted_by_abbrev = XNEWVEC (struct tu_abbrev_offset,
+ dwarf2_per_objfile->n_type_units);
+ for (i = 0; i < dwarf2_per_objfile->n_type_units; ++i)
+ {
+ struct signatured_type *sig_type = dwarf2_per_objfile->all_type_units[i];
+
+ sorted_by_abbrev[i].sig_type = sig_type;
+ sorted_by_abbrev[i].abbrev_offset =
+ read_abbrev_offset (sig_type->per_cu.section,
+ sig_type->per_cu.offset);
+ }
+ cleanups = make_cleanup (xfree, sorted_by_abbrev);
+ qsort (sorted_by_abbrev, dwarf2_per_objfile->n_type_units,
+ sizeof (struct tu_abbrev_offset), sort_tu_by_abbrev_offset);
+
+ abbrev_offset.sect_off = ~(unsigned) 0;
+ abbrev_table = NULL;
+ make_cleanup (abbrev_table_free_cleanup, &abbrev_table);
+
+ for (i = 0; i < dwarf2_per_objfile->n_type_units; ++i)
+ {
+ const struct tu_abbrev_offset *tu = &sorted_by_abbrev[i];
+
+ /* Switch to the next abbrev table if necessary. */
+ if (abbrev_table == NULL
+ || tu->abbrev_offset.sect_off != abbrev_offset.sect_off)
+ {
+ if (abbrev_table != NULL)
+ {
+ abbrev_table_free (abbrev_table);
+ /* Reset to NULL in case abbrev_table_read_table throws
+ an error: abbrev_table_free_cleanup will get called. */
+ abbrev_table = NULL;
+ }
+ abbrev_offset = tu->abbrev_offset;
+ abbrev_table =
+ abbrev_table_read_table (&dwarf2_per_objfile->abbrev,
+ abbrev_offset);
+ ++tu_stats->nr_uniq_abbrev_tables;
+ }
+
+ init_cutu_and_read_dies (&tu->sig_type->per_cu, abbrev_table, 0, 0,
+ build_type_psymtabs_reader, NULL);
+ }
+
+ do_cleanups (cleanups);
+}
+
+/* Print collected type unit statistics. */
+
+static void
+print_tu_stats (void)
+{
+ struct tu_stats *tu_stats = &dwarf2_per_objfile->tu_stats;
+
+ fprintf_unfiltered (gdb_stdlog, "Type unit statistics:\n");
+ fprintf_unfiltered (gdb_stdlog, " %d TUs\n",
+ dwarf2_per_objfile->n_type_units);
+ fprintf_unfiltered (gdb_stdlog, " %d uniq abbrev tables\n",
+ tu_stats->nr_uniq_abbrev_tables);
+ fprintf_unfiltered (gdb_stdlog, " %d symtabs from stmt_list entries\n",
+ tu_stats->nr_symtabs);
+ fprintf_unfiltered (gdb_stdlog, " %d symtab sharers\n",
+ tu_stats->nr_symtab_sharers);
+ fprintf_unfiltered (gdb_stdlog, " %d type units without a stmt_list\n",
+ tu_stats->nr_stmt_less_type_units);
+ fprintf_unfiltered (gdb_stdlog, " %d all_type_units reallocs\n",
+ tu_stats->nr_all_type_units_reallocs);
+}
+
/* Traversal function for build_type_psymtabs. */
static int
if (! create_all_type_units (objfile))
return;
- build_type_unit_groups (build_type_psymtabs_reader, NULL);
+ build_type_psymtabs_1 ();
+}
+
+/* Traversal function for process_skeletonless_type_unit.
+ Read a TU in a DWO file and build partial symbols for it. */
- /* Now that all TUs have been processed we can fill in the dependencies. */
- htab_traverse_noresize (dwarf2_per_objfile->type_unit_groups,
- build_type_psymtab_dependencies, NULL);
+static int
+process_skeletonless_type_unit (void **slot, void *info)
+{
+ struct dwo_unit *dwo_unit = (struct dwo_unit *) *slot;
+ struct objfile *objfile = info;
+ struct signatured_type find_entry, *entry;
+
+ /* If this TU doesn't exist in the global table, add it and read it in. */
+
+ if (dwarf2_per_objfile->signatured_types == NULL)
+ {
+ dwarf2_per_objfile->signatured_types
+ = allocate_signatured_type_table (objfile);
+ }
+
+ find_entry.signature = dwo_unit->signature;
+ slot = htab_find_slot (dwarf2_per_objfile->signatured_types, &find_entry,
+ INSERT);
+ /* If we've already seen this type there's nothing to do. What's happening
+ is we're doing our own version of comdat-folding here. */
+ if (*slot != NULL)
+ return 1;
+
+ /* This does the job that create_all_type_units would have done for
+ this TU. */
+ entry = add_type_unit (dwo_unit->signature, slot);
+ fill_in_sig_entry_from_dwo_entry (objfile, entry, dwo_unit);
+ *slot = entry;
+
+ /* This does the job that build_type_psymtabs_1 would have done. */
+ init_cutu_and_read_dies (&entry->per_cu, NULL, 0, 0,
+ build_type_psymtabs_reader, NULL);
+
+ return 1;
+}
+
+/* Traversal function for process_skeletonless_type_units. */
+
+static int
+process_dwo_file_for_skeletonless_type_units (void **slot, void *info)
+{
+ struct dwo_file *dwo_file = (struct dwo_file *) *slot;
+
+ if (dwo_file->tus != NULL)
+ {
+ htab_traverse_noresize (dwo_file->tus,
+ process_skeletonless_type_unit, info);
+ }
+
+ return 1;
+}
+
+/* Scan all TUs of DWO files, verifying we've processed them.
+ This is needed in case a TU was emitted without its skeleton.
+ Note: This can't be done until we know what all the DWO files are. */
+
+static void
+process_skeletonless_type_units (struct objfile *objfile)
+{
+ /* Skeletonless TUs in DWP files without .gdb_index is not supported yet. */
+ if (get_dwp_file () == NULL
+ && dwarf2_per_objfile->dwo_files != NULL)
+ {
+ htab_traverse_noresize (dwarf2_per_objfile->dwo_files,
+ process_dwo_file_for_skeletonless_type_units,
+ objfile);
+ }
}
/* A cleanup function that clears objfile's psymtabs_addrmap field. */
for (i = 0; i < dwarf2_per_objfile->n_comp_units; ++i)
{
- struct dwarf2_per_cu_data *per_cu = dw2_get_cu (i);
+ struct dwarf2_per_cu_data *per_cu = dw2_get_cutu (i);
struct partial_symtab *pst = per_cu->v.psymtab;
int j;
for (i = 0; i < dwarf2_per_objfile->n_comp_units; ++i)
{
- struct dwarf2_per_cu_data *per_cu = dw2_get_cu (i);
+ struct dwarf2_per_cu_data *per_cu = dw2_get_cutu (i);
process_psymtab_comp_unit (per_cu, 0, language_minimal);
}
+ /* This has to wait until we read the CUs, we need the list of DWOs. */
+ process_skeletonless_type_units (objfile);
+
+ /* Now that all TUs have been processed we can fill in the dependencies. */
+ if (dwarf2_per_objfile->type_unit_groups != NULL)
+ {
+ htab_traverse_noresize (dwarf2_per_objfile->type_unit_groups,
+ build_type_psymtab_dependencies, NULL);
+ }
+
+ if (dwarf2_read_debug)
+ print_tu_stats ();
+
set_partial_user (objfile);
objfile->psymtabs_addrmap = addrmap_create_fixed (objfile->psymtabs_addrmap,
if (sibling_ptr < info_ptr)
complaint (&symfile_complaints,
_("DW_AT_sibling points backwards"));
+ else if (sibling_ptr > reader->buffer_end)
+ dwarf2_section_buffer_overflow_complaint (reader->die_section);
else
return sibling_ptr;
}
/* Called when we find the DIE that starts a structure or union scope
(definition) to create a type for the structure or union. Fill in
the type's name and general properties; the members will not be
- processed until process_structure_scope.
+ processed until process_structure_scope. A symbol table entry for
+ the type will also not be done until process_structure_scope (assuming
+ the type has a name).
NOTE: we need to call these functions regardless of whether or not the
DIE has a DW_AT_name attribute, since it might be an anonymous
structure or union. This gets the type entered into our set of
- user defined types.
-
- However, if the structure is incomplete (an opaque struct/union)
- then suppress creating a symbol table entry for it since gdb only
- wants to find the one with the complete definition. Note that if
- it is complete, we just call new_symbol, which does it's own
- checking about whether the struct/union is anonymous or not (and
- suppresses creating a symbol table entry itself). */
+ user defined types. */
static struct type *
read_structure_type (struct die_info *die, struct dwarf2_cu *cu)
if (name != NULL)
TYPE_TAG_NAME (type) = name;
+ attr = dwarf2_attr (die, DW_AT_type, cu);
+ if (attr != NULL)
+ {
+ struct type *underlying_type = die_type (die, cu);
+
+ TYPE_TARGET_TYPE (type) = underlying_type;
+ }
+
attr = dwarf2_attr (die, DW_AT_byte_size, cu);
if (attr)
{
if (die_is_declaration (die, cu))
TYPE_STUB (type) = 1;
- /* Finish the creation of this type by using the enum's children. */
+ /* Finish the creation of this type by using the enum's children.
+ We must call this even when the underlying type has been provided
+ so that we can determine if we're looking at a "flag" enum. */
update_enumeration_type_from_children (die, type, cu);
+ /* If this type has an underlying type that is not a stub, then we
+ may use its attributes. We always use the "unsigned" attribute
+ in this situation, because ordinarily we guess whether the type
+ is unsigned -- but the guess can be wrong and the underlying type
+ can tell us the reality. However, we defer to a local size
+ attribute if one exists, because this lets the compiler override
+ the underlying type if needed. */
+ if (TYPE_TARGET_TYPE (type) != NULL && !TYPE_STUB (TYPE_TARGET_TYPE (type)))
+ {
+ TYPE_UNSIGNED (type) = TYPE_UNSIGNED (TYPE_TARGET_TYPE (type));
+ if (TYPE_LENGTH (type) == 0)
+ TYPE_LENGTH (type) = TYPE_LENGTH (TYPE_TARGET_TYPE (type));
+ }
+
+ TYPE_DECLARED_CLASS (type) = dwarf2_flag_true_p (die, DW_AT_enum_class, cu);
+
return set_die_type (die, type, cu);
}
return set_die_type (die, type, cu);
}
+/* Parse dwarf attribute if it's a block, reference or constant and put the
+ resulting value of the attribute into struct bound_prop.
+ Returns 1 if ATTR could be resolved into PROP, 0 otherwise. */
+
+static int
+attr_to_dynamic_prop (const struct attribute *attr, struct die_info *die,
+ struct dwarf2_cu *cu, struct dynamic_prop *prop)
+{
+ struct dwarf2_property_baton *baton;
+ struct obstack *obstack = &cu->objfile->objfile_obstack;
+
+ if (attr == NULL || prop == NULL)
+ return 0;
+
+ if (attr_form_is_block (attr))
+ {
+ baton = obstack_alloc (obstack, sizeof (*baton));
+ baton->referenced_type = NULL;
+ baton->locexpr.per_cu = cu->per_cu;
+ baton->locexpr.size = DW_BLOCK (attr)->size;
+ baton->locexpr.data = DW_BLOCK (attr)->data;
+ prop->data.baton = baton;
+ prop->kind = PROP_LOCEXPR;
+ gdb_assert (prop->data.baton != NULL);
+ }
+ else if (attr_form_is_ref (attr))
+ {
+ struct dwarf2_cu *target_cu = cu;
+ struct die_info *target_die;
+ struct attribute *target_attr;
+
+ target_die = follow_die_ref (die, attr, &target_cu);
+ target_attr = dwarf2_attr (target_die, DW_AT_location, target_cu);
+ if (target_attr == NULL)
+ return 0;
+
+ if (attr_form_is_section_offset (target_attr))
+ {
+ baton = obstack_alloc (obstack, sizeof (*baton));
+ baton->referenced_type = die_type (target_die, target_cu);
+ fill_in_loclist_baton (cu, &baton->loclist, target_attr);
+ prop->data.baton = baton;
+ prop->kind = PROP_LOCLIST;
+ gdb_assert (prop->data.baton != NULL);
+ }
+ else if (attr_form_is_block (target_attr))
+ {
+ baton = obstack_alloc (obstack, sizeof (*baton));
+ baton->referenced_type = die_type (target_die, target_cu);
+ baton->locexpr.per_cu = cu->per_cu;
+ baton->locexpr.size = DW_BLOCK (target_attr)->size;
+ baton->locexpr.data = DW_BLOCK (target_attr)->data;
+ prop->data.baton = baton;
+ prop->kind = PROP_LOCEXPR;
+ gdb_assert (prop->data.baton != NULL);
+ }
+ else
+ {
+ dwarf2_invalid_attrib_class_complaint ("DW_AT_location",
+ "dynamic property");
+ return 0;
+ }
+ }
+ else if (attr_form_is_constant (attr))
+ {
+ prop->data.const_val = dwarf2_get_attr_constant_value (attr, 0);
+ prop->kind = PROP_CONST;
+ }
+ else
+ {
+ dwarf2_invalid_attrib_class_complaint (dwarf_form_name (attr->form),
+ dwarf2_name (die, cu));
+ return 0;
+ }
+
+ return 1;
+}
+
/* Read the given DW_AT_subrange DIE. */
static struct type *
struct attribute *attr;
struct dynamic_prop low, high;
int low_default_is_valid;
+ int high_bound_is_count = 0;
const char *name;
LONGEST negative_mask;
break;
}
- /* 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);
if (attr)
- low.data.const_val
- = dwarf2_get_attr_constant_value (attr, low.data.const_val);
+ attr_to_dynamic_prop (attr, die, cu, &low);
else if (!low_default_is_valid)
complaint (&symfile_complaints, _("Missing DW_AT_lower_bound "
"- DIE at 0x%x [in module %s]"),
die->offset.sect_off, objfile_name (cu->objfile));
attr = dwarf2_attr (die, DW_AT_upper_bound, cu);
- if (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.
- FIXME: GDB does not yet know how to handle dynamic
- arrays properly, treat them as arrays with unspecified
- length for now.
-
- FIXME: jimb/2003-09-22: GDB does not really know
- how to handle arrays of unspecified length
- either; we just represent them as zero-length
- arrays. Choose an appropriate upper bound given
- the lower bound we've computed above. */
- high.data.const_val = low.data.const_val - 1;
- }
- else
- high.data.const_val = dwarf2_get_attr_constant_value (attr, 1);
- }
- else
+ if (!attr_to_dynamic_prop (attr, die, cu, &high))
{
attr = dwarf2_attr (die, DW_AT_count, cu);
- if (attr)
+ if (attr_to_dynamic_prop (attr, die, cu, &high))
{
- int count = dwarf2_get_attr_constant_value (attr, 1);
- high.data.const_val = low.data.const_val + count - 1;
- }
- else
- {
- /* Unspecified array length. */
- high.data.const_val = low.data.const_val - 1;
+ /* If bounds are constant do the final calculation here. */
+ if (low.kind == PROP_CONST && high.kind == PROP_CONST)
+ high.data.const_val = low.data.const_val + high.data.const_val - 1;
+ else
+ high_bound_is_count = 1;
}
}
range_type = create_range_type (NULL, orig_base_type, &low, &high);
- /* Mark arrays with dynamic length at least as an array of unspecified
- length. GDB could check the boundary but before it gets implemented at
- least allow accessing the array elements. */
- if (attr && attr_form_is_block (attr))
- TYPE_HIGH_BOUND_KIND (range_type) = PROP_UNDEFINED;
+ if (high_bound_is_count)
+ TYPE_RANGE_DATA (range_type)->flag_upper_bound_is_count = 1;
/* Ada expects an empty array on no boundary attributes. */
if (attr == NULL && cu->language != language_ada)
/* Same as abbrev_table_free but as a cleanup.
We pass in a pointer to the pointer to the table so that we can
set the pointer to NULL when we're done. It also simplifies
- build_type_unit_groups. */
+ build_type_psymtabs_1. */
static void
abbrev_table_free_cleanup (void *table_ptr)
if (sibling_ptr < info_ptr)
complaint (&symfile_complaints,
_("DW_AT_sibling points backwards"));
+ else if (sibling_ptr > reader->buffer_end)
+ dwarf2_section_buffer_overflow_complaint (reader->die_section);
else
part_die->sibling = sibling_ptr;
}
return name;
}
return "";
+ case DW_TAG_enumeration_type:
+ parent_type = read_type_die (parent, cu);
+ if (TYPE_DECLARED_CLASS (parent_type))
+ {
+ if (TYPE_TAG_NAME (parent_type) != NULL)
+ return TYPE_TAG_NAME (parent_type);
+ return "";
+ }
+ /* Fall through. */
default:
return determine_prefix (parent, cu);
}