[project @ 2001-01-26 14:40:18 by simonmar]
[ghc-hetmet.git] / ghc / rts / RtsFlags.c
index fb205cc..f8b8e99 100644 (file)
@@ -1,5 +1,5 @@
 /* -----------------------------------------------------------------------------
- * $Id: RtsFlags.c,v 1.29 2000/04/03 15:54:50 simonmar Exp $
+ * $Id: RtsFlags.c,v 1.36 2001/01/24 15:41:30 simonmar Exp $
  *
  * (c) The AQUA Project, Glasgow University, 1994-1997
  * (c) The GHC Team, 1998-1999
 #include "RtsFlags.h"
 #include "RtsUtils.h"
 #include "BlockAlloc.h"
+#include "Itimer.h"            /* CS_MIN_MILLISECS */
 #include "Profiling.h"
 
 #if defined(PROFILING) 
 #include "Itimer.h"
 #endif
 
-#if HAVE_STDLIB_H
-#include <stdlib.h>
-#endif
-
-#ifdef HAVE_STRING_H
-#include <string.h>
+#ifdef HAVE_CTYPE_H
+#include <ctype.h>
 #endif
 
 extern struct RTS_FLAGS RtsFlags;
@@ -70,7 +67,8 @@ char *debug_opts_strs[] = {
   "DEBUG (-D256): stable\n",
   "DEBUG (-D512): prof\n",
   "DEBUG (-D1024): gran\n",
-  "DEBUG (-D2048): par\n"
+  "DEBUG (-D2048): par\n",
+  "DEBUG (-D4096): linker\n"
 };
 
 char *debug_opts_prefix[] = {
@@ -86,6 +84,7 @@ char *debug_opts_prefix[] = {
   "_!", /* prof */
   "_=", /* gran */
   "_=" /* par */
+  "_*" /* linker */
 };
 
 #if defined(GRAN)
@@ -230,6 +229,9 @@ void initRtsFlagsDefaults(void)
     RtsFlags.GcFlags.steps              = 2;
 
     RtsFlags.GcFlags.squeezeUpdFrames  = rtsTrue;
+#ifdef RTS_GTK_FRONTPANEL
+    RtsFlags.GcFlags.frontpanel         = rtsFalse;
+#endif
 
 #if defined(PROFILING) || defined(PAR)
     RtsFlags.CcFlags.doCostCentres     = 0;
@@ -238,12 +240,6 @@ void initRtsFlagsDefaults(void)
 #ifdef PROFILING
     RtsFlags.ProfFlags.doHeapProfile = rtsFalse;
     RtsFlags.ProfFlags.showCCSOnException = rtsFalse;
-
-    RtsFlags.ProfFlags.ccSelector    = NULL;
-    RtsFlags.ProfFlags.modSelector   = NULL;
-    RtsFlags.ProfFlags.descrSelector = NULL;
-    RtsFlags.ProfFlags.typeSelector  = NULL;
-    RtsFlags.ProfFlags.kindSelector  = NULL;
 #elif defined(DEBUG)
     RtsFlags.ProfFlags.doHeapProfile = rtsFalse;
 #endif
@@ -276,7 +272,6 @@ void initRtsFlagsDefaults(void)
 
 #if defined(GRAN)
     /* ToDo: check defaults for GranSim and GUM */
-    RtsFlags.ConcFlags.ctxtSwitchTime  = CS_MIN_MILLISECS;  /* In milliseconds */
     RtsFlags.GcFlags.maxStkSize                = (1024 * 1024) / sizeof(W_);
     RtsFlags.GcFlags.initialStkSize    = 1024 / sizeof(W_);
 
@@ -361,7 +356,7 @@ usage_text[] = {
 "",
 "The following run time system options are available:",
 "",
-"  -? -f    Prints this message and exits; the program is not executed",
+"  -?       Prints this message and exits; the program is not executed",
 "",
 "  -K<size> Sets the maximum stack size (default 1M)  Egs: -K32k   -K512k",
 "  -k<size> Sets the initial thread stack size (default 1k)  Egs: -K4k   -K2m",
@@ -372,8 +367,13 @@ usage_text[] = {
 "  -m<n>%   Minimum % of heap which must be available (default 3%)",
 "  -G<n>    Number of generations (default: 2)",
 "  -T<n>    Number of steps in younger generations (default: 2)",
-"  -s<file> Summary GC statistics   (default file: <program>.stat)",
-"  -S<file> Detailed GC statistics  (with -Sstderr going to stderr)",
+"",
+"  -t<file> One-line GC statistics  (default file: <program>.stat)",
+"  -s<file> Summary  GC statistics  (with -Sstderr going to stderr)",
+"  -S<file> Detailed GC statistics",
+#ifdef RTS_GTK_FRONTPANEL
+"  -f       Display front panel (requires X11 & GTK+)",
+#endif
 "",
 "",
 "  -Z       Don't squeeze out update frames on stack overflow",
@@ -412,7 +412,7 @@ usage_text[] = {
 #endif
 "  -C<secs>  Context-switch interval in seconds",
 "                (0 or no argument means switch as often as possible)",
-"                the default is .01 sec; resolution is .01 sec",
+"                the default is .02 sec; resolution is .02 sec",
 #if defined(SMP)
 "  -N<n>     Use <n> OS threads (default: 1)",
 #endif
@@ -574,7 +574,6 @@ error = rtsTrue;
 
              /* =========== GENERAL ========================== */
              case '?':
-             case 'f':
                error = rtsTrue;
                break;
 
@@ -664,23 +663,37 @@ error = rtsTrue;
                }
                break;
 
+#ifdef RTS_GTK_FRONTPANEL
+             case 'f':
+                 RtsFlags.GcFlags.frontpanel = rtsTrue;
+                 break;
+#endif
+
              case 'S':
-               RtsFlags.GcFlags.giveStats ++;
+                 RtsFlags.GcFlags.giveStats = VERBOSE_GC_STATS;
+                 goto stats;
 
              case 's':
-               RtsFlags.GcFlags.giveStats ++;
+                 RtsFlags.GcFlags.giveStats = SUMMARY_GC_STATS;
+                 goto stats;
+
+             case 't':
+                 RtsFlags.GcFlags.giveStats = ONELINE_GC_STATS;
+                 goto stats;
+
+           stats:
 #ifdef PAR
-               /* Opening all those files would almost certainly fail... */
-               RtsFlags.ParFlags.ParStats.Full = rtsTrue;
-               RtsFlags.GcFlags.statsFile = stderr; /* temporary; ToDo: rm */
+                 /* Opening all those files would almost certainly fail... */
+                 RtsFlags.ParFlags.ParStats.Full = rtsTrue;
+                 RtsFlags.GcFlags.statsFile = stderr; /* temporary; ToDo: rm */
 #else
-               RtsFlags.GcFlags.statsFile
-                 = open_stats_file(arg, *argc, argv,
-                       *rts_argc, rts_argv, STAT_FILENAME_FMT);
-
-               if (RtsFlags.GcFlags.statsFile == NULL) error = rtsTrue;
+                 RtsFlags.GcFlags.statsFile
+                     = open_stats_file(arg, *argc, argv,
+                                       *rts_argc, rts_argv, STAT_FILENAME_FMT);
+                 
+                 if (RtsFlags.GcFlags.statsFile == NULL) error = rtsTrue;
 #endif
-               break;
+                 break;
 
              case 'Z':
                RtsFlags.GcFlags.squeezeUpdFrames = rtsFalse;
@@ -752,7 +765,7 @@ error = rtsTrue;
                    /* Convert to milliseconds */
                    cst = (I_) ((atof(rts_argv[arg]+2) * 1000));
                    cst = (cst / CS_MIN_MILLISECS) * CS_MIN_MILLISECS;
-                   if (cst < CS_MIN_MILLISECS)
+                   if (cst != 0 && cst < CS_MIN_MILLISECS)
                        cst = CS_MIN_MILLISECS;
 
                    RtsFlags.ConcFlags.ctxtSwitchTime = cst;
@@ -1794,18 +1807,19 @@ set_debug_options(nat n) {
     if ((n>>i)&1) {
       fprintf(stderr, debug_opts_strs[i]);
       switch (i) {
-        case 0: RtsFlags.DebugFlags.scheduler   = rtsTrue; break;
-        case 1: RtsFlags.DebugFlags.evaluator   = rtsTrue; break;
-        case 2: RtsFlags.DebugFlags.codegen     = rtsTrue; break;
-        case 3: RtsFlags.DebugFlags.weak        = rtsTrue; break;
-        case 4: RtsFlags.DebugFlags.gccafs      = rtsTrue; break;
-        case 5: RtsFlags.DebugFlags.gc          = rtsTrue; break;
-        case 6: RtsFlags.DebugFlags.block_alloc = rtsTrue; break;
-        case 7: RtsFlags.DebugFlags.sanity      = rtsTrue; break;
-        case 8: RtsFlags.DebugFlags.stable      = rtsTrue; break;
-        case 9: RtsFlags.DebugFlags.prof        = rtsTrue; break;
-        case 10:  RtsFlags.DebugFlags.gran       = rtsTrue; break;
-        case 11:  RtsFlags.DebugFlags.par        = rtsTrue; break;
+        case 0:  RtsFlags.DebugFlags.scheduler   = rtsTrue; break;
+        case 1:  RtsFlags.DebugFlags.evaluator   = rtsTrue; break;
+        case 2:  RtsFlags.DebugFlags.codegen     = rtsTrue; break;
+        case 3:  RtsFlags.DebugFlags.weak        = rtsTrue; break;
+        case 4:  RtsFlags.DebugFlags.gccafs      = rtsTrue; break;
+        case 5:  RtsFlags.DebugFlags.gc          = rtsTrue; break;
+        case 6:  RtsFlags.DebugFlags.block_alloc = rtsTrue; break;
+        case 7:  RtsFlags.DebugFlags.sanity      = rtsTrue; break;
+        case 8:  RtsFlags.DebugFlags.stable      = rtsTrue; break;
+        case 9:  RtsFlags.DebugFlags.prof        = rtsTrue; break;
+        case 10: RtsFlags.DebugFlags.gran        = rtsTrue; break;
+        case 11: RtsFlags.DebugFlags.par         = rtsTrue; break;
+        case 12: RtsFlags.DebugFlags.linker      = rtsTrue; break;
       } /* switch */
     } /* if */
 }