summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authork0kubun <k0kubun@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2019-04-14 06:57:21 +0000
committerk0kubun <k0kubun@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2019-04-14 06:57:21 +0000
commit5ce28c0642591a950e5757150137253cb8d0b9a9 (patch)
tree0375860b61cede9367082ef0343f93d39d80f394
parent57f9a700d719c0ab0a9ade41ebecac022a2a06d4 (diff)
Add RubyVM.reset_debug_counters when RB_DEBUG_COUNTER
is defined. It's 0 by default and so it dissappears on actual build. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@67544 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
-rw-r--r--debug_counter.c9
-rw-r--r--debug_counter.h2
-rw-r--r--vm.c3
3 files changed, 14 insertions, 0 deletions
diff --git a/debug_counter.c b/debug_counter.c
index b5a0606454..4a0655380f 100644
--- a/debug_counter.c
+++ b/debug_counter.c
@@ -43,6 +43,15 @@ rb_debug_counter_show_results(const char *msg)
}
}
+VALUE
+rb_debug_counter_reset(void)
+{
+ for (int i = 0; i < RB_DEBUG_COUNTER_MAX; i++) {
+ rb_debug_counter[i] = 0;
+ }
+ return Qnil;
+}
+
__attribute__((destructor))
static void
debug_counter_show_results_at_exit(void)
diff --git a/debug_counter.h b/debug_counter.h
index b28efb3278..8510bb90f8 100644
--- a/debug_counter.h
+++ b/debug_counter.h
@@ -319,6 +319,8 @@ rb_debug_counter_add(enum rb_debug_counter_type type, int add, int cond)
return cond;
}
+VALUE rb_debug_counter_reset(void);
+
#define RB_DEBUG_COUNTER_INC(type) rb_debug_counter_add(RB_DEBUG_COUNTER_##type, 1, 1)
#define RB_DEBUG_COUNTER_INC_UNLESS(type, cond) (!rb_debug_counter_add(RB_DEBUG_COUNTER_##type, 1, !(cond)))
#define RB_DEBUG_COUNTER_INC_IF(type, cond) rb_debug_counter_add(RB_DEBUG_COUNTER_##type, 1, (cond))
diff --git a/vm.c b/vm.c
index 142573929a..8c208bb26c 100644
--- a/vm.c
+++ b/vm.c
@@ -2872,6 +2872,9 @@ Init_VM(void)
rb_undef_alloc_func(rb_cRubyVM);
rb_undef_method(CLASS_OF(rb_cRubyVM), "new");
rb_define_singleton_method(rb_cRubyVM, "stat", vm_stat, -1);
+#if USE_DEBUG_COUNTER
+ rb_define_singleton_method(rb_cRubyVM, "reset_debug_counters", rb_debug_counter_reset, 0);
+#endif
/* FrozenCore (hidden) */
fcore = rb_class_new(rb_cBasicObject);