1#ifndef JEMALLOC_INTERNAL_PROF_EXTERNS_H
2#define JEMALLOC_INTERNAL_PROF_EXTERNS_H
3
4#include "jemalloc/internal/mutex.h"
5#include "jemalloc/internal/prof_hook.h"
6
7extern bool opt_prof;
8extern bool opt_prof_active;
9extern bool opt_prof_thread_active_init;
10extern size_t opt_lg_prof_sample; /* Mean bytes between samples. */
11extern ssize_t opt_lg_prof_interval; /* lg(prof_interval). */
12extern bool opt_prof_gdump; /* High-water memory dumping. */
13extern bool opt_prof_final; /* Final profile dumping. */
14extern bool opt_prof_leak; /* Dump leak summary at exit. */
15extern bool opt_prof_leak_error; /* Exit with error code if memory leaked */
16extern bool opt_prof_accum; /* Report cumulative bytes. */
17extern bool opt_prof_log; /* Turn logging on at boot. */
18extern char opt_prof_prefix[
19 /* Minimize memory bloat for non-prof builds. */
20#ifdef JEMALLOC_PROF
21 PATH_MAX +
22#endif
23 1];
24extern bool opt_prof_unbias;
25
26/* For recording recent allocations */
27extern ssize_t opt_prof_recent_alloc_max;
28
29/* Whether to use thread name provided by the system or by mallctl. */
30extern bool opt_prof_sys_thread_name;
31
32/* Whether to record per size class counts and request size totals. */
33extern bool opt_prof_stats;
34
35/* Accessed via prof_active_[gs]et{_unlocked,}(). */
36extern bool prof_active_state;
37
38/* Accessed via prof_gdump_[gs]et{_unlocked,}(). */
39extern bool prof_gdump_val;
40
41/* Profile dump interval, measured in bytes allocated. */
42extern uint64_t prof_interval;
43
44/*
45 * Initialized as opt_lg_prof_sample, and potentially modified during profiling
46 * resets.
47 */
48extern size_t lg_prof_sample;
49
50extern bool prof_booted;
51
52void prof_backtrace_hook_set(prof_backtrace_hook_t hook);
53prof_backtrace_hook_t prof_backtrace_hook_get();
54
55void prof_dump_hook_set(prof_dump_hook_t hook);
56prof_dump_hook_t prof_dump_hook_get();
57
58/* Functions only accessed in prof_inlines.h */
59prof_tdata_t *prof_tdata_init(tsd_t *tsd);
60prof_tdata_t *prof_tdata_reinit(tsd_t *tsd, prof_tdata_t *tdata);
61
62void prof_alloc_rollback(tsd_t *tsd, prof_tctx_t *tctx);
63void prof_malloc_sample_object(tsd_t *tsd, const void *ptr, size_t size,
64 size_t usize, prof_tctx_t *tctx);
65void prof_free_sampled_object(tsd_t *tsd, size_t usize, prof_info_t *prof_info);
66prof_tctx_t *prof_tctx_create(tsd_t *tsd);
67void prof_idump(tsdn_t *tsdn);
68bool prof_mdump(tsd_t *tsd, const char *filename);
69void prof_gdump(tsdn_t *tsdn);
70
71void prof_tdata_cleanup(tsd_t *tsd);
72bool prof_active_get(tsdn_t *tsdn);
73bool prof_active_set(tsdn_t *tsdn, bool active);
74const char *prof_thread_name_get(tsd_t *tsd);
75int prof_thread_name_set(tsd_t *tsd, const char *thread_name);
76bool prof_thread_active_get(tsd_t *tsd);
77bool prof_thread_active_set(tsd_t *tsd, bool active);
78bool prof_thread_active_init_get(tsdn_t *tsdn);
79bool prof_thread_active_init_set(tsdn_t *tsdn, bool active_init);
80bool prof_gdump_get(tsdn_t *tsdn);
81bool prof_gdump_set(tsdn_t *tsdn, bool active);
82void prof_boot0(void);
83void prof_boot1(void);
84bool prof_boot2(tsd_t *tsd, base_t *base);
85void prof_prefork0(tsdn_t *tsdn);
86void prof_prefork1(tsdn_t *tsdn);
87void prof_postfork_parent(tsdn_t *tsdn);
88void prof_postfork_child(tsdn_t *tsdn);
89
90/* Only accessed by thread event. */
91uint64_t prof_sample_new_event_wait(tsd_t *tsd);
92uint64_t prof_sample_postponed_event_wait(tsd_t *tsd);
93void prof_sample_event_handler(tsd_t *tsd, uint64_t elapsed);
94
95#endif /* JEMALLOC_INTERNAL_PROF_EXTERNS_H */
96