diff options
Diffstat (limited to 'tools/llvm-dwarfdump')
-rw-r--r-- | tools/llvm-dwarfdump/llvm-dwarfdump.cpp | 47 |
1 files changed, 37 insertions, 10 deletions
diff --git a/tools/llvm-dwarfdump/llvm-dwarfdump.cpp b/tools/llvm-dwarfdump/llvm-dwarfdump.cpp index ec0b4ae..38c3a1e 100644 --- a/tools/llvm-dwarfdump/llvm-dwarfdump.cpp +++ b/tools/llvm-dwarfdump/llvm-dwarfdump.cpp @@ -44,6 +44,18 @@ PrintFunctions("functions", cl::init(false), cl::desc("Print function names as well as line information " "for a given address")); +static cl::opt<bool> +PrintInlining("inlining", cl::init(false), + cl::desc("Print all inlined frames for a given address")); + +static void PrintDILineInfo(DILineInfo dli) { + if (PrintFunctions) + outs() << (dli.getFunctionName() ? dli.getFunctionName() : "<unknown>") + << "\n"; + outs() << (dli.getFileName() ? dli.getFileName() : "<unknown>") << ':' + << dli.getLine() << ':' << dli.getColumn() << '\n'; +} + static void DumpInput(const StringRef &Filename) { OwningPtr<MemoryBuffer> Buff; @@ -59,6 +71,7 @@ static void DumpInput(const StringRef &Filename) { StringRef DebugLineSection; StringRef DebugArangesSection; StringRef DebugStringSection; + StringRef DebugRangesSection; error_code ec; for (section_iterator i = Obj->begin_sections(), @@ -82,6 +95,8 @@ static void DumpInput(const StringRef &Filename) { DebugArangesSection = data; else if (name == "debug_str") DebugStringSection = data; + else if (name == "debug_ranges") + DebugRangesSection = data; } OwningPtr<DIContext> dictx(DIContext::getDWARFContext(/*FIXME*/true, @@ -89,7 +104,8 @@ static void DumpInput(const StringRef &Filename) { DebugAbbrevSection, DebugArangesSection, DebugLineSection, - DebugStringSection)); + DebugStringSection, + DebugRangesSection)); if (Address == -1ULL) { outs() << Filename << ":\tfile format " << Obj->getFileFormatName() << "\n\n"; @@ -97,16 +113,27 @@ static void DumpInput(const StringRef &Filename) { dictx->dump(outs()); } else { // Print line info for the specified address. - int spec_flags = DILineInfoSpecifier::FileLineInfo | - DILineInfoSpecifier::AbsoluteFilePath; - if (PrintFunctions) - spec_flags |= DILineInfoSpecifier::FunctionName; - DILineInfo dli = dictx->getLineInfoForAddress(Address, spec_flags); + int SpecFlags = DILineInfoSpecifier::FileLineInfo | + DILineInfoSpecifier::AbsoluteFilePath; if (PrintFunctions) - outs() << (dli.getFunctionName() ? dli.getFunctionName() : "<unknown>") - << "\n"; - outs() << (dli.getFileName() ? dli.getFileName() : "<unknown>") << ':' - << dli.getLine() << ':' << dli.getColumn() << '\n'; + SpecFlags |= DILineInfoSpecifier::FunctionName; + if (PrintInlining) { + DIInliningInfo InliningInfo = dictx->getInliningInfoForAddress( + Address, SpecFlags); + uint32_t n = InliningInfo.getNumberOfFrames(); + if (n == 0) { + // Print one empty debug line info in any case. + PrintDILineInfo(DILineInfo()); + } else { + for (uint32_t i = 0; i < n; i++) { + DILineInfo dli = InliningInfo.getFrame(i); + PrintDILineInfo(dli); + } + } + } else { + DILineInfo dli = dictx->getLineInfoForAddress(Address, SpecFlags); + PrintDILineInfo(dli); + } } } |