summaryrefslogtreecommitdiff
path: root/src/trace/usdt.zig
diff options
context:
space:
mode:
authorGabriel Schneider <[email protected]>2026-11-10 11:49:22 -0300
committerGabriel Schneider <[email protected]>2026-11-10 12:19:06 -0300
commit297943b01e18bb3d1dd41a8d3e220811de25228b (patch)
tree4938e643abada811d3ab28b14c0e31dc94ebda62 /src/trace/usdt.zig
parentdb923fa823354270217362db06356f2b1a41315e (diff)
downloadcomputeranim-297943b01e18bb3d1dd41a8d3e220811de25228b.tar.gz
computeranim-297943b01e18bb3d1dd41a8d3e220811de25228b.zip
ztrace probe: BPF on syscalls, scheduling, kprobes, uprobes and USDT
Programs built as instruction arrays for one process (no compiler, no libbpf), writing Events into a BPF ring buffer; a drop counter in a map; task_struct offsets from the kernel's BTF; a USDT probe's arguments read in the kernel at the probe. Without CAP_BPF and CAP_PERFMON it says so; --dry-run builds and lists everything. Tested offline by running the programs in a small BPF machine, and for real by test-kernel-vm, which boots this kernel in QEMU where we are root. ztrace perf: moments are no longer cut per event unless --cut; --max-size, and a full recording stops the target and says so. perf.Sorted merges two backends' events by time. Co-Authored-By: Claude Fable 5.2 <[email protected]>
Diffstat (limited to 'src/trace/usdt.zig')
-rw-r--r--src/trace/usdt.zig3
1 files changed, 2 insertions, 1 deletions
diff --git a/src/trace/usdt.zig b/src/trace/usdt.zig
index ba03079..d5f1d04 100644
--- a/src/trace/usdt.zig
+++ b/src/trace/usdt.zig
@@ -194,6 +194,7 @@ pub const Arg = struct {
.index = if (parts.next()) |r| try register(r) else null,
.scale = if (parts.next()) |s| std.fmt.parseInt(u8, s, 10) catch return error.BadUsdtArg else 1,
} };
+ if (std.mem.indexOfScalar(u8, &.{ 1, 2, 4, 8 }, arg.at.memory.scale) == null) return error.BadUsdtArg;
}
return arg;
}
@@ -278,7 +279,7 @@ test "argument specs are parsed and fetched" {
.{ "8@0x7000(%rbp)", null },
};
for (cases) |case| try std.testing.expectEqual(case[1], (try Arg.parse(case[0])).fetch(&regs, memory));
- for ([_][]const u8{ "4@counter(%rip)", "3@%eax", "4@%ah", "4", "4@", "4@8(%rdx", "4@%r8x" }) |bad| {
+ for ([_][]const u8{ "4@counter(%rip)", "3@%eax", "4@%ah", "4", "4@", "4@8(%rdx", "4@%r8x", "4@(%rdx,%rax,3)" }) |bad| {
try std.testing.expectError(error.BadUsdtArg, Arg.parse(bad));
}
}