Skip to content

Commit

Permalink
Enable getregs/setregs on musl
Browse files Browse the repository at this point in the history
  • Loading branch information
coord-e committed Mar 19, 2020
1 parent 5c3fbbb commit 3b1a2c9
Showing 1 changed file with 15 additions and 12 deletions.
27 changes: 15 additions & 12 deletions src/sys/ptrace/linux.rs
Expand Up @@ -9,10 +9,11 @@ use sys::signal::Signal;

pub type AddressType = *mut ::libc::c_void;

#[cfg(all(target_os = "linux",
any(target_arch = "x86_64",
target_arch = "x86"),
target_env = "gnu"))]
#[cfg(all(
target_os = "linux",
any(target_arch = "x86_64", target_arch = "x86"),
any(target_env = "gnu", target_env = "musl")
))]
use libc::user_regs_struct;

cfg_if! {
Expand Down Expand Up @@ -199,19 +200,21 @@ fn ptrace_peek(request: Request, pid: Pid, addr: AddressType, data: *mut c_void)
}

/// Get user registers, as with `ptrace(PTRACE_GETREGS, ...)`
#[cfg(all(target_os = "linux",
any(target_arch = "x86_64",
target_arch = "x86"),
target_env = "gnu"))]
#[cfg(all(
target_os = "linux",
any(target_arch = "x86_64", target_arch = "x86"),
any(target_env = "gnu", target_env = "musl"),
))]
pub fn getregs(pid: Pid) -> Result<user_regs_struct> {
ptrace_get_data::<user_regs_struct>(Request::PTRACE_GETREGS, pid)
}

/// Set user registers, as with `ptrace(PTRACE_SETREGS, ...)`
#[cfg(all(target_os = "linux",
any(target_arch = "x86_64",
target_arch = "x86"),
target_env = "gnu"))]
#[cfg(all(
target_os = "linux",
any(target_arch = "x86_64", target_arch = "x86"),
any(target_env = "gnu", target_env = "musl"),
))]
pub fn setregs(pid: Pid, regs: user_regs_struct) -> Result<()> {
let res = unsafe {
libc::ptrace(Request::PTRACE_SETREGS as RequestType,
Expand Down

0 comments on commit 3b1a2c9

Please sign in to comment.