forked from OSchip/llvm-project
Use DWARFBaseDIE as a compile-time protection
As suggested by Pavel Labath in D46810 DWARFUnit::GetUnitDIEOnly() returning a pointer to m_first_die should not permit using methods like GetFirstChild(). Differential revision: https://reviews.llvm.org/D47276 llvm-svn: 333224
This commit is contained in:
parent
e522c97ef4
commit
93afb0598e
|
@ -638,7 +638,7 @@ void DWARFDebugInfoEntry::Dump(SymbolFileDWARF *dwarf2Data,
|
|||
|
||||
void DWARFDebugInfoEntry::DumpLocation(SymbolFileDWARF *dwarf2Data,
|
||||
DWARFUnit *cu, Stream &s) const {
|
||||
const DWARFDIE cu_die = cu->GetUnitDIEOnly();
|
||||
const DWARFBaseDIE cu_die = cu->GetUnitDIEOnly();
|
||||
const char *cu_name = NULL;
|
||||
if (cu_die)
|
||||
cu_name = cu_die.GetName();
|
||||
|
@ -912,7 +912,7 @@ dw_offset_t DWARFDebugInfoEntry::GetAttributeValue(
|
|||
if (!dwo_cu)
|
||||
return 0;
|
||||
|
||||
DWARFDIE dwo_cu_die = dwo_cu->GetUnitDIEOnly();
|
||||
DWARFBaseDIE dwo_cu_die = dwo_cu->GetUnitDIEOnly();
|
||||
if (!dwo_cu_die.IsValid())
|
||||
return 0;
|
||||
|
||||
|
|
|
@ -207,7 +207,7 @@ void DWARFUnit::AddUnitDIE(DWARFDebugInfoEntry &die) {
|
|||
if (!dwo_cu)
|
||||
return; // Can't fetch the compile unit from the dwo file.
|
||||
|
||||
DWARFDIE dwo_cu_die = dwo_cu->GetUnitDIEOnly();
|
||||
DWARFBaseDIE dwo_cu_die = dwo_cu->GetUnitDIEOnly();
|
||||
if (!dwo_cu_die.IsValid())
|
||||
return; // Can't fetch the compile unit DIE from the dwo file.
|
||||
|
||||
|
|
|
@ -113,7 +113,7 @@ public:
|
|||
|
||||
void SetBaseAddress(dw_addr_t base_addr);
|
||||
|
||||
DWARFDIE GetUnitDIEOnly() { return DWARFDIE(this, GetUnitDIEPtrOnly()); }
|
||||
DWARFBaseDIE GetUnitDIEOnly() { return DWARFDIE(this, GetUnitDIEPtrOnly()); }
|
||||
|
||||
DWARFDIE DIE() { return DWARFDIE(this, DIEPtr()); }
|
||||
|
||||
|
|
|
@ -748,7 +748,7 @@ lldb::CompUnitSP SymbolFileDWARF::ParseCompileUnit(DWARFUnit *dwarf_cu,
|
|||
} else {
|
||||
ModuleSP module_sp(m_obj_file->GetModule());
|
||||
if (module_sp) {
|
||||
const DWARFDIE cu_die = dwarf_cu->GetUnitDIEOnly();
|
||||
const DWARFDIE cu_die = dwarf_cu->DIE();
|
||||
if (cu_die) {
|
||||
FileSpec cu_file_spec{cu_die.GetName(), false};
|
||||
if (cu_file_spec) {
|
||||
|
@ -883,7 +883,7 @@ bool SymbolFileDWARF::ParseCompileUnitSupportFiles(
|
|||
assert(sc.comp_unit);
|
||||
DWARFUnit *dwarf_cu = GetDWARFCompileUnit(sc.comp_unit);
|
||||
if (dwarf_cu) {
|
||||
const DWARFDIE cu_die = dwarf_cu->GetUnitDIEOnly();
|
||||
const DWARFBaseDIE cu_die = dwarf_cu->GetUnitDIEOnly();
|
||||
|
||||
if (cu_die) {
|
||||
FileSpec cu_comp_dir = resolveCompDir(
|
||||
|
@ -922,7 +922,7 @@ bool SymbolFileDWARF::ParseImportedModules(
|
|||
UpdateExternalModuleListIfNeeded();
|
||||
|
||||
if (sc.comp_unit) {
|
||||
const DWARFDIE die = dwarf_cu->GetUnitDIEOnly();
|
||||
const DWARFDIE die = dwarf_cu->DIE();
|
||||
|
||||
if (die) {
|
||||
for (DWARFDIE child_die = die.GetFirstChild(); child_die;
|
||||
|
@ -997,7 +997,7 @@ bool SymbolFileDWARF::ParseCompileUnitLineTable(const SymbolContext &sc) {
|
|||
|
||||
DWARFUnit *dwarf_cu = GetDWARFCompileUnit(sc.comp_unit);
|
||||
if (dwarf_cu) {
|
||||
const DWARFDIE dwarf_cu_die = dwarf_cu->GetUnitDIEOnly();
|
||||
const DWARFBaseDIE dwarf_cu_die = dwarf_cu->GetUnitDIEOnly();
|
||||
if (dwarf_cu_die) {
|
||||
const dw_offset_t cu_line_offset =
|
||||
dwarf_cu_die.GetAttributeValueAsUnsigned(DW_AT_stmt_list,
|
||||
|
@ -1082,7 +1082,7 @@ bool SymbolFileDWARF::ParseCompileUnitDebugMacros(const SymbolContext &sc) {
|
|||
if (dwarf_cu == nullptr)
|
||||
return false;
|
||||
|
||||
const DWARFDIE dwarf_cu_die = dwarf_cu->GetUnitDIEOnly();
|
||||
const DWARFBaseDIE dwarf_cu_die = dwarf_cu->GetUnitDIEOnly();
|
||||
if (!dwarf_cu_die)
|
||||
return false;
|
||||
|
||||
|
@ -1578,7 +1578,7 @@ void SymbolFileDWARF::UpdateExternalModuleListIfNeeded() {
|
|||
for (uint32_t cu_idx = 0; cu_idx < num_compile_units; ++cu_idx) {
|
||||
DWARFUnit *dwarf_cu = debug_info->GetCompileUnitAtIndex(cu_idx);
|
||||
|
||||
const DWARFDIE die = dwarf_cu->GetUnitDIEOnly();
|
||||
const DWARFBaseDIE die = dwarf_cu->GetUnitDIEOnly();
|
||||
if (die && die.HasChildren() == false) {
|
||||
const char *name = die.GetAttributeValueAsString(DW_AT_name, nullptr);
|
||||
|
||||
|
|
Loading…
Reference in New Issue