GC_INNER void GC_start_debugging(void) { DCL_LOCK_STATE; LOCK(); GC_start_debugging_inner(); UNLOCK(); }
/* we already hold the GC lock. */ GC_INNER void * GC_debug_generic_malloc_inner(size_t lb, int k) { void * result = GC_generic_malloc_inner(lb + DEBUG_BYTES, k); if (result == 0) { GC_err_printf("GC internal allocation (%lu bytes) returning NULL\n", (unsigned long) lb); return(0); } if (!GC_debugging_started) { GC_start_debugging_inner(); } ADD_CALL_CHAIN(result, GC_RETURN_ADDR); return (GC_store_debug_info_inner(result, (word)lb, "INTERNAL", 0)); }
GC_INNER void * GC_debug_generic_malloc_inner_ignore_off_page(size_t lb, int k) { void * result; GC_ASSERT(I_HOLD_LOCK()); result = GC_generic_malloc_inner_ignore_off_page( SIZET_SAT_ADD(lb, DEBUG_BYTES), k); if (NULL == result) { GC_err_printf("GC internal allocation (%lu bytes) returning NULL\n", (unsigned long) lb); return(0); } if (!GC_debugging_started) { GC_start_debugging_inner(); } ADD_CALL_CHAIN(result, GC_RETURN_ADDR); return (GC_store_debug_info_inner(result, (word)lb, "INTERNAL", 0)); }
/* start the debugging mode (if not yet), and return displaced pointer. */ static void *store_debug_info(void *p, size_t lb, const char *fn, GC_EXTRA_PARAMS) { void *result; DCL_LOCK_STATE; if (NULL == p) { GC_err_printf("%s(%lu) returning NULL (%s:%d)\n", fn, (unsigned long)lb, s, i); return NULL; } LOCK(); if (!GC_debugging_started) GC_start_debugging_inner(); ADD_CALL_CHAIN(p, ra); result = GC_store_debug_info_inner(p, (word)lb, s, i); UNLOCK(); return result; }