/* Initialize per-objfile state. */
struct dwarf2_per_objfile *data
= obstack_alloc (&objfile->objfile_obstack, sizeof (*data));
+
memset (data, 0, sizeof (*data));
set_objfile_data (objfile, dwarf2_objfile_data_key, data);
dwarf2_per_objfile = data;
else if (section_is_p (sectp->name, EH_FRAME_SECTION))
{
flagword aflag = bfd_get_section_flags (ignore_abfd, sectp);
+
if (aflag & SEC_HAS_CONTENTS)
{
dwarf2_per_objfile->eh_frame.asection = sectp;
unsigned int top = (cu_header->offset
+ cu_header->length
+ cu_header->initial_length_size);
+
return (offset >= bottom && offset < top);
}
if (attr)
{
unsigned int line_offset = DW_UNSND (attr);
+
lh = dwarf_decode_line_header (line_offset, abfd, cu);
}
if (lh == NULL)
hash_type_signature (const void *item)
{
const struct signatured_type *type_sig = item;
+
/* This drops the top 32 bits of the signature, but is ok for a hash. */
return type_sig->signature;
}
{
const struct signatured_type *lhs = item_lhs;
const struct signatured_type *rhs = item_rhs;
+
return lhs->signature == rhs->signature;
}
struct dwarf2_per_objfile *dpo_backlink
= objfile_data (pst->objfile->separate_debug_objfile_backlink,
dwarf2_objfile_data_key);
+
dwarf2_per_objfile->has_section_at_zero
= dpo_backlink->has_section_at_zero;
}
case DW_TAG_base_type:
case DW_TAG_subrange_type:
case DW_TAG_typedef:
+ case DW_TAG_const_type:
+ case DW_TAG_volatile_type:
/* Add a typedef symbol for the type definition, if it has a
DW_AT_name. */
new_symbol (die, read_type_die (die, cu), cu);
if (dwarf2_attr (die, DW_AT_specification, cu))
{
struct dwarf2_cu *spec_cu = cu;
+
return die_needs_namespace (die_specification (die, &spec_cu),
spec_cu);
}
if (*prefix != '\0')
{
char *prefixed_name = typename_concat (NULL, prefix, name, cu);
+
fputs_unfiltered (prefixed_name, buf);
xfree (prefixed_name);
}
char *cname
= dwarf2_canonicalize_name (name, cu,
&cu->objfile->objfile_obstack);
+
if (cname != NULL)
name = cname;
}
if (attr && line_header)
{
unsigned int macro_offset = DW_UNSND (attr);
+
dwarf_decode_macros (line_header, macro_offset,
comp_dir, abfd, cu);
}
but GCC versions at least through 4.4 generate this (GCC PR
40573). */
struct die_info *child_origin_die = child_die;
+
while (1)
{
attr = dwarf2_attr (child_origin_die, DW_AT_abstract_origin, cu);
if (attr)
{
CORE_ADDR high = DW_ADDR (attr);
+
attr = dwarf2_attr (die, DW_AT_low_pc, cu);
if (attr)
{
CORE_ADDR low = DW_ADDR (attr);
+
record_block_range (block, baseaddr + low, baseaddr + high - 1);
}
}
&& DW_BLOCK (attr)->data[0] == DW_OP_deref)
{
struct dwarf_block blk;
+
blk.size = DW_BLOCK (attr)->size - 1;
blk.data = DW_BLOCK (attr)->data + 1;
fnp->voffset = decode_locdesc (&blk, cu);
{
struct dwarf2_cu *type_cu = cu;
struct die_info *type_die = follow_die_ref_or_sig (die, attr, &type_cu);
+
/* We could just recurse on read_structure_type, but we need to call
get_die_type to ensure only one type for this DIE is created.
This is important, for example, because for c++ classes we need
{
struct dwarf2_cu *type_cu = cu;
struct die_info *type_die = follow_die_ref_or_sig (die, attr, &type_cu);
+
type = read_type_die (type_die, type_cu);
return set_die_type (die, type, cu);
}
if (child_die->tag == DW_TAG_subrange_type)
{
struct type *child_type = read_type_die (child_die, cu);
+
if (child_type != NULL)
{
/* The range type was succesfully read. Save it for
if (read_array_order (die, cu) == DW_ORD_col_major)
{
int i = 0;
+
while (i < ndim)
type = create_array_type (NULL, type, range_types[i++]);
}
read_set_type (struct die_info *die, struct dwarf2_cu *cu)
{
struct type *set_type = create_set_type (NULL, die_type (die, cu));
+ struct attribute *attr = dwarf2_attr (die, DW_AT_byte_size, cu);
+ if (attr)
+ TYPE_LENGTH (set_type) = DW_UNSND (attr);
return set_die_type (die, set_type, cu);
}
{
struct die_info *ext_die;
struct dwarf2_cu *ext_cu = cu;
+
ext_die = dwarf2_extension (die, &ext_cu);
type = read_type_die (ext_die, ext_cu);
return set_die_type (die, type, cu);
if (is_anonymous)
{
const char *previous_prefix = determine_prefix (die, cu);
+
cp_add_using_directive (previous_prefix, TYPE_NAME (type), NULL,
NULL, &objfile->objfile_obstack);
}
{
complaint (&symfile_complaints, _("invalid pointer size %d"), byte_size);
}
- else {
- /* Should we also complain about unhandled address classes? */
- }
+ else
+ {
+ /* Should we also complain about unhandled address classes? */
+ }
}
TYPE_LENGTH (type) = byte_size;
if (cu->language == language_java)
{
const char *name = dwarf2_name (child_die, cu);
+
if (name && !strcmp (name, "this"))
TYPE_FIELD_ARTIFICIAL (ftype, iparams) = 1;
}
die_hash (const void *item)
{
const struct die_info *die = item;
+
return die->offset;
}
{
const struct die_info *die_lhs = item_lhs;
const struct die_info *die_rhs = item_rhs;
+
return die_lhs->offset == die_rhs->offset;
}
unsigned int *bytes_read)
{
LONGEST offset = read_offset_1 (abfd, buf, cu_header->offset_size);
+
*bytes_read = cu_header->offset_size;
return offset;
}
for (i = 0; i < lh->num_file_names; i++)
{
char *dir = NULL;
+
fe = &lh->file_names[i];
if (fe->dir_index)
dir = lh->include_dirs[fe->dir_index - 1];
if (attr)
{
int file_index = DW_UNSND (attr);
+
if (cu->line_header == NULL
|| file_index > cu->line_header->num_file_names)
complaint (&symfile_complaints,
else if (file_index > 0)
{
struct file_entry *fe;
+
fe = &cu->line_header->file_names[file_index - 1];
SYMBOL_SYMTAB (sym) = fe->symtab;
}
{
dwarf2_const_value (attr, sym, cu);
}
+ attr = dwarf2_attr (die, DW_AT_variable_parameter, cu);
+ if (attr && DW_UNSND (attr))
+ {
+ struct type *ref_type;
+
+ ref_type = lookup_reference_type (SYMBOL_TYPE (sym));
+ SYMBOL_TYPE (sym) = ref_type;
+ }
+
add_symbol_to_list (sym, cu->list_in_scope);
break;
case DW_TAG_unspecified_parameters:
break;
case DW_TAG_base_type:
case DW_TAG_subrange_type:
+ case DW_TAG_const_type:
+ case DW_TAG_volatile_type:
SYMBOL_CLASS (sym) = LOC_TYPEDEF;
SYMBOL_DOMAIN (sym) = VAR_DOMAIN;
add_symbol_to_list (sym, cu->list_in_scope);
static struct type *
die_type (struct die_info *die, struct dwarf2_cu *cu)
{
- struct type *type;
struct attribute *type_attr;
struct die_info *type_die;
type_die = follow_die_ref_or_sig (die, type_attr, &cu);
- type = tag_type_to_type (type_die, cu);
- if (!type)
- {
- dump_die_for_error (type_die);
- error (_("Dwarf Error: Problem turning type die at offset into gdb type [in module %s]"),
- cu->objfile->name);
- }
- return type;
+ return tag_type_to_type (type_die, cu);
}
/* True iff CU's producer generates GNAT Ada auxiliary information
static struct type *
die_descriptive_type (struct die_info *die, struct dwarf2_cu *cu)
{
- struct type *type;
struct attribute *type_attr;
struct die_info *type_die;
return NULL;
type_die = follow_die_ref (die, type_attr, &cu);
- type = tag_type_to_type (type_die, cu);
- if (!type)
- {
- dump_die_for_error (type_die);
- error (_("Dwarf Error: Problem turning type die at offset into gdb type [in module %s]"),
- cu->objfile->name);
- }
- return type;
+ return tag_type_to_type (type_die, cu);
}
/* If DIE has a descriptive_type attribute, then set the TYPE's
static struct type *
die_containing_type (struct die_info *die, struct dwarf2_cu *cu)
{
- struct type *type = NULL;
struct attribute *type_attr;
- struct die_info *type_die = NULL;
+ struct die_info *type_die;
type_attr = dwarf2_attr (die, DW_AT_containing_type, cu);
- if (type_attr)
- {
- type_die = follow_die_ref_or_sig (die, type_attr, &cu);
- type = tag_type_to_type (type_die, cu);
- }
- if (!type)
- {
- if (type_die)
- dump_die_for_error (type_die);
- error (_("Dwarf Error: Problem turning containing type into gdb type [in module %s]"),
- cu->objfile->name);
- }
- return type;
+ if (!type_attr)
+ error (_("Dwarf Error: Problem turning containing type into gdb type "
+ "[in module %s]"), cu->objfile->name);
+
+ type_die = follow_die_ref_or_sig (die, type_attr, &cu);
+ return tag_type_to_type (type_die, cu);
}
static struct type *
if (obs == NULL)
{
char *retval = xmalloc (strlen (prefix) + MAX_SEP_LEN + strlen (suffix) + 1);
+
strcpy (retval, prefix);
strcat (retval, sep);
strcat (retval, suffix);
else if (! offset_in_cu_p (&cu->header, offset))
{
struct dwarf2_per_cu_data *per_cu;
+
per_cu = dwarf2_find_containing_comp_unit (offset, cu->objfile);
/* If necessary, add it to the queue and load its DIEs. */
record the macro definitions made in the file, even if we
won't be able to find the file by name. */
char fake_name[80];
+
sprintf (fake_name, "<bad macro file number %d>", file);
complaint (&symfile_complaints,
copy_string (const char *buf, int len)
{
char *s = xmalloc (len + 1);
+
memcpy (s, buf, len);
s[len] = '\0';
-
return s;
}
struct dwarf2_per_objfile *per_objfile
= objfile_data (objfile, dwarf2_objfile_data_key);
gdb_byte *info_ptr = per_objfile->info.buffer + per_cu->offset;
-
struct comp_unit_head cu_header;
+
memset (&cu_header, 0, sizeof cu_header);
read_comp_unit_head (&cu_header, info_ptr, objfile->obfd);
return cu_header.addr_size;
while (high > low)
{
int mid = low + (high - low) / 2;
+
if (dwarf2_per_objfile->all_comp_units[mid]->offset >= offset)
high = mid;
else
dwarf2_find_comp_unit (unsigned int offset, struct objfile *objfile)
{
struct dwarf2_per_cu_data *this_cu;
+
this_cu = dwarf2_find_containing_comp_unit (offset, objfile);
if (this_cu->offset != offset)
error (_("no compilation unit with offset %u."), offset);
offset_and_type_hash (const void *item)
{
const struct dwarf2_offset_and_type *ofs = item;
+
return ofs->offset;
}
{
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;
}
partial_die_hash (const void *item)
{
const struct partial_die_info *part_die = item;
+
return part_die->offset;
}
{
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;
}
intptr_t begin = (intptr_t) info->buffer;
intptr_t map_begin = begin & ~(pagesize - 1);
size_t map_length = info->size + begin - map_begin;
+
gdb_assert (munmap ((void *) map_begin, map_length) == 0);
#else
/* Without HAVE_MMAP, we should never be here to begin with. */
dwarf2_per_objfile_free (struct objfile *objfile, void *d)
{
struct dwarf2_per_objfile *data = d;
+
munmap_section_buffer (&data->info);
munmap_section_buffer (&data->abbrev);
munmap_section_buffer (&data->line);