diff --git a/artiq/runtime.rs/src/kernel_proto.rs b/artiq/runtime.rs/src/kernel_proto.rs index b84a93df0..64a074518 100644 --- a/artiq/runtime.rs/src/kernel_proto.rs +++ b/artiq/runtime.rs/src/kernel_proto.rs @@ -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 _) } diff --git a/artiq/runtime.rs/src/session.rs b/artiq/runtime.rs/src/session.rs index 2f04926d7..644381ea8 100644 --- a/artiq/runtime.rs/src/session.rs +++ b/artiq/runtime.rs/src/session.rs @@ -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(()) + } } } diff --git a/artiq/runtime/Makefile b/artiq/runtime/Makefile index 30a8b1d7f..0f8aec3cd 100644 --- a/artiq/runtime/Makefile +++ b/artiq/runtime/Makefile @@ -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