]> git.proxmox.com Git - rustc.git/blame - src/compiler-rt/test/asan/TestCases/Darwin/dump_registers.cc
New upstream version 1.19.0+dfsg3
[rustc.git] / src / compiler-rt / test / asan / TestCases / Darwin / dump_registers.cc
CommitLineData
7cac9316
XL
1// Check that ASan dumps the CPU registers on a SIGSEGV.
2
3// RUN: %clangxx_asan %s -o %t
4// RUN: not %run %t 2>&1 | FileCheck %s
5
6#include <assert.h>
7#include <stdio.h>
8
9int main() {
10 fprintf(stderr, "Hello\n");
11 char *ptr;
12
13 if (sizeof(void *) == 8)
14 ptr = (char *)0x6666666666666666;
15 else if (sizeof(void *) == 4)
16 ptr = (char *)0x55555555;
17 else
18 assert(0 && "Your computer is weird.");
19
20 char c = *ptr; // BOOM
21 // CHECK: ERROR: AddressSanitizer: SEGV
22 // CHECK: Register values:
23 // CHECK: {{0x55555555|0x6666666666666666}}
24 fprintf(stderr, "World\n");
25 return c;
26}