summaryrefslogtreecommitdiff
path: root/blacklst.c
diff options
context:
space:
mode:
authorIvan Maidanski <ivmai@mail.ru>2012-11-10 15:37:06 +0400
committerIvan Maidanski <ivmai@mail.ru>2012-11-10 15:37:06 +0400
commit3d84e7d8f7985b2a13d0ac591be37dbed847388a (patch)
treeff50bc82fa25c6c6adce444f511ab42d96748f55 /blacklst.c
parent8d246e305d0579bf29d26a21f80a9aa9d88d77be (diff)
downloadbdwgc-3d84e7d8f7985b2a13d0ac591be37dbed847388a.tar.gz
Improve GC error printing atomicity in GC_add_to_black_list_normal/stack
(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.
Diffstat (limited to 'blacklst.c')
-rw-r--r--blacklst.c36
1 files changed, 16 insertions, 20 deletions
diff --git a/blacklst.c b/blacklst.c
index 0213176f..778b2af6 100644
--- a/blacklst.c
+++ b/blacklst.c
@@ -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);