From a303ea3ff50c68d77679e72f7b67256b992cbd94 Mon Sep 17 00:00:00 2001 From: Vincent Ambo Date: Fri, 2 Sep 2022 23:55:10 +0300 Subject: refactor(tvix/eval): implement much clearer disassembler output With this change the runtime trace contains much more exact information about the context of the computation (entering/exiting calls etc.) This is in large part due to moving the tracer to be a field on the VM itself, which enables consistent ordering of traces across the execution, and tracing an execution with its *input* instead of *output* stack. Change-Id: Ibe525e6e7d869756501e52bef1a441619ce7332c Reviewed-on: https://cl.tvl.fyi/c/depot/+/6419 Reviewed-by: sterni Tested-by: BuildkiteCI --- tvix/eval/src/disassembler.rs | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) (limited to 'tvix/eval/src/disassembler.rs') diff --git a/tvix/eval/src/disassembler.rs b/tvix/eval/src/disassembler.rs index e3cc1f16e706..a555f9179102 100644 --- a/tvix/eval/src/disassembler.rs +++ b/tvix/eval/src/disassembler.rs @@ -15,9 +15,7 @@ pub struct Tracer(TabWriter); impl Tracer { pub fn new() -> Self { - let mut tw = TabWriter::new(std::io::stderr()); - write!(&mut tw, "=== runtime trace ===\n").ok(); - Tracer(tw) + Tracer(TabWriter::new(std::io::stderr())) } pub fn trace(&mut self, op: &OpCode, ip: usize, stack: &[Value]) { @@ -29,6 +27,10 @@ impl Tracer { write!(&mut self.0, "]\n").ok(); } + + pub fn literal(&mut self, line: &str) { + let _ = write!(&mut self.0, "{}\n", line); + } } impl Drop for Tracer { -- cgit 1.4.1