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

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