llvm.org GIT mirror llvm / a7aff25
[cfi] Help sanstats to find binary if they are not at the original location Summary: By default sanstats search binaries at the same location where they were when stats was collected. Sometime you can not print report immediately or you need to move post-processing to another workstation. To support this use-case when original binary is missing sanstats will fall-back to directory with sanstats file. Reviewers: pcc Subscribers: llvm-commits Differential Revision: https://reviews.llvm.org/D53857 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@347601 91177308-0d34-0410-b5e6-96231b3b80d8 Vitaly Buka 9 months ago
2 changed file(s) with 17 addition(s) and 1 deletion(s). Raw diff Collapse all Expand all
2424
2525 # RUN: sanstats %t.stats | FileCheck %s
2626
27 # Test that if binaries are not in the original location then sanstats
28 # searches them next to the stats file.
29 # RUN: mkdir -p %t.dir
30 # RUN: mv -f %t1.o %t2.o %t.dir
31 # RUN: sanstats %t.stats | FileCheck %s --check-prefix=INVALID
32 # RUN: mv -f %t.stats %t.dir/copy.stats
33 # RUN: cd %t.dir && sanstats copy.stats | FileCheck %s
34
35 # INVALID:
36 # CHECK-NOT:
2737 # CHECK: 0x0000000000000000 /tmp{{[/\\]}}f.c:1 f1 cfi-vcall 1
2838 # CHECK: 0x0000000000000010 /tmp{{[/\\]}}f.c:2 f2 cfi-nvcall 2
2939 # CHECK: 0x0000000000000020 /tmp{{[/\\]}}f.c:3 f3 cfi-derived-cast 3
1414 #include "llvm/DebugInfo/Symbolize/Symbolize.h"
1515 #include "llvm/Support/CommandLine.h"
1616 #include "llvm/Support/ErrorOr.h"
17 #include "llvm/Support/FileSystem.h"
1718 #include "llvm/Support/MemoryBuffer.h"
19 #include "llvm/Support/Path.h"
1820 #include "llvm/Transforms/Utils/SanitizerStats.h"
1921 #include
2022
5153 ++Begin;
5254 if (Begin == End)
5355 return nullptr;
54 StringRef Filename(FilenameBegin, Begin - FilenameBegin);
56 std::string Filename(FilenameBegin, Begin - FilenameBegin);
57
58 if (!llvm::sys::fs::exists(Filename))
59 Filename = std::string(llvm::sys::path::parent_path(ClInputFile)) +
60 std::string(llvm::sys::path::filename(Filename));
5561
5662 ++Begin;
5763 if (Begin == End)