commit
ad7089f194
3 changed files with 41 additions and 27 deletions
|
|
@ -1 +1 @@
|
|||
1edd389cc4c7b5be7a3dd4fe4b986f6017018e54
|
||||
342c5f33d097b2dc07a2dbc0ca45a37379d2ff60
|
||||
|
|
|
|||
|
|
@ -1,4 +1,5 @@
|
|||
use std::cell::RefCell;
|
||||
use std::fmt;
|
||||
|
||||
use rustc_span::DUMMY_SP;
|
||||
|
||||
|
|
@ -12,6 +13,26 @@ pub enum TerminationInfo {
|
|||
ExperimentalUb { msg: String, url: String }
|
||||
}
|
||||
|
||||
impl fmt::Debug for TerminationInfo {
|
||||
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||
use TerminationInfo::*;
|
||||
match self {
|
||||
Exit(code) =>
|
||||
write!(f, "the evaluated program completed with exit code {}", code),
|
||||
Abort(None) =>
|
||||
write!(f, "the evaluated program aborted execution"),
|
||||
Abort(Some(msg)) =>
|
||||
write!(f, "the evaluated program aborted execution: {}", msg),
|
||||
UnsupportedInIsolation(msg) =>
|
||||
write!(f, "{}", msg),
|
||||
ExperimentalUb { msg, .. } =>
|
||||
write!(f, "{}", msg),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl MachineStopType for TerminationInfo {}
|
||||
|
||||
/// Miri specific diagnostics
|
||||
pub enum NonHaltingDiagnostic {
|
||||
PoppedTrackedPointerTag(Item),
|
||||
|
|
@ -25,21 +46,18 @@ pub fn report_error<'tcx, 'mir>(
|
|||
) -> Option<i64> {
|
||||
use InterpError::*;
|
||||
|
||||
e.print_backtrace();
|
||||
let (title, msg, helps) = match e.kind {
|
||||
MachineStop(info) => {
|
||||
let (title, helps) = match e.kind {
|
||||
MachineStop(ref info) => {
|
||||
let info = info.downcast_ref::<TerminationInfo>().expect("invalid MachineStop payload");
|
||||
use TerminationInfo::*;
|
||||
let (title, msg) = match info {
|
||||
let title = match info {
|
||||
Exit(code) => return Some(*code),
|
||||
Abort(None) =>
|
||||
("abnormal termination", format!("the evaluated program aborted execution")),
|
||||
Abort(Some(msg)) =>
|
||||
("abnormal termination", format!("the evaluated program aborted execution: {}", msg)),
|
||||
UnsupportedInIsolation(msg) =>
|
||||
("unsupported operation", format!("{}", msg)),
|
||||
ExperimentalUb { msg, .. } =>
|
||||
("Undefined Behavior", format!("{}", msg)),
|
||||
Abort(_) =>
|
||||
"abnormal termination",
|
||||
UnsupportedInIsolation(_) =>
|
||||
"unsupported operation",
|
||||
ExperimentalUb { .. } =>
|
||||
"Undefined Behavior",
|
||||
};
|
||||
let helps = match info {
|
||||
UnsupportedInIsolation(_) =>
|
||||
|
|
@ -51,16 +69,16 @@ pub fn report_error<'tcx, 'mir>(
|
|||
],
|
||||
_ => vec![],
|
||||
};
|
||||
(title, msg, helps)
|
||||
(title, helps)
|
||||
}
|
||||
_ => {
|
||||
let (title, msg) = match e.kind {
|
||||
let title = match e.kind {
|
||||
Unsupported(_) =>
|
||||
("unsupported operation", e.to_string()),
|
||||
"unsupported operation",
|
||||
UndefinedBehavior(_) =>
|
||||
("Undefined Behavior", e.to_string()),
|
||||
"Undefined Behavior",
|
||||
ResourceExhaustion(_) =>
|
||||
("resource exhaustion", e.to_string()),
|
||||
"resource exhaustion",
|
||||
_ =>
|
||||
bug!("This error should be impossible in Miri: {}", e),
|
||||
};
|
||||
|
|
@ -76,9 +94,12 @@ pub fn report_error<'tcx, 'mir>(
|
|||
],
|
||||
_ => vec![],
|
||||
};
|
||||
(title, msg, helps)
|
||||
(title, helps)
|
||||
}
|
||||
};
|
||||
|
||||
e.print_backtrace();
|
||||
let msg = e.to_string();
|
||||
report_msg(ecx, &format!("{}: {}", title, msg), msg, &helps, true)
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -114,13 +114,6 @@ trait EvalContextExtPrivate<'mir, 'tcx: 'mir>: crate::MiriEvalContextExt<'mir, '
|
|||
let blksize_t_layout = this.libc_ty_layout("blksize_t")?;
|
||||
let uint32_t_layout = this.libc_ty_layout("uint32_t")?;
|
||||
|
||||
// We need to add 32 bits of padding after `st_rdev` if we are on a 64-bit target.
|
||||
let pad_layout = if this.tcx.sess.target.ptr_width == 64 {
|
||||
uint32_t_layout
|
||||
} else {
|
||||
this.layout_of(this.tcx.mk_unit())?
|
||||
};
|
||||
|
||||
let imms = [
|
||||
immty_from_uint_checked(0u128, dev_t_layout)?, // st_dev
|
||||
immty_from_uint_checked(mode, mode_t_layout)?, // st_mode
|
||||
|
|
@ -129,7 +122,7 @@ trait EvalContextExtPrivate<'mir, 'tcx: 'mir>: crate::MiriEvalContextExt<'mir, '
|
|||
immty_from_uint_checked(0u128, uid_t_layout)?, // st_uid
|
||||
immty_from_uint_checked(0u128, gid_t_layout)?, // st_gid
|
||||
immty_from_uint_checked(0u128, dev_t_layout)?, // st_rdev
|
||||
immty_from_uint_checked(0u128, pad_layout)?, // padding for 64-bit targets
|
||||
immty_from_uint_checked(0u128, uint32_t_layout)?, // padding
|
||||
immty_from_uint_checked(access_sec, time_t_layout)?, // st_atime
|
||||
immty_from_uint_checked(access_nsec, long_layout)?, // st_atime_nsec
|
||||
immty_from_uint_checked(modified_sec, time_t_layout)?, // st_mtime
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue