summaryrefslogtreecommitdiffstats
path: root/llvm/tools/llvm-dwarfdump/llvm-dwarfdump.cpp
diff options
context:
space:
mode:
authorPavel Labath <labath@google.com>2018-02-24 00:35:21 +0000
committerPavel Labath <labath@google.com>2018-02-24 00:35:21 +0000
commitd99072bc9749874a7885740959e35ac08d99e324 (patch)
treef89ad4876b7b009ca75439a04cd3a3dd3a44afc3 /llvm/tools/llvm-dwarfdump/llvm-dwarfdump.cpp
parentd4e2dabbbb4cf31d4cebb26bf6fefe4b0249bec9 (diff)
downloadbcm5719-llvm-d99072bc9749874a7885740959e35ac08d99e324.tar.gz
bcm5719-llvm-d99072bc9749874a7885740959e35ac08d99e324.zip
Implement equal_range for the DWARF v5 accelerator table
Summary: This patch implements the name lookup functionality of the .debug_names accelerator table and hooks it up to "llvm-dwarfdump -find". To make the interface of the two kinds of accelerator tables more consistent, I've created an abstract "DWARFAcceleratorTable::Entry" class, which provides a consistent interface to access the common functionality of the table entries (such as getting the die offset, die tag, etc.). I've also modified the apple table to vend entries conforming to this interface. Reviewers: JDevlieghere, aprantl, probinson, dblaikie Subscribers: vleschuk, clayborg, echristo, llvm-commits Differential Revision: https://reviews.llvm.org/D43067 llvm-svn: 326003
Diffstat (limited to 'llvm/tools/llvm-dwarfdump/llvm-dwarfdump.cpp')
-rw-r--r--llvm/tools/llvm-dwarfdump/llvm-dwarfdump.cpp26
1 files changed, 14 insertions, 12 deletions
diff --git a/llvm/tools/llvm-dwarfdump/llvm-dwarfdump.cpp b/llvm/tools/llvm-dwarfdump/llvm-dwarfdump.cpp
index f2a837d4cf2..b110480a2c8 100644
--- a/llvm/tools/llvm-dwarfdump/llvm-dwarfdump.cpp
+++ b/llvm/tools/llvm-dwarfdump/llvm-dwarfdump.cpp
@@ -336,6 +336,15 @@ static bool lookup(DWARFContext &DICtx, uint64_t Address, raw_ostream &OS) {
bool collectStatsForObjectFile(ObjectFile &Obj, DWARFContext &DICtx,
Twine Filename, raw_ostream &OS);
+template <typename AccelTable>
+static Optional<uint64_t> getDIEOffset(const AccelTable &Accel,
+ StringRef Name) {
+ for (const auto &Entry : Accel.equal_range(Name))
+ if (Optional<uint64_t> Off = Entry.getDIEOffset())
+ return *Off;
+ return None;
+}
+
static bool dumpObjectFile(ObjectFile &Obj, DWARFContext &DICtx, Twine Filename,
raw_ostream &OS) {
logAllUnhandledErrors(DICtx.loadRegisterInfo(Obj), errs(),
@@ -363,21 +372,14 @@ static bool dumpObjectFile(ObjectFile &Obj, DWARFContext &DICtx, Twine Filename,
if (!Find.empty()) {
DumpOffsets[DIDT_ID_DebugInfo] = [&]() -> llvm::Optional<uint64_t> {
for (auto Name : Find) {
- auto find = [&](const AppleAcceleratorTable &Accel)
- -> llvm::Optional<uint64_t> {
- for (auto Entry : Accel.equal_range(Name))
- for (auto Atom : Entry)
- if (auto Offset = Atom.getAsSectionOffset())
- return Offset;
- return None;
- };
- if (auto Offset = find(DICtx.getAppleNames()))
+ if (auto Offset = getDIEOffset(DICtx.getAppleNames(), Name))
+ return DumpOffsets[DIDT_ID_DebugInfo] = *Offset;
+ if (auto Offset = getDIEOffset(DICtx.getAppleTypes(), Name))
return DumpOffsets[DIDT_ID_DebugInfo] = *Offset;
- if (auto Offset = find(DICtx.getAppleTypes()))
+ if (auto Offset = getDIEOffset(DICtx.getAppleNamespaces(), Name))
return DumpOffsets[DIDT_ID_DebugInfo] = *Offset;
- if (auto Offset = find(DICtx.getAppleNamespaces()))
+ if (auto Offset = getDIEOffset(DICtx.getDebugNames(), Name))
return DumpOffsets[DIDT_ID_DebugInfo] = *Offset;
- // TODO: Add .debug_names support
}
return None;
}();
OpenPOWER on IntegriCloud