aboutsummaryrefslogtreecommitdiffstats
path: root/debug_counter.c
diff options
context:
space:
mode:
authorko1 <ko1@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2018-09-25 18:13:29 +0000
committerko1 <ko1@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2018-09-25 18:13:29 +0000
commitcdc614cd0a21b2e72d953438438c78bafdfd9f80 (patch)
treeb1e470a5deb7ab926c465b5814e03f338761efcf /debug_counter.c
parent989fc2de9afccb14865735346bbfa3b3325de84c (diff)
downloadruby-cdc614cd0a21b2e72d953438438c78bafdfd9f80.tar.gz
refactoring debug_counter.
* debug_counter.h: add comments for each counters. * debug_counter.h: add some counters (see added comments for details). * obj_newobj * obj_newobj_slowpath * obj_newobj_wb_unprotected * obj_hash_empty * obj_hash_under4 * obj_hash_ge4 * obj_hash_ge8 * heap_xmalloc * heap_xrealloc * heap_xfree * gc.c: add some debug counters (see the above list). * debug_counter.c (rb_debug_counter_show_results): accept a header message. * signal.c (ruby_default_signal): show debug counter results and malloc info (rb_malloc_info_show_results()) before SIGNAL exit. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@64841 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'debug_counter.c')
-rw-r--r--debug_counter.c26
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 */