jankratochvil updated this revision to Diff 184919.
jankratochvil added a comment.
This update fixes a regression after D52403 <https://reviews.llvm.org/D52403>,
the code is simplified - `eSectionTypeDWARFDebugInfo` is no longer hardcoded in
this patch.
OK for check-in with this new code?
Repository:
rLLDB LLDB
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D51578/new/
https://reviews.llvm.org/D51578
Files:
lldb/include/lldb/lldb-enumerations.h
lldb/source/Core/Section.cpp
lldb/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp
lldb/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp
lldb/source/Plugins/SymbolFile/DWARF/DWARFCompileUnit.cpp
lldb/source/Plugins/SymbolFile/DWARF/DWARFCompileUnit.h
lldb/source/Plugins/SymbolFile/DWARF/DWARFDebugInfo.cpp
lldb/source/Plugins/SymbolFile/DWARF/DWARFUnit.cpp
lldb/source/Plugins/SymbolFile/DWARF/DWARFUnit.h
lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h
lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDwo.cpp
lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDwo.h
lldb/source/Symbol/ObjectFile.cpp
Index: lldb/source/Symbol/ObjectFile.cpp
===================================================================
--- lldb/source/Symbol/ObjectFile.cpp
+++ lldb/source/Symbol/ObjectFile.cpp
@@ -367,6 +367,7 @@
case eSectionTypeDWARFDebugStrOffsets:
case eSectionTypeDWARFDebugStrOffsetsDwo:
case eSectionTypeDWARFDebugTypes:
+ case eSectionTypeDWARFDebugTypesDwo:
case eSectionTypeDWARFAppleNames:
case eSectionTypeDWARFAppleTypes:
case eSectionTypeDWARFAppleNamespaces:
Index: lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDwo.h
===================================================================
--- lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDwo.h
+++ lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDwo.h
@@ -47,9 +47,10 @@
const lldb_private::DWARFDataExtractor &get_debug_abbrev_data() override;
const lldb_private::DWARFDataExtractor &get_debug_addr_data() override;
- const lldb_private::DWARFDataExtractor &get_debug_info_data() override;
+ const lldb_private::DWARFDataExtractor &get_raw_debug_info_data() override;
const lldb_private::DWARFDataExtractor &get_debug_str_data() override;
const lldb_private::DWARFDataExtractor &get_debug_str_offsets_data() override;
+ const lldb_private::DWARFDataExtractor &get_raw_debug_types_data() override;
protected:
void LoadSectionData(lldb::SectionType sect_type,
Index: lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDwo.cpp
===================================================================
--- lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDwo.cpp
+++ lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDwo.cpp
@@ -135,8 +135,9 @@
return m_data_debug_addr.m_data;
}
-const DWARFDataExtractor &SymbolFileDWARFDwo::get_debug_info_data() {
- return GetCachedSectionData(eSectionTypeDWARFDebugInfoDwo, m_data_debug_info);
+const DWARFDataExtractor &SymbolFileDWARFDwo::get_raw_debug_info_data() {
+ return GetCachedSectionData(eSectionTypeDWARFDebugInfoDwo,
+ m_data_raw_debug_info);
}
const DWARFDataExtractor &SymbolFileDWARFDwo::get_debug_str_data() {
@@ -148,6 +149,11 @@
m_data_debug_str_offsets);
}
+const DWARFDataExtractor &SymbolFileDWARFDwo::get_raw_debug_types_data() {
+ return GetCachedSectionData(eSectionTypeDWARFDebugTypesDwo,
+ m_data_raw_debug_types);
+}
+
SymbolFileDWARF *SymbolFileDWARFDwo::GetBaseSymbolFile() {
return m_base_dwarf_cu->GetSymbolFileDWARF();
}
Index: lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h
===================================================================
--- lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h
+++ lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h
@@ -231,7 +231,8 @@
virtual const lldb_private::DWARFDataExtractor &get_debug_addr_data();
const lldb_private::DWARFDataExtractor &get_debug_aranges_data();
const lldb_private::DWARFDataExtractor &get_debug_frame_data();
- virtual const lldb_private::DWARFDataExtractor &get_debug_info_data();
+ const lldb_private::DWARFDataExtractor &get_debug_info_data();
+ virtual const lldb_private::DWARFDataExtractor &get_raw_debug_info_data();
const lldb_private::DWARFDataExtractor &get_debug_line_data();
const lldb_private::DWARFDataExtractor &get_debug_line_str_data();
const lldb_private::DWARFDataExtractor &get_debug_macro_data();
@@ -241,7 +242,7 @@
const lldb_private::DWARFDataExtractor &get_debug_rnglists_data();
virtual const lldb_private::DWARFDataExtractor &get_debug_str_data();
virtual const lldb_private::DWARFDataExtractor &get_debug_str_offsets_data();
- const lldb_private::DWARFDataExtractor &get_debug_types_data();
+ virtual const lldb_private::DWARFDataExtractor &get_raw_debug_types_data();
const lldb_private::DWARFDataExtractor &get_apple_names_data();
const lldb_private::DWARFDataExtractor &get_apple_types_data();
const lldb_private::DWARFDataExtractor &get_apple_namespaces_data();
@@ -321,6 +322,10 @@
void DumpClangAST(lldb_private::Stream &s) override;
+ uint64_t get_debug_types_offset() const {
+ return m_debug_info_concatenated_types_offset;
+ }
+
protected:
typedef llvm::DenseMap<const DWARFDebugInfoEntry *, lldb_private::Type *>
DIEToTypePtr;
@@ -466,7 +471,7 @@
DWARFDataSegment m_data_debug_addr;
DWARFDataSegment m_data_debug_aranges;
DWARFDataSegment m_data_debug_frame;
- DWARFDataSegment m_data_debug_info;
+ DWARFDataSegment m_data_raw_debug_info;
DWARFDataSegment m_data_debug_line;
DWARFDataSegment m_data_debug_line_str;
DWARFDataSegment m_data_debug_macro;
@@ -476,13 +481,17 @@
DWARFDataSegment m_data_debug_rnglists;
DWARFDataSegment m_data_debug_str;
DWARFDataSegment m_data_debug_str_offsets;
- DWARFDataSegment m_data_debug_types;
+ DWARFDataSegment m_data_raw_debug_types;
DWARFDataSegment m_data_apple_names;
DWARFDataSegment m_data_apple_types;
DWARFDataSegment m_data_apple_namespaces;
DWARFDataSegment m_data_apple_objc;
DWARFDataSegment m_data_gnu_debugaltlink;
+ llvm::once_flag m_concatenated_data_once;
+ lldb_private::DWARFDataExtractor m_data_debug_info_concatenated;
+ uint64_t m_debug_info_concatenated_types_offset;
+
// The unique pointer items below are generated on demand if and when someone
// accesses
// them through a non const version of this class.
Index: lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
===================================================================
--- lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
+++ lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
@@ -354,7 +354,7 @@
// when this class parses .o files to
// contain the .o file index/ID
m_debug_map_module_wp(), m_debug_map_symfile(NULL), m_data_debug_abbrev(),
- m_data_debug_aranges(), m_data_debug_frame(), m_data_debug_info(),
+ m_data_debug_aranges(), m_data_debug_frame(), m_data_raw_debug_info(),
m_data_debug_line(), m_data_debug_macro(), m_data_debug_loc(),
m_data_debug_ranges(), m_data_debug_rnglists(), m_data_debug_str(),
m_data_apple_names(), m_data_apple_types(), m_data_apple_namespaces(),
@@ -580,8 +580,9 @@
return GetCachedSectionData(eSectionTypeDWARFDebugFrame, m_data_debug_frame);
}
-const DWARFDataExtractor &SymbolFileDWARF::get_debug_info_data() {
- return GetCachedSectionData(eSectionTypeDWARFDebugInfo, m_data_debug_info);
+const DWARFDataExtractor &SymbolFileDWARF::get_raw_debug_info_data() {
+ return GetCachedSectionData(eSectionTypeDWARFDebugInfo,
+ m_data_raw_debug_info);
}
const DWARFDataExtractor &SymbolFileDWARF::get_debug_line_data() {
@@ -631,8 +632,9 @@
m_data_debug_str_offsets);
}
-const DWARFDataExtractor &SymbolFileDWARF::get_debug_types_data() {
- return GetCachedSectionData(eSectionTypeDWARFDebugTypes, m_data_debug_types);
+const DWARFDataExtractor &SymbolFileDWARF::get_raw_debug_types_data() {
+ return GetCachedSectionData(eSectionTypeDWARFDebugTypes,
+ m_data_raw_debug_types);
}
const DWARFDataExtractor &SymbolFileDWARF::get_apple_names_data() {
@@ -657,6 +659,56 @@
m_data_gnu_debugaltlink);
}
+const DWARFDataExtractor &
+ SymbolFileDWARF::get_debug_info_data() {
+ llvm::call_once(m_concatenated_data_once, [&] {
+ const auto &debug_info_data = get_raw_debug_info_data();
+ const auto &debug_types_data = get_raw_debug_types_data();
+ if (!debug_info_data.GetByteSize() && !debug_types_data.GetByteSize())
+ return;
+ // For this optimization of mmapped sections we do not handle .debug_types
+ // present without .debug_info as that should not happen.
+ if (debug_info_data.GetByteSize()
+ && (!debug_types_data.GetByteSize()
+ || debug_info_data.GetDataStart() + debug_info_data.GetByteSize()
+ <= debug_types_data.GetDataStart())) {
+ uint64_t length;
+ if (debug_types_data.GetByteSize()) {
+ m_debug_info_concatenated_types_offset =
+ debug_types_data.GetDataStart() - debug_info_data.GetDataStart();
+ length = debug_types_data.GetDataStart()
+ + debug_types_data.GetByteSize() - debug_info_data.GetDataStart();
+ lldbassert(debug_info_data.GetByteOrder()
+ == debug_types_data.GetByteOrder());
+ } else {
+ m_debug_info_concatenated_types_offset = debug_info_data.GetByteSize();
+ length = debug_info_data.GetByteSize();
+ }
+ if (!m_obj_file->IsInMemory()) {
+ m_data_debug_info_concatenated.SetData(debug_info_data.GetDataStart(),
+ length, debug_info_data.GetByteOrder());
+ return;
+ }
+ }
+ DataBufferHeap *databufferheap = new DataBufferHeap();
+ DataBufferSP databuffer = DataBufferSP(databufferheap);
+ databufferheap->AppendData(
+ debug_info_data.GetDataStart(),
+ debug_info_data.GetByteSize());
+ m_debug_info_concatenated_types_offset =
+ databufferheap->GetByteSize();
+ databufferheap->AppendData(
+ debug_types_data.GetDataStart(),
+ debug_types_data.GetByteSize());
+ m_data_debug_info_concatenated.SetData(databuffer);
+ m_data_debug_info_concatenated.SetByteOrder(
+ debug_info_data.GetByteOrder());
+ m_data_debug_info_concatenated.SetAddressByteSize(
+ debug_info_data.GetAddressByteSize());
+ });
+ return m_data_debug_info_concatenated;
+}
+
DWARFDebugAbbrev *SymbolFileDWARF::DebugAbbrev() {
if (m_abbr.get() == NULL) {
const DWARFDataExtractor &debug_abbrev_data = get_debug_abbrev_data();
Index: lldb/source/Plugins/SymbolFile/DWARF/DWARFUnit.h
===================================================================
--- lldb/source/Plugins/SymbolFile/DWARF/DWARFUnit.h
+++ lldb/source/Plugins/SymbolFile/DWARF/DWARFUnit.h
@@ -69,7 +69,7 @@
/// @return
/// The correct data for the DIE information in this unit.
//------------------------------------------------------------------
- virtual const lldb_private::DWARFDataExtractor &GetData() const = 0;
+ const lldb_private::DWARFDataExtractor &GetData() const;
//------------------------------------------------------------------
/// Get the size in bytes of the compile unit header.
///
Index: lldb/source/Plugins/SymbolFile/DWARF/DWARFUnit.cpp
===================================================================
--- lldb/source/Plugins/SymbolFile/DWARF/DWARFUnit.cpp
+++ lldb/source/Plugins/SymbolFile/DWARF/DWARFUnit.cpp
@@ -876,3 +876,6 @@
return *m_func_aranges_ap.get();
}
+const lldb_private::DWARFDataExtractor &DWARFUnit::GetData() const {
+ return m_dwarf->get_debug_info_data();
+}
Index: lldb/source/Plugins/SymbolFile/DWARF/DWARFDebugInfo.cpp
===================================================================
--- lldb/source/Plugins/SymbolFile/DWARF/DWARFDebugInfo.cpp
+++ lldb/source/Plugins/SymbolFile/DWARF/DWARFDebugInfo.cpp
@@ -97,7 +97,7 @@
if (m_dwarf2Data != NULL) {
lldb::offset_t offset = 0;
DWARFUnitSP cu_sp;
- const auto &debug_info_data = m_dwarf2Data->get_debug_info_data();
+ const auto &debug_info_data = m_dwarf2Data->get_raw_debug_info_data();
while ((cu_sp = DWARFCompileUnit::Extract(m_dwarf2Data, debug_info_data,
&offset))) {
m_compile_units.push_back(cu_sp);
Index: lldb/source/Plugins/SymbolFile/DWARF/DWARFCompileUnit.h
===================================================================
--- lldb/source/Plugins/SymbolFile/DWARF/DWARFCompileUnit.h
+++ lldb/source/Plugins/SymbolFile/DWARF/DWARFCompileUnit.h
@@ -18,16 +18,6 @@
lldb::offset_t *offset_ptr);
void Dump(lldb_private::Stream *s) const override;
- //------------------------------------------------------------------
- /// Get the data that contains the DIE information for this unit.
- ///
- /// @return
- /// The correct data (.debug_types for DWARF 4 and earlier, and
- /// .debug_info for DWARF 5 and later) for the DIE information in
- /// this unit.
- //------------------------------------------------------------------
- const lldb_private::DWARFDataExtractor &GetData() const override;
-
//------------------------------------------------------------------
/// Get the size in bytes of the header.
///
Index: lldb/source/Plugins/SymbolFile/DWARF/DWARFCompileUnit.cpp
===================================================================
--- lldb/source/Plugins/SymbolFile/DWARF/DWARFCompileUnit.cpp
+++ lldb/source/Plugins/SymbolFile/DWARF/DWARFCompileUnit.cpp
@@ -91,7 +91,3 @@
}
llvm_unreachable("invalid UnitType.");
}
-
-const lldb_private::DWARFDataExtractor &DWARFCompileUnit::GetData() const {
- return m_dwarf->get_debug_info_data();
-}
Index: lldb/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp
===================================================================
--- lldb/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp
+++ lldb/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp
@@ -1210,6 +1210,7 @@
case eSectionTypeDWARFDebugStrOffsets:
case eSectionTypeDWARFDebugStrOffsetsDwo:
case eSectionTypeDWARFDebugTypes:
+ case eSectionTypeDWARFDebugTypesDwo:
case eSectionTypeDWARFAppleNames:
case eSectionTypeDWARFAppleTypes:
case eSectionTypeDWARFAppleNamespaces:
Index: lldb/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp
===================================================================
--- lldb/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp
+++ lldb/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp
@@ -1774,6 +1774,7 @@
.Case(".debug_str_offsets", eSectionTypeDWARFDebugStrOffsets)
.Case(".debug_str_offsets.dwo", eSectionTypeDWARFDebugStrOffsetsDwo)
.Case(".debug_types", eSectionTypeDWARFDebugTypes)
+ .Case(".debug_types.dwo", eSectionTypeDWARFDebugTypesDwo)
.Case(".eh_frame", eSectionTypeEHFrame)
.Case(".gnu_debugaltlink", eSectionTypeDWARFGNUDebugAltLink)
.Case(".gosymtab", eSectionTypeGoSymtab)
Index: lldb/source/Core/Section.cpp
===================================================================
--- lldb/source/Core/Section.cpp
+++ lldb/source/Core/Section.cpp
@@ -104,6 +104,8 @@
return "dwarf-str-offsets-dwo";
case eSectionTypeDWARFDebugTypes:
return "dwarf-types";
+ case eSectionTypeDWARFDebugTypesDwo:
+ return "dwarf-types-dwo";
case eSectionTypeDWARFDebugNames:
return "dwarf-names";
case eSectionTypeELFSymbolTable:
Index: lldb/include/lldb/lldb-enumerations.h
===================================================================
--- lldb/include/lldb/lldb-enumerations.h
+++ lldb/include/lldb/lldb-enumerations.h
@@ -718,6 +718,7 @@
eSectionTypeDWARFDebugInfoDwo,
eSectionTypeDWARFDebugStrDwo,
eSectionTypeDWARFDebugStrOffsetsDwo,
+ eSectionTypeDWARFDebugTypesDwo,
};
FLAGS_ENUM(EmulateInstructionOptions){
_______________________________________________
lldb-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits