1 // RUN: %clangxx_asan -fsanitize-coverage=func,trace-pc-guard -DSHARED %s -shared -o %dynamiclib -fPIC %ld_flags_rpath_so
2 // RUN: %clangxx_asan -fsanitize-coverage=func,trace-pc-guard %s %ld_flags_rpath_exe -o %t
3 // RUN: rm -rf %t-dir && mkdir -p %t-dir && cd %t-dir
4 // RUN: %env_asan_opts=coverage=1:verbosity=1 %run %t 2>&1 | FileCheck %s
10 #include <sanitizer/coverage_interface.h>
13 void bar1() { printf("bar1\n"); }
14 void bar2() { printf("bar2\n"); }
16 __attribute__((noinline
)) void foo1() { printf("foo1\n"); }
17 __attribute__((noinline
)) void foo2() { printf("foo2\n"); }
21 int main(int argc
, char **argv
) {
22 fprintf(stderr
, "RESET\n");
23 __sanitizer_cov_reset();
28 __sanitizer_cov_dump();
30 // CHECK-DAG: SanitizerCoverage: ./coverage-reset.cpp{{.*}}.sancov: 2 PCs written
31 // CHECK-DAG: SanitizerCoverage: ./libcoverage-reset.cpp{{.*}}.sancov: 2 PCs written
33 fprintf(stderr
, "RESET\n");
34 __sanitizer_cov_reset();
37 __sanitizer_cov_dump();
39 // CHECK-DAG: SanitizerCoverage: ./coverage-reset.cpp{{.*}}.sancov: 1 PCs written
40 // CHECK-DAG: SanitizerCoverage: ./libcoverage-reset.cpp{{.*}}.sancov: 1 PCs written
42 fprintf(stderr
, "RESET\n");
43 __sanitizer_cov_reset();
46 __sanitizer_cov_dump();
48 // CHECK: SanitizerCoverage: ./coverage-reset.cpp{{.*}}.sancov: 2 PCs written
50 fprintf(stderr
, "RESET\n");
51 __sanitizer_cov_reset();
54 __sanitizer_cov_dump();
56 // CHECK: SanitizerCoverage: ./libcoverage-reset.cpp{{.*}}.sancov: 2 PCs written
58 fprintf(stderr
, "RESET\n");
59 __sanitizer_cov_reset();
63 // CHECK: SanitizerCoverage: ./libcoverage-reset.cpp{{.*}}.sancov: 1 PCs written