diff options
author | Mike McGaughey <mmcg@cs.monash.edu.au> | 2013-07-21 15:47:53 +0400 |
---|---|---|
committer | Ivan Maidanski <ivmai@mail.ru> | 2013-08-25 15:22:48 +0400 |
commit | 97d71091e67380b6812dd8673c337cbf20410996 (patch) | |
tree | 84d6bf1b0a945a4044b254716b0d106996b9e595 /dbg_mlc.c | |
parent | 4872305d33db1c36a1cf7bf4ee157810d34cb6aa (diff) | |
download | bdwgc-97d71091e67380b6812dd8673c337cbf20410996.tar.gz |
FreeBSD New ports collection for boehm-gc v7.1
(Imported from freebsd-ports/devel/boehm-gc)
(Apply commit 2cdf7ec from 'release-7_2' branch.)
* dbg_mlc.c (GC_caller_func_offset): New function (empty unless
FreeBSD).
* dbg_mlc.c (GC_debug_malloc, GC_debug_realloc): Invoke
GC_caller_func_offset if GC_ADD_CALLER.
* include/private/gc_priv.h (GC_DBG_RA): Define to GC_RETURN_ADDR_PARENT
(if the latter is defined).
* dbg_mlc.c (GC_debug_malloc_replacement,
GC_debug_realloc_replacement): Pass NULL (instead of "unknown") to
GC_debug_malloc/realloc.
* doc/gc.man: Add "PORT INFORMATION".
* dyn_load.c (ElfW): Define for FreeBSD.
* include/private/gcconfig.h (X86_64, IA64, POWERPC, ARM32,
mach_type_known, ALIGNMENT, OS_TYPE, DYNAMIC_LOADING, HEURISTIC2,
etext, SEARCH_FOR_DATA_START): Likewise.
* os_dep.c (old_bus_act): Likewise.
* include/gc.h (GC_RETURN_ADDR_PARENT): New macro.
* os_dep.c (GC_set_and_save_fault_handler): Invoke sigaction(SIGBUS)
for FreeBSD.
* os_dep.c (AIM): Define before include machine/trap.h if FreeBSD/ppc.
* os_dep.c (CODE_OK): Define to test "code" against EXC_DSI (instead
of BUS_PAGE_FAULT) if FreeBSD/ppc.
Conflicts:
Makefile.in
configure
dbg_mlc.c
include/gc.h
include/private/gcconfig.h
os_dep.c
Diffstat (limited to 'dbg_mlc.c')
-rw-r--r-- | dbg_mlc.c | 36 |
1 files changed, 34 insertions, 2 deletions
@@ -485,6 +485,23 @@ GC_API void GC_CALL GC_debug_register_displacement(size_t offset) UNLOCK(); } +#if defined(__FreeBSD__) +#include <dlfcn.h> +static void GC_caller_func_offset(ad, symp, offp) +const GC_word ad; +const char **symp; +int *offp; +{ + Dl_info caller; + if (dladdr((const void *)ad, &caller) && caller.dli_sname != NULL) { + *symp = caller.dli_sname; + *offp = (const char *)ad - (const char *)caller.dli_saddr; + } +} +#else +#define GC_caller_func(ad, symp, offp) +#endif + GC_API void * GC_CALL GC_debug_malloc(size_t lb, GC_EXTRA_PARAMS) { void * result; @@ -493,6 +510,13 @@ GC_API void * GC_CALL GC_debug_malloc(size_t lb, GC_EXTRA_PARAMS) /* later be successfully passed to free(). We always do the latter. */ result = GC_malloc(lb + DEBUG_BYTES); +#ifdef GC_ADD_CALLER + if (s == NULL) { + GC_caller_func_offset(ra, &s, &i); + if (s == NULL) + s = "unknown"; + } +#endif if (result == 0) { GC_err_printf("GC_debug_malloc(%lu) returning NULL (%s:%d)\n", (unsigned long)lb, s, i); @@ -841,6 +865,14 @@ GC_API void * GC_CALL GC_debug_realloc(void * p, size_t lb, GC_EXTRA_PARAMS) void * base; void * result; hdr * hhdr; + +#ifdef GC_ADD_CALLER + if (s == NULL) { + GC_caller_func_offset(ra, &s, &i); + if (s == NULL) + s = "unknown"; + } +#endif if (p == 0) return(GC_debug_malloc(lb, OPT_RA s, i)); @@ -1177,10 +1209,10 @@ GC_API void GC_CALL GC_debug_register_finalizer_ignore_self GC_API void * GC_CALL GC_debug_malloc_replacement(size_t lb) { - return GC_debug_malloc(lb, GC_DBG_RA "unknown", 0); + return GC_debug_malloc(lb, GC_DBG_RA NULL, 0); } GC_API void * GC_CALL GC_debug_realloc_replacement(void *p, size_t lb) { - return GC_debug_realloc(p, lb, GC_DBG_RA "unknown", 0); + return GC_debug_realloc(p, lb, GC_DBG_RA NULL, 0); } |