ruby-changes:38940
From: ko1 <ko1@a...>
Date: Thu, 25 Jun 2015 07:10:50 +0900 (JST)
Subject: [ruby-changes:38940] ko1:r51021 (trunk): * gc.c (obj_info, method_type_name): show method type name in a string
ko1 2015-06-25 07:10:13 +0900 (Thu, 25 Jun 2015) New Revision: 51021 http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=51021 Log: * gc.c (obj_info, method_type_name): show method type name in a string instead of a number. Modified files: trunk/ChangeLog trunk/gc.c Index: ChangeLog =================================================================== --- ChangeLog (revision 51020) +++ ChangeLog (revision 51021) @@ -1,3 +1,8 @@ https://github.com/ruby/ruby/blob/trunk/ChangeLog#L1 +Thu Jun 25 07:08:35 2015 Koichi Sasada <ko1@a...> + + * gc.c (obj_info, method_type_name): show method type name in a string + instead of a number. + Thu Jun 25 06:49:25 2015 Koichi Sasada <ko1@a...> * gc.c (obj_info): show more details for T_IMEMO/imemo_ment. Index: gc.c =================================================================== --- gc.c (revision 51020) +++ gc.c (revision 51021) @@ -8838,6 +8838,28 @@ obj_type_name(VALUE obj) https://github.com/ruby/ruby/blob/trunk/gc.c#L8838 } #if RGENGC_OBJ_INFO + +static const char * +method_type_name(rb_method_type_t type) +{ + switch (type) { + case VM_METHOD_TYPE_ISEQ: return "iseq"; + case VM_METHOD_TYPE_ATTRSET: return "attrest"; + case VM_METHOD_TYPE_IVAR: return "ivar"; + case VM_METHOD_TYPE_BMETHOD: return "bmethod"; + case VM_METHOD_TYPE_ALIAS: return "alias"; + case VM_METHOD_TYPE_REFINED: return "refined"; + case VM_METHOD_TYPE_CFUNC: return "cfunc"; + case VM_METHOD_TYPE_ZSUPER: return "zsuper"; + case VM_METHOD_TYPE_MISSING: return "missing"; + case VM_METHOD_TYPE_OPTIMIZED: return "optimized"; + case VM_METHOD_TYPE_UNDEF: return "undef"; + case VM_METHOD_TYPE_NOTIMPLEMENTED: return "notimplemented"; + } + rb_bug("method_type_name: unreachable (type: %d)", type); +} + + #define OBJ_INFO_BUFFERS_NUM 10 #define OBJ_INFO_BUFFERS_SIZE 0x100 static int obj_info_buffers_index = 0; @@ -8944,8 +8966,8 @@ obj_info(VALUE obj) https://github.com/ruby/ruby/blob/trunk/gc.c#L8966 snprintf(buff, OBJ_INFO_BUFFERS_SIZE, "%s %s", buff, imemo_name); if (imemo_type(obj) == imemo_ment) { const rb_method_entry_t *me = &RANY(obj)->as.imemo.ment; - snprintf(buff, OBJ_INFO_BUFFERS_SIZE, "%s (called_id: %s, type: %d, alias: %d, class: %s)", buff, - rb_id2name(me->called_id), me->def->type, me->def->alias_count, obj_info(me->klass)); + snprintf(buff, OBJ_INFO_BUFFERS_SIZE, "%s (called_id: %s, type: %s, alias: %d, class: %s)", buff, + rb_id2name(me->called_id), method_type_name(me->def->type), me->def->alias_count, obj_info(me->klass)); } } default: -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/