From ed46c51fe127377eb1fde8dee83da984e0f61860 Mon Sep 17 00:00:00 2001 From: Gabriel Schneider Date: Tue, 10 Nov 2026 14:39:55 -0300 Subject: context: eight instructions above the pc and eight below; where a branch goes A function is decoded once from its start, so the instructions before the pc are known: each instruction's string now says the length of the one before it, and ztrace show prints eight above and eight below, as pwndbg does. A call, a jump or a return at the pc is a branch event with its target (named) and, for a conditional jump, whether the flags take it. --- src/trace/event.zig | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) (limited to 'src/trace/event.zig') diff --git a/src/trace/event.zig b/src/trace/event.zig index 6f7a258..dcd4aa9 100644 --- a/src/trace/event.zig +++ b/src/trace/event.zig @@ -43,6 +43,11 @@ pub const Kind = enum(u16) { /// debugger, which sees the instruction before it runs; what is there is /// recorded beside it, and what a write left there after the step. touch = 22, + /// The instruction at the pc is a call, a jump or a return: a0=where it + /// goes a1=1 when it will go there (0: a conditional jump that falls + /// through) a2=pc. aux: 1 call, 2 jump, 3 return. From a debugger, + /// before the instruction runs; the target is named like any code address. + branch = 23, // Instrumentation (compiler passes, hooks). /// a0=callee (the string id of its name, or its address when the @@ -174,7 +179,8 @@ pub fn stringId(text: []const u8) u64 { } /// The id of the string that describes the instruction at `addr`: a byte -/// for its length, then its text ("mov rbp, rsp"). The string whose id is +/// for its length, a byte for the length of the instruction before it (0 +/// when that is not known), then its text ("mov rbp, rsp"). The string whose id is /// `addr` itself is the address's name ("main+4"). Addresses stay below /// bit 47 and hashed ids have bit 63: bit 62 keeps the two apart. pub fn codeId(addr: u64) u64 { -- cgit v1.3