1
0
mirror of https://git.FreeBSD.org/ports.git synced 2024-12-26 05:02:18 +00:00

Add four knobs (WITH_THREADING, WITH_PARALLEL_MARK, WITH_REDIRECT and WITH_FULLDEBUG).

Use OPTIONS.
Fix a bug in leak detection.

Submitted by:	green
This commit is contained in:
MANTANI Nobutaka 2004-05-24 14:54:56 +00:00
parent 042a7f935a
commit 7cf2a6a1ca
Notes: svn2git 2021-03-31 03:12:20 +00:00
svn path=/head/; revision=109870
3 changed files with 118 additions and 3 deletions

View File

@ -7,6 +7,7 @@
PORTNAME= boehm-gc
PORTVERSION= 6.2
PORTREVISION= 1
CATEGORIES= devel
MASTER_SITES= http://www.hpl.hp.com/personal/Hans_Boehm/gc/gc_source/
DISTNAME= gc${PORTVERSION:S/.a/alpha/}
@ -18,12 +19,34 @@ USE_LIBTOOL_VER= 13
USE_REINPLACE= yes
HAS_CONFIGURE= yes
INSTALLS_SHLIB= yes
CONFIGURE_ARGS= --prefix=${PREFIX} --disable-threads --enable-cplusplus
MAN3= gc.3
CONFIGURE_ARGS= --prefix=${PREFIX} --enable-cplusplus
OPTIONS= REDIRECT "Define malloc(3)-family replacements" no \
FULLDEBUG "full-debug support (see documentation)" no \
THREADING "POSIX thread support" no \
PARALLEL_MARK "Parallel-thread marking (faster for SMP)" yes
.include <bsd.port.pre.mk>
.ifdef WITH_THREADING
CONFIGURE_ARGS+= --enable-threads=posix --enable-thread-local-alloc
.ifdef WITH_PARALLEL_MARK
CONFIGURE_ARGS+= --enable-parallel-mark
.endif
PKGNAMESUFFIX= +threaded
.else
CONFIGURE_ARGS+= --disable-threads
.endif
.ifdef WITH_REDIRECT
CONFIGURE_ARGS+= --enable-redirect-malloc
PKGNAMESUFFIX:=${PKGNAMESUFFIX}+redirect
.endif
.ifdef WITH_FULLDEBUG
CONFIGURE_ARGS+= --enable-full-debug
PKGNAMESUFFIX:=${PKGNAMESUFFIX}+fulldebug
.endif
MAN3= gc.3
.if ${ARCH} != "i386" && ${ARCH} != "alpha" && ${ARCH} != "amd64"
BROKEN= "Does not compile on !i386 and !alpha and !amd64"
.endif

View File

@ -0,0 +1,82 @@
--- dbg_mlc.c.orig Tue May 13 16:59:49 2003
+++ dbg_mlc.c Wed May 12 20:13:19 2004
@@ -414,6 +414,23 @@
GC_register_displacement((word)sizeof(oh) + offset);
}
+#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
+
# ifdef __STDC__
GC_PTR GC_debug_malloc(size_t lb, GC_EXTRA_PARAMS)
# else
@@ -428,6 +445,13 @@
{
GC_PTR 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_printf1("GC_debug_malloc(%ld) returning NIL (",
(unsigned long) lb);
@@ -789,6 +813,13 @@
register size_t old_sz;
register 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));
if (base == 0) {
GC_err_printf1(
@@ -1094,7 +1125,11 @@
}
#ifdef GC_ADD_CALLER
-# define RA GC_RETURN_ADDR,
+# ifdef GC_RETURN_ADDR_PARENT
+# define RA GC_RETURN_ADDR_PARENT,
+# else
+# define RA GC_RETURN_ADDR,
+# endif
#else
# define RA
#endif
@@ -1102,12 +1137,12 @@
GC_PTR GC_debug_malloc_replacement(lb)
size_t lb;
{
- return GC_debug_malloc(lb, RA "unknown", 0);
+ return GC_debug_malloc(lb, RA NULL, 0);
}
GC_PTR GC_debug_realloc_replacement(p, lb)
GC_PTR p;
size_t lb;
{
- return GC_debug_realloc(p, lb, RA "unknown", 0);
+ return GC_debug_realloc(p, lb, RA NULL, 0);
}

View File

@ -0,0 +1,10 @@
--- include/gc.h.orig Wed Jun 4 17:07:33 2003
+++ include/gc.h Wed May 12 20:03:22 2004
@@ -487,6 +487,7 @@
/* gcc knows how to retrieve return address, but we don't know */
/* how to generate call stacks. */
# define GC_RETURN_ADDR (GC_word)__builtin_return_address(0)
+# define GC_RETURN_ADDR_PARENT (GC_word)__builtin_return_address(1)
# else
/* Just pass 0 for gcc compatibility. */
# define GC_RETURN_ADDR 0