1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00
ruby--ruby/debug_counter.c
ko1 df5ec4107d add debug counters more.
* debug_counter.h: add the following counters.
  * frame_push: control frame counts (total counts).
  * frame_push_*: control frame counts per every frame type.
  * obj_*: add free'ed counts for each type.

* gc.c: ditto.

* vm_insnhelper.c (vm_push_frame): ditto.

* debug_counter.c (rb_debug_counter_show_results): widen counts field
  to show >10G numbers.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@64867 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-09-28 01:10:43 +00:00

55 lines
1.2 KiB
C

/**********************************************************************
debug_counter.c -
created at: Tue Feb 21 16:51:18 2017
Copyright (C) 2017 Koichi Sasada
**********************************************************************/
#include "debug_counter.h"
#if USE_DEBUG_COUNTER
#include <stdio.h>
#include <locale.h>
#include "internal.h"
static const char *const debug_counter_names[] = {
""
#define RB_DEBUG_COUNTER(name) #name,
#include "debug_counter.h"
#undef RB_DEBUG_COUNTER
};
size_t rb_debug_counter[numberof(debug_counter_names)];
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%-30s\t%'14"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 */