Rename rterr to rtprintpanic

This commit is contained in:
Christiaan Dirkx 2021-05-06 14:03:50 +02:00
parent 6145051eee
commit 4ff5ab5296
5 changed files with 12 additions and 11 deletions

View File

@ -315,7 +315,7 @@ pub fn take_alloc_error_hook() -> fn(Layout) {
}
fn default_alloc_error_hook(layout: Layout) {
rterr!("memory allocation of {} bytes failed\n", layout.size());
rtprintpanic!("memory allocation of {} bytes failed\n", layout.size());
}
#[cfg(not(test))]

View File

@ -596,15 +596,12 @@ fn rust_panic_with_hook(
if panics > 2 {
// Don't try to print the message in this case
// - perhaps that is causing the recursive panics.
rterr!("thread panicked while processing panic. aborting.\n");
rtprintpanic!("thread panicked while processing panic. aborting.\n");
} else {
// Unfortunately, this does not print a backtrace, because creating
// a `Backtrace` will allocate, which we must to avoid here.
let panicinfo = PanicInfo::internal_constructor(message, location);
rterr!(
"{}\npanicked after panic::always_abort(), aborting.\n",
panicinfo
);
rtprintpanic!("{}\npanicked after panic::always_abort(), aborting.\n", panicinfo);
}
intrinsics::abort()
}
@ -637,7 +634,7 @@ fn rust_panic_with_hook(
// have limited options. Currently our preference is to
// just abort. In the future we may consider resuming
// unwinding or otherwise exiting the thread cleanly.
rterr!("thread panicked while panicking. aborting.\n");
rtprintpanic!("thread panicked while panicking. aborting.\n");
intrinsics::abort()
}

View File

@ -102,7 +102,7 @@ mod imp {
// If the faulting address is within the guard page, then we print a
// message saying so and abort.
if guard.start <= addr && addr < guard.end {
rterr!(
rtprintpanic!(
"\nthread '{}' has overflowed its stack\n",
thread::current().name().unwrap_or("<unknown>")
);

View File

@ -24,7 +24,7 @@ extern "system" fn vectored_handler(ExceptionInfo: *mut c::EXCEPTION_POINTERS) -
let code = rec.ExceptionCode;
if code == c::EXCEPTION_STACK_OVERFLOW {
rterr!(
rtprintpanic!(
"\nthread '{}' has overflowed its stack\n",
thread::current().name().unwrap_or("<unknown>")
);

View File

@ -39,7 +39,11 @@ pub fn cleanup() {
});
}
macro_rules! rterr {
// Prints to the "panic output", depending on the platform this may be:
// - the standard error output
// - some dedicated platform specific output
// - nothing (so this macro is a no-op)
macro_rules! rtprintpanic {
($($t:tt)*) => {
if let Some(mut out) = crate::sys::stdio::panic_output() {
let _ = crate::io::Write::write_fmt(&mut out, format_args!($($t)*));
@ -50,7 +54,7 @@ macro_rules! rterr {
macro_rules! rtabort {
($($t:tt)*) => {
{
rterr!("fatal runtime error: {}\n", format_args!($($t)*));
rtprintpanic!("fatal runtime error: {}\n", format_args!($($t)*));
crate::sys::abort_internal();
}
}