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