about summary refs log tree commit diff
path: root/tvix/eval/src/observer.rs
diff options
context:
space:
mode:
authorVincent Ambo <mail@tazj.in>2022-10-10T23·24+0300
committerclbot <clbot@tvl.fyi>2022-10-11T00·07+0000
commit76e0c37b9eb9e2ddf6cedbbf0b5a1d2a603de0c4 (patch)
tree8bfaf0ab71f284ea022f824b26f22d7cb9a5b123 /tvix/eval/src/observer.rs
parent8e122574c238ec18644fbe49d18a8d204fff66e0 (diff)
feat(tvix/eval): observe stack after exiting call frames/builtins r/5099
Change-Id: I1937d37551503a0b6bb0ac899d067302e4791e5f
Reviewed-on: https://cl.tvl.fyi/c/depot/+/6939
Reviewed-by: grfn <grfn@gws.fyi>
Autosubmit: tazjin <tazjin@tvl.su>
Tested-by: BuildkiteCI
Diffstat (limited to 'tvix/eval/src/observer.rs')
-rw-r--r--tvix/eval/src/observer.rs24
1 files changed, 18 insertions, 6 deletions
diff --git a/tvix/eval/src/observer.rs b/tvix/eval/src/observer.rs
index 8572c2c1eb42..74ed316a6ac9 100644
--- a/tvix/eval/src/observer.rs
+++ b/tvix/eval/src/observer.rs
@@ -42,7 +42,7 @@ pub trait RuntimeObserver {
     fn observe_enter_frame(&mut self, _arg_count: usize, _: &Rc<Lambda>, _call_depth: usize) {}
 
     /// Called when the runtime exits a call frame.
-    fn observe_exit_frame(&mut self, _frame_at: usize) {}
+    fn observe_exit_frame(&mut self, _frame_at: usize, _stack: &[Value]) {}
 
     /// Called when the runtime replaces the current call frame for a
     /// tail call.
@@ -52,7 +52,7 @@ pub trait RuntimeObserver {
     fn observe_enter_builtin(&mut self, _name: &'static str) {}
 
     /// Called when the runtime exits a builtin.
-    fn observe_exit_builtin(&mut self, _name: &'static str) {}
+    fn observe_exit_builtin(&mut self, _name: &'static str, _stack: &[Value]) {}
 
     /// Called when the runtime *begins* executing an instruction. The
     /// provided stack is the state at the beginning of the operation.
@@ -146,16 +146,28 @@ impl<W: Write> RuntimeObserver for TracingObserver<W> {
         );
     }
 
-    fn observe_exit_frame(&mut self, frame_at: usize) {
-        let _ = writeln!(&mut self.writer, "=== exiting frame {} ===", frame_at);
+    fn observe_exit_frame(&mut self, frame_at: usize, stack: &[Value]) {
+        let _ = write!(&mut self.writer, "=== exiting frame {} ===\t[ ", frame_at);
+
+        for val in stack {
+            let _ = write!(&mut self.writer, "{} ", val);
+        }
+
+        let _ = writeln!(&mut self.writer, "]");
     }
 
     fn observe_enter_builtin(&mut self, name: &'static str) {
         let _ = writeln!(&mut self.writer, "=== entering builtin {} ===", name);
     }
 
-    fn observe_exit_builtin(&mut self, name: &'static str) {
-        let _ = writeln!(&mut self.writer, "=== exiting builtin {} ===", name);
+    fn observe_exit_builtin(&mut self, name: &'static str, stack: &[Value]) {
+        let _ = write!(&mut self.writer, "=== exiting builtin {} ===\t[ ", name);
+
+        for val in stack {
+            let _ = write!(&mut self.writer, "{} ", val);
+        }
+
+        let _ = writeln!(&mut self.writer, "]");
     }
 
     fn observe_tail_call(&mut self, frame_at: usize, lambda: &Rc<Lambda>) {