#define ARCH_REGS_FOR_GETREGS i386_regs
#define ARCH_PC_REG i386_regs.eip
#define ARCH_SP_REG i386_regs.esp
+
+#undef ARCH_MIGHT_USE_SET_REGS
+#define ARCH_MIGHT_USE_SET_REGS 0
arch_set_error(struct tcb *tcp)
{
i386_regs.eax = -tcp->u_error;
-#ifdef HAVE_GETREGS_OLD
return upoke(tcp, 4 * EAX, i386_regs.eax);
-#else
- return set_regs(tcp->pid);
-#endif
}
static int
arch_set_success(struct tcb *tcp)
{
i386_regs.eax = tcp->u_rval;
-#ifdef HAVE_GETREGS_OLD
return upoke(tcp, 4 * EAX, i386_regs.eax);
-#else
- return set_regs(tcp->pid);
-#endif
}
static int
arch_set_scno(struct tcb *tcp, kernel_ulong_t scno)
{
-#ifdef HAVE_GETREGS_OLD
return upoke(tcp, 4 * ORIG_EAX, scno);
-#else
- i386_regs.orig_eax = scno;
- return set_regs(tcp->pid);
-#endif
}
#define ARCH_REGS_FOR_GETREGS ppc_regs
#define ARCH_PC_REG ppc_regs.nip
#define ARCH_SP_REG ppc_regs.gpr[1]
+
+#undef ARCH_MIGHT_USE_SET_REGS
+#define ARCH_MIGHT_USE_SET_REGS 0
{
ppc_regs.gpr[3] = tcp->u_error;
ppc_regs.ccr |= 0x10000000;
-#ifdef HAVE_GETREGS_OLD
return upoke(tcp, sizeof(long) * PT_CCR, ppc_regs.ccr) ||
upoke(tcp, sizeof(long) * (PT_R0 + 3), ppc_regs.gpr[3]);
-#else
- return set_regs(tcp->pid);
-#endif
}
static int
{
ppc_regs.gpr[3] = tcp->u_rval;
ppc_regs.ccr &= ~0x10000000;
-#ifdef HAVE_GETREGS_OLD
return upoke(tcp, sizeof(long) * PT_CCR, ppc_regs.ccr) ||
upoke(tcp, sizeof(long) * (PT_R0 + 3), ppc_regs.gpr[3]);
-#else
- return set_regs(tcp->pid);
-#endif
}
static int
arch_set_scno(struct tcb *tcp, kernel_ulong_t scno)
{
-#ifdef HAVE_GETREGS_OLD
return upoke(tcp, sizeof(long) * PT_R0, scno);
-#else
- ppc_regs.gpr[0] = scno;
- return set_regs(tcp->pid);
-#endif
}
(x86_io.iov_len == sizeof(i386_regs) ? i386_regs.eip : x86_64_regs.rip)
#define ARCH_SP_REG \
(x86_io.iov_len == sizeof(i386_regs) ? i386_regs.esp : x86_64_regs.rsp)
+
+#undef ARCH_MIGHT_USE_SET_REGS
+#define ARCH_MIGHT_USE_SET_REGS 0
-#ifndef HAVE_GETREGS_OLD
-# define arch_set_error i386_set_error
-# define arch_set_success i386_set_success
-# include "i386/set_error.c"
-# undef arch_set_success
-# undef arch_set_error
-#endif /* !HAVE_GETREGS_OLD */
-
static int
arch_set_error(struct tcb *tcp)
{
-#ifdef HAVE_GETREGS_OLD
- kernel_ulong_t rval = -(kernel_long_t) tcp->u_error;
+ kernel_ulong_t rval = -(long) tcp->u_error;
- if (x86_io.iov_len == sizeof(i386_regs))
+ if (tcp->currpers == 1)
i386_regs.eax = rval;
else
x86_64_regs.rax = rval;
return upoke(tcp, 8 * RAX, rval);
-#else
- if (x86_io.iov_len == sizeof(i386_regs))
- return i386_set_error(tcp);
-
- x86_64_regs.rax = -(kernel_long_t) tcp->u_error;
- return set_regs(tcp->pid);
-#endif
}
static int
arch_set_success(struct tcb *tcp)
{
-#ifdef HAVE_GETREGS_OLD
kernel_ulong_t rval = (kernel_ulong_t) tcp->u_rval;
- if (x86_io.iov_len == sizeof(i386_regs))
+ if (tcp->currpers == 1)
i386_regs.eax = rval;
else
x86_64_regs.rax = rval;
return upoke(tcp, 8 * RAX, rval);
-#else
- if (x86_io.iov_len == sizeof(i386_regs))
- return i386_set_success(tcp);
-
- x86_64_regs.rax = (kernel_ulong_t) tcp->u_rval;
- return set_regs(tcp->pid);
-#endif
}
-#ifndef HAVE_GETREGS_OLD
-# define arch_set_scno i386_set_scno
-# include "i386/set_scno.c"
-# undef arch_set_scno
-#endif /* !HAVE_GETREGS_OLD */
-
static int
arch_set_scno(struct tcb *tcp, kernel_ulong_t scno)
{
-#ifdef HAVE_GETREGS_OLD
return upoke(tcp, 8 * ORIG_RAX, scno);
-#else
- if (x86_io.iov_len == sizeof(i386_regs))
- return i386_set_scno(tcp, scno);
-
- x86_64_regs.orig_rax = scno;
- return set_regs(tcp->pid);
-#endif
}
# include "xlat/nt_descriptor_types.h"
#undef XLAT_MACROS_ONLY
+#define ARCH_MIGHT_USE_SET_REGS 1
#include "arch_regs.c"
#if HAVE_ARCH_GETRVAL2
#endif
#include "getregs_old.h"
+#ifdef HAVE_GETREGS_OLD
+/* Either getregs_old() or set_regs() */
+# undef ARCH_MIGHT_USE_SET_REGS
+# define ARCH_MIGHT_USE_SET_REGS 0
+#endif
#undef ptrace_getregset_or_getregs
#undef ptrace_setregset_or_setregs
# endif
}
-# ifndef HAVE_GETREGS_OLD
+# if ARCH_MIGHT_USE_SET_REGS
# define ptrace_setregset_or_setregs ptrace_setregset
static int
ptrace_setregset(pid_t pid)
return ptrace(PTRACE_SETREGSET, pid, NT_PRSTATUS, &io);
# endif
}
-# endif /* !HAVE_GETREGS_OLD */
+# endif /* ARCH_MIGHT_USE_SET_REGS */
#elif defined ARCH_REGS_FOR_GETREGS
# endif
}
-# ifndef HAVE_GETREGS_OLD
+# if ARCH_MIGHT_USE_SET_REGS
# define ptrace_setregset_or_setregs ptrace_setregs
static int
ptrace_setregs(pid_t pid)
return ptrace(PTRACE_SETREGS, pid, NULL, &ARCH_REGS_FOR_GETREGS);
# endif
}
-# endif /* !HAVE_GETREGS_OLD */
+# endif /* ARCH_MIGHT_USE_SET_REGS */
#endif /* ARCH_REGS_FOR_GETREGSET || ARCH_REGS_FOR_GETREGS */