diff --git a/docs/debugger.md b/docs/debugger.md index fd3b56b..08e5540 100644 --- a/docs/debugger.md +++ b/docs/debugger.md @@ -109,8 +109,9 @@ each backend derives the frame from its own context: current function → `{file, line, col, func}` (reusing the source map wired in for DWARF), **interns and builds the `Frame` global** in [`src/backend/llvm/reflection.zig`](../src/backend/llvm/reflection.zig) - (the same mechanism, in the same file, as the tag-name table), then emits - `call sx_trace_push(ptr)`. + (the same mechanism, in the same file, as the tag-name table), and yields + its address as the op's value. The lowerer feeds that value to a separate + `sx_trace_push` call emitted through the normal call lowering. - **`interp`:** pushes the packed `(func_id, ir_offset)` from its own execution context. @@ -276,13 +277,15 @@ traces and DWARF can never disagree: 1. `lower.zig` reaches a failure site — `lowerRaise`, `lowerTry`'s propagation branch, `lowerFailableOr`, or `lowerDestructureDecl` — and - (when `tracesEnabled()`) emits the niladic `.trace_frame_push` op, - replacing today's `emitTracePush(placeholderTraceFrame())`. Absorbing - sites emit `emitTraceClear()` → `call sx_trace_clear()`. -2. **Compiled backend** (`emit_llvm.emitInst`, `.trace_frame_push` arm): + (when `tracesEnabled()`) emits the niladic `.trace_frame` op via + `placeholderTraceFrame()`, whose result feeds a separate `sx_trace_push` + call via `emitTracePush()`. Absorbing sites emit `emitTraceClear()` → + `call sx_trace_clear()`. +2. **Compiled backend** (`emit_llvm.emitInst`, `.trace_frame` arm): resolve the op's `span` + current function → `{file,line,col,func}`, intern into the `Frame` table (built alongside `tag_name_array`), and - emit `call sx_trace_push(ptr_to_Frame)`. The `sx_trace_push` extern is + yield the `Frame` global's address as the op's value, which the separate + `sx_trace_push` call (step 1) consumes. The `sx_trace_push` extern is declared lazily by `getTraceFids()` (which sets `needs_trace_runtime`). 3. **Interpreter** (`interp.zig`, same op): pack `(current_func_id, ir_offset)` into a `u64` and call the foreign `sx_trace_push` (resolved