Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
LLVM's DWARF parsing library has a class called DWARFContext which holds all of the various DWARF data sections and lots of other information. LLDB's on the other hand stores all of this directly in SymbolFileDWARF / SymbolFileDWARFDwo and passes this interface around through the parsing library. Obviously this is incompatible with a world where the low level interface does not depend on the high level interface, so we need to move towards a model similar to LLVM's - i.e. all of the context needed for low level parsing should be in a single class, and that class gets passed around. This patch is a small incremental step towards achieving this. The interface and internals deviate from LLVM's for technical reasons, but the high level idea is the same. The goal is, eventually, to remove all occurrences of SymbolFileDWARF from the low level parsing code. For now I've chosen a very simple section - the .debug_aranges section to move into DWARFContext while leaving everything else unchanged. In the short term this is a bit confusing because now the information you need might come from either of 2 different locations. But it's a huge refactor to do this all at once and runs a much higher risk of breaking things. So I think it would be wise to do this in very small pieces. TL;DR - No functional change Differential Revision: https://reviews.llvm.org/D59562 llvm-svn: 356612
- Loading branch information
Zachary Turner
committed
Mar 20, 2019
1 parent
2065206
commit 6e66512
Showing
8 changed files
with
108 additions
and
54 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
//===-- DWARFContext.cpp ----------------------------------------*- C++ -*-===// | ||
// | ||
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | ||
// See https://llvm.org/LICENSE.txt for license information. | ||
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | ||
// | ||
//===----------------------------------------------------------------------===// | ||
|
||
#include "DWARFContext.h" | ||
|
||
#include "lldb/Core/Section.h" | ||
|
||
using namespace lldb; | ||
using namespace lldb_private; | ||
|
||
static const DWARFDataExtractor * | ||
LoadOrGetSection(Module &module, SectionType section_type, | ||
llvm::Optional<DWARFDataExtractor> &extractor) { | ||
if (extractor.hasValue()) | ||
return extractor->GetByteSize() > 0 ? extractor.getPointer() : nullptr; | ||
|
||
// Initialize to an empty extractor so that we always take the fast path going | ||
// forward. | ||
extractor.emplace(); | ||
|
||
const SectionList *section_list = module.GetSectionList(); | ||
if (!section_list) | ||
return nullptr; | ||
|
||
auto section_sp = section_list->FindSectionByType(section_type, true); | ||
if (!section_sp) | ||
return nullptr; | ||
|
||
section_sp->GetSectionData(*extractor); | ||
return extractor.getPointer(); | ||
} | ||
|
||
DWARFContext::DWARFContext(Module &module) : m_module(module) {} | ||
|
||
const DWARFDataExtractor *DWARFContext::getOrLoadArangesData() { | ||
return LoadOrGetSection(m_module, eSectionTypeDWARFDebugAranges, | ||
m_data_debug_aranges); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
//===-- DWARFContext.h ------------------------------------------*- C++ -*-===// | ||
// | ||
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | ||
// See https://llvm.org/LICENSE.txt for license information. | ||
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | ||
// | ||
//===----------------------------------------------------------------------===// | ||
|
||
#ifndef LLDB_PLUGINS_SYMBOLFILE_DWARF_DWARFCONTEXT_H | ||
#define LLDB_PLUGINS_SYMBOLFILE_DWARF_DWARFCONTEXT_H | ||
|
||
#include "DWARFDataExtractor.h" | ||
#include "lldb/Core/Module.h" | ||
#include "llvm/ADT/Optional.h" | ||
#include <memory> | ||
|
||
namespace lldb_private { | ||
class DWARFContext { | ||
private: | ||
Module &m_module; | ||
llvm::Optional<DWARFDataExtractor> m_data_debug_aranges; | ||
|
||
public: | ||
explicit DWARFContext(Module &module); | ||
|
||
const DWARFDataExtractor *getOrLoadArangesData(); | ||
}; | ||
} // namespace lldb_private | ||
|
||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters