From 0587977055a89673e1e34baab008e6b03831f15a Mon Sep 17 00:00:00 2001 From: Marcin Mielniczuk Date: Thu, 10 Aug 2017 10:13:28 +0200 Subject: Deprecate `ptrace`. --- src/sys/ptrace.rs | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) (limited to 'src') 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 { use self::ptrace::*; @@ -106,8 +110,9 @@ fn ptrace_get_data(request: ptrace::PtraceRequest, pid: Pid) -> Result { Ok(data) } -fn ptrace_other(request: ptrace::PtraceRequest, pid: Pid, addr: *mut c_void, data: *mut c_void) -> Result { - 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 { + 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>>(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 } } -- cgit v1.2.3