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 
access_violation_write(void * addr)10 int access_violation_write(void* addr) {
11     *(int*)addr = 42;
12     return 0;
13 }
14 
15 
access_violation_read(void * addr)16 int access_violation_read(void* addr) {
17     volatile int ret = *(int*)addr;
18     return ret;
19 }
20 
main(int argc,char * argv[])21 int main(int argc, char *argv[]) {
22     if (argc < 2) {
23         return 1;
24     }
25     if (strcmp(argv[1], "write") == 0) {
26         return access_violation_write((void*)42);
27     }
28     if (strcmp(argv[1], "read") == 0) {
29         return access_violation_read((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