1 /* x86 variant of the amd64-solaris/context_gpr.c test. */
8 #include <sys/regset.h>
9 #include <sys/syscall.h>
14 /* x0 is always zero, but is visible to Valgrind as uninitialised. */
17 static void sighandler(int sig
, siginfo_t
*sip
, void *arg
)
19 ucontext_t
*ucp
= (ucontext_t
*) arg
;
24 ucp
->uc_mcontext
.gregs
[ECX
] = x0
;
31 int eax
, ebx
, ecx
, edx
, esi
, edi
;
34 /* Uninitialised, but we know px[0] is 0x0. */
35 int *px
= malloc(sizeof(*px
));
38 /* Uninitialised, but we know py[0] is 0x0. */
39 int *py
= malloc(sizeof(*py
));
42 sa
.sa_sigaction
= sighandler
;
43 sa
.sa_flags
= SA_SIGINFO
;
44 if (sigfillset(&sa
.sa_mask
)) {
48 if (sigaction(SIGUSR1
, &sa
, NULL
)) {
56 /* Set values in general purpose registers. */
63 /* Prepare syscall parameters. */
67 "movl %[scall], %%eax\n"
69 /* Trigger the signal handler. */
72 : "=a" (eax
), "=b" (ebx
), "=c" (ecx
), "=d" (edx
), "=S" (esi
),
74 : [scall
] "i" (SYS_kill
), [pid
] "a" (pid
), [sig
] "i" (SIGUSR1
),
78 printf("Values in the signal handler:\n");
79 printf(" eax=%#x, edx=%#x, esi=%#x, edi=%#x\n",
80 uc
.uc_mcontext
.gregs
[EAX
], uc
.uc_mcontext
.gregs
[EDX
],
81 uc
.uc_mcontext
.gregs
[ESI
], uc
.uc_mcontext
.gregs
[EDI
]);
82 /* Check that ebx contains an uninitialised value (origin is py[0]). */
83 if (uc
.uc_mcontext
.gregs
[EBX
])
86 printf("Values after the return from the signal handler:\n");
87 printf(" eax=%#x, edx=%#x, esi=%#x, edi=%#x\n", eax
, edx
, esi
, edi
);
88 /* Check that ebx and ecx contain uninitialised values (origin is py[0]
89 and px[0], respectively). */