summaryrefslogtreecommitdiff
path: root/src/sys/ptrace.rs
diff options
context:
space:
mode:
authorBryant Mairs <bryant@mai.rs>2017-07-17 16:12:40 -0700
committerBryant Mairs <bryant@mai.rs>2017-07-17 16:12:40 -0700
commit73ae9e012e65f631dd96f45cf7d25de678958600 (patch)
tree7d8bdcbe74f57b542a5285bc2b56836320ea8d30 /src/sys/ptrace.rs
parent5d296505b597d29bf6b339904f7f1550febe863d (diff)
downloadnix-73ae9e012e65f631dd96f45cf7d25de678958600.zip
Fix UnsupportedOperation when using ptrace_* functions
Diffstat (limited to 'src/sys/ptrace.rs')
-rw-r--r--src/sys/ptrace.rs10
1 files changed, 6 insertions, 4 deletions
diff --git a/src/sys/ptrace.rs b/src/sys/ptrace.rs
index bf395259..4c3d29b1 100644
--- a/src/sys/ptrace.rs
+++ b/src/sys/ptrace.rs
@@ -91,15 +91,16 @@ fn ptrace_peek(request: ptrace::PtraceRequest, pid: Pid, addr: *mut c_void, data
}
}
-/// Function for ptrace requests that return values from the data field.
+/// Function for ptrace requests that return values from the data field.
/// Some ptrace get requests populate structs or larger elements than c_long
/// and therefore use the data field to return values. This function handles these
/// requests.
fn ptrace_get_data<T>(request: ptrace::PtraceRequest, pid: Pid) -> Result<T> {
- // Creates an uninitialized pointer to store result in
+ // Creates an uninitialized pointer to store result in
let data: Box<T> = Box::new(unsafe { mem::uninitialized() });
let data: *mut c_void = unsafe { mem::transmute(data) };
- ptrace(request, pid, ptr::null_mut(), data)?;
+ let res = unsafe { ffi::ptrace(request, pid.into(), ptr::null_mut(), data) };
+ Errno::result(res)?;
// Convert back into the original data format and return unboxed value
let data: Box<T> = unsafe { mem::transmute(data) };
Ok(*data)
@@ -114,7 +115,8 @@ pub fn ptrace_setoptions(pid: Pid, options: ptrace::PtraceOptions) -> Result<()>
use self::ptrace::*;
use std::ptr;
- ptrace(PTRACE_SETOPTIONS, pid, ptr::null_mut(), options as *mut c_void).map(drop)
+ let res = unsafe { ffi::ptrace(PTRACE_SETOPTIONS, pid.into(), ptr::null_mut(), options as *mut c_void) };
+ Errno::result(res).map(|_| ())
}
/// Gets a ptrace event as described by `ptrace(PTRACE_GETEVENTMSG,...)`