diff options
author | Koichi Sasada <ko1@atdot.net> | 2021-02-19 14:56:58 +0900 |
---|---|---|
committer | Koichi Sasada <ko1@atdot.net> | 2021-02-19 16:54:31 +0900 |
commit | d260cbe2950392c41e263c82ab753e5faa12468c (patch) | |
tree | 853b3c159f8c192c82d9152607fb9f2b99cd1527 | |
parent | 4c4c0043b81f9e03f6cca50b523fb6db9f6b9c0e (diff) | |
download | ruby-d260cbe2950392c41e263c82ab753e5faa12468c.tar.gz |
show more information about imemo_ment
rb_obj_info(obj) (rp(obj)) doesn't show enough information for
non-iseq methods, so this patch shows more.
-rw-r--r-- | gc.c | 33 |
1 files changed, 18 insertions, 15 deletions
@@ -12402,31 +12402,34 @@ rb_raw_obj_info(char *buff, const int buff_size, VALUE obj) APPENDF((BUFF_ARGS, "<%s> ", rb_imemo_name(imemo_type(obj)))); switch (imemo_type(obj)) { - case imemo_ment: { - const rb_method_entry_t *me = &RANY(obj)->as.imemo.ment; - if (me->def) { + case imemo_ment: + { + const rb_method_entry_t *me = &RANY(obj)->as.imemo.ment; + APPENDF((BUFF_ARGS, ":%s (%s%s%s%s) type:%s alias:%d owner:%p defined_class:%p", - rb_id2name(me->called_id), + rb_id2name(me->called_id), METHOD_ENTRY_VISI(me) == METHOD_VISI_PUBLIC ? "pub" : METHOD_ENTRY_VISI(me) == METHOD_VISI_PRIVATE ? "pri" : "pro", METHOD_ENTRY_COMPLEMENTED(me) ? ",cmp" : "", METHOD_ENTRY_CACHED(me) ? ",cc" : "", METHOD_ENTRY_INVALIDATED(me) ? ",inv" : "", - rb_method_type_name(me->def->type), - me->def->alias_count, + me->def ? rb_method_type_name(me->def->type) : "NULL", + me->def ? me->def->alias_count : -1, (void *)me->owner, // obj_info(me->owner), (void *)me->defined_class)); //obj_info(me->defined_class))); - if (me->def->type == VM_METHOD_TYPE_ISEQ) { - // APPENDF((BUFF_ARGS, " (iseq:%p)", (void *)me->def->body.iseq.iseqptr)); - APPENDF((BUFF_ARGS, " (iseq:%s)", obj_info((VALUE)me->def->body.iseq.iseqptr))); + if (me->def) { + switch (me->def->type) { + case VM_METHOD_TYPE_ISEQ: + APPENDF((BUFF_ARGS, " (iseq:%s)", obj_info((VALUE)me->def->body.iseq.iseqptr))); + break; + default: + break; + } } - } - else { - APPENDF((BUFF_ARGS, "%s", rb_id2name(me->called_id))); - } - break; - } + + break; + } case imemo_iseq: { const rb_iseq_t *iseq = (const rb_iseq_t *)obj; rb_raw_iseq_info(BUFF_ARGS, iseq); |