From 97ce7f485fc0419df693fdf16d634e9e9a6085fc Mon Sep 17 00:00:00 2001 From: Gabriel Schneider Date: Tue, 10 Nov 2026 14:35:56 -0300 Subject: 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. --- src/cli/disasm.zig | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) (limited to 'src/cli/disasm.zig') diff --git a/src/cli/disasm.zig b/src/cli/disasm.zig index 5c0d27b..40cab9d 100644 --- a/src/cli/disasm.zig +++ b/src/cli/disasm.zig @@ -1,12 +1,14 @@ //! Disassembly for the debugger: capstone, through src/cli/disasm.c. const std = @import("std"); const zt = @import("ztrace"); +const Touch = zt.Debugger.Touch; -extern fn zt_disasm(code: [*]const u8, len: usize, addr: u64, text: [*]u8, cap: usize) usize; +extern fn zt_disasm(code: [*]const u8, len: usize, addr: u64, text: [*]u8, cap: usize, regs: ?*const zt.Regs, touches: [*]Touch, count: ?*usize) usize; /// What `Debugger.disasm` is set to. -pub fn one(code: []const u8, addr: u64, text: []u8) ?zt.Debugger.Insn { - const len = zt_disasm(code.ptr, code.len, addr, text.ptr, text.len); +pub fn one(code: []const u8, addr: u64, text: []u8, regs: ?*const zt.Regs, touches: []Touch) ?zt.Debugger.Insn { + var count = touches.len; + const len = zt_disasm(code.ptr, code.len, addr, text.ptr, text.len, regs, touches.ptr, &count); if (len == 0) return null; - return .{ .len = @intCast(len), .text = std.mem.sliceTo(text, 0) }; + return .{ .len = @intCast(len), .text = std.mem.sliceTo(text, 0), .touches = touches[0..count] }; } -- cgit v1.3