make mi_options_print, mi_arenas_print, and mi_stats_print independent of the vebosity setting

This commit is contained in:
Daan 2025-03-03 16:23:28 -08:00
parent b54a7d836c
commit db831d4cf4
3 changed files with 23 additions and 15 deletions

View file

@ -188,7 +188,7 @@ void _mi_options_init(void) {
}
}
#endif
mi_options_print();
if (!mi_option_is_enabled(mi_option_verbose)) { mi_options_print(); }
}
#define mi_stringifyx(str) #str // and stringify
@ -200,7 +200,7 @@ void mi_options_print(void) mi_attr_noexcept
const int vermajor = MI_MALLOC_VERSION/100;
const int verminor = (MI_MALLOC_VERSION%100)/10;
const int verpatch = (MI_MALLOC_VERSION%10);
_mi_verbose_message("v%i.%i.%i%s%s (built on %s, %s)\n", vermajor, verminor, verpatch,
_mi_message("v%i.%i.%i%s%s (built on %s, %s)\n", vermajor, verminor, verpatch,
#if defined(MI_CMAKE_BUILD_TYPE)
", " mi_stringify(MI_CMAKE_BUILD_TYPE)
#else
@ -219,18 +219,18 @@ void mi_options_print(void) mi_attr_noexcept
mi_option_t option = (mi_option_t)i;
long l = mi_option_get(option); MI_UNUSED(l); // possibly initialize
mi_option_desc_t* desc = &options[option];
_mi_verbose_message("option '%s': %ld %s\n", desc->name, desc->value, (mi_option_has_size_in_kib(option) ? "KiB" : ""));
_mi_message("option '%s': %ld %s\n", desc->name, desc->value, (mi_option_has_size_in_kib(option) ? "KiB" : ""));
}
// show build configuration
_mi_verbose_message("debug level : %d\n", MI_DEBUG );
_mi_verbose_message("secure level: %d\n", MI_SECURE );
_mi_verbose_message("mem tracking: %s\n", MI_TRACK_TOOL);
_mi_message("debug level : %d\n", MI_DEBUG );
_mi_message("secure level: %d\n", MI_SECURE );
_mi_message("mem tracking: %s\n", MI_TRACK_TOOL);
#if MI_GUARDED
_mi_verbose_message("guarded build: %s\n", mi_option_get(mi_option_guarded_sample_rate) != 0 ? "enabled" : "disabled");
_mi_message("guarded build: %s\n", mi_option_get(mi_option_guarded_sample_rate) != 0 ? "enabled" : "disabled");
#endif
#if MI_TSAN
_mi_verbose_message("thread santizer enabled\n");
_mi_message("thread santizer enabled\n");
#endif
}
@ -481,6 +481,13 @@ static void mi_vfprintf_thread(mi_output_fun* out, void* arg, const char* prefix
}
}
void _mi_message(const char* fmt, ...) {
va_list args;
va_start(args, fmt);
mi_vfprintf_thread(NULL, NULL, "mimalloc: ", fmt, args);
va_end(args);
}
void _mi_trace_message(const char* fmt, ...) {
if (mi_option_get(mi_option_verbose) <= 1) return; // only with verbose level 2 or higher
va_list args;