2021-12-04 02:20:26 +01:00
|
|
|
import ./make-test-python.nix ({ pkgs, ... }: {
|
|
|
|
name = "bpf";
|
|
|
|
meta.maintainers = with pkgs.lib.maintainers; [ martinetd ];
|
|
|
|
|
|
|
|
machine = { pkgs, ... }: {
|
|
|
|
programs.bcc.enable = true;
|
|
|
|
environment.systemPackages = with pkgs; [ bpftrace ];
|
|
|
|
};
|
|
|
|
|
|
|
|
testScript = ''
|
|
|
|
## bcc
|
|
|
|
# syscount -d 1 stops 1s after probe started so is good for that
|
|
|
|
print(machine.succeed("syscount -d 1"))
|
|
|
|
|
|
|
|
## bpftrace
|
|
|
|
# list probes
|
|
|
|
machine.succeed("bpftrace -l")
|
|
|
|
# simple BEGIN probe (user probe on bpftrace itself)
|
|
|
|
print(machine.succeed("bpftrace -e 'BEGIN { print(\"ok\"); exit(); }'"))
|
|
|
|
# tracepoint
|
2022-02-11 08:55:34 +01:00
|
|
|
print(machine.succeed("bpftrace -e 'tracepoint:syscalls:sys_enter_* { print(probe); exit() }'"))
|
2021-12-04 02:20:26 +01:00
|
|
|
# kprobe
|
|
|
|
print(machine.succeed("bpftrace -e 'kprobe:schedule { print(probe); exit() }'"))
|
2022-02-11 08:55:34 +01:00
|
|
|
# BTF
|
|
|
|
print(machine.succeed("bpftrace -e 'kprobe:schedule { "
|
|
|
|
" printf(\"tgid: %d\", ((struct task_struct*) curtask)->tgid); exit() "
|
|
|
|
"}'"))
|
2021-12-04 02:20:26 +01:00
|
|
|
'';
|
|
|
|
})
|