refactor(snapshot.rs): use const generics (#2069)
* refactor(snapshot.rs): use const generics * Add docs to read hooks --------- Co-authored-by: Romain Malmain <romain.malmain@pm.me>
This commit is contained in:
parent
176659821a
commit
0f42efa12b
@ -1161,6 +1161,18 @@ impl Qemu {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// `data` can be used to pass data that can be accessed as the first argument in the `gen` and the `exec` functions
|
||||||
|
///
|
||||||
|
/// `gen` gets passed the current programm counter, mutable access to a `TCGTemp` and information about the memory
|
||||||
|
/// access being performed.
|
||||||
|
/// The `u64` return value is an id that gets passed to the `exec` functions as their second argument.
|
||||||
|
///
|
||||||
|
/// `exec` hooks get invoked on every read performed by the guest
|
||||||
|
///
|
||||||
|
/// `exec1`-`exec8` special case accesses of width 1-8
|
||||||
|
///
|
||||||
|
/// If there is no specialized hook for a given read width, the `exec_n` will be
|
||||||
|
/// called and its last argument will specify the access width
|
||||||
#[allow(clippy::missing_transmute_annotations)]
|
#[allow(clippy::missing_transmute_annotations)]
|
||||||
pub fn add_read_hooks<T: Into<HookData>>(
|
pub fn add_read_hooks<T: Into<HookData>>(
|
||||||
&self,
|
&self,
|
||||||
|
@ -498,10 +498,10 @@ where
|
|||||||
// The ASan helper, if present, will call the tracer hook for the snapshot helper as opt
|
// The ASan helper, if present, will call the tracer hook for the snapshot helper as opt
|
||||||
hooks.writes(
|
hooks.writes(
|
||||||
Hook::Empty,
|
Hook::Empty,
|
||||||
Hook::Function(trace_write1_snapshot::<QT, S>),
|
Hook::Function(trace_write_snapshot::<QT, S, 1>),
|
||||||
Hook::Function(trace_write2_snapshot::<QT, S>),
|
Hook::Function(trace_write_snapshot::<QT, S, 2>),
|
||||||
Hook::Function(trace_write4_snapshot::<QT, S>),
|
Hook::Function(trace_write_snapshot::<QT, S, 4>),
|
||||||
Hook::Function(trace_write8_snapshot::<QT, S>),
|
Hook::Function(trace_write_snapshot::<QT, S, 8>),
|
||||||
Hook::Function(trace_write_n_snapshot::<QT, S>),
|
Hook::Function(trace_write_n_snapshot::<QT, S>),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@ -521,7 +521,7 @@ where
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn trace_write1_snapshot<QT, S>(
|
pub fn trace_write_snapshot<QT, S, const SIZE: usize>(
|
||||||
hooks: &mut QemuHooks<QT, S>,
|
hooks: &mut QemuHooks<QT, S>,
|
||||||
_state: Option<&mut S>,
|
_state: Option<&mut S>,
|
||||||
_id: u64,
|
_id: u64,
|
||||||
@ -531,46 +531,7 @@ pub fn trace_write1_snapshot<QT, S>(
|
|||||||
QT: QemuHelperTuple<S>,
|
QT: QemuHelperTuple<S>,
|
||||||
{
|
{
|
||||||
let h = hooks.match_helper_mut::<QemuSnapshotHelper>().unwrap();
|
let h = hooks.match_helper_mut::<QemuSnapshotHelper>().unwrap();
|
||||||
h.access(addr, 1);
|
h.access(addr, SIZE);
|
||||||
}
|
|
||||||
|
|
||||||
pub fn trace_write2_snapshot<QT, S>(
|
|
||||||
hooks: &mut QemuHooks<QT, S>,
|
|
||||||
_state: Option<&mut S>,
|
|
||||||
_id: u64,
|
|
||||||
addr: GuestAddr,
|
|
||||||
) where
|
|
||||||
S: UsesInput,
|
|
||||||
QT: QemuHelperTuple<S>,
|
|
||||||
{
|
|
||||||
let h = hooks.match_helper_mut::<QemuSnapshotHelper>().unwrap();
|
|
||||||
h.access(addr, 2);
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn trace_write4_snapshot<QT, S>(
|
|
||||||
hooks: &mut QemuHooks<QT, S>,
|
|
||||||
_state: Option<&mut S>,
|
|
||||||
_id: u64,
|
|
||||||
addr: GuestAddr,
|
|
||||||
) where
|
|
||||||
S: UsesInput,
|
|
||||||
QT: QemuHelperTuple<S>,
|
|
||||||
{
|
|
||||||
let h = hooks.match_helper_mut::<QemuSnapshotHelper>().unwrap();
|
|
||||||
h.access(addr, 4);
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn trace_write8_snapshot<QT, S>(
|
|
||||||
hooks: &mut QemuHooks<QT, S>,
|
|
||||||
_state: Option<&mut S>,
|
|
||||||
_id: u64,
|
|
||||||
addr: GuestAddr,
|
|
||||||
) where
|
|
||||||
S: UsesInput,
|
|
||||||
QT: QemuHelperTuple<S>,
|
|
||||||
{
|
|
||||||
let h = hooks.match_helper_mut::<QemuSnapshotHelper>().unwrap();
|
|
||||||
h.access(addr, 8);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn trace_write_n_snapshot<QT, S>(
|
pub fn trace_write_n_snapshot<QT, S>(
|
||||||
|
Loading…
x
Reference in New Issue
Block a user