summaryrefslogtreecommitdiff
path: root/build/debugger.zig
diff options
context:
space:
mode:
authorGabriel Schneider <[email protected]>2026-11-10 22:51:17 -0300
committerGabriel Schneider <[email protected]>2026-11-10 23:04:17 -0300
commitb4ab1d770edb06d3eeebfd290bbf97725e55b7fa (patch)
tree75c0b876f4dde764e50e21c4faf9963887f63b44 /build/debugger.zig
parentfa5d150ac6977264f0704e9af664f8150bd25127 (diff)
downloadcomputeranim-b4ab1d770edb06d3eeebfd290bbf97725e55b7fa.tar.gz
computeranim-b4ab1d770edb06d3eeebfd290bbf97725e55b7fa.zip
trace: the call chain by the unwind tables; what each word of the stack is
backtrace and frames follow .debug_frame or .eh_frame where there is one (PLT entries expanded into exact rows) and the frame pointer where there is none: the caller is no longer lost in a prologue, in a function that keeps no frame, in a PLT entry or inside libc's syscall wrappers. Against gdb: the same chains on fib and on SQLite, where the old walk lost __sbrk and unixSync. A recording holds, once a function, its unwind rows and its locals on the stack (DW_OP_fbreg, with the block each lives in), and the process's first stack pointer. telescope.slots says of each word what it is: a saved register and which, a return address, a local by name, argc, argv, envp, auxv. Four bytes a moment on the list by instruction, and no slower. Co-Authored-By: Claude Fable 5.2 <[email protected]> Claude-Session: https://claude.ai/code/session_016Y9MNCKgYCGiANnEwcEQxa
Diffstat (limited to 'build/debugger.zig')
-rw-r--r--build/debugger.zig6
1 files changed, 5 insertions, 1 deletions
diff --git a/build/debugger.zig b/build/debugger.zig
index 6fa6f8c..cb67354 100644
--- a/build/debugger.zig
+++ b/build/debugger.zig
@@ -17,6 +17,10 @@ pub fn add(ctx: Ctx) void {
const musl_mod = b.createModule(.{ .target = musl, .optimize = .Debug, .link_libc = true, .omit_frame_pointer = false });
musl_mod.addCSourceFiles(.{ .root = b.path("targets"), .files = &.{"libc.c"}, .flags = &.{ "-O1", "-g", "-fno-omit-frame-pointer" } });
const libc_musl = b.addExecutable(.{ .name = "libc-musl", .root_module = musl_mod });
+ // The list at -O0, where every local has its place on the stack.
+ const o0_mod = b.createModule(.{ .target = ctx.target, .optimize = .Debug, .link_libc = true, .omit_frame_pointer = false });
+ o0_mod.addCSourceFiles(.{ .root = b.path("targets"), .files = &.{"list.c"}, .flags = &.{ "-O0", "-g" } });
+ const list_o0 = b.addExecutable(.{ .name = "list-O0", .root_module = o0_mod });
// Zig, no libc: always a debug build, so its lines are the source's.
const graph = b.addExecutable(.{ .name = "graph", .root_module = b.createModule(.{
.root_source_file = b.path("targets/graph.zig"),
@@ -24,7 +28,7 @@ pub fn add(ctx: Ctx) void {
.optimize = .Debug,
}) });
- const targets = [_]*std.Build.Step.Compile{ fib, list, threads, libc_glibc, libc_musl, graph };
+ const targets = [_]*std.Build.Step.Compile{ fib, list, list_o0, threads, libc_glibc, libc_musl, graph };
for (targets) |t| b.getInstallStep().dependOn(&b.addInstallArtifact(t, .{ .dest_dir = .{ .override = .{ .custom = "targets" } } }).step);
// The compiler's own checks (UBSan, on by default in a debug build) are