[Lldb-commits] [PATCH] D39825: [lldb] Fix cu_offset for dwo/dwp used by DWARFCompileUnit::Index
Alexander Shaposhnikov via Phabricator via lldb-commits
lldb-commits at lists.llvm.org
Wed Nov 8 17:20:08 PST 2017
alexshap created this revision.
Herald added subscribers: JDevlieghere, aprantl.
At the moment for DIERefs coming from DWO/DWP LLDB expects cu_offset to be equal to the offset of
the original compilation unit. This invariant is ensured during the "indexing" of DIEs of the original SymbolFileDWARF
and during the "retrieval" (see, for example, SymbolFileDWARFDwo::GetDIE(const DIERef &die_ref) ) as well.
However any call of SymbolFileDWARFDwo::Index would violate this invariant since GetOffset() would return 0 in this case
(and later the various asserts would fire).
The diff addresses the issue.
Repository:
rL LLVM
https://reviews.llvm.org/D39825
Files:
source/Plugins/SymbolFile/DWARF/DWARFCompileUnit.cpp
source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h
source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDwo.h
Index: source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDwo.h
===================================================================
--- source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDwo.h
+++ source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDwo.h
@@ -45,6 +45,10 @@
return nullptr;
}
+ DWARFCompileUnit* GetBaseCompileUnit() override {
+ return m_base_dwarf_cu;
+ }
+
protected:
void LoadSectionData(lldb::SectionType sect_type,
lldb_private::DWARFDataExtractor &data) override;
Index: source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h
===================================================================
--- source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h
+++ source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h
@@ -299,6 +299,11 @@
GetDwoSymbolFileForCompileUnit(DWARFCompileUnit &dwarf_cu,
const DWARFDebugInfoEntry &cu_die);
+ // For regular SymbolFileDWARF instances the method returns nullptr,
+ // for the instances of the subclass SymbolFileDWARFDwo
+ // the method returns a pointer to the base compile unit.
+ virtual DWARFCompileUnit* GetBaseCompileUnit();
+
protected:
typedef llvm::DenseMap<const DWARFDebugInfoEntry *, lldb_private::Type *>
DIEToTypePtr;
Index: source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
===================================================================
--- source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
+++ source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
@@ -209,6 +209,10 @@
return nullptr;
}
+DWARFCompileUnit* SymbolFileDWARF::GetBaseCompileUnit() {
+ return nullptr;
+}
+
void SymbolFileDWARF::Initialize() {
LogChannelDWARF::Initialize();
PluginManager::RegisterPlugin(GetPluginNameStatic(),
Index: source/Plugins/SymbolFile/DWARF/DWARFCompileUnit.cpp
===================================================================
--- source/Plugins/SymbolFile/DWARF/DWARFCompileUnit.cpp
+++ source/Plugins/SymbolFile/DWARF/DWARFCompileUnit.cpp
@@ -634,14 +634,23 @@
DWARFFormValue::GetFixedFormSizesForAddressSize(GetAddressByteSize(),
m_is_dwarf64);
- IndexPrivate(this, cu_language, fixed_form_sizes, GetOffset(), func_basenames,
+ dw_offset_t cu_offset = DW_INVALID_OFFSET;
+ // m_dwarf2Data->GetBaseCompileUnit() will return non null
+ // if m_dwarf2Data represents a DWO or DWP file.
+ // In this case the offset of the base compile unit should be used.
+ if (const DWARFCompileUnit *base_cu = m_dwarf2Data->GetBaseCompileUnit())
+ cu_offset = base_cu->GetOffset();
+ else
+ cu_offset = GetOffset();
+
+ IndexPrivate(this, cu_language, fixed_form_sizes, cu_offset, func_basenames,
func_fullnames, func_methods, func_selectors,
objc_class_selectors, globals, types, namespaces);
SymbolFileDWARFDwo *dwo_symbol_file = GetDwoSymbolFile();
if (dwo_symbol_file) {
IndexPrivate(dwo_symbol_file->GetCompileUnit(), cu_language,
- fixed_form_sizes, GetOffset(), func_basenames, func_fullnames,
+ fixed_form_sizes, cu_offset, func_basenames, func_fullnames,
func_methods, func_selectors, objc_class_selectors, globals,
types, namespaces);
}
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D39825.122183.patch
Type: text/x-patch
Size: 3288 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/lldb-commits/attachments/20171109/72fa3538/attachment.bin>
More information about the lldb-commits
mailing list