From 13cce09c0cd28a7fa110b31928c899c95e8fbb55 Mon Sep 17 00:00:00 2001 From: "coord.e" Date: Thu, 19 Mar 2020 16:52:15 +0000 Subject: [PATCH] Enable getregs/setregs on musl Update CHANGELOG for #1198 --- CHANGELOG.md | 4 ++++ src/sys/ptrace/linux.rs | 30 ++++++++++++++++++------------ 2 files changed, 22 insertions(+), 12 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index dc64b24c94..b88718c040 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -18,6 +18,10 @@ This project adheres to [Semantic Versioning](http://semver.org/). ### Changed - Changed `fallocate` return type from `c_int` to `()` (#[1201](https://github.com/nix-rust/nix/pull/1201)) + +- Enabled `sys::ptrace::setregs` and `sys::ptrace::getregs` on x86_64-unknown-linux-musl target + (#[1198](https://github.com/nix-rust/nix/pull/1198)) + ### Fixed ### Removed diff --git a/src/sys/ptrace/linux.rs b/src/sys/ptrace/linux.rs index ba0e6148ad..ca89afaa4f 100644 --- a/src/sys/ptrace/linux.rs +++ b/src/sys/ptrace/linux.rs @@ -9,10 +9,12 @@ 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(all(target_arch = "x86_64", + any(target_env = "gnu", target_env = "musl")), + all(target_arch = "x86", target_env = "gnu")) +))] use libc::user_regs_struct; cfg_if! { @@ -199,19 +201,23 @@ 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(all(target_arch = "x86_64", + any(target_env = "gnu", target_env = "musl")), + all(target_arch = "x86", target_env = "gnu")) +))] pub fn getregs(pid: Pid) -> Result { ptrace_get_data::(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(all(target_arch = "x86_64", + any(target_env = "gnu", target_env = "musl")), + all(target_arch = "x86", target_env = "gnu")) +))] pub fn setregs(pid: Pid, regs: user_regs_struct) -> Result<()> { let res = unsafe { libc::ptrace(Request::PTRACE_SETREGS as RequestType,