aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMike Frysinger <vapier@gentoo.org>2015-12-20 06:06:45 -0500
committerMike Frysinger <vapier@gentoo.org>2015-12-20 06:06:45 -0500
commitd4aff41888c4e8eb71519330ab7621aed3f73da4 (patch)
tree66abe3e09fd7aeb5e572a3d24936fcec2b91bb40 /libsandbox
parentlibsandbox: new arm ptrace port (diff)
downloadsandbox-d4aff41888c4e8eb71519330ab7621aed3f73da4.tar.gz
sandbox-d4aff41888c4e8eb71519330ab7621aed3f73da4.tar.bz2
sandbox-d4aff41888c4e8eb71519330ab7621aed3f73da4.zip
libsandbox: new alpha ptrace port
Signed-off-by: Mike Frysinger <vapier@gentoo.org>
Diffstat (limited to 'libsandbox')
-rw-r--r--libsandbox/trace/linux/alpha.c58
-rw-r--r--libsandbox/trace/linux/arch.c2
2 files changed, 60 insertions, 0 deletions
diff --git a/libsandbox/trace/linux/alpha.c b/libsandbox/trace/linux/alpha.c
new file mode 100644
index 0000000..4aa6cd6
--- /dev/null
+++ b/libsandbox/trace/linux/alpha.c
@@ -0,0 +1,58 @@
+#define REG_R0 0
+#define REG_A0 16
+
+#define trace_reg_sysnum r0
+
+static unsigned long trace_arg(void *vregs, int num)
+{
+ trace_regs *regs = vregs;
+ if (num < 7)
+ return *(&regs->r16 + num - 1);
+ else
+ return -1;
+}
+
+static long do_peekuser(long offset)
+{
+ return do_ptrace(PTRACE_PEEKUSER, (void *)offset, NULL);
+}
+
+static long do_pokeuser(long offset, long val)
+{
+ return do_ptrace(PTRACE_POKEUSER, (void *)offset, (void *)val);
+}
+
+#undef trace_get_regs
+static long trace_get_regs(void *vregs)
+{
+ trace_regs *regs = vregs;
+ size_t i;
+ regs->r0 = do_peekuser(REG_R0);
+ for (i = 0; i < 7; ++i)
+ *(&regs->r16 + i) = do_peekuser(REG_A0 + i);
+ return 0;
+}
+
+#undef trace_set_regs
+static long trace_set_regs(void *vregs)
+{
+ trace_regs *regs = vregs;
+ size_t i;
+ do_pokeuser(REG_R0, regs->r0);
+ for (i = 0; i < 7; ++i)
+ do_pokeuser(REG_A0 + i, *(&regs->r16 + i));
+ return 0;
+}
+
+static long trace_raw_ret(void *vregs)
+{
+ trace_regs *regs = vregs;
+ return regs->r16;
+}
+
+static void trace_set_ret(void *vregs, int err)
+{
+ trace_regs *regs = vregs;
+ regs->r0 = -err;
+ trace_set_regs(regs);
+}
diff --git a/libsandbox/trace/linux/arch.c b/libsandbox/trace/linux/arch.c
index 83b6977..1515abe 100644
--- a/libsandbox/trace/linux/arch.c
+++ b/libsandbox/trace/linux/arch.c
@@ -7,6 +7,8 @@
#if !defined(HAVE_PTRACE) || !defined(HAVE_SYS_PTRACE_H) || \
!defined(HAVE_SYS_USER_H) || !defined(PTRACE_SETOPTIONS)
# define SB_NO_TRACE_ARCH
+#elif defined(__alpha__)
+# include "alpha.c"
#elif defined(__arm__)
# include "arm.c"
#elif defined(__bfin__)