struct dwarf2_section_info *section;
/* Set to non-NULL iff this CU is currently loaded. When it gets freed out
- of the CU cache it gets reset to NULL again. */
+ of the CU cache it gets reset to NULL again. This is left as NULL for
+ dummy CUs (a CU header, but nothing else). */
struct dwarf2_cu *cu;
/* The corresponding objfile.
dwarf2_per_objfile->gdb_index.size = bfd_get_section_size (sectp);
}
- if ((bfd_get_section_flags (abfd, sectp) & SEC_LOAD)
+ if ((bfd_get_section_flags (abfd, sectp) & (SEC_LOAD | SEC_ALLOC))
&& bfd_section_vma (abfd, sectp) == 0)
dwarf2_per_objfile->has_section_at_zero = 1;
}
else
load_full_comp_unit (per_cu, language_minimal);
- gdb_assert (per_cu->cu != NULL);
+ if (per_cu->cu == NULL)
+ return; /* Dummy CU. */
dwarf2_find_base_address (per_cu->cu->dies, per_cu->cu);
}
that may badly handle TUs, load all the TUs in that DWO as well.
http://sourceware.org/bugzilla/show_bug.cgi?id=15021 */
if (!per_cu->is_debug_types
+ && per_cu->cu != NULL
&& per_cu->cu->dwo_unit != NULL
&& dwarf2_per_objfile->index_table != NULL
&& dwarf2_per_objfile->index_table->version <= 7
if (current_language->la_language == language_cplus
|| current_language->la_language == language_java
- || current_language->la_language == language_fortran)
+ || current_language->la_language == language_fortran
+ || current_language->la_language == language_d)
{
/* NAME is already canonical. Drop any qualifiers as .gdb_index does
not contain any. */
subpst->dirname = pst->dirname;
}
- subpst->section_offsets = pst->section_offsets;
subpst->textlow = 0;
subpst->texthigh = 0;
struct objfile *objfile = per_cu->objfile;
struct partial_symtab *pst;
- pst = start_psymtab_common (objfile, objfile->section_offsets,
- name, 0,
+ pst = start_psymtab_common (objfile, name, 0,
objfile->global_psymbols.next,
objfile->static_psymbols.next);
may load a new CU, adding it to the end of the queue. */
for (item = dwarf2_queue; item != NULL; dwarf2_queue = item = next_item)
{
- if (dwarf2_per_objfile->using_index
- ? !item->per_cu->v.quick->compunit_symtab
- : (item->per_cu->v.psymtab && !item->per_cu->v.psymtab->readin))
+ if ((dwarf2_per_objfile->using_index
+ ? !item->per_cu->v.quick->compunit_symtab
+ : (item->per_cu->v.psymtab && !item->per_cu->v.psymtab->readin))
+ /* Skip dummy CUs. */
+ && item->per_cu->cu != NULL)
{
struct dwarf2_per_cu_data *per_cu = item->per_cu;
unsigned int debug_print_threshold;
/* These are the only languages we know how to qualify names in. */
if (name != NULL
&& (cu->language == language_cplus || cu->language == language_java
- || cu->language == language_fortran))
+ || cu->language == language_fortran || cu->language == language_d))
{
if (die_needs_namespace (die, cu))
{
}
else if (strlen (imported_name_prefix) > 0)
canonical_name = obconcat (&objfile->objfile_obstack,
- imported_name_prefix, "::", imported_name,
- (char *) NULL);
+ imported_name_prefix,
+ (cu->language == language_d ? "." : "::"),
+ imported_name, (char *) NULL);
else
canonical_name = imported_name;
lowpc, highpc);
/* For C++, set the block's scope. */
- if ((cu->language == language_cplus || cu->language == language_fortran)
+ if ((cu->language == language_cplus
+ || cu->language == language_fortran
+ || cu->language == language_d)
&& cu->processing_has_namespace_info)
block_set_scope (block, determine_prefix (die, cu),
&objfile->objfile_obstack);
if (name != NULL)
{
if (cu->language == language_cplus
- || cu->language == language_java)
+ || cu->language == language_java
+ || cu->language == language_d)
{
const char *full_name = dwarf2_full_name (name, die, cu);
class. */
if (cu->language == language_cplus
|| cu->language == language_java
- || cu->language == language_ada)
+ || cu->language == language_ada
+ || cu->language == language_d)
{
/* The symbol's name is already allocated along
with this objfile, so we don't need to
char *retval;
if (cu->language != language_cplus && cu->language != language_java
- && cu->language != language_fortran)
+ && cu->language != language_fortran && cu->language != language_d)
return "";
retval = anonymous_struct_prefix (die, cu);
sep = "";
else if (cu->language == language_java)
sep = ".";
+ else if (cu->language == language_d)
+ {
+ /* For D, the 'main' function could be defined in any module, but it
+ should never be prefixed. */
+ if (strcmp (suffix, "D main") == 0)
+ {
+ prefix = "";
+ sep = "";
+ }
+ else
+ sep = ".";
+ }
else if (cu->language == language_fortran && physname)
{
/* This is gfortran specific mangling. Normally DW_AT_linkage_name or
if (per_cu->cu == NULL)
load_cu (per_cu);
cu = per_cu->cu;
+ if (cu == NULL)
+ {
+ /* We shouldn't get here for a dummy CU, but don't crash on the user.
+ Instead just throw an error, not much else we can do. */
+ error (_("Dwarf Error: Dummy CU at 0x%x referenced in module %s"),
+ offset.sect_off, objfile_name (per_cu->objfile));
+ }
die = follow_die_offset (offset, per_cu->is_dwz, &cu);
if (!die)
if (per_cu->cu == NULL)
load_cu (per_cu);
cu = per_cu->cu;
+ if (cu == NULL)
+ {
+ /* We shouldn't get here for a dummy CU, but don't crash on the user.
+ Instead just throw an error, not much else we can do. */
+ error (_("Dwarf Error: Dummy CU at 0x%x referenced in module %s"),
+ offset.sect_off, objfile_name (per_cu->objfile));
+ }
die = follow_die_offset (offset, per_cu->is_dwz, &cu);
if (!die)