summaryrefslogtreecommitdiff
path: root/targets/kernel_usdt.c
blob: d5b48b061bc5dcf4356a9313c54767e254d11bed (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
// Static probes the DTrace way: <sys/sdt.h> leaves a nop and an ELF note
// where each one is. `start` and `done` are always there; `tick` (in
// kernel_usdt_tick.c) hides behind a semaphore until a tracer raises it.
#include <stdlib.h>
#include <sys/sdt.h>

long work(long n);

int main(int argc, char **argv) {
    long n = argc > 1 ? atol(argv[1]) : 5;
    DTRACE_PROBE1(ztrace, start, n);
    long sum = work(n);
    DTRACE_PROBE2(ztrace, done, n, sum);
    return 0;
}