1/* Tests that Valgrind coredump support for SSE registers works correctly
2   by producing a core dump analyzable by mdb.
3   Basic register set is tested in coredump_single_thread. */
4
5#include <stdio.h>
6#include <sys/types.h>
7
8__attribute__((noinline))
9static void inner(void)
10{
11   /* Set XMM registers to apriori known values.
12      Unfortunately there is no instruction to load
13      an immediate value directly into xmm register. */
14   __asm__ __volatile__("\n"
15      "pushl $0x12345678\n"
16      "pushl $0x9abcdef0\n"
17      "pushl $0xfedbca98\n"
18      "pushl $0x76543210\n"
19      "movups (%%esp), %%xmm0\n"
20      "pushl $0x23456789\n"
21      "pushl $0x09876543\n"
22      "pushl $0x21fedcba\n"
23      "pushl $0x9467feca\n"
24      "movups (%%esp), %%xmm1\n"
25      "pushl $0xabcdabcd\n"
26      "pushl $0xcedecede\n"
27      "pushl $0xfabafaba\n"
28      "pushl $0x50656754\n"
29      "movups (%%esp), %%xmm2\n"
30      "pushl $0x03050608\n"
31      "pushl $0x1d1b4b15\n"
32      "pushl $0x25272120\n"
33      "pushl $0x373a3d35\n"
34      "movups (%%esp), %%xmm3\n"
35      "pushl $0x9abcdef0\n"
36      "pushl $0x76543210\n"
37      "pushl $0x12345678\n"
38      "pushl $0xfedbca98\n"
39      "movups (%%esp), %%xmm4\n"
40      "pushl $0x9467feca\n"
41      "pushl $0x23456789\n"
42      "pushl $0x21fedcba\n"
43      "pushl $0x09876543\n"
44      "movups (%%esp), %%xmm5\n"
45      "pushl $0x50656754\n"
46      "pushl $0xcedecede\n"
47      "pushl $0xabcdabcd\n"
48      "pushl $0xfabafaba\n"
49      "movups (%%esp), %%xmm6\n"
50      "pushl $0x373a3d35\n"
51      "pushl $0x1d1b4b15\n"
52      "pushl $0x03050608\n"
53      "pushl $0x25272120\n"
54      "movups (%%esp), %%xmm7\n"
55      "movl $0x1, %%eax\n"
56      "movl $0x1234, (%%eax)\n"  // should cause SEGV here
57      : // no output registers
58      : // no input registers
59      : "memory", "%xmm0", "%xmm1", "%xmm2", "%xmm3",
60                  "%xmm4", "%xmm5", "%xmm6", "%xmm7");
61}
62
63__attribute__((noinline))
64static void outer(void)
65{
66   inner();
67}
68
69int main(int argc, const char *argv[])
70{
71   outer();
72   return 0;
73}
74