diff options
Diffstat (limited to 'debug_counter.c')
-rw-r--r-- | debug_counter.c | 26 |
1 files changed, 20 insertions, 6 deletions
diff --git a/debug_counter.c b/debug_counter.c index 6000f98c54..7225b6a08e 100644 --- a/debug_counter.c +++ b/debug_counter.c @@ -9,9 +9,9 @@ **********************************************************************/ #include "debug_counter.h" -#include <stdio.h> - #if USE_DEBUG_COUNTER +#include <stdio.h> +#include <locale.h> #include "internal.h" static const char *const debug_counter_names[] = { @@ -23,19 +23,33 @@ static const char *const debug_counter_names[] = { size_t rb_debug_counter[numberof(debug_counter_names)]; -__attribute__((destructor)) -static void -rb_debug_counter_show_results(void) +void +rb_debug_counter_show_results(const char *msg) { const char *env = getenv("RUBY_DEBUG_COUNTER_DISABLE"); + + setlocale(LC_NUMERIC, ""); + if (env == NULL || strcmp("1", env) != 0) { int i; + fprintf(stderr, "[RUBY_DEBUG_COUNTER]\t%d %s\n", getpid(), msg); for (i=0; i<RB_DEBUG_COUNTER_MAX; i++) { - fprintf(stderr, "[RUBY_DEBUG_COUNTER]\t%s\t%"PRIuSIZE"\n", + fprintf(stderr, "[RUBY_DEBUG_COUNTER]\t%-30s\t%'12"PRIuSIZE"\n", debug_counter_names[i], rb_debug_counter[i]); } } } +__attribute__((destructor)) +static void +debug_counter_show_results_at_exit(void) +{ + rb_debug_counter_show_results("normal exit."); +} +#else +void +rb_debug_counter_show_results(const char *msg) +{ +} #endif /* USE_DEBUG_COUNTER */ |