1 #ifndef JEMALLOC_INTERNAL_PROF_EXTERNS_H
2 #define JEMALLOC_INTERNAL_PROF_EXTERNS_H
4 #include "jemalloc/internal/mutex.h"
6 extern malloc_mutex_t bt2gctx_mtx;
9 extern bool opt_prof_active;
10 extern bool opt_prof_thread_active_init;
11 extern size_t opt_lg_prof_sample; /* Mean bytes between samples. */
12 extern ssize_t opt_lg_prof_interval; /* lg(prof_interval). */
13 extern bool opt_prof_gdump; /* High-water memory dumping. */
14 extern bool opt_prof_final; /* Final profile dumping. */
15 extern bool opt_prof_leak; /* Dump leak summary at exit. */
16 extern bool opt_prof_accum; /* Report cumulative bytes. */
17 extern bool opt_prof_log; /* Turn logging on at boot. */
18 extern char opt_prof_prefix[
19 /* Minimize memory bloat for non-prof builds. */
25 /* Accessed via prof_active_[gs]et{_unlocked,}(). */
26 extern bool prof_active;
28 /* Accessed via prof_gdump_[gs]et{_unlocked,}(). */
29 extern bool prof_gdump_val;
32 * Profile dump interval, measured in bytes allocated. Each arena triggers a
33 * profile dump when it reaches this threshold. The effect is that the
34 * interval between profile dumps averages prof_interval, though the actual
35 * interval between dumps will tend to be sporadic, and the interval will be a
36 * maximum of approximately (prof_interval * narenas).
38 extern uint64_t prof_interval;
41 * Initialized as opt_lg_prof_sample, and potentially modified during profiling
44 extern size_t lg_prof_sample;
46 void prof_alloc_rollback(tsd_t *tsd, prof_tctx_t *tctx, bool updated);
47 void prof_malloc_sample_object(tsdn_t *tsdn, const void *ptr, size_t usize,
49 void prof_free_sampled_object(tsd_t *tsd, const void *ptr, size_t usize,
51 void bt_init(prof_bt_t *bt, void **vec);
52 void prof_backtrace(prof_bt_t *bt);
53 prof_tctx_t *prof_lookup(tsd_t *tsd, prof_bt_t *bt);
55 size_t prof_tdata_count(void);
56 size_t prof_bt_count(void);
58 typedef int (prof_dump_open_t)(bool, const char *);
59 extern prof_dump_open_t *JET_MUTABLE prof_dump_open;
61 typedef bool (prof_dump_header_t)(tsdn_t *, bool, const prof_cnt_t *);
62 extern prof_dump_header_t *JET_MUTABLE prof_dump_header;
64 void prof_cnt_all(uint64_t *curobjs, uint64_t *curbytes, uint64_t *accumobjs,
65 uint64_t *accumbytes);
67 bool prof_accum_init(tsdn_t *tsdn, prof_accum_t *prof_accum);
68 void prof_idump(tsdn_t *tsdn);
69 bool prof_mdump(tsd_t *tsd, const char *filename);
70 void prof_gdump(tsdn_t *tsdn);
71 prof_tdata_t *prof_tdata_init(tsd_t *tsd);
72 prof_tdata_t *prof_tdata_reinit(tsd_t *tsd, prof_tdata_t *tdata);
73 void prof_reset(tsd_t *tsd, size_t lg_sample);
74 void prof_tdata_cleanup(tsd_t *tsd);
75 bool prof_active_get(tsdn_t *tsdn);
76 bool prof_active_set(tsdn_t *tsdn, bool active);
77 const char *prof_thread_name_get(tsd_t *tsd);
78 int prof_thread_name_set(tsd_t *tsd, const char *thread_name);
79 bool prof_thread_active_get(tsd_t *tsd);
80 bool prof_thread_active_set(tsd_t *tsd, bool active);
81 bool prof_thread_active_init_get(tsdn_t *tsdn);
82 bool prof_thread_active_init_set(tsdn_t *tsdn, bool active_init);
83 bool prof_gdump_get(tsdn_t *tsdn);
84 bool prof_gdump_set(tsdn_t *tsdn, bool active);
85 void prof_boot0(void);
86 void prof_boot1(void);
87 bool prof_boot2(tsd_t *tsd);
88 void prof_prefork0(tsdn_t *tsdn);
89 void prof_prefork1(tsdn_t *tsdn);
90 void prof_postfork_parent(tsdn_t *tsdn);
91 void prof_postfork_child(tsdn_t *tsdn);
92 void prof_sample_threshold_update(prof_tdata_t *tdata);
94 bool prof_log_start(tsdn_t *tsdn, const char *filename);
95 bool prof_log_stop(tsdn_t *tsdn);
97 size_t prof_log_bt_count(void);
98 size_t prof_log_alloc_count(void);
99 size_t prof_log_thr_count(void);
100 bool prof_log_is_logging(void);
101 bool prof_log_rep_check(void);
102 void prof_log_dummy_set(bool new_value);
105 #endif /* JEMALLOC_INTERNAL_PROF_EXTERNS_H */