in reverie-ptrace/src/trace/mod.rs [394:426]
fn try_from(wait_status: WaitStatus) -> Result<Self, Error> {
Ok(match wait_status {
WaitStatus::Exited(pid, code) => Self::Exited(pid.into(), ExitStatus::Exited(code)),
WaitStatus::Signaled(pid, sig, coredump) => {
Self::Exited(pid.into(), ExitStatus::Signaled(sig, coredump))
}
WaitStatus::Stopped(pid, sig) => {
let event = Event::Signal(sig);
Self::Stopped(Stopped(pid.into()), event)
}
WaitStatus::PtraceEvent(pid, sig, event) => {
// PTRACE_EVENT_STOP is not guaranteed to return the correct
// signal, so we ignore it here.
debug_assert!(event == libc::PTRACE_EVENT_STOP || sig == Signal::SIGTRAP);
let task = Stopped(pid.into());
let event = Event::from_ptrace_event(&task, event)?;
Self::Stopped(task, event)
}
WaitStatus::PtraceSyscall(pid) => {
let event = Event::Syscall;
Self::Stopped(Stopped(pid.into()), event)
}
WaitStatus::Continued(_pid) => {
// Not possible because we aren't using WaitPidFlag::WCONTINUED
// anywhere.
unreachable!("unexpected WaitStatus::Continued");
}
WaitStatus::StillAlive => {
// The precondition of this function forbids this.
unreachable!("precondition violated with WaitStatus::StillAlive");
}
})
}