From 8ac0639bfc0186acedb11759432a2cfa277193f2 Mon Sep 17 00:00:00 2001 From: Gabriel Schneider Date: Tue, 10 Nov 2026 12:28:33 -0300 Subject: static probes from the debugger: -b usdt:PROVIDER:NAME, no root Debugger.usdt arms the USDT probes of every mapped module as breakpoints whose hook records a probe event with its arguments and lets the program run on, raising a probe's semaphore first; record and dbg take usdt:PROVIDER:NAME (* for any), running the loader through when the probe is a library's. glibc's own 78 probes are there for the asking: memory_sbrk_more shows malloc growing the heap. --- build/kernel.zig | 15 +++++++++++++++ 1 file changed, 15 insertions(+) (limited to 'build') diff --git a/build/kernel.zig b/build/kernel.zig index aae593a..3a0c65c 100644 --- a/build/kernel.zig +++ b/build/kernel.zig @@ -30,6 +30,21 @@ pub fn add(ctx: Ctx) void { // ... and the library's own tests of this area: what needs no target. step.dependOn(&b.addRunArtifact(b.addTest(.{ .root_module = ctx.ztrace, .filters = &.{ "perf.test", "usdt.test", "bpf.test" } })).step); + // The static probes without root: the debugger stops at each for as + // long as it takes to record it. start, four ticks, done. + const probed = b.addRunArtifact(ctx.exe); + probed.addArgs(&.{ "record", "--by", "break", "-b", "usdt:ztrace:*", "-o" }); + const probes = probed.addOutputFileArg("usdt.ztrace"); + probed.addArg("--"); + probed.addArtifactArg(targets[2]); + probed.addArg("4"); + probed.expectStdErrMatch("exit 0"); + const shown = b.addRunArtifact(ctx.exe); + shown.addArg("show"); + shown.addFileArg(probes); + shown.expectStdOutMatch("6 probe"); + step.dependOn(&shown.step); + // The BPF side for real: this machine's kernel booted in QEMU, where we // are root. Not part of `test`: it wants qemu, /dev/kvm, cpio and a // kernel image a user can read. -- cgit v1.3