From 25748c78cf94d1b068a1db1a1634d815c001af6f Mon Sep 17 00:00:00 2001 From: "Greg J. Badros" Date: Mon, 27 Sep 1999 23:30:36 +0000 Subject: [PATCH] * stacks.c: Avoid compiler warning re: unitialized var. * scmconfig.h.in: Added DEBUG_FREELIST * pairs.h: Fix macro that was not do-while(0) sandwiched. * gc.h, gc.c: Added scm_gc_set_debug_check_freelist_x, scm_map_free_list --- libguile/gc.c | 16 +++++++++++++++- libguile/gc.h | 2 ++ libguile/pairs.h | 6 +++--- libguile/scmconfig.h.in | 3 +++ libguile/stacks.c | 8 ++++---- 5 files changed, 27 insertions(+), 8 deletions(-) diff --git a/libguile/gc.c b/libguile/gc.c index a00c89228..98a5edc66 100644 --- a/libguile/gc.c +++ b/libguile/gc.c @@ -290,14 +290,28 @@ scm_check_freelist () } static int scm_debug_check_freelist = 0; + +SCM_PROC (s_gc_set_debug_check_freelist_x, "gc-set-debug-check-freelist!", 1, 0, 0, scm_gc_set_debug_check_freelist_x); +SCM +scm_gc_set_debug_check_freelist_x (SCM flag) +{ + SCM_ASSERT(SCM_BOOL_T == flag || SCM_BOOL_F == flag, + flag, 1, s_gc_set_debug_check_freelist_x); + scm_debug_check_freelist = (SCM_BOOL_T==flag)? 1: 0; + return SCM_UNSPECIFIED; +} + + SCM scm_debug_newcell (void) { SCM new; scm_newcell_count++; - if (scm_debug_check_freelist) + if (scm_debug_check_freelist) { scm_check_freelist (); + scm_gc(); + } /* The rest of this is supposed to be identical to the SCM_NEWCELL macro. */ diff --git a/libguile/gc.h b/libguile/gc.h index ea964beb4..c3416cbb6 100644 --- a/libguile/gc.h +++ b/libguile/gc.h @@ -76,7 +76,9 @@ extern long scm_mallocated; extern unsigned long scm_mtrigger; #ifdef DEBUG_FREELIST +extern SCM scm_map_free_list (void); extern SCM scm_debug_newcell (void); +extern SCM scm_gc_set_debug_check_freelist_x (SCM flag); #endif diff --git a/libguile/pairs.h b/libguile/pairs.h index 3b5661041..9e4b9ed26 100644 --- a/libguile/pairs.h +++ b/libguile/pairs.h @@ -145,10 +145,10 @@ typedef SCM huge *SCMPTR; #ifdef DEBUG_FREELIST -#define SCM_NEWCELL(_into) (_into = scm_debug_newcell ()) +#define SCM_NEWCELL(_into) do { _into = scm_debug_newcell (); } while (0) #else #define SCM_NEWCELL(_into) \ - { \ + do { \ if (SCM_IMP(scm_freelist)) \ _into = scm_gc_for_newcell();\ else \ @@ -157,7 +157,7 @@ typedef SCM huge *SCMPTR; scm_freelist = SCM_CDR(scm_freelist);\ ++scm_cells_allocated; \ } \ - } + } while(0) #endif diff --git a/libguile/scmconfig.h.in b/libguile/scmconfig.h.in index a1cc26e8d..1057f4e53 100644 --- a/libguile/scmconfig.h.in +++ b/libguile/scmconfig.h.in @@ -98,6 +98,9 @@ #undef DEBUG_EXTENSIONS #undef READER_EXTENSIONS +/* Define this if you want to debug the free list (helps w/ GC bugs) */ +#undef DEBUG_FREELIST + /* Define this if your system defines S_ISLNK in sys/stat.h */ #undef HAVE_S_ISLNK diff --git a/libguile/stacks.c b/libguile/stacks.c index f7d8afc7e..51d89c9ac 100644 --- a/libguile/stacks.c +++ b/libguile/stacks.c @@ -440,7 +440,7 @@ scm_make_stack (args) SCM args; { int n, maxp, size; - scm_debug_frame *dframe; + scm_debug_frame *dframe = scm_last_debug_frame; scm_info_frame *iframe; long offset = 0; SCM stack, id; @@ -455,9 +455,9 @@ scm_make_stack (args) /* Extract a pointer to the innermost frame of whatever object scm_make_stack was given. */ - if (obj == SCM_BOOL_T) - dframe = scm_last_debug_frame; - else + /* just use dframe == scm_last_debug_frame + (from initialization of dframe, above) if obj is #t */ + if (obj != SCM_BOOL_T) { SCM_ASSERT (SCM_NIMP (obj), obj, SCM_ARG1, s_make_stack); if (SCM_DEBUGOBJP (obj))