Allow setting custom backtrace hook
Existing backtrace implementations skip native stack frames from runtimes like Python. The hook allows to augment the backtraces to attribute allocations to native functions in heap profiles.
This commit is contained in:
committed by
Alexander Lapenkov
parent
523cfa55c5
commit
f7d46b8119
@@ -2,6 +2,7 @@
|
||||
#define JEMALLOC_INTERNAL_PROF_EXTERNS_H
|
||||
|
||||
#include "jemalloc/internal/mutex.h"
|
||||
#include "jemalloc/internal/prof_hook.h"
|
||||
|
||||
extern bool opt_prof;
|
||||
extern bool opt_prof_active;
|
||||
@@ -52,7 +53,8 @@ extern bool prof_booted;
|
||||
* otherwise difficult to guarantee that two allocations are reported as coming
|
||||
* from the exact same stack trace in the presence of an optimizing compiler.
|
||||
*/
|
||||
extern void (* JET_MUTABLE prof_backtrace_hook)(prof_bt_t *bt);
|
||||
void prof_backtrace_hook_set(prof_backtrace_hook_t hook);
|
||||
prof_backtrace_hook_t prof_backtrace_hook_get();
|
||||
|
||||
/* Functions only accessed in prof_inlines.h */
|
||||
prof_tdata_t *prof_tdata_init(tsd_t *tsd);
|
||||
|
16
include/jemalloc/internal/prof_hook.h
Normal file
16
include/jemalloc/internal/prof_hook.h
Normal file
@@ -0,0 +1,16 @@
|
||||
#ifndef JEMALLOC_INTERNAL_PROF_HOOK_H
|
||||
#define JEMALLOC_INTERNAL_PROF_HOOK_H
|
||||
|
||||
/*
|
||||
* The hooks types of which are declared in this file are experimental and
|
||||
* undocumented, thus the typedefs are located in an 'internal' header.
|
||||
*/
|
||||
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
typedef void (*prof_backtrace_hook_t)(void **, unsigned *, unsigned);
|
||||
|
||||
#endif /* JEMALLOC_INTERNAL_PROF_HOOK_H */
|
@@ -16,7 +16,8 @@ struct prof_bt_s {
|
||||
#ifdef JEMALLOC_PROF_LIBGCC
|
||||
/* Data structure passed to libgcc _Unwind_Backtrace() callback functions. */
|
||||
typedef struct {
|
||||
prof_bt_t *bt;
|
||||
void **vec;
|
||||
unsigned *len;
|
||||
unsigned max;
|
||||
} prof_unwind_data_t;
|
||||
#endif
|
||||
|
@@ -6,6 +6,7 @@ extern base_t *prof_base;
|
||||
|
||||
void bt_init(prof_bt_t *bt, void **vec);
|
||||
void prof_backtrace(tsd_t *tsd, prof_bt_t *bt);
|
||||
void prof_hooks_init();
|
||||
void prof_unwind_init();
|
||||
void prof_sys_thread_name_fetch(tsd_t *tsd);
|
||||
int prof_getpid(void);
|
||||
|
Reference in New Issue
Block a user