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:
Jason White 2022-11-18 12:36:51 -08:00 committed by Facebook GitHub Bot
parent 58bc1cce8b
commit 9a942d055f
33 changed files with 102 additions and 4 deletions

View file

@ -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 {

View file

@ -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();

View file

@ -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 {

View file

@ -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,

View file

@ -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;

View file

@ -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()
}

View file

@ -20,6 +20,9 @@ struct NoopTool;
#[reverie::tool]
impl Tool for NoopTool {
type GlobalState = ();
type ThreadState = ();
fn subscriptions(_cfg: &()) -> Subscription {
Subscription::none()
}

View file

@ -28,6 +28,7 @@ struct PedigreeLocal(Pedigree);
#[reverie::tool]
impl Tool for PedigreeLocal {
type GlobalState = ();
type ThreadState = PedigreeLocal;
fn new(pid: Pid, _cfg: &()) -> Self {

View file

@ -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.

View file

@ -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,

View file

@ -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,

View file

@ -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,

View file

@ -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,

View file

@ -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;

View file

@ -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,

View file

@ -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();

View file

@ -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,

View file

@ -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,

View file

@ -30,6 +30,9 @@ pub struct GdbServerCommand {
struct TestTool;
impl Tool for TestTool {
type GlobalState = ();
type ThreadState = ();
fn subscriptions(_cfg: &()) -> Subscription {
Subscription::all()
}

View file

@ -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,

View file

@ -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();

View file

@ -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,

View file

@ -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>>(

View file

@ -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 {

View file

@ -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,

View file

@ -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

View file

@ -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,

View file

@ -23,6 +23,7 @@ struct TestTool {}
#[reverie::tool]
impl Tool for TestTool {
type GlobalState = ();
type ThreadState = ();
}
const NUM_ELEMENTS: usize = 1_000_000;

View file

@ -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 {

View file

@ -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.

View file

@ -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,

View file

@ -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,

View file

@ -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,