]> granicus.if.org Git - llvm/commitdiff
[sanstats] Print the correct line information.
authorDavide Italiano <davide@freebsd.org>
Thu, 13 Jul 2017 00:49:03 +0000 (00:49 +0000)
committerDavide Italiano <davide@freebsd.org>
Thu, 13 Jul 2017 00:49:03 +0000 (00:49 +0000)
The instrumentation tracks the return address and not that of the
call so we remove one to compensate. Thanks for Peter Collingbourne
for confirming the analysis of the problem.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@307871 91177308-0d34-0410-b5e6-96231b3b80d8

test/tools/sanstats/Inputs/debuginfo.stats [new file with mode: 0644]
test/tools/sanstats/debuginfo.test [new file with mode: 0644]
tools/sanstats/sanstats.cpp

diff --git a/test/tools/sanstats/Inputs/debuginfo.stats b/test/tools/sanstats/Inputs/debuginfo.stats
new file mode 100644 (file)
index 0000000..45de79b
Binary files /dev/null and b/test/tools/sanstats/Inputs/debuginfo.stats differ
diff --git a/test/tools/sanstats/debuginfo.test b/test/tools/sanstats/debuginfo.test
new file mode 100644 (file)
index 0000000..6585ff7
--- /dev/null
@@ -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
index b2216eab119e124d7887bb5b139d061e88cd143a..4463c0f0e48c428c0fed06a92e866e8ea212441d 100644 (file)
@@ -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 {