From e2fa716dcda7de877908de006adc34f0c3593693 Mon Sep 17 00:00:00 2001 From: Gabriel Schneider Date: Tue, 10 Nov 2026 14:12:08 -0300 Subject: ztrace dbg: context, everything at the moment looked at, pwndbg's way --- src/cli/dbg.zig | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'src/cli/dbg.zig') 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; -- cgit v1.3