To keep things simple we allocate both lazily. */
htab_t debug_info_type_hash;
- /* Table mapping type .debug_types DIE offsets to types.
+ /* Table mapping type .debug_types DIE sect_offset to types.
This is NULL if not allocated yet. */
htab_t debug_types_type_hash;
};
short version;
unsigned char addr_size;
unsigned char signed_addr_p;
- unsigned int abbrev_offset;
+ sect_offset abbrev_offset;
/* Size of file offsets; either 4 or 8. */
unsigned int offset_size;
/* Offset to the first byte of this compilation unit header in the
.debug_info section, for resolving relative reference dies. */
- unsigned int offset;
+ sect_offset offset;
/* Offset to first die in this cu from the start of the cu.
This will be the first byte following the compilation unit header. */
- unsigned int first_die_offset;
+ cu_offset first_die_offset;
};
/* Type used for delaying computation of method physnames.
/* Storage for the abbrev table. */
struct obstack abbrev_obstack;
- /* Hash table holding all the loaded partial DIEs. */
+ /* Hash table holding all the loaded partial DIEs
+ with partial_die->offset.SECT_OFF as hash. */
htab_t partial_dies;
/* Storage for things with the same lifetime as this read-in compilation
/* How many compilation units ago was this CU last referenced? */
int last_used;
- /* A hash table of die offsets for following references. */
+ /* A hash table of DIE cu_offset for following references with
+ die_info->offset.sect_off as hash. */
htab_t die_hash;
/* Full DIEs if read in. */
- if it doesn't, GDB will fall over anyway.
NOTE: Unlike comp_unit_head.length, this length includes
initial_length_size. */
- unsigned int offset;
+ sect_offset offset;
unsigned int length : 29;
/* Flag indicating this compilation unit will be read in before
{
ULONGEST signature;
- /* Offset in .debug_types of the type defined by this TU. */
- unsigned int type_offset;
+ /* Offset in this TU of the type defined by this TU. */
+ cu_offset type_offset;
/* The CU(/TU) of this type. */
struct dwarf2_per_cu_data per_cu;
struct partial_die_info
{
/* Offset of this DIE. */
- unsigned int offset;
+ sect_offset offset;
/* DWARF-2 tag for this DIE. */
ENUM_BITFIELD(dwarf_tag) tag : 16;
/* If HAS_SPECIFICATION, the offset of the DIE referred to by
DW_AT_specification (or DW_AT_abstract_origin or
DW_AT_extension). */
- unsigned int spec_offset;
+ sect_offset spec_offset;
/* Pointers to this DIE's parent, first child, and next sibling,
if any. */
unsigned int abbrev;
/* Offset in .debug_info or .debug_types section. */
- unsigned int offset;
+ sect_offset offset;
/* The dies in a compilation unit form an n-ary tree. PARENT
points to this die's parent; CHILD points to the first child of
gdb_byte *, gdb_byte *,
struct dwarf2_cu *);
-static struct partial_die_info *find_partial_die (unsigned int,
+static struct partial_die_info *find_partial_die (sect_offset,
struct dwarf2_cu *);
static void fixup_partial_die (struct partial_die_info *,
static int is_ref_attr (struct attribute *);
-static unsigned int dwarf2_get_ref_die_offset (struct attribute *);
+static sect_offset dwarf2_get_ref_die_offset (struct attribute *);
static LONGEST dwarf2_get_attr_constant_value (struct attribute *, int);
static struct signatured_type *lookup_signatured_type_at_offset
(struct objfile *objfile,
- struct dwarf2_section_info *section,
- unsigned int offset);
+ struct dwarf2_section_info *section, sect_offset offset);
static void load_full_type_unit (struct dwarf2_per_cu_data *per_cu);
static int partial_die_eq (const void *item_lhs, const void *item_rhs);
static struct dwarf2_per_cu_data *dwarf2_find_containing_comp_unit
- (unsigned int offset, struct objfile *objfile);
+ (sect_offset offset, struct objfile *objfile);
static void init_one_comp_unit (struct dwarf2_cu *cu,
struct dwarf2_per_cu_data *per_cu);
static void dwarf2_clear_marks (struct dwarf2_per_cu_data *);
-static struct type *get_die_type_at_offset (unsigned int,
+static struct type *get_die_type_at_offset (sect_offset,
struct dwarf2_per_cu_data *per_cu);
static struct type *get_die_type (struct die_info *die, struct dwarf2_cu *cu);
the_cu = OBSTACK_ZALLOC (&objfile->objfile_obstack,
struct dwarf2_per_cu_data);
- the_cu->offset = offset;
+ the_cu->offset.sect_off = offset;
the_cu->length = length;
the_cu->objfile = objfile;
the_cu->v.quick = OBSTACK_ZALLOC (&objfile->objfile_obstack,
type_sig = OBSTACK_ZALLOC (&objfile->objfile_obstack,
struct signatured_type);
type_sig->signature = signature;
- type_sig->type_offset = type_offset;
+ type_sig->type_offset.cu_off = type_offset;
type_sig->per_cu.debug_types_section = section;
- type_sig->per_cu.offset = offset;
+ type_sig->per_cu.offset.sect_off = offset;
type_sig->per_cu.objfile = objfile;
type_sig->per_cu.v.quick
= OBSTACK_ZALLOC (&objfile->objfile_obstack,
else
sec = &dwarf2_per_objfile->info;
dwarf2_read_section (objfile, sec);
- info_ptr = sec->buffer + this_cu->offset;
+ info_ptr = sec->buffer + this_cu->offset.sect_off;
info_ptr = read_and_check_comp_unit_head (&cu.header, sec, info_ptr,
this_cu->debug_types_section != NULL);
/* Return TRUE if OFFSET is within CU_HEADER. */
static inline int
-offset_in_cu_p (const struct comp_unit_head *cu_header, unsigned int offset)
+offset_in_cu_p (const struct comp_unit_head *cu_header, sect_offset offset)
{
- unsigned int bottom = cu_header->offset;
- unsigned int top = (cu_header->offset
- + cu_header->length
- + cu_header->initial_length_size);
+ sect_offset bottom = { cu_header->offset.sect_off };
+ sect_offset top = { (cu_header->offset.sect_off + cu_header->length
+ + cu_header->initial_length_size) };
- return (offset >= bottom && offset < top);
+ return (offset.sect_off >= bottom.sect_off && offset.sect_off < top.sect_off);
}
/* Read in the comp unit header information from the debug_info at info_ptr.
info_ptr += bytes_read;
cu_header->version = read_2_bytes (abfd, info_ptr);
info_ptr += 2;
- cu_header->abbrev_offset = read_offset (abfd, info_ptr, cu_header,
- &bytes_read);
+ cu_header->abbrev_offset.sect_off = read_offset (abfd, info_ptr, cu_header,
+ &bytes_read);
info_ptr += bytes_read;
cu_header->addr_size = read_1_byte (abfd, info_ptr);
info_ptr += 1;
"(is %d, should be 2, 3, or 4) [in module %s]"), header->version,
filename);
- if (header->abbrev_offset
+ if (header->abbrev_offset.sect_off
>= dwarf2_section_size (dwarf2_per_objfile->objfile,
&dwarf2_per_objfile->abbrev))
error (_("Dwarf Error: bad offset (0x%lx) in compilation unit header "
"(offset 0x%lx + 6) [in module %s]"),
- (long) header->abbrev_offset, (long) header->offset,
+ (long) header->abbrev_offset.sect_off, (long) header->offset.sect_off,
filename);
/* Cast to unsigned long to use 64-bit arithmetic when possible to
avoid potential 32-bit overflow. */
- if (((unsigned long) header->offset
+ if (((unsigned long) header->offset.sect_off
+ header->length + header->initial_length_size)
> section->size)
error (_("Dwarf Error: bad length (0x%lx) in compilation unit header "
"(offset 0x%lx + 0) [in module %s]"),
- (long) header->length, (long) header->offset,
+ (long) header->length, (long) header->offset.sect_off,
filename);
}
gdb_byte *beg_of_comp_unit = info_ptr;
bfd *abfd = section->asection->owner;
- header->offset = beg_of_comp_unit - section->buffer;
+ header->offset.sect_off = beg_of_comp_unit - section->buffer;
info_ptr = read_comp_unit_head (header, info_ptr, abfd);
if (is_debug_types_section)
info_ptr += 8 /*signature*/ + header->offset_size;
- header->first_die_offset = info_ptr - beg_of_comp_unit;
+ header->first_die_offset.cu_off = info_ptr - beg_of_comp_unit;
error_check_comp_unit_head (header, section);
read_and_check_type_unit_head (struct comp_unit_head *header,
struct dwarf2_section_info *section,
gdb_byte *info_ptr,
- ULONGEST *signature, unsigned int *type_offset)
+ ULONGEST *signature, cu_offset *type_offset)
{
gdb_byte *beg_of_comp_unit = info_ptr;
bfd *abfd = section->asection->owner;
- header->offset = beg_of_comp_unit - section->buffer;
+ header->offset.sect_off = beg_of_comp_unit - section->buffer;
info_ptr = read_comp_unit_head (header, info_ptr, abfd);
*signature = read_8_bytes (abfd, info_ptr);
info_ptr += 8;
if (type_offset != NULL)
- *type_offset = read_offset_1 (abfd, info_ptr, header->offset_size);
+ type_offset->cu_off = read_offset_1 (abfd, info_ptr, header->offset_size);
info_ptr += header->offset_size;
- header->first_die_offset = info_ptr - beg_of_comp_unit;
+ header->first_die_offset.cu_off = info_ptr - beg_of_comp_unit;
error_check_comp_unit_head (header, section);
end_ptr = info_ptr + section->size;
while (info_ptr < end_ptr)
{
- unsigned int offset;
- unsigned int type_offset;
+ sect_offset offset;
+ cu_offset type_offset;
ULONGEST signature;
struct signatured_type *type_sig;
void **slot;
gdb_byte *ptr = info_ptr;
struct comp_unit_head header;
- offset = ptr - section->buffer;
+ offset.sect_off = ptr - section->buffer;
/* We need to read the type's signature in order to build the hash
table, but we don't need anything else just yet. */
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,
+ offset.sect_off, dup_sig->per_cu.offset.sect_off,
phex (signature, sizeof (signature)));
gdb_assert (signature == dup_sig->signature);
}
if (dwarf2_die_debug)
fprintf_unfiltered (gdb_stdlog, " offset 0x%x, signature 0x%s\n",
- offset, phex (signature, sizeof (signature)));
+ offset.sect_off,
+ phex (signature, sizeof (signature)));
info_ptr = info_ptr + header.initial_length_size + header.length;
}
struct objfile *objfile = this_cu->objfile;
bfd *abfd = objfile->obfd;
gdb_byte *buffer = section->buffer;
- gdb_byte *info_ptr = buffer + this_cu->offset;
+ gdb_byte *info_ptr = buffer + this_cu->offset.sect_off;
unsigned int buffer_size = section->size;
gdb_byte *beg_of_comp_unit = info_ptr;
struct die_info *comp_unit_die;
if (is_debug_types_section)
{
/* LENGTH has not been set yet for type units. */
- gdb_assert (this_cu->offset == cu.header.offset);
+ gdb_assert (this_cu->offset.sect_off == cu.header.offset.sect_off);
this_cu->length = cu.header.length + cu.header.initial_length_size;
}
else if (comp_unit_die->tag == DW_TAG_partial_unit)
gdb_assert (! this_cu->debug_types_section);
gdb_assert (section->readin);
- info_ptr = section->buffer + this_cu->offset;
+ info_ptr = section->buffer + this_cu->offset.sect_off;
if (this_cu->cu == NULL)
{
else
{
cu = this_cu->cu;
- info_ptr += cu->header.first_die_offset;
+ info_ptr += cu->header.first_die_offset.cu_off;
}
/* Read the abbrevs for this compilation unit into a table. */
{
unsigned int length, initial_length_size;
struct dwarf2_per_cu_data *this_cu;
- unsigned int offset;
+ sect_offset offset;
- offset = info_ptr - dwarf2_per_objfile->info.buffer;
+ offset.sect_off = info_ptr - dwarf2_per_objfile->info.buffer;
/* Read just enough information to find out where the next
compilation unit is. */
ignoring them. */
complaint (&symfile_complaints,
_("unhandled containing DIE tag %d for DIE at %d"),
- parent->tag, pdi->offset);
+ parent->tag, pdi->offset.sect_off);
parent->scope = grandparent_scope;
}
struct attribute attr;
struct dwarf2_cu *ref_cu = cu;
+ /* DW_FORM_ref_addr is using section offset. */
attr.name = 0;
attr.form = DW_FORM_ref_addr;
- attr.u.addr = pdi->offset;
+ attr.u.addr = pdi->offset.sect_off;
die = follow_die_ref (NULL, &attr, &ref_cu);
return xstrdup (dwarf2_full_name (NULL, die, ref_cu));
complaint (&symfile_complaints,
_("ignoring absolute DW_AT_sibling"));
else
- return buffer + dwarf2_get_ref_die_offset (&attr);
+ return buffer + dwarf2_get_ref_die_offset (&attr).sect_off;
}
/* If it isn't DW_AT_sibling, skip this attribute. */
struct objfile *objfile = per_cu->objfile;
bfd *abfd = objfile->obfd;
struct dwarf2_cu *cu;
- unsigned int offset;
+ sect_offset offset;
gdb_byte *info_ptr, *beg_of_comp_unit;
struct cleanup *free_cu_cleanup = NULL;
struct attribute *attr;
offset = per_cu->offset;
dwarf2_read_section (objfile, &dwarf2_per_objfile->info);
- info_ptr = dwarf2_per_objfile->info.buffer + offset;
+ info_ptr = dwarf2_per_objfile->info.buffer + offset.sect_off;
beg_of_comp_unit = info_ptr;
if (per_cu->cu == NULL)
/* Complete the cu_header. */
cu->header.offset = offset;
- cu->header.first_die_offset = info_ptr - beg_of_comp_unit;
+ cu->header.first_die_offset.cu_off = info_ptr - beg_of_comp_unit;
}
else
{
cu = per_cu->cu;
- info_ptr += cu->header.first_die_offset;
+ info_ptr += cu->header.first_die_offset.cu_off;
}
cu->dies = read_comp_unit (info_ptr, cu);
complaint (&symfile_complaints,
_("Computed physname <%s> does not match demangled <%s> "
"(from linkage <%s>) - DIE at 0x%x [in module %s]"),
- physname, canon, mangled, die->offset, objfile->name);
+ physname, canon, mangled, die->offset.sect_off, objfile->name);
/* Prefer DW_AT_linkage_name (in the CANON form) - when it
is available here - over computed PHYSNAME. It is safer
complaint (&symfile_complaints,
_("child DW_TAG_imported_declaration expected "
"- DIE at 0x%x [in module %s]"),
- child_die->offset, objfile->name);
+ child_die->offset.sect_off, objfile->name);
continue;
}
complaint (&symfile_complaints,
_("child DW_TAG_imported_declaration has unknown "
"imported name - DIE at 0x%x [in module %s]"),
- child_die->offset, objfile->name);
+ child_die->offset.sect_off, objfile->name);
continue;
}
struct die_info *child_die;
unsigned die_children_count;
/* CU offsets which were referenced by children of the current DIE. */
- unsigned *offsets;
- unsigned *offsets_end, *offsetp;
+ sect_offset *offsets;
+ sect_offset *offsets_end, *offsetp;
/* Parent of DIE - referenced by DW_AT_abstract_origin. */
struct die_info *origin_die;
/* Iterator of the ORIGIN_DIE children. */
&& origin_die->tag == DW_TAG_subprogram))
complaint (&symfile_complaints,
_("DIE 0x%x and its abstract origin 0x%x have different tags"),
- die->offset, origin_die->offset);
+ die->offset.sect_off, origin_die->offset.sect_off);
child_die = die->child;
die_children_count = 0;
&& child_origin_die->tag == DW_TAG_subprogram))
complaint (&symfile_complaints,
_("Child DIE 0x%x and its abstract origin 0x%x have "
- "different tags"), child_die->offset,
- child_origin_die->offset);
+ "different tags"), child_die->offset.sect_off,
+ child_origin_die->offset.sect_off);
if (child_origin_die->parent != origin_die)
complaint (&symfile_complaints,
_("Child DIE 0x%x and its abstract origin 0x%x have "
- "different parents"), child_die->offset,
- child_origin_die->offset);
+ "different parents"), child_die->offset.sect_off,
+ child_origin_die->offset.sect_off);
else
*offsets_end++ = child_origin_die->offset;
}
qsort (offsets, offsets_end - offsets, sizeof (*offsets),
unsigned_int_compar);
for (offsetp = offsets + 1; offsetp < offsets_end; offsetp++)
- if (offsetp[-1] == *offsetp)
+ if (offsetp[-1].sect_off == offsetp->sect_off)
complaint (&symfile_complaints,
_("Multiple children of DIE 0x%x refer "
"to DIE 0x%x as their abstract origin"),
- die->offset, *offsetp);
+ die->offset.sect_off, offsetp->sect_off);
offsetp = offsets;
origin_child_die = origin_die->child;
while (origin_child_die && origin_child_die->tag)
{
/* Is ORIGIN_CHILD_DIE referenced by any of the DIE children? */
- while (offsetp < offsets_end && *offsetp < origin_child_die->offset)
+ while (offsetp < offsets_end
+ && offsetp->sect_off < origin_child_die->offset.sect_off)
offsetp++;
- if (offsetp >= offsets_end || *offsetp > origin_child_die->offset)
+ if (offsetp >= offsets_end
+ || offsetp->sect_off > origin_child_die->offset.sect_off)
{
/* Found that ORIGIN_CHILD_DIE is really not referenced. */
process_die (origin_child_die, origin_cu);
if (name == NULL)
{
complaint (&symfile_complaints,
- _("missing name for subprogram DIE at %d"), die->offset);
+ _("missing name for subprogram DIE at %d"),
+ die->offset.sect_off);
return;
}
complaint (&symfile_complaints,
_("cannot get low and high bounds "
"for subprogram DIE at %d"),
- die->offset);
+ die->offset.sect_off);
return;
}
complaint (&symfile_complaints,
_("missing DW_AT_low_pc for DW_TAG_GNU_call_site "
"DIE 0x%x [in module %s]"),
- die->offset, objfile->name);
+ die->offset.sect_off, objfile->name);
return;
}
pc = DW_ADDR (attr) + baseaddr;
complaint (&symfile_complaints,
_("Duplicate PC %s for DW_TAG_GNU_call_site "
"DIE 0x%x [in module %s]"),
- paddress (gdbarch, pc), die->offset, objfile->name);
+ paddress (gdbarch, pc), die->offset.sect_off, objfile->name);
return;
}
complaint (&symfile_complaints,
_("Tag %d is not DW_TAG_GNU_call_site_parameter in "
"DW_TAG_GNU_call_site child DIE 0x%x [in module %s]"),
- child_die->tag, child_die->offset, objfile->name);
+ child_die->tag, child_die->offset.sect_off, objfile->name);
continue;
}
complaint (&symfile_complaints,
_("Cannot find function owning DW_TAG_GNU_call_site "
"DIE 0x%x [in module %s]"),
- die->offset, objfile->name);
+ die->offset.sect_off, objfile->name);
}
}
complaint (&symfile_complaints,
_("DW_AT_GNU_call_site_target target DIE has invalid "
"physname, for referencing DIE 0x%x [in module %s]"),
- die->offset, objfile->name);
+ die->offset.sect_off, objfile->name);
else
SET_FIELD_PHYSNAME (call_site->target, (char *) target_physname);
}
complaint (&symfile_complaints,
_("DW_AT_GNU_call_site_target target DIE has invalid "
"low pc, for referencing DIE 0x%x [in module %s]"),
- die->offset, objfile->name);
+ die->offset.sect_off, objfile->name);
else
SET_FIELD_PHYSADDR (call_site->target, lowpc + baseaddr);
}
complaint (&symfile_complaints,
_("DW_TAG_GNU_call_site DW_AT_GNU_call_site_target is neither "
"block nor reference, for DIE 0x%x [in module %s]"),
- die->offset, objfile->name);
+ die->offset.sect_off, objfile->name);
call_site->per_cu = cu->per_cu;
complaint (&symfile_complaints,
_("No DW_FORM_block* DW_AT_location for "
"DW_TAG_GNU_call_site child DIE 0x%x [in module %s]"),
- child_die->offset, objfile->name);
+ child_die->offset.sect_off, objfile->name);
continue;
}
parameter->dwarf_reg = dwarf_block_to_dwarf_reg (DW_BLOCK (attr)->data,
_("Only single DW_OP_reg or DW_OP_fbreg is supported "
"for DW_FORM_block* DW_AT_location for "
"DW_TAG_GNU_call_site child DIE 0x%x [in module %s]"),
- child_die->offset, objfile->name);
+ child_die->offset.sect_off, objfile->name);
continue;
}
complaint (&symfile_complaints,
_("No DW_FORM_block* DW_AT_GNU_call_site_value for "
"DW_TAG_GNU_call_site child DIE 0x%x [in module %s]"),
- child_die->offset, objfile->name);
+ child_die->offset.sect_off, objfile->name);
continue;
}
parameter->value = DW_BLOCK (attr)->data;
complaint (&symfile_complaints,
_("No DW_FORM_block* DW_AT_GNU_call_site_data_value for "
"DW_TAG_GNU_call_site child DIE 0x%x [in module %s]"),
- child_die->offset, objfile->name);
+ child_die->offset.sect_off, objfile->name);
else
{
parameter->data_value = DW_BLOCK (attr)->data;
complaint (&symfile_complaints,
_("Member function \"%s\" (offset %d) is virtual "
"but the vtable offset is not specified"),
- fieldname, die->offset);
+ fieldname, die->offset.sect_off);
ALLOCATE_CPLUS_STRUCT_TYPE (type);
TYPE_CPLUS_DYNAMIC (type) = 1;
}
= lookup_signatured_type_at_offset (dwarf2_per_objfile->objfile,
cu->per_cu->debug_types_section,
cu->per_cu->offset);
- if (type_sig->per_cu.offset + type_sig->type_offset
- != die->offset)
+ if (type_sig->per_cu.offset.sect_off + type_sig->type_offset.cu_off
+ != die->offset.sect_off)
return;
}
if (!module_name)
complaint (&symfile_complaints,
_("DW_TAG_module has no name, offset 0x%x"),
- die->offset);
+ die->offset.sect_off);
type = init_type (TYPE_CODE_MODULE, 0, 0, module_name, objfile);
/* determine_prefix uses TYPE_TAG_NAME. */
complaint (&symfile_complaints,
_("Self-referential DW_TAG_typedef "
"- DIE at 0x%x [in module %s]"),
- die->offset, objfile->name);
+ die->offset.sect_off, objfile->name);
TYPE_TARGET_TYPE (this_type) = NULL;
}
return this_type;
{
const struct die_info *die = item;
- return die->offset;
+ return die->offset.sect_off;
}
/* Trivial comparison function for die_info structures: two DIEs
const struct die_info *die_lhs = item_lhs;
const struct die_info *die_rhs = item_rhs;
- return die_lhs->offset == die_rhs->offset;
+ return die_lhs->offset.sect_off == die_rhs->offset.sect_off;
}
/* Read a whole compilation unit into a linked list of dies. */
struct die_info **diep, gdb_byte *info_ptr,
int *has_children)
{
- unsigned int abbrev_number, bytes_read, i, offset;
+ unsigned int abbrev_number, bytes_read, i;
+ sect_offset offset;
struct abbrev_info *abbrev;
struct die_info *die;
struct dwarf2_cu *cu = reader->cu;
bfd *abfd = reader->abfd;
- offset = info_ptr - reader->buffer;
+ offset.sect_off = info_ptr - reader->buffer;
abbrev_number = read_unsigned_leb128 (abfd, info_ptr, &bytes_read);
info_ptr += bytes_read;
if (!abbrev_number)
dwarf2_read_section (dwarf2_per_objfile->objfile,
&dwarf2_per_objfile->abbrev);
- abbrev_ptr = dwarf2_per_objfile->abbrev.buffer + cu_header->abbrev_offset;
+ abbrev_ptr = (dwarf2_per_objfile->abbrev.buffer
+ + cu_header->abbrev_offset.sect_off);
abbrev_number = read_unsigned_leb128 (abfd, abbrev_ptr, &bytes_read);
abbrev_ptr += bytes_read;
complaint (&symfile_complaints,
_("DW_TAG_typedef has childen - GCC PR debug/47510 bug "
"- DIE at 0x%x [in module %s]"),
- part_die->offset, objfile->name);
+ part_die->offset.sect_off, objfile->name);
/* If we're at the second level, and we're an enumerator, and
our parent has no specification (meaning possibly lives in a
void **slot;
slot = htab_find_slot_with_hash (cu->partial_dies, part_die,
- part_die->offset, INSERT);
+ part_die->offset.sect_off, INSERT);
*slot = part_die;
}
memset (part_die, 0, sizeof (struct partial_die_info));
- part_die->offset = info_ptr - buffer;
+ part_die->offset.sect_off = info_ptr - buffer;
info_ptr += abbrev_len;
complaint (&symfile_complaints,
_("ignoring absolute DW_AT_sibling"));
else
- part_die->sibling = buffer + dwarf2_get_ref_die_offset (&attr);
+ part_die->sibling = buffer + dwarf2_get_ref_die_offset (&attr).sect_off;
break;
case DW_AT_byte_size:
part_die->has_byte_size = 1;
_("DW_AT_low_pc %s is zero "
"for DIE at 0x%x [in module %s]"),
paddress (gdbarch, part_die->lowpc),
- part_die->offset, objfile->name);
+ part_die->offset.sect_off, objfile->name);
}
/* dwarf2_get_pc_bounds has also the strict low < high requirement. */
else if (part_die->lowpc >= part_die->highpc)
"for DIE at 0x%x [in module %s]"),
paddress (gdbarch, part_die->lowpc),
paddress (gdbarch, part_die->highpc),
- part_die->offset, objfile->name);
+ part_die->offset.sect_off, objfile->name);
}
else
part_die->has_pc_info = 1;
/* Find a cached partial DIE at OFFSET in CU. */
static struct partial_die_info *
-find_partial_die_in_comp_unit (unsigned int offset, struct dwarf2_cu *cu)
+find_partial_die_in_comp_unit (sect_offset offset, struct dwarf2_cu *cu)
{
struct partial_die_info *lookup_die = NULL;
struct partial_die_info part_die;
part_die.offset = offset;
- lookup_die = htab_find_with_hash (cu->partial_dies, &part_die, offset);
+ lookup_die = htab_find_with_hash (cu->partial_dies, &part_die,
+ offset.sect_off);
return lookup_die;
}
DW_FORM_ref_sig8). */
static struct partial_die_info *
-find_partial_die (unsigned int offset, struct dwarf2_cu *cu)
+find_partial_die (sect_offset offset, struct dwarf2_cu *cu)
{
struct objfile *objfile = cu->objfile;
struct dwarf2_per_cu_data *per_cu = NULL;
make_cleanup (dwarf2_free_abbrev_table, per_cu->cu);
}
info_ptr = (dwarf2_per_objfile->info.buffer
- + per_cu->cu->header.offset
- + per_cu->cu->header.first_die_offset);
+ + per_cu->cu->header.offset.sect_off
+ + per_cu->cu->header.first_die_offset.cu_off);
abbrev = peek_die_abbrev (info_ptr, &bytes_read, per_cu->cu);
info_ptr = read_partial_die (&comp_unit_die, abbrev, bytes_read,
objfile->obfd,
internal_error (__FILE__, __LINE__,
_("could not find partial DIE 0x%x "
"in cache [from module %s]\n"),
- offset, bfd_get_filename (objfile->obfd));
+ offset.sect_off, bfd_get_filename (objfile->obfd));
return pd;
}
info_ptr += bytes_read;
break;
case DW_FORM_ref1:
- DW_ADDR (attr) = cu->header.offset + read_1_byte (abfd, info_ptr);
+ DW_ADDR (attr) = (cu->header.offset.sect_off
+ + read_1_byte (abfd, info_ptr));
info_ptr += 1;
break;
case DW_FORM_ref2:
- DW_ADDR (attr) = cu->header.offset + read_2_bytes (abfd, info_ptr);
+ DW_ADDR (attr) = (cu->header.offset.sect_off
+ + read_2_bytes (abfd, info_ptr));
info_ptr += 2;
break;
case DW_FORM_ref4:
- DW_ADDR (attr) = cu->header.offset + read_4_bytes (abfd, info_ptr);
+ DW_ADDR (attr) = (cu->header.offset.sect_off
+ + read_4_bytes (abfd, info_ptr));
info_ptr += 4;
break;
case DW_FORM_ref8:
- DW_ADDR (attr) = cu->header.offset + read_8_bytes (abfd, info_ptr);
+ DW_ADDR (attr) = (cu->header.offset.sect_off
+ + read_8_bytes (abfd, info_ptr));
info_ptr += 8;
break;
case DW_FORM_ref_sig8:
info_ptr += 8;
break;
case DW_FORM_ref_udata:
- DW_ADDR (attr) = (cu->header.offset
+ DW_ADDR (attr) = (cu->header.offset.sect_off
+ read_unsigned_leb128 (abfd, info_ptr, &bytes_read));
info_ptr += bytes_read;
break;
if (is_ref_attr (attr))
{
- unsigned int offset = dwarf2_get_ref_die_offset (attr);
+ sect_offset offset = dwarf2_get_ref_die_offset (attr);
this_type = get_die_type_at_offset (offset, cu->per_cu);
}
{
struct signatured_type *sig_type = DW_SIGNATURED_TYPE (attr);
struct dwarf2_cu *sig_cu;
- unsigned int offset;
+ sect_offset offset;
/* sig_type will be NULL if the signatured type is missing from
the debug info. */
if (sig_type == NULL)
error (_("Dwarf Error: Cannot find signatured DIE referenced from DIE "
"at 0x%x [in module %s]"),
- die->offset, objfile->name);
+ die->offset.sect_off, objfile->name);
gdb_assert (sig_type->per_cu.debug_types_section);
- offset = sig_type->per_cu.offset + sig_type->type_offset;
+ offset.sect_off = (sig_type->per_cu.offset.sect_off
+ + sig_type->type_offset.cu_off);
this_type = get_die_type_at_offset (offset, &sig_type->per_cu);
}
else
/* read_type_die already issued a complaint. */
message = xstrprintf (_("<unknown type in %s, CU 0x%x, DIE 0x%x>"),
objfile->name,
- cu->header.offset,
- die->offset);
+ cu->header.offset.sect_off,
+ die->offset.sect_off);
saved = obstack_copy0 (&objfile->objfile_obstack,
message, strlen (message));
xfree (message);
print_spaces (indent, f);
fprintf_unfiltered (f, "Die: %s (abbrev %d, offset 0x%x)\n",
- dwarf_tag_name (die->tag), die->abbrev, die->offset);
+ dwarf_tag_name (die->tag), die->abbrev, die->offset.sect_off);
if (die->parent != NULL)
{
print_spaces (indent, f);
fprintf_unfiltered (f, " parent at offset: 0x%x\n",
- die->parent->offset);
+ die->parent->offset.sect_off);
}
print_spaces (indent, f);
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])->per_cu.offset);
+ DW_SIGNATURED_TYPE (&die->attrs[i])->per_cu.offset.sect_off);
else
fprintf_unfiltered (f, "signatured type, offset: unknown");
break;
{
void **slot;
- slot = htab_find_slot_with_hash (cu->die_hash, die, die->offset, INSERT);
+ slot = htab_find_slot_with_hash (cu->die_hash, die, die->offset.sect_off,
+ INSERT);
*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)
{
}
}
-static unsigned int
+/* 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)
{
+ sect_offset retval = { DW_ADDR (attr) };
+
if (is_ref_attr (attr))
- return DW_ADDR (attr);
+ return retval;
+ retval.sect_off = 0;
complaint (&symfile_complaints,
_("unsupported die ref attribute form: '%s'"),
dwarf_form_name (attr->form));
- return 0;
+ return retval;
}
/* Return the constant value held by ATTR. Return DEFAULT_VALUE if
Returns NULL if OFFSET is invalid. */
static struct die_info *
-follow_die_offset (unsigned int offset, struct dwarf2_cu **ref_cu)
+follow_die_offset (sect_offset offset, struct dwarf2_cu **ref_cu)
{
struct die_info temp_die;
struct dwarf2_cu *target_cu, *cu = *ref_cu;
*ref_cu = target_cu;
temp_die.offset = offset;
- return htab_find_with_hash (target_cu->die_hash, &temp_die, offset);
+ return htab_find_with_hash (target_cu->die_hash, &temp_die, offset.sect_off);
}
/* Follow reference attribute ATTR of SRC_DIE.
follow_die_ref (struct die_info *src_die, struct attribute *attr,
struct dwarf2_cu **ref_cu)
{
- unsigned int offset = dwarf2_get_ref_die_offset (attr);
+ sect_offset offset = dwarf2_get_ref_die_offset (attr);
struct dwarf2_cu *cu = *ref_cu;
struct die_info *die;
if (!die)
error (_("Dwarf Error: Cannot find DIE at 0x%x referenced from DIE "
"at 0x%x [in module %s]"),
- offset, src_die->offset, cu->objfile->name);
+ offset.sect_off, src_die->offset.sect_off, cu->objfile->name);
return die;
}
dwarf2_locexpr_baton->data has lifetime of PER_CU->OBJFILE. */
struct dwarf2_locexpr_baton
-dwarf2_fetch_die_location_block (unsigned int offset_in_cu,
+dwarf2_fetch_die_location_block (cu_offset offset_in_cu,
struct dwarf2_per_cu_data *per_cu,
CORE_ADDR (*get_frame_pc) (void *baton),
void *baton)
{
- unsigned int offset = per_cu->offset + offset_in_cu;
+ sect_offset offset = { per_cu->offset.sect_off + offset_in_cu.cu_off };
struct dwarf2_cu *cu;
struct die_info *die;
struct attribute *attr;
die = follow_die_offset (offset, &cu);
if (!die)
error (_("Dwarf Error: Cannot find DIE at 0x%x referenced in module %s"),
- offset, per_cu->objfile->name);
+ offset.sect_off, per_cu->objfile->name);
attr = dwarf2_attr (die, DW_AT_location, cu);
if (!attr)
if (!attr_form_is_block (attr))
error (_("Dwarf Error: DIE at 0x%x referenced in module %s "
"is neither DW_FORM_block* nor DW_FORM_exprloc"),
- offset, per_cu->objfile->name);
+ offset.sect_off, per_cu->objfile->name);
retval.data = DW_BLOCK (attr)->data;
retval.size = DW_BLOCK (attr)->size;
PER_CU. */
struct type *
-dwarf2_get_die_type (unsigned int die_offset,
+dwarf2_get_die_type (cu_offset die_offset,
struct dwarf2_per_cu_data *per_cu)
{
+ sect_offset die_offset_sect;
+
dw2_setup (per_cu->objfile);
- return get_die_type_at_offset (per_cu->offset + die_offset, per_cu);
+
+ die_offset_sect.sect_off = per_cu->offset.sect_off + die_offset.cu_off;
+ return get_die_type_at_offset (die_offset_sect, per_cu);
}
/* Follow the signature attribute ATTR in SRC_DIE.
if (sig_type == NULL)
error (_("Dwarf Error: Cannot find signatured DIE referenced from DIE "
"at 0x%x [in module %s]"),
- src_die->offset, objfile->name);
+ src_die->offset.sect_off, objfile->name);
/* If necessary, add it to the queue and load its DIEs. */
gdb_assert (sig_type->per_cu.cu != NULL);
sig_cu = sig_type->per_cu.cu;
- temp_die.offset = sig_cu->header.offset + sig_type->type_offset;
- die = htab_find_with_hash (sig_cu->die_hash, &temp_die, temp_die.offset);
+ temp_die.offset.sect_off = (sig_type->per_cu.offset.sect_off
+ + sig_type->type_offset.cu_off);
+ die = htab_find_with_hash (sig_cu->die_hash, &temp_die,
+ temp_die.offset.sect_off);
if (die)
{
*ref_cu = sig_cu;
error (_("Dwarf Error: Cannot find signatured DIE at 0x%x referenced "
"from DIE at 0x%x [in module %s]"),
- sig_type->type_offset, src_die->offset, objfile->name);
+ temp_die.offset.sect_off, src_die->offset.sect_off, objfile->name);
}
/* Given an offset of a signatured type, return its signatured_type. */
static struct signatured_type *
lookup_signatured_type_at_offset (struct objfile *objfile,
struct dwarf2_section_info *section,
- unsigned int offset)
+ sect_offset offset)
{
- gdb_byte *info_ptr = section->buffer + offset;
+ gdb_byte *info_ptr = section->buffer + offset.sect_off;
unsigned int length, initial_length_size;
unsigned int sig_offset;
struct signatured_type find_entry, *type_sig;
/* 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->per_cu.offset);
+ gdb_assert (offset.sect_off == type_sig->per_cu.offset.sect_off);
return type_sig;
}
{
struct objfile *objfile = per_cu->objfile;
struct dwarf2_section_info *sect = per_cu->debug_types_section;
- unsigned int offset = per_cu->offset;
+ sect_offset offset = per_cu->offset;
struct signatured_type *type_sig;
dwarf2_read_section (objfile, sect);
struct dwarf2_section_info *section = type_sig->per_cu.debug_types_section;
dwarf2_read_section (objfile, section);
- types_ptr = section->buffer + type_sig->per_cu.offset;
+ types_ptr = section->buffer + type_sig->per_cu.offset.sect_off;
gdb_assert (type_sig->per_cu.cu == NULL);
objfile = per_cu->objfile;
per_objfile = objfile_data (objfile, dwarf2_objfile_data_key);
- info_ptr = per_objfile->info.buffer + per_cu->offset;
+ info_ptr = per_objfile->info.buffer + per_cu->offset.sect_off;
memset (cu_headerp, 0, sizeof (*cu_headerp));
read_comp_unit_head (cu_headerp, info_ptr, objfile->obfd);
the DIE at OFFSET. Raises an error on failure. */
static struct dwarf2_per_cu_data *
-dwarf2_find_containing_comp_unit (unsigned int offset,
+dwarf2_find_containing_comp_unit (sect_offset offset,
struct objfile *objfile)
{
struct dwarf2_per_cu_data *this_cu;
{
int mid = low + (high - low) / 2;
- if (dwarf2_per_objfile->all_comp_units[mid]->offset >= offset)
+ if (dwarf2_per_objfile->all_comp_units[mid]->offset.sect_off
+ >= offset.sect_off)
high = mid;
else
low = mid + 1;
}
gdb_assert (low == high);
- if (dwarf2_per_objfile->all_comp_units[low]->offset > offset)
+ if (dwarf2_per_objfile->all_comp_units[low]->offset.sect_off
+ > offset.sect_off)
{
if (low == 0)
error (_("Dwarf Error: could not find partial DIE containing "
"offset 0x%lx [in module %s]"),
- (long) offset, bfd_get_filename (objfile->obfd));
+ (long) offset.sect_off, bfd_get_filename (objfile->obfd));
- gdb_assert (dwarf2_per_objfile->all_comp_units[low-1]->offset <= offset);
+ gdb_assert (dwarf2_per_objfile->all_comp_units[low-1]->offset.sect_off
+ <= offset.sect_off);
return dwarf2_per_objfile->all_comp_units[low-1];
}
else
{
this_cu = dwarf2_per_objfile->all_comp_units[low];
if (low == dwarf2_per_objfile->n_comp_units - 1
- && offset >= this_cu->offset + this_cu->length)
- error (_("invalid dwarf2 offset %u"), offset);
- gdb_assert (offset < this_cu->offset + this_cu->length);
+ && offset.sect_off >= this_cu->offset.sect_off + this_cu->length)
+ error (_("invalid dwarf2 offset %u"), offset.sect_off);
+ gdb_assert (offset.sect_off < this_cu->offset.sect_off + this_cu->length);
return this_cu;
}
}
struct dwarf2_offset_and_type
{
- unsigned int offset;
+ sect_offset offset;
struct type *type;
};
{
const struct dwarf2_offset_and_type *ofs = item;
- return ofs->offset;
+ return ofs->offset.sect_off;
}
/* Equality function for a dwarf2_offset_and_type. */
const struct dwarf2_offset_and_type *ofs_lhs = item_lhs;
const struct dwarf2_offset_and_type *ofs_rhs = item_rhs;
- return ofs_lhs->offset == ofs_rhs->offset;
+ return ofs_lhs->offset.sect_off == ofs_rhs->offset.sect_off;
}
/* Set the type associated with DIE to TYPE. Save it in CU's hash
ofs.offset = die->offset;
ofs.type = type;
slot = (struct dwarf2_offset_and_type **)
- htab_find_slot_with_hash (*type_hash_ptr, &ofs, ofs.offset, INSERT);
+ htab_find_slot_with_hash (*type_hash_ptr, &ofs, ofs.offset.sect_off,
+ INSERT);
if (*slot)
complaint (&symfile_complaints,
_("A problem internal to GDB: DIE 0x%x has type already set"),
- die->offset);
+ die->offset.sect_off);
*slot = obstack_alloc (&objfile->objfile_obstack, sizeof (**slot));
**slot = ofs;
return type;
table, or return NULL if the die does not have a saved type. */
static struct type *
-get_die_type_at_offset (unsigned int offset,
+get_die_type_at_offset (sect_offset offset,
struct dwarf2_per_cu_data *per_cu)
{
struct dwarf2_offset_and_type *slot, ofs;
return NULL;
ofs.offset = offset;
- slot = htab_find_with_hash (type_hash, &ofs, ofs.offset);
+ slot = htab_find_with_hash (type_hash, &ofs, ofs.offset.sect_off);
if (slot)
return slot->type;
else
{
const struct partial_die_info *part_die = item;
- return part_die->offset;
+ return part_die->offset.sect_off;
}
/* Trivial comparison function for partial_die_info structures: two DIEs
const struct partial_die_info *part_die_lhs = item_lhs;
const struct partial_die_info *part_die_rhs = item_rhs;
- return part_die_lhs->offset == part_die_rhs->offset;
+ return part_die_lhs->offset.sect_off == part_die_rhs->offset.sect_off;
}
static struct cmd_list_element *set_dwarf2_cmdlist;
psymtab->n_static_syms, info->cu_index,
1);
- store_unsigned_integer (val, 8, BFD_ENDIAN_LITTLE, entry->per_cu.offset);
+ store_unsigned_integer (val, 8, BFD_ENDIAN_LITTLE,
+ entry->per_cu.offset.sect_off);
obstack_grow (info->types_list, val, 8);
- store_unsigned_integer (val, 8, BFD_ENDIAN_LITTLE, entry->type_offset);
+ store_unsigned_integer (val, 8, BFD_ENDIAN_LITTLE, entry->type_offset.cu_off);
obstack_grow (info->types_list, val, 8);
store_unsigned_integer (val, 8, BFD_ENDIAN_LITTLE, entry->signature);
obstack_grow (info->types_list, val, 8);
gdb_assert (*slot == NULL);
*slot = map;
- store_unsigned_integer (val, 8, BFD_ENDIAN_LITTLE, per_cu->offset);
+ store_unsigned_integer (val, 8, BFD_ENDIAN_LITTLE,
+ per_cu->offset.sect_off);
obstack_grow (&cu_list, val, 8);
store_unsigned_integer (val, 8, BFD_ENDIAN_LITTLE, per_cu->length);
obstack_grow (&cu_list, val, 8);