Add opt.stats_print_opts.

The value is passed to atexit(3)-triggered malloc_stats_print() calls.
This commit is contained in:
Qi Wang
2017-05-27 15:35:36 -07:00
committed by Qi Wang
parent 49505e558b
commit d5ef5ae934
5 changed files with 94 additions and 45 deletions

View File

@@ -724,7 +724,7 @@ stats_print_atexit(void) {
}
}
}
je_malloc_stats_print(NULL, NULL, NULL);
je_malloc_stats_print(NULL, NULL, opt_stats_print_opts);
}
/*
@@ -777,6 +777,31 @@ malloc_ncpus(void) {
return ((result == -1) ? 1 : (unsigned)result);
}
static void
init_opt_stats_print_opts(const char *v, size_t vlen) {
size_t opts_len = strlen(opt_stats_print_opts);
assert(opts_len <= stats_print_tot_num_options);
for (size_t i = 0; i < vlen; i++) {
switch (v[i]) {
#define OPTION(o, v, d, s) case o: break;
STATS_PRINT_OPTIONS
#undef OPTION
default: continue;
}
if (strchr(opt_stats_print_opts, v[i]) != NULL) {
/* Ignore repeated. */
continue;
}
opt_stats_print_opts[opts_len++] = v[i];
opt_stats_print_opts[opts_len] = '\0';
assert(opts_len <= stats_print_tot_num_options);
}
assert(opts_len == strlen(opt_stats_print_opts));
}
static bool
malloc_conf_next(char const **opts_p, char const **k_p, size_t *klen_p,
char const **v_p, size_t *vlen_p) {
@@ -1099,6 +1124,10 @@ malloc_conf_init(void) {
QU(SSIZE_MAX) ? NSTIME_SEC_MAX * KQU(1000) :
SSIZE_MAX);
CONF_HANDLE_BOOL(opt_stats_print, "stats_print")
if (CONF_MATCH("stats_print_opts")) {
init_opt_stats_print_opts(v, vlen);
continue;
}
if (config_fill) {
if (CONF_MATCH("junk")) {
if (CONF_MATCH_VALUE("true")) {