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

ruby-changes:26001

From: ko1 <ko1@a...>
Date: Fri, 30 Nov 2012 20:50:38 +0900 (JST)
Subject: [ruby-changes:26001] ko1:r38058 (trunk): * thread.c: TracePoint#self returns invoking/exitting thread object

ko1	2012-11-30 20:50:26 +0900 (Fri, 30 Nov 2012)

  New Revision: 38058

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

  Log:
    * thread.c: TracePoint#self returns invoking/exitting thread object
      at thread_begin/end event.
    * test/ruby/test_settracefunc.rb: fix test.

  Modified files:
    trunk/ChangeLog
    trunk/test/ruby/test_settracefunc.rb
    trunk/thread.c

Index: ChangeLog
===================================================================
--- ChangeLog	(revision 38057)
+++ ChangeLog	(revision 38058)
@@ -1,3 +1,10 @@
+Fri Nov 30 20:47:44 2012  Koichi Sasada  <ko1@a...>
+
+	* thread.c: TracePoint#self returns invoking/exitting thread object
+	  at thread_begin/end event.
+
+	* test/ruby/test_settracefunc.rb: fix test.
+
 Fri Nov 30 19:55:17 2012  NAKAMURA Usaku  <usa@r...>
 
 	* test/ruby/memory_status.rb (Memory::Win32): use fiddle instead of dl,
Index: thread.c
===================================================================
--- thread.c	(revision 38057)
+++ thread.c	(revision 38058)
@@ -478,9 +478,9 @@
 		    th->errinfo = Qnil;
 		    th->root_lep = rb_vm_ep_local_ep(proc->block.ep);
 		    th->root_svar = Qnil;
-		    EXEC_EVENT_HOOK(th, RUBY_EVENT_THREAD_BEGIN, proc->block.self, 0, 0, th->self);
+		    EXEC_EVENT_HOOK(th, RUBY_EVENT_THREAD_BEGIN, th->self, 0, 0, Qundef);
 		    th->value = rb_vm_invoke_proc(th, proc, (int)RARRAY_LEN(args), RARRAY_PTR(args), 0);
-		    EXEC_EVENT_HOOK(th, RUBY_EVENT_THREAD_END, proc->block.self, 0, 0, th->self);
+		    EXEC_EVENT_HOOK(th, RUBY_EVENT_THREAD_END, th->self, 0, 0, Qundef);
 		}
 		else {
 		    th->value = (*th->first_func)((void *)args);
Index: test/ruby/test_settracefunc.rb
===================================================================
--- test/ruby/test_settracefunc.rb	(revision 38057)
+++ test/ruby/test_settracefunc.rb	(revision 38058)
@@ -726,15 +726,24 @@
 
   def test_tracepoint_thread
     events = []
+    thread_self = nil
     created_thread = nil
     TracePoint.new(:thread_begin, :thread_end){|tp|
-      events << [Thread.current, tp.event, tp.self]
+      events << [Thread.current,
+                 tp.event,
+                 tp.lineno,  #=> 0
+                 tp.path,    #=> nil
+                 tp.binding, #=> nil
+                 tp.defined_class, #=> nil,
+                 tp.self.class # tp.self return creating/ending thread
+                 ]
     }.enable{
-      created_thread = Thread.new{}
+      created_thread = Thread.new{thread_self = self}
       created_thread.join
     }
-    assert_equal([created_thread, :thread_begin, self], events[0])
-    assert_equal([created_thread, :thread_end, self], events[1])
+    assert_equal(self, thread_self)
+    assert_equal([created_thread, :thread_begin, 0, nil, nil, nil, Thread], events[0])
+    assert_equal([created_thread, :thread_end, 0, nil, nil, nil, Thread], events[1])
     assert_equal(2, events.size)
   end
 end

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

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