mirror of
https://git.savannah.gnu.org/git/guile.git
synced 2025-05-20 11:40:18 +02:00
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.
This commit is contained in:
parent
f7a1ab8b94
commit
5aec3cf407
1 changed files with 14 additions and 6 deletions
|
@ -37,10 +37,13 @@
|
||||||
* Scheme guardians should be simple and friendly, not like the greedy
|
* Scheme guardians should be simple and friendly, not like the greedy
|
||||||
* monsters we had...
|
* 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.
|
* FIXME: This is currently not thread-safe.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
/* Uncomment the following line to debug guardian finalization. */
|
||||||
|
/* #define DEBUG_GUARDIANS 1 */
|
||||||
|
|
||||||
#ifdef HAVE_CONFIG_H
|
#ifdef HAVE_CONFIG_H
|
||||||
# include <config.h>
|
# include <config.h>
|
||||||
#endif
|
#endif
|
||||||
|
@ -109,7 +112,7 @@ finalize_guarded (GC_PTR ptr, GC_PTR finalizer_data)
|
||||||
guardian_list = SCM_CDR (PTR2SCM (finalizer_data));
|
guardian_list = SCM_CDR (PTR2SCM (finalizer_data));
|
||||||
proxied_finalizer = SCM_CAR (PTR2SCM (finalizer_data));
|
proxied_finalizer = SCM_CAR (PTR2SCM (finalizer_data));
|
||||||
|
|
||||||
#if 0
|
#ifdef DEBUG_GUARDIANS
|
||||||
printf ("finalizing guarded %p (%u guardians)\n",
|
printf ("finalizing guarded %p (%u guardians)\n",
|
||||||
ptr, scm_to_uint (scm_length (guardian_list)));
|
ptr, scm_to_uint (scm_length (guardian_list)));
|
||||||
#endif
|
#endif
|
||||||
|
@ -130,8 +133,13 @@ finalize_guarded (GC_PTR ptr, GC_PTR finalizer_data)
|
||||||
t_guardian *g;
|
t_guardian *g;
|
||||||
|
|
||||||
if (SCM_WEAK_PAIR_CAR_DELETED_P (guardian_list))
|
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));
|
g = GUARDIAN_DATA (SCM_CAR (guardian_list));
|
||||||
if (g->live == 0)
|
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,
|
GC_REGISTER_FINALIZER_NO_ORDER (ptr, finalizer, finalizer_data,
|
||||||
&prev_finalizer, &prev_finalizer_data);
|
&prev_finalizer, &prev_finalizer_data);
|
||||||
|
|
||||||
#if 0
|
#ifdef DEBUG_GUARDIANS
|
||||||
printf (" reinstalled proxied finalizer %p for %p\n", finalizer, ptr);
|
printf (" reinstalled proxied finalizer %p for %p\n", finalizer, ptr);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
#if 0
|
#ifdef DEBUG_GUARDIANS
|
||||||
printf ("end of finalize (%p)\n", ptr);
|
printf ("end of finalize (%p)\n", ptr);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue