diff --git a/src/jdk.hotspot.agent/linux/native/libsaproc/ps_proc.c b/src/jdk.hotspot.agent/linux/native/libsaproc/ps_proc.c index b5fec835a98..1101b999961 100644 --- a/src/jdk.hotspot.agent/linux/native/libsaproc/ps_proc.c +++ b/src/jdk.hotspot.agent/linux/native/libsaproc/ps_proc.c @@ -125,10 +125,6 @@ static bool process_write_data(struct ps_prochandle* ph, static bool process_get_lwp_regs(struct ps_prochandle* ph, pid_t pid, struct user_regs_struct *user) { // we have already attached to all thread 'pid's, just use ptrace call // to get regset now. Note that we don't cache regset upfront for processes. -// Linux on x86 and sparc are different. On x86 ptrace(PTRACE_GETREGS, ...) -// uses pointer from 4th argument and ignores 3rd argument. On sparc it uses -// pointer from 3rd argument and ignores 4th argument -#define ptrace_getregs(request, pid, addr, data) ptrace(request, pid, data, addr) #if defined(_LP64) && defined(PTRACE_GETREGS64) #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 #define PTRACE_GETREGS_REQ PT_GETREGS #endif -#ifdef PTRACE_GETREGS_REQ - if (ptrace_getregs(PTRACE_GETREGS_REQ, pid, user, NULL) < 0) { +#if defined(PTRACE_GETREGSET) + struct iovec iov; + iov.iov_base = user; + iov.iov_len = sizeof(*user); + if (ptrace(PTRACE_GETREGSET, pid, NT_PRSTATUS, (void*) &iov) < 0) { + print_debug("ptrace(PTRACE_GETREGSET, ...) failed for lwp %d\n", pid); + return false; + } + return true; +#elif defined(PTRACE_GETREGS_REQ) + if (ptrace(PTRACE_GETREGS_REQ, pid, NULL, user) < 0) { print_debug("ptrace(PTRACE_GETREGS, ...) failed for lwp(%d) errno(%d) \"%s\"\n", pid, errno, strerror(errno)); return false; } return true; -#elif defined(PTRACE_GETREGSET) - struct iovec iov; - iov.iov_base = user; - iov.iov_len = sizeof(*user); - if (ptrace(PTRACE_GETREGSET, pid, NT_PRSTATUS, (void*) &iov) < 0) { - print_debug("ptrace(PTRACE_GETREGSET, ...) failed for lwp %d\n", pid); - return false; - } - return true; #else print_debug("ptrace(PTRACE_GETREGS, ...) not supported\n"); return false;