replace Emulator::new_empty
by Emulator::get
calls outside of emu.rs
for safety. (#1763)
This commit is contained in:
parent
2717018601
commit
38e16fbade
@ -246,7 +246,7 @@ impl QemuCmpLogRoutinesHelper {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
let emu = Emulator::new_empty();
|
let emu = Emulator::get().unwrap();
|
||||||
|
|
||||||
let a0: GuestAddr = emu
|
let a0: GuestAddr = emu
|
||||||
.read_function_argument(CallingConvention::Cdecl, 0)
|
.read_function_argument(CallingConvention::Cdecl, 0)
|
||||||
|
@ -508,7 +508,7 @@ pub trait ArchExtras {
|
|||||||
impl CPU {
|
impl CPU {
|
||||||
#[must_use]
|
#[must_use]
|
||||||
pub fn emulator(&self) -> Emulator {
|
pub fn emulator(&self) -> Emulator {
|
||||||
Emulator::new_empty()
|
unsafe { Emulator::new_empty() }
|
||||||
}
|
}
|
||||||
|
|
||||||
#[must_use]
|
#[must_use]
|
||||||
@ -997,8 +997,14 @@ impl Emulator {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Get an empty emulator.
|
||||||
|
///
|
||||||
|
/// # Safety
|
||||||
|
///
|
||||||
|
/// Should not be used if `Emulator::new` has never been used before (otherwise QEMU will not be initialized).
|
||||||
|
/// Prefer `Emulator::get` for a safe version of this method.
|
||||||
#[must_use]
|
#[must_use]
|
||||||
pub fn new_empty() -> Emulator {
|
unsafe fn new_empty() -> Emulator {
|
||||||
Emulator { _private: () }
|
Emulator { _private: () }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -212,7 +212,7 @@ where
|
|||||||
mgr: &mut EM,
|
mgr: &mut EM,
|
||||||
input: &Self::Input,
|
input: &Self::Input,
|
||||||
) -> Result<ExitKind, Error> {
|
) -> Result<ExitKind, Error> {
|
||||||
let emu = Emulator::new_empty();
|
let emu = Emulator::get().unwrap();
|
||||||
if self.first_exec {
|
if self.first_exec {
|
||||||
self.hooks.helpers().first_exec_all(self.hooks);
|
self.hooks.helpers().first_exec_all(self.hooks);
|
||||||
self.first_exec = false;
|
self.first_exec = false;
|
||||||
@ -377,7 +377,7 @@ where
|
|||||||
mgr: &mut EM,
|
mgr: &mut EM,
|
||||||
input: &Self::Input,
|
input: &Self::Input,
|
||||||
) -> Result<ExitKind, Error> {
|
) -> Result<ExitKind, Error> {
|
||||||
let emu = Emulator::new_empty();
|
let emu = Emulator::get().unwrap();
|
||||||
if self.first_exec {
|
if self.first_exec {
|
||||||
self.hooks.helpers().first_exec_all(self.hooks);
|
self.hooks.helpers().first_exec_all(self.hooks);
|
||||||
self.first_exec = false;
|
self.first_exec = false;
|
||||||
|
@ -331,7 +331,7 @@ impl QemuSnapshotHelper {
|
|||||||
|
|
||||||
if self.mmap_limit != 0 && total_size > self.mmap_limit {
|
if self.mmap_limit != 0 && total_size > self.mmap_limit {
|
||||||
let mut cb = self.stop_execution.take().unwrap();
|
let mut cb = self.stop_execution.take().unwrap();
|
||||||
let emu = Emulator::new_empty();
|
let emu = Emulator::get().unwrap();
|
||||||
(cb)(self, &emu);
|
(cb)(self, &emu);
|
||||||
self.stop_execution = Some(cb);
|
self.stop_execution = Some(cb);
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user