diff options
author | Ludovic Courtès <ludo@gnu.org> | 2009-02-28 16:27:19 +0100 |
---|---|---|
committer | Ludovic Courtès <ludo@gnu.org> | 2009-02-28 16:27:19 +0100 |
commit | 5aec3cf4078f773903807677e8142a3ded337404 (patch) | |
tree | 9ed662c648924d5710b9586b32150650fdfaf7d7 | |
parent | f7a1ab8b946e03f6ad5ccdecba5e8d69b3ce0a1a (diff) | |
download | guile-5aec3cf4078f773903807677e8142a3ded337404.tar.gz |
Add `DEBUG_GUARDIANS' macro for guardian finalization debugging.
* libguile/guardians.c (finalize_guarded): Use `#ifdef DEBUG_GUARDIANS'
instead of `#if 0'. Add " guardian for %p vanished\n" debugging
statement.
-rw-r--r-- | libguile/guardians.c | 20 |
1 files changed, 14 insertions, 6 deletions
diff --git a/libguile/guardians.c b/libguile/guardians.c index 43edf818d..73730fc45 100644 --- a/libguile/guardians.c +++ b/libguile/guardians.c @@ -37,10 +37,13 @@ * Scheme guardians should be simple and friendly, not like the greedy * monsters we had... * - * Rewritten for the Boehm-Wiser GC by Ludovic Courtès. + * Rewritten for the Boehm-Demers-Weiser GC by Ludovic Courtès. * FIXME: This is currently not thread-safe. */ +/* Uncomment the following line to debug guardian finalization. */ +/* #define DEBUG_GUARDIANS 1 */ + #ifdef HAVE_CONFIG_H # include <config.h> #endif @@ -109,7 +112,7 @@ finalize_guarded (GC_PTR ptr, GC_PTR finalizer_data) guardian_list = SCM_CDR (PTR2SCM (finalizer_data)); proxied_finalizer = SCM_CAR (PTR2SCM (finalizer_data)); -#if 0 +#ifdef DEBUG_GUARDIANS printf ("finalizing guarded %p (%u guardians)\n", ptr, scm_to_uint (scm_length (guardian_list))); #endif @@ -130,8 +133,13 @@ finalize_guarded (GC_PTR ptr, GC_PTR finalizer_data) t_guardian *g; if (SCM_WEAK_PAIR_CAR_DELETED_P (guardian_list)) - /* The guardian itself vanished in the meantime. */ - continue; + { + /* The guardian itself vanished in the meantime. */ +#ifdef DEBUG_GUARDIANS + printf (" guardian for %p vanished\n", ptr); +#endif + continue; + } g = GUARDIAN_DATA (SCM_CAR (guardian_list)); if (g->live == 0) @@ -166,12 +174,12 @@ finalize_guarded (GC_PTR ptr, GC_PTR finalizer_data) GC_REGISTER_FINALIZER_NO_ORDER (ptr, finalizer, finalizer_data, &prev_finalizer, &prev_finalizer_data); -#if 0 +#ifdef DEBUG_GUARDIANS printf (" reinstalled proxied finalizer %p for %p\n", finalizer, ptr); #endif } -#if 0 +#ifdef DEBUG_GUARDIANS printf ("end of finalize (%p)\n", ptr); #endif } |