11#include "debug_counter.h"
19const char *
const rb_debug_counter_names[] = {
20#define DEBUG_COUNTER_NAME_EMPTY ""
21 DEBUG_COUNTER_NAME_EMPTY
22#undef DEBUG_COUNTER_NAME_EMPTY
23#define RB_DEBUG_COUNTER(name) #name,
24#include "debug_counter.h"
25#undef RB_DEBUG_COUNTER
28MJIT_SYMBOL_EXPORT_BEGIN
29size_t rb_debug_counter[numberof(rb_debug_counter_names)];
30void rb_debug_counter_add_atomic(
enum rb_debug_counter_type
type,
int add);
37debug_counter_setup(
void)
43rb_debug_counter_add_atomic(
enum rb_debug_counter_type
type,
int add)
47 rb_debug_counter[(int)
type] += add;
52static int debug_counter_disable_show_at_exit = 0;
56ruby_debug_counter_reset(
void)
58 for (
int i = 0; i < RB_DEBUG_COUNTER_MAX; i++) {
59 rb_debug_counter[i] = 0;
65ruby_debug_counter_get(
const char **names_ptr,
size_t *counters_ptr)
68 if (names_ptr != NULL) {
69 for (i=0; i<RB_DEBUG_COUNTER_MAX; i++) {
70 names_ptr[i] = rb_debug_counter_names[i];
73 if (counters_ptr != NULL) {
74 for (i=0; i<RB_DEBUG_COUNTER_MAX; i++) {
75 counters_ptr[i] = rb_debug_counter[i];
79 return RB_DEBUG_COUNTER_MAX;
83ruby_debug_counter_show_at_exit(
int enable)
85 debug_counter_disable_show_at_exit = !enable;
89rb_debug_counter_show_results(
const char *msg)
91 const char *env = getenv(
"RUBY_DEBUG_COUNTER_DISABLE");
93 setlocale(LC_NUMERIC,
"");
95 if (env == NULL || strcmp(
"1", env) != 0) {
97 fprintf(stderr,
"[RUBY_DEBUG_COUNTER]\t%d %s\n", getpid(), msg);
98 for (i=0; i<RB_DEBUG_COUNTER_MAX; i++) {
99 fprintf(stderr,
"[RUBY_DEBUG_COUNTER]\t%-30s\t%'14"PRIuSIZE
"\n",
100 rb_debug_counter_names[i],
101 rb_debug_counter[i]);
107rb_debug_counter_show(RB_UNUSED_VAR(
VALUE klass))
109 rb_debug_counter_show_results(
"show_debug_counters");
110 ruby_debug_counter_show_at_exit(FALSE);
115rb_debug_counter_reset(RB_UNUSED_VAR(
VALUE klass))
117 ruby_debug_counter_reset();
123debug_counter_show_results_at_exit(
void)
125 if (debug_counter_disable_show_at_exit == 0) {
126 rb_debug_counter_show_results(
"normal exit.");
133rb_debug_counter_show_results(
const char *msg)
138ruby_debug_counter_get(
const char **names_ptr,
size_t *counters_ptr)
143ruby_debug_counter_reset(
void)
148ruby_debug_counter_show_at_exit(
int enable)
#define Qnil
Old name of RUBY_Qnil.
VALUE type(ANYARGS)
ANYARGS-ed function type.
void rb_nativethread_lock_lock(rb_nativethread_lock_t *lock)
Blocks until the current thread obtains a lock.
void rb_nativethread_lock_unlock(rb_nativethread_lock_t *lock)
Releases a lock.
void rb_nativethread_lock_initialize(rb_nativethread_lock_t *lock)
Fills the passed lock with an initial value.
uintptr_t VALUE
Type that represents a Ruby object.