Skip to content

Commit 627dff9

Browse files
bors[bot]coord-e
andauthored
Merge #1198
1198: Enable getregs/setregs on x86_64 musl r=asomers a=coord-e Hi, I needed `ptrace::getregs` in my project. I noticed that they're only enabled on glibc while they can be compiled with musl. This PR enables getregs/setregs on x86_64 musl libc environment. Co-authored-by: coord.e <[email protected]>
2 parents b5a129a + 87047fc commit 627dff9

File tree

2 files changed

+21
-12
lines changed

2 files changed

+21
-12
lines changed

CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,9 @@ This project adheres to [Semantic Versioning](http://semver.org/).
1818

1919
### Changed
2020
- Changed `fallocate` return type from `c_int` to `()` (#[1201](https://github.com/nix-rust/nix/pull/1201))
21+
- Enabled `sys::ptrace::setregs` and `sys::ptrace::getregs` on x86_64-unknown-linux-musl target
22+
(#[1198](https://github.com/nix-rust/nix/pull/1198))
23+
2124
### Fixed
2225
### Removed
2326

src/sys/ptrace/linux.rs

Lines changed: 18 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,12 @@ use sys::signal::Signal;
99

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

12-
#[cfg(all(target_os = "linux",
13-
any(target_arch = "x86_64",
14-
target_arch = "x86"),
15-
target_env = "gnu"))]
12+
#[cfg(all(
13+
target_os = "linux",
14+
any(all(target_arch = "x86_64",
15+
any(target_env = "gnu", target_env = "musl")),
16+
all(target_arch = "x86", target_env = "gnu"))
17+
))]
1618
use libc::user_regs_struct;
1719

1820
cfg_if! {
@@ -199,19 +201,23 @@ fn ptrace_peek(request: Request, pid: Pid, addr: AddressType, data: *mut c_void)
199201
}
200202

201203
/// Get user registers, as with `ptrace(PTRACE_GETREGS, ...)`
202-
#[cfg(all(target_os = "linux",
203-
any(target_arch = "x86_64",
204-
target_arch = "x86"),
205-
target_env = "gnu"))]
204+
#[cfg(all(
205+
target_os = "linux",
206+
any(all(target_arch = "x86_64",
207+
any(target_env = "gnu", target_env = "musl")),
208+
all(target_arch = "x86", target_env = "gnu"))
209+
))]
206210
pub fn getregs(pid: Pid) -> Result<user_regs_struct> {
207211
ptrace_get_data::<user_regs_struct>(Request::PTRACE_GETREGS, pid)
208212
}
209213

210214
/// Set user registers, as with `ptrace(PTRACE_SETREGS, ...)`
211-
#[cfg(all(target_os = "linux",
212-
any(target_arch = "x86_64",
213-
target_arch = "x86"),
214-
target_env = "gnu"))]
215+
#[cfg(all(
216+
target_os = "linux",
217+
any(all(target_arch = "x86_64",
218+
any(target_env = "gnu", target_env = "musl")),
219+
all(target_arch = "x86", target_env = "gnu"))
220+
))]
215221
pub fn setregs(pid: Pid, regs: user_regs_struct) -> Result<()> {
216222
let res = unsafe {
217223
libc::ptrace(Request::PTRACE_SETREGS as RequestType,

0 commit comments

Comments
 (0)