From 20c3237d148f3972c1c5d63eb99ee3fc6dc561f5 Mon Sep 17 00:00:00 2001 From: nobu Date: Fri, 15 Dec 2017 03:07:10 +0000 Subject: [PATCH] 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. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61268 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- thread.c | 22 +++++++++++++++------- 1 file changed, 15 insertions(+), 7 deletions(-) diff --git a/thread.c b/thread.c index 5ff387cd43..baa50ea388 100644 --- a/thread.c +++ b/thread.c @@ -98,6 +98,7 @@ static double timeofday(void); 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_thread_t *main_thread) 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) } 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, double delay) 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, double delay) } } - 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, double delay) 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: