1// Check that sanitizer prints the faulting instruction bytes on
2// dump_instruction_bytes=1
3
4// RUN: %clangxx %s -o %t
5// RUN: %env_tool_opts=dump_instruction_bytes=1 not %run %t 2>&1 | FileCheck %s --check-prefix=CHECK-DUMP
6// RUN: not %run %t 2>&1 | FileCheck %s --check-prefix=CHECK-NODUMP
7
8// REQUIRES: x86-target-arch
9
10int main() {
11#if defined(__x86_64__)
12 asm("movq $0, %rax");
13 asm("movl $0xcafebabe, 0x0(%rax)");
14#elif defined(i386)
15 asm("movl $0, %eax");
16 asm("movl $0xcafebabe, 0x0(%eax)");
17#endif
18 // CHECK-DUMP: First 16 instruction bytes at pc: c7 00 be ba fe ca
19 // CHECK-NODUMP-NOT: First 16 instruction bytes
20 return 0;
21}
22

source code of compiler-rt/test/sanitizer_common/TestCases/Posix/dump_instruction_bytes.cpp