Skip to content

Instantly share code, notes, and snippets.

@KJTsanaktsidis
Created September 23, 2021 07:34
Show Gist options
  • Save KJTsanaktsidis/cbc3229f67bbeda5046b885dc3b82519 to your computer and use it in GitHub Desktop.
Save KJTsanaktsidis/cbc3229f67bbeda5046b885dc3b82519 to your computer and use it in GitHub Desktop.
rd.h
// include macros from SystemTap project
#include <sys/sdt.h>
// ... lots of librdkafka code ...
static RD_INLINE RD_UNUSED void *rd_malloc(size_t sz) {
void *p = malloc(sz);
rd_assert(p);
// Add a call to DTRACE_PROBE here to call our probe with the address
// of the allocated memory
DTRACE_PROBE1(librdkafka, rd_malloc, p);
return p;
}
static RD_INLINE RD_UNUSED void rd_free(void *ptr) {
// Call our probe here with the address of the memory being freed
DTRACE_PROBE1(librdkafka, rd_free, ptr);
free(ptr);
}
// ... lots more librdkafka code ...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment