aboutsummaryrefslogtreecommitdiffstats
path: root/sctrace.c
diff options
context:
space:
mode:
authorMattias Andrée <maandree@kth.se>2020-06-02 14:44:08 +0200
committerMattias Andrée <maandree@kth.se>2020-06-02 14:44:08 +0200
commit7198c7b9f01bbd5e8f8528440d290569e588b260 (patch)
treec4bbeb956b37965d589ffe3c0b4dbde94e0ccaca /sctrace.c
parentReject i386 and x32 applications (not yet supported) (diff)
downloadsctrace-7198c7b9f01bbd5e8f8528440d290569e588b260.tar.gz
sctrace-7198c7b9f01bbd5e8f8528440d290569e588b260.tar.bz2
sctrace-7198c7b9f01bbd5e8f8528440d290569e588b260.tar.xz
Some cleanup and preparation for support for multiple architectures (both host and client) and OSes
Signed-off-by: Mattias Andrée <maandree@kth.se>
Diffstat (limited to 'sctrace.c')
-rw-r--r--sctrace.c29
1 files changed, 6 insertions, 23 deletions
diff --git a/sctrace.c b/sctrace.c
index 9bab8ff..3d2669a 100644
--- a/sctrace.c
+++ b/sctrace.c
@@ -18,10 +18,6 @@ static void
handle_syscall(struct process *proc)
{
struct user_regs_struct regs;
- struct iovec iov = {
- .iov_base = &regs,
- .iov_len = sizeof(regs),
- };
switch ((int)proc->state) {
default:
@@ -29,24 +25,11 @@ handle_syscall(struct process *proc)
if (ptrace(PTRACE_GETREGS, proc->pid, NULL, &regs))
eprintf("ptrace PTRACE_GETREGS %ju NULL <buffer>:", (uintmax_t)proc->pid);
proc->scall = regs.SYSCALL_NUM_REG;
- proc->args[0] = regs.SYSCALL_ARG1_REG;
- proc->args[1] = regs.SYSCALL_ARG2_REG;
- proc->args[2] = regs.SYSCALL_ARG3_REG;
- proc->args[3] = regs.SYSCALL_ARG4_REG;
- proc->args[4] = regs.SYSCALL_ARG5_REG;
- proc->args[5] = regs.SYSCALL_ARG6_REG;
-
- /* Check architecture */
- if (ptrace(PTRACE_GETREGSET, proc->pid, NT_PRSTATUS, &iov)) {
- eprintf("ptrace PTRACE_GETREGSET %ju NT_PRSTATUS {.iov_base=<buffer>, .iov_len=%zu}:",
- (uintmax_t)proc->pid, sizeof(regs));
- } else if (iov.iov_len != sizeof(regs)) {
- tprintf(proc, "Process is running as i386, this is not yet supported\n");
- exit(1);
- } else if (proc->scall & __X32_SYSCALL_BIT) {
- tprintf(proc, "Process is running as x32, this is not yet supported\n");
- exit(1);
- }
+#ifdef CHECK_ARCHITECTURE
+ CHECK_ARCHITECTURE(proc, &regs);
+ proc->scall ^= proc->scall_xor;
+#endif
+ GET_SYSCALL_ARGUMENTS(proc, &regs);
/* Print system call */
print_systemcall(proc);
@@ -115,7 +98,7 @@ handle_event(struct process *proc, int status)
struct process *proc2;
sig = WSTOPSIG(status);
- trace_event = ((status >> 8) ^ SIGTRAP) >> 8;
+ trace_event = status >> 16;
switch (trace_event) {
case PTRACE_EVENT_VFORK: