-
Notifications
You must be signed in to change notification settings - Fork 673
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Rename the public ptrace_* functions. #692
Changes from 42 commits
b4f1749
3192df4
d5c4d0f
18b2bc1
8928a7d
1b9a779
a5b01c0
2fe5c2b
233a678
55a7d4b
caaffb8
82e0139
e4a1851
88dc19b
7b07847
3cf4cc6
571386b
d63c616
93b2929
085f47c
1c9e0ca
2a5b86d
b6ad298
845453b
903a52f
2288202
907bb98
a162ea2
745a4ab
4cefd53
536787e
283fb1c
f3167db
021e851
8beaea2
46191fd
a717003
ce60aa5
1844378
6583fd1
9cf8248
6ce39a6
bf93180
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -41,7 +41,7 @@ fn test_wait_exit() { | |
// FIXME: qemu-user doesn't implement ptrace on most arches | ||
#[cfg(any(target_arch = "x86", target_arch = "x86_64"))] | ||
mod ptrace { | ||
use nix::sys::ptrace::*; | ||
use nix::sys::ptrace; | ||
use nix::sys::ptrace::ptrace::*; | ||
use nix::sys::signal::*; | ||
use nix::sys::wait::*; | ||
|
@@ -51,7 +51,8 @@ mod ptrace { | |
use libc::_exit; | ||
|
||
fn ptrace_child() -> ! { | ||
let _ = ptrace(PTRACE_TRACEME, Pid::from_raw(0), ptr::null_mut(), ptr::null_mut()); | ||
// TODO ptrace::traceme will be added in #666 | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There's no need for these comments. |
||
let _ = ptrace::ptrace(PTRACE_TRACEME, Pid::from_raw(0), ptr::null_mut(), ptr::null_mut()); | ||
// As recommended by ptrace(2), raise SIGTRAP to pause the child | ||
// until the parent is ready to continue | ||
let _ = raise(SIGTRAP); | ||
|
@@ -62,16 +63,18 @@ mod ptrace { | |
// Wait for the raised SIGTRAP | ||
assert_eq!(waitpid(child, None), Ok(WaitStatus::Stopped(child, SIGTRAP))); | ||
// We want to test a syscall stop and a PTRACE_EVENT stop | ||
assert!(ptrace_setoptions(child, PTRACE_O_TRACESYSGOOD | PTRACE_O_TRACEEXIT).is_ok()); | ||
assert!(ptrace::setoptions(child, PTRACE_O_TRACESYSGOOD | PTRACE_O_TRACEEXIT).is_ok()); | ||
|
||
// First, stop on the next system call, which will be exit() | ||
assert!(ptrace(PTRACE_SYSCALL, child, ptr::null_mut(), ptr::null_mut()).is_ok()); | ||
// TODO ptrace::syscall will be added in #666 | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. And here. |
||
assert!(ptrace::ptrace(PTRACE_SYSCALL, child, ptr::null_mut(), ptr::null_mut()).is_ok()); | ||
assert_eq!(waitpid(child, None), Ok(WaitStatus::PtraceSyscall(child))); | ||
// Then get the ptrace event for the process exiting | ||
assert!(ptrace(PTRACE_CONT, child, ptr::null_mut(), ptr::null_mut()).is_ok()); | ||
// TODO ptrace::cont will be added in #666 | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Same here. |
||
assert!(ptrace::ptrace(PTRACE_CONT, child, ptr::null_mut(), ptr::null_mut()).is_ok()); | ||
assert_eq!(waitpid(child, None), Ok(WaitStatus::PtraceEvent(child, SIGTRAP, PTRACE_EVENT_EXIT))); | ||
// Finally get the normal wait() result, now that the process has exited | ||
assert!(ptrace(PTRACE_CONT, child, ptr::null_mut(), ptr::null_mut()).is_ok()); | ||
assert!(ptrace::ptrace(PTRACE_CONT, child, ptr::null_mut(), ptr::null_mut()).is_ok()); | ||
assert_eq!(waitpid(child, None), Ok(WaitStatus::Exited(child, 0))); | ||
} | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There's no module-level documentation for the ptrace module, but it'd be good to add one showing an example usage that demonstrates the namespacing we recomment. We don't need it per-say, but it'd help users use this crate very easily. It'll also help us see where the imports aren't very ergonomic so we can improve them later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'll add the documentation when I'm done with all the ptrace changes, ok?
Besides, I really think about splitting up #666 into a couple smaller PRs because I'm starting to lose control of the tests.