[Lldb-commits] [lldb] r361000 - Make DWARFContext dwo-aware and port debug_info sections over
Pavel Labath via lldb-commits
lldb-commits at lists.llvm.org
Fri May 17 01:26:58 PDT 2019
Author: labath
Date: Fri May 17 01:26:58 2019
New Revision: 361000
URL: http://llvm.org/viewvc/llvm-project?rev=361000&view=rev
Log:
Make DWARFContext dwo-aware and port debug_info sections over
Summary:
The previous attempt and moving section handling over to DWARFContext
(D59611) failed because it did not take into account the dwo sections
correctly. All DWARFContexts (even those in SymbolFileDWARFDwo) used the
main module for loading the sections, but in the dwo scenario some
sections should come from the dwo file.
This patch fixes that by making the DWARFContext aware of whether it a
dwo context or a regular one. A dwo context gets two sections lists, and
it knows where to look for a particular type of a section. This isn't
fully consistent with how the llvm DWARFContext behaves, because that
one leaves it up to the user to know whether it should ask for a dwo
section or not. However, for the time being, it seems useful to have a
single entity which knows how to peice together the debug info in dwo
and non-dwo scenarios. The rough roadmap for the future is:
- port over the rest of the sections to DWARFContext
- find a way to get rid of SymbolFileDWARFDwo/Dwp/DwpDwo. This will
likely involve adding the ability for the DWARFContext to spawn
dwo sub-contexts, similarly to how it's done in llvm.
- get rid of the special handling of the "dwo" contexts by making
sure everything knows whether it should ask for the .dwo version of
the section or not (similarly to how llvm's DWARFUnits do that)
To demonstrate how the DWARFContext should behave in this new world, I
port the debug_info section (which is debug_info.dwo in the dwo file)
handling to DWARFContext. The rest of the sections will come in
subsequent patches.
Reviewers: aprantl, clayborg, JDevlieghere
Subscribers: zturner, lldb-commits
Differential Revision: https://reviews.llvm.org/D62012
Modified:
lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFCompileUnit.cpp
lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFContext.cpp
lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFContext.h
lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFDebugInfo.cpp
lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFFormValue.cpp
lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h
lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDwo.cpp
lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDwo.h
Modified: lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFCompileUnit.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFCompileUnit.cpp?rev=361000&r1=360999&r2=361000&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFCompileUnit.cpp (original)
+++ lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFCompileUnit.cpp Fri May 17 01:26:58 2019
@@ -106,5 +106,5 @@ uint32_t DWARFCompileUnit::GetHeaderByte
}
const lldb_private::DWARFDataExtractor &DWARFCompileUnit::GetData() const {
- return m_dwarf->get_debug_info_data();
+ return m_dwarf->GetDWARFContext().getOrLoadDebugInfoData();
}
Modified: lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFContext.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFContext.cpp?rev=361000&r1=360999&r2=361000&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFContext.cpp (original)
+++ lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFContext.cpp Fri May 17 01:26:58 2019
@@ -13,9 +13,8 @@
using namespace lldb;
using namespace lldb_private;
-static DWARFDataExtractor LoadSection(Module &module,
+static DWARFDataExtractor LoadSection(SectionList *section_list,
SectionType section_type) {
- SectionList *section_list = module.GetSectionList();
if (!section_list)
return DWARFDataExtractor();
@@ -29,16 +28,22 @@ static DWARFDataExtractor LoadSection(Mo
}
static const DWARFDataExtractor &
-LoadOrGetSection(Module &module, SectionType section_type,
+LoadOrGetSection(SectionList *section_list, SectionType section_type,
llvm::Optional<DWARFDataExtractor> &extractor) {
if (!extractor)
- extractor = LoadSection(module, section_type);
+ extractor = LoadSection(section_list, section_type);
return *extractor;
}
-DWARFContext::DWARFContext(Module &module) : m_module(module) {}
-
const DWARFDataExtractor &DWARFContext::getOrLoadArangesData() {
- return LoadOrGetSection(m_module, eSectionTypeDWARFDebugAranges,
+ return LoadOrGetSection(m_main_section_list, eSectionTypeDWARFDebugAranges,
m_data_debug_aranges);
}
+
+const DWARFDataExtractor &DWARFContext::getOrLoadDebugInfoData() {
+ if (isDwo())
+ return LoadOrGetSection(m_dwo_section_list, eSectionTypeDWARFDebugInfoDwo,
+ m_data_debug_info);
+ return LoadOrGetSection(m_main_section_list, eSectionTypeDWARFDebugInfo,
+ m_data_debug_info);
+}
Modified: lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFContext.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFContext.h?rev=361000&r1=360999&r2=361000&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFContext.h (original)
+++ lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFContext.h Fri May 17 01:26:58 2019
@@ -10,20 +10,29 @@
#define LLDB_PLUGINS_SYMBOLFILE_DWARF_DWARFCONTEXT_H
#include "DWARFDataExtractor.h"
-#include "lldb/Core/Module.h"
+#include "lldb/Core/Section.h"
#include "llvm/ADT/Optional.h"
#include <memory>
namespace lldb_private {
class DWARFContext {
private:
- Module &m_module;
+ SectionList *m_main_section_list;
+ SectionList *m_dwo_section_list;
+
llvm::Optional<DWARFDataExtractor> m_data_debug_aranges;
+ llvm::Optional<DWARFDataExtractor> m_data_debug_info;
+
+ bool isDwo() { return m_dwo_section_list != nullptr; }
public:
- explicit DWARFContext(Module &module);
+ explicit DWARFContext(SectionList *main_section_list,
+ SectionList *dwo_section_list)
+ : m_main_section_list(main_section_list),
+ m_dwo_section_list(dwo_section_list) {}
const DWARFDataExtractor &getOrLoadArangesData();
+ const DWARFDataExtractor &getOrLoadDebugInfoData();
};
} // namespace lldb_private
Modified: lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFDebugInfo.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFDebugInfo.cpp?rev=361000&r1=360999&r2=361000&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFDebugInfo.cpp (original)
+++ lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFDebugInfo.cpp Fri May 17 01:26:58 2019
@@ -80,7 +80,7 @@ void DWARFDebugInfo::ParseUnitHeadersIfN
return;
lldb::offset_t offset = 0;
- const auto &debug_info_data = m_dwarf2Data->get_debug_info_data();
+ const auto &debug_info_data = m_context.getOrLoadDebugInfoData();
while (debug_info_data.ValidOffset(offset)) {
llvm::Expected<DWARFUnitSP> cu_sp = DWARFCompileUnit::extract(
Modified: lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFFormValue.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFFormValue.cpp?rev=361000&r1=360999&r2=361000&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFFormValue.cpp (original)
+++ lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFFormValue.cpp Fri May 17 01:26:58 2019
@@ -8,7 +8,9 @@
#include <assert.h>
+#include "lldb/Core/Module.h"
#include "lldb/Core/dwarf.h"
+#include "lldb/Symbol/ObjectFile.h"
#include "lldb/Utility/Stream.h"
#include "DWARFDebugInfo.h"
Modified: lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp?rev=361000&r1=360999&r2=361000&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp (original)
+++ lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp Fri May 17 01:26:58 2019
@@ -200,7 +200,8 @@ const char *SymbolFileDWARF::GetPluginDe
}
SymbolFile *SymbolFileDWARF::CreateInstance(ObjectFile *obj_file) {
- return new SymbolFileDWARF(obj_file);
+ return new SymbolFileDWARF(obj_file,
+ /*dwo_section_list*/ nullptr);
}
TypeList *SymbolFileDWARF::GetTypeList() {
@@ -348,18 +349,19 @@ SymbolFileDWARF::GetParentSymbolContextD
return DWARFDIE();
}
-SymbolFileDWARF::SymbolFileDWARF(ObjectFile *objfile)
+SymbolFileDWARF::SymbolFileDWARF(ObjectFile *objfile,
+ SectionList *dwo_section_list)
: SymbolFile(objfile),
UserID(0x7fffffff00000000), // Used by SymbolFileDWARFDebugMap to
// when this class parses .o files to
// contain the .o file index/ID
m_debug_map_module_wp(), m_debug_map_symfile(NULL),
- m_context(*objfile->GetModule()), m_data_debug_abbrev(),
- m_data_debug_frame(), m_data_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(), m_abbr(), m_info(),
- m_line(), m_fetched_external_modules(false),
+ m_context(objfile->GetModule()->GetSectionList(), dwo_section_list),
+ m_data_debug_abbrev(), m_data_debug_frame(), m_data_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(),
+ m_abbr(), m_info(), m_line(), m_fetched_external_modules(false),
m_supports_DW_AT_APPLE_objc_complete_type(eLazyBoolCalculate), m_ranges(),
m_unique_ast_type_map() {}
@@ -563,10 +565,6 @@ const DWARFDataExtractor &SymbolFileDWAR
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_debug_line_data() {
return GetCachedSectionData(eSectionTypeDWARFDebugLine, m_data_debug_line);
}
@@ -670,7 +668,7 @@ DWARFDebugInfo *SymbolFileDWARF::DebugIn
static Timer::Category func_cat(LLVM_PRETTY_FUNCTION);
Timer scoped_timer(func_cat, "%s this = %p", LLVM_PRETTY_FUNCTION,
static_cast<void *>(this));
- if (get_debug_info_data().GetByteSize() > 0) {
+ if (m_context.getOrLoadDebugInfoData().GetByteSize() > 0) {
m_info = llvm::make_unique<DWARFDebugInfo>(m_context);
m_info->SetDwarfData(this);
}
Modified: lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h?rev=361000&r1=360999&r2=361000&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h (original)
+++ lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h Fri May 17 01:26:58 2019
@@ -84,7 +84,8 @@ public:
// Constructors and Destructors
- SymbolFileDWARF(lldb_private::ObjectFile *ofile);
+ SymbolFileDWARF(lldb_private::ObjectFile *ofile,
+ lldb_private::SectionList *dwo_section_list);
~SymbolFileDWARF() override;
@@ -214,7 +215,6 @@ public:
virtual const lldb_private::DWARFDataExtractor &get_debug_abbrev_data();
virtual const lldb_private::DWARFDataExtractor &get_debug_addr_data();
const lldb_private::DWARFDataExtractor &get_debug_frame_data();
- virtual const lldb_private::DWARFDataExtractor &get_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();
@@ -315,6 +315,8 @@ public:
void DumpClangAST(lldb_private::Stream &s) override;
+ lldb_private::DWARFContext &GetDWARFContext() { return m_context; }
+
protected:
typedef llvm::DenseMap<const DWARFDebugInfoEntry *, lldb_private::Type *>
DIEToTypePtr;
Modified: lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDwo.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDwo.cpp?rev=361000&r1=360999&r2=361000&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDwo.cpp (original)
+++ lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDwo.cpp Fri May 17 01:26:58 2019
@@ -21,8 +21,9 @@ using namespace lldb_private;
SymbolFileDWARFDwo::SymbolFileDWARFDwo(ObjectFileSP objfile,
DWARFUnit *dwarf_cu)
- : SymbolFileDWARF(objfile.get()), m_obj_file_sp(objfile),
- m_base_dwarf_cu(dwarf_cu) {
+ : SymbolFileDWARF(objfile.get(), objfile->GetSectionList(
+ /*update_module_section_list*/ false)),
+ m_obj_file_sp(objfile), m_base_dwarf_cu(dwarf_cu) {
SetID(((lldb::user_id_t)dwarf_cu->GetID()) << 32);
}
@@ -129,10 +130,6 @@ const DWARFDataExtractor &SymbolFileDWAR
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_debug_str_data() {
return GetCachedSectionData(eSectionTypeDWARFDebugStrDwo, m_data_debug_str);
}
Modified: lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDwo.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDwo.h?rev=361000&r1=360999&r2=361000&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDwo.h (original)
+++ lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDwo.h Fri May 17 01:26:58 2019
@@ -47,7 +47,6 @@ public:
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_debug_str_data() override;
const lldb_private::DWARFDataExtractor &get_debug_str_offsets_data() override;
More information about the lldb-commits
mailing list