1// Checks that module map does not print at 0, prints once after aborting with 1,
2// and prints once before and after aborting with 2
3
4// mac header is "Process module map"
5// other posix header is "Process memory map follows"
6// windows header is "Dumping process modules" (ignored here)
7// we should consider unifying the message cross platform
8
9// RUN: %clangxx -DUSING_%tool_name %s -o %t -w
10
11// RUN: %env_tool_opts="print_module_map=0:halt_on_error=1" not %run %t 2>&1 | FileCheck %s --check-prefixes=CHECK,CHECK-MM0
12// RUN: %env_tool_opts="print_module_map=1:halt_on_error=1" not %run %t 2>&1 | FileCheck %s --check-prefixes=CHECK,CHECK-MM1
13// RUN: %env_tool_opts="print_module_map=2:halt_on_error=1" not %run %t 2>&1 | FileCheck %s --check-prefixes=CHECK,CHECK-MM2
14
15// tsan support pending rdar://67747473
16// XFAIL: tsan
17
18// FIXME: Add linux support.
19// XFAIL: msan && target={{.*linux.*}}
20
21// FIXME: Implement.
22// XFAIL: lsan, hwasan
23
24int global;
25
26int main() {
27#if defined(USING_ubsan)
28 int value = 5;
29 int computation = value / 0; // Division by zero.
30#else
31 volatile int *a = new int[100];
32 delete[] a;
33 global = a[0]; // use-after-free: triggers ASan/TSan report.
34#endif
35 return 0;
36}
37
38// CHECK-NOT: {{Process .*map}}
39// CHECK: SUMMARY:
40// CHECK-MM0-NOT: {{Process .*map}}
41
42// CHECK-MM1: {{Process (module|memory) map}}
43// CHECK-MM1-NOT: {{Process .*map}}
44
45// CHECK-MM2: {{Process (module|memory) map}}
46// CHECK-MM2: {{Process (module|memory) map}}
47// CHECK-MM2-NOT: {{Process .*map}}
48

source code of compiler-rt/test/sanitizer_common/TestCases/Posix/print-module-map.cpp