trace: add serf event tracing for peek writs

This commit is contained in:
Alex Shelkovnykov 2023-11-19 14:33:30 -05:00
parent eef367bb63
commit 60aaa45443

View File

@ -242,9 +242,8 @@ pub fn serf() -> io::Result<()> {
context.live(); context.live();
} }
tas!(b"peek") => { tas!(b"peek") => {
let sam = slot(writ, 7)?; let ovo = slot(writ, 7)?;
let res = let res = peek(&mut context, ovo);
slam(&mut context, PEEK_AXIS, sam).expect("peek error handling unimplemented");
context.peek_done(res); context.peek_done(res);
} }
tas!(b"play") => { tas!(b"play") => {
@ -289,6 +288,33 @@ fn slam(context: &mut Context, axis: u64, ovo: Noun) -> Result<Noun, Error> {
interpret(&mut context.nock_context, sub, fol) interpret(&mut context.nock_context, sub, fol)
} }
fn peek(context: &mut Context, ovo: Noun) -> Noun {
if context.nock_context.trace_info.is_some() {
// XX: way too many cases in the input to pull the actual vane, care, and path out
let trace_name = "peek";
let _ = write_serf_trace_start(
context.nock_context.trace_info.as_mut().unwrap(),
trace_name,
);
let slam_res = slam(context, PEEK_AXIS, ovo);
// Abort writing to trace file if we encountered an error. This should result in a
// well-formed partial trace file.
if let Err(e) = write_serf_trace_start(
context.nock_context.trace_info.as_mut().unwrap(),
trace_name,
) {
eprintln!("\rserf: error writing event trace to file: {:?}", e);
context.nock_context.trace_info = None;
}
slam_res.expect("peek error handling unimplemented")
} else {
slam(context, PEEK_AXIS, ovo).expect("peek error handling unimplemented")
}
}
fn goof(context: &mut Context, traces: Noun) -> Noun { fn goof(context: &mut Context, traces: Noun) -> Noun {
let trace = zing(&mut context.nock_context.stack, traces).unwrap(); let trace = zing(&mut context.nock_context.stack, traces).unwrap();
let tone = Cell::new(&mut context.nock_context.stack, D(2), trace); let tone = Cell::new(&mut context.nock_context.stack, D(2), trace);