//! 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, regs: ?*const zt.Regs, touches: [*]Touch, count: ?*usize, branch: ?*zt.Debugger.Branch) usize; /// What `Debugger.disasm` is set to. pub fn one(code: []const u8, addr: u64, text: []u8, regs: ?*const zt.Regs, touches: []Touch) ?zt.Debugger.Insn { var count = touches.len; var branch: zt.Debugger.Branch = .{}; const len = zt_disasm(code.ptr, code.len, addr, text.ptr, text.len, regs, touches.ptr, &count, &branch); if (len == 0) return null; return .{ .len = @intCast(len), .text = std.mem.sliceTo(text, 0), .touches = touches[0..count], .branch = branch }; }