mirror of
https://github.com/ruby/ruby.git
synced 2025-08-15 13:39:04 +02:00
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
This commit is contained in:
parent
989fc2de9a
commit
cdc614cd0a
4 changed files with 137 additions and 19 deletions
|
@ -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 */
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue