Apply rustfmt

Reviewed By: zertosh

Differential Revision: D38485027

fbshipit-source-id: 0f5e5b743e002045c95aca427b76e969d6bce347
This commit is contained in:
Stiopa Koltsov 2022-08-06 08:21:44 -07:00 committed by Facebook GitHub Bot
parent 0eaea9b139
commit e53c5ef362
120 changed files with 542 additions and 497 deletions

View file

@ -6,11 +6,8 @@
* This source code is licensed under the BSD-style license found in the
* LICENSE file in the root directory of this source tree.
*/
use serde::Deserialize;
use serde::Serialize;
use std::sync::atomic::AtomicU64;
use std::sync::atomic::Ordering;
use structopt::StructOpt;
use reverie::syscalls::Displayable;
use reverie::syscalls::Errno;
@ -21,6 +18,9 @@ use reverie::Guest;
use reverie::Pid;
use reverie::Tool;
use reverie_util::CommonToolArguments;
use serde::Deserialize;
use serde::Serialize;
use structopt::StructOpt;
/// A tool to introduce inject "chaos" into a running process. A pathological
/// kernel is simulated by forcing reads to only return one byte a time.

View file

@ -6,19 +6,18 @@
* This source code is licensed under the BSD-style license found in the
* LICENSE file in the root directory of this source tree.
*/
use reverie::GlobalTool;
use reverie::Pid;
use serde::Deserialize;
use serde::Serialize;
use crate::event::ThreadExit;
use std::io;
use std::path::PathBuf;
use std::sync::Mutex;
use std::time::SystemTime;
use reverie::GlobalTool;
use reverie::Pid;
use serde::Deserialize;
use serde::Serialize;
use crate::event::ThreadExit;
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct Program {
/// The path to the program.

View file

@ -14,17 +14,15 @@ mod event;
mod global_state;
mod tool;
use tool::ChromeTrace;
use structopt::StructOpt;
use std::fs;
use std::io;
use std::path::PathBuf;
use anyhow::Context;
use reverie::Error;
use reverie_util::CommonToolArguments;
use std::fs;
use std::io;
use std::path::PathBuf;
use structopt::StructOpt;
use tool::ChromeTrace;
/// A tool to render a summary of the process tree.
#[derive(Debug, StructOpt)]

View file

@ -7,10 +7,10 @@
* LICENSE file in the root directory of this source tree.
*/
use crate::event::Event;
use crate::event::Program;
use crate::event::ThreadExit;
use crate::global_state::GlobalState;
use std::borrow::Cow;
use std::fs;
use std::str;
use std::time::SystemTime;
use reverie::syscalls::Displayable;
use reverie::syscalls::Syscall;
@ -28,10 +28,10 @@ use reverie::Tool;
use serde::Deserialize;
use serde::Serialize;
use std::borrow::Cow;
use std::fs;
use std::str;
use std::time::SystemTime;
use crate::event::Event;
use crate::event::Program;
use crate::event::ThreadExit;
use crate::global_state::GlobalState;
#[derive(Debug, Serialize, Deserialize, Clone)]
pub struct ChromeTrace(Pid);

View file

@ -10,6 +10,13 @@
//! This tool will chunk together printed output from each thread, over fixed
//! time intervals.
use std::collections::HashMap;
use std::fmt::Write;
use std::io;
use std::sync::atomic::AtomicBool;
use std::sync::atomic::Ordering;
use std::sync::Mutex;
use reverie::syscalls::Addr;
use reverie::syscalls::MemoryAccess;
use reverie::syscalls::Syscall;
@ -21,12 +28,6 @@ use reverie::Tool;
use reverie_util::CommonToolArguments;
use serde::Deserialize;
use serde::Serialize;
use std::collections::HashMap;
use std::fmt::Write;
use std::io;
use std::sync::atomic::AtomicBool;
use std::sync::atomic::Ordering;
use std::sync::Mutex;
use structopt::StructOpt;
use tracing::debug;
use tracing::info;

View file

@ -9,6 +9,9 @@
//! An example that counts system calls using a simple, global state.
use std::sync::atomic::AtomicU64;
use std::sync::atomic::Ordering;
use reverie::syscalls::Syscall;
use reverie::syscalls::SyscallInfo;
use reverie::syscalls::Sysno;
@ -20,8 +23,6 @@ use reverie::Tool;
use reverie_util::CommonToolArguments;
use serde::Deserialize;
use serde::Serialize;
use std::sync::atomic::AtomicU64;
use std::sync::atomic::Ordering;
use structopt::StructOpt;
#[derive(Debug, Serialize, Deserialize, Default)]

View file

@ -9,6 +9,10 @@
//! An example that counts system calls using a simple, global state.
use core::sync::atomic::AtomicU64;
use core::sync::atomic::Ordering;
use std::sync::Mutex;
use reverie::syscalls::Syscall;
use reverie::syscalls::SyscallInfo;
use reverie::Error;
@ -20,13 +24,9 @@ use reverie::Pid;
use reverie::Tid;
use reverie::Tool;
use reverie_util::CommonToolArguments;
use structopt::StructOpt;
use core::sync::atomic::AtomicU64;
use core::sync::atomic::Ordering;
use serde::Deserialize;
use serde::Serialize;
use std::sync::Mutex;
use structopt::StructOpt;
use tracing::debug;
/// Global state for the tool.

View file

@ -7,11 +7,11 @@
* LICENSE file in the root directory of this source tree.
*/
use crate::filter::Filter;
use serde::Deserialize;
use serde::Serialize;
use crate::filter::Filter;
#[derive(Clone, Default, Serialize, Deserialize)]
pub struct Config {
pub filters: Vec<Filter>,

View file

@ -7,7 +7,6 @@
* LICENSE file in the root directory of this source tree.
*/
use reverie::syscalls::Sysno;
use serde::Deserialize;
use serde::Serialize;

View file

@ -18,12 +18,10 @@ mod tool;
use config::Config;
use filter::Filter;
use tool::Strace;
use structopt::StructOpt;
use reverie::Error;
use reverie_util::CommonToolArguments;
use structopt::StructOpt;
use tool::Strace;
/// A tool to trace system calls.
#[derive(StructOpt, Debug)]

View file

@ -7,9 +7,6 @@
* LICENSE file in the root directory of this source tree.
*/
use crate::config::Config;
use crate::global_state::GlobalState;
use reverie::syscalls::Displayable;
use reverie::syscalls::Errno;
use reverie::syscalls::Syscall;
@ -23,10 +20,12 @@ use reverie::Signal;
use reverie::Subscription;
use reverie::Tid;
use reverie::Tool;
use serde::Deserialize;
use serde::Serialize;
use crate::config::Config;
use crate::global_state::GlobalState;
// Strace has no need for process-level state, so this is a unit struct.
#[derive(Debug, Serialize, Deserialize, Default, Clone)]
pub struct Strace;

View file

@ -6,8 +6,17 @@
* This source code is licensed under the BSD-style license found in the
* LICENSE file in the root directory of this source tree.
*/
use super::ExitStatus;
use super::Pid;
use core::fmt;
use core::future::Future;
use core::pin::Pin;
use core::task::Context;
use core::task::Poll;
use std::io;
use nix::sys::signal::Signal;
use serde::Deserialize;
use serde::Serialize;
use syscalls::Errno;
use super::seccomp::SeccompNotif;
use super::stdio::ChildStderr;
@ -15,18 +24,8 @@ use super::stdio::ChildStdin;
use super::stdio::ChildStdout;
use super::stdio::Stdio;
use super::Command;
use core::fmt;
use core::future::Future;
use core::pin::Pin;
use core::task::Context;
use core::task::Poll;
use nix::sys::signal::Signal;
use serde::Deserialize;
use serde::Serialize;
use std::io;
use syscalls::Errno;
use super::ExitStatus;
use super::Pid;
/// Represents a child process.
///

View file

@ -6,6 +6,22 @@
* This source code is licensed under the BSD-style license found in the
* LICENSE file in the root directory of this source tree.
*/
use std::borrow::Cow;
use std::collections::BTreeMap;
use std::ffi::CString;
use std::ffi::OsStr;
use std::ffi::OsString;
use std::io::Read;
use std::os::unix::ffi::OsStrExt;
use std::os::unix::io::AsRawFd;
use std::path::Path;
use nix::sched::sched_setaffinity;
use nix::sched::CpuSet;
use serde::de::DeserializeOwned;
use serde::Serialize;
use syscalls::Errno;
use super::clone::clone_with_stack;
use super::env::Env;
use super::error::AddContext;
@ -26,22 +42,6 @@ use super::stdio::Stdio;
use super::util::reset_signal_handling;
use super::util::to_cstring;
use nix::sched::sched_setaffinity;
use nix::sched::CpuSet;
use serde::de::DeserializeOwned;
use serde::Serialize;
use syscalls::Errno;
use std::borrow::Cow;
use std::collections::BTreeMap;
use std::ffi::CString;
use std::ffi::OsStr;
use std::ffi::OsString;
use std::io::Read;
use std::os::unix::ffi::OsStrExt;
use std::os::unix::io::AsRawFd;
use std::path::Path;
/// A `Container` is a configuration of how a process shall be spawned. It can,
/// but doesn't have to, include Linux namespace configuration.
///
@ -923,9 +923,10 @@ impl Drop for WaitGuard {
#[cfg(test)]
mod tests {
use super::*;
use nix::sys::signal::Signal;
use super::*;
#[test]
fn can_panic() {
assert_eq!(
@ -1009,9 +1010,10 @@ mod tests {
#[test]
pub fn pin_affinity_to_all_cores() -> Result<(), Error> {
use raw_cpuid::CpuId;
use std::collections::HashMap;
use raw_cpuid::CpuId;
let cpus = num_cpus::get();
println!("Total cpus {}", cpus);

View file

@ -150,7 +150,6 @@ impl<'de> serde::Deserialize<'de> for ExitStatus {
#[cfg(all(test, not(sanitized)))]
mod tests_non_sanitized {
use super::*;
use nix::sys::signal;
use nix::sys::signal::Signal;
use nix::sys::wait::waitpid;
@ -158,6 +157,8 @@ mod tests_non_sanitized {
use nix::unistd::fork;
use nix::unistd::ForkResult;
use super::*;
// Runs a closure in a forked process and reports the exit status.
fn run_forked<F>(f: F) -> nix::Result<ExitStatus>
where

View file

@ -7,12 +7,9 @@
* LICENSE file in the root directory of this source tree.
*/
use super::util;
use core::pin::Pin;
use core::task::Context;
use core::task::Poll;
use std::ffi::CStr;
use std::ffi::CString;
use std::io;
@ -31,6 +28,8 @@ use tokio::io::AsyncWrite;
use tokio::io::Interest;
use tokio::io::ReadBuf;
use super::util;
#[derive(Debug)]
// From `std/src/sys/unix/fd.rs`. Mark `-1` as an invalid file descriptor so it
// can be reused to in `Option<Fd>`.
@ -498,10 +497,12 @@ where
#[cfg(test)]
mod tests {
use super::*;
use const_cstr::const_cstr;
use std::os::unix::ffi::OsStrExt;
use const_cstr::const_cstr;
use super::*;
#[test]
fn test_is_dir() {
assert!(is_dir(const_cstr!("/").as_ptr()));

View file

@ -35,6 +35,8 @@ mod spawn;
mod stdio;
mod util;
use std::ffi::CString;
pub use child::Child;
pub use child::Output;
pub use container::Container;
@ -47,6 +49,8 @@ pub use mount::Mount;
pub use mount::MountFlags;
pub use mount::MountParseError;
pub use namespace::Namespace;
// Re-export Signal since it is used by `Child::signal`.
pub use nix::sys::signal::Signal;
pub use pid::Pid;
pub use pty::Pty;
pub use pty::PtyChild;
@ -54,12 +58,6 @@ pub use stdio::ChildStderr;
pub use stdio::ChildStdin;
pub use stdio::ChildStdout;
pub use stdio::Stdio;
// Re-export Signal since it is used by `Child::signal`.
pub use nix::sys::signal::Signal;
use std::ffi::CString;
use syscalls::Errno;
/// A builder for spawning a process.
@ -155,14 +153,14 @@ impl Command {
#[cfg(test)]
mod tests {
use super::*;
use crate::ExitStatus;
use std::collections::BTreeMap;
use std::fs;
use std::path::Path;
use std::str::from_utf8;
use super::*;
use crate::ExitStatus;
#[tokio::test]
async fn spawn() {
assert_eq!(
@ -610,9 +608,10 @@ mod tests {
#[tokio::test]
async fn seccomp() {
use super::seccomp::*;
use syscalls::Sysno;
use super::seccomp::*;
let filter = FilterBuilder::new()
.default_action(Action::Allow)
.syscalls([(Sysno::brk, Action::KillProcess)])
@ -634,13 +633,15 @@ mod tests {
#[tokio::test]
async fn seccomp_notify() {
use super::seccomp::*;
use std::collections::HashMap;
use futures::future::select;
use futures::future::Either;
use futures::stream::TryStreamExt;
use std::collections::HashMap;
use syscalls::Sysno;
use super::seccomp::*;
let filter = FilterBuilder::new()
.default_action(Action::Notify)
.syscalls([

View file

@ -6,25 +6,23 @@
* This source code is licensed under the BSD-style license found in the
* LICENSE file in the root directory of this source tree.
*/
use super::fd::create_dir_all;
use super::fd::touch_path;
use super::fd::FileType;
use super::util;
use core::convert::Infallible;
use core::fmt;
use core::ptr;
use core::str::FromStr;
use std::collections::HashMap;
use std::ffi::CString;
use std::ffi::OsStr;
use std::os::unix::ffi::OsStrExt;
use std::path::Path;
pub use nix::mount::MsFlags as MountFlags;
use syscalls::Errno;
pub use nix::mount::MsFlags as MountFlags;
use super::fd::create_dir_all;
use super::fd::touch_path;
use super::fd::FileType;
use super::util;
/// A mount.
#[derive(Clone, Debug, Eq, PartialEq)]

View file

@ -7,9 +7,10 @@
* LICENSE file in the root directory of this source tree.
*/
use std::str::FromStr;
use serde::Deserialize;
use serde::Serialize;
use std::str::FromStr;
bitflags::bitflags! {
/// A namespace that may be unshared with [`Command::unshare`].

View file

@ -7,8 +7,6 @@
* LICENSE file in the root directory of this source tree.
*/
use super::fd::Fd;
use std::ffi::CStr;
use std::ffi::OsStr;
use std::mem::MaybeUninit;
@ -16,6 +14,8 @@ use std::os::unix::io::AsRawFd;
use syscalls::Errno;
use super::fd::Fd;
/// Interface name.
#[derive(Default, Debug, Copy, Clone, Eq, PartialEq)]
#[repr(C)]
@ -193,9 +193,10 @@ impl<T> IfReq<T> {
#[cfg(test)]
mod tests {
use super::*;
use nix::net::if_::InterfaceFlags;
use super::*;
#[test]
fn ifname() {
assert_eq!(IfName::new("lo"), Ok(IfName::LOOPBACK));

View file

@ -8,6 +8,7 @@
*/
use core::fmt;
use core::hash::Hash;
use serde::Deserialize;
use serde::Serialize;

View file

@ -6,23 +6,22 @@
* This source code is licensed under the BSD-style license found in the
* LICENSE file in the root directory of this source tree.
*/
use super::fd::AsyncFd;
use super::fd::Fd;
use core::mem::MaybeUninit;
use core::pin::Pin;
use core::task::Context;
use core::task::Poll;
use std::io;
use std::os::unix::io::AsRawFd;
use std::os::unix::io::IntoRawFd;
use std::os::unix::io::RawFd;
use syscalls::Errno;
use tokio::io::AsyncRead;
use tokio::io::AsyncWrite;
use tokio::io::ReadBuf;
use core::mem::MaybeUninit;
use core::pin::Pin;
use core::task::Context;
use core::task::Poll;
use std::io;
use std::os::unix::io::AsRawFd;
use std::os::unix::io::IntoRawFd;
use std::os::unix::io::RawFd;
use super::fd::AsyncFd;
use super::fd::Fd;
/// Represents a pseudo-TTY "master".
#[derive(Debug)]

View file

@ -9,11 +9,11 @@
#![allow(non_snake_case)]
use crate::fd::Fd;
pub use libc::sock_filter;
use syscalls::Errno;
use syscalls::Sysno;
pub use libc::sock_filter;
use crate::fd::Fd;
// See: /include/uapi/linux/bpf_common.h

View file

@ -74,15 +74,13 @@ mod bpf;
#[allow(unused)]
mod notif;
use bpf::*;
use syscalls::Errno;
use syscalls::Sysno;
use std::collections::BTreeMap;
pub use bpf::Filter;
use bpf::*;
pub use notif::*;
use std::collections::BTreeMap;
use syscalls::Errno;
use syscalls::Sysno;
/// Builder for creating seccomp filters.
#[derive(Clone)]

View file

@ -9,18 +9,18 @@
#![allow(missing_docs)]
use syscalls::Errno;
use crate::fd::Fd;
use core::pin::Pin;
use core::task::Context;
use core::task::Poll;
use std::io;
use std::os::unix::io::AsRawFd;
use syscalls::Errno;
use tokio::io::unix::AsyncFd;
use tokio::io::Interest;
use crate::fd::Fd;
/// The format the BPF program executes over.
#[derive(Copy, Clone, Debug, Eq, PartialEq, Hash)]
#[repr(C)]

View file

@ -6,7 +6,11 @@
* This source code is licensed under the BSD-style license found in the
* LICENSE file in the root directory of this source tree.
*/
use std::io;
use std::io::Write;
use super::clone::clone;
use super::container::ChildContext;
use super::error::Context;
use super::error::Error;
use super::fd::pipe;
@ -21,11 +25,6 @@ use super::util::SharedValue;
use super::Child;
use super::Command;
use super::container::ChildContext;
use std::io;
use std::io::Write;
impl Command {
/// Executes the command as a child process, returning a handle to it.
///

View file

@ -6,10 +6,6 @@
* This source code is licensed under the BSD-style license found in the
* LICENSE file in the root directory of this source tree.
*/
use super::fd::pipe;
use super::fd::AsyncFd;
use super::fd::Fd;
use core::pin::Pin;
use core::task::Context;
use core::task::Poll;
@ -23,6 +19,10 @@ use tokio::io::AsyncRead;
use tokio::io::AsyncWrite;
use tokio::io::ReadBuf;
use super::fd::pipe;
use super::fd::AsyncFd;
use super::fd::Fd;
/// Describes what to do with a standard I/O stream for a child process when
/// passed to the [`stdin`], [`stdout`], and [`stderr`] methods of [`Command`].
///

View file

@ -7,12 +7,13 @@
* LICENSE file in the root directory of this source tree.
*/
use super::consts::*;
use nix::sys::uio;
use nix::sys::uio::IoVec;
use nix::sys::uio::RemoteIoVec;
use nix::unistd::Pid;
use super::consts::*;
/// generate syscall instructions at injected page
/// the page address should be 0x7000_0000 (PRIVATE_PAGE_OFFSET)
/// the byte code can be confirmed by running objcopy

View file

@ -7,9 +7,10 @@
* LICENSE file in the root directory of this source tree.
*/
use bytes::BytesMut;
use crate::gdbstub::commands::*;
use crate::gdbstub::hex::*;
use bytes::BytesMut;
#[derive(PartialEq, Debug)]
pub struct QStartNoAckMode;

View file

@ -7,9 +7,10 @@
* LICENSE file in the root directory of this source tree.
*/
use bytes::BytesMut;
use crate::gdbstub::commands::*;
use crate::gdbstub::hex::*;
use bytes::BytesMut;
#[derive(PartialEq, Debug)]
pub struct QThreadEvents {

View file

@ -7,9 +7,10 @@
* LICENSE file in the root directory of this source tree.
*/
use bytes::BytesMut;
use crate::gdbstub::commands::*;
use crate::gdbstub::hex::*;
use bytes::BytesMut;
#[derive(PartialEq, Debug)]
pub struct QuestionMark;

View file

@ -7,9 +7,10 @@
* LICENSE file in the root directory of this source tree.
*/
use bytes::BytesMut;
use crate::gdbstub::commands::*;
use crate::gdbstub::hex::*;
use bytes::BytesMut;
#[derive(PartialEq, Debug)]
pub struct g;

View file

@ -7,9 +7,10 @@
* LICENSE file in the root directory of this source tree.
*/
use bytes::BytesMut;
use crate::gdbstub::commands::*;
use crate::gdbstub::hex::*;
use bytes::BytesMut;
#[derive(PartialEq, Debug)]
pub struct G {

View file

@ -7,9 +7,10 @@
* LICENSE file in the root directory of this source tree.
*/
use bytes::BytesMut;
use crate::gdbstub::commands::*;
use crate::gdbstub::hex::*;
use bytes::BytesMut;
#[derive(PartialEq, Debug)]
pub struct H {

View file

@ -7,9 +7,10 @@
* LICENSE file in the root directory of this source tree.
*/
use bytes::Bytes;
use crate::gdbstub::commands::*;
use crate::gdbstub::hex::*;
use bytes::Bytes;
pub struct P {
pub reg_id: usize,

View file

@ -7,9 +7,10 @@
* LICENSE file in the root directory of this source tree.
*/
use bytes::BytesMut;
use crate::gdbstub::commands::*;
use crate::gdbstub::hex::*;
use bytes::BytesMut;
#[derive(PartialEq, Debug)]
pub struct qAttached {

View file

@ -7,9 +7,10 @@
* LICENSE file in the root directory of this source tree.
*/
use crate::gdbstub::commands::*;
use bytes::BytesMut;
use crate::gdbstub::commands::*;
#[derive(PartialEq, Debug)]
pub struct qC {}

View file

@ -7,11 +7,12 @@
* LICENSE file in the root directory of this source tree.
*/
use crate::gdbstub::commands::*;
use crate::gdbstub::hex::*;
use bytes::Bytes;
use bytes::BytesMut;
use crate::gdbstub::commands::*;
use crate::gdbstub::hex::*;
#[derive(PartialEq, Debug)]
pub struct qSupported {
pub features: Bytes, // use Features type here!

View file

@ -7,9 +7,10 @@
* LICENSE file in the root directory of this source tree.
*/
use bytes::BytesMut;
use crate::gdbstub::commands::*;
use crate::gdbstub::hex::*;
use bytes::BytesMut;
#[derive(PartialEq, Debug)]
pub struct qfThreadInfo;

View file

@ -7,9 +7,10 @@
* LICENSE file in the root directory of this source tree.
*/
use bytes::BytesMut;
use crate::gdbstub::commands::*;
use crate::gdbstub::hex::*;
use bytes::BytesMut;
#[derive(PartialEq, Debug)]
pub struct qsThreadInfo;

View file

@ -7,9 +7,10 @@
* LICENSE file in the root directory of this source tree.
*/
use bytes::BytesMut;
use crate::gdbstub::commands::*;
use crate::gdbstub::hex::*;
use bytes::BytesMut;
pub struct s {
pub addr: Option<u64>,

View file

@ -7,9 +7,10 @@
* LICENSE file in the root directory of this source tree.
*/
use bytes::BytesMut;
use crate::gdbstub::commands::*;
use crate::gdbstub::hex::*;
use bytes::BytesMut;
pub struct T {
pub thread: ThreadId,

View file

@ -8,7 +8,6 @@
*/
use bytes::BytesMut;
use nix::sys::signal::Signal;
use crate::gdbstub::commands::*;

View file

@ -7,13 +7,12 @@
* LICENSE file in the root directory of this source tree.
*/
use bytes::BytesMut;
use std::ffi::OsString;
use std::os::unix::ffi::OsStringExt;
use std::path::PathBuf;
use bytes::BytesMut;
use nix::sys::stat::FileStat;
use reverie::Pid;
use crate::gdbstub::commands::*;
@ -120,9 +119,10 @@ impl ParseCommand for vFile {
#[cfg(test)]
mod test {
use super::*;
use std::mem;
use super::*;
#[test]
fn hostio_stat_size_check() {
assert_eq!(mem::size_of::<HostioStat>(), 0x40);

View file

@ -8,10 +8,10 @@
*/
use bytes::BytesMut;
use reverie::Pid;
use crate::gdbstub::commands::*;
use crate::gdbstub::hex::*;
use reverie::Pid;
#[derive(PartialEq, Debug)]
pub struct vKill {

View file

@ -35,6 +35,10 @@ mod _x_upper;
mod _z;
mod _z_upper;
//pub use _p::*;
//pub use _p_upper::*;
pub use _QStartNoAckMode::*;
pub use _QThreadEvents::*;
pub use _QuestionMark::*;
//pub use _c::*;
pub use _d_upper::*;
@ -44,10 +48,6 @@ pub use _h_upper::*;
//pub use _k::*;
pub use _m::*;
pub use _m_upper::*;
//pub use _p::*;
//pub use _p_upper::*;
pub use _QStartNoAckMode::*;
pub use _QThreadEvents::*;
pub use _qAttached::*;
pub use _qC::*;
pub use _qSupported::*;

View file

@ -7,9 +7,10 @@
* LICENSE file in the root directory of this source tree.
*/
use bytes::BytesMut;
use crate::gdbstub::commands::*;
use crate::gdbstub::hex::*;
use bytes::BytesMut;
#[derive(PartialEq, Debug)]
pub struct ExclamationMark;

View file

@ -7,9 +7,10 @@
* LICENSE file in the root directory of this source tree.
*/
use bytes::Bytes;
use crate::gdbstub::commands::*;
use crate::gdbstub::hex::*;
use bytes::Bytes;
pub struct QEnvironmentHexEncoded {
pub key: Bytes,

View file

@ -7,9 +7,10 @@
* LICENSE file in the root directory of this source tree.
*/
use bytes::Bytes;
use crate::gdbstub::commands::*;
use crate::gdbstub::hex::*;
use bytes::Bytes;
pub struct QEnvironmentUnset {
pub key: Bytes,

View file

@ -7,9 +7,10 @@
* LICENSE file in the root directory of this source tree.
*/
use bytes::Bytes;
use crate::gdbstub::commands::*;
use crate::gdbstub::hex::*;
use bytes::Bytes;
pub struct QSetWorkingDir {
pub dir: Option<Bytes>,

View file

@ -7,9 +7,10 @@
* LICENSE file in the root directory of this source tree.
*/
use bytes::BytesMut;
use crate::gdbstub::commands::*;
use crate::gdbstub::hex::*;
use bytes::BytesMut;
pub struct QStartupWithShell {
pub val: bool,

View file

@ -7,8 +7,9 @@
* LICENSE file in the root directory of this source tree.
*/
use crate::gdbstub::commands::*;
use crate::gdbstub::hex::*;
use bytes::BytesMut;
use crate::gdbstub::commands::*;
use crate::gdbstub::hex::*;
pub struct R;

View file

@ -7,11 +7,12 @@
* LICENSE file in the root directory of this source tree.
*/
use crate::gdbstub::commands::*;
use crate::gdbstub::hex::*;
use bytes::BytesMut;
use reverie::Pid;
use crate::gdbstub::commands::*;
use crate::gdbstub::hex::*;
pub struct vAttach {
pub pid: Pid,
}

View file

@ -7,9 +7,10 @@
* LICENSE file in the root directory of this source tree.
*/
use bytes::Bytes;
use crate::gdbstub::commands::*;
use crate::gdbstub::hex::*;
use bytes::Bytes;
pub struct vRun {
pub filename: Option<Bytes>,

View file

@ -33,6 +33,20 @@
#![allow(non_snake_case, non_camel_case_types, dead_code, unused_imports)]
use std::collections::BTreeMap;
use std::path::PathBuf;
use bytes::Bytes;
use bytes::BytesMut;
use paste::paste;
use reverie::ExitStatus;
use reverie::Pid;
use reverie::Signal;
use thiserror::Error;
use tokio::sync::broadcast;
use tokio::sync::mpsc;
use tokio::sync::oneshot;
use crate::gdbstub::hex::*;
use crate::gdbstub::request::*;
use crate::gdbstub::response::*;
@ -43,19 +57,6 @@ use crate::gdbstub::ResumeInferior;
use crate::gdbstub::StoppedInferior;
use crate::trace::ChildOp;
use crate::trace::Stopped;
use bytes::Bytes;
use bytes::BytesMut;
use paste::paste;
use std::collections::BTreeMap;
use std::path::PathBuf;
use thiserror::Error;
use tokio::sync::broadcast;
use tokio::sync::mpsc;
use tokio::sync::oneshot;
use reverie::ExitStatus;
use reverie::Pid;
use reverie::Signal;
mod base;
mod extended_mode;

View file

@ -7,11 +7,12 @@
* LICENSE file in the root directory of this source tree.
*/
use crate::gdbstub::commands::*;
use crate::gdbstub::hex::*;
use bytes::Bytes;
use bytes::BytesMut;
use crate::gdbstub::commands::*;
use crate::gdbstub::hex::*;
#[derive(PartialEq, Debug)]
pub struct qRcmd {
pub cmd: Bytes,

View file

@ -7,9 +7,10 @@
* LICENSE file in the root directory of this source tree.
*/
use bytes::BytesMut;
use crate::gdbstub::commands::*;
use crate::gdbstub::hex::*;
use bytes::BytesMut;
#[derive(PartialEq, Debug)]
pub struct qOffsets;

View file

@ -7,17 +7,16 @@
* LICENSE file in the root directory of this source tree.
*/
use std::io;
use reverie::Pid;
use thiserror::Error;
use super::commands::CommandParseError;
use super::hex::GdbHexError;
use super::packet::PacketParseError;
use crate::trace::Error as TraceError;
use reverie::Pid;
use std::io;
#[derive(Error, Debug)]
#[allow(clippy::enum_variant_names)]
pub enum Error {

View file

@ -7,13 +7,13 @@
* LICENSE file in the root directory of this source tree.
*/
use reverie::Pid;
use tokio::sync::mpsc;
use super::commands::*;
use super::Error;
use super::GdbRequest;
use reverie::Pid;
use tokio::sync::mpsc;
/// Thread id and Pid use to uniquely indentify an inferior.
#[derive(Clone, Copy, PartialEq, Eq, Debug)]
pub struct InferiorThreadId {

View file

@ -31,12 +31,13 @@
* SOFTWARE.
*/
use bytes::BytesMut;
use thiserror::Error;
use super::commands::Command;
use super::commands::CommandParseError;
use super::hex::*;
use super::PacketLogger;
use bytes::BytesMut;
use thiserror::Error;
/// Packet parse error.
#[derive(PartialEq, Debug, Error)]

View file

@ -7,9 +7,10 @@
* LICENSE file in the root directory of this source tree.
*/
use std::fmt;
use serde::Deserialize;
use serde::Serialize;
use std::fmt;
use super::response::*;
@ -392,9 +393,10 @@ pub struct Amd64ExtraRegs {
#[cfg(test)]
mod test {
use super::*;
use std::mem;
use super::*;
#[test]
fn fp80_sanity() {
assert_eq!(mem::size_of::<Fp80>(), 10);

View file

@ -7,10 +7,11 @@
* LICENSE file in the root directory of this source tree.
*/
use tokio::sync::oneshot;
use super::Amd64CoreRegs;
use super::Breakpoint;
use crate::trace::Error as TraceError;
use tokio::sync::oneshot;
/// gdb request send to reverie.
#[derive(Debug)]

View file

@ -36,7 +36,6 @@ use bytes::Bytes;
use bytes::BytesMut;
use num_traits::AsPrimitive;
use num_traits::PrimInt;
use reverie::Errno;
use super::Error;

View file

@ -7,11 +7,12 @@
* LICENSE file in the root directory of this source tree.
*/
use bytes::BytesMut;
use futures::future;
use std::io;
use std::net::SocketAddr;
use std::path::Path;
use bytes::BytesMut;
use futures::future;
use tokio::io::AsyncRead;
use tokio::io::AsyncReadExt;
use tokio::net::TcpListener;

View file

@ -7,6 +7,9 @@
* LICENSE file in the root directory of this source tree.
*/
use std::collections::BTreeMap;
use std::sync::Arc;
use bytes::Bytes;
use bytes::BytesMut;
use futures::future::Future;
@ -20,7 +23,6 @@ use nix::sys::stat::Mode;
use nix::sys::uio;
use nix::unistd;
use reverie::Pid;
use std::sync::Arc;
use tokio::io::AsyncWrite;
use tokio::io::AsyncWriteExt;
use tokio::sync::mpsc;
@ -29,8 +31,6 @@ use tokio::sync::MappedMutexGuard;
use tokio::sync::Mutex;
use tokio::sync::MutexGuard;
use crate::trace::ChildOp;
use super::commands;
use super::commands::*;
use super::regs::Amd64CoreRegs;
@ -44,8 +44,7 @@ use super::InferiorThreadId;
use super::Packet;
use super::ResumeInferior;
use super::StoppedInferior;
use std::collections::BTreeMap;
use crate::trace::ChildOp;
type BoxWriter = Box<dyn AsyncWrite + Unpin + Send + Sync + 'static>;

View file

@ -23,13 +23,15 @@
//! [`PerfCounter::DISABLE_SAMPLE_PERIOD`] can be used to avoid this for sampling.
//! events.
use crate::validation::check_for_pmu_bugs;
use crate::validation::PmuValidationError;
use core::ptr::NonNull;
#[allow(unused_imports)] // only used if we have an error
use std::compile_error;
use lazy_static::lazy_static;
use nix::sys::signal::Signal;
use nix::unistd::sysconf;
use nix::unistd::SysconfVar;
pub use perf::perf_event_header;
use perf_event_open_sys::bindings as perf;
use perf_event_open_sys::ioctls;
use reverie::Errno;
@ -37,10 +39,8 @@ use reverie::Tid;
use tracing::info;
use tracing::warn;
#[allow(unused_imports)] // only used if we have an error
use std::compile_error;
pub use perf::perf_event_header;
use crate::validation::check_for_pmu_bugs;
use crate::validation::PmuValidationError;
lazy_static! {
static ref PMU_BUG: Result<(), PmuValidationError> = check_for_pmu_bugs();
@ -615,9 +615,10 @@ pub fn do_branches(count: u64) {
#[cfg(test)]
mod test {
use super::*;
use nix::unistd::gettid;
use super::*;
#[test]
fn trace_self() {
ret_without_perf!();

View file

@ -6,8 +6,9 @@
* This source code is licensed under the BSD-style license found in the
* LICENSE file in the root directory of this source tree.
*/
use crate::trace::Error as TraceError;
use crate::trace::Stopped;
use std::sync::atomic::AtomicBool;
use std::sync::atomic::Ordering;
use std::sync::Arc;
use reverie::syscalls::Addr;
use reverie::syscalls::AddrMut;
@ -15,9 +16,9 @@ use reverie::syscalls::MemoryAccess;
use reverie::Errno;
use reverie::Pid;
use reverie::Stack;
use std::sync::atomic::AtomicBool;
use std::sync::atomic::Ordering;
use std::sync::Arc;
use crate::trace::Error as TraceError;
use crate::trace::Stopped;
// NB: leaf function can use redzone without explicit stack allocation, as
// a result it is not safe to just adjust stack pointer. 128B of stack

View file

@ -9,29 +9,17 @@
//! `TracedTask` and its methods.
use crate::children;
use crate::cp;
use crate::error::Error;
use crate::gdbstub::Amd64CoreRegs;
use crate::gdbstub::BreakpointType;
use crate::gdbstub::GdbRequest;
use crate::gdbstub::GdbServer;
use crate::gdbstub::ResumeAction;
use crate::gdbstub::ResumeInferior;
use crate::gdbstub::StopEvent;
use crate::gdbstub::StopReason;
use crate::gdbstub::StoppedInferior;
use crate::stack::GuestStack;
use crate::timer::HandleFailure;
use crate::timer::Timer;
use crate::timer::TimerEventRequest;
use crate::trace::ChildOp;
use crate::trace::Error as TraceError;
use crate::trace::Event;
use crate::trace::Running;
use crate::trace::Stopped;
use crate::trace::Wait;
use crate::vdso;
use std::collections::BTreeMap;
use std::collections::HashMap;
use std::fmt;
use std::ops::DerefMut;
use std::pin::Pin;
use std::sync::atomic::AtomicBool;
use std::sync::atomic::AtomicUsize;
use std::sync::atomic::Ordering;
use std::sync::Arc;
use std::task::Context;
use std::task::Poll;
use async_trait::async_trait;
use futures::future;
@ -39,6 +27,7 @@ use futures::future::Either;
use futures::future::Future;
use futures::future::FutureExt;
use futures::future::TryFutureExt;
use libc::user_regs_struct;
use nix::sys::mman::ProtFlags;
use nix::sys::signal::Signal;
use reverie::syscalls::Addr;
@ -65,23 +54,6 @@ use reverie::Symbol;
use reverie::Tid;
use reverie::TimerSchedule;
use reverie::Tool;
use std::collections::BTreeMap;
use std::collections::HashMap;
use std::fmt;
use std::ops::DerefMut;
use std::pin::Pin;
use std::sync::atomic::AtomicBool;
use std::sync::atomic::AtomicUsize;
use std::sync::atomic::Ordering;
use std::sync::Arc;
use std::task::Context;
use std::task::Poll;
use tracing::debug;
use tracing::info;
use tracing::trace;
use tracing::warn;
use libc::user_regs_struct;
use tokio::sync::broadcast;
use tokio::sync::mpsc;
use tokio::sync::oneshot;
@ -89,6 +61,34 @@ use tokio::sync::Mutex;
use tokio::sync::Notify;
use tokio::task::JoinError;
use tokio::task::JoinHandle;
use tracing::debug;
use tracing::info;
use tracing::trace;
use tracing::warn;
use crate::children;
use crate::cp;
use crate::error::Error;
use crate::gdbstub::Amd64CoreRegs;
use crate::gdbstub::BreakpointType;
use crate::gdbstub::GdbRequest;
use crate::gdbstub::GdbServer;
use crate::gdbstub::ResumeAction;
use crate::gdbstub::ResumeInferior;
use crate::gdbstub::StopEvent;
use crate::gdbstub::StopReason;
use crate::gdbstub::StoppedInferior;
use crate::stack::GuestStack;
use crate::timer::HandleFailure;
use crate::timer::Timer;
use crate::timer::TimerEventRequest;
use crate::trace::ChildOp;
use crate::trace::Error as TraceError;
use crate::trace::Event;
use crate::trace::Running;
use crate::trace::Stopped;
use crate::trace::Wait;
use crate::vdso;
#[derive(Debug)]
struct Suspended {

View file

@ -9,8 +9,6 @@
//! Utilities that support constructing tests for Reverie Tools.
use crate::spawn_fn_with_config;
use crate::TracerBuilder;
use futures::Future;
use reverie::process::Command;
use reverie::process::Output;
@ -21,6 +19,8 @@ use reverie::GlobalTool;
use reverie::Tool;
pub use crate::perf::do_branches;
use crate::spawn_fn_with_config;
use crate::TracerBuilder;
/// For some tests, its nice to show what was printed.
pub fn print_tracee_output(output: &Output) {

View file

@ -30,11 +30,6 @@
//! - before resumption of the guest,
//! which _usually_ means immediately after the tool callback returns.
use crate::perf::*;
use crate::trace::Error as TraceError;
use crate::trace::Event as TraceEvent;
use crate::trace::Stopped;
use crate::trace::Wait;
use raw_cpuid::CpuId;
use reverie::Errno;
use reverie::Pid;
@ -44,6 +39,12 @@ use thiserror::Error;
use tracing::debug;
use tracing::warn;
use crate::perf::*;
use crate::trace::Error as TraceError;
use crate::trace::Event as TraceEvent;
use crate::trace::Stopped;
use crate::trace::Wait;
// This signal is unused, in that the kernel will never send it to a process.
const MARKER_SIGNAL: Signal = reverie::PERF_EVENT_SIGNAL;

View file

@ -7,12 +7,9 @@
* LICENSE file in the root directory of this source tree.
*/
use core::mem;
use nix::sys::ptrace;
use std::io;
use super::Stopped;
use nix::sys::ptrace;
use reverie::syscalls::Addr;
use reverie::syscalls::AddrMut;
use reverie::syscalls::AddrSlice;
@ -20,6 +17,8 @@ use reverie::syscalls::AddrSliceMut;
use reverie::syscalls::Errno;
use reverie::syscalls::MemoryAccess;
use super::Stopped;
impl Stopped {
/// Does a read that is already page-aligned.
fn read_aligned(&self, addr: Addr<u8>, buf: &mut [u8]) -> Result<usize, Errno> {
@ -196,10 +195,6 @@ impl MemoryAccess for Stopped {
#[cfg(test)]
mod test {
use super::*;
use reverie::Pid;
use std::ffi::CString;
use nix::sys::ptrace;
@ -211,6 +206,9 @@ mod test {
use nix::unistd::ForkResult;
use quickcheck::QuickCheck;
use quickcheck_macros::quickcheck;
use reverie::Pid;
use super::*;
// Helper function for spawning a child process in a stopped state. The
// value `T` will be in the child's address space allowing us to read or

View file

@ -19,19 +19,17 @@ use std::mem;
use std::ptr;
use nix::sys::ptrace;
use nix::sys::wait::WaitPidFlag;
use nix::sys::wait::WaitStatus;
use thiserror::Error;
pub use reverie::Errno;
pub use reverie::ExitStatus;
pub use reverie::Pid;
use waitid::waitid;
use waitid::IdType;
// Re-exports so that nothing else needs to depend on `nix`.
pub use nix::sys::ptrace::Options;
pub use nix::sys::signal::Signal;
use nix::sys::wait::WaitPidFlag;
use nix::sys::wait::WaitStatus;
pub use reverie::Errno;
pub use reverie::ExitStatus;
pub use reverie::Pid;
use thiserror::Error;
use waitid::waitid;
use waitid::IdType;
/// An error that occurred during tracing.
#[derive(Error, Debug, Eq, PartialEq)]
@ -967,16 +965,16 @@ pub fn traceme_and_stop() -> Result<(), Errno> {
/// These tests are meant to test this API but also to show how ptrace works.
#[cfg(test)]
mod test {
use super::*;
use std::io;
use std::mem;
use std::thread;
use nix::sys::signal;
use nix::sys::signal::Signal;
use nix::unistd::fork;
use nix::unistd::ForkResult;
use std::io;
use std::mem;
use std::thread;
use super::*;
// Traces a closure in a forked process. The forked process starts in a
// stopped state so that ptrace options may be set.

View file

@ -357,11 +357,12 @@ impl Future for ExitFuture {
#[cfg(test)]
mod test {
use super::*;
use nix::sys::signal::Signal;
use nix::sys::wait::WaitStatus;
use nix::unistd::Pid;
use super::*;
#[test]
fn exit_event_code() {
assert_eq!(

View file

@ -14,14 +14,15 @@
//! `WCONTINUED`, `WNOHANG` and `WNOWAIT`. see `waitid(2)` for more details.
//! NB: `waitid` here provide a similar interface as `nix`'s `waitpid`.
use super::Errno;
use std::mem::MaybeUninit;
use std::os::unix::io::RawFd;
use nix::sys::signal::Signal;
use nix::sys::wait::WaitPidFlag;
use nix::sys::wait::WaitStatus;
use nix::unistd::Pid;
use std::mem::MaybeUninit;
use std::os::unix::io::RawFd;
use super::Errno;
#[derive(Clone, Copy, PartialEq, Eq)]
pub enum IdType {
@ -146,12 +147,13 @@ pub fn waitid(waitid_type: IdType, flags: WaitPidFlag) -> Result<WaitStatus, Err
#[cfg(test)]
mod tests {
use super::*;
use nix::sys::signal::Signal;
use nix::sys::wait::WaitPidFlag;
use nix::unistd;
use nix::unistd::ForkResult;
use super::*;
#[test]
fn waitid_w_exited_0() {
let fork_result = unsafe { unistd::fork() };

View file

@ -9,15 +9,10 @@
//! `Tracer` type, plus ways to spawn it and retrieve its output.
use crate::cp;
use crate::gdbstub::GdbServer;
use crate::task::Child;
use crate::task::TracedTask;
use crate::trace;
use crate::trace::Error as TraceError;
use crate::trace::Event;
use crate::trace::Running;
use crate::trace::Stopped;
use std::io::Write;
use std::net::SocketAddr;
use std::path::PathBuf;
use std::sync::Arc;
use anyhow::Context;
use futures::future;
@ -29,9 +24,6 @@ use nix::sys::signal;
use nix::sys::signal::Signal;
use nix::unistd;
use nix::unistd::ForkResult;
use tokio::sync::broadcast;
use tokio::sync::mpsc;
use reverie::process::seccomp;
use reverie::process::ChildStderr;
use reverie::process::ChildStdin;
@ -46,11 +38,18 @@ use reverie::GlobalTool;
use reverie::Pid;
use reverie::Subscription;
use reverie::Tool;
use tokio::sync::broadcast;
use tokio::sync::mpsc;
use std::io::Write;
use std::net::SocketAddr;
use std::path::PathBuf;
use std::sync::Arc;
use crate::cp;
use crate::gdbstub::GdbServer;
use crate::task::Child;
use crate::task::TracedTask;
use crate::trace;
use crate::trace::Error as TraceError;
use crate::trace::Event;
use crate::trace::Running;
use crate::trace::Stopped;
/// Represents the tracer.
///

View file

@ -7,12 +7,8 @@
* LICENSE file in the root directory of this source tree.
*/
use crate::perf::do_branches;
use crate::perf::PerfCounter;
use crate::timer::get_rcb_perf_config;
use crate::timer::AMD_VENDOR;
use crate::timer::INTEL_VENDOR;
use core::mem;
use perf_event_open_sys::bindings as perf;
use raw_cpuid::CpuId;
use raw_cpuid::FeatureInfo;
@ -21,6 +17,12 @@ use thiserror::Error;
use tracing::error;
use tracing::warn;
use crate::perf::do_branches;
use crate::perf::PerfCounter;
use crate::timer::get_rcb_perf_config;
use crate::timer::AMD_VENDOR;
use crate::timer::INTEL_VENDOR;
const IN_TXCP: u64 = 1 << 33;
const NUM_BRANCHES: u64 = 500;

View file

@ -12,8 +12,9 @@
*/
//! provide APIs to disable VDSOs at runtime.
use goblin::elf::Elf;
use std::collections::HashMap;
use goblin::elf::Elf;
use lazy_static::lazy_static;
use nix::sys::mman::ProtFlags;
use nix::unistd;
@ -23,7 +24,6 @@ use reverie::syscalls::Mprotect;
use reverie::Error;
use reverie::Guest;
use reverie::Tool;
use std::collections::HashMap;
use tracing::debug;
/*

View file

@ -6,14 +6,15 @@
* This source code is licensed under the BSD-style license found in the
* LICENSE file in the root directory of this source tree.
*/
use core::fmt;
use serde::Deserialize;
use serde::Serialize;
use crate::Displayable;
use crate::FromToRaw;
use crate::MemoryAccess;
use core::fmt;
use serde::Deserialize;
use serde::Serialize;
bitflags::bitflags! {
/// Flags used with the `clone`, `clone3`, or `unshare` syscalls.
#[derive(Serialize, Deserialize)]

View file

@ -9,15 +9,15 @@
//! Everything related to ioctl arguments.
use serde::Deserialize;
use serde::Serialize;
use crate::Addr;
use crate::AddrMut;
use crate::Errno;
use crate::FromToRaw;
use crate::MemoryAccess;
use serde::Deserialize;
use serde::Serialize;
/// The type of ioctl from the perspective of userspace. That is, whether
/// userspace is reading, writing, or doing nothing.
#[derive(Copy, Clone, Eq, PartialEq, Debug)]

View file

@ -11,7 +11,6 @@
//! potentially many syscalls.
use core::fmt;
use std::ffi::CString;
use std::ffi::OsString;
use std::os::unix::ffi::OsStringExt;
@ -24,16 +23,14 @@ mod poll;
mod stat;
mod time;
pub use clone::*;
pub use fcntl::FcntlCmd;
use nix::sys::stat::Mode;
use nix::sys::stat::SFlag;
use nix::unistd::Pid;
pub use poll::*;
use serde::Deserialize;
use serde::Serialize;
pub use clone::*;
pub use fcntl::FcntlCmd;
pub use poll::*;
pub use stat::*;
pub use time::*;

View file

@ -9,14 +9,15 @@
//! Serialization support for poll-related enums and structs.
use core::fmt;
use serde::Deserialize;
use serde::Serialize;
use crate::Displayable;
use crate::FromToRaw;
use crate::MemoryAccess;
use core::fmt;
use serde::Deserialize;
use serde::Serialize;
/// A serializable version of `libc::pollfd`.
#[derive(Serialize, Deserialize, Copy, Clone, Eq, PartialEq, Debug, Default)]
#[repr(C)]

View file

@ -130,10 +130,11 @@ impl From<libc::statx> for StatxBuf {
#[cfg(test)]
mod tests {
use super::*;
use core::mem::align_of;
use core::mem::size_of;
use super::*;
#[test]
fn sizes() {
assert_eq!(size_of::<StatBuf>(), size_of::<libc::stat>());

View file

@ -8,11 +8,6 @@
*/
use core::fmt;
use crate::memory::Addr;
use crate::memory::AddrMut;
use crate::memory::MemoryAccess;
use crate::Errno;
use nix::fcntl::AtFlags;
use nix::fcntl::OFlag;
use nix::sched::CloneFlags;
@ -31,6 +26,11 @@ use nix::sys::timerfd::TimerFlags;
use nix::sys::wait::WaitPidFlag;
use nix::unistd::Pid;
use crate::memory::Addr;
use crate::memory::AddrMut;
use crate::memory::MemoryAccess;
use crate::Errno;
/// A wrapper that combines an address space and a syscall. This is useful for
/// displaying the contents of syscall pointer inputs.
pub struct Display<'a, M, T> {

View file

@ -27,13 +27,13 @@ mod memory;
mod raw;
mod syscalls;
// Re-export the only things that might be needed from the syscalls crate
pub use ::syscalls::Errno;
pub use ::syscalls::SyscallArgs;
pub use ::syscalls::Sysno;
pub use crate::args::*;
pub use crate::display::*;
pub use crate::memory::*;
pub use crate::raw::*;
pub use crate::syscalls::*;
// Re-export the only things that might be needed from the syscalls crate
pub use ::syscalls::Errno;
pub use ::syscalls::SyscallArgs;
pub use ::syscalls::Sysno;

View file

@ -9,7 +9,6 @@
use core::fmt;
use core::marker::PhantomData;
use core::ptr::NonNull;
// Only used for `IoSlice`. To be fully no_std, this should get replaced with a
// custom `IoSlice` type.
use std::io;
@ -438,10 +437,11 @@ fn next_page(addr: usize) -> usize {
#[cfg(test)]
mod test {
use super::*;
use core::mem::align_of;
use core::mem::size_of;
use super::*;
#[test]
fn test_next_page() {
assert_eq!(next_page(0x1000), 0x2000);

View file

@ -10,7 +10,6 @@ mod addr;
mod local;
use core::mem;
use std::ffi::CString;
use std::io;

View file

@ -190,9 +190,10 @@ where
#[cfg(test)]
mod test {
use super::*;
use nix::unistd::Pid;
use super::*;
#[test]
fn test_results() {
assert_eq!(

View file

@ -11,8 +11,9 @@
//! "families"). These are useful when needing to handle families in very similar
//! ways.
use super::Syscall;
use derive_more::From;
use super::Syscall;
use crate::args::ClockId;
use crate::args::CloneFlags;
use crate::args::StatPtr;
@ -21,8 +22,6 @@ use crate::memory::Addr;
use crate::memory::AddrMut;
use crate::memory::MemoryAccess;
use derive_more::From;
/// Represents the `[p]write{64,v,v2}` family of syscalls. All of these syscalls
/// have an associated file descriptor.
#[derive(From, Debug, Copy, Clone, Eq, PartialEq)]

View file

@ -9,6 +9,25 @@
pub mod family;
use ::syscalls::SyscallArgs;
use ::syscalls::Sysno;
// Re-export flags that used by syscalls from the `nix` crate so downstream
// projects don't need to add another dependency on it.
pub use nix::fcntl::AtFlags;
pub use nix::fcntl::OFlag;
// FIXME: Switch everything over to `crate::args::CloneFlags`.
use nix::sched::CloneFlags;
pub use nix::sys::epoll::EpollCreateFlags;
pub use nix::sys::eventfd::EfdFlags;
pub use nix::sys::inotify::InitFlags;
pub use nix::sys::mman::MapFlags;
pub use nix::sys::mman::ProtFlags;
pub use nix::sys::signalfd::SfdFlags;
pub use nix::sys::socket::SockFlag;
pub use nix::sys::stat::Mode;
pub use nix::sys::timerfd::TimerFlags;
pub use nix::sys::wait::WaitPidFlag;
use crate::args::ioctl;
use crate::args::ArchPrctlCmd;
use crate::args::CArrayPtr;
@ -29,26 +48,6 @@ use crate::display::Displayable;
use crate::memory::Addr;
use crate::memory::AddrMut;
use crate::raw::FromToRaw;
use ::syscalls::SyscallArgs;
use ::syscalls::Sysno;
// FIXME: Switch everything over to `crate::args::CloneFlags`.
use nix::sched::CloneFlags;
// Re-export flags that used by syscalls from the `nix` crate so downstream
// projects don't need to add another dependency on it.
pub use nix::fcntl::AtFlags;
pub use nix::fcntl::OFlag;
pub use nix::sys::epoll::EpollCreateFlags;
pub use nix::sys::eventfd::EfdFlags;
pub use nix::sys::inotify::InitFlags;
pub use nix::sys::mman::MapFlags;
pub use nix::sys::mman::ProtFlags;
pub use nix::sys::signalfd::SfdFlags;
pub use nix::sys::socket::SockFlag;
pub use nix::sys::stat::Mode;
pub use nix::sys::timerfd::TimerFlags;
pub use nix::sys::wait::WaitPidFlag;
/// A trait that all syscalls implement.
pub trait SyscallInfo: Displayable + Copy + Send {
@ -3284,17 +3283,17 @@ typed_syscall! {
#[cfg(test)]
mod test {
use super::*;
use crate::Displayable;
use crate::LocalMemory;
use crate::ReadAddr;
use std::ffi::CString;
use std::path::Path;
use syscalls::SyscallArgs;
use syscalls::Sysno;
use super::*;
use crate::Displayable;
use crate::LocalMemory;
use crate::ReadAddr;
#[test]
fn test_syscall_open() {
assert_eq!(Open::NAME, "open");

View file

@ -11,7 +11,6 @@
//! Each tool with this backend is a standalone executable, and thus
//! needs its own CLI.
use chrono::Local;
use std::error::Error;
use std::ffi::OsStr;
use std::fmt::Display;
@ -19,13 +18,14 @@ use std::io;
use std::path::Path;
use std::path::PathBuf;
use std::str::FromStr;
use chrono::Local;
use reverie::process::Command;
use structopt::StructOpt;
use tracing_appender::non_blocking::WorkerGuard;
use tracing_subscriber::fmt::MakeWriter;
use tracing_subscriber::EnvFilter;
use reverie::process::Command;
/// Parses an environment variable command-line argument.
pub fn parse_env<T, U>(s: &str) -> Result<(T, U), Box<dyn Error>>
where

View file

@ -9,6 +9,9 @@
//! An example that tracks thread pedigree using local state.
use std::io;
use std::mem;
use bitvec::bitvec;
use bitvec::order::Msb0;
use bitvec::vec::BitVec;
@ -16,8 +19,6 @@ use libc::pid_t;
use nix::unistd::Pid;
use serde::Deserialize;
use serde::Serialize;
use std::io;
use std::mem;
/// Helper function that finds the longest run of repeating bits in a bitvec
fn longest_run(sequence: &BitVec) -> (usize, usize) {

View file

@ -6,15 +6,15 @@
* This source code is licensed under the BSD-style license found in the
* LICENSE file in the root directory of this source tree.
*/
use crate::syscalls::Addr;
use crate::Pid;
use std::collections::BTreeMap;
use std::fs;
use std::io;
use byteorder::NativeEndian;
use byteorder::ReadBytesExt;
use std::collections::BTreeMap;
use std::fs;
use std::io;
use crate::syscalls::Addr;
use crate::Pid;
/// Represents the auxv table of a process.
///

View file

@ -6,10 +6,10 @@
* This source code is licensed under the BSD-style license found in the
* LICENSE file in the root directory of this source tree.
*/
use super::Pid;
use std::path::PathBuf;
use super::Pid;
/// A segment of a memory map for a loaded library.
#[derive(Debug, Copy, Clone)]
pub struct LibrarySegment {
@ -59,9 +59,10 @@ pub struct Libraries {
impl Libraries {
/// Loads the list of libraries that have been mapped by the given process.
pub fn new(pid: Pid) -> Result<Self, procfs::ProcError> {
use procfs::process::MMapPath;
use std::collections::BTreeMap;
use procfs::process::MMapPath;
let process = procfs::process::Process::new(pid.as_raw())?;
let maps = process.maps()?;

View file

@ -11,18 +11,18 @@ mod library;
mod symbols;
use core::fmt;
use serde::Deserialize;
use serde::Serialize;
use std::borrow::Cow;
use std::fs::File;
use std::io;
use std::io::Read;
use std::path::PathBuf;
use super::Pid;
use serde::Deserialize;
use serde::Serialize;
use self::cache::cache;
use self::library::Libraries;
use super::Pid;
/// A backtrace is a list of stack frames. These stack frames may have originated
/// from a remote process.

View file

@ -9,9 +9,8 @@
//! Error handling.
use thiserror::Error;
pub use reverie_syscalls::Errno;
use thiserror::Error;
/// A general error.
#[derive(Error, Debug)]

View file

@ -31,17 +31,15 @@ pub use auxv::*;
pub use backtrace::*;
pub use error::*;
pub use guest::*;
pub use process::ExitStatus;
pub use process::Pid;
pub use rdtsc::*;
pub use reverie_process as process;
pub use stack::*;
pub use subscription::*;
pub use timer::*;
pub use tool::*;
pub use reverie_process as process;
pub use process::ExitStatus;
pub use process::Pid;
/// The identifier for a specific thread, corresponding to the output of gettid.
/// In many cases, Linux blurs the Pid/Tid distinction, but Reverie should
/// consistently use TIDs when referring to threads, and Pids when referring to
@ -51,24 +49,20 @@ pub use process::Pid;
/// is deprecated. `Tid` may be a distinct newtype in the future.
pub type Tid = Pid;
/// typed syscalls.
pub use reverie_syscalls as syscalls;
/// CPUID result.
pub use raw_cpuid::CpuIdResult;
// Reexport nix Signal type.
pub use nix::sys::signal::Signal;
/// Required for `impl Tool for MyTool` blocks.
///
/// NOTE: This is just an alias for `async_trait` for now, but may be extended in
/// the future to do more things (like derive syscall subscriptions).
pub use async_trait::async_trait as tool;
/// Required for `impl GlobalTool for MyGlobalTool` blocks.
///
/// NOTE: This is just an alias for `async_trait` for now, but may be extended in
/// the future to do more things (like deriving Request/Response types from
/// method names).
pub use async_trait::async_trait as global_tool;
// Reexport nix Signal type.
pub use nix::sys::signal::Signal;
/// CPUID result.
pub use raw_cpuid::CpuIdResult;
/// typed syscalls.
pub use reverie_syscalls as syscalls;

View file

@ -12,6 +12,7 @@
use core::arch::x86_64::__rdtscp;
use core::arch::x86_64::_rdtsc;
use core::mem::MaybeUninit;
use serde::Deserialize;
use serde::Serialize;

View file

@ -6,9 +6,8 @@
* This source code is licensed under the BSD-style license found in the
* LICENSE file in the root directory of this source tree.
*/
use reverie_syscalls::Sysno;
use bitflags::bitflags;
use reverie_syscalls::Sysno;
use syscalls::SysnoSet;
bitflags! {

View file

@ -13,6 +13,13 @@
//! thread) instrumentation, though in some backends these will execute in the
//! same process.
use async_trait::async_trait;
use raw_cpuid::cpuid;
use raw_cpuid::CpuIdResult;
use reverie_syscalls::Syscall;
use serde::de::DeserializeOwned;
use serde::Serialize;
use crate::error::Errno;
use crate::error::Error;
use crate::guest::Guest;
@ -23,12 +30,6 @@ use crate::Pid;
use crate::Signal;
use crate::Subscription;
use crate::Tid;
use async_trait::async_trait;
use raw_cpuid::cpuid;
use raw_cpuid::CpuIdResult;
use reverie_syscalls::Syscall;
use serde::de::DeserializeOwned;
use serde::Serialize;
/// The global half of a complete Reverie tool.
///

View file

@ -16,7 +16,6 @@ use reverie::Error;
use reverie::ExitStatus;
use reverie::Guest;
use reverie::Tool;
use serde::Deserialize;
use serde::Serialize;

View file

@ -10,6 +10,13 @@
//! Basic tests that don't fall into some other category.
#[allow(unused_imports)]
use std::ffi::CString;
#[allow(unused_imports)]
use std::io::Write;
use std::sync::atomic::AtomicU64;
use std::sync::atomic::Ordering;
#[allow(unused_imports)]
use nix::sys::wait;
#[allow(unused_imports)]
@ -35,12 +42,6 @@ use reverie_ptrace::testing::test_cmd;
use reverie_ptrace::testing::test_fn;
use serde::Deserialize;
use serde::Serialize;
#[allow(unused_imports)]
use std::ffi::CString;
#[allow(unused_imports)]
use std::io::Write;
use std::sync::atomic::AtomicU64;
use std::sync::atomic::Ordering;
#[derive(Debug, serde::Serialize, serde::Deserialize, Default)]
struct NoopTool;
@ -182,11 +183,12 @@ fn run_guest_func_print_test() {
#[cfg(not(sanitized))]
#[test]
fn orphans() {
use nix::unistd::fork;
use nix::unistd::ForkResult;
use std::thread;
use std::time::Duration;
use nix::unistd::fork;
use nix::unistd::ForkResult;
let (output, _state) = test_fn::<CounterLocal, _>(|| {
// Spawn a child process and make sure the parent exits before the child
// process.

Some files were not shown because too many files have changed in this diff Show more