From 254849621d36b1404f9b393f74f040a912bc6909 Mon Sep 17 00:00:00 2001 From: xd009642 Date: Tue, 30 Jan 2018 17:37:42 +0000 Subject: Add step function to ptrace Added step function to ptrace, this follows the same form as the PTRACE_CONTINUE by advanced the tracee by a single step! --- src/sys/ptrace.rs | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 'src/sys') diff --git a/src/sys/ptrace.rs b/src/sys/ptrace.rs index 8fb8f823..22c6f487 100644 --- a/src/sys/ptrace.rs +++ b/src/sys/ptrace.rs @@ -280,3 +280,17 @@ pub fn cont>>(pid: Pid, sig: T) -> Result<()> { } } +/// Move the stopped tracee process forward by a single step as with +/// `ptrace(PTRACE_SINGLESTEP, ...)` +/// +/// Advances the execution of the process with PID `pid` by a single step optionally delivering a +/// single specified by `sig`. +pub fn step>>(pid: Pid, sig: T) -> Result<()> { + let data = match sig.into() { + Some(s) => s as i32 as *mut c_void, + None => ptr::null_mut(), + }; + unsafe { + ptrace_other(Request::PTRACE_SINGLESTEP, pid, ptr::null_mut(), data).map(|_| ()) + } +} -- cgit v1.2.3