@@ -125,10 +125,6 @@ static bool process_write_data(struct ps_prochandle* ph,
125125static bool process_get_lwp_regs (struct ps_prochandle * ph , pid_t pid , struct user_regs_struct * user ) {
126126 // we have already attached to all thread 'pid's, just use ptrace call
127127 // to get regset now. Note that we don't cache regset upfront for processes.
128- // Linux on x86 and sparc are different. On x86 ptrace(PTRACE_GETREGS, ...)
129- // uses pointer from 4th argument and ignores 3rd argument. On sparc it uses
130- // pointer from 3rd argument and ignores 4th argument
131- #define ptrace_getregs (request , pid , addr , data ) ptrace(request, pid, data, addr)
132128
133129#if defined(_LP64 ) && defined(PTRACE_GETREGS64 )
134130#define PTRACE_GETREGS_REQ PTRACE_GETREGS64
@@ -138,22 +134,22 @@ static bool process_get_lwp_regs(struct ps_prochandle* ph, pid_t pid, struct use
138134#define PTRACE_GETREGS_REQ PT_GETREGS
139135#endif
140136
141- #ifdef PTRACE_GETREGS_REQ
142- if (ptrace_getregs (PTRACE_GETREGS_REQ , pid , user , NULL ) < 0 ) {
137+ #if defined(PTRACE_GETREGSET )
138+ struct iovec iov ;
139+ iov .iov_base = user ;
140+ iov .iov_len = sizeof (* user );
141+ if (ptrace (PTRACE_GETREGSET , pid , NT_PRSTATUS , (void * ) & iov ) < 0 ) {
142+ print_debug ("ptrace(PTRACE_GETREGSET, ...) failed for lwp %d\n" , pid );
143+ return false;
144+ }
145+ return true;
146+ #elif defined(PTRACE_GETREGS_REQ )
147+ if (ptrace (PTRACE_GETREGS_REQ , pid , NULL , user ) < 0 ) {
143148 print_debug ("ptrace(PTRACE_GETREGS, ...) failed for lwp(%d) errno(%d) \"%s\"\n" , pid ,
144149 errno , strerror (errno ));
145150 return false;
146151 }
147152 return true;
148- #elif defined(PTRACE_GETREGSET )
149- struct iovec iov ;
150- iov .iov_base = user ;
151- iov .iov_len = sizeof (* user );
152- if (ptrace (PTRACE_GETREGSET , pid , NT_PRSTATUS , (void * ) & iov ) < 0 ) {
153- print_debug ("ptrace(PTRACE_GETREGSET, ...) failed for lwp %d\n" , pid );
154- return false;
155- }
156- return true;
157153#else
158154 print_debug ("ptrace(PTRACE_GETREGS, ...) not supported\n" );
159155 return false;
0 commit comments