diff options
author | xd009642 <danielmckenna93@gmail.com> | 2018-01-30 17:37:42 +0000 |
---|---|---|
committer | xd009642 <danielmckenna93@gmail.com> | 2018-01-30 17:37:42 +0000 |
commit | 254849621d36b1404f9b393f74f040a912bc6909 (patch) | |
tree | 2a917d0cf2226faae2bc81e7960379ff104be9f3 /src/sys | |
parent | 899eff72f92cbc300fbd7779957907a39aa0e42b (diff) | |
download | nix-254849621d36b1404f9b393f74f040a912bc6909.zip |
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!
Diffstat (limited to 'src/sys')
-rw-r--r-- | src/sys/ptrace.rs | 14 |
1 files changed, 14 insertions, 0 deletions
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<T: Into<Option<Signal>>>(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<T: Into<Option<Signal>>>(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(|_| ()) + } +} |