[Lldb-commits] [lldb] ddf60ba - [lldb/DWARF] Always construct a DWARFDebugInfo object
Pavel Labath via lldb-commits
lldb-commits at lists.llvm.org
Thu Feb 20 01:52:33 PST 2020
Author: Pavel Labath
Date: 2020-02-20T10:51:40+01:00
New Revision: ddf60ba09f2cf31851ea165c7c5fcfc4c2ad546e
URL: https://github.com/llvm/llvm-project/commit/ddf60ba09f2cf31851ea165c7c5fcfc4c2ad546e
DIFF: https://github.com/llvm/llvm-project/commit/ddf60ba09f2cf31851ea165c7c5fcfc4c2ad546e.diff
LOG: [lldb/DWARF] Always construct a DWARFDebugInfo object
Change the return value of SymbolFileDWARF::DebugInfo from a pointer to
a reference, and remove all null checks.
Previously, we were not constructing the DebugInfo object when the
debug_info section was empty. Now we always construct the object but
it will return an empty list of dwarf units (a thing which it already
supported).
Added:
Modified:
lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp
lldb/source/Plugins/SymbolFile/DWARF/DWARFFormValue.cpp
lldb/source/Plugins/SymbolFile/DWARF/DebugNamesDWARFIndex.cpp
lldb/source/Plugins/SymbolFile/DWARF/DebugNamesDWARFIndex.h
lldb/source/Plugins/SymbolFile/DWARF/ManualDWARFIndex.cpp
lldb/source/Plugins/SymbolFile/DWARF/ManualDWARFIndex.h
lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h
lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDwo.cpp
Removed:
################################################################################
diff --git a/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp b/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp
index 0ea3adceaecc..8d0ac23ef9e3 100644
--- a/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp
+++ b/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp
@@ -2001,12 +2001,12 @@ bool DWARFASTParserClang::CompleteRecordType(const DWARFDIE &die,
dwarf->GetObjCMethodDIEOffsets(class_name, method_die_offsets);
if (!method_die_offsets.empty()) {
- DWARFDebugInfo *debug_info = dwarf->DebugInfo();
+ DWARFDebugInfo &debug_info = dwarf->DebugInfo();
const size_t num_matches = method_die_offsets.size();
for (size_t i = 0; i < num_matches; ++i) {
const DIERef &die_ref = method_die_offsets[i];
- DWARFDIE method_die = debug_info->GetDIE(die_ref);
+ DWARFDIE method_die = debug_info.GetDIE(die_ref);
if (method_die)
method_die.ResolveType();
diff --git a/lldb/source/Plugins/SymbolFile/DWARF/DWARFFormValue.cpp b/lldb/source/Plugins/SymbolFile/DWARF/DWARFFormValue.cpp
index 83cda24a27d2..305f1cbd2826 100644
--- a/lldb/source/Plugins/SymbolFile/DWARF/DWARFFormValue.cpp
+++ b/lldb/source/Plugins/SymbolFile/DWARF/DWARFFormValue.cpp
@@ -517,7 +517,7 @@ DWARFDIE DWARFFormValue::Reference() const {
case DW_FORM_ref_addr: {
DWARFUnit *ref_cu =
- m_unit->GetSymbolFileDWARF().DebugInfo()->GetUnitContainingDIEOffset(
+ m_unit->GetSymbolFileDWARF().DebugInfo().GetUnitContainingDIEOffset(
DIERef::Section::DebugInfo, value);
if (!ref_cu) {
m_unit->GetSymbolFileDWARF().GetObjectFile()->GetModule()->ReportError(
@@ -530,7 +530,7 @@ DWARFDIE DWARFFormValue::Reference() const {
case DW_FORM_ref_sig8: {
DWARFTypeUnit *tu =
- m_unit->GetSymbolFileDWARF().DebugInfo()->GetTypeUnitForHash(value);
+ m_unit->GetSymbolFileDWARF().DebugInfo().GetTypeUnitForHash(value);
if (!tu)
return {};
return tu->GetDIE(tu->GetTypeOffset());
diff --git a/lldb/source/Plugins/SymbolFile/DWARF/DebugNamesDWARFIndex.cpp b/lldb/source/Plugins/SymbolFile/DWARF/DebugNamesDWARFIndex.cpp
index 705578c2e4eb..c11df30696f0 100644
--- a/lldb/source/Plugins/SymbolFile/DWARF/DebugNamesDWARFIndex.cpp
+++ b/lldb/source/Plugins/SymbolFile/DWARF/DebugNamesDWARFIndex.cpp
@@ -19,18 +19,14 @@ using namespace lldb;
llvm::Expected<std::unique_ptr<DebugNamesDWARFIndex>>
DebugNamesDWARFIndex::Create(Module &module, DWARFDataExtractor debug_names,
DWARFDataExtractor debug_str,
- DWARFDebugInfo *debug_info) {
- if (!debug_info) {
- return llvm::make_error<llvm::StringError>("debug info null",
- llvm::inconvertibleErrorCode());
- }
+ DWARFDebugInfo &debug_info) {
auto index_up = std::make_unique<DebugNames>(debug_names.GetAsLLVM(),
debug_str.GetAsLLVM());
if (llvm::Error E = index_up->extract())
return std::move(E);
return std::unique_ptr<DebugNamesDWARFIndex>(new DebugNamesDWARFIndex(
- module, std::move(index_up), debug_names, debug_str, *debug_info));
+ module, std::move(index_up), debug_names, debug_str, debug_info));
}
llvm::DenseSet<dw_offset_t>
diff --git a/lldb/source/Plugins/SymbolFile/DWARF/DebugNamesDWARFIndex.h b/lldb/source/Plugins/SymbolFile/DWARF/DebugNamesDWARFIndex.h
index f2f5c0bc34de..5ba8577d59f4 100644
--- a/lldb/source/Plugins/SymbolFile/DWARF/DebugNamesDWARFIndex.h
+++ b/lldb/source/Plugins/SymbolFile/DWARF/DebugNamesDWARFIndex.h
@@ -20,7 +20,7 @@ class DebugNamesDWARFIndex : public DWARFIndex {
public:
static llvm::Expected<std::unique_ptr<DebugNamesDWARFIndex>>
Create(Module &module, DWARFDataExtractor debug_names,
- DWARFDataExtractor debug_str, DWARFDebugInfo *debug_info);
+ DWARFDataExtractor debug_str, DWARFDebugInfo &debug_info);
void Preload() override { m_fallback.Preload(); }
@@ -53,7 +53,7 @@ class DebugNamesDWARFIndex : public DWARFIndex {
: DWARFIndex(module), m_debug_info(debug_info),
m_debug_names_data(debug_names_data), m_debug_str_data(debug_str_data),
m_debug_names_up(std::move(debug_names_up)),
- m_fallback(module, &debug_info, GetUnits(*m_debug_names_up)) {}
+ m_fallback(module, debug_info, GetUnits(*m_debug_names_up)) {}
DWARFDebugInfo &m_debug_info;
diff --git a/lldb/source/Plugins/SymbolFile/DWARF/ManualDWARFIndex.cpp b/lldb/source/Plugins/SymbolFile/DWARF/ManualDWARFIndex.cpp
index 6480bef29e10..502bec3bf0f7 100644
--- a/lldb/source/Plugins/SymbolFile/DWARF/ManualDWARFIndex.cpp
+++ b/lldb/source/Plugins/SymbolFile/DWARF/ManualDWARFIndex.cpp
@@ -105,7 +105,7 @@ void ManualDWARFIndex::IndexUnit(DWARFUnit &unit, IndexSet &set) {
IndexUnitImpl(unit, cu_language, set);
if (SymbolFileDWARFDwo *dwo_symbol_file = unit.GetDwoSymbolFile()) {
- DWARFDebugInfo &dwo_info = *dwo_symbol_file->DebugInfo();
+ DWARFDebugInfo &dwo_info = dwo_symbol_file->DebugInfo();
for (size_t i = 0; i < dwo_info.GetNumUnits(); ++i)
IndexUnitImpl(*dwo_info.GetUnitAtIndex(i), cu_language, set);
}
diff --git a/lldb/source/Plugins/SymbolFile/DWARF/ManualDWARFIndex.h b/lldb/source/Plugins/SymbolFile/DWARF/ManualDWARFIndex.h
index d0ee32f2d7f2..0dd27068bbfb 100644
--- a/lldb/source/Plugins/SymbolFile/DWARF/ManualDWARFIndex.h
+++ b/lldb/source/Plugins/SymbolFile/DWARF/ManualDWARFIndex.h
@@ -18,9 +18,9 @@ class DWARFDebugInfo;
namespace lldb_private {
class ManualDWARFIndex : public DWARFIndex {
public:
- ManualDWARFIndex(Module &module, DWARFDebugInfo *debug_info,
+ ManualDWARFIndex(Module &module, DWARFDebugInfo &debug_info,
llvm::DenseSet<dw_offset_t> units_to_avoid = {})
- : DWARFIndex(module), m_debug_info(debug_info),
+ : DWARFIndex(module), m_debug_info(&debug_info),
m_units_to_avoid(std::move(units_to_avoid)) {}
void Preload() override { Index(); }
diff --git a/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp b/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
index f288ac97b4f5..44aeff92922d 100644
--- a/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
+++ b/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
@@ -357,15 +357,12 @@ void SymbolFileDWARF::GetTypes(SymbolContextScope *sc_scope,
GetTypes(dwarf_cu->DIE(), dwarf_cu->GetOffset(),
dwarf_cu->GetNextUnitOffset(), type_mask, type_set);
} else {
- DWARFDebugInfo *info = DebugInfo();
- if (info) {
- const size_t num_cus = info->GetNumUnits();
- for (size_t cu_idx = 0; cu_idx < num_cus; ++cu_idx) {
- dwarf_cu = info->GetUnitAtIndex(cu_idx);
- if (dwarf_cu) {
- GetTypes(dwarf_cu->DIE(), 0, UINT32_MAX, type_mask, type_set);
- }
- }
+ DWARFDebugInfo &info = DebugInfo();
+ const size_t num_cus = info.GetNumUnits();
+ for (size_t cu_idx = 0; cu_idx < num_cus; ++cu_idx) {
+ dwarf_cu = info.GetUnitAtIndex(cu_idx);
+ if (dwarf_cu)
+ GetTypes(dwarf_cu->DIE(), 0, UINT32_MAX, type_mask, type_set);
}
}
@@ -599,15 +596,14 @@ DWARFDebugAbbrev *SymbolFileDWARF::DebugAbbrev() {
return m_abbr.get();
}
-DWARFDebugInfo *SymbolFileDWARF::DebugInfo() {
+DWARFDebugInfo &SymbolFileDWARF::DebugInfo() {
llvm::call_once(m_info_once_flag, [&] {
static Timer::Category func_cat(LLVM_PRETTY_FUNCTION);
Timer scoped_timer(func_cat, "%s this = %p", LLVM_PRETTY_FUNCTION,
static_cast<void *>(this));
- if (m_context.getOrLoadDebugInfoData().GetByteSize() > 0)
- m_info = std::make_unique<DWARFDebugInfo>(*this, m_context);
+ m_info = std::make_unique<DWARFDebugInfo>(*this, m_context);
});
- return m_info.get();
+ return *m_info;
}
DWARFUnit *
@@ -615,15 +611,11 @@ SymbolFileDWARF::GetDWARFCompileUnit(lldb_private::CompileUnit *comp_unit) {
if (!comp_unit)
return nullptr;
- DWARFDebugInfo *info = DebugInfo();
- if (info) {
- // The compile unit ID is the index of the DWARF unit.
- DWARFUnit *dwarf_cu = info->GetUnitAtIndex(comp_unit->GetID());
- if (dwarf_cu && dwarf_cu->GetUserData() == nullptr)
- dwarf_cu->SetUserData(comp_unit);
- return dwarf_cu;
- }
- return nullptr;
+ // The compile unit ID is the index of the DWARF unit.
+ DWARFUnit *dwarf_cu = DebugInfo().GetUnitAtIndex(comp_unit->GetID());
+ if (dwarf_cu && dwarf_cu->GetUserData() == nullptr)
+ dwarf_cu->SetUserData(comp_unit);
+ return dwarf_cu;
}
DWARFDebugRanges *SymbolFileDWARF::GetDebugRanges() {
@@ -695,16 +687,13 @@ void SymbolFileDWARF::BuildCuTranslationTable() {
if (!m_lldb_cu_to_dwarf_unit.empty())
return;
- DWARFDebugInfo *info = DebugInfo();
- if (!info)
- return;
-
- if (!info->ContainsTypeUnits()) {
+ DWARFDebugInfo &info = DebugInfo();
+ if (!info.ContainsTypeUnits()) {
// We can use a 1-to-1 mapping. No need to build a translation table.
return;
}
- for (uint32_t i = 0, num = info->GetNumUnits(); i < num; ++i) {
- if (auto *cu = llvm::dyn_cast<DWARFCompileUnit>(info->GetUnitAtIndex(i))) {
+ for (uint32_t i = 0, num = info.GetNumUnits(); i < num; ++i) {
+ if (auto *cu = llvm::dyn_cast<DWARFCompileUnit>(info.GetUnitAtIndex(i))) {
cu->SetID(m_lldb_cu_to_dwarf_unit.size());
m_lldb_cu_to_dwarf_unit.push_back(i);
}
@@ -721,23 +710,16 @@ llvm::Optional<uint32_t> SymbolFileDWARF::GetDWARFUnitIndex(uint32_t cu_idx) {
}
uint32_t SymbolFileDWARF::CalculateNumCompileUnits() {
- DWARFDebugInfo *info = DebugInfo();
- if (!info)
- return 0;
BuildCuTranslationTable();
- return m_lldb_cu_to_dwarf_unit.empty() ? info->GetNumUnits()
+ return m_lldb_cu_to_dwarf_unit.empty() ? DebugInfo().GetNumUnits()
: m_lldb_cu_to_dwarf_unit.size();
}
CompUnitSP SymbolFileDWARF::ParseCompileUnitAtIndex(uint32_t cu_idx) {
ASSERT_MODULE_LOCK(this);
- DWARFDebugInfo *info = DebugInfo();
- if (!info)
- return {};
-
if (llvm::Optional<uint32_t> dwarf_idx = GetDWARFUnitIndex(cu_idx)) {
if (auto *dwarf_cu = llvm::cast_or_null<DWARFCompileUnit>(
- info->GetUnitAtIndex(*dwarf_idx)))
+ DebugInfo().GetUnitAtIndex(*dwarf_idx)))
return ParseCompileUnit(*dwarf_cu);
}
return {};
@@ -1511,16 +1493,12 @@ SymbolFileDWARF::GetDIE(const DIERef &die_ref) {
SymbolFileDWARF *dwarf = *die_ref.dwo_num() == 0x3fffffff
? m_dwp_symfile.get()
: this->DebugInfo()
- ->GetUnitAtIndex(*die_ref.dwo_num())
+ .GetUnitAtIndex(*die_ref.dwo_num())
->GetDwoSymbolFile();
- return dwarf->DebugInfo()->GetDIE(die_ref);
+ return dwarf->DebugInfo().GetDIE(die_ref);
}
- DWARFDebugInfo *debug_info = DebugInfo();
- if (debug_info)
- return debug_info->GetDIE(die_ref);
- else
- return DWARFDIE();
+ return DebugInfo().GetDIE(die_ref);
}
/// Return the DW_AT_(GNU_)dwo_name.
@@ -1615,13 +1593,13 @@ void SymbolFileDWARF::UpdateExternalModuleListIfNeeded() {
if (m_fetched_external_modules)
return;
m_fetched_external_modules = true;
- DWARFDebugInfo *debug_info = DebugInfo();
+ DWARFDebugInfo &debug_info = DebugInfo();
// Follow DWO skeleton unit breadcrumbs.
const uint32_t num_compile_units = GetNumCompileUnits();
for (uint32_t cu_idx = 0; cu_idx < num_compile_units; ++cu_idx) {
auto *dwarf_cu =
- llvm::dyn_cast<DWARFCompileUnit>(debug_info->GetUnitAtIndex(cu_idx));
+ llvm::dyn_cast<DWARFCompileUnit>(debug_info.GetUnitAtIndex(cu_idx));
if (!dwarf_cu)
continue;
@@ -1801,104 +1779,99 @@ uint32_t SymbolFileDWARF::ResolveSymbolContext(const Address &so_addr,
eSymbolContextLineEntry | eSymbolContextVariable)) {
lldb::addr_t file_vm_addr = so_addr.GetFileAddress();
- DWARFDebugInfo *debug_info = DebugInfo();
- if (debug_info) {
- llvm::Expected<DWARFDebugAranges &> aranges =
- debug_info->GetCompileUnitAranges();
- if (!aranges) {
- Log *log = LogChannelDWARF::GetLogIfAll(DWARF_LOG_DEBUG_INFO);
- LLDB_LOG_ERROR(log, aranges.takeError(),
- "SymbolFileDWARF::ResolveSymbolContext failed to get cu "
- "aranges. {0}");
- return 0;
- }
+ DWARFDebugInfo &debug_info = DebugInfo();
+ llvm::Expected<DWARFDebugAranges &> aranges =
+ debug_info.GetCompileUnitAranges();
+ if (!aranges) {
+ Log *log = LogChannelDWARF::GetLogIfAll(DWARF_LOG_DEBUG_INFO);
+ LLDB_LOG_ERROR(log, aranges.takeError(),
+ "SymbolFileDWARF::ResolveSymbolContext failed to get cu "
+ "aranges. {0}");
+ return 0;
+ }
- const dw_offset_t cu_offset = aranges->FindAddress(file_vm_addr);
- if (cu_offset == DW_INVALID_OFFSET) {
- // Global variables are not in the compile unit address ranges. The
- // only way to currently find global variables is to iterate over the
- // .debug_pubnames or the __apple_names table and find all items in
- // there that point to DW_TAG_variable DIEs and then find the address
- // that matches.
- if (resolve_scope & eSymbolContextVariable) {
- GlobalVariableMap &map = GetGlobalAranges();
- const GlobalVariableMap::Entry *entry =
- map.FindEntryThatContains(file_vm_addr);
- if (entry && entry->data) {
- Variable *variable = entry->data;
- SymbolContextScope *scc = variable->GetSymbolContextScope();
- if (scc) {
- scc->CalculateSymbolContext(&sc);
- sc.variable = variable;
- }
- return sc.GetResolvedMask();
+ const dw_offset_t cu_offset = aranges->FindAddress(file_vm_addr);
+ if (cu_offset == DW_INVALID_OFFSET) {
+ // Global variables are not in the compile unit address ranges. The only
+ // way to currently find global variables is to iterate over the
+ // .debug_pubnames or the __apple_names table and find all items in there
+ // that point to DW_TAG_variable DIEs and then find the address that
+ // matches.
+ if (resolve_scope & eSymbolContextVariable) {
+ GlobalVariableMap &map = GetGlobalAranges();
+ const GlobalVariableMap::Entry *entry =
+ map.FindEntryThatContains(file_vm_addr);
+ if (entry && entry->data) {
+ Variable *variable = entry->data;
+ SymbolContextScope *scc = variable->GetSymbolContextScope();
+ if (scc) {
+ scc->CalculateSymbolContext(&sc);
+ sc.variable = variable;
}
+ return sc.GetResolvedMask();
}
- } else {
- uint32_t cu_idx = DW_INVALID_INDEX;
- if (auto *dwarf_cu = llvm::dyn_cast_or_null<DWARFCompileUnit>(
- debug_info->GetUnitAtOffset(DIERef::Section::DebugInfo,
- cu_offset, &cu_idx))) {
- sc.comp_unit = GetCompUnitForDWARFCompUnit(*dwarf_cu);
- if (sc.comp_unit) {
- resolved |= eSymbolContextCompUnit;
-
- bool force_check_line_table = false;
- if (resolve_scope &
- (eSymbolContextFunction | eSymbolContextBlock)) {
- ResolveFunctionAndBlock(file_vm_addr,
- resolve_scope & eSymbolContextBlock, sc);
- if (sc.function)
- resolved |= eSymbolContextFunction;
- else {
- // We might have had a compile unit that had discontiguous
- // address ranges where the gaps are symbols that don't have
- // any debug info. Discontiguous compile unit address ranges
- // should only happen when there aren't other functions from
- // other compile units in these gaps. This helps keep the size
- // of the aranges down.
- force_check_line_table = true;
- }
- if (sc.block)
- resolved |= eSymbolContextBlock;
+ }
+ } else {
+ uint32_t cu_idx = DW_INVALID_INDEX;
+ if (auto *dwarf_cu = llvm::dyn_cast_or_null<DWARFCompileUnit>(
+ debug_info.GetUnitAtOffset(DIERef::Section::DebugInfo, cu_offset,
+ &cu_idx))) {
+ sc.comp_unit = GetCompUnitForDWARFCompUnit(*dwarf_cu);
+ if (sc.comp_unit) {
+ resolved |= eSymbolContextCompUnit;
+
+ bool force_check_line_table = false;
+ if (resolve_scope & (eSymbolContextFunction | eSymbolContextBlock)) {
+ ResolveFunctionAndBlock(file_vm_addr,
+ resolve_scope & eSymbolContextBlock, sc);
+ if (sc.function)
+ resolved |= eSymbolContextFunction;
+ else {
+ // We might have had a compile unit that had discontiguous address
+ // ranges where the gaps are symbols that don't have any debug
+ // info. Discontiguous compile unit address ranges should only
+ // happen when there aren't other functions from other compile
+ // units in these gaps. This helps keep the size of the aranges
+ // down.
+ force_check_line_table = true;
}
+ if (sc.block)
+ resolved |= eSymbolContextBlock;
+ }
- if ((resolve_scope & eSymbolContextLineEntry) ||
- force_check_line_table) {
- LineTable *line_table = sc.comp_unit->GetLineTable();
- if (line_table != nullptr) {
- // And address that makes it into this function should be in
- // terms of this debug file if there is no debug map, or it
- // will be an address in the .o file which needs to be fixed up
- // to be in terms of the debug map executable. Either way,
- // calling FixupAddress() will work for us.
- Address exe_so_addr(so_addr);
- if (FixupAddress(exe_so_addr)) {
- if (line_table->FindLineEntryByAddress(exe_so_addr,
- sc.line_entry)) {
- resolved |= eSymbolContextLineEntry;
- }
+ if ((resolve_scope & eSymbolContextLineEntry) ||
+ force_check_line_table) {
+ LineTable *line_table = sc.comp_unit->GetLineTable();
+ if (line_table != nullptr) {
+ // And address that makes it into this function should be in terms
+ // of this debug file if there is no debug map, or it will be an
+ // address in the .o file which needs to be fixed up to be in
+ // terms of the debug map executable. Either way, calling
+ // FixupAddress() will work for us.
+ Address exe_so_addr(so_addr);
+ if (FixupAddress(exe_so_addr)) {
+ if (line_table->FindLineEntryByAddress(exe_so_addr,
+ sc.line_entry)) {
+ resolved |= eSymbolContextLineEntry;
}
}
}
+ }
- if (force_check_line_table &&
- !(resolved & eSymbolContextLineEntry)) {
- // We might have had a compile unit that had discontiguous
- // address ranges where the gaps are symbols that don't have any
- // debug info. Discontiguous compile unit address ranges should
- // only happen when there aren't other functions from other
- // compile units in these gaps. This helps keep the size of the
- // aranges down.
- sc.comp_unit = nullptr;
- resolved &= ~eSymbolContextCompUnit;
- }
- } else {
- GetObjectFile()->GetModule()->ReportWarning(
- "0x%8.8x: compile unit %u failed to create a valid "
- "lldb_private::CompileUnit class.",
- cu_offset, cu_idx);
+ if (force_check_line_table && !(resolved & eSymbolContextLineEntry)) {
+ // We might have had a compile unit that had discontiguous address
+ // ranges where the gaps are symbols that don't have any debug info.
+ // Discontiguous compile unit address ranges should only happen when
+ // there aren't other functions from other compile units in these
+ // gaps. This helps keep the size of the aranges down.
+ sc.comp_unit = nullptr;
+ resolved &= ~eSymbolContextCompUnit;
}
+ } else {
+ GetObjectFile()->GetModule()->ReportWarning(
+ "0x%8.8x: compile unit %u failed to create a valid "
+ "lldb_private::CompileUnit class.",
+ cu_offset, cu_idx);
}
}
}
@@ -2052,10 +2025,6 @@ void SymbolFileDWARF::FindGlobalVariables(
if (!DeclContextMatchesThisSymbolFile(parent_decl_ctx))
return;
- DWARFDebugInfo *info = DebugInfo();
- if (!info)
- return;
-
// Remember how many variables are in the list before we search.
const uint32_t original_size = variables.GetSize();
@@ -2156,10 +2125,6 @@ void SymbolFileDWARF::FindGlobalVariables(const RegularExpression ®ex,
regex.GetText().str().c_str(), max_matches);
}
- DWARFDebugInfo *info = DebugInfo();
- if (!info)
- return;
-
// Remember how many variables are in the list before we search.
const uint32_t original_size = variables.GetSize();
@@ -2341,16 +2306,13 @@ void SymbolFileDWARF::FindFunctions(const RegularExpression ®ex,
regex.GetText().str().c_str());
}
- DWARFDebugInfo *info = DebugInfo();
- if (!info)
- return;
-
+ DWARFDebugInfo &info = DebugInfo();
DIEArray offsets;
m_index->GetFunctions(regex, offsets);
llvm::DenseSet<const DWARFDebugInfoEntry *> resolved_dies;
for (DIERef ref : offsets) {
- DWARFDIE die = info->GetDIE(ref);
+ DWARFDIE die = info.GetDIE(ref);
if (!die) {
m_index->ReportInvalidDIERef(ref, regex.GetText());
continue;
@@ -2363,13 +2325,10 @@ void SymbolFileDWARF::FindFunctions(const RegularExpression ®ex,
void SymbolFileDWARF::GetMangledNamesForFunction(
const std::string &scope_qualified_name,
std::vector<ConstString> &mangled_names) {
- DWARFDebugInfo *info = DebugInfo();
- uint32_t num_comp_units = 0;
- if (info)
- num_comp_units = info->GetNumUnits();
-
+ DWARFDebugInfo &info = DebugInfo();
+ uint32_t num_comp_units = info.GetNumUnits();
for (uint32_t i = 0; i < num_comp_units; i++) {
- DWARFUnit *cu = info->GetUnitAtIndex(i);
+ DWARFUnit *cu = info.GetUnitAtIndex(i);
if (cu == nullptr)
continue;
@@ -2395,10 +2354,6 @@ void SymbolFileDWARF::FindTypes(
if (!searched_symbol_files.insert(this).second)
return;
- DWARFDebugInfo *info = DebugInfo();
- if (!info)
- return;
-
Log *log(LogChannelDWARF::GetLogIfAll(DWARF_LOG_LOOKUPS));
if (log) {
@@ -2547,28 +2502,25 @@ SymbolFileDWARF::FindNamespace(ConstString name,
if (!DeclContextMatchesThisSymbolFile(parent_decl_ctx))
return namespace_decl_ctx;
- DWARFDebugInfo *info = DebugInfo();
- if (info) {
- DIEArray die_offsets;
- m_index->GetNamespaces(name, die_offsets);
- const size_t num_matches = die_offsets.size();
- if (num_matches) {
- for (size_t i = 0; i < num_matches; ++i) {
- const DIERef &die_ref = die_offsets[i];
- DWARFDIE die = GetDIE(die_ref);
-
- if (die) {
- if (!DIEInDeclContext(parent_decl_ctx, die))
- continue; // The containing decl contexts don't match
-
- if (DWARFASTParser *dwarf_ast = GetDWARFParser(*die.GetCU())) {
- namespace_decl_ctx = dwarf_ast->GetDeclContextForUIDFromDWARF(die);
- if (namespace_decl_ctx)
- break;
- }
- } else {
- m_index->ReportInvalidDIERef(die_ref, name.GetStringRef());
+ DIEArray die_offsets;
+ m_index->GetNamespaces(name, die_offsets);
+ const size_t num_matches = die_offsets.size();
+ if (num_matches) {
+ for (size_t i = 0; i < num_matches; ++i) {
+ const DIERef &die_ref = die_offsets[i];
+ DWARFDIE die = GetDIE(die_ref);
+
+ if (die) {
+ if (!DIEInDeclContext(parent_decl_ctx, die))
+ continue; // The containing decl contexts don't match
+
+ if (DWARFASTParser *dwarf_ast = GetDWARFParser(*die.GetCU())) {
+ namespace_decl_ctx = dwarf_ast->GetDeclContextForUIDFromDWARF(die);
+ if (namespace_decl_ctx)
+ break;
}
+ } else {
+ m_index->ReportInvalidDIERef(die_ref, name.GetStringRef());
}
}
}
@@ -2697,10 +2649,10 @@ bool SymbolFileDWARF::Supports_DW_AT_APPLE_objc_complete_type(DWARFUnit *cu) {
if (cu && cu->Supports_DW_AT_APPLE_objc_complete_type())
m_supports_DW_AT_APPLE_objc_complete_type = eLazyBoolYes;
else {
- DWARFDebugInfo *debug_info = DebugInfo();
+ DWARFDebugInfo &debug_info = DebugInfo();
const uint32_t num_compile_units = GetNumCompileUnits();
for (uint32_t cu_idx = 0; cu_idx < num_compile_units; ++cu_idx) {
- DWARFUnit *dwarf_cu = debug_info->GetUnitAtIndex(cu_idx);
+ DWARFUnit *dwarf_cu = debug_info.GetUnitAtIndex(cu_idx);
if (dwarf_cu != cu &&
dwarf_cu->Supports_DW_AT_APPLE_objc_complete_type()) {
m_supports_DW_AT_APPLE_objc_complete_type = eLazyBoolYes;
@@ -3114,10 +3066,6 @@ size_t SymbolFileDWARF::ParseTypes(CompileUnit &comp_unit) {
size_t SymbolFileDWARF::ParseVariablesForContext(const SymbolContext &sc) {
std::lock_guard<std::recursive_mutex> guard(GetModuleMutex());
if (sc.comp_unit != nullptr) {
- DWARFDebugInfo *info = DebugInfo();
- if (info == nullptr)
- return 0;
-
if (sc.function) {
DWARFDIE function_die = GetDIE(sc.function->GetID());
@@ -3132,7 +3080,7 @@ size_t SymbolFileDWARF::ParseVariablesForContext(const SymbolContext &sc) {
return num_variables;
}
} else if (sc.comp_unit) {
- DWARFUnit *dwarf_cu = info->GetUnitAtIndex(sc.comp_unit->GetID());
+ DWARFUnit *dwarf_cu = DebugInfo().GetUnitAtIndex(sc.comp_unit->GetID());
if (dwarf_cu == nullptr)
return 0;
@@ -3563,7 +3511,7 @@ SymbolFileDWARF::FindBlockContainingSpecification(
// Give the concrete function die specified by "func_die_offset", find the
// concrete block whose DW_AT_specification or DW_AT_abstract_origin points
// to "spec_block_die_offset"
- return FindBlockContainingSpecification(DebugInfo()->GetDIE(func_die_ref),
+ return FindBlockContainingSpecification(DebugInfo().GetDIE(func_die_ref),
spec_block_die_offset);
}
diff --git a/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h b/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h
index 04be8f5e7349..f05d455eb8d9 100644
--- a/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h
+++ b/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h
@@ -222,7 +222,7 @@ class SymbolFileDWARF : public lldb_private::SymbolFile,
DWARFDebugAbbrev *DebugAbbrev();
- DWARFDebugInfo *DebugInfo();
+ DWARFDebugInfo &DebugInfo();
DWARFDebugRanges *GetDebugRanges();
diff --git a/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDwo.cpp b/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDwo.cpp
index 652c910be4dc..cfb841621566 100644
--- a/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDwo.cpp
+++ b/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDwo.cpp
@@ -36,15 +36,11 @@ SymbolFileDWARFDwo::SymbolFileDWARFDwo(SymbolFileDWARF &base_symbol_file,
}
DWARFCompileUnit *SymbolFileDWARFDwo::GetDWOCompileUnitForHash(uint64_t hash) {
- DWARFDebugInfo *debug_info = DebugInfo();
- if (!debug_info)
- return nullptr;
-
if (const llvm::DWARFUnitIndex &index = m_context.GetAsLLVM().getCUIndex()) {
if (const llvm::DWARFUnitIndex::Entry *entry = index.getFromHash(hash)) {
if (auto *unit_contrib = entry->getOffset())
return llvm::dyn_cast_or_null<DWARFCompileUnit>(
- debug_info->GetUnitAtOffset(DIERef::Section::DebugInfo,
+ DebugInfo().GetUnitAtOffset(DIERef::Section::DebugInfo,
unit_contrib->Offset));
}
return nullptr;
@@ -60,19 +56,19 @@ DWARFCompileUnit *SymbolFileDWARFDwo::GetDWOCompileUnitForHash(uint64_t hash) {
}
DWARFCompileUnit *SymbolFileDWARFDwo::FindSingleCompileUnit() {
- DWARFDebugInfo *debug_info = DebugInfo();
+ DWARFDebugInfo &debug_info = DebugInfo();
// Right now we only support dwo files with one compile unit. If we don't have
// type units, we can just check for the unit count.
- if (!debug_info->ContainsTypeUnits() && debug_info->GetNumUnits() == 1)
- return llvm::cast<DWARFCompileUnit>(debug_info->GetUnitAtIndex(0));
+ if (!debug_info.ContainsTypeUnits() && debug_info.GetNumUnits() == 1)
+ return llvm::cast<DWARFCompileUnit>(debug_info.GetUnitAtIndex(0));
// Otherwise, we have to run through all units, and find the compile unit that
// way.
DWARFCompileUnit *cu = nullptr;
- for (size_t i = 0; i < debug_info->GetNumUnits(); ++i) {
+ for (size_t i = 0; i < debug_info.GetNumUnits(); ++i) {
if (auto *candidate =
- llvm::dyn_cast<DWARFCompileUnit>(debug_info->GetUnitAtIndex(i))) {
+ llvm::dyn_cast<DWARFCompileUnit>(debug_info.GetUnitAtIndex(i))) {
if (cu)
return nullptr; // More that one CU found.
cu = candidate;
@@ -130,6 +126,6 @@ SymbolFileDWARFDwo::GetTypeSystemForLanguage(LanguageType language) {
DWARFDIE
SymbolFileDWARFDwo::GetDIE(const DIERef &die_ref) {
if (*die_ref.dwo_num() == GetDwoNum())
- return DebugInfo()->GetDIE(die_ref);
+ return DebugInfo().GetDIE(die_ref);
return GetBaseSymbolFile().GetDIE(die_ref);
}
More information about the lldb-commits
mailing list