Trait miri::helpers::EvalContextExt
source · [−]pub trait EvalContextExt<'mir, 'tcx: 'mir>: MiriEvalContextExt<'mir, 'tcx> {
Show 43 methods
fn try_resolve_path(&self, path: &[&str]) -> Option<Instance<'tcx>> { ... }
fn resolve_path(&self, path: &[&str]) -> Instance<'tcx> { ... }
fn eval_path_scalar(&self, path: &[&str]) -> InterpResult<'tcx, Scalar<Tag>> { ... }
fn eval_libc(&self, name: &str) -> InterpResult<'tcx, Scalar<Tag>> { ... }
fn eval_libc_i32(&self, name: &str) -> InterpResult<'tcx, i32> { ... }
fn eval_windows(
&self,
module: &str,
name: &str
) -> InterpResult<'tcx, Scalar<Tag>> { ... }
fn eval_windows_u64(
&self,
module: &str,
name: &str
) -> InterpResult<'tcx, u64> { ... }
fn libc_ty_layout(&self, name: &str) -> InterpResult<'tcx, TyAndLayout<'tcx>> { ... }
fn windows_ty_layout(
&self,
name: &str
) -> InterpResult<'tcx, TyAndLayout<'tcx>> { ... }
fn mplace_field_named(
&self,
mplace: &MPlaceTy<'tcx, Tag>,
name: &str
) -> InterpResult<'tcx, MPlaceTy<'tcx, Tag>> { ... }
fn write_int(
&mut self,
i: impl Into<i128>,
dest: &PlaceTy<'tcx, Tag>
) -> InterpResult<'tcx> { ... }
fn write_int_fields(
&mut self,
values: &[i128],
dest: &MPlaceTy<'tcx, Tag>
) -> InterpResult<'tcx> { ... }
fn write_int_fields_named(
&mut self,
values: &[(&str, i128)],
dest: &MPlaceTy<'tcx, Tag>
) -> InterpResult<'tcx> { ... }
fn write_null(&mut self, dest: &PlaceTy<'tcx, Tag>) -> InterpResult<'tcx> { ... }
fn ptr_is_null(&self, ptr: Pointer<Option<Tag>>) -> InterpResult<'tcx, bool> { ... }
fn local_place(
&mut self,
local: Local
) -> InterpResult<'tcx, PlaceTy<'tcx, Tag>> { ... }
fn gen_random(
&mut self,
ptr: Pointer<Option<Tag>>,
len: u64
) -> InterpResult<'tcx> { ... }
fn call_function(
&mut self,
f: Instance<'tcx>,
caller_abi: Abi,
args: &[Immediate<Tag>],
dest: Option<&PlaceTy<'tcx, Tag>>,
stack_pop: StackPopCleanup
) -> InterpResult<'tcx> { ... }
fn visit_freeze_sensitive(
&self,
place: &MPlaceTy<'tcx, Tag>,
size: Size,
action: impl FnMut(AllocRange, bool) -> InterpResult<'tcx>
) -> InterpResult<'tcx> { ... }
fn check_no_isolation(&self, name: &str) -> InterpResult<'tcx> { ... }
fn reject_in_isolation(
&self,
op_name: &str,
reject_with: RejectOpWith
) -> InterpResult<'tcx> { ... }
fn assert_target_os(&self, target_os: &str, name: &str) { ... }
fn assert_target_os_is_unix(&self, name: &str) { ... }
fn last_error_place(&mut self) -> InterpResult<'tcx, MPlaceTy<'tcx, Tag>> { ... }
fn set_last_error(&mut self, scalar: Scalar<Tag>) -> InterpResult<'tcx> { ... }
fn get_last_error(&mut self) -> InterpResult<'tcx, Scalar<Tag>> { ... }
fn io_error_to_errnum(
&self,
err_kind: ErrorKind
) -> InterpResult<'tcx, Scalar<Tag>> { ... }
fn errnum_to_io_error(
&self,
errnum: Scalar<Tag>
) -> InterpResult<'tcx, ErrorKind> { ... }
fn set_last_error_from_io_error(
&mut self,
err_kind: ErrorKind
) -> InterpResult<'tcx> { ... }
fn try_unwrap_io_result<T: From<i32>>(
&mut self,
result: Result<T>
) -> InterpResult<'tcx, T> { ... }
fn deref_operand_and_offset(
&self,
op: &OpTy<'tcx, Tag>,
offset: u64,
layout: TyAndLayout<'tcx>
) -> InterpResult<'tcx, MPlaceTy<'tcx, Tag>> { ... }
fn read_scalar_at_offset(
&self,
op: &OpTy<'tcx, Tag>,
offset: u64,
layout: TyAndLayout<'tcx>
) -> InterpResult<'tcx, ScalarMaybeUninit<Tag>> { ... }
fn write_scalar_at_offset(
&mut self,
op: &OpTy<'tcx, Tag>,
offset: u64,
value: impl Into<ScalarMaybeUninit<Tag>>,
layout: TyAndLayout<'tcx>
) -> InterpResult<'tcx, ()> { ... }
fn read_timespec(
&mut self,
tp: &MPlaceTy<'tcx, Tag>
) -> InterpResult<'tcx, Option<Duration>> { ... }
fn read_c_str<'a>(
&'a self,
ptr: Pointer<Option<Tag>>
) -> InterpResult<'tcx, &'a [u8]>
where
'tcx: 'a,
'mir: 'a,
{ ... }
fn read_wide_str(
&self,
ptr: Pointer<Option<Tag>>
) -> InterpResult<'tcx, Vec<u16>> { ... }
fn check_abi<'a>(&self, abi: Abi, exp_abi: Abi) -> InterpResult<'a, ()> { ... }
fn frame_in_std(&self) -> bool { ... }
fn handle_unsupported<S: AsRef<str>>(
&mut self,
error_msg: S
) -> InterpResult<'tcx, ()> { ... }
fn check_abi_and_shim_symbol_clash(
&mut self,
abi: Abi,
exp_abi: Abi,
link_name: Symbol
) -> InterpResult<'tcx, ()> { ... }
fn check_shim<'a, const N: usize>(
&mut self,
abi: Abi,
exp_abi: Abi,
link_name: Symbol,
args: &'a [OpTy<'tcx, Tag>]
) -> InterpResult<'tcx, &'a [OpTy<'tcx, Tag>; N]>
where
&'a [OpTy<'tcx, Tag>; N]: TryFrom<&'a [OpTy<'tcx, Tag>]>,
{ ... }
fn mark_immutable(&mut self, mplace: &MemPlace<Tag>) { ... }
fn item_link_name(&self, def_id: DefId) -> Symbol { ... }
}Provided Methods
fn try_resolve_path(&self, path: &[&str]) -> Option<Instance<'tcx>>
fn try_resolve_path(&self, path: &[&str]) -> Option<Instance<'tcx>>
Gets an instance for a path; fails gracefully if the path does not exist.
fn resolve_path(&self, path: &[&str]) -> Instance<'tcx>
fn resolve_path(&self, path: &[&str]) -> Instance<'tcx>
Gets an instance for a path.
fn eval_path_scalar(&self, path: &[&str]) -> InterpResult<'tcx, Scalar<Tag>>
fn eval_path_scalar(&self, path: &[&str]) -> InterpResult<'tcx, Scalar<Tag>>
Evaluates the scalar at the specified path. Returns Some(val) if the path could be resolved, and None otherwise
Helper function to get a libc constant as a Scalar.
fn eval_libc_i32(&self, name: &str) -> InterpResult<'tcx, i32>
fn eval_libc_i32(&self, name: &str) -> InterpResult<'tcx, i32>
Helper function to get a libc constant as an i32.
fn eval_windows(
&self,
module: &str,
name: &str
) -> InterpResult<'tcx, Scalar<Tag>>
fn eval_windows(
&self,
module: &str,
name: &str
) -> InterpResult<'tcx, Scalar<Tag>>
Helper function to get a windows constant as a Scalar.
fn eval_windows_u64(&self, module: &str, name: &str) -> InterpResult<'tcx, u64>
fn eval_windows_u64(&self, module: &str, name: &str) -> InterpResult<'tcx, u64>
Helper function to get a windows constant as a u64.
fn libc_ty_layout(&self, name: &str) -> InterpResult<'tcx, TyAndLayout<'tcx>>
fn libc_ty_layout(&self, name: &str) -> InterpResult<'tcx, TyAndLayout<'tcx>>
Helper function to get the TyAndLayout of a libc type
fn windows_ty_layout(&self, name: &str) -> InterpResult<'tcx, TyAndLayout<'tcx>>
fn windows_ty_layout(&self, name: &str) -> InterpResult<'tcx, TyAndLayout<'tcx>>
Helper function to get the TyAndLayout of a windows type
fn mplace_field_named(
&self,
mplace: &MPlaceTy<'tcx, Tag>,
name: &str
) -> InterpResult<'tcx, MPlaceTy<'tcx, Tag>>
fn mplace_field_named(
&self,
mplace: &MPlaceTy<'tcx, Tag>,
name: &str
) -> InterpResult<'tcx, MPlaceTy<'tcx, Tag>>
Project to the given named field of the mplace (which must be a struct or union type).
Write an int of the appropriate size to dest. The target type may be signed or unsigned,
we try to do the right thing anyway. i128 can fit all integer types except for u128 so
this method is fine for almost all integer types.
fn write_int_fields(
&mut self,
values: &[i128],
dest: &MPlaceTy<'tcx, Tag>
) -> InterpResult<'tcx>
fn write_int_fields(
&mut self,
values: &[i128],
dest: &MPlaceTy<'tcx, Tag>
) -> InterpResult<'tcx>
Write the first N fields of the given place.
fn write_int_fields_named(
&mut self,
values: &[(&str, i128)],
dest: &MPlaceTy<'tcx, Tag>
) -> InterpResult<'tcx>
fn write_int_fields_named(
&mut self,
values: &[(&str, i128)],
dest: &MPlaceTy<'tcx, Tag>
) -> InterpResult<'tcx>
Write the given fields of the given place.
fn write_null(&mut self, dest: &PlaceTy<'tcx, Tag>) -> InterpResult<'tcx>
fn write_null(&mut self, dest: &PlaceTy<'tcx, Tag>) -> InterpResult<'tcx>
Write a 0 of the appropriate size to dest.
fn ptr_is_null(&self, ptr: Pointer<Option<Tag>>) -> InterpResult<'tcx, bool>
fn ptr_is_null(&self, ptr: Pointer<Option<Tag>>) -> InterpResult<'tcx, bool>
Test if this pointer equals 0.
fn local_place(&mut self, local: Local) -> InterpResult<'tcx, PlaceTy<'tcx, Tag>>
fn local_place(&mut self, local: Local) -> InterpResult<'tcx, PlaceTy<'tcx, Tag>>
Get the Place for a local
fn gen_random(
&mut self,
ptr: Pointer<Option<Tag>>,
len: u64
) -> InterpResult<'tcx>
fn gen_random(
&mut self,
ptr: Pointer<Option<Tag>>,
len: u64
) -> InterpResult<'tcx>
Generate some random bytes, and write them to dest.
fn call_function(
&mut self,
f: Instance<'tcx>,
caller_abi: Abi,
args: &[Immediate<Tag>],
dest: Option<&PlaceTy<'tcx, Tag>>,
stack_pop: StackPopCleanup
) -> InterpResult<'tcx>
fn call_function(
&mut self,
f: Instance<'tcx>,
caller_abi: Abi,
args: &[Immediate<Tag>],
dest: Option<&PlaceTy<'tcx, Tag>>,
stack_pop: StackPopCleanup
) -> InterpResult<'tcx>
Call a function: Push the stack frame and pass the arguments. For now, arguments must be scalars (so that the caller does not have to know the layout).
If you do not provie a return place, a dangling zero-sized place will be created for your convenience.
fn visit_freeze_sensitive(
&self,
place: &MPlaceTy<'tcx, Tag>,
size: Size,
action: impl FnMut(AllocRange, bool) -> InterpResult<'tcx>
) -> InterpResult<'tcx>
fn visit_freeze_sensitive(
&self,
place: &MPlaceTy<'tcx, Tag>,
size: Size,
action: impl FnMut(AllocRange, bool) -> InterpResult<'tcx>
) -> InterpResult<'tcx>
Visits the memory covered by place, sensitive to freezing: the 2nd parameter
of action will be true if this is frozen, false if this is in an UnsafeCell.
The range is relative to place.
fn check_no_isolation(&self, name: &str) -> InterpResult<'tcx>
fn check_no_isolation(&self, name: &str) -> InterpResult<'tcx>
Helper function used inside the shims of foreign functions to check that isolation is
disabled. It returns an error using the name of the foreign function if this is not the
case.
fn reject_in_isolation(
&self,
op_name: &str,
reject_with: RejectOpWith
) -> InterpResult<'tcx>
fn reject_in_isolation(
&self,
op_name: &str,
reject_with: RejectOpWith
) -> InterpResult<'tcx>
Helper function used inside the shims of foreign functions which reject the op when isolation is enabled. It is used to print a warning/backtrace about the rejection.
fn assert_target_os(&self, target_os: &str, name: &str)
fn assert_target_os(&self, target_os: &str, name: &str)
Helper function used inside the shims of foreign functions to assert that the target OS
is target_os. It panics showing a message with the name of the foreign function
if this is not the case.
fn assert_target_os_is_unix(&self, name: &str)
fn assert_target_os_is_unix(&self, name: &str)
Helper function used inside the shims of foreign functions to assert that the target OS
is part of the UNIX family. It panics showing a message with the name of the foreign function
if this is not the case.
fn last_error_place(&mut self) -> InterpResult<'tcx, MPlaceTy<'tcx, Tag>>
fn last_error_place(&mut self) -> InterpResult<'tcx, MPlaceTy<'tcx, Tag>>
Get last error variable as a place, lazily allocating thread-local storage for it if necessary.
fn set_last_error(&mut self, scalar: Scalar<Tag>) -> InterpResult<'tcx>
fn set_last_error(&mut self, scalar: Scalar<Tag>) -> InterpResult<'tcx>
Sets the last error variable.
fn get_last_error(&mut self) -> InterpResult<'tcx, Scalar<Tag>>
fn get_last_error(&mut self) -> InterpResult<'tcx, Scalar<Tag>>
Gets the last error variable.
fn io_error_to_errnum(
&self,
err_kind: ErrorKind
) -> InterpResult<'tcx, Scalar<Tag>>
fn io_error_to_errnum(
&self,
err_kind: ErrorKind
) -> InterpResult<'tcx, Scalar<Tag>>
This function tries to produce the most similar OS error from the std::io::ErrorKind
as a platform-specific errnum.
fn errnum_to_io_error(
&self,
errnum: Scalar<Tag>
) -> InterpResult<'tcx, ErrorKind>
fn errnum_to_io_error(
&self,
errnum: Scalar<Tag>
) -> InterpResult<'tcx, ErrorKind>
The inverse of io_error_to_errnum.
fn set_last_error_from_io_error(
&mut self,
err_kind: ErrorKind
) -> InterpResult<'tcx>
fn set_last_error_from_io_error(
&mut self,
err_kind: ErrorKind
) -> InterpResult<'tcx>
Sets the last OS error using a std::io::ErrorKind.
fn try_unwrap_io_result<T: From<i32>>(
&mut self,
result: Result<T>
) -> InterpResult<'tcx, T>
fn try_unwrap_io_result<T: From<i32>>(
&mut self,
result: Result<T>
) -> InterpResult<'tcx, T>
Helper function that consumes an std::io::Result<T> and returns an
InterpResult<'tcx,T>::Ok instead. In case the result is an error, this function returns
Ok(-1) and sets the last OS error accordingly.
This function uses T: From<i32> instead of i32 directly because some IO related
functions return different integer types (like read, that returns an i64).
fn deref_operand_and_offset(
&self,
op: &OpTy<'tcx, Tag>,
offset: u64,
layout: TyAndLayout<'tcx>
) -> InterpResult<'tcx, MPlaceTy<'tcx, Tag>>
fn deref_operand_and_offset(
&self,
op: &OpTy<'tcx, Tag>,
offset: u64,
layout: TyAndLayout<'tcx>
) -> InterpResult<'tcx, MPlaceTy<'tcx, Tag>>
Calculates the MPlaceTy given the offset and layout of an access on an operand
fn read_scalar_at_offset(
&self,
op: &OpTy<'tcx, Tag>,
offset: u64,
layout: TyAndLayout<'tcx>
) -> InterpResult<'tcx, ScalarMaybeUninit<Tag>>
fn write_scalar_at_offset(
&mut self,
op: &OpTy<'tcx, Tag>,
offset: u64,
value: impl Into<ScalarMaybeUninit<Tag>>,
layout: TyAndLayout<'tcx>
) -> InterpResult<'tcx, ()>
fn read_timespec(
&mut self,
tp: &MPlaceTy<'tcx, Tag>
) -> InterpResult<'tcx, Option<Duration>>
fn read_timespec(
&mut self,
tp: &MPlaceTy<'tcx, Tag>
) -> InterpResult<'tcx, Option<Duration>>
Parse a timespec struct and return it as a std::time::Duration. It returns None
if the value in the timespec struct is invalid. Some libc functions will return
EINVAL in this case.
fn read_c_str<'a>(
&'a self,
ptr: Pointer<Option<Tag>>
) -> InterpResult<'tcx, &'a [u8]> where
'tcx: 'a,
'mir: 'a,
fn read_wide_str(
&self,
ptr: Pointer<Option<Tag>>
) -> InterpResult<'tcx, Vec<u16>>
Check that the ABI is what we expect.
fn frame_in_std(&self) -> bool
fn handle_unsupported<S: AsRef<str>>(
&mut self,
error_msg: S
) -> InterpResult<'tcx, ()>
fn handle_unsupported<S: AsRef<str>>(
&mut self,
error_msg: S
) -> InterpResult<'tcx, ()>
Handler that should be called when unsupported functionality is encountered. This function will either panic within the context of the emulated application or return an error in the Miri process context
Return value of Ok(bool) indicates whether execution should continue.
fn check_abi_and_shim_symbol_clash(
&mut self,
abi: Abi,
exp_abi: Abi,
link_name: Symbol
) -> InterpResult<'tcx, ()>
fn check_shim<'a, const N: usize>(
&mut self,
abi: Abi,
exp_abi: Abi,
link_name: Symbol,
args: &'a [OpTy<'tcx, Tag>]
) -> InterpResult<'tcx, &'a [OpTy<'tcx, Tag>; N]> where
&'a [OpTy<'tcx, Tag>; N]: TryFrom<&'a [OpTy<'tcx, Tag>]>,
fn mark_immutable(&mut self, mplace: &MemPlace<Tag>)
fn mark_immutable(&mut self, mplace: &MemPlace<Tag>)
Mark a machine allocation that was just created as immutable.