summaryrefslogtreecommitdiff
path: root/src/cli/show.zig
diff options
context:
space:
mode:
authorGabriel Schneider <[email protected]>2026-11-10 14:35:56 -0300
committerGabriel Schneider <[email protected]>2026-11-10 14:39:55 -0300
commit97ce7f485fc0419df693fdf16d634e9e9a6085fc (patch)
tree9d36463512024242665c7836b94a4de4e541b3bf /src/cli/show.zig
parentf8740f6996eefc235af066a6686f52847c158a6b (diff)
downloadcomputeranim-97ce7f485fc0419df693fdf16d634e9e9a6085fc.tar.gz
computeranim-97ce7f485fc0419df693fdf16d634e9e9a6085fc.zip
context: what an instruction is about to touch, and the call chain
At a stop the instruction at the pc is decoded against the registers it will run with (capstone's operands): a touch event for each memory operand (address, size, read or write), what is there recorded with it, and what a write left there read back at the next stop. An instruction-level recording so has every memory write of the stepped thread, nothing watched. The frames of the call chain are recorded and their return addresses named; telescope.backtrace walks them from the recording and ztrace show prints them. Process.read no longer panics on address 0.
Diffstat (limited to 'src/cli/show.zig')
-rw-r--r--src/cli/show.zig11
1 files changed, 11 insertions, 0 deletions
diff --git a/src/cli/show.zig b/src/cli/show.zig
index 057b210..35cc928 100644
--- a/src/cli/show.zig
+++ b/src/cli/show.zig
@@ -114,6 +114,17 @@ pub fn state(arena: std.mem.Allocator, trace: *zt.Trace, index: u64, w: *std.Io.
try w.writeAll("\n");
}
}
+ if (try m.regs(tid)) |regs| {
+ // The call chain, by frame pointer; the calls the program itself
+ // reported (instrumentation, hooks) follow it when there are any.
+ var frames: [32]u64 = undefined;
+ const chain = try zt.telescope.backtrace(m, &regs, &frames);
+ if (chain.len > 1) try w.writeAll("\n");
+ if (chain.len > 1) for (chain, 0..) |pc, depth| {
+ var text: [256]u8 = undefined;
+ try w.print(" #{d} {x} {s}\n", .{ depth, pc, (try m.string(pc, &text)) orelse "" });
+ };
+ }
for (try m.stack(arena, tid), 0..) |frame, depth| {
try w.print(" #{d} {s} from {x} sp {x}\n", .{ depth, try name(m, arena, frame.function), frame.site, frame.sp });
}