Skip to content

Instantly share code, notes, and snippets.

@NicolasT
Last active August 29, 2015 14:14
Show Gist options
  • Save NicolasT/78c9e870945bcb251ab5 to your computer and use it in GitHub Desktop.
Save NicolasT/78c9e870945bcb251ab5 to your computer and use it in GitHub Desktop.
Demo of custom userspace probe points
#include <stdio.h>
#include <string.h>
#include "sofs_probes.h"
static void chord_put(int policy, const char *msg) {
SOFS_PROBES_CHORD_PUT(policy, strlen(msg));
printf("%s\n", msg);
}
int main(int argc, char **argv) {
chord_put(1, "Hello, world!");
return 0;
}
DTRACE := dtrace
default: demo
sofs_probes.h: sofs_probes.d
$(DTRACE) -h -o $@ -s $<
sofs_probes.o: sofs_probes.d
$(DTRACE) -G -o $@ -s $<
demo: demo.o sofs_probes.o
$(CC) -o $@ $^
demo.o: demo.c sofs_probes.h
$(CC) -c -o $@ demo.c
test: demo
stap -I. -e 'probe sofs_* { printf("%s\n", probestr); }' -c ./demo
probe sofs_chord_put = process.mark("chord_put") {
policy = $arg1;
length = $arg2;
probestr = sprintf("%s(policy=%d, length=%d)", $$name, policy, length);
}
provider sofs_probes {
probe chord_put(int policy, int size);
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment