Skip to content

Commit a192a19

Browse files
committed
Rename flag, datastructure and messaging around muting stdout and stderr
1 parent 1d0fe1b commit a192a19

File tree

6 files changed

+22
-22
lines changed

6 files changed

+22
-22
lines changed

src/bin/miri.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -374,8 +374,8 @@ fn main() {
374374
miri_config.tag_raw = true;
375375
miri_config.check_number_validity = true;
376376
}
377-
"-Zmiri-drop-stdout-stderr" => {
378-
miri_config.drop_stdout_stderr = true;
377+
"-Zmiri-mute-stdout-stderr" => {
378+
miri_config.mute_stdout_stderr = true;
379379
}
380380
"-Zmiri-track-raw-pointers" => {
381381
eprintln!(

src/eval.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@ pub struct MiriConfig {
118118
pub strict_provenance: bool,
119119
/// Whether to ignore any output by the program. This is helpful when debugging miri
120120
/// as its messages don't get intermingled with the program messages.
121-
pub drop_stdout_stderr: bool,
121+
pub mute_stdout_stderr: bool,
122122
}
123123

124124
impl Default for MiriConfig {
@@ -145,7 +145,7 @@ impl Default for MiriConfig {
145145
panic_on_unsupported: false,
146146
backtrace_style: BacktraceStyle::Short,
147147
strict_provenance: false,
148-
drop_stdout_stderr: false,
148+
mute_stdout_stderr: false,
149149
}
150150
}
151151
}

src/machine.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -292,8 +292,8 @@ pub struct Evaluator<'mir, 'tcx> {
292292
/// Failure rate of compare_exchange_weak, between 0.0 and 1.0
293293
pub(crate) cmpxchg_weak_failure_rate: f64,
294294

295-
/// Corresponds to -Zmiri-drop-stdout-stderr and doesn't write the output but acts as if it succeeded.
296-
pub(crate) drop_stdout_stderr: bool,
295+
/// Corresponds to -Zmiri-mute-stdout-stderr and doesn't write the output but acts as if it succeeded.
296+
pub(crate) mute_stdout_stderr: bool,
297297
}
298298

299299
impl<'mir, 'tcx> Evaluator<'mir, 'tcx> {
@@ -330,7 +330,7 @@ impl<'mir, 'tcx> Evaluator<'mir, 'tcx> {
330330
validate: config.validate,
331331
enforce_number_validity: config.check_number_validity,
332332
enforce_abi: config.check_abi,
333-
file_handler: FileHandler::new(config.drop_stdout_stderr),
333+
file_handler: FileHandler::new(config.mute_stdout_stderr),
334334
dir_handler: Default::default(),
335335
time_anchor: Instant::now(),
336336
layouts,
@@ -347,7 +347,7 @@ impl<'mir, 'tcx> Evaluator<'mir, 'tcx> {
347347
tracked_alloc_ids: config.tracked_alloc_ids.clone(),
348348
check_alignment: config.check_alignment,
349349
cmpxchg_weak_failure_rate: config.cmpxchg_weak_failure_rate,
350-
drop_stdout_stderr: config.drop_stdout_stderr,
350+
mute_stdout_stderr: config.mute_stdout_stderr,
351351
}
352352
}
353353

src/shims/posix/fs.rs

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -252,27 +252,27 @@ impl FileDescriptor for io::Stderr {
252252
}
253253

254254
#[derive(Debug)]
255-
struct DevNull;
255+
struct DummyOutput;
256256

257-
impl FileDescriptor for DevNull {
257+
impl FileDescriptor for DummyOutput {
258258
fn as_file_handle<'tcx>(&self) -> InterpResult<'tcx, &FileHandle> {
259-
throw_unsup_format!("/dev/null cannot be used as FileHandle");
259+
throw_unsup_format!("stderr and stdout cannot be used as FileHandle");
260260
}
261261

262262
fn read<'tcx>(
263263
&mut self,
264264
_communicate_allowed: bool,
265265
_bytes: &mut [u8],
266266
) -> InterpResult<'tcx, io::Result<usize>> {
267-
throw_unsup_format!("cannot read from /dev/null");
267+
throw_unsup_format!("cannot read from stderr or stdout");
268268
}
269269

270270
fn write<'tcx>(
271271
&self,
272272
_communicate_allowed: bool,
273273
bytes: &[u8],
274274
) -> InterpResult<'tcx, io::Result<usize>> {
275-
// We just don't write anything
275+
// We just don't write anything, but report to the user that we did.
276276
Ok(Ok(bytes.len()))
277277
}
278278

@@ -281,18 +281,18 @@ impl FileDescriptor for DevNull {
281281
_communicate_allowed: bool,
282282
_offset: SeekFrom,
283283
) -> InterpResult<'tcx, io::Result<u64>> {
284-
throw_unsup_format!("cannot seek on /dev/null");
284+
throw_unsup_format!("cannot seek on stderr or stdout");
285285
}
286286

287287
fn close<'tcx>(
288288
self: Box<Self>,
289289
_communicate_allowed: bool,
290290
) -> InterpResult<'tcx, io::Result<i32>> {
291-
throw_unsup_format!("/dev/null cannot be closed");
291+
throw_unsup_format!("stderr and stdout cannot be closed");
292292
}
293293

294294
fn dup<'tcx>(&mut self) -> io::Result<Box<dyn FileDescriptor>> {
295-
Ok(Box::new(DevNull))
295+
Ok(Box::new(DummyOutput))
296296
}
297297
}
298298

@@ -302,11 +302,11 @@ pub struct FileHandler {
302302
}
303303

304304
impl<'tcx> FileHandler {
305-
pub(crate) fn new(drop_stdout_stderr: bool) -> FileHandler {
305+
pub(crate) fn new(mute_stdout_stderr: bool) -> FileHandler {
306306
let mut handles: BTreeMap<_, Box<dyn FileDescriptor>> = BTreeMap::new();
307-
if drop_stdout_stderr {
308-
handles.insert(0i32, Box::new(DevNull));
309-
handles.insert(1i32, Box::new(DevNull));
307+
if mute_stdout_stderr {
308+
handles.insert(0i32, Box::new(DummyOutput));
309+
handles.insert(1i32, Box::new(DummyOutput));
310310
} else {
311311
handles.insert(0i32, Box::new(io::stdin()));
312312
handles.insert(1i32, Box::new(io::stdout()));

src/shims/windows/dlsym.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriEvalContextExt<'mir, 'tcx
7575
use std::io::{self, Write};
7676

7777
let buf_cont = this.read_bytes_ptr(buf, Size::from_bytes(u64::from(n)))?;
78-
let res = if this.machine.drop_stdout_stderr {
78+
let res = if this.machine.mute_stdout_stderr {
7979
Ok(buf_cont.len())
8080
} else if handle == -11 {
8181
io::stdout().write(buf_cont)

tests/run-pass/hide_stdout.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// compile-flags: -Zmiri-drop-stdout-stderr
1+
// compile-flags: -Zmiri-mute-stdout-stderr
22

33
fn main() {
44
println!("cake");

0 commit comments

Comments
 (0)