1 // Tests trace pc guard coverage collection.
3 // REQUIRES: has_sancovcc
4 // UNSUPPORTED: ubsan,target={{(powerpc64|s390x|thumb).*}}
6 // XFAIL: android && asan
9 // RUN: CLANG_ARGS="-O0 -fsanitize-coverage=trace-pc-guard"
13 // RUN: %clangxx -DSHARED1 $CLANG_ARGS -shared %s -o %t_1.so -fPIC
14 // RUN: %clangxx -DSHARED2 $CLANG_ARGS -shared %s -o %t_2.so -fPIC
15 // RUN: %clangxx -DMAIN $CLANG_ARGS %s -o %t %t_1.so %t_2.so
16 // RUN: %env_tool_opts=coverage=1 %t 2>&1 | FileCheck %s
17 // RUN: %sancovcc -covered-functions -strip_path_prefix=TestCases/ *.sancov \
18 // RUN: %t %t_1.so %t_2.so 2>&1 | \
19 // RUN: FileCheck --check-prefix=CHECK-SANCOV %s
32 fprintf(stderr
, "foo\n");
37 fprintf(stderr
, "main\n");
49 fprintf(stderr
, "bar\n");
56 fprintf(stderr
, "baz\n");
67 // CHECK-DAG: SanitizerCoverage: ./sanitizer_coverage_trace_pc_guard-dso.{{.*}}.sancov: 2 PCs written
68 // CHECK-DAG: SanitizerCoverage: ./sanitizer_coverage_trace_pc_guard-dso.{{.*}}_2.so.{{.*}}.sancov: 1 PCs written
69 // CHECK-DAG: SanitizerCoverage: ./sanitizer_coverage_trace_pc_guard-dso.{{.*}}_1.so.{{.*}}.sancov: 1 PCs written
71 // CHECK-SANCOV: Ignoring {{.*}}_1.so and its coverage because __sanitizer_cov* functions were not found.
72 // CHECK-SANCOV: Ignoring {{.*}}_2.so and its coverage because __sanitizer_cov* functions were not found.
73 // CHECK-SANCOV-NEXT: sanitizer_coverage_trace_pc_guard-dso.cpp:[[@LINE-42]] foo
74 // CHECK-SANCOV-NEXT: sanitizer_coverage_trace_pc_guard-dso.cpp:[[@LINE-38]] main