[PATCH] D53857: [cfi] Support sanstats if binary is not available in the original location
Vitaly Buka via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Fri Nov 16 17:54:12 PST 2018
vitalybuka updated this revision to Diff 174490.
vitalybuka added a comment.
test
Repository:
rL LLVM
https://reviews.llvm.org/D53857
Files:
llvm/test/tools/sanstats/elf.test
llvm/tools/sanstats/sanstats.cpp
Index: llvm/tools/sanstats/sanstats.cpp
===================================================================
--- llvm/tools/sanstats/sanstats.cpp
+++ llvm/tools/sanstats/sanstats.cpp
@@ -15,7 +15,9 @@
#include "llvm/DebugInfo/Symbolize/Symbolize.h"
#include "llvm/Support/CommandLine.h"
#include "llvm/Support/ErrorOr.h"
+#include "llvm/Support/FileSystem.h"
#include "llvm/Support/MemoryBuffer.h"
+#include "llvm/Support/Path.h"
#include "llvm/Transforms/Utils/SanitizerStats.h"
#include <stdint.h>
@@ -52,7 +54,11 @@
++Begin;
if (Begin == End)
return nullptr;
- StringRef Filename(FilenameBegin, Begin - FilenameBegin);
+ std::string Filename(FilenameBegin, Begin - FilenameBegin);
+
+ if (!llvm::sys::fs::exists(Filename))
+ Filename = std::string(llvm::sys::path::parent_path(ClInputFile)) +
+ std::string(llvm::sys::path::filename(Filename));
++Begin;
if (Begin == End)
Index: llvm/test/tools/sanstats/elf.test
===================================================================
--- llvm/test/tools/sanstats/elf.test
+++ llvm/test/tools/sanstats/elf.test
@@ -25,6 +25,16 @@
# RUN: sanstats %t.stats | FileCheck %s
+# Test that if binaries are not in the original location then sanstats
+# searches them next to the stats file.
+# RUN: mkdir -p %t.dir
+# RUN: mv -f %t1.o %t2.o %t.dir
+# RUN: sanstats %t.stats | FileCheck %s --check-prefix=INVALID
+# RUN: mv -f %t.stats %t.dir/copy.stats
+# RUN: cd %t.dir && sanstats copy.stats | FileCheck %s
+
+# INVALID: <invalid>
+# CHECK-NOT: <invalid>
# CHECK: 0x0000000000000000 /tmp{{[/\\]}}f.c:1 f1 cfi-vcall 1
# CHECK: 0x0000000000000010 /tmp{{[/\\]}}f.c:2 f2 cfi-nvcall 2
# CHECK: 0x0000000000000020 /tmp{{[/\\]}}f.c:3 f3 cfi-derived-cast 3
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D53857.174490.patch
Type: text/x-patch
Size: 1748 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20181117/a36dcd8c/attachment.bin>
More information about the llvm-commits
mailing list