1 | // clang-format off |
2 | |
3 | // REQUIRES: system-windows |
4 | // RUN: %build --compiler=clang-cl -o %t.exe -- %s |
5 | // RUN: env LLDB_USE_NATIVE_PDB_READER=1 %lldb -f %t.exe -o "run" -- write | FileCheck --check-prefix=WRITE %s |
6 | // RUN: env LLDB_USE_NATIVE_PDB_READER=1 %lldb -f %t.exe -o "run" -- read | FileCheck --check-prefix=READ %s |
7 | |
8 | #include <string.h> |
9 | |
10 | int access_violation_write(void* addr) { |
11 | *(int*)addr = 42; |
12 | return 0; |
13 | } |
14 | |
15 | |
16 | int access_violation_read(void* addr) { |
17 | volatile int ret = *(int*)addr; |
18 | return ret; |
19 | } |
20 | |
21 | int main(int argc, char *argv[]) { |
22 | if (argc < 2) { |
23 | return 1; |
24 | } |
25 | if (strcmp(s1: argv[1], s2: "write" ) == 0) { |
26 | return access_violation_write(addr: (void*)42); |
27 | } |
28 | if (strcmp(s1: argv[1], s2: "read" ) == 0) { |
29 | return access_violation_read(addr: (void*)42); |
30 | } |
31 | return 1; |
32 | } |
33 | |
34 | |
35 | // WRITE: * thread #1, stop reason = Exception 0xc0000005 encountered at address {{.*}}: Access violation writing location 0x0000002a |
36 | |
37 | // READ: * thread #1, stop reason = Exception 0xc0000005 encountered at address {{.*}}: Access violation reading location 0x0000002a |
38 | |