Created
September 5, 2022 18:53
-
-
Save LukasWoodtli/1600d23e9d8a97a4660e650623fec924 to your computer and use it in GitHub Desktop.
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
// run it like this: | |
// stap -v -x <PID> system_tap_example.stp | |
global count; | |
probe begin { | |
count = 0; | |
printf("Staring system tap session for pid=%i\n", target()); | |
} | |
probe end { | |
if (pid() == target()) { | |
printf("End of system tap session!\n"); | |
} | |
} | |
//probe process("mylibrary.so").function("do_something::*") { | |
// if (pid() == target()) { | |
// printf("%x: my function %s() called...\n", tid(), ppfunc()); | |
// } | |
//} | |
probe process("/usr/lib64/libc.so*").function("malloc") { | |
if (pid() == target()) { | |
if ($size > 20000) { | |
printf("%s: malloc(%d)\n", ctime(gettimeofday_s()), $size); | |
print_ubacktrace(); | |
printf("\n\n"); | |
} | |
} | |
} | |
probe process("mylibrary.so").function("do_something") { | |
if (pid() == target()) { | |
++count; | |
} | |
} | |
probe process("mylibrary.so").function("dtor").return { | |
if (pid() == target()) { | |
printf("Number of counted calls: %d\n", count); | |
count = 0; | |
exit(); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment