aboutsummaryrefslogtreecommitdiff
path: root/test/asan/TestCases/Darwin/dump_registers.cc
blob: 884ad2ed44c07ecb8ae7b5618673cdd7c8c0acb7 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
// Check that ASan dumps the CPU registers on a SIGSEGV.

// RUN: %clangxx_asan %s -o %t
// RUN: not %run %t 2>&1 | FileCheck %s

#include <assert.h>
#include <stdio.h>

int main() {
  fprintf(stderr, "Hello\n");
  char *ptr;

  if (sizeof(void *) == 8)
    ptr = (char *)0x6666666666666666;
  else if (sizeof(void *) == 4)
    ptr = (char *)0x55555555;
  else
    assert(0 && "Your computer is weird.");

  char c = *ptr;  // BOOM
  // CHECK: ERROR: AddressSanitizer: SEGV
  // CHECK: Register values:
  // CHECK: {{0x55555555|0x6666666666666666}}
  fprintf(stderr, "World\n");
  return c;
}