Skip to content
This repository was archived by the owner on Mar 28, 2020. It is now read-only.

Commit 4fc8e6f

Browse files
committed
llvm-symbolizer: prefer .dwo contents over fission-gmlt-like-data when .dwo file is present
Rather than relying on the gmlt-like data emitted into the .o/executable which only contains the simple name of any inlined functions, use the .dwo file if present. Test symbolication with/without a .dwo, and the old test that was testing behavior when no gmlt-like data was present. (I haven't included a test of non-gmlt-like data + no .dwo (that would be akin to symbolication with no debug info) but we could add one for completeness) The test was simplified a bit to be a little clearer (unoptimized, force inline, using a function call as the inlined entity) and regenerated with ToT clang. For the no-gmlt-like-data case, I modified Clang back to its old behavior temporarily & the .dwo file is identical so it is shared between the two executables. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@267227 91177308-0d34-0410-b5e6-96231b3b80d8
1 parent 1e4609e commit 4fc8e6f

File tree

6 files changed

+40
-26
lines changed

6 files changed

+40
-26
lines changed

lib/DebugInfo/DWARF/DWARFUnit.cpp

Lines changed: 7 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -378,19 +378,14 @@ DWARFUnit::getInlinedChainForAddress(uint64_t Address) {
378378
// First, find a subprogram that contains the given address (the root
379379
// of inlined chain).
380380
const DWARFUnit *ChainCU = nullptr;
381-
const DWARFDebugInfoEntryMinimal *SubprogramDIE =
382-
getSubprogramForAddress(Address);
383-
if (SubprogramDIE) {
381+
const DWARFDebugInfoEntryMinimal *SubprogramDIE;
382+
// Try to look for subprogram DIEs in the DWO file.
383+
parseDWO();
384+
if (DWO) {
385+
if ((SubprogramDIE = DWO->getUnit()->getSubprogramForAddress(Address)))
386+
ChainCU = DWO->getUnit();
387+
} else if ((SubprogramDIE = getSubprogramForAddress(Address)))
384388
ChainCU = this;
385-
} else {
386-
// Try to look for subprogram DIEs in the DWO file.
387-
parseDWO();
388-
if (DWO.get()) {
389-
SubprogramDIE = DWO->getUnit()->getSubprogramForAddress(Address);
390-
if (SubprogramDIE)
391-
ChainCU = DWO->getUnit();
392-
}
393-
}
394389

395390
// Get inlined chain rooted at this subprogram DIE.
396391
if (!SubprogramDIE)
-171 Bytes
Binary file not shown.
8.91 KB
Binary file not shown.

test/DebugInfo/Inputs/split-dwarf-test.cc

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,16 @@
1-
int foo(int a) {
2-
return a + 1;
1+
void f1() {
32
}
43

5-
int main(int argc, char *argv[]) {
6-
return foo(argc);
4+
inline __attribute__((always_inline)) void f2() {
5+
f1();
6+
}
7+
8+
int main() {
9+
f2();
710
}
811

912
// Build instructions:
10-
// 1) clang++ -### -O2 -gsplit-dwarf.cc split-dwarf-test.cc -o split-dwarf-test
13+
// 1) clang++ -### -gsplit-dwarf split-dwarf-test.cc -o split-dwarf-test
1114
// 2) Replace the value "-fdebug-compilation-dir" flag to "Output"
1215
// (this is the temp directory used by lit).
1316
// 3) Manually run clang-cc1, objcopy and ld invocations.
-232 Bytes
Binary file not shown.

test/DebugInfo/llvm-symbolizer.test

Lines changed: 25 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -20,12 +20,27 @@ RUN: echo "%p/Inputs/llvm-symbolizer-dwo-test 0x400514" >> %t.input
2020
RUN: echo "%p/Inputs/fission-ranges.elf-x86_64 0x720" >> %t.input
2121
RUN: echo "%p/Inputs/arange-overlap.elf-x86_64 0x714" >> %t.input
2222
RUN: cp %p/Inputs/split-dwarf-test.dwo %T
23-
RUN: echo "%p/Inputs/split-dwarf-test 0x4004d0" >> %t.input
24-
RUN: echo "%p/Inputs/split-dwarf-test 0x4004c0" >> %t.input
23+
RUN: echo "%p/Inputs/split-dwarf-test 0x4005d4" >> %t.input
24+
RUN: echo "%p/Inputs/split-dwarf-test 0x4005c4" >> %t.input
2525
RUN: echo "%p/Inputs/cross-cu-inlining.x86_64-macho.o 0x17" >> %t.input
2626

2727
RUN: llvm-symbolizer --functions=linkage --inlining --demangle=false \
28-
RUN: --default-arch=i386 < %t.input | FileCheck %s
28+
RUN: --default-arch=i386 < %t.input | FileCheck --check-prefix=CHECK --check-prefix=SPLIT --check-prefix=DWO %s
29+
30+
Ensure we get the same results in the absence of gmlt-like data in the executable but the presence of a .dwo file
31+
32+
RUN: echo "%p/Inputs/split-dwarf-test-nogmlt 0x4005d4" >> %t.input
33+
RUN: echo "%p/Inputs/split-dwarf-test-nogmlt 0x4005c4" >> %t.input
34+
RUN: llvm-symbolizer --functions=linkage --inlining --demangle=false \
35+
RUN: --default-arch=i386 < %t.input | FileCheck --check-prefix=SPLIT --check-prefix=DWO %s
36+
37+
Ensure we get gmlt like results in the absence of a .dwo file but the presence of gmlt-like data in the executable
38+
39+
RUN: rm %T/split-dwarf-test.dwo
40+
RUN: echo "%p/Inputs/split-dwarf-test 0x4005d4" >> %t.input
41+
RUN: echo "%p/Inputs/split-dwarf-test 0x4005c4" >> %t.input
42+
RUN: llvm-symbolizer --functions=linkage --inlining --demangle=false \
43+
RUN: --default-arch=i386 < %t.input | FileCheck --check-prefix=SPLIT --check-prefix=NODWO %s
2944

3045
CHECK: main
3146
CHECK-NEXT: /tmp/dbginfo{{[/\\]}}dwarfdump-test.cc:16
@@ -102,13 +117,14 @@ CHECK-NEXT: {{.*}}fission-ranges.cc:6
102117
CHECK: _ZN1S3bazEv
103118
CHECK-NEXT: {{.*}}arange-overlap.cc:6
104119

105-
CHECK: _Z3fooi
106-
CHECK-NEXT: {{.*}}split-dwarf-test.cc
107-
CHECK-NEXT: main
108-
CHECK-NEXT: {{.*}}split-dwarf-test.cc
120+
DWO: _Z2f2v
121+
NODWO: {{^f2$}}
122+
SPLIT-NEXT: {{.*}}split-dwarf-test.cc
123+
SPLIT-NEXT: main
124+
SPLIT-NEXT: {{.*}}split-dwarf-test.cc
109125

110-
CHECK: _Z3fooi
111-
CHECK-NEXT: {{.*}}split-dwarf-test.cc
126+
SPLIT: _Z2f1v
127+
SPLIT-NEXT: {{.*}}split-dwarf-test.cc
112128

113129
; func has been inlined into main by LTO. Check that the symbolizer is able
114130
; to resolve the cross-cu reference and retrieve func's name

0 commit comments

Comments
 (0)