summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorbors[bot] <bors[bot]@users.noreply.github.com>2017-07-09 16:23:25 +0000
committerbors[bot] <bors[bot]@users.noreply.github.com>2017-07-09 16:23:25 +0000
commit1b1f15c27c73197bc256220644440a2d0874d9aa (patch)
treeee1c727795207605f07dd0a1a041316b18adb5aa
parent930de3811f024d7e6e5fda3da527d122f9a24279 (diff)
parent0bf5af584c11ffa22c452fb89dcbea70c03e018c (diff)
downloadnix-1b1f15c27c73197bc256220644440a2d0874d9aa.zip
Merge #624
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.
-rw-r--r--CHANGELOG.md3
-rw-r--r--src/sys/mod.rs6
-rw-r--r--src/sys/ptrace.rs5
-rw-r--r--test/sys/mod.rs2
-rw-r--r--test/sys/test_ptrace.rs14
5 files changed, 20 insertions, 10 deletions
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 5fa342c4..15f42a45 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -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
diff --git a/src/sys/mod.rs b/src/sys/mod.rs
index 69632f00..783b8364 100644
--- a/src/sys/mod.rs
+++ b/src/sys/mod.rs
@@ -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;
diff --git a/src/sys/ptrace.rs b/src/sys/ptrace.rs
index 17dfee34..bf395259 100644
--- a/src/sys/ptrace.rs
+++ b/src/sys/ptrace.rs
@@ -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;
diff --git a/test/sys/mod.rs b/test/sys/mod.rs
index e93b0d28..4edb6af0 100644
--- a/test/sys/mod.rs
+++ b/test/sys/mod.rs
@@ -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;
diff --git a/test/sys/test_ptrace.rs b/test/sys/test_ptrace.rs
new file mode 100644
index 00000000..6318495a
--- /dev/null
+++ b/test/sys/test_ptrace.rs
@@ -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));
+}