mirror of
https://github.com/espressif/binutils-gdb.git
synced 2025-06-29 08:24:05 +08:00
gdb/
Fix -readnow for -gdwarf-4 unused type units. * dwarf2read.c (struct signatured_type): Remove the field offset. (create_signatured_type_table_from_index): Remove its initialization. (create_debug_types_hash_table): Likewise. Initialize per_cu.offset instead. Add a complaint call. (process_psymtab_comp_unit): Change assignment to gdb_assert. (process_type_comp_unit, lookup_die_type, dump_die_shallow) (lookup_signatured_type_at_offset, read_signatured_type) (write_one_signatured_type): Update the field for per_cu. gdb/testsuite/ Fix -readnow for -gdwarf-4 unused type units. * gdb.dwarf2/dw4-sig-type-unused.S: New file. * gdb.dwarf2/dw4-sig-type-unused.exp: New file.
This commit is contained in:
@ -470,9 +470,6 @@ struct signatured_type
|
||||
{
|
||||
ULONGEST signature;
|
||||
|
||||
/* Offset in .debug_types of the TU (type_unit) for this type. */
|
||||
unsigned int offset;
|
||||
|
||||
/* Offset in .debug_types of the type defined by this TU. */
|
||||
unsigned int type_offset;
|
||||
|
||||
@ -1918,7 +1915,6 @@ create_signatured_type_table_from_index (struct objfile *objfile,
|
||||
type_sig = OBSTACK_ZALLOC (&objfile->objfile_obstack,
|
||||
struct signatured_type);
|
||||
type_sig->signature = signature;
|
||||
type_sig->offset = offset;
|
||||
type_sig->type_offset = type_offset;
|
||||
type_sig->per_cu.from_debug_types = 1;
|
||||
type_sig->per_cu.offset = offset;
|
||||
@ -3093,13 +3089,24 @@ create_debug_types_hash_table (struct objfile *objfile)
|
||||
type_sig = obstack_alloc (&objfile->objfile_obstack, sizeof (*type_sig));
|
||||
memset (type_sig, 0, sizeof (*type_sig));
|
||||
type_sig->signature = signature;
|
||||
type_sig->offset = offset;
|
||||
type_sig->type_offset = type_offset;
|
||||
type_sig->per_cu.objfile = objfile;
|
||||
type_sig->per_cu.from_debug_types = 1;
|
||||
type_sig->per_cu.offset = offset;
|
||||
|
||||
slot = htab_find_slot (types_htab, type_sig, INSERT);
|
||||
gdb_assert (slot != NULL);
|
||||
if (*slot != NULL)
|
||||
{
|
||||
const struct signatured_type *dup_sig = *slot;
|
||||
|
||||
complaint (&symfile_complaints,
|
||||
_("debug type entry at offset 0x%x is duplicate to the "
|
||||
"entry at offset 0x%x, signature 0x%s"),
|
||||
offset, dup_sig->per_cu.offset,
|
||||
phex (signature, sizeof (signature)));
|
||||
gdb_assert (signature == dup_sig->signature);
|
||||
}
|
||||
*slot = type_sig;
|
||||
|
||||
if (dwarf2_die_debug)
|
||||
@ -3264,8 +3271,8 @@ process_psymtab_comp_unit (struct objfile *objfile,
|
||||
|
||||
if (this_cu->from_debug_types)
|
||||
{
|
||||
/* offset,length haven't been set yet for type units. */
|
||||
this_cu->offset = cu.header.offset;
|
||||
/* LENGTH has not been set yet for type units. */
|
||||
gdb_assert (this_cu->offset == cu.header.offset);
|
||||
this_cu->length = cu.header.length + cu.header.initial_length_size;
|
||||
}
|
||||
else if (comp_unit_die->tag == DW_TAG_partial_unit)
|
||||
@ -3390,7 +3397,7 @@ process_type_comp_unit (void **slot, void *info)
|
||||
gdb_assert (dwarf2_per_objfile->types.readin);
|
||||
process_psymtab_comp_unit (objfile, this_cu,
|
||||
dwarf2_per_objfile->types.buffer,
|
||||
dwarf2_per_objfile->types.buffer + entry->offset,
|
||||
dwarf2_per_objfile->types.buffer + this_cu->offset,
|
||||
dwarf2_per_objfile->types.size);
|
||||
|
||||
return 1;
|
||||
@ -11703,7 +11710,7 @@ lookup_die_type (struct die_info *die, struct attribute *attr,
|
||||
die->offset, cu->objfile->name);
|
||||
|
||||
gdb_assert (sig_type->per_cu.from_debug_types);
|
||||
offset = sig_type->offset + sig_type->type_offset;
|
||||
offset = sig_type->per_cu.offset + sig_type->type_offset;
|
||||
this_type = get_die_type_at_offset (offset, &sig_type->per_cu);
|
||||
}
|
||||
else
|
||||
@ -13330,7 +13337,7 @@ dump_die_shallow (struct ui_file *f, int indent, struct die_info *die)
|
||||
case DW_FORM_ref_sig8:
|
||||
if (DW_SIGNATURED_TYPE (&die->attrs[i]) != NULL)
|
||||
fprintf_unfiltered (f, "signatured type, offset: 0x%x",
|
||||
DW_SIGNATURED_TYPE (&die->attrs[i])->offset);
|
||||
DW_SIGNATURED_TYPE (&die->attrs[i])->per_cu.offset);
|
||||
else
|
||||
fprintf_unfiltered (f, "signatured type, offset: unknown");
|
||||
break;
|
||||
@ -13738,7 +13745,7 @@ lookup_signatured_type_at_offset (struct objfile *objfile, unsigned int offset)
|
||||
/* This is only used to lookup previously recorded types.
|
||||
If we didn't find it, it's our bug. */
|
||||
gdb_assert (type_sig != NULL);
|
||||
gdb_assert (offset == type_sig->offset);
|
||||
gdb_assert (offset == type_sig->per_cu.offset);
|
||||
|
||||
return type_sig;
|
||||
}
|
||||
@ -13777,7 +13784,7 @@ read_signatured_type (struct objfile *objfile,
|
||||
struct cleanup *back_to, *free_cu_cleanup;
|
||||
|
||||
dwarf2_read_section (objfile, &dwarf2_per_objfile->types);
|
||||
types_ptr = dwarf2_per_objfile->types.buffer + type_sig->offset;
|
||||
types_ptr = dwarf2_per_objfile->types.buffer + type_sig->per_cu.offset;
|
||||
|
||||
gdb_assert (type_sig->per_cu.cu == NULL);
|
||||
|
||||
@ -15905,7 +15912,7 @@ write_one_signatured_type (void **slot, void *d)
|
||||
psymtab->n_static_syms, info->cu_index,
|
||||
1);
|
||||
|
||||
store_unsigned_integer (val, 8, BFD_ENDIAN_LITTLE, entry->offset);
|
||||
store_unsigned_integer (val, 8, BFD_ENDIAN_LITTLE, entry->per_cu.offset);
|
||||
obstack_grow (info->types_list, val, 8);
|
||||
store_unsigned_integer (val, 8, BFD_ENDIAN_LITTLE, entry->type_offset);
|
||||
obstack_grow (info->types_list, val, 8);
|
||||
|
Reference in New Issue
Block a user