ERR/E3.0 (slice 3b): comptime trace resolution
#run failures now print the same `func at file:line:col` trace as runtime, resolved in-process via the interpreter's IR/source tables. - Read-side context-split op `.trace_resolve` (mirror of .trace_frame), lowered from a name-recognized `__trace_resolve_frame(u64) -> Frame`. - emit_llvm: inttoptr the operand to *Frame + load (the value .trace_frame stamped in). - interp: unpack (func_id << 32 | span.start); resolve func/file from module.functions and line/col via SourceLoc.compute over a new source_map (setSourceMap wired at every production interp site). - trace.sx: frame_at -> u64; to_string routes each frame through __trace_resolve_frame, so one source works in both machines. Compiled path behavior unchanged (243/244/247 identical; it now loads via the op). New examples/253-comptime-trace.sx exercises the comptime path. Gates: zig build, zig build test, run_examples.sh -> 291 passed.
This commit is contained in:
@@ -31,10 +31,12 @@ Frame :: struct {
|
||||
|
||||
// The error-trace buffer C API (library/vendors/sx_trace_runtime/sx_trace.c),
|
||||
// linked in for the JIT and auto-injected for AOT when traces are used.
|
||||
// `frame_at` hands back the stamped `*Frame` (the compiler stored its address).
|
||||
// `frame_at` returns the raw stored `u64`; `__trace_resolve_frame` turns it
|
||||
// into a `Frame` — by reinterpreting the stamped `*Frame` in compiled code, or
|
||||
// by resolving the packed `(func_id, span.start)` in the comptime interpreter.
|
||||
sx_trace_len :: () -> u32 #foreign;
|
||||
sx_trace_truncated :: () -> u32 #foreign;
|
||||
sx_trace_frame_at :: (i: u32) -> *Frame #foreign;
|
||||
sx_trace_frame_at :: (i: u32) -> u64 #foreign;
|
||||
|
||||
write :: (fd: s32, buf: [*]u8, count: usize) -> isize #foreign libc;
|
||||
|
||||
@@ -51,7 +53,7 @@ to_string :: () -> string {
|
||||
|
||||
i : u32 = 0;
|
||||
while i < n {
|
||||
f := sx_trace_frame_at(i);
|
||||
f := __trace_resolve_frame(sx_trace_frame_at(i));
|
||||
line := format(" {} at {}:{}:{}\n", f.func, f.file, f.line, f.col);
|
||||
result = concat(result, line);
|
||||
i = i + 1;
|
||||
|
||||
Reference in New Issue
Block a user