forked from M-Labs/artiq
1
0
Fork 0

Rust: implement exceptional RPC replies.

This commit is contained in:
whitequark 2016-10-06 14:08:02 +00:00
parent 226fa723bb
commit e92f20546a
3 changed files with 33 additions and 4 deletions

View File

@ -110,7 +110,7 @@ impl<'a> Message<'a> {
let msg = c::RpcRecvReply {
ty: c::Type::RpcRecvReply,
alloc_size: alloc_size as _,
exception: exn.map_or(ptr::null(), |exn| &exn as *const _)
exception: exn.as_ref().map_or(ptr::null(), |exn| exn as *const _)
};
f(&msg as *const _ as *const _)
}

View File

@ -264,7 +264,36 @@ fn process_host_message(waiter: Waiter,
Ok(())
}
request => unexpected!("unexpected request {:?} from host machine", request)
host::Request::RpcException {
name, message, param, file, line, column, function
} => {
if session.kernel_state != KernelState::RpcWait {
unexpected!("unsolicited RPC reply")
}
try!(kern_recv(waiter, |reply| {
match reply {
kern::RpcRecvRequest { .. } => Ok(()),
other =>
unexpected!("unexpected reply from kernel CPU: {:?}", other)
}
}));
try!(kern_send(waiter, kern::RpcRecvReply {
alloc_size: 0,
exception: Some(kern::Exception {
name: &name,
message: &message,
param: param,
file: &file,
line: line,
column: column,
function: &function
})
}));
session.kernel_state = KernelState::Running;
Ok(())
}
}
}

View File

@ -15,8 +15,8 @@ CFLAGS += -I$(LIBALLOC_DIRECTORY) \
-I$(LIBUNWIND_DIRECTORY) \
-I$(LIBUNWIND_DIRECTORY)/../unwinder/include \
-I$(LIBLWIP_DIRECTORY)/../lwip/src/include \
-I$(LIBLWIP_DIRECTORY) \
-DNDEBUG
-I$(LIBLWIP_DIRECTORY)
CFLAGS += -DNDEBUG
all: runtime.bin runtime.fbi