-/* Use PTRACE_GETREGS and PTRACE_SETREGS when available. This is useful for
+/*
+ * Use PTRACE_GETREGS and PTRACE_SETREGS when available. This is useful for
* architectures without HAVE_ARCH_TRACEHOOK (e.g. User-mode Linux).
*/
#if defined(__x86_64__) || defined(__i386__) || defined(__mips__)
* architectures without HAVE_ARCH_TRACEHOOK (e.g. User-mode Linux).
*/
#if defined(__x86_64__) || defined(__i386__) || defined(__mips__)
+# define ARCH_GETREGS(_regs) ptrace(PTRACE_GETREGS, tracee, 0, &(_regs))
+# define ARCH_SETREGS(_regs) ptrace(PTRACE_SETREGS, tracee, 0, &(_regs))
#endif
/* Architecture-specific syscall fetching routine. */
int get_syscall(struct __test_metadata *_metadata, pid_t tracee)
{
ARCH_REGS regs;
#endif
/* Architecture-specific syscall fetching routine. */
int get_syscall(struct __test_metadata *_metadata, pid_t tracee)
{
ARCH_REGS regs;
-#ifdef HAVE_GETREGS
- EXPECT_EQ(0, ptrace(PTRACE_GETREGS, tracee, 0, ®s)) {
- TH_LOG("PTRACE_GETREGS failed");
+#ifdef ARCH_GETREGS
+ EXPECT_EQ(0, ARCH_GETREGS(regs)) {
void change_syscall(struct __test_metadata *_metadata,
pid_t tracee, int syscall, int result)
{
void change_syscall(struct __test_metadata *_metadata,
pid_t tracee, int syscall, int result)
{
-#ifdef HAVE_GETREGS
- ret = ptrace(PTRACE_GETREGS, tracee, 0, ®s);
+#ifdef ARCH_GETREGS
+ EXPECT_EQ(0, ARCH_GETREGS(regs)) {
+ return;
+ }
struct iovec iov;
iov.iov_base = ®s;
iov.iov_len = sizeof(regs);
ret = ptrace(PTRACE_GETREGSET, tracee, NT_PRSTATUS, &iov);
struct iovec iov;
iov.iov_base = ®s;
iov.iov_len = sizeof(regs);
ret = ptrace(PTRACE_GETREGSET, tracee, NT_PRSTATUS, &iov);
SYSCALL_NUM_SET(regs, syscall);
SYSCALL_NUM_SET(regs, syscall);
#endif
/* Flush any register changes made. */
#endif
/* Flush any register changes made. */
-#ifdef HAVE_GETREGS
- ret = ptrace(PTRACE_SETREGS, tracee, 0, ®s);
+#ifdef ARCH_SETREGS
+ EXPECT_EQ(0, ARCH_SETREGS(regs));
#else
iov.iov_base = ®s;
iov.iov_len = sizeof(regs);
ret = ptrace(PTRACE_SETREGSET, tracee, NT_PRSTATUS, &iov);
#else
iov.iov_base = ®s;
iov.iov_len = sizeof(regs);
ret = ptrace(PTRACE_SETREGSET, tracee, NT_PRSTATUS, &iov);
}
void tracer_seccomp(struct __test_metadata *_metadata, pid_t tracee,
}
void tracer_seccomp(struct __test_metadata *_metadata, pid_t tracee,