mirror of
https://github.com/facebookexperimental/reverie.git
synced 2024-11-28 01:06:45 +00:00
Remove unused pedigree example
Summary: Removing this to remove another dependency on `reverie-util`, so we can eventually get rid of it. Reviewed By: rrnewton Differential Revision: D41629842 fbshipit-source-id: bf6d518db6e5ff9f4149936a7dabc0e912133886
This commit is contained in:
parent
7ff30097d7
commit
68cb6d5f3a
3 changed files with 0 additions and 120 deletions
|
@ -36,10 +36,6 @@ path = "debug.rs"
|
||||||
name = "noop"
|
name = "noop"
|
||||||
path = "noop.rs"
|
path = "noop.rs"
|
||||||
|
|
||||||
[[bin]]
|
|
||||||
name = "pedigree"
|
|
||||||
path = "pedigree.rs"
|
|
||||||
|
|
||||||
[[bin]]
|
[[bin]]
|
||||||
name = "strace"
|
name = "strace"
|
||||||
path = "strace/main.rs"
|
path = "strace/main.rs"
|
||||||
|
@ -51,7 +47,6 @@ path = "strace_minimal.rs"
|
||||||
[dependencies]
|
[dependencies]
|
||||||
anyhow = "1.0.65"
|
anyhow = "1.0.65"
|
||||||
clap = { version = "3.2.17", features = ["derive", "env", "regex", "unicode", "wrap_help"] }
|
clap = { version = "3.2.17", features = ["derive", "env", "regex", "unicode", "wrap_help"] }
|
||||||
nix = "0.25"
|
|
||||||
reverie = { version = "0.1.0", path = "../reverie" }
|
reverie = { version = "0.1.0", path = "../reverie" }
|
||||||
reverie-ptrace = { version = "0.1.0", path = "../reverie-ptrace" }
|
reverie-ptrace = { version = "0.1.0", path = "../reverie-ptrace" }
|
||||||
reverie-util = { version = "0.1.0", path = "../reverie-util" }
|
reverie-util = { version = "0.1.0", path = "../reverie-util" }
|
||||||
|
|
|
@ -37,17 +37,6 @@ This example tool intercepts write events on stdout and stderr and
|
||||||
manipulates either when those outputs are released, or the scheduling order
|
manipulates either when those outputs are released, or the scheduling order
|
||||||
that determines the order of printed output.
|
that determines the order of printed output.
|
||||||
|
|
||||||
# pedigree: Deterministic virtual process IDs
|
|
||||||
|
|
||||||
This tool monitors the spawning of new processes and maps each new PID to a
|
|
||||||
deterministic virtual PID. The new virtual PID is reported after each
|
|
||||||
process-spawning syscall.
|
|
||||||
|
|
||||||
This tool is a work-in-progress and is not yet functioning.
|
|
||||||
|
|
||||||
`pedigree.rs` is an implementation of pedigree / virtual PID generation using local state.
|
|
||||||
`virtual_process_tree.rs` is an implementation which uses global state.
|
|
||||||
|
|
||||||
# strace: Reverie Echo Tool
|
# strace: Reverie Echo Tool
|
||||||
|
|
||||||
This instrumentation tool simply echos intercepted events, like strace.
|
This instrumentation tool simply echos intercepted events, like strace.
|
||||||
|
|
|
@ -1,104 +0,0 @@
|
||||||
/*
|
|
||||||
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
||||||
* All rights reserved.
|
|
||||||
*
|
|
||||||
* This source code is licensed under the BSD-style license found in the
|
|
||||||
* LICENSE file in the root directory of this source tree.
|
|
||||||
*/
|
|
||||||
|
|
||||||
//! An example that tracks thread pedigree using local state
|
|
||||||
use clap::Parser;
|
|
||||||
use reverie::syscalls::Syscall;
|
|
||||||
use reverie::Error;
|
|
||||||
use reverie::Guest;
|
|
||||||
use reverie::Pid;
|
|
||||||
use reverie::Tool;
|
|
||||||
use reverie_util::pedigree::Pedigree;
|
|
||||||
use reverie_util::CommonToolArguments;
|
|
||||||
use serde::Deserialize;
|
|
||||||
use serde::Serialize;
|
|
||||||
use tracing::debug;
|
|
||||||
use tracing::trace;
|
|
||||||
|
|
||||||
// TODO: Add handle pedigree forking, initialization, etc. to tool.
|
|
||||||
// This tool is NOT FUNCTIONAL in its current state.
|
|
||||||
|
|
||||||
#[derive(Debug, Serialize, Deserialize, Default, Clone)]
|
|
||||||
struct PedigreeLocal(Pedigree);
|
|
||||||
|
|
||||||
#[reverie::tool]
|
|
||||||
impl Tool for PedigreeLocal {
|
|
||||||
type GlobalState = ();
|
|
||||||
type ThreadState = PedigreeLocal;
|
|
||||||
|
|
||||||
fn new(pid: Pid, _cfg: &()) -> Self {
|
|
||||||
debug!("[pedigree] initialize pedigree for pid {}", pid);
|
|
||||||
PedigreeLocal(Pedigree::new())
|
|
||||||
}
|
|
||||||
|
|
||||||
fn init_thread_state(
|
|
||||||
&self,
|
|
||||||
_tid: Pid,
|
|
||||||
parent: Option<(Pid, &Self::ThreadState)>,
|
|
||||||
) -> Self::ThreadState {
|
|
||||||
if let Some((_, state)) = parent {
|
|
||||||
let mut parent = state.clone();
|
|
||||||
let child = parent.0.fork_mut();
|
|
||||||
trace!("child pedigree: {:?}", child);
|
|
||||||
PedigreeLocal(child)
|
|
||||||
} else {
|
|
||||||
PedigreeLocal(Pedigree::new())
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
async fn handle_syscall_event<T: Guest<Self>>(
|
|
||||||
&self,
|
|
||||||
guest: &mut T,
|
|
||||||
syscall: Syscall,
|
|
||||||
) -> Result<i64, Error> {
|
|
||||||
match syscall {
|
|
||||||
#[cfg(target_arch = "x86_64")]
|
|
||||||
Syscall::Fork(_) | Syscall::Vfork(_) => self.handle_fork(syscall, guest).await,
|
|
||||||
Syscall::Clone(_) => self.handle_fork(syscall, guest).await,
|
|
||||||
Syscall::Getpid(_) | Syscall::Getppid(_) | Syscall::Gettid(_) | Syscall::Getpgid(_) => {
|
|
||||||
let pid = guest.inject(syscall).await?;
|
|
||||||
let vpid = nix::unistd::Pid::try_from(&self.0).unwrap();
|
|
||||||
trace!("getpid returned {:?} vpid: {:?}", pid, vpid);
|
|
||||||
Ok(pid)
|
|
||||||
}
|
|
||||||
Syscall::Setpgid(_) => {
|
|
||||||
panic!("[pedigree] setpgid is not allowed.");
|
|
||||||
}
|
|
||||||
_ => guest.tail_inject(syscall).await,
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
impl PedigreeLocal {
|
|
||||||
async fn handle_fork(
|
|
||||||
&self,
|
|
||||||
syscall: Syscall,
|
|
||||||
guest: &mut impl Guest<Self>,
|
|
||||||
) -> Result<i64, Error> {
|
|
||||||
let retval = guest.inject(syscall).await?;
|
|
||||||
let pedigree = guest.thread_state_mut().0.fork_mut();
|
|
||||||
trace!(
|
|
||||||
"got new pedigree: {:?} => {:x?}",
|
|
||||||
pedigree,
|
|
||||||
nix::unistd::Pid::try_from(&pedigree)
|
|
||||||
);
|
|
||||||
Ok(retval)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
#[tokio::main]
|
|
||||||
async fn main() -> Result<(), Error> {
|
|
||||||
let args = CommonToolArguments::from_args();
|
|
||||||
let log_guard = args.init_tracing();
|
|
||||||
let tracer = reverie_ptrace::TracerBuilder::<PedigreeLocal>::new(args.into())
|
|
||||||
.spawn()
|
|
||||||
.await?;
|
|
||||||
let (status, _global_state) = tracer.wait().await?;
|
|
||||||
drop(log_guard); // Flush logs before exiting.
|
|
||||||
status.raise_or_exit()
|
|
||||||
}
|
|
Loading…
Reference in a new issue