summaryrefslogtreecommitdiff
path: root/src/trace/event.zig
diff options
context:
space:
mode:
authorGabriel Schneider <[email protected]>2026-11-10 14:39:55 -0300
committerGabriel Schneider <[email protected]>2026-11-10 14:48:26 -0300
commited46c51fe127377eb1fde8dee83da984e0f61860 (patch)
treeaddbb6b270a22fdca2ac35c8f4094539b83cf21f /src/trace/event.zig
parent97ce7f485fc0419df693fdf16d634e9e9a6085fc (diff)
downloadcomputeranim-ed46c51fe127377eb1fde8dee83da984e0f61860.tar.gz
computeranim-ed46c51fe127377eb1fde8dee83da984e0f61860.zip
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.
Diffstat (limited to 'src/trace/event.zig')
-rw-r--r--src/trace/event.zig8
1 files changed, 7 insertions, 1 deletions
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 {