diff options
author | Marcin Mielniczuk <marmistrz.dev@zoho.eu> | 2017-08-10 10:13:28 +0200 |
---|---|---|
committer | Marcin Mielniczuk <marmistrz.dev@zoho.eu> | 2017-08-10 10:13:28 +0200 |
commit | 0587977055a89673e1e34baab008e6b03831f15a (patch) | |
tree | 3648d98e1173f05d03c8c0fb0df05bf4e29daa95 /src | |
parent | ebcedb3bf98271fb77752acaec7a5c4990db578c (diff) | |
download | nix-0587977055a89673e1e34baab008e6b03831f15a.zip |
Deprecate `ptrace`.
Diffstat (limited to 'src')
-rw-r--r-- | src/sys/ptrace.rs | 17 |
1 files changed, 11 insertions, 6 deletions
diff --git a/src/sys/ptrace.rs b/src/sys/ptrace.rs index b6c64362..54d4667d 100644 --- a/src/sys/ptrace.rs +++ b/src/sys/ptrace.rs @@ -73,6 +73,10 @@ mod ffi { /// Performs a ptrace request. If the request in question is provided by a specialised function /// this function will return an unsupported operation error. +#[deprecated( + since="0.10.0", + note="usages of `ptrace()` should be replaced with the specialized helper functions instead" +)] pub unsafe fn ptrace(request: ptrace::PtraceRequest, pid: Pid, addr: *mut c_void, data: *mut c_void) -> Result<c_long> { use self::ptrace::*; @@ -106,8 +110,9 @@ fn ptrace_get_data<T>(request: ptrace::PtraceRequest, pid: Pid) -> Result<T> { Ok(data) } -fn ptrace_other(request: ptrace::PtraceRequest, pid: Pid, addr: *mut c_void, data: *mut c_void) -> Result<c_long> { - Errno::result(unsafe { ffi::ptrace(request, pid.into(), addr, data) }).map(|_| 0) +/// Performs a general ptrace request. +unsafe fn ptrace_other(request: ptrace::PtraceRequest, pid: Pid, addr: *mut c_void, data: *mut c_void) -> Result<c_long> { + Errno::result(ffi::ptrace(request, pid.into(), addr, data)).map(|_| 0) } /// Set options, as with `ptrace(PTRACE_SETOPTIONS,...)`. @@ -150,7 +155,7 @@ pub fn setsiginfo(pid: Pid, sig: &siginfo_t) -> Result<()> { /// This is the only ptrace request to be issued by the tracee. pub fn traceme() -> Result<()> { unsafe { - ptrace( + ptrace_other( ptrace::PTRACE_TRACEME, Pid::from_raw(0), ptr::null_mut(), @@ -164,7 +169,7 @@ pub fn traceme() -> Result<()> { /// Arranges for the tracee to be stopped at the next entry to or exit from a system call. pub fn syscall(pid: Pid) -> Result<()> { unsafe { - ptrace( + ptrace_other( ptrace::PTRACE_SYSCALL, pid, ptr::null_mut(), @@ -178,7 +183,7 @@ pub fn syscall(pid: Pid) -> Result<()> { /// Attaches to the process specified in pid, making it a tracee of the calling process. pub fn attach(pid: Pid) -> Result<()> { unsafe { - ptrace( + ptrace_other( ptrace::PTRACE_ATTACH, pid, ptr::null_mut(), @@ -197,7 +202,7 @@ pub fn cont<T: Into<Option<Signal>>>(pid: Pid, sig: T) -> Result<()> { None => ptr::null_mut(), }; unsafe { - ptrace(ptrace::PTRACE_CONT, pid, ptr::null_mut(), data).map(|_| ()) // ignore the useless return value + ptrace_other(ptrace::PTRACE_CONT, pid, ptr::null_mut(), data).map(|_| ()) // ignore the useless return value } } |