diff options
Diffstat (limited to 'targets/kernel_usdt.c')
| -rw-r--r-- | targets/kernel_usdt.c | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/targets/kernel_usdt.c b/targets/kernel_usdt.c new file mode 100644 index 0000000..d5b48b0 --- /dev/null +++ b/targets/kernel_usdt.c @@ -0,0 +1,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; +} |
