pub trait EvalContextExt<'tcx>: MiriInterpCxExt<'tcx> {
Show 48 methods
// Provided methods
fn have_module(&self, path: &[&str]) -> bool { ... }
fn eval_path(&self, path: &[&str]) -> MPlaceTy<'tcx> { ... }
fn eval_path_scalar(&self, path: &[&str]) -> Scalar { ... }
fn eval_libc(&self, name: &str) -> Scalar { ... }
fn eval_libc_i32(&self, name: &str) -> i32 { ... }
fn eval_libc_u32(&self, name: &str) -> u32 { ... }
fn eval_windows(&self, module: &str, name: &str) -> Scalar { ... }
fn eval_windows_u32(&self, module: &str, name: &str) -> u32 { ... }
fn eval_windows_u64(&self, module: &str, name: &str) -> u64 { ... }
fn libc_ty_layout(&self, name: &str) -> TyAndLayout<'tcx> { ... }
fn windows_ty_layout(&self, name: &str) -> TyAndLayout<'tcx> { ... }
fn libc_array_ty_layout(&self, name: &str, size: u64) -> TyAndLayout<'tcx> { ... }
fn project_field_named<P: Projectable<'tcx, Provenance>>(
&self,
base: &P,
name: &str,
) -> InterpResult<'tcx, P> { ... }
fn projectable_has_field<P: Projectable<'tcx, Provenance>>(
&self,
base: &P,
name: &str,
) -> bool { ... }
fn write_int(
&mut self,
i: impl Into<i128>,
dest: &impl Writeable<'tcx, Provenance>,
) -> InterpResult<'tcx> { ... }
fn write_int_fields(
&mut self,
values: &[i128],
dest: &impl Writeable<'tcx, Provenance>,
) -> InterpResult<'tcx> { ... }
fn write_int_fields_named(
&mut self,
values: &[(&str, i128)],
dest: &impl Writeable<'tcx, Provenance>,
) -> InterpResult<'tcx> { ... }
fn write_null(
&mut self,
dest: &impl Writeable<'tcx, Provenance>,
) -> InterpResult<'tcx> { ... }
fn ptr_is_null(&self, ptr: Pointer) -> InterpResult<'tcx, bool> { ... }
fn gen_random(&mut self, ptr: Pointer, len: u64) -> InterpResult<'tcx> { ... }
fn call_function(
&mut self,
f: Instance<'tcx>,
caller_abi: ExternAbi,
args: &[ImmTy<'tcx>],
dest: Option<&MPlaceTy<'tcx>>,
stack_pop: StackPopCleanup,
) -> InterpResult<'tcx> { ... }
fn visit_freeze_sensitive(
&self,
place: &MPlaceTy<'tcx>,
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 target_os_is_unix(&self) -> bool { ... }
fn deref_pointer_as(
&self,
op: &impl Projectable<'tcx, Provenance>,
layout: TyAndLayout<'tcx>,
) -> InterpResult<'tcx, MPlaceTy<'tcx>> { ... }
fn deref_pointer_and_offset(
&self,
op: &impl Projectable<'tcx, Provenance>,
offset: u64,
base_layout: TyAndLayout<'tcx>,
value_layout: TyAndLayout<'tcx>,
) -> InterpResult<'tcx, MPlaceTy<'tcx>> { ... }
fn deref_pointer_and_read(
&self,
op: &impl Projectable<'tcx, Provenance>,
offset: u64,
base_layout: TyAndLayout<'tcx>,
value_layout: TyAndLayout<'tcx>,
) -> InterpResult<'tcx, Scalar> { ... }
fn deref_pointer_and_write(
&mut self,
op: &impl Projectable<'tcx, Provenance>,
offset: u64,
value: impl Into<Scalar>,
base_layout: TyAndLayout<'tcx>,
value_layout: TyAndLayout<'tcx>,
) -> InterpResult<'tcx, ()> { ... }
fn read_timespec(
&mut self,
tp: &MPlaceTy<'tcx>,
) -> InterpResult<'tcx, Option<Duration>> { ... }
fn read_byte_slice<'a>(
&'a self,
slice: &ImmTy<'tcx>,
) -> InterpResult<'tcx, &'a [u8]>
where 'tcx: 'a { ... }
fn read_c_str<'a>(&'a self, ptr: Pointer) -> InterpResult<'tcx, &'a [u8]>
where 'tcx: 'a { ... }
fn write_c_str(
&mut self,
c_str: &[u8],
ptr: Pointer,
size: u64,
) -> InterpResult<'tcx, (bool, u64)> { ... }
fn read_c_str_with_char_size<T>(
&self,
ptr: Pointer,
size: Size,
align: Align,
) -> InterpResult<'tcx, Vec<T>>
where T: TryFrom<u128>,
<T as TryFrom<u128>>::Error: Debug { ... }
fn read_wide_str(&self, ptr: Pointer) -> InterpResult<'tcx, Vec<u16>> { ... }
fn write_wide_str(
&mut self,
wide_str: &[u16],
ptr: Pointer,
size: u64,
) -> InterpResult<'tcx, (bool, u64)> { ... }
fn read_wchar_t_str(&self, ptr: Pointer) -> InterpResult<'tcx, Vec<u32>> { ... }
fn check_abi<'a>(
&self,
abi: ExternAbi,
exp_abi: ExternAbi,
) -> InterpResult<'a, ()> { ... }
fn frame_in_std(&self) -> bool { ... }
fn check_abi_and_shim_symbol_clash(
&mut self,
abi: ExternAbi,
exp_abi: ExternAbi,
link_name: Symbol,
) -> InterpResult<'tcx, ()> { ... }
fn check_shim<'a, const N: usize>(
&mut self,
abi: ExternAbi,
exp_abi: ExternAbi,
link_name: Symbol,
args: &'a [OpTy<'tcx>],
) -> InterpResult<'tcx, &'a [OpTy<'tcx>; N]>
where &'a [OpTy<'tcx>; N]: TryFrom<&'a [OpTy<'tcx>]> { ... }
fn mark_immutable(&mut self, mplace: &MPlaceTy<'tcx>) { ... }
fn float_to_int_checked(
&self,
src: &ImmTy<'tcx>,
cast_to: TyAndLayout<'tcx>,
round: Round,
) -> InterpResult<'tcx, Option<ImmTy<'tcx>>> { ... }
fn get_twice_wide_int_ty(&self, ty: Ty<'tcx>) -> Ty<'tcx> { ... }
fn expect_target_feature_for_intrinsic(
&self,
intrinsic: Symbol,
target_feature: &str,
) -> InterpResult<'tcx, ()> { ... }
fn lookup_link_section(
&mut self,
name: &str,
) -> InterpResult<'tcx, Vec<ImmTy<'tcx>>> { ... }
}
Provided Methods§
Sourcefn have_module(&self, path: &[&str]) -> bool
fn have_module(&self, path: &[&str]) -> bool
Checks if the given crate/module exists.
Sourcefn eval_path(&self, path: &[&str]) -> MPlaceTy<'tcx>
fn eval_path(&self, path: &[&str]) -> MPlaceTy<'tcx>
Evaluates the scalar at the specified path.
fn eval_path_scalar(&self, path: &[&str]) -> Scalar
Sourcefn eval_libc_i32(&self, name: &str) -> i32
fn eval_libc_i32(&self, name: &str) -> i32
Helper function to get a libc
constant as an i32
.
Sourcefn eval_libc_u32(&self, name: &str) -> u32
fn eval_libc_u32(&self, name: &str) -> u32
Helper function to get a libc
constant as an u32
.
Sourcefn eval_windows(&self, module: &str, name: &str) -> Scalar
fn eval_windows(&self, module: &str, name: &str) -> Scalar
Helper function to get a windows
constant as a Scalar
.
Sourcefn eval_windows_u32(&self, module: &str, name: &str) -> u32
fn eval_windows_u32(&self, module: &str, name: &str) -> u32
Helper function to get a windows
constant as a u32
.
Sourcefn eval_windows_u64(&self, module: &str, name: &str) -> u64
fn eval_windows_u64(&self, module: &str, name: &str) -> u64
Helper function to get a windows
constant as a u64
.
Sourcefn libc_ty_layout(&self, name: &str) -> TyAndLayout<'tcx>
fn libc_ty_layout(&self, name: &str) -> TyAndLayout<'tcx>
Helper function to get the TyAndLayout
of a libc
type
Sourcefn windows_ty_layout(&self, name: &str) -> TyAndLayout<'tcx>
fn windows_ty_layout(&self, name: &str) -> TyAndLayout<'tcx>
Helper function to get the TyAndLayout
of a windows
type
Sourcefn libc_array_ty_layout(&self, name: &str, size: u64) -> TyAndLayout<'tcx>
fn libc_array_ty_layout(&self, name: &str, size: u64) -> TyAndLayout<'tcx>
Helper function to get TyAndLayout
of an array that consists of libc
type.
Sourcefn project_field_named<P: Projectable<'tcx, Provenance>>(
&self,
base: &P,
name: &str,
) -> InterpResult<'tcx, P>
fn project_field_named<P: Projectable<'tcx, Provenance>>( &self, base: &P, name: &str, ) -> InterpResult<'tcx, P>
Project to the given named field (which must be a struct or union type).
Sourcefn projectable_has_field<P: Projectable<'tcx, Provenance>>(
&self,
base: &P,
name: &str,
) -> bool
fn projectable_has_field<P: Projectable<'tcx, Provenance>>( &self, base: &P, name: &str, ) -> bool
Search if base
(which must be a struct or union type) contains the name
field.
Sourcefn write_int(
&mut self,
i: impl Into<i128>,
dest: &impl Writeable<'tcx, Provenance>,
) -> InterpResult<'tcx>
fn write_int( &mut self, i: impl Into<i128>, dest: &impl Writeable<'tcx, Provenance>, ) -> InterpResult<'tcx>
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.
Sourcefn write_int_fields(
&mut self,
values: &[i128],
dest: &impl Writeable<'tcx, Provenance>,
) -> InterpResult<'tcx>
fn write_int_fields( &mut self, values: &[i128], dest: &impl Writeable<'tcx, Provenance>, ) -> InterpResult<'tcx>
Write the first N fields of the given place.
Sourcefn write_int_fields_named(
&mut self,
values: &[(&str, i128)],
dest: &impl Writeable<'tcx, Provenance>,
) -> InterpResult<'tcx>
fn write_int_fields_named( &mut self, values: &[(&str, i128)], dest: &impl Writeable<'tcx, Provenance>, ) -> InterpResult<'tcx>
Write the given fields of the given place.
Sourcefn write_null(
&mut self,
dest: &impl Writeable<'tcx, Provenance>,
) -> InterpResult<'tcx>
fn write_null( &mut self, dest: &impl Writeable<'tcx, Provenance>, ) -> InterpResult<'tcx>
Write a 0 of the appropriate size to dest
.
Sourcefn ptr_is_null(&self, ptr: Pointer) -> InterpResult<'tcx, bool>
fn ptr_is_null(&self, ptr: Pointer) -> InterpResult<'tcx, bool>
Test if this pointer equals 0.
Sourcefn gen_random(&mut self, ptr: Pointer, len: u64) -> InterpResult<'tcx>
fn gen_random(&mut self, ptr: Pointer, len: u64) -> InterpResult<'tcx>
Generate some random bytes, and write them to dest
.
Sourcefn call_function(
&mut self,
f: Instance<'tcx>,
caller_abi: ExternAbi,
args: &[ImmTy<'tcx>],
dest: Option<&MPlaceTy<'tcx>>,
stack_pop: StackPopCleanup,
) -> InterpResult<'tcx>
fn call_function( &mut self, f: Instance<'tcx>, caller_abi: ExternAbi, args: &[ImmTy<'tcx>], dest: Option<&MPlaceTy<'tcx>>, 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 provide a return place, a dangling zero-sized place will be created for your convenience.
Sourcefn visit_freeze_sensitive(
&self,
place: &MPlaceTy<'tcx>,
size: Size,
action: impl FnMut(AllocRange, bool) -> InterpResult<'tcx>,
) -> InterpResult<'tcx>
fn visit_freeze_sensitive( &self, place: &MPlaceTy<'tcx>, 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
.
Sourcefn 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.
Sourcefn 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.
Sourcefn 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.
Sourcefn 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 target_os_is_unix(&self) -> bool
Sourcefn deref_pointer_as(
&self,
op: &impl Projectable<'tcx, Provenance>,
layout: TyAndLayout<'tcx>,
) -> InterpResult<'tcx, MPlaceTy<'tcx>>
fn deref_pointer_as( &self, op: &impl Projectable<'tcx, Provenance>, layout: TyAndLayout<'tcx>, ) -> InterpResult<'tcx, MPlaceTy<'tcx>>
Dereference a pointer operand to a place using layout
instead of the pointer’s declared type
Sourcefn deref_pointer_and_offset(
&self,
op: &impl Projectable<'tcx, Provenance>,
offset: u64,
base_layout: TyAndLayout<'tcx>,
value_layout: TyAndLayout<'tcx>,
) -> InterpResult<'tcx, MPlaceTy<'tcx>>
fn deref_pointer_and_offset( &self, op: &impl Projectable<'tcx, Provenance>, offset: u64, base_layout: TyAndLayout<'tcx>, value_layout: TyAndLayout<'tcx>, ) -> InterpResult<'tcx, MPlaceTy<'tcx>>
Calculates the MPlaceTy given the offset and layout of an access on an operand
fn deref_pointer_and_read( &self, op: &impl Projectable<'tcx, Provenance>, offset: u64, base_layout: TyAndLayout<'tcx>, value_layout: TyAndLayout<'tcx>, ) -> InterpResult<'tcx, Scalar>
fn deref_pointer_and_write( &mut self, op: &impl Projectable<'tcx, Provenance>, offset: u64, value: impl Into<Scalar>, base_layout: TyAndLayout<'tcx>, value_layout: TyAndLayout<'tcx>, ) -> InterpResult<'tcx, ()>
Sourcefn read_timespec(
&mut self,
tp: &MPlaceTy<'tcx>,
) -> InterpResult<'tcx, Option<Duration>>
fn read_timespec( &mut self, tp: &MPlaceTy<'tcx>, ) -> 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.
Sourcefn read_byte_slice<'a>(
&'a self,
slice: &ImmTy<'tcx>,
) -> InterpResult<'tcx, &'a [u8]>where
'tcx: 'a,
fn read_byte_slice<'a>(
&'a self,
slice: &ImmTy<'tcx>,
) -> InterpResult<'tcx, &'a [u8]>where
'tcx: 'a,
Read bytes from a byte slice.
Sourcefn read_c_str<'a>(&'a self, ptr: Pointer) -> InterpResult<'tcx, &'a [u8]>where
'tcx: 'a,
fn read_c_str<'a>(&'a self, ptr: Pointer) -> InterpResult<'tcx, &'a [u8]>where
'tcx: 'a,
Read a sequence of bytes until the first null terminator.
Sourcefn write_c_str(
&mut self,
c_str: &[u8],
ptr: Pointer,
size: u64,
) -> InterpResult<'tcx, (bool, u64)>
fn write_c_str( &mut self, c_str: &[u8], ptr: Pointer, size: u64, ) -> InterpResult<'tcx, (bool, u64)>
Helper function to write a sequence of bytes with an added null-terminator, which is what
the Unix APIs usually handle. This function returns Ok((false, length))
without trying
to write if size
is not large enough to fit the contents of c_str
plus a null
terminator. It returns Ok((true, length))
if the writing process was successful. The
string length returned does include the null terminator.
Sourcefn read_c_str_with_char_size<T>(
&self,
ptr: Pointer,
size: Size,
align: Align,
) -> InterpResult<'tcx, Vec<T>>
fn read_c_str_with_char_size<T>( &self, ptr: Pointer, size: Size, align: Align, ) -> InterpResult<'tcx, Vec<T>>
Helper function to read a sequence of unsigned integers of the given size and alignment until the first null terminator.
Sourcefn read_wide_str(&self, ptr: Pointer) -> InterpResult<'tcx, Vec<u16>>
fn read_wide_str(&self, ptr: Pointer) -> InterpResult<'tcx, Vec<u16>>
Read a sequence of u16 until the first null terminator.
Sourcefn write_wide_str(
&mut self,
wide_str: &[u16],
ptr: Pointer,
size: u64,
) -> InterpResult<'tcx, (bool, u64)>
fn write_wide_str( &mut self, wide_str: &[u16], ptr: Pointer, size: u64, ) -> InterpResult<'tcx, (bool, u64)>
Helper function to write a sequence of u16 with an added 0x0000-terminator, which is what
the Windows APIs usually handle. This function returns Ok((false, length))
without trying
to write if size
is not large enough to fit the contents of os_string
plus a null
terminator. It returns Ok((true, length))
if the writing process was successful. The
string length returned does include the null terminator. Length is measured in units of
u16.
Sourcefn read_wchar_t_str(&self, ptr: Pointer) -> InterpResult<'tcx, Vec<u32>>
fn read_wchar_t_str(&self, ptr: Pointer) -> InterpResult<'tcx, Vec<u32>>
Read a sequence of wchar_t until the first null terminator.
Always returns a Vec<u32>
no matter the size of wchar_t
.
Sourcefn check_abi<'a>(
&self,
abi: ExternAbi,
exp_abi: ExternAbi,
) -> InterpResult<'a, ()>
fn check_abi<'a>( &self, abi: ExternAbi, exp_abi: ExternAbi, ) -> InterpResult<'a, ()>
Check that the ABI is what we expect.
fn frame_in_std(&self) -> bool
fn check_abi_and_shim_symbol_clash( &mut self, abi: ExternAbi, exp_abi: ExternAbi, link_name: Symbol, ) -> InterpResult<'tcx, ()>
fn check_shim<'a, const N: usize>( &mut self, abi: ExternAbi, exp_abi: ExternAbi, link_name: Symbol, args: &'a [OpTy<'tcx>], ) -> InterpResult<'tcx, &'a [OpTy<'tcx>; N]>
Sourcefn mark_immutable(&mut self, mplace: &MPlaceTy<'tcx>)
fn mark_immutable(&mut self, mplace: &MPlaceTy<'tcx>)
Mark a machine allocation that was just created as immutable.
Sourcefn float_to_int_checked(
&self,
src: &ImmTy<'tcx>,
cast_to: TyAndLayout<'tcx>,
round: Round,
) -> InterpResult<'tcx, Option<ImmTy<'tcx>>>
fn float_to_int_checked( &self, src: &ImmTy<'tcx>, cast_to: TyAndLayout<'tcx>, round: Round, ) -> InterpResult<'tcx, Option<ImmTy<'tcx>>>
Converts src
from floating point to integer type dest_ty
after rounding with mode round
.
Returns None
if f
is NaN or out of range.
Sourcefn get_twice_wide_int_ty(&self, ty: Ty<'tcx>) -> Ty<'tcx>
fn get_twice_wide_int_ty(&self, ty: Ty<'tcx>) -> Ty<'tcx>
Returns an integer type that is twice wide as ty
Sourcefn expect_target_feature_for_intrinsic(
&self,
intrinsic: Symbol,
target_feature: &str,
) -> InterpResult<'tcx, ()>
fn expect_target_feature_for_intrinsic( &self, intrinsic: Symbol, target_feature: &str, ) -> InterpResult<'tcx, ()>
Checks that target feature target_feature
is enabled.
If not enabled, emits an UB error that states that the feature is
required by intrinsic
.
Sourcefn lookup_link_section(
&mut self,
name: &str,
) -> InterpResult<'tcx, Vec<ImmTy<'tcx>>>
fn lookup_link_section( &mut self, name: &str, ) -> InterpResult<'tcx, Vec<ImmTy<'tcx>>>
Lookup an array of immediates stored as a linker section of name name
.
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.