Skip to content

Commit

Permalink
Merge branch 'master' into acct-api
Browse files Browse the repository at this point in the history
  • Loading branch information
jabedude committed Oct 21, 2018
2 parents 78501aa + 5ffaee2 commit 837d87c
Showing 1 changed file with 18 additions and 1 deletion.
19 changes: 18 additions & 1 deletion src/sys/ptrace.rs
Expand Up @@ -3,7 +3,7 @@
use std::{mem, ptr};
use {Error, Result};
use errno::Errno;
use libc::{self, c_void, c_long, siginfo_t};
use libc::{self, c_void, c_long, siginfo_t, user_regs_struct};
use ::unistd::Pid;
use sys::signal::Signal;

Expand Down Expand Up @@ -229,6 +229,23 @@ pub fn getevent(pid: Pid) -> Result<c_long> {
ptrace_get_data::<c_long>(Request::PTRACE_GETEVENTMSG, pid)
}

/// Gets tracee GP registers as described by `ptrace(PTRACE_GETREGS,...)`
pub fn getregs(pid: Pid) -> Result<user_regs_struct> {
ptrace_get_data::<user_regs_struct>(Request::PTRACE_GETREGS, pid)
}

/// Sets tracee GP registers as described by `ptrace(PTRACE_SETREGS,...)`
pub fn setregs(pid: Pid, regs: &user_regs_struct) -> Result<()> {
let res = unsafe {
libc::ptrace(Request::PTRACE_SETREGS as RequestType,
libc::pid_t::from(pid),
ptr::null_mut::<c_void>(),
regs as *const _ as *const c_void)
};

Errno::result(res).map(|_| ())
}

/// Get siginfo as with `ptrace(PTRACE_GETSIGINFO,...)`
pub fn getsiginfo(pid: Pid) -> Result<siginfo_t> {
ptrace_get_data::<siginfo_t>(Request::PTRACE_GETSIGINFO, pid)
Expand Down

0 comments on commit 837d87c

Please sign in to comment.