@@ -20,8 +20,7 @@ mod ffi;
20
20
) ]
21
21
pub mod trace;
22
22
23
- use self :: ffi:: CArg ;
24
- use crate :: shims:: native_lib:: ffi:: CPrimitive ;
23
+ use self :: ffi:: { CArg , CPrimitive , FfiArg } ;
25
24
use crate :: * ;
26
25
27
26
/// The final results of an FFI trace, containing every relevant event detected
@@ -83,7 +82,7 @@ trait EvalContextExtPriv<'tcx>: crate::MiriInterpCxExt<'tcx> {
83
82
link_name : Symbol ,
84
83
dest : & MPlaceTy < ' tcx > ,
85
84
ptr : CodePtr ,
86
- libffi_args : Vec < ffi :: FfiArg < ' a > > ,
85
+ libffi_args : Vec < FfiArg < ' a > > ,
87
86
) -> InterpResult < ' tcx , ( crate :: ImmTy < ' tcx > , Option < MemEvents > ) > {
88
87
let this = self . eval_context_mut ( ) ;
89
88
#[ cfg( target_os = "linux" ) ]
@@ -280,7 +279,7 @@ trait EvalContextExtPriv<'tcx>: crate::MiriInterpCxExt<'tcx> {
280
279
interp_ok ( ( ) )
281
280
}
282
281
283
- /// Extract the value from the result of reading a scalar or mplace from the machine,
282
+ /// Extract the value from the result of reading an operand from the machine
284
283
/// and convert it to a `CArg`.
285
284
fn op_to_carg ( & self , v : & OpTy < ' tcx > , tracing : bool ) -> InterpResult < ' tcx , CArg > {
286
285
let this = self . eval_context_ref ( ) ;
@@ -316,7 +315,7 @@ trait EvalContextExtPriv<'tcx>: crate::MiriInterpCxExt<'tcx> {
316
315
} ;
317
316
318
317
// This relies on the `expose_provenance` in the `visit_reachable_allocs` callback
319
- // below.
318
+ // below to expose the actual interpreter-level allocation .
320
319
CPrimitive :: RawPtr ( std:: ptr:: with_exposed_provenance_mut ( ptr. addr ( ) . bytes_usize ( ) ) )
321
320
. into ( )
322
321
}
@@ -332,21 +331,21 @@ trait EvalContextExtPriv<'tcx>: crate::MiriInterpCxExt<'tcx> {
332
331
// exposed recursively.
333
332
let ptr = mplace. ptr ( ) ;
334
333
// Make sure the provenance of this allocation is exposed;
335
- // there must be one for this arg to be valid at all.
334
+ // there must be one for this mplace to be valid at all.
335
+ // The interpreter-level allocation itself is exposed in
336
+ // visit_reachable_allocs.
336
337
this. expose_provenance ( ptr. provenance . unwrap ( ) ) ?;
337
338
// Then get the actual bytes.
338
339
let id = this
339
340
. alloc_id_from_addr (
340
341
ptr. addr ( ) . bytes ( ) ,
341
342
mplace. layout . size . bytes_usize ( ) . try_into ( ) . unwrap ( ) ,
342
- /* only_exposed_allocations */ false ,
343
+ /* only_exposed_allocations */ true ,
343
344
)
344
345
. unwrap ( ) ;
345
346
let ptr_raw = this. get_alloc_bytes_unchecked_raw ( id) ?;
346
- // Expose the allocation here so that the FFI code can access it.
347
- std:: hint:: black_box ( ptr_raw. expose_provenance ( ) ) ;
348
- // SAFETY: We know for sure that at ptr_raw there are initialised
349
- // bytes as indicated by the layout size.
347
+ // SAFETY: We know for sure that at ptr_raw the next layout.size bytes
348
+ // are part of this allocation and initialised.
350
349
unsafe {
351
350
std:: slice:: from_raw_parts ( ptr_raw, mplace. layout . size . bytes_usize ( ) )
352
351
. to_vec ( )
0 commit comments