diff --git a/src/arch/mod.rs b/src/arch/mod.rs index 74ed19b..c380451 100644 --- a/src/arch/mod.rs +++ b/src/arch/mod.rs @@ -98,9 +98,7 @@ pub fn read_bytes<'a>(pid: Pid, address: c_ulonglong, length: usize) -> Vec pub fn ptrace_init_options(pid: Pid) -> nix::Result<()> { ptrace::setoptions( pid, - Options::PTRACE_O_TRACESYSGOOD - | Options::PTRACE_O_TRACEEXIT - | Options::PTRACE_O_TRACEEXEC, + Options::PTRACE_O_TRACESYSGOOD | Options::PTRACE_O_TRACEEXIT | Options::PTRACE_O_TRACEEXEC, ) } @@ -164,4 +162,4 @@ pub fn escape_to_string(buf: &Vec) -> String { } } string -} \ No newline at end of file +} diff --git a/src/arch/x86_64.rs b/src/arch/x86_64.rs index 302cb2d..52ce593 100644 --- a/src/arch/x86_64.rs +++ b/src/arch/x86_64.rs @@ -1008,7 +1008,7 @@ pub static SYSCALLS: [Option<(Sysno, [Option; 6])>; 452] = [ syscall!(process_mrelease, INT, INT), syscall!(futex_waitv, ADDR, INT, INT, ADDR, INT), syscall!(set_mempolicy_home_node, INT, INT, INT, INT), - syscall!(cachestat, INT, INT, INT, INT) + syscall!(cachestat, INT, INT, INT, INT), ]; pub fn get_arg_value(registers: user_regs_struct, i: usize) -> c_ulonglong { diff --git a/src/lib.rs b/src/lib.rs index 045c0bf..6e343a2 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -202,7 +202,11 @@ impl Tracer { WaitStatus::Exited(pid, _) => { // If the process that exits is the original tracee, we can safely break here, // but we need to continue if the process that exits is a child of the original tracee. - if self.pid == pid { break } else { continue }; + if self.pid == pid { + break; + } else { + continue; + }; } // The traced process was stopped by a `PTRACE_EVENT_*` event. WaitStatus::PtraceEvent(pid, _, code) => { @@ -292,7 +296,9 @@ impl Tracer { self.syscalls_pass.get(sysno), self.syscalls_fail.get(sysno), self.syscalls_time.get(sysno), - ) else { continue }; + ) else { + continue; + }; let calls = pass + fail; if calls == 0 { @@ -414,26 +420,18 @@ impl Tracer { // Issue a PTRACE_SYSCALL request to the tracee, forwarding a signal if one is provided. fn issue_ptrace_syscall_request(&self, pid: Pid, signal: Option) -> Result<()> { - ptrace::syscall(pid, signal).map_err(|_| - anyhow!( - "Unable to issue a PTRACE_SYSCALL request in tracee {}", - pid - ) - ) + ptrace::syscall(pid, signal) + .map_err(|_| anyhow!("Unable to issue a PTRACE_SYSCALL request in tracee {}", pid)) } // TODO: This is arch-specific code and should be modularized fn get_registers(&self, pid: Pid) -> Result { - ptrace::getregs(pid).map_err(|_| - anyhow!( - "Unable to get registers from tracee {}", - pid - ) - ) + ptrace::getregs(pid).map_err(|_| anyhow!("Unable to get registers from tracee {}", pid)) } fn get_syscall(&self, registers: user_regs_struct) -> Result { - (registers.orig_rax as u32).try_into() + (registers.orig_rax as u32) + .try_into() .map_err(|_| anyhow!("Invalid syscall number {}", registers.orig_rax)) } @@ -447,7 +445,8 @@ impl Tracer { fn is_exit_syscall(&self, pid: Pid) -> Result { self.get_registers(pid).map(|registers| { - registers.orig_rax == Sysno::exit as u64 || registers.orig_rax == Sysno::exit_group as u64 + registers.orig_rax == Sysno::exit as u64 + || registers.orig_rax == Sysno::exit_group as u64 }) } }