From 66a2a7cf733f6abc1f79561c52d901ce67019fb1 Mon Sep 17 00:00:00 2001 From: Gabriel Schneider Date: Tue, 10 Nov 2026 16:03:43 -0300 Subject: trace: what the context draws is in the recording; SQLite on the ladder An instruction's string carries its source line and, for a direct call, how many parameters the callee takes (DWARF); telescope.frames gives each frame's extent on the stack; with --alloc the debugger watches each live allocation and the allocator's header before it, changes only, 256 KiB a stop at most. C++ names are shown and found as the source has them (the command links the C++ runtime for its demangler). SQLite 3.50.4 through every backend, measured (README, bench/sqlite.sh). It found two faults: a file compiled by its full path was recorded under a path joined onto the compile directory, and ztrace run noticed a target's exit up to 10 ms late. Co-Authored-By: Claude Fable 5.2 --- src/cli/disasm.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) (limited to 'src/cli/disasm.c') diff --git a/src/cli/disasm.c b/src/cli/disasm.c index 82fd0bb..9b15e0c 100644 --- a/src/cli/disasm.c +++ b/src/cli/disasm.c @@ -76,7 +76,8 @@ static int slot(x86_reg reg) { // The instruction at `code`, which is at `addr`: its text into `text`, its // length returned; 0 where there is no instruction. With `regs` (the // thread's, about to run it), the memory it touches into `touches`, at -// most `*count` of them, and how many into `*count`. +// most `*count` of them, and how many into `*count`. A branch is told +// without them too, its target where the instruction alone says it. size_t zt_disasm(const uint8_t *code, size_t len, uint64_t addr, char *text, size_t cap, const uint64_t *regs, struct zt_touch *touches, size_t *count, struct zt_branch *branch) { if (!handle) { if (cs_open(CS_ARCH_X86, CS_MODE_64, &handle) != CS_ERR_OK) return 0; @@ -89,17 +90,17 @@ size_t zt_disasm(const uint8_t *code, size_t len, uint64_t addr, char *text, siz if (cs_disasm(handle, code, len, addr, 1, &insn) != 1) return 0; size_t size = insn->size; snprintf(text, cap, insn->op_str[0] ? "%s %s" : "%s", insn->mnemonic, insn->op_str); - if (regs && branch && insn->detail) { + if (branch && insn->detail) { const cs_x86 *x = &insn->detail->x86; branch->kind = cs_insn_group(handle, insn, CS_GRP_RET) ? 3 : cs_insn_group(handle, insn, CS_GRP_CALL) ? 1 : cs_insn_group(handle, insn, CS_GRP_JUMP) ? 2 : 0; - branch->taken = holds(insn->id, regs[18], regs[11]); + branch->taken = regs ? holds(insn->id, regs[18], regs[11]) : 1; branch->indirect = 0; branch->target = 0; if (branch->kind == 1 || branch->kind == 2) { const cs_x86_op *op = &x->operands[0]; if (x->op_count < 1) branch->kind = 0; else if (op->type == X86_OP_IMM) branch->target = (uint64_t)op->imm; - else if (op->type == X86_OP_REG && slot(op->reg) >= 0) branch->target = regs[slot(op->reg)]; + else if (op->type == X86_OP_REG && slot(op->reg) >= 0) branch->target = regs ? regs[slot(op->reg)] : 0; else if (op->type == X86_OP_MEM) { // Its address is the first touch below: the target is what is there. branch->indirect = 1; -- cgit v1.3