[PATCH] m68k: switch to PTRACE_GETREGS
Andreas Schwab
schwab at linux-m68k.org
Sat Nov 12 19:02:23 UTC 2016
* Makefile.am (EXTRA_DIST): Add linux/m68k/arch_regs.h, remove
linux/m68k/get_syscall_result.c.
* linux/m68k/arch_regs.c (m68k_d0, ARCH_PC_PEEK_ADDR): Don't
define.
(m68k_regs, m68k_usp_ptr, ARCH_PC_REG, ARCH_REGS_FOR_GETREGS):
Define.
* linux/m68k/arch_regs.h: New file.
* linux/m68k/arch_sigreturn.c (arch_sigreturn): Use m68k_usp_ptr.
* linux/m68k/get_error.c (get_error): Use m68k_regs.d0.
* linux/m68k/get_scno.c (arch_get_scno): Use m68k_regs.orig_d0.
* linux/m68k/get_syscall_args.c (get_syscall_args): Use m68k_regs.
* linux/m68k/get_syscall_result.c: Remove.
---
Makefile.am | 2 +-
linux/m68k/arch_regs.c | 6 ++++--
linux/m68k/arch_regs.h | 1 +
linux/m68k/arch_sigreturn.c | 4 +---
linux/m68k/get_error.c | 6 +++---
linux/m68k/get_scno.c | 3 ++-
linux/m68k/get_syscall_args.c | 11 ++++++-----
linux/m68k/get_syscall_result.c | 5 -----
8 files changed, 18 insertions(+), 20 deletions(-)
create mode 100644 linux/m68k/arch_regs.h
delete mode 100644 linux/m68k/get_syscall_result.c
diff --git a/Makefile.am b/Makefile.am
index c44231bcde..f4dbf8387f 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -415,11 +415,11 @@ EXTRA_DIST = \
linux/ia64/userent.h \
linux/inet_diag.h \
linux/m68k/arch_regs.c \
+ linux/m68k/arch_regs.h \
linux/m68k/arch_sigreturn.c \
linux/m68k/get_error.c \
linux/m68k/get_scno.c \
linux/m68k/get_syscall_args.c \
- linux/m68k/get_syscall_result.c \
linux/m68k/ioctls_arch0.h \
linux/m68k/ioctls_inc0.h \
linux/m68k/syscallent.h \
diff --git a/linux/m68k/arch_regs.c b/linux/m68k/arch_regs.c
index 8f0ab79ad6..1198762b07 100644
--- a/linux/m68k/arch_regs.c
+++ b/linux/m68k/arch_regs.c
@@ -1,2 +1,4 @@
-static long m68k_d0;
-#define ARCH_PC_PEEK_ADDR (4 * PT_PC)
+static struct user_regs_struct m68k_regs;
+long *const m68k_usp_ptr = &m68k_regs.usp;
+#define ARCH_PC_REG m68k_regs.pc
+#define ARCH_REGS_FOR_GETREGS m68k_regs
diff --git a/linux/m68k/arch_regs.h b/linux/m68k/arch_regs.h
new file mode 100644
index 0000000000..08293365e3
--- /dev/null
+++ b/linux/m68k/arch_regs.h
@@ -0,0 +1 @@
+extern long *const m68k_usp_ptr;
diff --git a/linux/m68k/arch_sigreturn.c b/linux/m68k/arch_sigreturn.c
index 0011c1748f..12e8bded6d 100644
--- a/linux/m68k/arch_sigreturn.c
+++ b/linux/m68k/arch_sigreturn.c
@@ -3,10 +3,8 @@ arch_sigreturn(struct tcb *tcp)
{
long addr;
- if (upeek(tcp->pid, 4*PT_USP, &addr) < 0)
- return;
/* Fetch pointer to struct sigcontext. */
- if (umove(tcp, addr + 2 * sizeof(int), &addr) < 0)
+ if (umove(tcp, *m68k_usp_ptr + 2 * sizeof(int), &addr) < 0)
return;
unsigned long mask[NSIG / 8 / sizeof(long)];
diff --git a/linux/m68k/get_error.c b/linux/m68k/get_error.c
index a792835d4a..3ad51a08d3 100644
--- a/linux/m68k/get_error.c
+++ b/linux/m68k/get_error.c
@@ -1,10 +1,10 @@
static void
get_error(struct tcb *tcp, const bool check_errno)
{
- if (check_errno && is_negated_errno(m68k_d0)) {
+ if (check_errno && is_negated_errno(m68k_regs.d0)) {
tcp->u_rval = -1;
- tcp->u_error = -m68k_d0;
+ tcp->u_error = -m68k_regs.d0;
} else {
- tcp->u_rval = m68k_d0;
+ tcp->u_rval = m68k_regs.d0;
}
}
diff --git a/linux/m68k/get_scno.c b/linux/m68k/get_scno.c
index 716a761618..829f3477cd 100644
--- a/linux/m68k/get_scno.c
+++ b/linux/m68k/get_scno.c
@@ -2,5 +2,6 @@
static int
arch_get_scno(struct tcb *tcp)
{
- return upeek(tcp->pid, 4 * PT_ORIG_D0, &tcp->scno) < 0 ? -1 : 1;
+ tcp->scno = m68k_regs.orig_d0;
+ return 1;
}
diff --git a/linux/m68k/get_syscall_args.c b/linux/m68k/get_syscall_args.c
index bc69a1957c..8ec3d28165 100644
--- a/linux/m68k/get_syscall_args.c
+++ b/linux/m68k/get_syscall_args.c
@@ -2,10 +2,11 @@
static int
get_syscall_args(struct tcb *tcp)
{
- unsigned int i;
-
- for (i = 0; i < tcp->s_ent->nargs; ++i)
- if (upeek(tcp->pid, (i < 5 ? i : i + 2)*4, &tcp->u_arg[i]) < 0)
- return -1;
+ tcp->u_arg[0] = m68k_regs.d1;
+ tcp->u_arg[1] = m68k_regs.d2;
+ tcp->u_arg[2] = m68k_regs.d3;
+ tcp->u_arg[3] = m68k_regs.d4;
+ tcp->u_arg[4] = m68k_regs.d5;
+ tcp->u_arg[5] = m68k_regs.a0;
return 1;
}
diff --git a/linux/m68k/get_syscall_result.c b/linux/m68k/get_syscall_result.c
deleted file mode 100644
index 005cf60cd7..0000000000
--- a/linux/m68k/get_syscall_result.c
+++ /dev/null
@@ -1,5 +0,0 @@
-static int
-get_syscall_result_regs(struct tcb *tcp)
-{
- return upeek(tcp->pid, 4 * PT_D0, &m68k_d0) < 0 ? -1 : 0;
-}
--
2.10.2
--
Andreas Schwab, schwab at linux-m68k.org
GPG Key fingerprint = 58CA 54C7 6D53 942B 1756 01D3 44D5 214B 8276 4ED5
"And now for something completely different."
More information about the Strace-devel
mailing list