Skip to content

Instantly share code, notes, and snippets.

@siddontang
Last active February 19, 2019 07:22
Show Gist options
  • Save siddontang/7f5d85497b5f7493dcbf2898667db9ce to your computer and use it in GitHub Desktop.
Save siddontang/7f5d85497b5f7493dcbf2898667db9ce to your computer and use it in GitHub Desktop.
probe begin {
warn("Begin to trace jemalloc.\n")
}
probe process.function("malloc").return,
process.function("mallocx").return{
if (pid() != target()) next
printf("malloc: %p, bytes: %d\n", $return, @entry($size))
print_ubacktrace()
}
probe process.function("calloc").return {
if (pid() != target()) next
printf("malloc: %p, bytes: %d\n", $return, @entry($size) * @entry($num))
print_ubacktrace()
}
probe process.function("realloc").return,
process.function("rallocx").return {
if (pid() != target()) next
printf("free: %p\n", @entry($ptr))
printf("malloc: %p, bytes: %d\n", $return, @entry($size))
print_ubacktrace()
}
probe process.function("free"),
process.function("sdallocx") {
if (pid() != target()) next
if ($ptr == 0) next
printf("free: %p\n", $ptr)
}
probe timer.s(10) {
exit()
}
/*
probe process.function("xallocx").return{
if (pid() != target()) next
// TODO: do we need to print free $ptr here?
printf("malloc: %p, bytes: %d\n", $return, @entry($size) + @entry($extra))
print_ubacktrace()
}
probe process.function("dallocx") {
if (pid() != target()) next
if ($ptr == 0) next
printf("free: %p\n", $ptr)
}
*/
@siddontang
Copy link
Author

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment