* gc.c (rb_raw_obj_info): support to show Proc obj.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@55754 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
ko1 2016-07-26 10:07:12 +00:00
parent 225915ef45
commit 78e86f75ed
2 changed files with 38 additions and 10 deletions

View File

@ -1,3 +1,7 @@
Tue Jul 26 19:06:39 2016 Koichi Sasada <ko1@atdot.net>
* gc.c (rb_raw_obj_info): support to show Proc obj.
Tue Jul 26 18:55:55 2016 Koichi Sasada <ko1@atdot.net> Tue Jul 26 18:55:55 2016 Koichi Sasada <ko1@atdot.net>
* gc.c (gc_mark): add `inline' explicitly. * gc.c (gc_mark): add `inline' explicitly.

38
gc.c
View File

@ -9139,6 +9139,30 @@ method_type_name(rb_method_type_t type)
(assert(!FL_TEST((ary), ELTS_SHARED) || !FL_TEST((ary), RARRAY_EMBED_FLAG)), \ (assert(!FL_TEST((ary), ELTS_SHARED) || !FL_TEST((ary), RARRAY_EMBED_FLAG)), \
FL_TEST((ary), RARRAY_EMBED_FLAG)!=0) FL_TEST((ary), RARRAY_EMBED_FLAG)!=0)
static void
rb_raw_iseq_info(char *buff, const int buff_size, const rb_iseq_t *iseq)
{
if (iseq->body->location.label) {
snprintf(buff, buff_size, "%s %s@%s:%d", buff,
RSTRING_PTR(iseq->body->location.label),
RSTRING_PTR(iseq->body->location.path),
FIX2INT(iseq->body->location.first_lineno));
}
}
static const rb_iseq_t *
vm_proc_iseq(VALUE procval)
{
rb_proc_t *proc = RTYPEDDATA_DATA(procval);
if (RUBY_VM_NORMAL_ISEQ_P(proc->block.iseq)) {
return proc->block.iseq;
}
else {
return NULL;
}
}
const char * const char *
rb_raw_obj_info(char *buff, const int buff_size, VALUE obj) rb_raw_obj_info(char *buff, const int buff_size, VALUE obj)
{ {
@ -9206,10 +9230,16 @@ rb_raw_obj_info(char *buff, const int buff_size, VALUE obj)
break; break;
} }
case T_DATA: { case T_DATA: {
const rb_iseq_t *iseq;
if (rb_obj_is_proc(obj) && (iseq = vm_proc_iseq(obj)) != NULL) {
rb_raw_iseq_info(buff, buff_size, iseq);
}
else {
const char * const type_name = rb_objspace_data_type_name(obj); const char * const type_name = rb_objspace_data_type_name(obj);
if (type_name) { if (type_name) {
snprintf(buff, buff_size, "%s %s", buff, type_name); snprintf(buff, buff_size, "%s %s", buff, type_name);
} }
}
break; break;
} }
case T_IMEMO: { case T_IMEMO: {
@ -9242,13 +9272,7 @@ rb_raw_obj_info(char *buff, const int buff_size, VALUE obj)
} }
case imemo_iseq: { case imemo_iseq: {
const rb_iseq_t *iseq = (const rb_iseq_t *)obj; const rb_iseq_t *iseq = (const rb_iseq_t *)obj;
rb_raw_iseq_info(buff, buff_size, iseq);
if (iseq->body->location.label) {
snprintf(buff, buff_size, "%s %s@%s:%d", buff,
RSTRING_PTR(iseq->body->location.label),
RSTRING_PTR(iseq->body->location.path),
FIX2INT(iseq->body->location.first_lineno));
}
break; break;
} }
default: default: