mirror of
https://github.com/facebookexperimental/reverie.git
synced 2024-11-24 12:17:50 +00:00
Remove dependencies on associated_type_defaults unstable feature
Summary: Removes usage of the `associated_type_defaults` unstable feature, but does not actually disable the feature yet. This brings us one step closer to removing all usage of unstable nightly features, which will allow publishing a crate on https://crates.io. Reviewed By: rrnewton Differential Revision: D41388745 fbshipit-source-id: f347a577857a713fe3088a556cbf37ffe92e5553
This commit is contained in:
parent
58bc1cce8b
commit
9a942d055f
33 changed files with 102 additions and 4 deletions
|
@ -71,6 +71,8 @@ struct ChaosToolGlobal {}
|
|||
|
||||
#[reverie::global_tool]
|
||||
impl GlobalTool for ChaosToolGlobal {
|
||||
type Request = ();
|
||||
type Response = ();
|
||||
type Config = ChaosOpts;
|
||||
|
||||
async fn receive_rpc(&self, _from: Pid, _request: ()) {}
|
||||
|
@ -78,8 +80,8 @@ impl GlobalTool for ChaosToolGlobal {
|
|||
|
||||
#[reverie::tool]
|
||||
impl Tool for ChaosTool {
|
||||
type ThreadState = bool;
|
||||
type GlobalState = ChaosToolGlobal;
|
||||
type ThreadState = bool;
|
||||
|
||||
fn new(_pid: Pid, _cfg: &ChaosOpts) -> Self {
|
||||
Self {
|
||||
|
|
|
@ -46,6 +46,7 @@ impl Default for GlobalState {
|
|||
impl GlobalTool for GlobalState {
|
||||
type Request = ThreadExit;
|
||||
type Response = ();
|
||||
type Config = ();
|
||||
|
||||
async fn receive_rpc(&self, _pid: Pid, event: ThreadExit) {
|
||||
let mut events = self.events.lock().unwrap();
|
||||
|
|
|
@ -68,6 +68,8 @@ struct Inner {
|
|||
impl GlobalTool for ChunkyPrintGlobal {
|
||||
type Request = Msg;
|
||||
type Response = ();
|
||||
type Config = ();
|
||||
|
||||
async fn receive_rpc(&self, from: Tid, m: Msg) {
|
||||
let mut mg = self.0.lock().unwrap();
|
||||
match m {
|
||||
|
|
|
@ -41,6 +41,8 @@ pub struct IncrMsg(Sysno);
|
|||
impl GlobalTool for CounterGlobal {
|
||||
type Request = IncrMsg;
|
||||
type Response = ();
|
||||
type Config = ();
|
||||
|
||||
async fn init_global_state(_: &Self::Config) -> Self {
|
||||
CounterGlobal {
|
||||
num_syscalls: AtomicU64::new(0),
|
||||
|
@ -55,6 +57,7 @@ impl GlobalTool for CounterGlobal {
|
|||
#[reverie::tool]
|
||||
impl Tool for CounterLocal {
|
||||
type GlobalState = CounterGlobal;
|
||||
type ThreadState = ();
|
||||
|
||||
async fn handle_syscall_event<T: Guest<Self>>(
|
||||
&self,
|
||||
|
|
|
@ -65,6 +65,8 @@ pub struct IncrMsg(u64, u64);
|
|||
impl GlobalTool for CounterGlobal {
|
||||
type Request = IncrMsg;
|
||||
type Response = ();
|
||||
type Config = ();
|
||||
|
||||
async fn init_global_state(_: &Self::Config) -> Self {
|
||||
CounterGlobal {
|
||||
inner: Mutex::new(GlobalInner {
|
||||
|
@ -74,6 +76,7 @@ impl GlobalTool for CounterGlobal {
|
|||
}),
|
||||
}
|
||||
}
|
||||
|
||||
async fn receive_rpc(&self, _from: Pid, IncrMsg(n, t): IncrMsg) -> Self::Response {
|
||||
let mut mg = self.inner.lock().unwrap();
|
||||
mg.total_syscalls += n;
|
||||
|
|
|
@ -16,6 +16,9 @@ use reverie_util::CommonToolArguments;
|
|||
#[derive(Debug, Default)]
|
||||
struct DebugTool;
|
||||
impl Tool for DebugTool {
|
||||
type GlobalState = ();
|
||||
type ThreadState = ();
|
||||
|
||||
fn subscriptions(_cfg: &()) -> Subscription {
|
||||
Subscription::none()
|
||||
}
|
||||
|
|
|
@ -20,6 +20,9 @@ struct NoopTool;
|
|||
|
||||
#[reverie::tool]
|
||||
impl Tool for NoopTool {
|
||||
type GlobalState = ();
|
||||
type ThreadState = ();
|
||||
|
||||
fn subscriptions(_cfg: &()) -> Subscription {
|
||||
Subscription::none()
|
||||
}
|
||||
|
|
|
@ -28,6 +28,7 @@ struct PedigreeLocal(Pedigree);
|
|||
|
||||
#[reverie::tool]
|
||||
impl Tool for PedigreeLocal {
|
||||
type GlobalState = ();
|
||||
type ThreadState = PedigreeLocal;
|
||||
|
||||
fn new(pid: Pid, _cfg: &()) -> Self {
|
||||
|
|
|
@ -32,6 +32,7 @@ pub struct Strace;
|
|||
#[reverie::tool]
|
||||
impl Tool for Strace {
|
||||
type GlobalState = GlobalState;
|
||||
type ThreadState = ();
|
||||
|
||||
fn subscriptions(cfg: &Config) -> Subscription {
|
||||
// Check if we're only excluding things.
|
||||
|
|
|
@ -19,6 +19,9 @@ struct StraceTool {}
|
|||
|
||||
#[reverie::tool]
|
||||
impl Tool for StraceTool {
|
||||
type GlobalState = ();
|
||||
type ThreadState = ();
|
||||
|
||||
async fn handle_syscall_event<T: Guest<Self>>(
|
||||
&self,
|
||||
guest: &mut T,
|
||||
|
|
|
@ -130,6 +130,8 @@ pub trait Guest<T: Tool>: Send + GlobalRPC<T::GlobalState> {
|
|||
///
|
||||
/// #[reverie::tool]
|
||||
/// impl Tool for MyTool {
|
||||
/// /// Global state is unused
|
||||
/// type GlobalState = ();
|
||||
/// /// Count of successful syscalls.
|
||||
/// type ThreadState = u64;
|
||||
///
|
||||
|
@ -219,6 +221,9 @@ pub trait Guest<T: Tool>: Send + GlobalRPC<T::GlobalState> {
|
|||
///
|
||||
/// #[reverie::tool]
|
||||
/// impl Tool for MyTool {
|
||||
/// type GlobalState = ();
|
||||
/// type ThreadState = ();
|
||||
///
|
||||
/// async fn handle_syscall_event<T: Guest<Self>>(
|
||||
/// &self,
|
||||
/// guest: &mut T,
|
||||
|
|
|
@ -21,6 +21,9 @@ struct TestTool;
|
|||
|
||||
#[reverie::tool]
|
||||
impl Tool for TestTool {
|
||||
type GlobalState = ();
|
||||
type ThreadState = ();
|
||||
|
||||
async fn handle_syscall_event<T: Guest<Self>>(
|
||||
&self,
|
||||
guest: &mut T,
|
||||
|
|
|
@ -43,7 +43,10 @@ use serde::Serialize;
|
|||
|
||||
#[derive(Debug, Default)]
|
||||
struct NoopTool;
|
||||
impl Tool for NoopTool {}
|
||||
impl Tool for NoopTool {
|
||||
type GlobalState = ();
|
||||
type ThreadState = ();
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn noop_tool_test() {
|
||||
|
@ -71,6 +74,8 @@ pub struct IncrMsg(Sysno);
|
|||
impl GlobalTool for CounterGlobal {
|
||||
type Request = IncrMsg;
|
||||
type Response = ();
|
||||
type Config = ();
|
||||
|
||||
async fn receive_rpc(&self, _from: Pid, _: IncrMsg) -> Self::Response {
|
||||
AtomicU64::fetch_add(&self.num_syscalls, 1, Ordering::SeqCst);
|
||||
}
|
||||
|
@ -79,6 +84,8 @@ impl GlobalTool for CounterGlobal {
|
|||
#[reverie::tool]
|
||||
impl Tool for CounterLocal {
|
||||
type GlobalState = CounterGlobal;
|
||||
type ThreadState = ();
|
||||
|
||||
async fn handle_syscall_event<T: Guest<Self>>(
|
||||
&self,
|
||||
guest: &mut T,
|
||||
|
|
|
@ -93,6 +93,7 @@ const TIMEOUT: TimerSchedule = TimerSchedule::Rcbs(120_000_000);
|
|||
#[reverie::tool]
|
||||
impl Tool for LocalState {
|
||||
type GlobalState = GlobalState;
|
||||
type ThreadState = ();
|
||||
|
||||
async fn handle_thread_start<T: Guest<Self>>(&self, guest: &mut T) -> Result<(), Error> {
|
||||
guest.send_rpc(IncrMsg::Increment).await;
|
||||
|
|
|
@ -25,6 +25,9 @@ struct LocalStateInject;
|
|||
|
||||
#[reverie::tool]
|
||||
impl Tool for LocalStateTailInject {
|
||||
type GlobalState = ();
|
||||
type ThreadState = ();
|
||||
|
||||
async fn handle_syscall_event<T: Guest<Self>>(
|
||||
&self,
|
||||
guest: &mut T,
|
||||
|
@ -43,6 +46,9 @@ impl Tool for LocalStateTailInject {
|
|||
|
||||
#[reverie::tool]
|
||||
impl Tool for LocalStateInject {
|
||||
type GlobalState = ();
|
||||
type ThreadState = ();
|
||||
|
||||
async fn handle_syscall_event<T: Guest<Self>>(
|
||||
&self,
|
||||
guest: &mut T,
|
||||
|
|
|
@ -28,6 +28,7 @@ struct GlobalState {
|
|||
impl GlobalTool for GlobalState {
|
||||
type Request = ();
|
||||
type Response = u64;
|
||||
type Config = ();
|
||||
|
||||
// Just get the current time.
|
||||
async fn receive_rpc(&self, _from: Pid, _request: ()) -> u64 {
|
||||
|
@ -42,6 +43,7 @@ struct LocalState {}
|
|||
#[reverie::tool]
|
||||
impl Tool for LocalState {
|
||||
type GlobalState = GlobalState;
|
||||
type ThreadState = ();
|
||||
|
||||
fn subscriptions(_cfg: &()) -> Subscription {
|
||||
let mut s = Subscription::none();
|
||||
|
|
|
@ -53,7 +53,9 @@ fn is_syscall_restarted(errno: Errno) -> bool {
|
|||
|
||||
#[reverie::tool]
|
||||
impl Tool for LocalState {
|
||||
type GlobalState = ();
|
||||
type ThreadState = ThreadState;
|
||||
|
||||
async fn handle_signal_event<T: Guest<Self>>(
|
||||
&self,
|
||||
guest: &mut T,
|
||||
|
|
|
@ -33,6 +33,7 @@ struct GlobalState {
|
|||
impl GlobalTool for GlobalState {
|
||||
type Request = ExitStatus;
|
||||
type Response = ();
|
||||
type Config = ();
|
||||
|
||||
async fn receive_rpc(&self, from: Pid, exit_status: ExitStatus) -> Self::Response {
|
||||
self.exited
|
||||
|
@ -48,6 +49,7 @@ struct InjectExitTool {}
|
|||
#[reverie::tool]
|
||||
impl Tool for InjectExitTool {
|
||||
type GlobalState = GlobalState;
|
||||
type ThreadState = ();
|
||||
|
||||
async fn on_exit_process<G: GlobalRPC<Self::GlobalState>>(
|
||||
self,
|
||||
|
|
|
@ -30,6 +30,9 @@ pub struct GdbServerCommand {
|
|||
struct TestTool;
|
||||
|
||||
impl Tool for TestTool {
|
||||
type GlobalState = ();
|
||||
type ThreadState = ();
|
||||
|
||||
fn subscriptions(_cfg: &()) -> Subscription {
|
||||
Subscription::all()
|
||||
}
|
||||
|
|
|
@ -27,6 +27,7 @@ struct TestTool {}
|
|||
impl GlobalTool for GlobalState {
|
||||
type Request = ();
|
||||
type Response = ();
|
||||
type Config = ();
|
||||
|
||||
async fn receive_rpc(&self, _from: Tid, _threads: Self::Request) -> Self::Response {
|
||||
// TODO: replace this with an ivar read:
|
||||
|
@ -106,6 +107,9 @@ struct TestTool2 {}
|
|||
|
||||
#[reverie::tool]
|
||||
impl Tool for TestTool2 {
|
||||
type GlobalState = ();
|
||||
type ThreadState = ();
|
||||
|
||||
async fn handle_syscall_event<T: Guest<Self>>(
|
||||
&self,
|
||||
guest: &mut T,
|
||||
|
|
|
@ -30,6 +30,7 @@ struct GlobalState {
|
|||
impl GlobalTool for GlobalState {
|
||||
type Request = Rdtsc;
|
||||
type Response = RdtscResult;
|
||||
type Config = ();
|
||||
|
||||
async fn init_global_state(_: &Self::Config) -> Self {
|
||||
GlobalState {
|
||||
|
@ -59,6 +60,7 @@ struct LocalState {}
|
|||
#[reverie::tool]
|
||||
impl Tool for LocalState {
|
||||
type GlobalState = GlobalState;
|
||||
type ThreadState = ();
|
||||
|
||||
fn subscriptions(_cfg: &()) -> Subscription {
|
||||
let mut s = Subscription::none();
|
||||
|
|
|
@ -25,6 +25,9 @@ struct LocalState;
|
|||
|
||||
#[reverie::tool]
|
||||
impl Tool for LocalState {
|
||||
type GlobalState = ();
|
||||
type ThreadState = ();
|
||||
|
||||
async fn handle_syscall_event<T: Guest<Self>>(
|
||||
&self,
|
||||
guest: &mut T,
|
||||
|
|
|
@ -25,6 +25,7 @@ struct ThreadState;
|
|||
|
||||
#[reverie::tool]
|
||||
impl Tool for LocalState {
|
||||
type GlobalState = ();
|
||||
type ThreadState = ThreadState;
|
||||
|
||||
async fn handle_syscall_event<T: Guest<Self>>(
|
||||
|
|
|
@ -12,7 +12,10 @@ use reverie::Tool;
|
|||
struct LocalState;
|
||||
|
||||
#[reverie::tool]
|
||||
impl Tool for LocalState {}
|
||||
impl Tool for LocalState {
|
||||
type GlobalState = ();
|
||||
type ThreadState = ();
|
||||
}
|
||||
|
||||
#[cfg(all(not(sanitized), test))]
|
||||
mod tests {
|
||||
|
|
|
@ -28,6 +28,9 @@ struct LocalState;
|
|||
|
||||
#[reverie::tool]
|
||||
impl Tool for LocalState {
|
||||
type GlobalState = ();
|
||||
type ThreadState = ();
|
||||
|
||||
async fn handle_syscall_event<T: Guest<Self>>(
|
||||
&self,
|
||||
guest: &mut T,
|
||||
|
@ -96,6 +99,9 @@ struct LocalState2;
|
|||
|
||||
#[reverie::tool]
|
||||
impl Tool for LocalState2 {
|
||||
type GlobalState = ();
|
||||
type ThreadState = ();
|
||||
|
||||
async fn handle_syscall_event<T: Guest<Self>>(
|
||||
&self,
|
||||
guest: &mut T,
|
||||
|
@ -130,6 +136,9 @@ struct LocalState3;
|
|||
|
||||
#[reverie::tool]
|
||||
impl Tool for LocalState3 {
|
||||
type GlobalState = ();
|
||||
type ThreadState = ();
|
||||
|
||||
async fn handle_syscall_event<T: Guest<Self>>(
|
||||
&self,
|
||||
guest: &mut T,
|
||||
|
|
|
@ -24,6 +24,9 @@ const PRNG_SEED: [u8; 16] = [
|
|||
|
||||
#[reverie::tool]
|
||||
impl Tool for TestTool {
|
||||
type GlobalState = ();
|
||||
type ThreadState = ();
|
||||
|
||||
async fn handle_post_exec<T: Guest<Self>>(&self, guest: &mut T) -> Result<(), Errno> {
|
||||
if let Some(ptr) = guest.auxv().at_random() {
|
||||
// It is safe to mutate this address since libc has not yet had a
|
||||
|
|
|
@ -29,6 +29,8 @@ type Dupcount = u64;
|
|||
|
||||
#[reverie::global_tool]
|
||||
impl GlobalTool for TestTool {
|
||||
type Request = ();
|
||||
type Response = ();
|
||||
type Config = Dupcount;
|
||||
|
||||
async fn receive_rpc(&self, _from: Pid, _message: ()) {}
|
||||
|
@ -43,6 +45,7 @@ const NUM_REPS: Dupcount = 3;
|
|||
#[reverie::tool]
|
||||
impl Tool for TestTool {
|
||||
type GlobalState = TestTool;
|
||||
type ThreadState = ();
|
||||
|
||||
async fn handle_syscall_event<T: Guest<Self>>(
|
||||
&self,
|
||||
|
|
|
@ -23,6 +23,7 @@ struct TestTool {}
|
|||
#[reverie::tool]
|
||||
impl Tool for TestTool {
|
||||
type GlobalState = ();
|
||||
type ThreadState = ();
|
||||
}
|
||||
|
||||
const NUM_ELEMENTS: usize = 1_000_000;
|
||||
|
|
|
@ -14,7 +14,10 @@ use reverie::Tool;
|
|||
struct LocalState;
|
||||
|
||||
#[reverie::tool]
|
||||
impl Tool for LocalState {}
|
||||
impl Tool for LocalState {
|
||||
type GlobalState = ();
|
||||
type ThreadState = ();
|
||||
}
|
||||
|
||||
#[cfg(all(not(sanitized), test))]
|
||||
mod tests {
|
||||
|
|
|
@ -43,6 +43,7 @@ struct ThreadState {
|
|||
impl GlobalTool for GlobalState {
|
||||
type Request = Vec<(i32, usize, usize)>;
|
||||
type Response = ();
|
||||
type Config = ();
|
||||
|
||||
async fn receive_rpc(&self, from: Pid, threads: Self::Request) -> Self::Response {
|
||||
// Merge with global state.
|
||||
|
|
|
@ -19,6 +19,9 @@ struct TestTool;
|
|||
|
||||
#[reverie::tool]
|
||||
impl Tool for TestTool {
|
||||
type GlobalState = ();
|
||||
type ThreadState = ();
|
||||
|
||||
async fn handle_syscall_event<T: Guest<Self>>(
|
||||
&self,
|
||||
guest: &mut T,
|
||||
|
|
|
@ -19,6 +19,9 @@ struct LocalState;
|
|||
|
||||
#[reverie::tool]
|
||||
impl Tool for LocalState {
|
||||
type GlobalState = ();
|
||||
type ThreadState = ();
|
||||
|
||||
async fn handle_syscall_event<T: Guest<Self>>(
|
||||
&self,
|
||||
guest: &mut T,
|
||||
|
|
|
@ -27,6 +27,9 @@ struct LocalStateVforkClone;
|
|||
|
||||
#[reverie::tool]
|
||||
impl Tool for LocalStateVfork {
|
||||
type GlobalState = ();
|
||||
type ThreadState = ();
|
||||
|
||||
async fn handle_syscall_event<T: Guest<Self>>(
|
||||
&self,
|
||||
guest: &mut T,
|
||||
|
@ -49,6 +52,9 @@ impl Tool for LocalStateVfork {
|
|||
|
||||
#[reverie::tool]
|
||||
impl Tool for LocalStateVforkClone {
|
||||
type GlobalState = ();
|
||||
type ThreadState = ();
|
||||
|
||||
async fn handle_syscall_event<T: Guest<Self>>(
|
||||
&self,
|
||||
guest: &mut T,
|
||||
|
|
Loading…
Reference in a new issue