summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--test/tools/sanstats/Inputs/debuginfo.statsbin0 -> 352 bytes
-rw-r--r--test/tools/sanstats/debuginfo.test4
-rw-r--r--tools/sanstats/sanstats.cpp5
3 files changed, 8 insertions, 1 deletions
diff --git a/test/tools/sanstats/Inputs/debuginfo.stats b/test/tools/sanstats/Inputs/debuginfo.stats
new file mode 100644
index 000000000000..45de79be3a7f
--- /dev/null
+++ b/test/tools/sanstats/Inputs/debuginfo.stats
Binary files differ
diff --git a/test/tools/sanstats/debuginfo.test b/test/tools/sanstats/debuginfo.test
new file mode 100644
index 000000000000..6585ff753107
--- /dev/null
+++ b/test/tools/sanstats/debuginfo.test
@@ -0,0 +1,4 @@
+# RUN: sanstats %p/Inputs/debuginfo.stats | FileCheck %s
+
+# CHECK: stats.cpp:23 vcall.cfi cfi-vcall 37
+# CHECK: stats.cpp:28 nvcall.cfi cfi-nvcall 51
diff --git a/tools/sanstats/sanstats.cpp b/tools/sanstats/sanstats.cpp
index b2216eab119e..4463c0f0e48c 100644
--- a/tools/sanstats/sanstats.cpp
+++ b/tools/sanstats/sanstats.cpp
@@ -76,8 +76,11 @@ const char *ReadModule(char SizeofPtr, const char *Begin, const char *End) {
if (Begin == End)
return nullptr;
+ // As the instrumentation tracks the return address and not
+ // the address of the call to `__sanitizer_stats_report` we
+ // remove one from the address to get the correct DI.
if (Expected<DILineInfo> LineInfo =
- Symbolizer.symbolizeCode(Filename, Addr)) {
+ Symbolizer.symbolizeCode(Filename, Addr - 1)) {
llvm::outs() << LineInfo->FileName << ':' << LineInfo->Line << ' '
<< LineInfo->FunctionName << ' ';
} else {