Projects10 of 15
Officina AI
An execution tracer for Python, C and Java, with a tutor that explains the trace
What it does
Write a program, press Trace, and step through what it actually did: forwards and back, line by line, with every variable it changed, every condition and the values it compared, and every call and return.
The trace comes from running the program, never from a model.
Python
Python runs under sys.settrace in a Web Worker. Each if, while and ternary is rewritten so that its operands are recorded as the program computes them, exactly once.
C and Java
C and Java have no settrace, so the program reports on itself.
- It is parsed with tree-sitter, and tracing calls are inserted on the lines they belong to.
- The edits are insertions only, never a new line, so the compiler’s messages still point at the reader’s code.
- It is then compiled here in the browser: by clang built to WebAssembly, or by the Eclipse compiler on CheerpJ’s JVM.
What the C runtime shows
- Each variable’s address is registered as its declaration runs, and memory is read back after every statement. A function that changes its caller’s array through a pointer shows it at the step it happened.
- Pointers are named by what they point at; structs and enums are shown field by field.
- A variable not yet given a value shows as ?.
- An index past an array, a division by zero or a NULL pointer stops the trace on the line that did it, where C itself would carry on into undefined behaviour.
The Java runtime passes the locals the compiler agrees are assigned, and reads objects by reflection, never by calling toString().
One format, any step instantly
All three languages produce one step format, held in memory with a snapshot every 256 steps. Any step of a 50,000-step trace is shown in under a millisecond, and nothing is run twice.
A run stops at 50,000 steps, five seconds or 256 KB of output, and says so.
The tutor
A tutor, Qwen2.5 Coder 32B on Cloudflare Workers AI, explains a step, answers a question about it, or writes a program to trace.
- It is handed the recorded facts and told not to add to them.
- It is reached through the site’s own Worker, which holds its instructions and a per-visitor rate limit, not the page.
Tested
Every C and Java example is traced natively in CI and held to printing exactly what it prints untraced. The Python tracer is checked step for step against native CPython.
Built with
Pyodide, tree-sitter, clang in WebAssembly, the Eclipse compiler on CheerpJ, and Cloudflare Workers AI.