1// RUN: %clangxx_msan -O0 -g %s -o %t && %run %t >%t.out 2>&1
2// RUN: FileCheck %s --check-prefix=CHECK --check-prefix=CHECK-NO-ORIGINS < %t.out
3
4// RUN: %clangxx_msan -fsanitize-memory-track-origins -O0 -g %s -o %t && %run %t >%t.out 2>&1
5// RUN: FileCheck %s --check-prefix=CHECK --check-prefix=CHECK-ORIGINS < %t.out
6
7// RUN: %clangxx_msan -fsanitize-memory-track-origins=2 -O0 -g %s -o %t && %run %t >%t.out 2>&1
8// RUN: FileCheck %s --check-prefix=CHECK --check-prefix=CHECK-ORIGINS < %t.out
9
10#include <sanitizer/msan_interface.h>
11
12int main(void) {
13 char *p = new char[16];
14 __msan_print_shadow(x: p, size: 1);
15 __msan_print_shadow(x: p+1, size: 1);
16 __msan_print_shadow(x: p+3, size: 1);
17 __msan_print_shadow(x: p+15, size: 1);
18 __msan_print_shadow(x: p, size: 0);
19 delete[] p;
20 int x = 0;
21 __msan_print_shadow(x: &x, size: 3);
22 return 0;
23}
24
25// CHECK: Shadow map [0x{{.*}}, 0x{{.*}}) of [0x{{.*}}, 0x{{.*}}), 1 bytes:
26// CHECK-NO-ORIGINS: 0x{{.*}}: ff...... ........ ........ ........
27// CHECK-ORIGINS: 0x{{.*}}: ff...... ........ ........ ........ |A . . .|
28// CHECK-ORIGINS: Origin A (origin_id {{.*}}):
29
30// CHECK: Shadow map [0x{{.*}}, 0x{{.*}}) of [0x{{.*}}, 0x{{.*}}), 1 bytes:
31// CHECK-NO-ORIGINS: 0x{{.*}}: ..ff.... ........ ........ ........
32// CHECK-ORIGINS: 0x{{.*}}: ..ff.... ........ ........ ........ |A . . .|
33// CHECK-ORIGINS: Origin A (origin_id {{.*}}):
34
35// CHECK: Shadow map [0x{{.*}}, 0x{{.*}}) of [0x{{.*}}, 0x{{.*}}), 1 bytes:
36// CHECK-NO-ORIGINS: 0x{{.*}}: ......ff ........ ........ ........
37// CHECK-ORIGINS: 0x{{.*}}: ......ff ........ ........ ........ |A . . .|
38// CHECK-ORIGINS: Origin A (origin_id {{.*}}):
39
40// CHECK: Shadow map [0x{{.*}}, 0x{{.*}}) of [0x{{.*}}, 0x{{.*}}), 1 bytes:
41// CHECK-NO-ORIGINS: 0x{{.*}}: ......ff ........ ........ ........
42// CHECK-ORIGINS: 0x{{.*}}: ......ff ........ ........ ........ |A . . .|
43// CHECK-ORIGINS: Origin A (origin_id {{.*}}):
44
45// CHECK: Shadow map [0x{{.*}}, 0x{{.*}}) of [0x{{.*}}, 0x{{.*}}), 0 bytes:
46
47// CHECK: Shadow map [0x{{.*}}, 0x{{.*}}) of [0x{{.*}}, 0x{{.*}}), 3 bytes:
48// CHECK-NO-ORIGINS: 0x{{.*}}: 000000.. ........ ........ ........
49// CHECK-ORIGINS: 0x{{.*}}: 000000.. ........ ........ ........ |. . . .|
50

source code of compiler-rt/test/msan/msan_print_shadow2.cpp