From patchwork Sun Jan 11 20:40:44 2026 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pietro Monteiro X-Patchwork-Id: 127854 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from vm01.sourceware.org (localhost [127.0.0.1]) by sourceware.org (Postfix) with ESMTP id 12C924BA2E22 for ; Sun, 11 Jan 2026 20:41:52 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 12C924BA2E22 Authentication-Results: sourceware.org; dkim=pass (2048-bit key, unprotected) header.d=sociotechnical.xyz header.i=@sociotechnical.xyz header.a=rsa-sha256 header.s=fm3 header.b=Pvw+wpFK; dkim=pass (2048-bit key, unprotected) header.d=messagingengine.com header.i=@messagingengine.com header.a=rsa-sha256 header.s=fm2 header.b=BgRL66ix X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from fout-b1-smtp.messagingengine.com (fout-b1-smtp.messagingengine.com [202.12.124.144]) by sourceware.org (Postfix) with ESMTPS id C3FA84BA540B; Sun, 11 Jan 2026 20:41:00 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org C3FA84BA540B Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=sociotechnical.xyz Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=sociotechnical.xyz ARC-Filter: OpenARC Filter v1.0.0 sourceware.org C3FA84BA540B Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=202.12.124.144 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1768164061; cv=none; b=cpzFTC31Q6sJU/g2UUIonHd0W/fR3MYJZIX2FXosIs9bg543rBMdn3Vm1chaka3h+rjXkB0wE9o0hetuccK//rY51tH8H/jMnvDPKrsNlReNOicQ4Rc2QkPbAOOyqTZnCrGbXGtknfKa6nZIwxSv9Nw9fVzDLA1xily1ffXimO0= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1768164061; c=relaxed/simple; bh=FCcIe7kmB7QhGQGi+tqux8WQHqF9hlS1tKVRWfDi1kA=; h=DKIM-Signature:DKIM-Signature:From:To:Subject:Date:Message-ID: MIME-Version; b=gsm4fSmZxMX4zIO1RQVwiXYeVGg+yDf8DZrAI4XOkUyipfHda0NepC8g8wlWGmMLWDU0yUfByBwqhVcD8zZ8ZDPaGAzt6O7fFnXENG0ja6FPIzrMHsF2rRztNR2l3YJRT8e/e+Ppkmgcf0dUesTiYzJJf8hcULFWBzKWUHNLEco= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org C3FA84BA540B Received: from phl-compute-10.internal (phl-compute-10.internal [10.202.2.50]) by mailfout.stl.internal (Postfix) with ESMTP id 4C3F81D00113; Sun, 11 Jan 2026 15:41:00 -0500 (EST) Received: from phl-frontend-04 ([10.202.2.163]) by phl-compute-10.internal (MEProxy); Sun, 11 Jan 2026 15:41:00 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= sociotechnical.xyz; h=cc:cc:content-transfer-encoding :content-type:date:date:from:from:in-reply-to:message-id :mime-version:reply-to:subject:subject:to:to; s=fm3; t= 1768164060; x=1768250460; bh=s/Hp3PcjrR4FcpJpsJiOjyXNnSYu6UxxaaH YMsRweQM=; b=Pvw+wpFK7C5PNCw40Yh9tEL05oweoKXI3tds3qnSDaoG/UeTOii MEPORFklyOpHY5WWmi8h14SKYOArjENXmeet7F1o13jMF+bczWG0eXDTFrzAXM65 HukBKtYzksv9jjamqtNGfhXOtZ/rrl6r7Q0ydJKH7pQrUzZkdenIV/X3cjaQuLtL dfyl+ZMPaligGNW7R73r5xUDFKKdUlPpAqlsZtsaLGym43ONFc/d0p7A4CVz7HQq M87xSBR6uh0SNETfqXbtHWwlUlpZ9iL0PFTD+A8651OA0dTY7Ypfs9s/8YgJR8FX Bt0GO5dbsfboVkcDlQkr5ln4BJNlQBDAUlA== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-transfer-encoding :content-type:date:date:feedback-id:feedback-id:from:from :in-reply-to:message-id:mime-version:reply-to:subject:subject:to :to:x-me-proxy:x-me-sender:x-me-sender:x-sasl-enc; s=fm2; t= 1768164060; x=1768250460; bh=s/Hp3PcjrR4FcpJpsJiOjyXNnSYu6UxxaaH YMsRweQM=; b=BgRL66ixJfN1CWz9RYTJwOGXWG+YXNOOsSCcgtXsmc/8eJKSJEx RWOkGNFk19pB6xZrE68a95HD4Kglv4DRcujLEHRfG/Fd9OYiTlts2Oq0kicCjWkL pkc2THJQAfnmNAe3iS5mubMI6Gq5YO5dEu2SrDfGm0i/BTCWMOWrEU8gp8e3bfNm +/mp+tLyTYzwVFVL59kyA+AXaG9zP5rcy0gFbopoFBYgFpOi0mHYdXgkAUzuPcaH cNpQVqtXnFEXVc8nv3bkqZn3htxqLMVKMKihjyDXknltx4p7zm6G3Xm7QeSPgZlK BYXuAAhgQbfrDzZMuxSheAogAC8U8naupPw== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeefgedrtddtgdduudehheeiucetufdoteggodetrf dotffvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfurfetoffkrfgpnffqhgenuceu rghilhhouhhtmecufedttdenucgfrhhlucfvnfffucdljedtmdenucfjughrpefhvfevuf ffkffoggfgsedtkeertdertddtnecuhfhrohhmpefrihgvthhrohcuofhonhhtvghirhho uceophhivghtrhhosehsohgtihhothgvtghhnhhitggrlhdrgiihiieqnecuggftrfgrth htvghrnhepjedtleevlefgjeeikedtvefgjeehhfefgedugfeiheehueetfffggfeffeef vdefnecuvehluhhsthgvrhfuihiivgeptdenucfrrghrrghmpehmrghilhhfrhhomhepph hivghtrhhosehsohgtihhothgvtghhnhhitggrlhdrgiihiidpnhgspghrtghpthhtohep gedpmhhouggvpehsmhhtphhouhhtpdhrtghpthhtohepghgttgdqphgrthgthhgvshesgh gttgdrghhnuhdrohhrghdprhgtphhtthhopegrlhhgohhlieeksehgtggtrdhgnhhurdho rhhgpdhrtghpthhtohepjhgvmhgrrhgthhesghhnuhdrohhrghdprhgtphhtthhopehpih gvthhrohesshhotghiohhtvggthhhnihgtrghlrdighiii X-ME-Proxy: Feedback-ID: i7f494689:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Sun, 11 Jan 2026 15:40:59 -0500 (EST) From: Pietro Monteiro To: gcc-patches@gcc.gnu.org, algol68@gcc.gnu.org Cc: jemarch@gnu.org, Pietro Monteiro Subject: [PATCH] libga68: Make it possible to debug the GC Date: Sun, 11 Jan 2026 15:40:44 -0500 Message-ID: <20260111204044.982556-1-pietro@sociotechnical.xyz> X-Mailer: git-send-email 2.43.0 MIME-Version: 1.0 X-Spam-Status: No, score=-3.3 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, FROM_SUSPICIOUS_NTLD, FROM_SUSPICIOUS_NTLD_FP, GIT_PATCH_0, KAM_INFOUSMEBIZ, KAM_SOMETLD_ARE_BAD_TLD, PDS_OTHER_BAD_TLD, PROLO_LEO1, RCVD_IN_DNSWL_BLOCKED, RCVD_IN_VALIDITY_RPBL_BLOCKED, RCVD_IN_VALIDITY_SAFE_BLOCKED, SPF_HELO_PASS, SPF_PASS, TXREP, URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on sourceware.org X-BeenThere: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: gcc-patches-bounces~patchwork=sourceware.org@gcc.gnu.org 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 GC_DEBUG if the user wants and swtich all `GC_` calls to the corresponding macros. * configure: Regenerate. * configure.ac: Add --enable-algol68-gc-debug option and define LIBGA68_DEBUG_GC accordingly. * ga68-alloc.c (GC_DEBUG): Define macro if LIBGA68_DEBUG_GC is true. (_libga68_realloc): Use the C macro version of the GC function. (_libga68_realloc_unchecked): Likewise. (_libga68_malloc): Likewise. Signed-off-by: Pietro Monteiro --- libga68/configure | 31 +++++++++++++++++++++++++++++-- libga68/configure.ac | 20 ++++++++++++++++++++ libga68/ga68-alloc.c | 11 ++++++++--- 3 files changed, 57 insertions(+), 5 deletions(-) base-commit: 87222af419eb272d4b66628abda573ba8fcadc77 diff --git a/libga68/configure b/libga68/configure index 63c27939e14..2ecee900035 100755 --- a/libga68/configure +++ b/libga68/configure @@ -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,21 @@ case $host in esac +case "$enable_algol68_gc_debug" in + no) + if test "$use_bdw_gc" = yes; then + LIBGA68_GCFLAGS="$LIBGA68_GCFLAGS -DLIBGA68_DEBUG_GC=0" + fi + ;; + *) + 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 -DLIBGA68_DEBUG_GC=1" + fi + ;; +esac + # Subst some variables used in Makefile.am diff --git a/libga68/configure.ac b/libga68/configure.ac index 20a903ad8d9..c8aa032fba4 100644 --- a/libga68/configure.ac +++ b/libga68/configure.ac @@ -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,21 @@ case $host in esac AC_SUBST(extra_darwin_ldflags_libga68) +case "$enable_algol68_gc_debug" in + no) + if test "$use_bdw_gc" = yes; then + LIBGA68_GCFLAGS="$LIBGA68_GCFLAGS -DLIBGA68_DEBUG_GC=0" + fi + ;; + *) + if test "$use_bdw_gc" = no; then + AC_MSG_ERROR([GC debugging enabled but GC is not being used]) + else + LIBGA68_GCFLAGS="$LIBGA68_GCFLAGS -DLIBGA68_DEBUG_GC=1" + fi + ;; +esac + # Subst some variables used in Makefile.am AC_SUBST(LIBGA68_GCFLAGS) AC_SUBST(LIBGA68_BOEHM_GC_INCLUDES) diff --git a/libga68/ga68-alloc.c b/libga68/ga68-alloc.c index 5e9f7c2b920..77abf592b8f 100644 --- a/libga68/ga68-alloc.c +++ b/libga68/ga68-alloc.c @@ -43,6 +43,11 @@ _libga68_malloc_internal (size_t size) } #if LIBGA68_WITH_GC + +# if LIBGA68_DEBUG_GC +# define GC_DEBUG 1 +#endif + #include void @@ -58,7 +63,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 +72,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;