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

ruby-changes:34056

From: nobu <ko1@a...>
Date: Mon, 26 May 2014 16:39:04 +0900 (JST)
Subject: [ruby-changes:34056] nobu:r46137 (trunk): thread.c: inspect location

nobu	2014-05-26 16:38:57 +0900 (Mon, 26 May 2014)

  New Revision: 46137

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

  Log:
    thread.c: inspect location
    
    * thread.c (rb_thread_inspect): show the location of the block.

  Modified files:
    trunk/thread.c
Index: thread.c
===================================================================
--- thread.c	(revision 46136)
+++ thread.c	(revision 46137)
@@ -2686,7 +2686,19 @@ rb_thread_inspect(VALUE thread) https://github.com/ruby/ruby/blob/trunk/thread.c#L2686
 
     GetThreadPtr(thread, th);
     status = thread_status_name(th);
-    str = rb_sprintf("#<%"PRIsVALUE":%p %s>", cname, (void *)thread, status);
+    str = rb_sprintf("#<%"PRIsVALUE":%p", cname, (void *)thread);
+    if (!th->first_func && th->first_proc) {
+	long i;
+	VALUE v, loc = rb_proc_location(th->first_proc);
+	if (!NIL_P(loc)) {
+	    char sep = '@';
+	    for (i = 0; i < RARRAY_LEN(loc) && !NIL_P(v = RARRAY_AREF(loc, i)); ++i) {
+		rb_str_catf(str, "%c%"PRIsVALUE, sep, v);
+		sep = ':';
+	    }
+	}
+    }
+    rb_str_catf(str, " %s>", status);
     OBJ_INFECT(str, thread);
 
     return str;

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

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