Use GC_log_printf for logging instead of GC_[err_]printf
authorIvan Maidanski <ivmai@mail.ru>
Thu, 8 Nov 2012 04:01:51 +0000 (08:01 +0400)
committerIvan Maidanski <ivmai@mail.ru>
Thu, 8 Nov 2012 12:05:45 +0000 (16:05 +0400)
* backgraph.c (GC_print_back_graph_stats): Use GC_err_printf instead
of GC_printf (since invoked GC_print_heap_obj uses GC_err_printf).
* darwin_stop_world.c (GC_FindTopOfStack): Replace GC_printf with
GC_log_printf (inside DEBUG_THREADS blocks).
* include/private/gc_priv.h (GC_printf, GC_log_printf): Add comment.
* malloc.c (GC_free): Replace GC_err_printf with GC_log_printf (inside
LOG_ALLOCS block).
* thread_local_alloc.c (GC_malloc): Likewise.

backgraph.c
darwin_stop_world.c
include/private/gc_priv.h
malloc.c
thread_local_alloc.c

index 6bd2621..74437ba 100644 (file)
@@ -462,8 +462,9 @@ void GC_print_back_graph_stats(void)
             (unsigned long) GC_gc_no, (unsigned long)GC_max_height);
   if (GC_max_height > GC_max_max_height) {
     GC_max_max_height = GC_max_height;
-    GC_printf("The following unreachable object is last in a longest chain "
-              "of unreachable objects:\n");
+    GC_err_printf(
+            "The following unreachable object is last in a longest chain "
+            "of unreachable objects:\n");
     GC_print_heap_obj(GC_deepest_obj);
   }
   if (GC_print_stats) {
index 8851893..8fb1d33 100644 (file)
@@ -69,7 +69,7 @@ GC_INNER ptr_t GC_FindTopOfStack(unsigned long stack_start)
   }
 
 # ifdef DEBUG_THREADS
-    /* GC_printf("FindTopOfStack start at sp = %p\n", frame); */
+    /* GC_log_printf("FindTopOfStack start at sp = %p\n", frame); */
 # endif
   while (frame->savedSP != 0) {
     /* if there are no more stack frames, stop */
@@ -83,7 +83,7 @@ GC_INNER ptr_t GC_FindTopOfStack(unsigned long stack_start)
       break; /* if the next LR is bogus, stop */
   }
 # ifdef DEBUG_THREADS
-    /* GC_printf("FindTopOfStack finish at sp = %p\n", frame); */
+    /* GC_log_printf("FindTopOfStack finish at sp = %p\n", frame); */
 # endif
   return (ptr_t)frame;
 }
index 5b8d8a8..3eca2b1 100644 (file)
@@ -2017,6 +2017,7 @@ GC_API void GC_CALL GC_noop1(word);
 #endif
 
 /* Logging and diagnostic output:       */
+/* GC_printf is used typically on client explicit print requests.       */
 GC_API_PRIV void GC_printf(const char * format, ...)
                         GC_ATTR_FORMAT_PRINTF(1, 2);
                         /* A version of printf that doesn't allocate,   */
@@ -2029,6 +2030,8 @@ GC_API_PRIV void GC_err_printf(const char * format, ...)
 #if defined(__cplusplus) && defined(SYMBIAN)
   extern "C" {
 #endif
+/* Logging routine.  Typically called only if GC_print_stats.  It is    */
+/* recommended to put "\n" at 'format' string end (for atomicity).      */
 GC_API_PRIV void GC_log_printf(const char * format, ...)
                         GC_ATTR_FORMAT_PRINTF(1, 2);
 #if defined(__cplusplus) && defined(SYMBIAN)
index 4469a3b..c10f60a 100644 (file)
--- a/malloc.c
+++ b/malloc.c
@@ -494,7 +494,7 @@ GC_API void GC_CALL GC_free(void * p)
     if (p == 0) return;
         /* Required by ANSI.  It's not my fault ...     */
 #   ifdef LOG_ALLOCS
-      GC_err_printf("GC_free(%p), GC: %lu\n", p, (unsigned long)GC_gc_no);
+      GC_log_printf("GC_free(%p), GC: %lu\n", p, (unsigned long)GC_gc_no);
 #   endif
     h = HBLKPTR(p);
     hhdr = HDR(h);
index 7924a78..e4fdc85 100644 (file)
@@ -175,7 +175,7 @@ GC_API void * GC_CALL GC_malloc(size_t bytes)
     GC_FAST_MALLOC_GRANS(result, granules, tiny_fl, DIRECT_GRANULES,
                          NORMAL, GC_core_malloc(bytes), obj_link(result)=0);
 #   ifdef LOG_ALLOCS
-      GC_err_printf("GC_malloc(%lu) = %p, GC: %lu\n",
+      GC_log_printf("GC_malloc(%lu) = %p, GC: %lu\n",
                     (unsigned long)bytes, result, (unsigned long)GC_gc_no);
 #   endif
     return result;