+2016-07-26 Pedro Alves <palves@redhat.com>
+
+ * nat/linux-ptrace.c: Include "gregset.h".
+ (linux_ptrace_test_ret_to_nx): Use PTRACE_GETREGS instead of
+ PTRACE_PEEKUSER.
+
2016-07-26 Pedro Alves <palves@redhat.com>
* amd64-linux-nat.c (amd64_linux_siginfo_fixup): Rename 'native'
#include "buffer.h"
#include "gdb_wait.h"
#include "gdb_ptrace.h"
+#include "gregset.h"
/* Stores the ptrace options supported by the running kernel.
A value of -1 means we did not check for features yet. A value
gdb_byte *return_address, *pc;
long l;
int status, kill_status;
+ elf_gregset_t regs;
return_address
= (gdb_byte *) mmap (NULL, 2, PROT_READ | PROT_WRITE,
return;
}
- errno = 0;
+ if (ptrace (PTRACE_GETREGS, child, (PTRACE_TYPE_ARG3) 0,
+ (PTRACE_TYPE_ARG4) ®s) < 0)
+ {
+ warning (_("linux_ptrace_test_ret_to_nx: Cannot PTRACE_GETREGS: %s"),
+ safe_strerror (errno));
+ }
#if defined __i386__
- l = ptrace (PTRACE_PEEKUSER, child, (PTRACE_TYPE_ARG3) (uintptr_t) (EIP * 4),
- (PTRACE_TYPE_ARG4) NULL);
+ pc = (gdb_byte *) (uintptr_t) regs[EIP];
#elif defined __x86_64__
- l = ptrace (PTRACE_PEEKUSER, child, (PTRACE_TYPE_ARG3) (uintptr_t) (RIP * 8),
- (PTRACE_TYPE_ARG4) NULL);
+ pc = (gdb_byte *) (uintptr_t) regs[RIP];
#else
# error "!__i386__ && !__x86_64__"
#endif
- if (errno != 0)
- {
- warning (_("linux_ptrace_test_ret_to_nx: Cannot PTRACE_PEEKUSER: %s"),
- safe_strerror (errno));
- return;
- }
- pc = (gdb_byte *) (uintptr_t) l;
kill (child, SIGKILL);
ptrace (PTRACE_KILL, child, (PTRACE_TYPE_ARG3) NULL,