diff options
author | Mattias Andrée <maandree@kth.se> | 2020-06-02 14:44:08 +0200 |
---|---|---|
committer | Mattias Andrée <maandree@kth.se> | 2020-06-02 14:44:08 +0200 |
commit | 7198c7b9f01bbd5e8f8528440d290569e588b260 (patch) | |
tree | c4bbeb956b37965d589ffe3c0b4dbde94e0ccaca /sctrace.c | |
parent | Reject i386 and x32 applications (not yet supported) (diff) | |
download | sctrace-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.c | 29 |
1 files changed, 6 insertions, 23 deletions
@@ -18,10 +18,6 @@ static void handle_syscall(struct process *proc) { struct user_regs_struct regs; - struct iovec iov = { - .iov_base = ®s, - .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, ®s)) 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, ®s); + proc->scall ^= proc->scall_xor; +#endif + GET_SYSCALL_ARGUMENTS(proc, ®s); /* 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: |