summaryrefslogtreecommitdiffstats
path: root/llvm/tools/llvm-dwarfdump/llvm-dwarfdump.cpp
diff options
context:
space:
mode:
authorJonas Devlieghere <jonas@devlieghere.com>2017-10-03 17:10:21 +0000
committerJonas Devlieghere <jonas@devlieghere.com>2017-10-03 17:10:21 +0000
commitf998c501b65d919081d01a9e1ba1f1901fb0eb56 (patch)
treeaee1089b79fa5b19fca1951dcfc83f19c6ee51d2 /llvm/tools/llvm-dwarfdump/llvm-dwarfdump.cpp
parent2ce23ab6f266d8852f3a836a026dd872367762df (diff)
downloadbcm5719-llvm-f998c501b65d919081d01a9e1ba1f1901fb0eb56.tar.gz
bcm5719-llvm-f998c501b65d919081d01a9e1ba1f1901fb0eb56.zip
[dwarfdump] Add -lookup option
Add the option to lookup an address in the debug information and print out the file, function, block and line table details. Differential revision: https://reviews.llvm.org/D38409 llvm-svn: 314817
Diffstat (limited to 'llvm/tools/llvm-dwarfdump/llvm-dwarfdump.cpp')
-rw-r--r--llvm/tools/llvm-dwarfdump/llvm-dwarfdump.cpp41
1 files changed, 36 insertions, 5 deletions
diff --git a/llvm/tools/llvm-dwarfdump/llvm-dwarfdump.cpp b/llvm/tools/llvm-dwarfdump/llvm-dwarfdump.cpp
index 9abc92b7b83..07a940b5005 100644
--- a/llvm/tools/llvm-dwarfdump/llvm-dwarfdump.cpp
+++ b/llvm/tools/llvm-dwarfdump/llvm-dwarfdump.cpp
@@ -155,13 +155,17 @@ static list<std::string>
"attribute) matches the exact text in <name>."),
value_desc("name"), cat(DwarfDumpCategory));
static alias NameAlias("n", desc("Alias for -name"), aliasopt(Name));
+static opt<uint64_t>
+ Lookup("lookup",
+ desc("Lookup <address> in the debug information and print out any"
+ "available file, function, block and line table details."),
+ value_desc("address"), cat(DwarfDumpCategory));
static opt<std::string>
OutputFilename("out-file", cl::init(""),
- cl::desc("Redirect output to the specified file"),
- cl::value_desc("filename"));
+ cl::desc("Redirect output to <filename>"),
+ cl::value_desc("filename"), cat(DwarfDumpCategory));
static alias OutputFilenameAlias("o", desc("Alias for -out-file"),
- aliasopt(OutputFilename),
- cat(DwarfDumpCategory));
+ aliasopt(OutputFilename));
static opt<bool>
ShowChildren("show-children",
desc("Show a debug info entry's children when selectively "
@@ -277,17 +281,44 @@ static void filterByName(const StringSet<> &Names,
Die.dump(OS, 0, getDumpOpts());
}
}
+
+}
+
+/// Handle the --lookup option and dump the DIEs and line info for the given
+/// address.
+static bool lookup(DWARFContext &DICtx, uint64_t Address, raw_ostream &OS) {
+ auto DIEsForAddr = DICtx.getDIEsForAddress(Lookup);
+
+ if (!DIEsForAddr)
+ return false;
+
+ DIDumpOptions DumpOpts = getDumpOpts();
+ DumpOpts.RecurseDepth = 0;
+ DIEsForAddr.CompileUnit->dump(OS, DumpOpts);
+ if (DIEsForAddr.FunctionDIE) {
+ DIEsForAddr.FunctionDIE.dump(OS, 2, DumpOpts);
+ if (DIEsForAddr.BlockDIE)
+ DIEsForAddr.BlockDIE.dump(OS, 4, DumpOpts);
+ }
+
+ if (DILineInfo LineInfo = DICtx.getLineInfoForAddress(Lookup))
+ LineInfo.dump(OS);
+
+ return true;
}
static bool dumpObjectFile(ObjectFile &Obj, DWARFContext &DICtx, Twine Filename,
raw_ostream &OS) {
logAllUnhandledErrors(DICtx.loadRegisterInfo(Obj), errs(),
Filename.str() + ": ");
-
// The UUID dump already contains all the same information.
if (!(DumpType & DIDT_UUID) || DumpType == DIDT_All)
OS << Filename << ":\tfile format " << Obj.getFileFormatName() << '\n';
+ // Handle the --lookup option.
+ if (Lookup)
+ return lookup(DICtx, Lookup, OS);
+
// Handle the --name option.
if (!Name.empty()) {
StringSet<> Names;
OpenPOWER on IntegriCloud