]> granicus.if.org Git - gc/commitdiff
Improve GC error printing atomicity in GC_add_to_black_list_normal/stack
authorIvan Maidanski <ivmai@mail.ru>
Sat, 10 Nov 2012 11:37:06 +0000 (15:37 +0400)
committerIvan Maidanski <ivmai@mail.ru>
Sat, 10 Nov 2012 11:37:06 +0000 (15:37 +0400)
(as well as in GC_print_sig_mask, GC_print_block_list, GC_print_free_list)

* blacklst.c (GC_print_source_ptr): Replace with 3-argument
GC_print_blacklisted_ptr(); rename "p" to "source" argument;
move GC_err_printf calls surrounding GC_print_source_ptr invocation
from GC_add_to_black_list_normal and GC_add_to_black_list_stack;
replace GC_default_print_heap_obj_proc call with the corresponding
GC_err_printf call; merge adjacent GC_err_printf calls into single
one (for output in-line atomicity).
* blacklst.c (GC_add_to_black_list_normal,
GC_add_to_black_list_stack): Replace GC_print_source_ptr (and
surrounding GC_err_printf) call with GC_print_blacklisted_ptr one.
* pthread_stop_world.c (GC_print_sig_mask): Print each blocked signal
on a separate line (replace multiple GC_printf calls with a single one
ending with "\n").
* reclaim.c (GC_print_block_descr): Terminate GC_printf message with
"\n" (for output in-line atomicity).
* reclaim.c (GC_print_block_list): Remove redundant "\n" at the
beginning of GC_printf message (since GC_print_block_descr prints
new-line at the end of the message).
* reclaim.c (GC_print_free_list): Enumerate printed objects starting
from 0 (instead of 1); print information about each free object on
a separate line (replace multiple GC_printf calls with a single one
ending with "\n"); remove "lastBlock" local variable.

blacklst.c
pthread_stop_world.c
reclaim.c

index 0213176ffb8408f59dd8baffdd4466041d3be026..778b2af6da33432253f33f7c6c4b3e345418e5de 100644 (file)
@@ -64,24 +64,26 @@ GC_INNER void GC_default_print_heap_obj_proc(ptr_t p)
 GC_INNER void (*GC_print_heap_obj)(ptr_t p) = GC_default_print_heap_obj_proc;
 
 #ifdef PRINT_BLACK_LIST
