1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
/*
* 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.
*/
use reverie::Error;
use reverie::Guest;
use reverie::Subscription;
use reverie::Tool;
use reverie::syscalls::Syscall;
use serde::Deserialize;
use serde::Serialize;
use crate::config::Config;
use crate::tool_global::GlobalState;
/// Helper trait.
pub trait RecordOrReplay: Tool<GlobalState = GlobalState> {}
impl<T> RecordOrReplay for T where T: Tool<GlobalState = GlobalState> {}
/// A tool that only injects the syscall it receives.
#[derive(Debug, Default, Serialize, Deserialize)]
pub struct NoopTool;
#[reverie::tool]
impl Tool for NoopTool {
type GlobalState = GlobalState;
type ThreadState = ();
fn subscriptions(_cfg: &Config) -> Subscription {
// Don't subscribe to anything by default. This noop-tool doesn't care
// about any syscalls and will be ORed with the detcore subscriptions.
Subscription::none()
}
async fn handle_syscall_event<T: Guest<Self>>(
&self,
guest: &mut T,
call: Syscall,
) -> Result<i64, Error> {
// NOTE: Cannot use tail_inject here as that would prevent any detcore
// post-hook code from running.
Ok(guest.inject(call).await?)
}
}