@@ -5,6 +5,8 @@ use std::io::{Read, Seek, SeekFrom, Write};
55use std:: path:: Path ;
66use std:: time:: SystemTime ;
77
8+ use log:: trace;
9+
810use rustc_data_structures:: fx:: FxHashMap ;
911use rustc_target:: abi:: { Align , LayoutOf , Size } ;
1012
@@ -413,17 +415,16 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriEvalContextExt<'mir, 'tcx
413415
414416 fn read (
415417 & 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 ,
419421 ) -> InterpResult < ' tcx , i64 > {
420422 let this = self . eval_context_mut ( ) ;
421423
422424 this. check_no_isolation ( "read" ) ?;
425+ assert ! ( fd >= 3 ) ;
423426
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) ;
427428
428429 // Check that the *entire* buffer is actually valid memory.
429430 this. memory . check_ptr_access (
@@ -437,6 +438,7 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriEvalContextExt<'mir, 'tcx
437438 let count = count. min ( this. machine_isize_max ( ) as u64 ) . min ( isize:: MAX as u64 ) ;
438439
439440 if let Some ( FileHandle { file, writable : _ } ) = this. machine . file_handler . handles . get_mut ( & fd) {
441+ trace ! ( "read: FD mapped to {:?}" , file) ;
440442 // This can never fail because `count` was capped to be smaller than
441443 // `isize::MAX`.
442444 let count = isize:: try_from ( count) . unwrap ( ) ;
@@ -461,23 +463,21 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriEvalContextExt<'mir, 'tcx
461463 }
462464 }
463465 } else {
466+ trace ! ( "read: FD not found" ) ;
464467 this. handle_not_found ( )
465468 }
466469 }
467470
468471 fn write (
469472 & 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 ,
473476 ) -> InterpResult < ' tcx , i64 > {
474477 let this = self . eval_context_mut ( ) ;
475478
476479 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 ) ;
481481
482482 // Check that the *entire* buffer is actually valid memory.
483483 this. memory . check_ptr_access (
0 commit comments