[project @ 2001-03-14 11:18:18 by sewardj]
[ghc-hetmet.git] / ghc / rts / RtsFlags.c
index c86690f..b6d210f 100644 (file)
@@ -1,5 +1,5 @@
 /* -----------------------------------------------------------------------------
- * $Id: RtsFlags.c,v 1.31 2000/08/03 11:28:35 simonmar Exp $
+ * $Id: RtsFlags.c,v 1.37 2001/03/14 11:18:18 sewardj Exp $
  *
  * (c) The AQUA Project, Glasgow University, 1994-1997
  * (c) The GHC Team, 1998-1999
@@ -67,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[] = {
@@ -83,6 +84,7 @@ char *debug_opts_prefix[] = {
   "_!", /* prof */
   "_=", /* gran */
   "_=" /* par */
+  "_*" /* linker */
 };
 
 #if defined(GRAN)
@@ -227,16 +229,23 @@ 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;
 #endif /* PROFILING or PAR */
 
 #ifdef PROFILING
-    RtsFlags.ProfFlags.doHeapProfile = rtsFalse;
+    RtsFlags.ProfFlags.doHeapProfile      = rtsFalse;
     RtsFlags.ProfFlags.showCCSOnException = rtsFalse;
+    RtsFlags.ProfFlags.modSelector        = NULL;
+    RtsFlags.ProfFlags.descrSelector      = NULL;
+    RtsFlags.ProfFlags.typeSelector       = NULL;
+    RtsFlags.ProfFlags.ccSelector         = NULL;
 #elif defined(DEBUG)
-    RtsFlags.ProfFlags.doHeapProfile = rtsFalse;
+    RtsFlags.ProfFlags.doHeapProfile      = rtsFalse;
 #endif
 
     RtsFlags.ConcFlags.ctxtSwitchTime  = CS_MIN_MILLISECS;  /* In milliseconds */
@@ -351,7 +360,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",
@@ -362,8 +371,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",
@@ -373,13 +387,19 @@ usage_text[] = {
 "  -px      Time/allocation profile (XML)  (output file <program>.prof)",
 "  -p<sort> Time/allocation profile        (output file <program>.prof)",
 "             sort: T = time (default), A = alloc, C = cost centre label",
-"  -P<sort> More detailed Time/Allocation profile"
+"  -P<sort> More detailed Time/Allocation profile",
+
 # if defined(PROFILING)
 "",
 "  -hx            Heap residency profile (XML)  (output file <program>.prof)",
 "  -h<break-down> Heap residency profile (text) (output file <program>.prof)",
 "     break-down: C = cost centre stack (default), M = module",
 "                 D = closure description, Y = type description",
+"  A subset of closures may be selected thusly:",
+"    -hc{cc, cc ...} specific cost centre(s) (NOT STACKS!)",
+"    -hm{mod,mod...} all cost centres from the specified modules(s)",
+"    -hd{des,des...} closures with specified closure descriptions",
+"    -hy{typ,typ...} closures with specified type descriptions",
 "",
 "  -xc      Show current cost centre stack on raising an exception",
 # endif
@@ -564,7 +584,6 @@ error = rtsTrue;
 
              /* =========== GENERAL ========================== */
              case '?':
-             case 'f':
                error = rtsTrue;
                break;
 
@@ -654,23 +673,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;
@@ -724,11 +757,44 @@ error = rtsTrue;
                  case TYPEchar:
                    RtsFlags.ProfFlags.doHeapProfile = HEAP_BY_TYPE;
                    break;
+                  case 'c': /* cost centre label select */
+                  case 'm': /* cost centre module select */
+                  case 'd': /* closure descr select */
+                  case 'y': /* closure type select */
+                    {char *left  = strchr(rts_argv[arg], '{');
+                     char *right = strrchr(rts_argv[arg], '}');
+                     if (! left || ! right ||
+                          strrchr(rts_argv[arg], '{') != left ||
+                           strchr(rts_argv[arg], '}') != right) {
+                        prog_belch(
+                           "Invalid heap profiling selection bracketing\n   %s\n", 
+                           rts_argv[arg]);
+                        error = rtsTrue;
+                     } else {
+                        *right = '\0';
+                        switch (rts_argv[arg][2]) {
+                          case 'c': /* cost centre label select */
+                            RtsFlags.ProfFlags.ccSelector = left + 1;
+                            break;
+                          case 'm': /* cost centre module select */
+                            RtsFlags.ProfFlags.modSelector = left + 1;
+                            break;
+                          case 'd': /* closure descr select */
+                            RtsFlags.ProfFlags.descrSelector = left + 1;
+                            break;
+                          case 'y': /* closure type select */
+                            RtsFlags.ProfFlags.typeSelector = left + 1;
+                            break;
+                        }
+                     }
+                    }
+                    break;
                  default:
                    prog_belch("invalid heap profile option: %s",rts_argv[arg]);
                    error = rtsTrue;
                }
                ) 
+
 #endif
                break;
 
@@ -1784,18 +1850,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 */
 }