* stacks.c: Avoid compiler warning re: unitialized var.
authorGreg J. Badros <gjb@cs.washington.edu>
Mon, 27 Sep 1999 23:30:36 +0000 (23:30 +0000)
committerGreg J. Badros <gjb@cs.washington.edu>
Mon, 27 Sep 1999 23:30:36 +0000 (23:30 +0000)
* 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
libguile/gc.h
libguile/pairs.h
libguile/scmconfig.h.in
libguile/stacks.c

index a00c892..98a5edc 100644 (file)
@@ -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.  */
index ea964be..c3416cb 100644 (file)
@@ -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
 
 \f
index 3b56610..9e4b9ed 100644 (file)
@@ -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
 
 \f
index a1cc26e..1057f4e 100644 (file)
@@ -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
 
index f7d8afc..51d89c9 100644 (file)
@@ -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))