summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGabriel Schneider <[email protected]>2026-11-10 14:12:08 -0300
committerGabriel Schneider <[email protected]>2026-11-10 14:12:42 -0300
commite2fa716dcda7de877908de006adc34f0c3593693 (patch)
tree7baa2294bd73871ca3eefc9dec6eb93bc07433fc
parent02aa51a6f54235cf18e627dbbfe21f21e502eb0b (diff)
downloadcomputeranim-e2fa716dcda7de877908de006adc34f0c3593693.tar.gz
computeranim-e2fa716dcda7de877908de006adc34f0c3593693.zip
ztrace dbg: context, everything at the moment looked at, pwndbg's way
-rw-r--r--src/cli/dbg.zig9
-rw-r--r--src/cli/show.zig2
2 files changed, 10 insertions, 1 deletions
diff --git a/src/cli/dbg.zig b/src/cli/dbg.zig
index e59c40a..22923be 100644
--- a/src/cli/dbg.zig
+++ b/src/cli/dbg.zig
@@ -4,6 +4,7 @@ const std = @import("std");
const zt = @import("ztrace");
const util = @import("util.zig");
const disasm = @import("disasm.zig");
+const show_cmd = @import("show.zig");
const fail = util.fail;
const Moment = zt.store.Moment;
@@ -24,6 +25,8 @@ pub const usage =
\\ regs the registers
\\ x WHAT [LEN] memory at an address, a symbol or $register (64 bytes)
\\ bt the call chain, by frame pointer
+ \\ context, ctx everything at once, pwndbg's way: registers followed
+ \\ as pointers, the instructions at the pc, the stack
\\ back [N] look N moments back in the recording: regs, x
\\ forward [N] and bt then show the program as it was. The
\\ goto MOMENT program itself stays where it stopped last
@@ -231,6 +234,12 @@ const Session = struct {
try s.d.describe(s.w, pc);
try s.w.writeAll("\n");
}
+ } else if (is(cmd, "context", "ctx")) {
+ // The whole of the moment looked at, as `ztrace show` prints it.
+ const t = try s.recording();
+ var arena: std.heap.ArenaAllocator = .init(s.gpa);
+ defer arena.deinit();
+ try show_cmd.state(arena.allocator(), t, s.view orelse t.len - 1, s.w, std.Io.File.stdout().isTty(s.io) catch false);
} else if (is(cmd, "back", "forward") or is(cmd, "goto", "goto")) {
const t = try s.recording();
const n = if (arg) |a| try std.fmt.parseInt(u64, a, 10) else if (is(cmd, "goto", "goto")) return error.MissingArgument else 1;
diff --git a/src/cli/show.zig b/src/cli/show.zig
index 422fd9e..057b210 100644
--- a/src/cli/show.zig
+++ b/src/cli/show.zig
@@ -79,7 +79,7 @@ fn telescope(m: zt.store.Moment, w: *std.Io.Writer, value: u64, colour: bool) !v
}
}
-fn state(arena: std.mem.Allocator, trace: *zt.Trace, index: u64, w: *std.Io.Writer, colour: bool) !void {
+pub fn state(arena: std.mem.Allocator, trace: *zt.Trace, index: u64, w: *std.Io.Writer, colour: bool) !void {
const m = try trace.moment(index);
try w.print("moment {d} of {d}, {d} events so far\n", .{ index, trace.len, try m.count() });