summaryrefslogtreecommitdiff
path: root/src/trace/event.zig
diff options
context:
space:
mode:
Diffstat (limited to 'src/trace/event.zig')
-rw-r--r--src/trace/event.zig8
1 files changed, 8 insertions, 0 deletions
diff --git a/src/trace/event.zig b/src/trace/event.zig
index 9ce8e94..7830979 100644
--- a/src/trace/event.zig
+++ b/src/trace/event.zig
@@ -168,6 +168,14 @@ pub fn stringId(text: []const u8) u64 {
return std.hash.Wyhash.hash(0, text) | 1 << 63;
}
+/// 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
+/// `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 {
+ return addr | 1 << 62;
+}
+
pub fn now() u64 {
var ts: std.os.linux.timespec = undefined;
_ = std.os.linux.clock_gettime(.MONOTONIC, &ts);