2 * Ptrace test for VMX/VSX registers
4 * Copyright (C) 2015 Anshuman Khandual, IBM Corporation.
6 * This program is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU General Public License
8 * as published by the Free Software Foundation; either version
9 * 2 of the License, or (at your option) any later version.
12 #include "ptrace-vsx.h"
14 /* Tracer and Tracee Shared Data */
18 unsigned long fp_load[VEC_MAX];
19 unsigned long fp_load_new[VEC_MAX];
20 unsigned long fp_store[VEC_MAX];
26 cptr = (int *)shmat(shm_id, NULL, 0);
31 asm volatile("" : : : "memory");
34 storevsx(fp_store, 0);
35 ret = compare_vsx_vmx(fp_store, fp_load_new);
41 int trace_vsx(pid_t child)
43 unsigned long vsx[VSX_MAX];
44 unsigned long vmx[VMX_MAX + 2][2];
46 FAIL_IF(start_trace(child));
47 FAIL_IF(show_vsx(child, vsx));
48 FAIL_IF(validate_vsx(vsx, fp_load));
49 FAIL_IF(show_vmx(child, vmx));
50 FAIL_IF(validate_vmx(vmx, fp_load));
52 memset(vsx, 0, sizeof(vsx));
53 memset(vmx, 0, sizeof(vmx));
54 load_vsx_vmx(fp_load_new, vsx, vmx);
56 FAIL_IF(write_vsx(child, vsx));
57 FAIL_IF(write_vmx(child, vmx));
58 FAIL_IF(stop_trace(child));
68 shm_id = shmget(IPC_PRIVATE, sizeof(int) * 2, 0777|IPC_CREAT);
70 for (i = 0; i < VEC_MAX; i++)
71 fp_load[i] = i + rand();
73 for (i = 0; i < VEC_MAX; i++)
74 fp_load_new[i] = i + 2 * rand();
78 perror("fork() failed");
86 pptr = (int *)shmat(shm_id, NULL, 0);
88 asm volatile("" : : : "memory");
94 shmctl(shm_id, IPC_RMID, NULL);
102 shmctl(shm_id, IPC_RMID, NULL);
104 printf("Child's exit status not captured\n");
108 return (WIFEXITED(status) && WEXITSTATUS(status)) ? TEST_FAIL :
114 int main(int argc, char *argv[])
116 return test_harness(ptrace_vsx, "ptrace_vsx");