diff --git a/src/bin/miri.rs b/src/bin/miri.rs index b55b6f8d5589..2fa045b57462 100644 --- a/src/bin/miri.rs +++ b/src/bin/miri.rs @@ -374,8 +374,8 @@ fn main() { miri_config.tag_raw = true; miri_config.check_number_validity = true; } - "-Zmiri-drop-stdout-stderr" => { - miri_config.drop_stdout_stderr = true; + "-Zmiri-mute-stdout-stderr" => { + miri_config.mute_stdout_stderr = true; } "-Zmiri-track-raw-pointers" => { eprintln!( diff --git a/src/eval.rs b/src/eval.rs index f1cbb00942bb..028c9b97abb3 100644 --- a/src/eval.rs +++ b/src/eval.rs @@ -118,7 +118,7 @@ pub struct MiriConfig { pub strict_provenance: bool, /// Whether to ignore any output by the program. This is helpful when debugging miri /// as its messages don't get intermingled with the program messages. - pub drop_stdout_stderr: bool, + pub mute_stdout_stderr: bool, } impl Default for MiriConfig { @@ -145,7 +145,7 @@ impl Default for MiriConfig { panic_on_unsupported: false, backtrace_style: BacktraceStyle::Short, strict_provenance: false, - drop_stdout_stderr: false, + mute_stdout_stderr: false, } } } diff --git a/src/machine.rs b/src/machine.rs index 6cce1a5db252..1c916220c8c5 100644 --- a/src/machine.rs +++ b/src/machine.rs @@ -292,8 +292,8 @@ pub struct Evaluator<'mir, 'tcx> { /// Failure rate of compare_exchange_weak, between 0.0 and 1.0 pub(crate) cmpxchg_weak_failure_rate: f64, - /// Corresponds to -Zmiri-drop-stdout-stderr and doesn't write the output but acts as if it succeeded. - pub(crate) drop_stdout_stderr: bool, + /// Corresponds to -Zmiri-mute-stdout-stderr and doesn't write the output but acts as if it succeeded. + pub(crate) mute_stdout_stderr: bool, } impl<'mir, 'tcx> Evaluator<'mir, 'tcx> { @@ -330,7 +330,7 @@ impl<'mir, 'tcx> Evaluator<'mir, 'tcx> { validate: config.validate, enforce_number_validity: config.check_number_validity, enforce_abi: config.check_abi, - file_handler: FileHandler::new(config.drop_stdout_stderr), + file_handler: FileHandler::new(config.mute_stdout_stderr), dir_handler: Default::default(), time_anchor: Instant::now(), layouts, @@ -347,7 +347,7 @@ impl<'mir, 'tcx> Evaluator<'mir, 'tcx> { tracked_alloc_ids: config.tracked_alloc_ids.clone(), check_alignment: config.check_alignment, cmpxchg_weak_failure_rate: config.cmpxchg_weak_failure_rate, - drop_stdout_stderr: config.drop_stdout_stderr, + mute_stdout_stderr: config.mute_stdout_stderr, } } diff --git a/src/shims/posix/fs.rs b/src/shims/posix/fs.rs index 78d0e958e2a0..1b0a94e0ffc9 100644 --- a/src/shims/posix/fs.rs +++ b/src/shims/posix/fs.rs @@ -252,11 +252,11 @@ impl FileDescriptor for io::Stderr { } #[derive(Debug)] -struct DevNull; +struct DummyOutput; -impl FileDescriptor for DevNull { +impl FileDescriptor for DummyOutput { fn as_file_handle<'tcx>(&self) -> InterpResult<'tcx, &FileHandle> { - throw_unsup_format!("/dev/null cannot be used as FileHandle"); + throw_unsup_format!("stderr and stdout cannot be used as FileHandle"); } fn read<'tcx>( @@ -264,7 +264,7 @@ impl FileDescriptor for DevNull { _communicate_allowed: bool, _bytes: &mut [u8], ) -> InterpResult<'tcx, io::Result> { - throw_unsup_format!("cannot read from /dev/null"); + throw_unsup_format!("cannot read from stderr or stdout"); } fn write<'tcx>( @@ -272,7 +272,7 @@ impl FileDescriptor for DevNull { _communicate_allowed: bool, bytes: &[u8], ) -> InterpResult<'tcx, io::Result> { - // We just don't write anything + // We just don't write anything, but report to the user that we did. Ok(Ok(bytes.len())) } @@ -281,18 +281,18 @@ impl FileDescriptor for DevNull { _communicate_allowed: bool, _offset: SeekFrom, ) -> InterpResult<'tcx, io::Result> { - throw_unsup_format!("cannot seek on /dev/null"); + throw_unsup_format!("cannot seek on stderr or stdout"); } fn close<'tcx>( self: Box, _communicate_allowed: bool, ) -> InterpResult<'tcx, io::Result> { - throw_unsup_format!("/dev/null cannot be closed"); + throw_unsup_format!("stderr and stdout cannot be closed"); } fn dup<'tcx>(&mut self) -> io::Result> { - Ok(Box::new(DevNull)) + Ok(Box::new(DummyOutput)) } } @@ -302,11 +302,11 @@ pub struct FileHandler { } impl<'tcx> FileHandler { - pub(crate) fn new(drop_stdout_stderr: bool) -> FileHandler { + pub(crate) fn new(mute_stdout_stderr: bool) -> FileHandler { let mut handles: BTreeMap<_, Box> = BTreeMap::new(); - if drop_stdout_stderr { - handles.insert(0i32, Box::new(DevNull)); - handles.insert(1i32, Box::new(DevNull)); + if mute_stdout_stderr { + handles.insert(0i32, Box::new(DummyOutput)); + handles.insert(1i32, Box::new(DummyOutput)); } else { handles.insert(0i32, Box::new(io::stdin())); handles.insert(1i32, Box::new(io::stdout())); diff --git a/src/shims/windows/dlsym.rs b/src/shims/windows/dlsym.rs index 05230531d917..ddbad8c5affa 100644 --- a/src/shims/windows/dlsym.rs +++ b/src/shims/windows/dlsym.rs @@ -75,7 +75,7 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriEvalContextExt<'mir, 'tcx use std::io::{self, Write}; let buf_cont = this.read_bytes_ptr(buf, Size::from_bytes(u64::from(n)))?; - let res = if this.machine.drop_stdout_stderr { + let res = if this.machine.mute_stdout_stderr { Ok(buf_cont.len()) } else if handle == -11 { io::stdout().write(buf_cont) diff --git a/tests/run-pass/hide_stdout.rs b/tests/run-pass/hide_stdout.rs index 04a4ef9df174..849fce913862 100644 --- a/tests/run-pass/hide_stdout.rs +++ b/tests/run-pass/hide_stdout.rs @@ -1,4 +1,4 @@ -// compile-flags: -Zmiri-drop-stdout-stderr +// compile-flags: -Zmiri-mute-stdout-stderr fn main() { println!("cake");