Allow setting a dump hook

If users want to be notified when a heap dump occurs, they can set this hook.
This commit is contained in:
Alex Lapenkou
2021-09-01 13:00:01 -07:00
committed by Alexander Lapenkov
parent f7d46b8119
commit a9031a0970
6 changed files with 178 additions and 11 deletions

View File

@@ -48,14 +48,12 @@ extern size_t lg_prof_sample;
extern bool prof_booted;
/*
* A hook to mock out backtrace functionality. This can be handy, since it's
* otherwise difficult to guarantee that two allocations are reported as coming
* from the exact same stack trace in the presence of an optimizing compiler.
*/
void prof_backtrace_hook_set(prof_backtrace_hook_t hook);
prof_backtrace_hook_t prof_backtrace_hook_get();
void prof_dump_hook_set(prof_dump_hook_t hook);
prof_dump_hook_t prof_dump_hook_get();
/* Functions only accessed in prof_inlines.h */
prof_tdata_t *prof_tdata_init(tsd_t *tsd);
prof_tdata_t *prof_tdata_reinit(tsd_t *tsd, prof_tdata_t *tdata);

View File

@@ -13,4 +13,9 @@
*/
typedef void (*prof_backtrace_hook_t)(void **, unsigned *, unsigned);
/*
* A callback hook that notifies about recently dumped heap profile.
*/
typedef void (*prof_dump_hook_t)(const char *filename);
#endif /* JEMALLOC_INTERNAL_PROF_HOOK_H */