[uim-commit] r1626 - branches/r5rs/sigscheme

yamaken at freedesktop.org yamaken at freedesktop.org
Tue Sep 27 17:06:06 PDT 2005


Author: yamaken
Date: 2005-09-27 17:06:04 -0700 (Tue, 27 Sep 2005)
New Revision: 1626

Modified:
   branches/r5rs/sigscheme/config.h
   branches/r5rs/sigscheme/debug.c
   branches/r5rs/sigscheme/io.c
   branches/r5rs/sigscheme/operations-siod.c
   branches/r5rs/sigscheme/sigscheme.c
   branches/r5rs/sigscheme/sigscheme.h
   branches/r5rs/sigscheme/sigschemeinternal.h
Log:
* sigscheme/config.h
  - (SCM_DEBUG, SCM_DEBUG_GC, SCM_DEBUG_PARSER): New macro
* sigscheme/sigscheme.h
  - (SCM_CDBG, SCM_DBG): New macro
  - (SigScm_EnablePredefinedDebugCategories): New function decl
* sigscheme/sigschemeinternal.h
  - (CDBG, DBG): New macro
  - (DEBUG_PARSER): Reflect SCM_DEBUG_PARSER
  - (DEBUG_GC): Reflect SCM_DEBUG_GC
* sigscheme/debug.c
  - (SigScm_EnablePredefinedDebugCategories): New function
  - (SigScm_Debug): Make SCM_DBG_DEVEL sensitive
* sigscheme/sigscheme.c
  - (SigScm_Initialize_internal): Improve debug categories
    configuration
* sigscheme/operations-siod.c
  - (SigScm_SetVerboseLevel): Add
    SigScm_EnablePredefinedDebugCategories() invocation
* sigscheme/io.c
  - (SigScm_load_internal): Replace SigScm_CategorizedDebug() with CDBG()


Modified: branches/r5rs/sigscheme/config.h
===================================================================
--- branches/r5rs/sigscheme/config.h	2005-09-27 21:44:39 UTC (rev 1625)
+++ branches/r5rs/sigscheme/config.h	2005-09-28 00:06:04 UTC (rev 1626)
@@ -71,6 +71,13 @@
 #define SCM_VOLATILE_OUTPUT     0  /* always flush files on write */
 
 /*===========================================================================
+  Debugging
+===========================================================================*/
+#define SCM_DEBUG               1  /* enable debugging features */
+#define SCM_DEBUG_GC            0  /* enable GC debugging */
+#define SCM_DEBUG_PARSER        0  /* enable parser debugging */
+
+/*===========================================================================
   Dependency Resolution
 ===========================================================================*/
 #if SCM_COMPAT_SIOD

Modified: branches/r5rs/sigscheme/debug.c
===================================================================
--- branches/r5rs/sigscheme/debug.c	2005-09-27 21:44:39 UTC (rev 1625)
+++ branches/r5rs/sigscheme/debug.c	2005-09-28 00:06:04 UTC (rev 1626)
@@ -142,15 +142,30 @@
     va_end(va);
 }
 
+int SigScm_EnablePredefinedDebugCategories(void)
+{
+    debug_mask = (debug_mask
+#if SCM_DEBUG_PARSER
+                  | SCM_DBG_PARSER
+#endif
+#if SCM_DEBUG_GC
+                  | SCM_DBG_GC
+#endif
+                  );
+
+    return debug_mask;
+}
+
 void SigScm_Debug(const char *msg, ...)
 {
     va_list va;
 
     va_start(va, msg);
-    vfprintf(stderr, msg, va);
+    if (debug_mask & SCM_DBG_DEVEL) {
+        vfprintf(stderr, msg, va);
+        fprintf(stderr, "\n");
+    }
     va_end(va);
-
-    fprintf(stderr, "\n");
 }
 
 void SigScm_Display(ScmObj obj)

Modified: branches/r5rs/sigscheme/io.c
===================================================================
--- branches/r5rs/sigscheme/io.c	2005-09-27 21:44:39 UTC (rev 1625)
+++ branches/r5rs/sigscheme/io.c	2005-09-28 00:06:04 UTC (rev 1626)
@@ -436,7 +436,7 @@
     ScmObj filepath     = SCM_FALSE;
     char  *c_filepath   = create_valid_path(c_filename);
 
-    SigScm_CategorizedDebug(SCM_DBG_FILE, "loading %s", c_filename);
+    CDBG((SCM_DBG_FILE, "loading %s", c_filename));
 
     /* sanity check */
     if (!c_filepath)
