diff --git a/src/sys/ptrace/bsd.rs b/src/sys/ptrace/bsd.rs index 5528115304..551e99535d 100644 --- a/src/sys/ptrace/bsd.rs +++ b/src/sys/ptrace/bsd.rs @@ -75,6 +75,21 @@ pub fn traceme() -> Result<()> { unsafe { ptrace_other(Request::PT_TRACE_ME, Pid::from_raw(0), ptr::null_mut(), 0).map(drop) } } +/// Ask for next syscall, as with `ptrace(PT_SYSCALL, ...)` +/// +/// Arranges for the tracee to be stopped at the next entry to or exit from a system call, +/// optionally delivering a signal specified by `sig`. +pub fn syscall>>(pid: Pid, sig: T) -> Result<()> { + let data = match sig.into() { + Some(s) => s as c_int, + None => 0, + }; + unsafe { + // Ignore the useless return value + ptrace_other(Request::PT_SYSCALL, pid, 1 as AddressType, data).map(drop) + } +} + /// Attach to a running process, as with `ptrace(PT_ATTACH, ...)` /// /// Attaches to the process specified in pid, making it a tracee of the calling process.