[llvm] r300486 - Add GNU_discriminator support for inline callsites in llvm-symbolizer.
Dehao Chen via llvm-commits
llvm-commits at lists.llvm.org
Mon Apr 17 13:10:39 PDT 2017
Author: dehao
Date: Mon Apr 17 15:10:39 2017
New Revision: 300486
URL: http://llvm.org/viewvc/llvm-project?rev=300486&view=rev
Log:
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
Modified:
llvm/trunk/include/llvm/DebugInfo/DWARF/DWARFDie.h
llvm/trunk/lib/DebugInfo/DWARF/DWARFContext.cpp
llvm/trunk/lib/DebugInfo/DWARF/DWARFDie.cpp
llvm/trunk/test/tools/llvm-symbolizer/Inputs/discrim
llvm/trunk/test/tools/llvm-symbolizer/Inputs/discrim.c
llvm/trunk/test/tools/llvm-symbolizer/Inputs/discrim.inp
llvm/trunk/test/tools/llvm-symbolizer/sym-verbose.test
Modified: llvm/trunk/include/llvm/DebugInfo/DWARF/DWARFDie.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/DebugInfo/DWARF/DWARFDie.h?rev=300486&r1=300485&r2=300486&view=diff
==============================================================================
--- llvm/trunk/include/llvm/DebugInfo/DWARF/DWARFDie.h (original)
+++ llvm/trunk/include/llvm/DebugInfo/DWARF/DWARFDie.h Mon Apr 17 15:10:39 2017
@@ -247,8 +247,10 @@ public:
/// DW_AT_call_line attribute in this DIE.
/// \param CallColumn filled in with non-zero if successful, zero if there is
/// no DW_AT_call_column attribute in this DIE.
+ /// \param CallDiscriminator filled in with non-zero if successful, zero if
+ /// there is no DW_AT_GNU_discriminator attribute in this DIE.
void getCallerFrame(uint32_t &CallFile, uint32_t &CallLine,
- uint32_t &CallColumn) const;
+ uint32_t &CallColumn, uint32_t &CallDiscriminator) const;
/// Get inlined chain for a given address, rooted at the current DIE.
/// Returns empty chain if address is not contained in address range
Modified: llvm/trunk/lib/DebugInfo/DWARF/DWARFContext.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/DebugInfo/DWARF/DWARFContext.cpp?rev=300486&r1=300485&r2=300486&view=diff
==============================================================================
--- llvm/trunk/lib/DebugInfo/DWARF/DWARFContext.cpp (original)
+++ llvm/trunk/lib/DebugInfo/DWARF/DWARFContext.cpp Mon Apr 17 15:10:39 2017
@@ -579,7 +579,7 @@ DWARFContext::getInliningInfoForAddress(
return InliningInfo;
}
- uint32_t CallFile = 0, CallLine = 0, CallColumn = 0;
+ uint32_t CallFile = 0, CallLine = 0, CallColumn = 0, CallDiscriminator = 0;
for (uint32_t i = 0, n = InlinedChain.size(); i != n; i++) {
DWARFDie &FunctionDIE = InlinedChain[i];
DILineInfo Frame;
@@ -605,10 +605,12 @@ DWARFContext::getInliningInfoForAddress(
Spec.FLIKind, Frame.FileName);
Frame.Line = CallLine;
Frame.Column = CallColumn;
+ Frame.Discriminator = CallDiscriminator;
}
// Get call file/line/column of a current DIE.
if (i + 1 < n) {
- FunctionDIE.getCallerFrame(CallFile, CallLine, CallColumn);
+ FunctionDIE.getCallerFrame(CallFile, CallLine, CallColumn,
+ CallDiscriminator);
}
}
InliningInfo.addFrame(Frame);
Modified: llvm/trunk/lib/DebugInfo/DWARF/DWARFDie.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/DebugInfo/DWARF/DWARFDie.cpp?rev=300486&r1=300485&r2=300486&view=diff
==============================================================================
--- llvm/trunk/lib/DebugInfo/DWARF/DWARFDie.cpp (original)
+++ llvm/trunk/lib/DebugInfo/DWARF/DWARFDie.cpp Mon Apr 17 15:10:39 2017
@@ -290,10 +290,12 @@ uint64_t DWARFDie::getDeclLine() const {
}
void DWARFDie::getCallerFrame(uint32_t &CallFile, uint32_t &CallLine,
- uint32_t &CallColumn) const {
+ uint32_t &CallColumn,
+ uint32_t &CallDiscriminator) const {
CallFile = toUnsigned(find(DW_AT_call_file), 0);
CallLine = toUnsigned(find(DW_AT_call_line), 0);
CallColumn = toUnsigned(find(DW_AT_call_column), 0);
+ CallDiscriminator = toUnsigned(find(DW_AT_GNU_discriminator), 0);
}
void DWARFDie::dump(raw_ostream &OS, unsigned RecurseDepth,
Modified: llvm/trunk/test/tools/llvm-symbolizer/Inputs/discrim
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/tools/llvm-symbolizer/Inputs/discrim?rev=300486&r1=300485&r2=300486&view=diff
==============================================================================
Binary files llvm/trunk/test/tools/llvm-symbolizer/Inputs/discrim (original) and llvm/trunk/test/tools/llvm-symbolizer/Inputs/discrim Mon Apr 17 15:10:39 2017 differ
Modified: llvm/trunk/test/tools/llvm-symbolizer/Inputs/discrim.c
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/tools/llvm-symbolizer/Inputs/discrim.c?rev=300486&r1=300485&r2=300486&view=diff
==============================================================================
--- llvm/trunk/test/tools/llvm-symbolizer/Inputs/discrim.c (original)
+++ llvm/trunk/test/tools/llvm-symbolizer/Inputs/discrim.c Mon Apr 17 15:10:39 2017
@@ -1,8 +1,11 @@
static volatile int do_mul;
-static volatile int do_inc;
+static volatile int x, v;
-int main () {
- int x = 1;
- if (do_mul) x *= 2; else x /= 2;
- return do_inc ? ++x : --x;
+int foo () {
+ if (do_mul) x *= v; else x /= v;
+ return x;
+}
+
+int main() {
+ return foo() + foo();
}
Modified: llvm/trunk/test/tools/llvm-symbolizer/Inputs/discrim.inp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/tools/llvm-symbolizer/Inputs/discrim.inp?rev=300486&r1=300485&r2=300486&view=diff
==============================================================================
--- llvm/trunk/test/tools/llvm-symbolizer/Inputs/discrim.inp (original)
+++ llvm/trunk/test/tools/llvm-symbolizer/Inputs/discrim.inp Mon Apr 17 15:10:39 2017
@@ -1,5 +1,8 @@
some text
-0x4004f2
-0x400509
-0x40050d
+0x400590
+0x4005a5
+0x4005ad
+0x4005b9
+0x4005ce
+0x4005d4
some more text
Modified: llvm/trunk/test/tools/llvm-symbolizer/sym-verbose.test
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/tools/llvm-symbolizer/sym-verbose.test?rev=300486&r1=300485&r2=300486&view=diff
==============================================================================
--- llvm/trunk/test/tools/llvm-symbolizer/sym-verbose.test (original)
+++ llvm/trunk/test/tools/llvm-symbolizer/sym-verbose.test Mon Apr 17 15:10:39 2017
@@ -1,39 +1,97 @@
#static volatile int do_mul;
-#static volatile int do_inc;
+#static volatile int x, v;
#
-#int main () {
-# int x = 1;
-# if (do_mul) x *= 2; else x /= 2;
-# return do_inc ? ++x : --x;
+#int foo () {
+# if (do_mul) x *= v; else x /= v;
+# return x;
#}
-#Build as : clang -g -O2 discrim.c -o discrim
+#
+#int main() {
+# return foo() + foo();
+#}
+#Build as : clang -gmlt -fdebug-info-for-profiling -O2 discrim.c -o discrim
RUN: llvm-symbolizer -verbose -print-address -obj=%p/Inputs/discrim < %p/Inputs/discrim.inp | FileCheck %s
#CHECK: some text
-#CHECK: 0x4004f2
+#CHECK: 0x400590
+#CHECK-NEXT: foo
+#CHECK-NEXT: Filename: /tmp/discrim.c
+#CHECK-NEXT: Function start line: 4
+#CHECK-NEXT: Line: 9
+#CHECK-NEXT: Column: 0
#CHECK-NEXT: main
-#CHECK-NEXT: Filename: /tmp{{[\\/]}}discrim.c
+#CHECK-NEXT: Filename: /tmp/discrim.c
+#CHECK-NEXT: Function start line: 9
+#CHECK-NEXT: Line: 10
+#CHECK-NEXT: Column: 0
+
+#CHECK: 0x4005a5
+#CHECK-NEXT: foo
+#CHECK-NEXT: Filename: /tmp/discrim.c
#CHECK-NEXT: Function start line: 4
-#CHECK-NEXT: Line: 6
-#CHECK-NEXT: Column: 7
-#CHECK-NOT: Discriminator: 0
-
-#CHECK: 0x400509
+#CHECK-NEXT: Line: 5
+#CHECK-NEXT: Column: 17
+#CHECK-NEXT: Discriminator: 2
+#CHECK-NEXT: main
+#CHECK-NEXT: Filename: /tmp/discrim.c
+#CHECK-NEXT: Function start line: 9
+#CHECK-NEXT: Line: 10
+#CHECK-NEXT: Column: 0
+
+#CHECK: 0x4005ad
+#CHECK-NEXT: foo
+#CHECK-NEXT: Filename: /tmp/discrim.c
+#CHECK-NEXT: Function start line: 4
+#CHECK-NEXT: Line: 0
+#CHECK-NEXT: Column: 30
+#CHECK-NEXT: Discriminator: 4
#CHECK-NEXT: main
-#CHECK-NEXT: Filename: /tmp{{[\\/]}}discrim.c
+#CHECK-NEXT: Filename: /tmp/discrim.c
+#CHECK-NEXT: Function start line: 9
+#CHECK-NEXT: Line: 10
+#CHECK-NEXT: Column: 0
+
+#CHECK: 0x4005b9
+#CHECK-NEXT: foo
+#CHECK-NEXT: Filename: /tmp/discrim.c
#CHECK-NEXT: Function start line: 4
-#CHECK-NEXT: Line: 7
-#CHECK-NEXT: Column: 3
-#CHECK-NEXT: Discriminator: 1
+#CHECK-NEXT: Line: 5
+#CHECK-NEXT: Column: 7
+#CHECK-NEXT: main
+#CHECK-NEXT: Filename: /tmp/discrim.c
+#CHECK-NEXT: Function start line: 9
+#CHECK-NEXT: Line: 10
+#CHECK-NEXT: Column: 0
+#CHECK-NEXT: Discriminator: 2
-#CHECK: 0x40050d
+#CHECK: 0x4005ce
+#CHECK-NEXT: foo
+#CHECK-NEXT: Filename: /tmp/discrim.c
+#CHECK-NEXT: Function start line: 4
+#CHECK-NEXT: Line: 5
+#CHECK-NEXT: Column: 17
+#CHECK-NEXT: Discriminator: 2
#CHECK-NEXT: main
-#CHECK-NEXT: Filename: /tmp{{[\\/]}}discrim.c
+#CHECK-NEXT: Filename: /tmp/discrim.c
+#CHECK-NEXT: Function start line: 9
+#CHECK-NEXT: Line: 10
+#CHECK-NEXT: Column: 0
+#CHECK-NEXT: Discriminator: 2
+
+#CHECK: 0x4005d4
+#CHECK-NEXT: foo
+#CHECK-NEXT: Filename: /tmp/discrim.c
#CHECK-NEXT: Function start line: 4
-#CHECK-NEXT: Line: 7
-#CHECK-NEXT: Column: 3
+#CHECK-NEXT: Line: 5
+#CHECK-NEXT: Column: 30
+#CHECK-NEXT: Discriminator: 4
+#CHECK-NEXT: main
+#CHECK-NEXT: Filename: /tmp/discrim.c
+#CHECK-NEXT: Function start line: 9
+#CHECK-NEXT: Line: 10
+#CHECK-NEXT: Column: 0
#CHECK-NEXT: Discriminator: 2
#CHECK: some more text
More information about the llvm-commits
mailing list