]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
libga68: Make it possible to debug the GC
authorPietro Monteiro <pietro@sociotechnical.xyz>
Sun, 11 Jan 2026 22:25:12 +0000 (17:25 -0500)
committerPietro Monteiro <pietro@sociotechnical.xyz>
Mon, 12 Jan 2026 02:49:03 +0000 (21:49 -0500)
If GC_DEBUG is defined then all-upper-case macros will expand to calls
to the debug variant of collector functions.

So add the configury bit to define GC_DEBUG if the user wants and
switch all `GC_` calls to the corresponding macros.

libga68/ChangeLog:

* configure: Regenerate.
* configure.ac: Add --enable-algol68-gc-debug option and
define GC_DEBUG accordingly.
* ga68-alloc.c (_libga68_realloc): Use the C macro version of
the GC function.
(_libga68_realloc_unchecked): Likewise.
(_libga68_malloc): Likewise.

Signed-off-by: Pietro Monteiro <pietro@sociotechnical.xyz>
libga68/configure
libga68/configure.ac
libga68/ga68-alloc.c

index 63c27939e14ca7e35ab8eb39b81ed982e2f9c603..5d652d6fd81f1a5f1740d4d137a4d91b64aac903 100755 (executable)
@@ -811,6 +811,7 @@ enable_algol68_gc
 with_target_bdw_gc
 with_target_bdw_gc_include
 with_target_bdw_gc_lib
+enable_algol68_gc_debug
 '
       ac_precious_vars='build_alias
 host_alias
@@ -1463,6 +1464,9 @@ Optional Features:
   --disable-symvers       disable symbol versioning for libga68
   --enable-algol68-gc     enable use of Boehm's garbage collector with the GNU
                           Algol runtime
+  --enable-algol68-gc-debug
+                          enable use of Boehm's garbage collector debug
+                          functions with the GNU Algol runtime
 
 Optional Packages:
   --with-PACKAGE[=ARG]    use PACKAGE [ARG=yes]
@@ -12829,7 +12833,7 @@ else
   lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
   lt_status=$lt_dlunknown
   cat > conftest.$ac_ext <<_LT_EOF
-#line 12832 "configure"
+#line 12836 "configure"
 #include "confdefs.h"
 
 #if HAVE_DLFCN_H
@@ -12935,7 +12939,7 @@ else
   lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
   lt_status=$lt_dlunknown
   cat > conftest.$ac_ext <<_LT_EOF
-#line 12938 "configure"
+#line 12942 "configure"
 #include "confdefs.h"
 
 #if HAVE_DLFCN_H
@@ -13532,6 +13536,14 @@ if test "${with_target_bdw_gc_lib+set}" = set; then :
 fi
 
 
+# Check whether --enable-algol68-gc-debug was given.
+if test "${enable_algol68_gc_debug+set}" = set; then :
+  enableval=$enable_algol68_gc_debug;
+else
+  enable_algol68_gc_debug=no
+fi
+
+
 bdw_lib_dir=
 case "$enable_algol68_gc" in
 no)
@@ -13719,6 +13731,17 @@ case $host in
 esac
 
 
+case "$enable_algol68_gc_debug" in
+  no) ;;
+  *)
+    if test "$use_bdw_gc" = no; then
+      as_fn_error $? "GC debugging enabled but GC is not being used" "$LINENO" 5
+    else
+      LIBGA68_GCFLAGS="$LIBGA68_GCFLAGS -DGC_DEBUG"
+    fi
+    ;;
+esac
+
 # Subst some variables used in Makefile.am
 
 
index 20a903ad8d9ed2327ae1660984cc92aab362a613..27a73b0c2eda45b829f3f8d32c289f3d0f356c0f 100644 (file)
@@ -248,6 +248,11 @@ AC_ARG_WITH([target-bdw-gc-lib],
 [AS_HELP_STRING([--with-target-bdw-gc-lib=PATHLIST],
                [specify directories for installed bdw-gc library])])
 
+AC_ARG_ENABLE(algol68-gc-debug,
+[AS_HELP_STRING([--enable-algol68-gc-debug],
+               [enable use of Boehm's garbage collector debug functions
+                with the GNU Algol runtime])],,enable_algol68_gc_debug=no)
+
 bdw_lib_dir=
 case "$enable_algol68_gc" in
 no)
@@ -405,6 +410,17 @@ case $host in
 esac
 AC_SUBST(extra_darwin_ldflags_libga68)
 
+case "$enable_algol68_gc_debug" in
+  no) ;;
+  *)
+    if test "$use_bdw_gc" = no; then
+      AC_MSG_ERROR([GC debugging enabled but GC is not being used])
+    else
+      LIBGA68_GCFLAGS="$LIBGA68_GCFLAGS -DGC_DEBUG"
+    fi
+    ;;
+esac
+
 # Subst some variables used in Makefile.am
 AC_SUBST(LIBGA68_GCFLAGS)
 AC_SUBST(LIBGA68_BOEHM_GC_INCLUDES)
index 5e9f7c2b9203b6611b18cf9ca1da53686c98b15c..1a0b25a098cb27ef431d1a48cafa23959a53c2de 100644 (file)
@@ -58,7 +58,7 @@ _libga68_init_heap (void)
 void *
 _libga68_realloc (void *ptr, size_t size)
 {
-  void *res = (void *) GC_realloc (ptr, size);
+  void *res = (void *) GC_REALLOC (ptr, size);
   if (!res)
     _libga68_abort ("Virtual memory exhausted\n");
   return res;
@@ -67,14 +67,14 @@ _libga68_realloc (void *ptr, size_t size)
 void *
 _libga68_realloc_unchecked (void *ptr, size_t size)
 {
-  void *res = (void *) GC_realloc (ptr, size);
+  void *res = (void *) GC_REALLOC (ptr, size);
   return res;
 }
 
 void *
 _libga68_malloc (size_t size)
 {
-  void *res = (void *) GC_malloc (size);
+  void *res = (void *) GC_MALLOC (size);
   if (!res)
     _libga68_abort ("Virtual memory exhausted\n");
   return res;