Skip to content
This repository was archived by the owner on May 21, 2019. It is now read-only.

Commit c26b748

Browse files
[sancov] sanitizer coverage initialization test
Summary: Reflects the change in https://reviews.llvm.org/D29662 Subscribers: kubamracek Differential Revision: https://reviews.llvm.org/D29721 git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@294533 91177308-0d34-0410-b5e6-96231b3b80d8
1 parent 76ca11d commit c26b748

File tree

1 file changed

+73
-0
lines changed

1 file changed

+73
-0
lines changed
Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
// Tests trace pc guard coverage collection.
2+
//
3+
// REQUIRES: has_sancovcc,stable-runtime,x86_64-linux
4+
// XFAIL: tsan
5+
//
6+
// RUN: DIR=%t_workdir
7+
// RUN: CLANG_ARGS="-O0 -fsanitize-coverage=trace-pc-guard"
8+
// RUN: rm -rf $DIR
9+
// RUN: mkdir -p $DIR
10+
// RUN: cd $DIR
11+
// RUN: %clangxx -DSHARED1 $CLANG_ARGS -shared %s -o %t_1.so -fPIC
12+
// RUN: %clangxx -DSTATIC1 $CLANG_ARGS %s -c -o %t_2.o
13+
// RUN: %clangxx -DMAIN $CLANG_ARGS %s -o %t %t_1.so %t_2.o
14+
// RUN: %env_tool_opts=coverage=1 %t 2>&1 | FileCheck %s
15+
// RUN: rm -rf $DIR
16+
17+
#include <stdio.h>
18+
#include <stdint.h>
19+
#include <stdlib.h>
20+
21+
extern "C" {
22+
int bar();
23+
int baz();
24+
}
25+
26+
#ifdef MAIN
27+
28+
extern "C" void __sanitizer_cov_trace_pc_guard_init(uint32_t *start, uint32_t *stop) {
29+
fprintf(stderr, "__sanitizer_cov_trace_pc_guard_init\n");
30+
}
31+
32+
extern "C" void __sanitizer_cov_trace_pc_guard(uint32_t *guard) { }
33+
34+
35+
int foo() {
36+
fprintf(stderr, "foo\n");
37+
return 1;
38+
}
39+
40+
int main() {
41+
fprintf(stderr, "main\n");
42+
foo();
43+
bar();
44+
baz();
45+
}
46+
47+
#endif // MAIN
48+
49+
extern "C" {
50+
51+
#ifdef SHARED1
52+
int bar() {
53+
fprintf(stderr, "bar\n");
54+
return 1;
55+
}
56+
#endif
57+
58+
#ifdef STATIC1
59+
int baz() {
60+
fprintf(stderr, "baz\n");
61+
return 1;
62+
}
63+
#endif
64+
65+
} // extern "C"
66+
67+
// Init is called once per DSO.
68+
// CHECK: __sanitizer_cov_trace_pc_guard_init
69+
// CHECK-NEXT: __sanitizer_cov_trace_pc_guard_init
70+
// CHECK-NEXT: main
71+
// CHECK-NEXT: foo
72+
// CHECK-NEXT: bar
73+
// CHECK-NEXT: baz

0 commit comments

Comments
 (0)