diff options
author | Alexey Samsonov <samsonov@google.com> | 2012-07-02 05:54:45 +0000 |
---|---|---|
committer | Alexey Samsonov <samsonov@google.com> | 2012-07-02 05:54:45 +0000 |
commit | 3e25c4a1e3e58bc1d00d894854a29dd2e4e7e88a (patch) | |
tree | 742a54896b5de0397c3d8cbf4809e0e225ea016e /tools | |
parent | 9c3d5a70f40f9e7bb90f3cb8ec1d87cff6e3f0ae (diff) | |
download | external_llvm-3e25c4a1e3e58bc1d00d894854a29dd2e4e7e88a.zip external_llvm-3e25c4a1e3e58bc1d00d894854a29dd2e4e7e88a.tar.gz external_llvm-3e25c4a1e3e58bc1d00d894854a29dd2e4e7e88a.tar.bz2 |
This patch extends the libLLVMDebugInfo which contains a minimalistic DWARF parser:
1) DIContext is now able to return function name for a given instruction address (besides file/line info).
2) llvm-dwarfdump accepts flag --functions that prints the function name (if address is specified by --address flag).
3) test case that checks the basic functionality of llvm-dwarfdump added
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@159512 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'tools')
-rw-r--r-- | tools/llvm-dwarfdump/llvm-dwarfdump.cpp | 13 |
1 files changed, 12 insertions, 1 deletions
diff --git a/tools/llvm-dwarfdump/llvm-dwarfdump.cpp b/tools/llvm-dwarfdump/llvm-dwarfdump.cpp index ca0493d..b6536fa 100644 --- a/tools/llvm-dwarfdump/llvm-dwarfdump.cpp +++ b/tools/llvm-dwarfdump/llvm-dwarfdump.cpp @@ -39,6 +39,11 @@ static cl::opt<unsigned long long> Address("address", cl::init(-1ULL), cl::desc("Print line information for a given address")); +static cl::opt<bool> +PrintFunctions("functions", cl::init(false), + cl::desc("Print function names as well as line information " + "for a given address")); + static void DumpInput(const StringRef &Filename) { OwningPtr<MemoryBuffer> Buff; @@ -92,7 +97,13 @@ static void DumpInput(const StringRef &Filename) { dictx->dump(outs()); } else { // Print line info for the specified address. - DILineInfo dli = dictx->getLineInfoForAddress(Address); + int spec_flags = DILineInfoSpecifier::FileLineInfo; + if (PrintFunctions) + spec_flags |= DILineInfoSpecifier::FunctionName; + DILineInfo dli = dictx->getLineInfoForAddress(Address, spec_flags); + if (PrintFunctions) + outs() << (dli.getFunctionName() ? dli.getFunctionName() : "<unknown>") + << "\n"; outs() << (dli.getFileName() ? dli.getFileName() : "<unknown>") << ':' << dli.getLine() << ':' << dli.getColumn() << '\n'; } |