@@ -453,7 +453,7 @@
 
     ScmOp_close_input_port(port);
 
-    SigScm_CategorizedDebug(SCM_DBG_FILE, "done.");
+    CDBG((SCM_DBG_FILE, "done."));
 
     return SCM_TRUE;
 }

Modified: branches/r5rs/sigscheme/operations-siod.c
===================================================================
--- branches/r5rs/sigscheme/operations-siod.c	2005-09-27 21:44:39 UTC (rev 1625)
+++ branches/r5rs/sigscheme/operations-siod.c	2005-09-28 00:06:04 UTC (rev 1626)
@@ -191,4 +191,7 @@
     if (level > 5)
         level = 5;
     SigScm_SetDebugCategories(sscm_debug_mask_tbl[level]);
+
+    if (level >= 2)
+        SigScm_EnablePredefinedDebugCategories();
 }

Modified: branches/r5rs/sigscheme/sigscheme.c
===================================================================
--- branches/r5rs/sigscheme/sigscheme.c	2005-09-27 21:44:39 UTC (rev 1625)
+++ branches/r5rs/sigscheme/sigscheme.c	2005-09-28 00:06:04 UTC (rev 1626)
@@ -92,7 +92,8 @@
 
 static void SigScm_Initialize_internal(void)
 {
-    SigScm_SetDebugCategories(SCM_DBG_ERRMSG | SCM_DBG_BACKTRACE);
+    SigScm_SetDebugCategories(SCM_DBG_ERRMSG | SCM_DBG_BACKTRACE
+                              | SCM_DBG_DEVEL | SCM_DBG_OTHER);
 
     /*=======================================================================
       Etc Variable Initialization
@@ -439,6 +440,8 @@
     scm_return_value = SCM_NULL;
     SigScm_SetVerboseLevel(2);
 #endif
+
+    SigScm_EnablePredefinedDebugCategories();
 }
 
 void SigScm_Finalize()

Modified: branches/r5rs/sigscheme/sigscheme.h
===================================================================
--- branches/r5rs/sigscheme/sigscheme.h	2005-09-27 21:44:39 UTC (rev 1625)
+++ branches/r5rs/sigscheme/sigscheme.h	2005-09-28 00:06:04 UTC (rev 1626)
@@ -60,6 +60,15 @@
 #define SCM_NOINLINE
 #endif /* __GNUC__ */
 
+/* RFC: better names for the debug printing */
+#if SCM_DEBUG
+#define SCM_CDBG(args) (SigScm_CategorizedDebug args)
+#define SCM_DBG(args)  (SigScm_Debug args)
+#else /* SCM_DEBUG */
+#define SCM_CDBG(args)
+#define SCM_DBG(args)
+#endif /* SCM_DEBUG */
+
 int SigScm_Die(const char *msg, const char *filename, int line); /* error.c */
 #define SCM_ASSERT(cond) \
     (cond ? 0 : SigScm_Die("assertion failed.", __FILE__, __LINE__))
@@ -564,6 +573,7 @@
 /* debug.c */
 int  SigScm_DebugCategories(void);
 void SigScm_SetDebugCategories(int categories);
+int  SigScm_EnablePredefinedDebugCategories(void);
 void SigScm_CategorizedDebug(int category, const char *msg, ...);
 void SigScm_Debug(const char *msg, ...);
 void SigScm_Display(ScmObj obj);

Modified: branches/r5rs/sigscheme/sigschemeinternal.h
===================================================================
--- branches/r5rs/sigscheme/sigschemeinternal.h	2005-09-27 21:44:39 UTC (rev 1625)
+++ branches/r5rs/sigscheme/sigschemeinternal.h	2005-09-28 00:06:04 UTC (rev 1626)
@@ -84,8 +84,8 @@
    Macro Declarations
 =======================================*/
 /* Debugging Flags */
-#define DEBUG_PARSER  0
-#define DEBUG_GC      0
+#define DEBUG_PARSER  SCM_DEBUG_PARSER
+#define DEBUG_GC      SCM_DEBUG_GC
 
 /* FreeCell Handling Macros */
 #define SCM_FREECELLP(a)     (SCM_TYPE(a) == ScmFreeCell)
@@ -146,6 +146,9 @@
 #define C_POINTERP     SCM_C_POINTERP
 #define C_FUNCPOINTERP SCM_C_FUNCPOINTERP
 
+#define CDBG           SCM_CDBG
+#define DBG            SCM_DBG
+
 /*
  * Abbrev name for these constants are not provided since it involves some
  * consistency problems and confusions. Use the canonical names always.



More information about the uim-commit mailing list