From: Ivan Maidanski Date: Thu, 8 Nov 2012 04:01:51 +0000 (+0400) Subject: Use GC_log_printf for logging instead of GC_[err_]printf X-Git-Tag: gc7_4_0~167 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=4e533165f59772b6d6afd58216650e003b53d6d1;p=platform%2Fupstream%2Flibgc.git Use GC_log_printf for logging instead of GC_[err_]printf * 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. --- diff --git a/backgraph.c b/backgraph.c index 6bd2621..74437ba 100644 --- a/backgraph.c +++ b/backgraph.c @@ -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) { diff --git a/darwin_stop_world.c b/darwin_stop_world.c index 8851893..8fb1d33 100644 --- a/darwin_stop_world.c +++ b/darwin_stop_world.c @@ -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; } diff --git a/include/private/gc_priv.h b/include/private/gc_priv.h index 5b8d8a8..3eca2b1 100644 --- a/include/private/gc_priv.h +++ b/include/private/gc_priv.h @@ -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) diff --git a/malloc.c b/malloc.c index 4469a3b..c10f60a 100644 --- 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); diff --git a/thread_local_alloc.c b/thread_local_alloc.c index 7924a78..e4fdc85 100644 --- a/thread_local_alloc.c +++ b/thread_local_alloc.c @@ -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;