1// Tests trace pc guard coverage collection.
2//
3// REQUIRES: x86_64-linux
4// XFAIL: tsan
5//
6// RUN: DIR=%t_workdir
7// RUN: rm -rf $DIR
8// RUN: mkdir -p $DIR
9// RUN: cd $DIR
10/// In glibc 2.39+, fprintf has a nonnull attribute. Disable nonnull-attribute,
11/// which would increase counters for ubsan.
12// RUN: %clangxx -O0 -fsanitize-coverage=trace-pc-guard -fno-sanitize=nonnull-attribute %s -o %t
13// RUN: %env_tool_opts=coverage=1 %t 2>&1 | FileCheck %s
14// RUN: rm -rf $DIR
15
16#include <stdio.h>
17
18int foo() {
19 fprintf(stderr, format: "foo\n");
20 return 1;
21}
22
23int main() {
24 fprintf(stderr, format: "main\n");
25 foo();
26 foo();
27}
28
29// CHECK: main
30// CHECK: SanitizerCoverage: ./sanitizer_coverage_symbolize.{{.*}}.sancov: 2 PCs written
31

source code of compiler-rt/test/sanitizer_common/TestCases/sanitizer_coverage_symbolize.cpp