From 77205540e0a1ff85b2441e3cbc3e16941fbc42a7 Mon Sep 17 00:00:00 2001 From: ko1 Date: Fri, 20 Mar 2015 03:17:06 +0000 Subject: [PATCH] * gc.c (obj_info): show class name and T_DATA type_name. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@50029 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- ChangeLog | 4 ++++ gc.c | 30 +++++++++++++++++++++++++----- 2 files changed, 29 insertions(+), 5 deletions(-) diff --git a/ChangeLog b/ChangeLog index 2938126075..f4c20a85db 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,7 @@ +Fri Mar 20 12:14:37 2015 Koichi Sasada + + * gc.c (obj_info): show class name and T_DATA type_name. + Thu Mar 19 22:12:46 2015 Koichi Sasada * gc.c (rb_copy_wb_protected_attribute): `dest' can be WB unprotected. diff --git a/gc.c b/gc.c index a0158d24db..13b7536acc 100644 --- a/gc.c +++ b/gc.c @@ -8798,9 +8798,10 @@ static char obj_info_buffers[OBJ_INFO_BUFFERS_NUM][OBJ_INFO_BUFFERS_SIZE]; static const char * obj_info(VALUE obj) { - int index = obj_info_buffers_index++; - char *buff = &obj_info_buffers[index][0]; - int age = RVALUE_FLAGS_AGE(RBASIC(obj)->flags); + const int index = obj_info_buffers_index++; + char *const buff = &obj_info_buffers[index][0]; + const int age = RVALUE_FLAGS_AGE(RBASIC(obj)->flags); + const int type = BUILTIN_TYPE(obj); if (obj_info_buffers_index >= OBJ_INFO_BUFFERS_NUM) { obj_info_buffers_index = 0; @@ -8816,12 +8817,28 @@ obj_info(VALUE obj) C(RVALUE_WB_UNPROTECTED_BITMAP(obj), "U"), obj_type_name(obj)); + switch (type) { + case T_NODE: + case T_IMEMO: + break; + default: + if (RBASIC(obj)->klass == 0) { + snprintf(buff, OBJ_INFO_BUFFERS_SIZE, "%s (internal)", buff); + } + else { + VALUE class_path = rb_class_path_cached(RBASIC(obj)->klass); + if (!NIL_P(class_path)) { + snprintf(buff, OBJ_INFO_BUFFERS_SIZE, "%s (%s)", buff, RSTRING_PTR(class_path)); + } + } + } + #if GC_DEBUG snprintf(buff, OBJ_INFO_BUFFERS_SIZE, "%s @%s:%d", buff, RANY(obj)->file, RANY(obj)->line); #endif #ifdef HAVE_VA_ARGS_MACRO - switch (BUILTIN_TYPE(obj)) { + switch (type) { case T_NODE: snprintf(buff, OBJ_INFO_BUFFERS_SIZE, "%s (%s)", buff, ruby_node_name(nd_type(obj))); @@ -8844,7 +8861,7 @@ obj_info(VALUE obj) break; } case T_DATA: { - const char *type_name = rb_objspace_data_type_name(obj); + const char * const type_name = rb_objspace_data_type_name(obj); if (type_name && strcmp(type_name, "iseq") == 0) { rb_iseq_t *iseq; GetISeqPtr(obj, iseq); @@ -8853,6 +8870,9 @@ obj_info(VALUE obj) RSTRING_PTR(iseq->location.label), RSTRING_PTR(iseq->location.path), (int)iseq->location.first_lineno); } } + else if (type_name) { + snprintf(buff, OBJ_INFO_BUFFERS_SIZE, "%s %s", buff, type_name); + } break; } case T_IMEMO: {