• Home
  • History
  • Annotate
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 // Test -mllvm -sanitizer-coverage-experimental-tracing
2 //
3 // RUN: %clangxx_asan -O1 -fsanitize-coverage=1 -mllvm -sanitizer-coverage-experimental-tracing %s -o %t
4 // RUN: rm -rf   %T/coverage-tracing
5 // RUN: mkdir %T/coverage-tracing
6 // RUN: cd %T/coverage-tracing
7 // RUN:  A=x;   ASAN_OPTIONS=coverage=1:verbosity=1 %run %t $A 1   2>&1 | FileCheck %s --check-prefix=CHECK --check-prefix=CHECK1; mv trace-points.*.sancov $A.points
8 // RUN:  A=f;   ASAN_OPTIONS=coverage=1:verbosity=1 %run %t $A 1   2>&1 | FileCheck %s --check-prefix=CHECK --check-prefix=CHECK2; mv trace-points.*.sancov $A.points
9 // RUN:  A=b;   ASAN_OPTIONS=coverage=1:verbosity=1 %run %t $A 1   2>&1 | FileCheck %s --check-prefix=CHECK --check-prefix=CHECK2; mv trace-points.*.sancov $A.points
10 // RUN:  A=bf;  ASAN_OPTIONS=coverage=1:verbosity=1 %run %t $A 1   2>&1 | FileCheck %s --check-prefix=CHECK --check-prefix=CHECK3; mv trace-points.*.sancov $A.points
11 // RUN:  A=fb;  ASAN_OPTIONS=coverage=1:verbosity=1 %run %t $A 1   2>&1 | FileCheck %s --check-prefix=CHECK --check-prefix=CHECK3; mv trace-points.*.sancov $A.points
12 // RUN:  A=ffb; ASAN_OPTIONS=coverage=1:verbosity=1 %run %t $A 1   2>&1 | FileCheck %s --check-prefix=CHECK --check-prefix=CHECK4; mv trace-points.*.sancov $A.points
13 // RUN:  A=fff; ASAN_OPTIONS=coverage=1:verbosity=1 %run %t $A 1   2>&1 | FileCheck %s --check-prefix=CHECK --check-prefix=CHECK4; mv trace-points.*.sancov $A.points
14 // RUN:  A=bbf; ASAN_OPTIONS=coverage=1:verbosity=1 %run %t $A 100 2>&1 | FileCheck %s --check-prefix=CHECK --check-prefix=CHECK301; mv trace-points.*.sancov $A.points
15 // RUN: diff f.points fff.points
16 // RUN: diff bf.points fb.points
17 // RUN: diff bf.points ffb.points
18 // RUN: diff bf.points bbf.points
19 // RUN: not diff x.points f.points
20 // RUN: not diff x.points b.points
21 // RUN: not diff x.points bf.points
22 // RUN: not diff f.points b.points
23 // RUN: not diff f.points bf.points
24 // RUN: not diff b.points bf.points
25 // RUN: rm -rf   %T/coverage-tracing
26 //
27 // REQUIRES: asan-64-bits
28 
29 #include <stdlib.h>
30 volatile int sink;
foo()31 __attribute__((noinline)) void foo() { sink++; }
bar()32 __attribute__((noinline)) void bar() { sink++; }
33 
main(int argc,char ** argv)34 int main(int argc, char **argv) {
35   if (argc != 3) return 0;
36   int n = strtol(argv[2], 0, 10);
37   while (n-- > 0) {
38     for (int i = 0; argv[1][i]; i++) {
39       if (argv[1][i] == 'f') foo();
40       else if (argv[1][i] == 'b') bar();
41     }
42   }
43 }
44 
45 // CHECK: CovDump: Trace: 3 PCs written
46 // CHECK1: CovDump: Trace: 1 Events written
47 // CHECK2: CovDump: Trace: 2 Events written
48 // CHECK3: CovDump: Trace: 3 Events written
49 // CHECK4: CovDump: Trace: 4 Events written
50 // CHECK301: CovDump: Trace: 301 Events written
51