llvm.org GIT mirror llvm / 3b1256d
Add GNU_discriminator support for inline callsites in llvm-symbolizer. Summary: LLVM symbolize cannot recognize GNU_discriminator for inline callsites. This patch adds support for it. Reviewers: dblaikie Reviewed By: dblaikie Subscribers: llvm-commits Differential Revision: https://reviews.llvm.org/D32134 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@300486 91177308-0d34-0410-b5e6-96231b3b80d8 Dehao Chen 2 years ago
7 changed file(s) with 103 addition(s) and 33 deletion(s). Raw diff Collapse all Expand all
246246 /// DW_AT_call_line attribute in this DIE.
247247 /// \param CallColumn filled in with non-zero if successful, zero if there is
248248 /// no DW_AT_call_column attribute in this DIE.
249 /// \param CallDiscriminator filled in with non-zero if successful, zero if
250 /// there is no DW_AT_GNU_discriminator attribute in this DIE.
249251 void getCallerFrame(uint32_t &CallFile, uint32_t &CallLine,
250 uint32_t &CallColumn) const;
252 uint32_t &CallColumn, uint32_t &CallDiscriminator) const;
251253
252254 /// Get inlined chain for a given address, rooted at the current DIE.
253255 /// Returns empty chain if address is not contained in address range
578578 return InliningInfo;
579579 }
580580
581 uint32_t CallFile = 0, CallLine = 0, CallColumn = 0;
581 uint32_t CallFile = 0, CallLine = 0, CallColumn = 0, CallDiscriminator = 0;
582582 for (uint32_t i = 0, n = InlinedChain.size(); i != n; i++) {
583583 DWARFDie &FunctionDIE = InlinedChain[i];
584584 DILineInfo Frame;
604604 Spec.FLIKind, Frame.FileName);
605605 Frame.Line = CallLine;
606606 Frame.Column = CallColumn;
607 Frame.Discriminator = CallDiscriminator;
607608 }
608609 // Get call file/line/column of a current DIE.
609610 if (i + 1 < n) {
610 FunctionDIE.getCallerFrame(CallFile, CallLine, CallColumn);
611 FunctionDIE.getCallerFrame(CallFile, CallLine, CallColumn,
612 CallDiscriminator);
611613 }
612614 }
613615 InliningInfo.addFrame(Frame);
289289 }
290290
291291 void DWARFDie::getCallerFrame(uint32_t &CallFile, uint32_t &CallLine,
292 uint32_t &CallColumn) const {
292 uint32_t &CallColumn,
293 uint32_t &CallDiscriminator) const {
293294 CallFile = toUnsigned(find(DW_AT_call_file), 0);
294295 CallLine = toUnsigned(find(DW_AT_call_line), 0);
295296 CallColumn = toUnsigned(find(DW_AT_call_column), 0);
297 CallDiscriminator = toUnsigned(find(DW_AT_GNU_discriminator), 0);
296298 }
297299
298300 void DWARFDie::dump(raw_ostream &OS, unsigned RecurseDepth,
0 static volatile int do_mul;
1 static volatile int do_inc;
1 static volatile int x, v;
22
3 int main () {
4 int x = 1;
5 if (do_mul) x *= 2; else x /= 2;
6 return do_inc ? ++x : --x;
3 int foo () {
4 if (do_mul) x *= v; else x /= v;
5 return x;
76 }
7
8 int main() {
9 return foo() + foo();
10 }
0 some text
1 0x4004f2
2 0x400509
3 0x40050d
1 0x400590
2 0x4005a5
3 0x4005ad
4 0x4005b9
5 0x4005ce
6 0x4005d4
47 some more text
0 #static volatile int do_mul;
1 #static volatile int do_inc;
1 #static volatile int x, v;
22 #
3 #int main () {
4 # int x = 1;
5 # if (do_mul) x *= 2; else x /= 2;
6 # return do_inc ? ++x : --x;
3 #int foo () {
4 # if (do_mul) x *= v; else x /= v;
5 # return x;
76 #}
8 #Build as : clang -g -O2 discrim.c -o discrim
7 #
8 #int main() {
9 # return foo() + foo();
10 #}
11 #Build as : clang -gmlt -fdebug-info-for-profiling -O2 discrim.c -o discrim
912
1013 RUN: llvm-symbolizer -verbose -print-address -obj=%p/Inputs/discrim < %p/Inputs/discrim.inp | FileCheck %s
1114
1215 #CHECK: some text
1316
14 #CHECK: 0x4004f2
17 #CHECK: 0x400590
18 #CHECK-NEXT: foo
19 #CHECK-NEXT: Filename: /tmp/discrim.c
20 #CHECK-NEXT: Function start line: 4
21 #CHECK-NEXT: Line: 9
22 #CHECK-NEXT: Column: 0
1523 #CHECK-NEXT: main
16 #CHECK-NEXT: Filename: /tmp{{[\\/]}}discrim.c
24 #CHECK-NEXT: Filename: /tmp/discrim.c
25 #CHECK-NEXT: Function start line: 9
26 #CHECK-NEXT: Line: 10
27 #CHECK-NEXT: Column: 0
28
29 #CHECK: 0x4005a5
30 #CHECK-NEXT: foo
31 #CHECK-NEXT: Filename: /tmp/discrim.c
1732 #CHECK-NEXT: Function start line: 4
18 #CHECK-NEXT: Line: 6
33 #CHECK-NEXT: Line: 5
34 #CHECK-NEXT: Column: 17
35 #CHECK-NEXT: Discriminator: 2
36 #CHECK-NEXT: main
37 #CHECK-NEXT: Filename: /tmp/discrim.c
38 #CHECK-NEXT: Function start line: 9
39 #CHECK-NEXT: Line: 10
40 #CHECK-NEXT: Column: 0
41
42 #CHECK: 0x4005ad
43 #CHECK-NEXT: foo
44 #CHECK-NEXT: Filename: /tmp/discrim.c
45 #CHECK-NEXT: Function start line: 4
46 #CHECK-NEXT: Line: 0
47 #CHECK-NEXT: Column: 30
48 #CHECK-NEXT: Discriminator: 4
49 #CHECK-NEXT: main
50 #CHECK-NEXT: Filename: /tmp/discrim.c
51 #CHECK-NEXT: Function start line: 9
52 #CHECK-NEXT: Line: 10
53 #CHECK-NEXT: Column: 0
54
55 #CHECK: 0x4005b9
56 #CHECK-NEXT: foo
57 #CHECK-NEXT: Filename: /tmp/discrim.c
58 #CHECK-NEXT: Function start line: 4
59 #CHECK-NEXT: Line: 5
1960 #CHECK-NEXT: Column: 7
20 #CHECK-NOT: Discriminator: 0
61 #CHECK-NEXT: main
62 #CHECK-NEXT: Filename: /tmp/discrim.c
63 #CHECK-NEXT: Function start line: 9
64 #CHECK-NEXT: Line: 10
65 #CHECK-NEXT: Column: 0
66 #CHECK-NEXT: Discriminator: 2
2167
22 #CHECK: 0x400509
68 #CHECK: 0x4005ce
69 #CHECK-NEXT: foo
70 #CHECK-NEXT: Filename: /tmp/discrim.c
71 #CHECK-NEXT: Function start line: 4
72 #CHECK-NEXT: Line: 5
73 #CHECK-NEXT: Column: 17
74 #CHECK-NEXT: Discriminator: 2
2375 #CHECK-NEXT: main
24 #CHECK-NEXT: Filename: /tmp{{[\\/]}}discrim.c
76 #CHECK-NEXT: Filename: /tmp/discrim.c
77 #CHECK-NEXT: Function start line: 9
78 #CHECK-NEXT: Line: 10
79 #CHECK-NEXT: Column: 0
80 #CHECK-NEXT: Discriminator: 2
81
82 #CHECK: 0x4005d4
83 #CHECK-NEXT: foo
84 #CHECK-NEXT: Filename: /tmp/discrim.c
2585 #CHECK-NEXT: Function start line: 4
26 #CHECK-NEXT: Line: 7
27 #CHECK-NEXT: Column: 3
28 #CHECK-NEXT: Discriminator: 1
29
30 #CHECK: 0x40050d
86 #CHECK-NEXT: Line: 5
87 #CHECK-NEXT: Column: 30
88 #CHECK-NEXT: Discriminator: 4
3189 #CHECK-NEXT: main
32 #CHECK-NEXT: Filename: /tmp{{[\\/]}}discrim.c
33 #CHECK-NEXT: Function start line: 4
34 #CHECK-NEXT: Line: 7
35 #CHECK-NEXT: Column: 3
90 #CHECK-NEXT: Filename: /tmp/discrim.c
91 #CHECK-NEXT: Function start line: 9
92 #CHECK-NEXT: Line: 10
93 #CHECK-NEXT: Column: 0
3694 #CHECK-NEXT: Discriminator: 2
3795
3896 #CHECK: some more text