1 /* Tests that Valgrind coredump support works correctly by producing 2 a core dump analyzable by mdb. */ 3 4 #include <stdio.h> 5 #include <sys/types.h> 6 7 __attribute__((noinline)) 8 static void inner(void) 9 { 10 /* Set registers to apriori known values. */ 11 __asm__ __volatile__( 12 "movq $0x101, %%rax\n" 13 "movq $0x102, %%rbx\n" 14 "movq $0x103, %%rcx\n" 15 "movq $0x104, %%rdx\n" 16 "movq $0x105, %%rsi\n" 17 "movq $0x106, %%rdi\n" 18 "movq $0x107, %%r8\n" 19 "movq $0x108, %%r9\n" 20 "movq $0x109, %%r10\n" 21 "movq $0x10a, %%r11\n" 22 "movq $0x10b, %%r12\n" 23 "movq $0x10c, %%r13\n" 24 "movq $0x10d, %%r14\n" 25 "movq $0x10e, %%r15\n" 26 // not %rbp as mdb is then not able to reconstruct stack trace 27 "movq $0x10f, %%rsp\n" 28 "movq $0x1234, (%%rax)\n" // should cause SEGV here 29 "ud2" // should never get here 30 : // no output registers 31 : // no input registers 32 : "memory", "%rax", "%rbx", "%rcx", "%rdx", "%rsi", "%rdi", 33 "%r8", "%r9", "%r10", "%r11", "%r12", "%r13", "%r14", "%r15", "%rsp"); 34 } 35 36 __attribute__((noinline)) 37 static void outer(void) 38 { 39 inner(); 40 } 41 42 int main(int argc, const char *argv[]) 43 { 44 outer(); 45 return 0; 46 } 47