@@ -5,6 +5,8 @@ use std::io::{Read, Seek, SeekFrom, Write};
5
5
use std:: path:: Path ;
6
6
use std:: time:: SystemTime ;
7
7
8
+ use log:: trace;
9
+
8
10
use rustc_data_structures:: fx:: FxHashMap ;
9
11
use rustc_target:: abi:: { Align , LayoutOf , Size } ;
10
12
@@ -413,17 +415,16 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriEvalContextExt<'mir, 'tcx
413
415
414
416
fn read (
415
417
& mut self ,
416
- fd_op : OpTy < ' tcx , Tag > ,
417
- buf_op : OpTy < ' tcx , Tag > ,
418
- count_op : OpTy < ' tcx , Tag > ,
418
+ fd : i32 ,
419
+ buf : Scalar < Tag > ,
420
+ count : u64 ,
419
421
) -> InterpResult < ' tcx , i64 > {
420
422
let this = self . eval_context_mut ( ) ;
421
423
422
424
this. check_no_isolation ( "read" ) ?;
425
+ assert ! ( fd >= 3 ) ;
423
426
424
- let fd = this. read_scalar ( fd_op) ?. to_i32 ( ) ?;
425
- let buf = this. read_scalar ( buf_op) ?. not_undef ( ) ?;
426
- let count = this. read_scalar ( count_op) ?. to_machine_usize ( & * this. tcx ) ?;
427
+ trace ! ( "Reading from FD {}, size {}" , fd, count) ;
427
428
428
429
// Check that the *entire* buffer is actually valid memory.
429
430
this. memory . check_ptr_access (
@@ -437,6 +438,7 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriEvalContextExt<'mir, 'tcx
437
438
let count = count. min ( this. machine_isize_max ( ) as u64 ) . min ( isize:: MAX as u64 ) ;
438
439
439
440
if let Some ( FileHandle { file, writable : _ } ) = this. machine . file_handler . handles . get_mut ( & fd) {
441
+ trace ! ( "read: FD mapped to {:?}" , file) ;
440
442
// This can never fail because `count` was capped to be smaller than
441
443
// `isize::MAX`.
442
444
let count = isize:: try_from ( count) . unwrap ( ) ;
@@ -461,23 +463,21 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriEvalContextExt<'mir, 'tcx
461
463
}
462
464
}
463
465
} else {
466
+ trace ! ( "read: FD not found" ) ;
464
467
this. handle_not_found ( )
465
468
}
466
469
}
467
470
468
471
fn write (
469
472
& mut self ,
470
- fd_op : OpTy < ' tcx , Tag > ,
471
- buf_op : OpTy < ' tcx , Tag > ,
472
- count_op : OpTy < ' tcx , Tag > ,
473
+ fd : i32 ,
474
+ buf : Scalar < Tag > ,
475
+ count : u64 ,
473
476
) -> InterpResult < ' tcx , i64 > {
474
477
let this = self . eval_context_mut ( ) ;
475
478
476
479
this. check_no_isolation ( "write" ) ?;
477
-
478
- let fd = this. read_scalar ( fd_op) ?. to_i32 ( ) ?;
479
- let buf = this. read_scalar ( buf_op) ?. not_undef ( ) ?;
480
- let count = this. read_scalar ( count_op) ?. to_machine_usize ( & * this. tcx ) ?;
480
+ assert ! ( fd >= 3 ) ;
481
481
482
482
// Check that the *entire* buffer is actually valid memory.
483
483
this. memory . check_ptr_access (
0 commit comments