#include "addrmap.h"
#include "typeprint.h"
#include "jv-lang.h"
+#include "psympriv.h"
#include <fcntl.h>
#include "gdb_string.h"
#define _ACTUAL_COMP_UNIT_HEADER_SIZE 11
#endif
-/* .debug_pubnames header
- Because of alignment constraints, this structure has padding and cannot
- be mapped directly onto the beginning of the .debug_info section. */
-typedef struct pubnames_header
- {
- unsigned int length; /* length of the .debug_pubnames
- contribution */
- unsigned char version; /* version number -- 2 for DWARF
- version 2 */
- unsigned int info_offset; /* offset into .debug_info section */
- unsigned int info_size; /* byte size of .debug_info section
- portion */
- }
-_PUBNAMES_HEADER;
-#define _ACTUAL_PUBNAMES_HEADER_SIZE 13
-
-/* .debug_pubnames header
- Because of alignment constraints, this structure has padding and cannot
- be mapped directly onto the beginning of the .debug_info section. */
-typedef struct aranges_header
- {
- unsigned int length; /* byte len of the .debug_aranges
- contribution */
- unsigned short version; /* version number -- 2 for DWARF
- version 2 */
- unsigned int info_offset; /* offset into .debug_info section */
- unsigned char addr_size; /* byte size of an address */
- unsigned char seg_size; /* byte size of segment descriptor */
- }
-_ARANGES_HEADER;
-#define _ACTUAL_ARANGES_HEADER_SIZE 12
-
/* .debug_line statement program prologue
Because of alignment constraints, this structure has padding and cannot
be mapped directly onto the beginning of the .debug_info section. */
gdb_byte *buffer;
bfd_size_type size;
int was_mmapped;
+ /* True if we have tried to read this section. */
+ int readin;
};
struct dwarf2_per_objfile
struct dwarf2_section_info info;
struct dwarf2_section_info abbrev;
struct dwarf2_section_info line;
- struct dwarf2_section_info pubnames;
- struct dwarf2_section_info aranges;
struct dwarf2_section_info loc;
struct dwarf2_section_info macinfo;
struct dwarf2_section_info str;
struct dwarf2_section_info frame;
struct dwarf2_section_info eh_frame;
+ /* Back link. */
+ struct objfile *objfile;
+
/* A list of all the compilation units. This is used to locate
the target compilation unit of a particular reference. */
struct dwarf2_per_cu_data **all_comp_units;
#define INFO_SECTION "debug_info"
#define ABBREV_SECTION "debug_abbrev"
#define LINE_SECTION "debug_line"
-#define PUBNAMES_SECTION "debug_pubnames"
-#define ARANGES_SECTION "debug_aranges"
#define LOC_SECTION "debug_loc"
#define MACINFO_SECTION "debug_macinfo"
#define STR_SECTION "debug_str"
static void dwarf2_locate_sections (bfd *, asection *, void *);
-#if 0
-static void dwarf2_build_psymtabs_easy (struct objfile *);
-#endif
-
static void dwarf2_create_include_psymtab (char *, struct partial_symtab *,
struct objfile *);
int
dwarf2_has_info (struct objfile *objfile)
{
- struct dwarf2_per_objfile *data;
-
- /* Initialize per-objfile state. */
- 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;
+ dwarf2_per_objfile = objfile_data (objfile, dwarf2_objfile_data_key);
+ if (!dwarf2_per_objfile)
+ {
+ /* 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;
- bfd_map_over_sections (objfile->obfd, dwarf2_locate_sections, NULL);
- return (data->info.asection != NULL && data->abbrev.asection != NULL);
+ bfd_map_over_sections (objfile->obfd, dwarf2_locate_sections, NULL);
+ dwarf2_per_objfile->objfile = objfile;
+ }
+ return (dwarf2_per_objfile->info.asection != NULL
+ && dwarf2_per_objfile->abbrev.asection != NULL);
}
/* When loading sections, we can either look for ".<name>", or for
dwarf2_per_objfile->line.asection = sectp;
dwarf2_per_objfile->line.size = bfd_get_section_size (sectp);
}
- else if (section_is_p (sectp->name, PUBNAMES_SECTION))
- {
- dwarf2_per_objfile->pubnames.asection = sectp;
- dwarf2_per_objfile->pubnames.size = bfd_get_section_size (sectp);
- }
- else if (section_is_p (sectp->name, ARANGES_SECTION))
- {
- dwarf2_per_objfile->aranges.asection = sectp;
- dwarf2_per_objfile->aranges.size = bfd_get_section_size (sectp);
- }
else if (section_is_p (sectp->name, LOC_SECTION))
{
dwarf2_per_objfile->loc.asection = sectp;
gdb_byte *buf, *retbuf;
unsigned char header[4];
+ if (info->readin)
+ return;
info->buffer = NULL;
info->was_mmapped = 0;
+ info->readin = 1;
if (info->asection == NULL || info->size == 0)
return;
{
info->was_mmapped = 1;
info->buffer = retbuf + (sectp->filepos & (pagesize - 1)) ;
+#if HAVE_POSIX_MADVISE
+ posix_madvise (retbuf, map_length, POSIX_MADV_WILLNEED);
+#endif
return;
}
}
struct dwarf2_per_objfile *data
= objfile_data (objfile, dwarf2_objfile_data_key);
struct dwarf2_section_info *info;
+
+ /* We may see an objfile without any DWARF, in which case we just
+ return nothing. */
+ if (data == NULL)
+ {
+ *sectp = NULL;
+ *bufp = NULL;
+ *sizep = 0;
+ return;
+ }
if (section_is_p (section_name, EH_FRAME_SECTION))
info = &data->eh_frame;
else if (section_is_p (section_name, FRAME_SECTION))
void
dwarf2_build_psymtabs (struct objfile *objfile)
{
- dwarf2_read_section (objfile, &dwarf2_per_objfile->info);
- dwarf2_read_section (objfile, &dwarf2_per_objfile->abbrev);
- dwarf2_read_section (objfile, &dwarf2_per_objfile->line);
- dwarf2_read_section (objfile, &dwarf2_per_objfile->str);
- dwarf2_read_section (objfile, &dwarf2_per_objfile->macinfo);
- dwarf2_read_section (objfile, &dwarf2_per_objfile->ranges);
- dwarf2_read_section (objfile, &dwarf2_per_objfile->types);
- dwarf2_read_section (objfile, &dwarf2_per_objfile->loc);
- dwarf2_read_section (objfile, &dwarf2_per_objfile->eh_frame);
- dwarf2_read_section (objfile, &dwarf2_per_objfile->frame);
-
if (objfile->global_psymbols.size == 0 && objfile->static_psymbols.size == 0)
{
init_psymbol_list (objfile, 1024);
}
-#if 0
- if (dwarf_aranges_offset && dwarf_pubnames_offset)
- {
- /* Things are significantly easier if we have .debug_aranges and
- .debug_pubnames sections */
-
- dwarf2_build_psymtabs_easy (objfile);
- }
- else
-#endif
- /* only test this case for now */
- {
- /* In this case we have to work a bit harder */
- dwarf2_build_psymtabs_hard (objfile);
- }
-}
-
-#if 0
-/* Build the partial symbol table from the information in the
- .debug_pubnames and .debug_aranges sections. */
-
-static void
-dwarf2_build_psymtabs_easy (struct objfile *objfile)
-{
- bfd *abfd = objfile->obfd;
- char *aranges_buffer, *pubnames_buffer;
- char *aranges_ptr, *pubnames_ptr;
- unsigned int entry_length, version, info_offset, info_size;
-
- pubnames_buffer = dwarf2_read_section (objfile,
- dwarf_pubnames_section);
- pubnames_ptr = pubnames_buffer;
- while ((pubnames_ptr - pubnames_buffer) < dwarf2_per_objfile->pubnames.size)
- {
- unsigned int bytes_read;
-
- entry_length = read_initial_length (abfd, pubnames_ptr, &bytes_read);
- pubnames_ptr += bytes_read;
- version = read_1_byte (abfd, pubnames_ptr);
- pubnames_ptr += 1;
- info_offset = read_4_bytes (abfd, pubnames_ptr);
- pubnames_ptr += 4;
- info_size = read_4_bytes (abfd, pubnames_ptr);
- pubnames_ptr += 4;
- }
-
- aranges_buffer = dwarf2_read_section (objfile,
- dwarf_aranges_section);
-
+ dwarf2_build_psymtabs_hard (objfile);
}
-#endif
/* Return TRUE if OFFSET is within CU_HEADER. */
unsigned int bytes_read;
gdb_byte *initial_types_ptr = types_ptr;
+ dwarf2_read_section (dwarf2_per_objfile->objfile, &dwarf2_per_objfile->types);
cu_header->offset = types_ptr - dwarf2_per_objfile->types.buffer;
types_ptr = read_comp_unit_head (cu_header, types_ptr, abfd);
static int
create_debug_types_hash_table (struct objfile *objfile)
{
- gdb_byte *info_ptr = dwarf2_per_objfile->types.buffer;
+ gdb_byte *info_ptr;
htab_t types_htab;
+ dwarf2_read_section (objfile, &dwarf2_per_objfile->types);
+ info_ptr = dwarf2_per_objfile->types.buffer;
+
if (info_ptr == NULL)
{
dwarf2_per_objfile->signatured_types = NULL;
reader->abfd = cu->objfile->obfd;
reader->cu = cu;
if (cu->per_cu->from_debug_types)
- reader->buffer = dwarf2_per_objfile->types.buffer;
+ {
+ gdb_assert (dwarf2_per_objfile->types.readin);
+ reader->buffer = dwarf2_per_objfile->types.buffer;
+ }
else
- reader->buffer = dwarf2_per_objfile->info.buffer;
+ {
+ gdb_assert (dwarf2_per_objfile->info.readin);
+ reader->buffer = dwarf2_per_objfile->info.buffer;
+ }
}
/* Find the base address of the compilation unit for range lists and
if (attr != NULL)
pst->dirname = DW_STRING (attr);
- pst->read_symtab_private = (char *) this_cu;
+ pst->read_symtab_private = this_cu;
baseaddr = ANOFFSET (objfile->section_offsets, SECT_OFF_TEXT (objfile));
this_cu = &entry->per_cu;
this_cu->from_debug_types = 1;
+ 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,
static void
dwarf2_build_psymtabs_hard (struct objfile *objfile)
{
- /* Instead of reading this into a big buffer, we should probably use
- mmap() on architectures that support it. (FIXME) */
bfd *abfd = objfile->obfd;
gdb_byte *info_ptr;
struct cleanup *back_to;
+ dwarf2_read_section (objfile, &dwarf2_per_objfile->info);
info_ptr = dwarf2_per_objfile->info.buffer;
/* Any cached compilation units will be linked by the per-objfile
gdb_assert (! this_cu->from_debug_types);
+ gdb_assert (dwarf2_per_objfile->info.readin);
info_ptr = dwarf2_per_objfile->info.buffer + this_cu->offset;
beg_of_comp_unit = info_ptr;
int n_allocated;
int n_comp_units;
struct dwarf2_per_cu_data **all_comp_units;
- gdb_byte *info_ptr = dwarf2_per_objfile->info.buffer;
+ gdb_byte *info_ptr;
+
+ dwarf2_read_section (objfile, &dwarf2_per_objfile->info);
+ info_ptr = dwarf2_per_objfile->info.buffer;
n_comp_units = 0;
n_allocated = 10;
grandparent_scope = partial_die_parent_scope (parent, cu);
+ /* GCC 4.0 and 4.1 had a bug (PR c++/28460) where they generated bogus
+ DW_TAG_namespace DIEs with a name of "::" for the global namespace.
+ Work around this problem here. */
+ if (cu->language == language_cplus
+ && parent->tag == DW_TAG_namespace
+ && strcmp (parent->name, "::") == 0
+ && grandparent_scope == NULL)
+ {
+ parent->scope = NULL;
+ parent->scope_set = 1;
+ return NULL;
+ }
+
if (parent->tag == DW_TAG_namespace
|| parent->tag == DW_TAG_structure_type
|| parent->tag == DW_TAG_class_type
cu->per_cu->psymtab);
}
if (!pdi->is_declaration)
- add_partial_symbol (pdi, cu);
+ /* Ignore subprogram DIEs that do not have a name, they are
+ illegal. Do not emit a complaint at this point, we will
+ do so when we convert this psymtab into a symtab. */
+ if (pdi->name)
+ add_partial_symbol (pdi, cu);
}
}
psymtab_to_symtab_1 (pst->dependencies[i]);
}
- per_cu = (struct dwarf2_per_cu_data *) pst->read_symtab_private;
+ per_cu = pst->read_symtab_private;
if (per_cu == NULL)
{
/* Set local variables from the partial symbol table info. */
offset = per_cu->offset;
+ dwarf2_read_section (objfile, &dwarf2_per_objfile->info);
info_ptr = dwarf2_per_objfile->info.buffer + offset;
beg_of_comp_unit = info_ptr;
else
set_cu_language (language_minimal, cu);
+ /* Similarly, if we do not read the producer, we can not apply
+ producer-specific interpretation. */
+ attr = dwarf2_attr (cu->dies, DW_AT_producer, cu);
+ if (attr)
+ cu->producer = DW_STRING (attr);
+
/* Link this CU into read_in_chain. */
per_cu->cu->read_in_chain = dwarf2_per_objfile->read_in_chain;
dwarf2_per_objfile->read_in_chain = per_cu;
static int
die_needs_namespace (struct die_info *die, struct dwarf2_cu *cu)
{
+ struct attribute *attr;
+
switch (die->tag)
{
case DW_TAG_namespace:
spec_cu);
}
- if (dwarf2_attr (die, DW_AT_external, cu)
- || die->parent->tag == DW_TAG_namespace)
- return 1;
-
- return 0;
+ attr = dwarf2_attr (die, DW_AT_external, cu);
+ if (attr == NULL && die->parent->tag != DW_TAG_namespace)
+ return 0;
+ /* A variable in a lexical block of some kind does not need a
+ namespace, even though in C++ such variables may be external
+ and have a mangled name. */
+ if (die->parent->tag == DW_TAG_lexical_block
+ || die->parent->tag == DW_TAG_try_block
+ || die->parent->tag == DW_TAG_catch_block
+ || die->parent->tag == DW_TAG_subprogram)
+ return 0;
+ return 1;
default:
return 0;
struct dwarf2_cu *imported_cu;
const char *imported_name;
const char *imported_name_prefix;
- char *import_alias;
-
+ const char *canonical_name;
+ const char *import_alias;
+ const char *imported_declaration = NULL;
const char *import_prefix;
- char *canonical_name;
+
+ char *temp;
import_attr = dwarf2_attr (die, DW_AT_import, cu);
if (import_attr == NULL)
to the name of the imported die. */
imported_name_prefix = determine_prefix (imported_die, imported_cu);
- if (strlen (imported_name_prefix) > 0)
+ if (imported_die->tag != DW_TAG_namespace)
{
- canonical_name = alloca (strlen (imported_name_prefix)
- + 2 + strlen (imported_name) + 1);
- strcpy (canonical_name, imported_name_prefix);
- strcat (canonical_name, "::");
- strcat (canonical_name, imported_name);
+ imported_declaration = imported_name;
+ canonical_name = imported_name_prefix;
}
- else
+ else if (strlen (imported_name_prefix) > 0)
{
- canonical_name = alloca (strlen (imported_name) + 1);
- strcpy (canonical_name, imported_name);
+ temp = alloca (strlen (imported_name_prefix)
+ + 2 + strlen (imported_name) + 1);
+ strcpy (temp, imported_name_prefix);
+ strcat (temp, "::");
+ strcat (temp, imported_name);
+ canonical_name = temp;
}
+ else
+ canonical_name = imported_name;
- using_directives = cp_add_using (import_prefix,
- canonical_name,
- import_alias,
- using_directives);
+ cp_add_using_directive (import_prefix,
+ canonical_name,
+ import_alias,
+ imported_declaration,
+ &cu->objfile->objfile_obstack);
}
static void
name = dwarf2_name (die, cu);
- /* Ignore functions with missing or empty names and functions with
- missing or invalid low and high pc attributes. */
- if (name == NULL || !dwarf2_get_pc_bounds (die, &lowpc, &highpc, cu, NULL))
- return;
+ /* Ignore functions with missing or empty names. These are actually
+ illegal according to the DWARF standard. */
+ if (name == NULL)
+ {
+ complaint (&symfile_complaints,
+ _("missing name for subprogram DIE at %d"), die->offset);
+ return;
+ }
+
+ /* Ignore functions with missing or invalid low and high pc attributes. */
+ if (!dwarf2_get_pc_bounds (die, &lowpc, &highpc, cu, NULL))
+ {
+ complaint (&symfile_complaints,
+ _("cannot get low and high bounds for subprogram DIE at %d"),
+ die->offset);
+ return;
+ }
lowpc += baseaddr;
highpc += baseaddr;
inherit_abstract_dies (die, cu);
+ /* If we have a DW_AT_specification, we might need to import using
+ directives from the context of the specification DIE. See the
+ comment in determine_prefix. */
+ if (cu->language == language_cplus
+ && dwarf2_attr (die, DW_AT_specification, cu))
+ {
+ struct dwarf2_cu *spec_cu = cu;
+ struct die_info *spec_die = die_specification (die, &spec_cu);
+
+ while (spec_die)
+ {
+ child_die = spec_die->child;
+ while (child_die && child_die->tag)
+ {
+ if (child_die->tag == DW_TAG_imported_module)
+ process_die (child_die, spec_cu);
+ child_die = sibling_die (child_die);
+ }
+
+ /* In some cases, GCC generates specification DIEs that
+ themselves contain DW_AT_specification attributes. */
+ spec_die = die_specification (spec_die, &spec_cu);
+ }
+ }
+
new = pop_context ();
/* Make a block for the local symbols within. */
block = finish_block (new->name, &local_symbols, new->old_blocks,
found_base = cu->base_known;
base = cu->base_address;
+ dwarf2_read_section (objfile, &dwarf2_per_objfile->ranges);
if (offset >= dwarf2_per_objfile->ranges.size)
{
complaint (&symfile_complaints,
CORE_ADDR base = cu->base_address;
int base_known = cu->base_known;
+ gdb_assert (dwarf2_per_objfile->ranges.readin);
if (offset >= dwarf2_per_objfile->ranges.size)
{
complaint (&symfile_complaints,
TYPE_STUB_SUPPORTED (type) = 1;
if (die_is_declaration (die, cu))
TYPE_STUB (type) = 1;
+ else if (attr == NULL && die->child == NULL
+ && producer_is_realview (cu->producer))
+ /* RealView does not output the required DW_AT_declaration
+ on incomplete types. */
+ TYPE_STUB (type) = 1;
set_descriptive_type (type, die, cu);
if (is_anonymous)
{
const char *previous_prefix = determine_prefix (die, cu);
- cp_add_using_directive (previous_prefix, TYPE_NAME (type), NULL);
+ cp_add_using_directive (previous_prefix, TYPE_NAME (type), NULL,
+ NULL, &objfile->objfile_obstack);
}
}
|| cu->language == language_java
|| cu->language == language_pascal)
TYPE_PROTOTYPED (ftype) = 1;
+ else if (producer_is_realview (cu->producer))
+ /* RealView does not emit DW_AT_prototyped. We can not
+ distinguish prototyped and unprototyped functions; default to
+ prototyped, since that is more common in modern code (and
+ RealView warns about unprototyped functions). */
+ TYPE_PROTOTYPED (ftype) = 1;
/* Store the calling convention in the type if it's available in
the subroutine die. Otherwise set the calling convention to
if (attr)
TYPE_FIELD_ARTIFICIAL (ftype, iparams) = DW_UNSND (attr);
else
- TYPE_FIELD_ARTIFICIAL (ftype, iparams) = 0;
+ {
+ TYPE_FIELD_ARTIFICIAL (ftype, iparams) = 0;
+
+ /* GCC/43521: In java, the formal parameter
+ "this" is sometimes not marked with DW_AT_artificial. */
+ if (cu->language == language_java)
+ {
+ const char *name = dwarf2_name (child_die, cu);
+ if (name && !strcmp (name, "this"))
+ TYPE_FIELD_ARTIFICIAL (ftype, iparams) = 1;
+ }
+ }
TYPE_FIELD_TYPE (ftype, iparams) = die_type (child_die, cu);
iparams++;
}
range_type = create_range_type (NULL, 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 == DW_FORM_block1)
+ TYPE_HIGH_BOUND_UNDEFINED (range_type) = 1;
+
name = dwarf2_name (die, cu);
if (name)
TYPE_NAME (range_type) = name;
memset (cu->dwarf2_abbrevs, 0,
ABBREV_HASH_SIZE * sizeof (struct abbrev_info *));
+ dwarf2_read_section (dwarf2_per_objfile->objfile,
+ &dwarf2_per_objfile->abbrev);
abbrev_ptr = dwarf2_per_objfile->abbrev.buffer + cu_header->abbrev_offset;
abbrev_number = read_unsigned_leb128 (abfd, abbrev_ptr, &bytes_read);
abbrev_ptr += bytes_read;
{
LONGEST str_offset = read_offset (abfd, buf, cu_header, bytes_read_ptr);
+ dwarf2_read_section (dwarf2_per_objfile->objfile, &dwarf2_per_objfile->str);
if (dwarf2_per_objfile->str.buffer == NULL)
{
error (_("DW_FORM_strp used without .debug_str section [in module %s]"),
int i;
char *cur_dir, *cur_file;
+ dwarf2_read_section (dwarf2_per_objfile->objfile, &dwarf2_per_objfile->line);
if (dwarf2_per_objfile->line.buffer == NULL)
{
complaint (&symfile_complaints, _("missing .debug_line section"));
var_decode_location (attr, sym, cu);
attr2 = dwarf2_attr (die, DW_AT_external, cu);
if (attr2 && (DW_UNSND (attr2) != 0))
- add_symbol_to_list (sym, &global_symbols);
+ {
+ struct pending **list_to_add;
+
+ /* A variable with DW_AT_external is never static,
+ but it may be block-scoped. */
+ list_to_add = (cu->list_in_scope == &file_symbols
+ ? &global_symbols : cu->list_in_scope);
+ add_symbol_to_list (sym, list_to_add);
+ }
else
add_symbol_to_list (sym, cu->list_in_scope);
}
{
case DW_TAG_namespace:
parent_type = read_type_die (parent, cu);
+ /* GCC 4.0 and 4.1 had a bug (PR c++/28460) where they generated bogus
+ DW_TAG_namespace DIEs with a name of "::" for the global namespace.
+ Work around this problem here. */
+ if (cu->language == language_cplus
+ && strcmp (TYPE_TAG_NAME (parent_type), "::") == 0)
+ return "";
/* We give a name to even anonymous namespaces. */
return TYPE_TAG_NAME (parent_type);
case DW_TAG_class_type:
/* These tags always have simple identifiers already; no need
to canonicalize them. */
return DW_STRING (attr);
- default:
- if (!DW_STRING_IS_CANONICAL (attr))
+
+ case DW_TAG_subprogram:
+ /* Java constructors will all be named "<init>", so return
+ the class name when we see this special case. */
+ if (cu->language == language_java
+ && DW_STRING (attr) != NULL
+ && strcmp (DW_STRING (attr), "<init>") == 0)
{
- DW_STRING (attr)
- = dwarf2_canonicalize_name (DW_STRING (attr), cu,
- &cu->objfile->objfile_obstack);
- DW_STRING_IS_CANONICAL (attr) = 1;
+ struct dwarf2_cu *spec_cu = cu;
+ struct die_info *spec_die;
+
+ /* GCJ will output '<init>' for Java constructor names.
+ For this special case, return the name of the parent class. */
+
+ /* GCJ may output suprogram DIEs with AT_specification set.
+ If so, use the name of the specified DIE. */
+ spec_die = die_specification (die, &spec_cu);
+ if (spec_die != NULL)
+ return dwarf2_name (spec_die, spec_cu);
+
+ do
+ {
+ die = die->parent;
+ if (die->tag == DW_TAG_class_type)
+ return dwarf2_name (die, cu);
+ }
+ while (die->tag != DW_TAG_compile_unit);
}
- return DW_STRING (attr);
+ break;
+
+ case DW_TAG_class_type:
+ case DW_TAG_interface_type:
+ case DW_TAG_structure_type:
+ case DW_TAG_union_type:
+ /* Some GCC versions emit spurious DW_AT_name attributes for unnamed
+ structures or unions. These were of the form "._%d" in GCC 4.1,
+ or simply "<anonymous struct>" or "<anonymous union>" in GCC 4.3
+ and GCC 4.4. We work around this problem by ignoring these. */
+ if (strncmp (DW_STRING (attr), "._", 2) == 0
+ || strncmp (DW_STRING (attr), "<anonymous", 10) == 0)
+ return NULL;
+ break;
+
+ default:
+ break;
}
+
+ if (!DW_STRING_IS_CANONICAL (attr))
+ {
+ DW_STRING (attr)
+ = dwarf2_canonicalize_name (DW_STRING (attr), cu,
+ &cu->objfile->objfile_obstack);
+ DW_STRING_IS_CANONICAL (attr) = 1;
+ }
+ return DW_STRING (attr);
}
/* Return the die that this die in an extension of, or NULL if there
{
struct signatured_type *type_sig;
+ dwarf2_read_section (objfile, &dwarf2_per_objfile->types);
+
/* We have the section offset, but we need the signature to do the
hash table lookup. */
type_sig = lookup_signatured_type_at_offset (objfile, offset);
enum dwarf_macinfo_record_type macinfo_type;
int at_commandline;
+ dwarf2_read_section (dwarf2_per_objfile->objfile,
+ &dwarf2_per_objfile->macinfo);
if (dwarf2_per_objfile->macinfo.buffer == NULL)
{
complaint (&symfile_complaints, _("missing .debug_macinfo section"));
baton->per_cu = cu->per_cu;
gdb_assert (baton->per_cu);
+ dwarf2_read_section (dwarf2_per_objfile->objfile,
+ &dwarf2_per_objfile->loc);
+
/* We don't know how long the location list is, but make sure we
don't run off the edge of the section. */
baton->size = dwarf2_per_objfile->loc.size - DW_UNSND (attr);