diff options
author | Benjamin Kramer <benny.kra@googlemail.com> | 2011-09-15 21:17:40 +0000 |
---|---|---|
committer | Benjamin Kramer <benny.kra@googlemail.com> | 2011-09-15 21:17:40 +0000 |
commit | 4d9924f950e8e5123e1ea9842b053e771d9aa432 (patch) | |
tree | 4a9c648e08cdf1a453e6144aada9efed95143d19 /llvm/tools/llvm-dwarfdump/llvm-dwarfdump.cpp | |
parent | d2868cf0167ded87444dae4189fb3533cd6075d7 (diff) | |
download | bcm5719-llvm-4d9924f950e8e5123e1ea9842b053e771d9aa432.tar.gz bcm5719-llvm-4d9924f950e8e5123e1ea9842b053e771d9aa432.zip |
llvm-dwarfdump: Add an option to print out line info for a specific address
Usage:
$ llvm-dwarfdump -address=0x0000000100000ed4 a.out.dSYM/Contents/Resources/DWARF/a.out
xxx.c:6:0
llvm-svn: 139850
Diffstat (limited to 'llvm/tools/llvm-dwarfdump/llvm-dwarfdump.cpp')
-rw-r--r-- | llvm/tools/llvm-dwarfdump/llvm-dwarfdump.cpp | 20 |
1 files changed, 15 insertions, 5 deletions
diff --git a/llvm/tools/llvm-dwarfdump/llvm-dwarfdump.cpp b/llvm/tools/llvm-dwarfdump/llvm-dwarfdump.cpp index 9618a1a4bba..66d5a72ea44 100644 --- a/llvm/tools/llvm-dwarfdump/llvm-dwarfdump.cpp +++ b/llvm/tools/llvm-dwarfdump/llvm-dwarfdump.cpp @@ -35,6 +35,10 @@ static cl::list<std::string> InputFilenames(cl::Positional, cl::desc("<input object files>"), cl::ZeroOrMore); +static cl::opt<unsigned long long> +Address("address", cl::init(-1ULL), + cl::desc("Print line information for a given address")); + static void DumpInput(const StringRef &Filename) { OwningPtr<MemoryBuffer> Buff; @@ -45,10 +49,6 @@ static void DumpInput(const StringRef &Filename) { OwningPtr<ObjectFile> Obj(ObjectFile::createObjectFile(Buff.take())); - outs() << '\n'; - outs() << Filename - << ":\tfile format " << Obj->getFileFormatName() << "\n\n"; - StringRef DebugInfoSection; StringRef DebugAbbrevSection; StringRef DebugLineSection; @@ -85,7 +85,17 @@ static void DumpInput(const StringRef &Filename) { DebugArangesSection, DebugLineSection, DebugStringSection)); - dictx->dump(outs()); + if (Address == -1ULL) { + outs() << Filename + << ":\tfile format " << Obj->getFileFormatName() << "\n\n"; + // Dump the complete DWARF structure. + dictx->dump(outs()); + } else { + // Print line info for the specified address. + DILineInfo dli = dictx->getLineInfoForAddress(Address); + outs() << (dli.getFileName() ? dli.getFileName() : "<unknown>") << ':' + << dli.getLine() << ':' << dli.getColumn() << '\n'; + } } int main(int argc, char **argv) { |