1 #ifndef JEMALLOC_INTERNAL_PROF_EXTERNS_H
2 #define JEMALLOC_INTERNAL_PROF_EXTERNS_H
3 
4 #include "jemalloc/internal/mutex.h"
5 
6 extern malloc_mutex_t	bt2gctx_mtx;
7 
8 extern bool	opt_prof;
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. */
20 #ifdef JEMALLOC_PROF
21     PATH_MAX +
22 #endif
23     1];
24 
25 /* Accessed via prof_active_[gs]et{_unlocked,}(). */
26 extern bool	prof_active;
27 
28 /* Accessed via prof_gdump_[gs]et{_unlocked,}(). */
29 extern bool	prof_gdump_val;
30 
31 /*
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).
37  */
38 extern uint64_t	prof_interval;
39 
40 /*
41  * Initialized as opt_lg_prof_sample, and potentially modified during profiling
42  * resets.
43  */
44 extern size_t	lg_prof_sample;
45 
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,
48     prof_tctx_t *tctx);
49 void prof_free_sampled_object(tsd_t *tsd, const void *ptr, size_t usize,
50     prof_tctx_t *tctx);
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);
54 #ifdef JEMALLOC_JET
55 size_t prof_tdata_count(void);
56 size_t prof_bt_count(void);
57 #endif
58 typedef int (prof_dump_open_t)(bool, const char *);
59 extern prof_dump_open_t *JET_MUTABLE prof_dump_open;
60 
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;
63 #ifdef JEMALLOC_JET
64 void prof_cnt_all(uint64_t *curobjs, uint64_t *curbytes, uint64_t *accumobjs,
65     uint64_t *accumbytes);
66 #endif
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);
93 
94 bool prof_log_start(tsdn_t *tsdn, const char *filename);
95 bool prof_log_stop(tsdn_t *tsdn);
96 #ifdef JEMALLOC_JET
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);
103 #endif
104 
105 #endif /* JEMALLOC_INTERNAL_PROF_EXTERNS_H */
106