2019-02-10 19:23:21 +00:00
|
|
|
use crate::fmt;
|
|
|
|
use crate::io::prelude::*;
|
|
|
|
use crate::sys::stdio::panic_output;
|
|
|
|
use crate::thread;
|
2013-08-17 06:14:55 +00:00
|
|
|
|
2019-03-01 08:34:11 +00:00
|
|
|
pub fn dumb_print(args: fmt::Arguments<'_>) {
|
2018-08-27 16:57:51 +00:00
|
|
|
if let Some(mut out) = panic_output() {
|
|
|
|
let _ = out.write_fmt(args);
|
2018-03-29 21:59:13 +00:00
|
|
|
}
|
2014-12-27 21:57:43 +00:00
|
|
|
}
|
|
|
|
|
2016-05-23 04:16:26 +00:00
|
|
|
// Other platforms should use the appropriate platform-specific mechanism for
|
|
|
|
// aborting the process. If no platform-specific mechanism is available,
|
2019-02-17 13:35:20 +00:00
|
|
|
// crate::intrinsics::abort() may be used instead. The above implementations cover
|
2016-05-23 04:16:26 +00:00
|
|
|
// all targets currently supported by libstd.
|
|
|
|
|
2019-03-01 08:34:11 +00:00
|
|
|
pub fn abort(args: fmt::Arguments<'_>) -> ! {
|
2016-01-09 19:19:56 +00:00
|
|
|
dumb_print(format_args!("fatal runtime error: {}\n", args));
|
2019-11-27 18:29:00 +00:00
|
|
|
unsafe {
|
|
|
|
crate::sys::abort_internal();
|
|
|
|
}
|
2014-11-24 03:21:17 +00:00
|
|
|
}
|
|
|
|
|
2015-09-08 22:53:46 +00:00
|
|
|
#[allow(dead_code)] // stack overflow detection not enabled on all platforms
|
2014-11-24 03:21:17 +00:00
|
|
|
pub unsafe fn report_overflow() {
|
2019-11-27 18:29:00 +00:00
|
|
|
dumb_print(format_args!(
|
|
|
|
"\nthread '{}' has overflowed its stack\n",
|
|
|
|
thread::current().name().unwrap_or("<unknown>")
|
|
|
|
));
|
2014-11-24 03:21:17 +00:00
|
|
|
}
|