diff options
author | Adrian Prantl <aprantl@apple.com> | 2017-09-28 18:10:52 +0000 |
---|---|---|
committer | Adrian Prantl <aprantl@apple.com> | 2017-09-28 18:10:52 +0000 |
commit | 99fdb9d9270c9df61e29a926787c8aa4317187ba (patch) | |
tree | 03a860b1d8ad7c3f574c66ebead70d9ae18e1e74 /llvm/tools/llvm-dwarfdump/llvm-dwarfdump.cpp | |
parent | 705db63ce1544c6618a95c4fbf28bc9e994c091a (diff) | |
download | bcm5719-llvm-99fdb9d9270c9df61e29a926787c8aa4317187ba.tar.gz bcm5719-llvm-99fdb9d9270c9df61e29a926787c8aa4317187ba.zip |
llvm-dwarfdump: implement --find for .apple_names
This patch implements the dwarfdump option --find=<name>. This option
looks for a DIE in the accelerator tables and dumps it if found. This
initial patch only adds support for .apple_names to keep the review
small, adding the other sections and pubnames support should be
trivial though.
Differential Revision: https://reviews.llvm.org/D38282
llvm-svn: 314439
Diffstat (limited to 'llvm/tools/llvm-dwarfdump/llvm-dwarfdump.cpp')
-rw-r--r-- | llvm/tools/llvm-dwarfdump/llvm-dwarfdump.cpp | 25 |
1 files changed, 24 insertions, 1 deletions
diff --git a/llvm/tools/llvm-dwarfdump/llvm-dwarfdump.cpp b/llvm/tools/llvm-dwarfdump/llvm-dwarfdump.cpp index 317094c68a4..5eea7041712 100644 --- a/llvm/tools/llvm-dwarfdump/llvm-dwarfdump.cpp +++ b/llvm/tools/llvm-dwarfdump/llvm-dwarfdump.cpp @@ -134,6 +134,13 @@ static list<std::string> "name or by number. This option can be specified " "multiple times, once for each desired architecture."), cat(DwarfDumpCategory)); +static list<std::string> + Find("find", + desc("Search for the exact match for <name> in the accelerator tables " + "and print the matching debug information entries."), + value_desc("name"), cat(DwarfDumpCategory)); +static alias FindAlias("f", desc("Alias for -find"), aliasopt(Find)); + static opt<bool> DumpUUID("uuid", desc("Show the UUID for each architecture"), cat(DwarfDumpCategory)); static alias DumpUUIDAlias("u", desc("Alias for -uuid"), aliasopt(DumpUUID)); @@ -164,7 +171,7 @@ static opt<unsigned> RecurseDepth( cat(DwarfDumpCategory), init(-1U), value_desc("N")); static alias RecurseDepthAlias("r", desc("Alias for -recurse-depth"), aliasopt(RecurseDepth)); - + static opt<bool> SummarizeTypes("summarize-types", desc("Abbreviate the description of type unit entries"), @@ -236,6 +243,22 @@ static bool dumpObjectFile(ObjectFile &Obj, DWARFContext &DICtx, Twine Filename, raw_ostream &OS) { logAllUnhandledErrors(DICtx.loadRegisterInfo(Obj), errs(), Filename.str() + ": "); + + // Handle the --find option and lower it to --debug-info=<offset>. + if (!Find.empty()) { + DumpOffsets[DIDT_ID_DebugInfo] = [&]() -> Optional<uint64_t> { + for (auto Name : Find) + for (auto Entry : DICtx.getAppleNames().equal_range(Name)) + for (auto Atom : Entry) + if (auto Offset = Atom.getAsSectionOffset()) + return DumpOffsets[DIDT_ID_DebugInfo] = *Offset; + return None; + }(); + // Early exit if --find was specified but the current file doesn't have it. + if (!DumpOffsets[DIDT_ID_DebugInfo]) + return true; + } + // The UUID dump already contains all the same information. if (!(DumpType & DIDT_UUID) || DumpType == DIDT_All) OS << Filename << ":\tfile format " << Obj.getFileFormatName() << '\n'; |