std: Make newsched failures log correctly

This commit is contained in:
Brian Anderson 2013-06-19 18:37:50 -07:00
parent 5086c0850e
commit 391bb0b4e7

View File

@ -180,10 +180,13 @@ impl FailWithCause for &'static str {
// FIXME #4427: Temporary until rt::rt_fail_ goes away
pub fn begin_unwind_(msg: *c_char, file: *c_char, line: size_t) -> ! {
use cell::Cell;
use option::Option;
use either::Left;
use rt::{context, OldTaskContext, TaskContext};
use rt::task::{Task, Unwinder};
use rt::local::Local;
use rt::logging::Logger;
let context = context();
match context {
@ -200,12 +203,18 @@ pub fn begin_unwind_(msg: *c_char, file: *c_char, line: size_t) -> ! {
let msg = str::raw::from_c_str(msg);
let file = str::raw::from_c_str(file);
let outmsg = fmt!("%s at line %i of file %s", msg, line as int, file);
let outmsg = fmt!("task failed: '%s' at line %i of file %s",
msg, line as int, file);
// XXX: Logging doesn't work correctly in non-task context because it
// invokes the local heap
if context == TaskContext {
error!(outmsg);
// XXX: Logging doesn't work here - the check to call the log
// function never passes - so calling the log function directly.
let outmsg = Cell::new(outmsg);
do Local::borrow::<Task, ()> |task| {
task.logger.log(Left(outmsg.take()));
}
} else {
rtdebug!("%s", outmsg);
}