ruby-changes:49152
From: nobu <ko1@a...>
Date: Fri, 15 Dec 2017 12:07:14 +0900 (JST)
Subject: [ruby-changes:49152] nobu:r61268 (trunk): thread.c: debug messages
nobu 2017-12-15 12:07:10 +0900 (Fri, 15 Dec 2017) New Revision: 61268 https://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=61268 Log: thread.c: debug messages * thread.c (terminate_all): fix funtion name in debug messages. * thread.c (terminate_all, thread_join_sleep, thread_join): show the status of the target thread in debug messages. Modified files: trunk/thread.c Index: thread.c =================================================================== --- thread.c (revision 61267) +++ thread.c (revision 61268) @@ -98,6 +98,7 @@ static double timeofday(void); https://github.com/ruby/ruby/blob/trunk/thread.c#L98 static int rb_threadptr_dead(rb_thread_t *th); static void rb_check_deadlock(rb_vm_t *vm); static int rb_threadptr_pending_interrupt_empty_p(const rb_thread_t *th); +static const char *thread_status_name(rb_thread_t *th, int detail); #define eKillSignal INT2FIX(0) #define eTerminateSignal INT2FIX(1) @@ -450,12 +451,15 @@ terminate_all(rb_vm_t *vm, const rb_thre https://github.com/ruby/ruby/blob/trunk/thread.c#L451 list_for_each(&vm->living_threads, th, vmlt_node) { if (th != main_thread) { - thread_debug("terminate_i: %p\n", (void *)th); + thread_debug("terminate_all: begin (thid: %"PRI_THREAD_ID", status: %s)\n", + thread_id_str(th), thread_status_name(th, TRUE)); rb_threadptr_pending_interrupt_enque(th, eTerminateSignal); rb_threadptr_interrupt(th); + thread_debug("terminate_all: end (thid: %"PRI_THREAD_ID", status: %s)\n", + thread_id_str(th), thread_status_name(th, TRUE)); } else { - thread_debug("terminate_i: main thread (%p)\n", (void *)th); + thread_debug("terminate_all: main thread (%p)\n", (void *)th); } } } @@ -890,8 +894,8 @@ thread_join_sleep(VALUE arg) https://github.com/ruby/ruby/blob/trunk/thread.c#L894 } sleep_wait_for_interrupt(th, limit - now, 0); } - thread_debug("thread_join: interrupted (thid: %"PRI_THREAD_ID")\n", - thread_id_str(target_th)); + thread_debug("thread_join: interrupted (thid: %"PRI_THREAD_ID", status: %s)\n", + thread_id_str(target_th), thread_status_name(target_th, TRUE)); } return Qtrue; } @@ -913,7 +917,8 @@ thread_join(rb_thread_t *target_th, doub https://github.com/ruby/ruby/blob/trunk/thread.c#L917 arg.waiting = th; arg.delay = delay; - thread_debug("thread_join (thid: %"PRI_THREAD_ID")\n", thread_id_str(target_th)); + thread_debug("thread_join (thid: %"PRI_THREAD_ID", status: %s)\n", + thread_id_str(target_th), thread_status_name(target_th, TRUE)); if (target_th->status != THREAD_KILLED) { rb_thread_list_t list; @@ -926,8 +931,8 @@ thread_join(rb_thread_t *target_th, doub https://github.com/ruby/ruby/blob/trunk/thread.c#L931 } } - thread_debug("thread_join: success (thid: %"PRI_THREAD_ID")\n", - thread_id_str(target_th)); + thread_debug("thread_join: success (thid: %"PRI_THREAD_ID", status: %s)\n", + thread_id_str(target_th), thread_status_name(target_th, TRUE)); if (target_th->ec->errinfo != Qnil) { VALUE err = target_th->ec->errinfo; @@ -935,6 +940,9 @@ thread_join(rb_thread_t *target_th, doub https://github.com/ruby/ruby/blob/trunk/thread.c#L940 if (FIXNUM_P(err)) { switch (err) { case INT2FIX(TAG_FATAL): + thread_debug("thread_join: terminated (thid: %"PRI_THREAD_ID", status: %s)\n", + thread_id_str(target_th), thread_status_name(target_th, TRUE)); + /* OK. killed. */ break; default: -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/