[llvm-commits] [llvm] r139850 - /llvm/trunk/tools/llvm-dwarfdump/llvm-dwarfdump.cpp
Benjamin Kramer
benny.kra at googlemail.com
Thu Sep 15 14:17:40 PDT 2011
Author: d0k
Date: Thu Sep 15 16:17:40 2011
New Revision: 139850
URL: http://llvm.org/viewvc/llvm-project?rev=139850&view=rev
Log:
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
Modified:
llvm/trunk/tools/llvm-dwarfdump/llvm-dwarfdump.cpp
Modified: llvm/trunk/tools/llvm-dwarfdump/llvm-dwarfdump.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/llvm-dwarfdump/llvm-dwarfdump.cpp?rev=139850&r1=139849&r2=139850&view=diff
==============================================================================
--- llvm/trunk/tools/llvm-dwarfdump/llvm-dwarfdump.cpp (original)
+++ llvm/trunk/tools/llvm-dwarfdump/llvm-dwarfdump.cpp Thu Sep 15 16:17:40 2011
@@ -35,6 +35,10 @@
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 @@
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 @@
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) {
More information about the llvm-commits
mailing list