llvm.org GIT mirror llvm / e0d2d7f
[llvm-symbolizer] Print file/line for a PC even if there is no DIE describing it. This is important for symbolizing executables with debug info in unavailable .dwo files. Even if all DIE entries are missing, we can still symbolize an address: function name can be fetched from symbol table, and file/line info can be fetched from line table. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@206665 91177308-0d34-0410-b5e6-96231b3b80d8 Alexey Samsonov 6 years ago
4 changed file(s) with 44 addition(s) and 11 deletion(s). Raw diff Collapse all Expand all
544544
545545 DIInliningInfo DWARFContext::getInliningInfoForAddress(uint64_t Address,
546546 DILineInfoSpecifier Specifier) {
547 DIInliningInfo InliningInfo;
548
547549 DWARFCompileUnit *CU = getCompileUnitForAddress(Address);
548550 if (!CU)
549 return DIInliningInfo();
550
551 return InliningInfo;
552
553 const DWARFLineTable *LineTable = nullptr;
554 const bool NeedsAbsoluteFilePath =
555 Specifier.needs(DILineInfoSpecifier::AbsoluteFilePath);
551556 const DWARFDebugInfoEntryInlinedChain &InlinedChain =
552557 CU->getInlinedChainForAddress(Address);
553 if (InlinedChain.DIEs.size() == 0)
554 return DIInliningInfo();
555
556 DIInliningInfo InliningInfo;
558 if (InlinedChain.DIEs.size() == 0) {
559 // If there is no DIE for address (e.g. it is in unavailable .dwo file),
560 // try to at least get file/line info from symbol table.
561 if (Specifier.needs(DILineInfoSpecifier::FileLineInfo)) {
562 DILineInfo Frame;
563 LineTable = getLineTableForCompileUnit(CU);
564 if (getFileLineInfoForCompileUnit(CU, LineTable, Address,
565 NeedsAbsoluteFilePath, Frame)) {
566 InliningInfo.addFrame(Frame);
567 }
568 }
569 return InliningInfo;
570 }
571
557572 uint32_t CallFile = 0, CallLine = 0, CallColumn = 0;
558 const DWARFLineTable *LineTable = nullptr;
559573 for (uint32_t i = 0, n = InlinedChain.DIEs.size(); i != n; i++) {
560574 const DWARFDebugInfoEntryMinimal &FunctionDIE = InlinedChain.DIEs[i];
561575 DILineInfo Frame;
565579 Frame.FunctionName = Name;
566580 }
567581 if (Specifier.needs(DILineInfoSpecifier::FileLineInfo)) {
568 const bool NeedsAbsoluteFilePath =
569 Specifier.needs(DILineInfoSpecifier::AbsoluteFilePath);
570582 if (i == 0) {
571583 // For the topmost frame, initialize the line table of this
572584 // compile unit and fetch file/line info from it.
573585 LineTable = getLineTableForCompileUnit(CU);
574586 // For the topmost routine, get file/line info from line table.
575587 getFileLineInfoForCompileUnit(CU, LineTable, Address,
576 NeedsAbsoluteFilePath,
577 Frame);
588 NeedsAbsoluteFilePath, Frame);
578589 } else {
579590 // Otherwise, use call file, call line and call column from
580591 // previous DIE in inlined chain.
0 int f(int a, int b) {
1 return a + b;
2 }
3
4 int g(int a) {
5 return a + 1;
6 }
7
8
9 int main() {
10 return f(2, g(2));
11 }
12
13 // Built with Clang 3.5.0:
14 // $ mkdir -p /tmp/dbginfo
15 // $ cp llvm-symbolizer-dwo-test.cc /tmp/dbginfo
16 // $ cd /tmp/dbginfo
17 // $ clang -gsplit-dwarf llvm-symbolizer-dwo-test.cc
77 RUN: echo "%p/Inputs/macho-universal 0x1f84" >> %t.input
88 RUN: echo "%p/Inputs/macho-universal:i386 0x1f67" >> %t.input
99 RUN: echo "%p/Inputs/macho-universal:x86_64 0x100000f05" >> %t.input
10 RUN: echo "%p/Inputs/llvm-symbolizer-dwo-test 0x400514" >> %t.input
1011
1112 RUN: llvm-symbolizer --functions --inlining --demangle=false \
1213 RUN: --default-arch=i386 < %t.input | FileCheck %s
4748 CHECK: _Z3inci
4849 CHECK: _Z3inci
4950
51 CHECK: main
52 CHECK-NEXT: llvm-symbolizer-dwo-test.cc:11
53
5054 RUN: echo "unexisting-file 0x1234" > %t.input2
5155 RUN: llvm-symbolizer < %t.input2
5256