From 297943b01e18bb3d1dd41a8d3e220811de25228b Mon Sep 17 00:00:00 2001 From: Gabriel Schneider Date: Tue, 10 Nov 2026 11:49:22 -0300 Subject: 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 --- src/trace/usdt.zig | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'src/trace/usdt.zig') 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(®s, 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)); } } -- cgit v1.3