static void process_die (struct die_info *, struct dwarf2_cu *);
static const char *dwarf2_canonicalize_name (const char *, struct dwarf2_cu *,
- struct obstack *);
+ struct objfile *);
static const char *dwarf2_name (struct die_info *die, struct dwarf2_cu *);
cutu_reader reader (this_cu, NULL, 0, false);
+ switch (reader.comp_unit_die->tag)
+ {
+ case DW_TAG_compile_unit:
+ this_cu->unit_type = DW_UT_compile;
+ break;
+ case DW_TAG_partial_unit:
+ this_cu->unit_type = DW_UT_partial;
+ break;
+ default:
+ abort ();
+ }
+
if (reader.dummy_p)
{
/* Nothing. */
reader.comp_unit_die,
pretend_language);
+ this_cu->lang = this_cu->cu->language;
+
/* Age out any secondary CUs. */
age_cached_comp_units (this_cu->dwarf2_per_objfile);
}
if (package_name != NULL)
{
struct objfile *objfile = cu->per_cu->dwarf2_per_objfile->objfile;
- const char *saved_package_name
- = obstack_strdup (&objfile->per_bfd->storage_obstack, package_name.get ());
+ const char *saved_package_name = objfile->intern (package_name.get ());
struct type *type = init_type (objfile, TYPE_CODE_MODULE, 0,
saved_package_name);
struct symbol *sym;
= dwarf2_find_containing_comp_unit (sect_off, is_dwz,
cu->per_cu->dwarf2_per_objfile);
+ /* We're importing a C++ compilation unit with tag DW_TAG_compile_unit
+ into another compilation unit, at root level. Regard this as a hint,
+ and ignore it. */
+ if (die->parent && die->parent->parent == NULL
+ && per_cu->unit_type == DW_UT_compile
+ && per_cu->lang == language_cplus)
+ return;
+
/* If necessary, add it to the queue and load its DIEs. */
if (maybe_queue_comp_unit (cu, per_cu, cu->language))
load_full_comp_unit (per_cu, false, cu->language);
if (cu->language == language_cplus)
canonical_name
= dwarf2_canonicalize_name (intermediate_name.c_str (), cu,
- &objfile->per_bfd->storage_obstack);
+ objfile);
/* If we only computed INTERMEDIATE_NAME, or if
INTERMEDIATE_NAME is already canonical, then we need to
- copy it to the appropriate obstack. */
+ intern it. */
if (canonical_name == NULL || canonical_name == intermediate_name.c_str ())
- name = obstack_strdup (&objfile->per_bfd->storage_obstack,
- intermediate_name);
+ name = objfile->intern (intermediate_name);
else
name = canonical_name;
}
retval = canon;
if (need_copy)
- retval = obstack_strdup (&objfile->per_bfd->storage_obstack, retval);
+ retval = objfile->intern (retval);
return retval;
}
virtual_dwo_name.c_str ());
}
dwo_file = new struct dwo_file;
- dwo_file->dwo_name = obstack_strdup (&objfile->objfile_obstack,
- virtual_dwo_name);
+ dwo_file->dwo_name = objfile->intern (virtual_dwo_name);
dwo_file->comp_dir = comp_dir;
dwo_file->sections.abbrev = sections.abbrev;
dwo_file->sections.line = sections.line;
virtual_dwo_name.c_str ());
}
dwo_file = new struct dwo_file;
- dwo_file->dwo_name = obstack_strdup (&objfile->objfile_obstack,
- virtual_dwo_name);
+ dwo_file->dwo_name = objfile->intern (virtual_dwo_name);
dwo_file->comp_dir = comp_dir;
dwo_file->sections.abbrev =
create_dwp_v2_section (dwarf2_per_objfile, &dwp_file->sections.abbrev,
sect_offset_str (die->sect_off), objfile_name (objfile));
TYPE_TARGET_TYPE (this_type) = NULL;
}
+ if (name == NULL)
+ {
+ /* Gcc-7 and before supports -feliminate-dwarf2-dups, which generates
+ anonymous typedefs, which is, strictly speaking, invalid DWARF.
+ Handle these by just returning the target type, rather than
+ constructing an anonymous typedef type and trying to handle this
+ elsewhere. */
+ set_die_type (die, target_type, cu);
+ return target_type;
+ }
return this_type;
}
struct objfile *objfile = dwarf2_per_objfile->objfile;
name
- = dwarf2_canonicalize_name (DW_STRING (&attr), cu,
- &objfile->per_bfd->storage_obstack);
+ = dwarf2_canonicalize_name (DW_STRING (&attr), cu, objfile);
}
break;
}
if (actual_class_name != NULL)
{
struct objfile *objfile = cu->per_cu->dwarf2_per_objfile->objfile;
- struct_pdi->name
- = obstack_strdup (&objfile->per_bfd->storage_obstack,
- actual_class_name.get ());
+ struct_pdi->name = objfile->intern (actual_class_name.get ());
}
break;
}
base = demangled.get ();
struct objfile *objfile = cu->per_cu->dwarf2_per_objfile->objfile;
- name = obstack_strdup (&objfile->per_bfd->storage_obstack, base);
+ name = objfile->intern (base);
}
}
static void
dwarf_record_line_1 (struct gdbarch *gdbarch, struct subfile *subfile,
- unsigned int line, CORE_ADDR address,
+ unsigned int line, CORE_ADDR address, bool is_stmt,
struct dwarf2_cu *cu)
{
CORE_ADDR addr = gdbarch_addr_bits_remove (gdbarch, address);
}
if (cu != nullptr)
- cu->get_builder ()->record_line (subfile, line, addr);
+ cu->get_builder ()->record_line (subfile, line, addr, is_stmt);
}
/* Subroutine of dwarf_decode_lines_1 to simplify it.
paddress (gdbarch, address));
}
- dwarf_record_line_1 (gdbarch, subfile, 0, address, cu);
+ dwarf_record_line_1 (gdbarch, subfile, 0, address, true, cu);
}
void
else if (m_op_index == 0 || end_sequence)
{
fe->included_p = 1;
- if (m_record_lines_p
- && (producer_is_codewarrior (m_cu) || m_is_stmt || end_sequence))
+ if (m_record_lines_p)
{
if (m_last_subfile != m_cu->get_builder ()->get_current_subfile ()
|| end_sequence)
if (!end_sequence)
{
+ bool is_stmt = producer_is_codewarrior (m_cu) || m_is_stmt;
+
if (dwarf_record_line_p (m_cu, m_line, m_last_line,
m_line_has_non_zero_discriminator,
m_last_subfile))
buildsym_compunit *builder = m_cu->get_builder ();
dwarf_record_line_1 (m_gdbarch,
builder->get_current_subfile (),
- m_line, m_address,
+ m_line, m_address, is_stmt,
m_currently_recording_lines ? m_cu : nullptr);
}
m_last_subfile = m_cu->get_builder ()->get_current_subfile ();
static const char *
dwarf2_canonicalize_name (const char *name, struct dwarf2_cu *cu,
- struct obstack *obstack)
+ struct objfile *objfile)
{
if (name && cu->language == language_cplus)
{
if (!canon_name.empty ())
{
if (canon_name != name)
- name = obstack_strdup (obstack, canon_name);
+ name = objfile->intern (canon_name);
}
}
if (demangled == nullptr)
return nullptr;
- const char *base;
-
- /* FIXME: we already did this for the partial symbol... */
- DW_STRING (attr)
- = obstack_strdup (&objfile->per_bfd->storage_obstack,
- demangled.get ());
+ DW_STRING (attr) = objfile->intern (demangled.get ());
DW_STRING_IS_CANONICAL (attr) = 1;
-
- /* Strip any leading namespaces/classes, keep only the base name.
- DW_AT_name for named DIEs does not contain the prefixes. */
- base = strrchr (DW_STRING (attr), ':');
- if (base && base > DW_STRING (attr) && base[-1] == ':')
- return &base[1];
- else
- return DW_STRING (attr);
}
+
+ /* Strip any leading namespaces/classes, keep only the base name.
+ DW_AT_name for named DIEs does not contain the prefixes. */
+ const char *base = strrchr (DW_STRING (attr), ':');
+ if (base && base > DW_STRING (attr) && base[-1] == ':')
+ return &base[1];
+ else
+ return DW_STRING (attr);
}
break;
if (!DW_STRING_IS_CANONICAL (attr))
{
- DW_STRING (attr)
- = dwarf2_canonicalize_name (DW_STRING (attr), cu,
- &objfile->per_bfd->storage_obstack);
+ DW_STRING (attr) = dwarf2_canonicalize_name (DW_STRING (attr), cu,
+ objfile);
DW_STRING_IS_CANONICAL (attr) = 1;
}
return DW_STRING (attr);