-STATIC void GC_print_source_ptr(ptr_t p)
-{
-    ptr_t base = GC_base(p);
+  STATIC void GC_print_blacklisted_ptr(word p, ptr_t source,
+                                       const char *kind_str)
+  {
+    ptr_t base = GC_base(source);
+
     if (0 == base) {
-        if (0 == p) {
-            GC_err_printf("in register");
-        } else {
-            GC_err_printf("in root set");
-        }
+        GC_err_printf("Black listing (%s) %p referenced from %p in %s\n",
+                      kind_str, (ptr_t)p, source,
+                      NULL != source ? "root set" : "register");
     } else {
-        GC_err_printf("in object at ");
         /* FIXME: We can't call the debug version of GC_print_heap_obj  */
         /* (with PRINT_CALL_CHAIN) here because the lock is held and    */
         /* the world is stopped.                                        */
-        GC_default_print_heap_obj_proc(base);
+        GC_err_printf("Black listing (%s) %p referenced from %p in"
+                      " object at %p of appr. %lu bytes\n",
+                      kind_str, (ptr_t)p, source,
+                      base, (unsigned long)GC_size(base));
     }
-}
-#endif
+  }
+#endif /* PRINT_BLACK_LIST */
 
 GC_INNER void GC_bl_init_no_interiors(void)
 {
@@ -183,10 +185,7 @@ GC_INNER void GC_unpromote_black_lists(void)
     if (HDR(p) == 0 || get_pht_entry_from_index(GC_old_normal_bl, index)) {
 #     ifdef PRINT_BLACK_LIST
         if (!get_pht_entry_from_index(GC_incomplete_normal_bl, index)) {
-          GC_err_printf("Black listing (normal) %p referenced from %p ",
-                        (ptr_t)p, source);
-          GC_print_source_ptr(source);
-          GC_err_puts("\n");
+          GC_print_blacklisted_ptr(p, source, "normal");
         }
 #     endif
       set_pht_entry_from_index(GC_incomplete_normal_bl, index);
@@ -207,10 +206,7 @@ GC_INNER void GC_unpromote_black_lists(void)
   if (HDR(p) == 0 || get_pht_entry_from_index(GC_old_stack_bl, index)) {
 #   ifdef PRINT_BLACK_LIST
       if (!get_pht_entry_from_index(GC_incomplete_stack_bl, index)) {
-        GC_err_printf("Black listing (stack) %p referenced from %p ",
-                      (ptr_t)p, source);
-        GC_print_source_ptr(source);
-        GC_err_puts("\n");
+        GC_print_blacklisted_ptr(p, source, "stack");
       }
 #   endif
     set_pht_entry_from_index(GC_incomplete_stack_bl, index);
index 11ebaea3c2566d39c3b7212084e639c47237a8b7..3f288b7c9baf41476dadbcc90a30ad53b60bb1c1 100644 (file)
@@ -70,12 +70,10 @@ int GC_nacl_thread_used[MAX_NACL_GC_THREADS];
 
     if (pthread_sigmask(SIG_BLOCK, NULL, &blocked) != 0)
       ABORT("pthread_sigmask failed");
-    GC_printf("Blocked: ");
     for (i = 1; i < NSIG; i++) {
       if (sigismember(&blocked, i))
-        GC_printf("%d ", i);
+        GC_printf("Signal blocked: %d\n", i);
     }
-    GC_printf("\n");
   }
 #endif /* DEBUG_THREADS */
 
index fd23836470ea5602d1e71f6bf486ed9e874f4296..cf2a4e998f3d033fda6178ba847171dbc890a2e1 100644 (file)
--- a/reclaim.c
+++ b/reclaim.c
@@ -535,10 +535,10 @@ STATIC void GC_print_block_descr(struct hblk *h,
     unsigned n_marks = GC_n_set_marks(hhdr);
 
     if (hhdr -> hb_n_marks != n_marks) {
-      GC_printf("(%u:%u,%u!=%u)", hhdr -> hb_obj_kind, (unsigned)bytes,
-                (unsigned)hhdr -> hb_n_marks, n_marks);
+      GC_printf("(%u:%u,%u!=%u)\n", hhdr->hb_obj_kind, (unsigned)bytes,
+                (unsigned)hhdr->hb_n_marks, n_marks);
     } else {
-      GC_printf("(%u:%u,%u)", hhdr -> hb_obj_kind,
+      GC_printf("(%u:%u,%u)\n", hhdr->hb_obj_kind,
                 (unsigned)bytes, n_marks);
     }
     bytes += HBLKSIZE-1;
@@ -557,7 +557,7 @@ void GC_print_block_list(void)
     pstats.number_of_blocks = 0;
     pstats.total_bytes = 0;
     GC_apply_to_all_blocks(GC_print_block_descr, (word)&pstats);
-    GC_printf("\nblocks = %lu, bytes = %lu\n",
+    GC_printf("blocks= %lu, bytes= %lu\n",
               (unsigned long)pstats.number_of_blocks,
               (unsigned long)pstats.total_bytes);
 }
@@ -567,16 +567,12 @@ void GC_print_free_list(int kind, size_t sz_in_granules)
 {
     struct obj_kind * ok = &GC_obj_kinds[kind];
     ptr_t flh = ok -> ok_freelist[sz_in_granules];
-    struct hblk *lastBlock = 0;
     int n;
 
-    for (n = 1; flh; n++) {
+    for (n = 0; flh; n++) {
         struct hblk *block = HBLKPTR(flh);
-        if (block != lastBlock) {
-          GC_printf("\nIn heap block at %p:\n\t", (void *)block);
-          lastBlock = block;
-        }
-        GC_printf("%d: %p;", n, flh);
+        GC_printf("Free object in heap block %p [%d]: %p\n",
+                  (void *)block, n, flh);
         flh = obj_link(flh);
     }
 }