[前][次][番号順一覧][スレッド一覧]

ruby-changes:37949

From: ko1 <ko1@a...>
Date: Fri, 20 Mar 2015 12:17:40 +0900 (JST)
Subject: [ruby-changes:37949] ko1:r50029 (trunk): * gc.c (obj_info): show class name and T_DATA type_name.

ko1	2015-03-20 12:17:06 +0900 (Fri, 20 Mar 2015)

  New Revision: 50029

  http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=50029

  Log:
    * gc.c (obj_info): show class name and T_DATA type_name.

  Modified files:
    trunk/ChangeLog
    trunk/gc.c
Index: ChangeLog
===================================================================
--- ChangeLog	(revision 50028)
+++ ChangeLog	(revision 50029)
@@ -1,3 +1,7 @@ https://github.com/ruby/ruby/blob/trunk/ChangeLog#L1
+Fri Mar 20 12:14:37 2015  Koichi Sasada  <ko1@a...>
+
+	* gc.c (obj_info): show class name and T_DATA type_name.
+
 Thu Mar 19 22:12:46 2015  Koichi Sasada  <ko1@a...>
 
 	* gc.c (rb_copy_wb_protected_attribute): `dest' can be WB unprotected.
Index: gc.c
===================================================================
--- gc.c	(revision 50028)
+++ gc.c	(revision 50029)
@@ -8798,9 +8798,10 @@ static char obj_info_buffers[OBJ_INFO_BU https://github.com/ruby/ruby/blob/trunk/gc.c#L8798
 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) https://github.com/ruby/ruby/blob/trunk/gc.c#L8817
 	     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) https://github.com/ruby/ruby/blob/trunk/gc.c#L8861
 	  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) https://github.com/ruby/ruby/blob/trunk/gc.c#L8870
 			   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: {

--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml/

[前][次][番号順一覧][スレッド一覧]