Skip to content

Commit

Permalink
Merge #624
Browse files Browse the repository at this point in the history
624: Enable ptrace on all Linux platforms r=Susurrus

Nothing that nix currently binds is architecture-specific, and Android
supports ptrace just as much as non-Android Linux.
  • Loading branch information
bors[bot] committed Jul 9, 2017
2 parents 930de38 + 0bf5af5 commit 1b1f15c
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 10 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,9 @@ This project adheres to [Semantic Versioning](http://semver.org/).
`Android` ([#631](https://github.com/nix-rust/nix/pull/631)).
- `bind` and `errno_location` now work correctly on `Android`
([#631](https://github.com/nix-rust/nix/pull/631))
- Added `nix::ptrace` on all Linux-kernel-based platforms
[#624](https://github.com/nix-rust/nix/pull/624). Previously it was
only available on x86, x86-64, and ARM, and also not on Android.

## [0.8.1] 2017-04-16

Expand Down
6 changes: 1 addition & 5 deletions src/sys/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -52,11 +52,7 @@ pub mod uio;

pub mod time;

#[cfg(all(target_os = "linux",
any(target_arch = "x86",
target_arch = "x86_64",
target_arch = "arm")),
)]
#[cfg(any(target_os = "linux", target_os = "android"))]
pub mod ptrace;

pub mod select;
Expand Down
5 changes: 0 additions & 5 deletions src/sys/ptrace.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,6 @@ use {Errno, Error, Result};
use libc::{c_void, c_long, siginfo_t};
use ::unistd::Pid;

#[cfg(all(target_os = "linux",
any(target_arch = "x86",
target_arch = "x86_64",
target_arch = "arm")),
)]
pub mod ptrace {
use libc::c_int;

Expand Down
2 changes: 2 additions & 0 deletions test/sys/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,5 @@ mod test_uio;
#[cfg(target_os = "linux")]
mod test_epoll;
mod test_pthread;
#[cfg(any(target_os = "linux", target_os = "android"))]
mod test_ptrace;
14 changes: 14 additions & 0 deletions test/sys/test_ptrace.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
use nix::Error;
use nix::errno::*;
use nix::unistd::*;
use nix::sys::ptrace::*;
use nix::sys::ptrace::ptrace::*;
use std::ptr;

#[test]
fn test_ptrace() {
// Just make sure ptrace can be called at all, for now.
// FIXME: qemu-user doesn't implement ptrace on all arches, so permit ENOSYS
let err = ptrace(PTRACE_ATTACH, getpid(), ptr::null_mut(), ptr::null_mut()).unwrap_err();
assert!(err == Error::Sys(Errno::EPERM) || err == Error::Sys(Errno::ENOSYS));
}

0 comments on commit 1b1f15c

Please sign in to comment.