summaryrefslogtreecommitdiff
path: root/gc.c
diff options
context:
space:
mode:
authorko1 <ko1@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2016-07-26 10:07:12 +0000
committerko1 <ko1@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2016-07-26 10:07:12 +0000
commit78e86f75ed7ba5b7cd0cbdd85b27c98e271fd2fc (patch)
tree003d0c0ef6752ad05f97925d5725e05147e3aaa3 /gc.c
parent225915ef45447edce824d11dc94bd0fc7a4cfec0 (diff)
* 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
Diffstat (limited to 'gc.c')
-rw-r--r--gc.c44
1 files changed, 34 insertions, 10 deletions
diff --git a/gc.c b/gc.c
index fd0566c4ca..f8a677ed8b 100644
--- a/gc.c
+++ b/gc.c
@@ -9139,6 +9139,30 @@ method_type_name(rb_method_type_t type)
(assert(!FL_TEST((ary), ELTS_SHARED) || !FL_TEST((ary), RARRAY_EMBED_FLAG)), \
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 *
rb_raw_obj_info(char *buff, const int buff_size, VALUE obj)
{
@@ -9206,9 +9230,15 @@ rb_raw_obj_info(char *buff, const int buff_size, VALUE obj)
break;
}
case T_DATA: {
- const char * const type_name = rb_objspace_data_type_name(obj);
- if (type_name) {
- snprintf(buff, buff_size, "%s %s", buff, type_name);
+ 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);
+ if (type_name) {
+ snprintf(buff, buff_size, "%s %s", buff, type_name);
+ }
}
break;
}
@@ -9242,13 +9272,7 @@ rb_raw_obj_info(char *buff, const int buff_size, VALUE obj)
}
case imemo_iseq: {
const rb_iseq_t *iseq = (const rb_iseq_t *)obj;
-
- 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));
- }
+ rb_raw_iseq_info(buff, buff_size, iseq);
break;
}
default: