2 #ifdef JEMALLOC_H_TYPES
4 typedef struct prof_bt_s prof_bt_t;
5 typedef struct prof_cnt_s prof_cnt_t;
6 typedef struct prof_tctx_s prof_tctx_t;
7 typedef struct prof_gctx_s prof_gctx_t;
8 typedef struct prof_tdata_s prof_tdata_t;
12 # define PROF_PREFIX_DEFAULT "jeprof"
14 # define PROF_PREFIX_DEFAULT ""
16 #define LG_PROF_SAMPLE_DEFAULT 19
17 #define LG_PROF_INTERVAL_DEFAULT -1
24 #define PROF_BT_MAX 128
27 #define PROF_CKH_MINITEMS 64
30 #define PROF_DUMP_BUFSIZE 65536
33 #define PROF_PRINTF_BUFSIZE 128
39 #define PROF_NCTX_LOCKS 1024
45 #define PROF_NTDATA_LOCKS 256
51 #define PROF_TDATA_STATE_REINCARNATED ((prof_tdata_t *)(uintptr_t)1)
52 #define PROF_TDATA_STATE_PURGATORY ((prof_tdata_t *)(uintptr_t)2)
53 #define PROF_TDATA_STATE_MAX PROF_TDATA_STATE_PURGATORY
57 #ifdef JEMALLOC_H_STRUCTS
65 #ifdef JEMALLOC_PROF_LIBGCC
82 prof_tctx_state_initializing,
83 prof_tctx_state_nominal,
84 prof_tctx_state_dumping,
85 prof_tctx_state_purgatory
121 rb_node(prof_tctx_t) tctx_link;
130 prof_tctx_state_t
state;
136 prof_cnt_t dump_cnts;
138 typedef rb_tree(prof_tctx_t) prof_tctx_tree_t;
142 malloc_mutex_t *
lock;
160 prof_tctx_tree_t tctxs;
163 rb_node(prof_gctx_t) dump_link;
166 prof_cnt_t cnt_summed;
174 typedef rb_tree(prof_gctx_t) prof_gctx_tree_t;
176 struct prof_tdata_s {
177 malloc_mutex_t *
lock;
194 rb_node(prof_tdata_t) tdata_link;
235 prof_cnt_t cnt_summed;
238 void *vec[PROF_BT_MAX];
240 typedef rb_tree(prof_tdata_t) prof_tdata_tree_t;
244 #ifdef JEMALLOC_H_EXTERNS
287 void bt_init(prof_bt_t *bt,
void **vec);
289 prof_tctx_t *
prof_lookup(tsd_t *tsd, prof_bt_t *bt);
293 const prof_cnt_t *prof_cnt_all(
void);
294 typedef int (prof_dump_open_t)(
bool,
const char *);
296 typedef bool (prof_dump_header_t)(tsdn_t *,
bool,
const prof_cnt_t *);
304 void prof_reset(tsd_t *tsd,
size_t lg_sample);
327 #ifdef JEMALLOC_H_INLINES
329 #ifndef JEMALLOC_ENABLE_INLINE
334 void prof_tctx_set(tsdn_t *tsdn,
const void *ptr,
size_t usize,
337 const void *old_ptr, prof_tctx_t *tctx);
339 prof_tdata_t **tdata_out);
342 void prof_malloc(tsdn_t *tsdn,
const void *ptr,
size_t usize,
344 void prof_realloc(tsd_t *tsd,
const void *ptr,
size_t usize,
345 prof_tctx_t *tctx,
bool prof_active,
bool updated,
const void *old_ptr,
346 size_t old_usize, prof_tctx_t *old_tctx);
347 void prof_free(tsd_t *tsd,
const void *ptr,
size_t usize);
350 #if (defined(JEMALLOC_ENABLE_INLINE) || defined(JEMALLOC_PROF_C_))
391 }
else if (
unlikely(tdata->expired)) {
395 if (
unlikely ( ( (tdata !=
NULL) || ! (tdata->attached) ) ) )
411 prof_tctx_set(tsdn_t *tsdn,
const void *ptr,
size_t usize, prof_tctx_t *tctx)
419 prof_tctx_reset(tsdn_t *tsdn,
const void *ptr,
size_t usize,
const void *old_ptr,
420 prof_tctx_t *old_tctx)
430 prof_tdata_t **tdata_out)
441 if (tdata_out !=
NULL)
447 if (
likely(tdata->bytes_until_sample >= usize)) {
449 tdata->bytes_until_sample -= usize;
455 return (!tdata->active);
482 prof_malloc(tsdn_t *tsdn,
const void *ptr,
size_t usize, prof_tctx_t *tctx)
495 prof_realloc(tsd_t *tsd,
const void *ptr,
size_t usize, prof_tctx_t *tctx,
496 bool prof_active,
bool updated,
const void *old_ptr,
size_t old_usize,
497 prof_tctx_t *old_tctx)
499 bool sampled, old_sampled;
532 prof_free(tsd_t *tsd,
const void *ptr,
size_t usize)
static RzBuffer * create(RzBin *bin, const ut8 *code, int codelen, const ut8 *data, int datalen, RzBinArchOptions *opt)
static bool update(RzCrypto *cry, const ut8 *buf, int len)
static const bool config_prof
#define JEMALLOC_ALWAYS_INLINE
assert(limit<=UINT32_MAX/2)
#define prof_tdata_cleanup
#define prof_free_sampled_object
#define prof_thread_active_init_set
#define tsd_prof_tdata_set
#define arena_prof_tctx_reset
#define prof_malloc_sample_object
#define prof_postfork_parent
#define prof_thread_name_set
#define prof_thread_active_get
#define arena_prof_tctx_set
#define prof_postfork_child
#define opt_lg_prof_interval
#define opt_prof_thread_active_init
#define opt_lg_prof_sample
#define prof_gdump_get_unlocked
#define prof_thread_name_get
#define prof_tdata_reinit
#define prof_sample_threshold_update
#define tsd_prof_tdata_get
#define prof_sample_accum_update
#define prof_active_get_unlocked
#define prof_alloc_rollback
#define prof_thread_active_set
#define prof_thread_active_init_get
#define arena_prof_tctx_get
_W64 unsigned int uintptr_t
static void lock(volatile int *lk)