]> granicus.if.org Git - gc/commitdiff
Add debug messages on thread suspend/resume (Win32)
authorIvan Maidanski <ivmai@mail.ru>
Mon, 16 Sep 2019 07:41:11 +0000 (10:41 +0300)
committerIvan Maidanski <ivmai@mail.ru>
Mon, 16 Sep 2019 07:41:11 +0000 (10:41 +0300)
The messages are similar to the ones for Darwin.

* win32_threads.c [DEBUG_THREADS] (GC_suspend): Log a message that the
thread is going to be suspended.
* win32_threads.c [DEBUG_THREADS] (GC_start_world): Log a message
whether the thread is going to be resumed or it cannot be resumed
because it is not suspended.

win32_threads.c

index a9fe66bdbfa6af387d922641506e7a87dc323e36..3a44f56363ee87a0eb9e8873ac4dc868fd20ea84 100644 (file)
@@ -1288,6 +1288,9 @@ STATIC void GC_suspend(GC_thread t)
 #     endif
       return;
     }
+# endif
+# ifdef DEBUG_THREADS
+    GC_log_printf("Suspending 0x%x\n", (int)t->id);
 # endif
   GC_acquire_dirty_lock();
 # ifdef MSWINCE
@@ -1420,6 +1423,9 @@ GC_INNER void GC_start_world(void)
     for (i = 0; i <= my_max; i++) {
       GC_thread t = (GC_thread)(dll_thread_table + i);
       if (t -> suspended) {
+#       ifdef DEBUG_THREADS
+          GC_log_printf("Resuming 0x%x\n", (int)t->id);
+#       endif
         GC_ASSERT(t -> stack_base != 0 && t -> id != thread_id);
         if (ResumeThread(THREAD_HANDLE(t)) == (DWORD)-1)
           ABORT("ResumeThread failed");
@@ -1427,6 +1433,7 @@ GC_INNER void GC_start_world(void)
         if (GC_on_thread_event)
           GC_on_thread_event(GC_EVENT_THREAD_UNSUSPENDED, THREAD_HANDLE(t));
       }
+      /* Else thread is unregistered or not suspended. */
     }
   } else {
     GC_thread t;
@@ -1435,6 +1442,9 @@ GC_INNER void GC_start_world(void)
     for (i = 0; i < THREAD_TABLE_SZ; i++) {
       for (t = GC_threads[i]; t != 0; t = t -> tm.next) {
         if (t -> suspended) {
+#         ifdef DEBUG_THREADS
+            GC_log_printf("Resuming 0x%x\n", (int)t->id);
+#         endif
           GC_ASSERT(t -> stack_base != 0 && t -> id != thread_id);
           if (ResumeThread(THREAD_HANDLE(t)) == (DWORD)-1)
             ABORT("ResumeThread failed");
@@ -1442,6 +1452,11 @@ GC_INNER void GC_start_world(void)
           t -> suspended = FALSE;
           if (GC_on_thread_event)
             GC_on_thread_event(GC_EVENT_THREAD_UNSUSPENDED, THREAD_HANDLE(t));
+        } else {
+#         ifdef DEBUG_THREADS
+            GC_log_printf("Not resuming thread 0x%x as it is not suspended\n",
+                          (int)t->id);
+#         endif
         }
       }
     }