Last active
August 29, 2015 14:14
-
-
Save NicolasT/78c9e870945bcb251ab5 to your computer and use it in GitHub Desktop.
Demo of custom userspace probe points
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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; | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
probe sofs_chord_put = process.mark("chord_put") { | |
policy = $arg1; | |
length = $arg2; | |
probestr = sprintf("%s(policy=%d, length=%d)", $$name, policy, length); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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