From 05160b340bc0677a9ab29c2379b09475f54bb4eb Mon Sep 17 00:00:00 2001 From: Gabriel Schneider Date: Wed, 11 Nov 2026 11:51:02 -0300 Subject: trace: an instruction's bytes are in the recording; show prints a mapping's permissions For an introduction that shows bytes becoming an instruction, and the address space as segments. Co-Authored-By: Claude Fable 5.2 Claude-Session: https://claude.ai/code/session_016Y9MNCKgYCGiANnEwcEQxa --- src/cli/show.zig | 4 +++- src/trace/Debugger.zig | 2 ++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/src/cli/show.zig b/src/cli/show.zig index ef05e7a..032538f 100644 --- a/src/cli/show.zig +++ b/src/cli/show.zig @@ -183,7 +183,9 @@ pub fn state(arena: std.mem.Allocator, trace: *zt.Trace, index: u64, w: *std.Io. var path: []const u8 = ""; var path_buf: [std.Io.Dir.max_path_bytes]u8 = undefined; _ = try m.mapping(region.addr, &path, &path_buf); - try w.print(" {x:0>12}-{x:0>12} {s}", .{ region.addr, region.addr + region.len, path }); + // As /proc/pid/maps has it: what may be done there, and where in the file it is from. + const p = region.prot; + try w.print(" {x:0>12}-{x:0>12} {c}{c}{c} {x:0>8} {s}", .{ region.addr, region.addr + region.len, @as(u8, if (p & 1 != 0) 'r' else '-'), @as(u8, if (p & 2 != 0) 'w' else '-'), @as(u8, if (p & 4 != 0) 'x' else '-'), region.offset, path }); // A module, once: which build it is, and whether its names come from its own debug info. if (!std.mem.eql(u8, path, last)) if (zt.telescope.module(m, path)) |module| { if (module.build_id.len > 0) try w.print(" build-id {x},", .{module.build_id}) else try w.writeAll(" no build id,"); diff --git a/src/trace/Debugger.zig b/src/trace/Debugger.zig index 2cef5ca..4ca7eca 100644 --- a/src/trace/Debugger.zig +++ b/src/trace/Debugger.zig @@ -627,6 +627,8 @@ fn emitInstruction(d: *Debugger, insnAt: @typeInfo(@TypeOf(d.disasm)).optional.c len += 2 + @sizeOf(Line); } try d.emit(.{ .kind = .string, .a = .{ event.codeId(addr), 0, 0, 0, 0, 0 } }, text[0..len]); + // Its bytes too, as memory: a viewer can show what the text was decoded from. + try d.snapshot(addr, insn.len); try d.code_len.put(d.gpa, addr, insn.len); return insn.len; } -- cgit v1.3