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