summaryrefslogtreecommitdiff
path: root/dbg_mlc.c
diff options
context:
space:
mode:
authorivmai <ivmai>2009-10-22 17:00:59 +0200
committerIvan Maidanski <ivmai@mail.ru>2011-07-26 19:06:51 +0200
commitc06769bfb05036d0ab57114d3b4568d8f743ad49 (patch)
treea0715b580d2c0bd3b565c6fa42109e2671bc6f0c /dbg_mlc.c
parentbad4c7acb6060861cd4be55968c1f58b2026a747 (diff)
2009-10-22 Ivan Maidanski <ivmai@mail.ru>
* alloc.c (GC_collection_in_progress): Move the prototype to gc_priv.h. * gc_dlopen.c (GC_collection_in_progress): Ditto. * pthread_support.c (GC_collection_in_progress): Ditto. * misc.c (GC_init_parallel): Ditto. * pthread_support.c (GC_init_parallel): Ditto. * win32_threads.c (GC_init_parallel): Ditto. * darwin_stop_world.c (GC_thr_init): Ditto. * misc.c (GC_thr_init): Ditto. * pthread_stop_world.c (GC_thr_init): Ditto. * pthread_support.c (GC_thr_init): Ditto. * blacklst.c (GC_clear_bl, GC_copy_bl, GC_number_stack_black_listed): Make STATIC. * dbg_mlc.c (GC_print_obj, GC_make_closure, GC_debug_invoke_finalizer): Ditto. * malloc.c (GC_alloc_large_and_clear): Ditto. * mark.c (GC_push_selected, GC_push_marked1, GC_push_marked2, GC_push_marked4, GC_push_marked, GC_push_next_marked, GC_push_next_marked_dirty, GC_push_next_marked_uncollectable): Ditto. * misc.c (GC_clear_stack_inner): Ditto. * os_dep.c (GC_repeat_read, GC_default_push_other_roots): Ditto. * darwin_stop_world.c (FindTopOfStack): Make static; define only if not DARWIN_DONT_PARSE_STACK. * dbg_mlc.c (GC_debug_free_inner): Define only if DBG_HDRS_ALL. * dyn_load.c (GC_repeat_read): Remove unused prototype. * include/private/gc_pmark.h (GC_find_start): Ditto. * misc.c (GC_read, GC_register_finalizer_no_order): Ditto. * dyn_load.c (GC_segment_is_thread_stack): Add prototype (only if THREADS). * dyn_load.c (GC_register_main_static_data): Define only if DYNAMIC_LOADING. * finalize.c (GC_enqueue_all_finalizers): Remove unnecessary tail "return" statement. * gc_dlopen.c (GC_SOLARIS_THREADS): Don't recognize (since implies GC_PTHREADS). * include/gc.h: Fix a typo. * include/gc_inline.h (GC_ASSERT): Define (if not defined) since the header is public. * include/gc_inline.h (GC_generic_malloc_many): New public function declaration. * mallocx.c (GC_generic_malloc_many): Make public. * include/private/gc_priv.h (GC_INNER): Use visibility attribute (if available). * include/private/gc_priv.h (GC_EXTERN): Define using GC_INNER. * include/private/gc_priv.h: Include atomic_ops.h if THREADS and MPROTECT_VDB. * os_dep.c: Don't include atomic_ops.h * win32_threads.c: Ditto. * include/private/gc_priv.h (GC_push_selected, GC_push_regs, GC_push_marked, GC_number_stack_black_listed, GC_alloc_large_and_clear, GC_reclaim_or_delete_all, GC_generic_malloc_many, GC_make_closure, GC_debug_invoke_finalizer, GC_print_obj, GC_page_was_ever_dirty): Remove the prototype. * mark.c (GC_page_was_ever_dirty): Add prototype (only if PROC_VDB). * include/private/gc_priv.h (GC_push_next_marked_dirty, GC_push_next_marked, GC_push_next_marked_uncollectable): Move the prototype to mark.c. * include/private/gc_priv.h (GC_is_static_root): Declare only if not THREADS. * include/private/gc_priv.h (GC_free_inner): Declare only if THREADS. * include/private/gc_priv.h (GC_debug_free_inner): Declare only if THREADS and DBG_HDRS_ALL. * include/private/gc_priv.h (GC_markers): Declare GC_markers only if PARALLEL_MARK. * include/private/gc_priv.h (GC_register_main_static_data): Move the prototype to misc.c. * mach_dep.c (GC_push_regs): Make STATIC; define only along with HAVE_PUSH_REGS definition. * mach_dep.c (GC_clear_stack_inner): Replace K&R-style function definition with the ANSI C one. * mark.c (GC_started_thread_while_stopped): Declared only if not GNU C. * win32_threads.c (GC_started_thread_while_stopped): Don't define if GNU C. * mark.c (GC_mark_from): Avoid unbalanced brackets in #if-#else-#endif blocks. * mark_rts.c (GC_is_static_root): Define only if not THREADS. * os_dep.c (GC_get_stack_base): Make public (for OpenBSD). * os_dep.c (GC_page_was_ever_dirty): Comment out the function except for PROC_VDB. * tests/test.c (main): Don't reference GC_print_obj, GC_make_closure, GC_debug_invoke_finalizer, GC_page_was_ever_dirty, GC_is_fresh (in GC_noop). * thread_local_alloc.c: Don't include "gc_inline.h". * win32_threads.c (GC_write_fault_handler): Declare only if MPROTECT_VDB.
Diffstat (limited to 'dbg_mlc.c')
-rw-r--r--dbg_mlc.c119
1 files changed, 57 insertions, 62 deletions
diff --git a/dbg_mlc.c b/dbg_mlc.c
index bbcb44f..9f8f2c1 100644
--- a/dbg_mlc.c
+++ b/dbg_mlc.c
@@ -23,23 +23,23 @@
#include <string.h>
void GC_default_print_heap_obj_proc(ptr_t p);
-GC_API void GC_CALL GC_register_finalizer_no_order
- (void * obj, GC_finalization_proc fn, void * cd,
- GC_finalization_proc *ofn, void * *ocd);
+GC_API void GC_CALL GC_register_finalizer_no_order(void * obj,
+ GC_finalization_proc fn, void * cd,
+ GC_finalization_proc *ofn, void * *ocd);
#ifndef SHORT_DBG_HDRS
-/* Check whether object with base pointer p has debugging info */
-/* p is assumed to point to a legitimate object in our part */
-/* of the heap. */
-/* This excludes the check as to whether the back pointer is */
-/* odd, which is added by the GC_HAS_DEBUG_INFO macro. */
-/* Note that if DBG_HDRS_ALL is set, uncollectable objects */
-/* on free lists may not have debug information set. Thus it's */
-/* not always safe to return TRUE, even if the client does */
-/* its part. */
-GC_bool GC_has_other_debug_info(ptr_t p)
-{
+ /* Check whether object with base pointer p has debugging info */
+ /* p is assumed to point to a legitimate object in our part */
+ /* of the heap. */
+ /* This excludes the check as to whether the back pointer is */
+ /* odd, which is added by the GC_HAS_DEBUG_INFO macro. */
+ /* Note that if DBG_HDRS_ALL is set, uncollectable objects */
+ /* on free lists may not have debug information set. Thus it's */
+ /* not always safe to return TRUE, even if the client does */
+ /* its part. */
+ GC_bool GC_has_other_debug_info(ptr_t p)
+ {
oh * ohdr = (oh *)p;
ptr_t body = (ptr_t)(ohdr + 1);
word sz = GC_size((ptr_t) ohdr);
@@ -57,7 +57,7 @@ GC_bool GC_has_other_debug_info(ptr_t p)
return(TRUE);
}
return(FALSE);
-}
+ }
#endif
#ifdef KEEP_BACK_PTRS
@@ -305,11 +305,11 @@ STATIC ptr_t GC_store_debug_info_inner(ptr_t p, word sz, char *string,
#endif
#ifndef SHORT_DBG_HDRS
-/* Check the object with debugging info at ohdr */
-/* return NIL if it's OK. Else return clobbered */
-/* address. */
-STATIC ptr_t GC_check_annotated_obj(oh *ohdr)
-{
+ /* Check the object with debugging info at ohdr */
+ /* return NIL if it's OK. Else return clobbered */
+ /* address. */
+ STATIC ptr_t GC_check_annotated_obj(oh *ohdr)
+ {
ptr_t body = (ptr_t)(ohdr + 1);
word gc_sz = GC_size((ptr_t)ohdr);
if (ohdr -> oh_sz + DEBUG_BYTES > gc_sz) {
@@ -323,10 +323,10 @@ STATIC ptr_t GC_check_annotated_obj(oh *ohdr)
}
if (((word *)body)[SIMPLE_ROUNDED_UP_WORDS(ohdr -> oh_sz)]
!= (END_FLAG ^ (word)body)) {
- return((ptr_t)((word *)body + SIMPLE_ROUNDED_UP_WORDS(ohdr -> oh_sz)));
+ return((ptr_t)((word *)body + SIMPLE_ROUNDED_UP_WORDS(ohdr->oh_sz)));
}
return(0);
-}
+ }
#endif /* !SHORT_DBG_HDRS */
STATIC GC_describe_type_fn GC_describe_type_fns[MAXOBJKINDS] = {0};
@@ -378,7 +378,9 @@ STATIC void GC_print_type(ptr_t p)
}
}
-void GC_print_obj(ptr_t p)
+/* Print a human-readable description of the object to stderr. p points */
+/* to somewhere inside an object with the debugging info. */
+STATIC void GC_print_obj(ptr_t p)
{
oh * ohdr = (oh *)GC_base(p);
@@ -407,11 +409,11 @@ STATIC void GC_debug_print_heap_obj_proc(ptr_t p)
}
#ifndef SHORT_DBG_HDRS
-/* Use GC_err_printf and friends to print a description of the object */
-/* whose client-visible address is p, and which was smashed at */
-/* clobbered_addr. */
-STATIC void GC_print_smashed_obj(ptr_t p, ptr_t clobbered_addr)
-{
+ /* Use GC_err_printf and friends to print a description of the object */
+ /* whose client-visible address is p, and which was smashed at */
+ /* clobbered_addr. */
+ STATIC void GC_print_smashed_obj(ptr_t p, ptr_t clobbered_addr)
+ {
oh * ohdr = (oh *)GC_base(p);
GC_ASSERT(I_DONT_HOLD_LOCK());
@@ -431,7 +433,7 @@ STATIC void GC_print_smashed_obj(ptr_t p, ptr_t clobbered_addr)
(unsigned long)(ohdr -> oh_sz));
PRINT_CALL_CHAIN(ohdr);
}
-}
+ }
#endif
#ifndef SHORT_DBG_HDRS
@@ -519,15 +521,15 @@ GC_API void * GC_CALL GC_debug_malloc_atomic_ignore_off_page(size_t lb,
return (GC_store_debug_info(result, (word)lb, s, (word)i));
}
-# ifdef DBG_HDRS_ALL
-/*
- * An allocation function for internal use.
- * Normally internally allocated objects do not have debug information.
- * But in this case, we need to make sure that all objects have debug
- * headers.
- * We assume debugging was started in collector initialization,
- * and we already hold the GC lock.
- */
+#ifdef DBG_HDRS_ALL
+ /*
+ * An allocation function for internal use.
+ * Normally internally allocated objects do not have debug information.
+ * But in this case, we need to make sure that all objects have debug
+ * headers.
+ * We assume debugging was started in collector initialization,
+ * and we already hold the GC lock.
+ */
void * GC_debug_generic_malloc_inner(size_t lb, int k)
{
void * result = GC_generic_malloc_inner(lb + DEBUG_BYTES, k);
@@ -554,7 +556,7 @@ GC_API void * GC_CALL GC_debug_malloc_atomic_ignore_off_page(size_t lb,
ADD_CALL_CHAIN(result, GC_RETURN_ADDR);
return (GC_store_debug_info_inner(result, (word)lb, "INTERNAL", (word)0));
}
-# endif
+#endif
#ifdef STUBBORN_ALLOC
GC_API void * GC_CALL GC_debug_malloc_stubborn(size_t lb, GC_EXTRA_PARAMS)
@@ -617,14 +619,10 @@ GC_API void * GC_CALL GC_debug_malloc_stubborn(size_t lb, GC_EXTRA_PARAMS)
}
/*ARGSUSED*/
-GC_API void GC_CALL GC_debug_change_stubborn(void *p)
-{
-}
+GC_API void GC_CALL GC_debug_change_stubborn(void *p) {}
/*ARGSUSED*/
-GC_API void GC_CALL GC_debug_end_stubborn_change(void *p)
-{
-}
+GC_API void GC_CALL GC_debug_end_stubborn_change(void *p) {}
#endif /* !STUBBORN_ALLOC */
@@ -687,8 +685,8 @@ GC_API void * GC_CALL GC_debug_malloc_uncollectable(size_t lb, GC_EXTRA_PARAMS)
}
#ifdef ATOMIC_UNCOLLECTABLE
-void * GC_debug_malloc_atomic_uncollectable(size_t lb, GC_EXTRA_PARAMS)
-{
+ void * GC_debug_malloc_atomic_uncollectable(size_t lb, GC_EXTRA_PARAMS)
+ {
void * result =
GC_malloc_atomic_uncollectable(lb + UNCOLLECTABLE_DEBUG_BYTES);
@@ -705,7 +703,7 @@ void * GC_debug_malloc_atomic_uncollectable(size_t lb, GC_EXTRA_PARAMS)
}
ADD_CALL_CHAIN(result, ra);
return (GC_store_debug_info(result, (word)lb, s, (word)i));
-}
+ }
#endif /* ATOMIC_UNCOLLECTABLE */
GC_API void GC_CALL GC_debug_free(void * p)
@@ -766,13 +764,10 @@ GC_API void GC_CALL GC_debug_free(void * p)
} /* !GC_find_leak */
}
-#ifdef THREADS
-
-void GC_free_inner(void * p);
-
-/* Used internally; we assume it's called correctly. */
-void GC_debug_free_inner(void * p)
-{
+#if defined(THREADS) && defined(DBG_HDRS_ALL)
+ /* Used internally; we assume it's called correctly. */
+ void GC_debug_free_inner(void * p)
+ {
ptr_t base = GC_base(p);
GC_ASSERT((ptr_t)p - (ptr_t)base == sizeof(oh));
# ifndef SHORT_DBG_HDRS
@@ -780,7 +775,7 @@ void GC_debug_free_inner(void * p)
((oh *)base) -> oh_sz = GC_size(base);
# endif
GC_free_inner(base);
-}
+ }
#endif
GC_API void * GC_CALL GC_debug_realloc(void * p, size_t lb, GC_EXTRA_PARAMS)
@@ -914,7 +909,6 @@ STATIC void GC_check_heap_block(struct hblk *hbp, word dummy)
}
}
-
/* This assumes that all accessible objects are marked, and that */
/* I hold the allocation lock. Normally called by collector. */
STATIC void GC_check_heap_proc(void)
@@ -933,7 +927,7 @@ struct closure {
void * cl_data;
};
-void * GC_make_closure(GC_finalization_proc fn, void * data)
+STATIC void * GC_make_closure(GC_finalization_proc fn, void * data)
{
struct closure * result =
# ifdef DBG_HDRS_ALL
@@ -948,10 +942,11 @@ void * GC_make_closure(GC_finalization_proc fn, void * data)
return((void *)result);
}
-void GC_CALLBACK GC_debug_invoke_finalizer(void * obj, void * data)
+/* An auxiliary fns to make finalization work correctly with displaced */
+/* pointers introduced by the debugging allocators. */
+STATIC void GC_CALLBACK GC_debug_invoke_finalizer(void * obj, void * data)
{
struct closure * cl = (struct closure *) data;
-
(*(cl -> cl_fn))((void *)((char *)obj + sizeof(oh)), cl -> cl_data);
}
@@ -1093,8 +1088,8 @@ GC_API void GC_CALL GC_debug_register_finalizer_ignore_self
GC_register_finalizer_ignore_self(base, 0, 0, &my_old_fn, &my_old_cd);
} else {
GC_register_finalizer_ignore_self(base, GC_debug_invoke_finalizer,
- GC_make_closure(fn,cd), &my_old_fn,
- &my_old_cd);
+ GC_make_closure(fn,cd), &my_old_fn,
+ &my_old_cd);
}
store_old(obj, my_old_fn, (struct closure *)my_old_cd, ofn, ocd);
}