Deprecate `ptrace`.
@@ -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
}
}
