2013-06-18 05:17:51 +00:00
|
|
|
// Copyright 2013 The Rust Project Developers. See the COPYRIGHT
|
|
|
|
// file at the top-level directory of this distribution and at
|
|
|
|
// http://rust-lang.org/COPYRIGHT.
|
|
|
|
//
|
|
|
|
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
|
|
|
|
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
|
|
|
|
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
|
|
|
|
// option. This file may not be copied, modified, or distributed
|
|
|
|
// except according to those terms.
|
2014-11-24 03:21:17 +00:00
|
|
|
|
2014-12-11 03:46:38 +00:00
|
|
|
use fmt;
|
2015-09-08 22:53:46 +00:00
|
|
|
use io::prelude::*;
|
2015-03-11 22:24:14 +00:00
|
|
|
use sys::stdio::Stderr;
|
2015-09-08 22:53:46 +00:00
|
|
|
use thread;
|
2013-08-17 06:14:55 +00:00
|
|
|
|
2014-12-27 21:57:43 +00:00
|
|
|
pub fn dumb_print(args: fmt::Arguments) {
|
2015-06-10 04:39:36 +00:00
|
|
|
let _ = Stderr::new().map(|mut stderr| stderr.write_fmt(args));
|
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,
|
|
|
|
// ::intrinsics::abort() may be used instead. The above implementations cover
|
|
|
|
// all targets currently supported by libstd.
|
|
|
|
|
2014-12-30 03:40:57 +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));
|
2016-09-30 23:07:04 +00:00
|
|
|
unsafe { ::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() {
|
2016-01-09 19:19:56 +00:00
|
|
|
dumb_print(format_args!("\nthread '{}' has overflowed its stack\n",
|
2015-09-08 22:53:46 +00:00
|
|
|
thread::current().name().unwrap_or("<unknown>")));
|
2014-11-24 03:21:17 +00:00
|
|
|
}
|