[project @ 2003-04-15 14:37:12 by simonmar]
[ghc-hetmet.git] / ghc / rts / RtsFlags.c
index 36d5ee1..b4ce185 100644 (file)
@@ -1,5 +1,5 @@
 /* -----------------------------------------------------------------------------
- * $Id: RtsFlags.c,v 1.61 2002/10/05 22:18:45 panne Exp $
+ * $Id: RtsFlags.c,v 1.67 2003/03/25 17:26:08 sof 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 "Timer.h"             /* CS_MIN_MILLISECS */
 #include "Profiling.h"
 
-#if defined(PROFILING) 
-#include "Itimer.h"
-#endif
-
 #ifdef HAVE_CTYPE_H
 #include <ctype.h>
 #endif
@@ -45,9 +41,9 @@ extern struct RTS_FLAGS RtsFlags;
 /*
  * Split argument lists
  */
-int     prog_argc; /* an "int" so as to match normal "argc" */
+int     prog_argc = 0; /* an "int" so as to match normal "argc" */
 char  **prog_argv = NULL;
-int     rts_argc;  /* ditto */
+int     rts_argc = 0;  /* ditto */
 char   *rts_argv[MAX_RTS_ARGS];
 
 //@node Constants, Static function decls, Includes
@@ -61,7 +57,7 @@ char   *rts_argv[MAX_RTS_ARGS];
 
 char *debug_opts_prefix[] = {
   "_-", /* scheduler */
-  "_.", /* evaluator */
+  "_.", /* interpreter */
   "_,", /* codegen */
   "_;", /* weak */
   "_~", /* gccafs */
@@ -229,7 +225,7 @@ void initRtsFlagsDefaults(void)
 
 #ifdef DEBUG
     RtsFlags.DebugFlags.scheduler      = rtsFalse;
-    RtsFlags.DebugFlags.evaluator      = rtsFalse;
+    RtsFlags.DebugFlags.interpreter    = rtsFalse;
     RtsFlags.DebugFlags.codegen                = rtsFalse;
     RtsFlags.DebugFlags.weak           = rtsFalse;
     RtsFlags.DebugFlags.gccafs         = rtsFalse;
@@ -250,6 +246,7 @@ void initRtsFlagsDefaults(void)
 #ifdef PROFILING
     RtsFlags.ProfFlags.doHeapProfile      = rtsFalse;
     RtsFlags.ProfFlags.profileInterval    = 100;
+    RtsFlags.ProfFlags.includeTSOs        = rtsFalse;
     RtsFlags.ProfFlags.showCCSOnException = rtsFalse;
     RtsFlags.ProfFlags.maxRetainerSetSize = 8;
     RtsFlags.ProfFlags.modSelector        = NULL;
@@ -438,6 +435,8 @@ usage_text[] = {
 "",
 "  -i<sec>        Time between heap samples (seconds, default: 0.1)",
 "",
+"  -xt            Include threads (TSOs) in a heap profile",
+"",
 "  -xc      Show current cost centre stack on raising an exception",
 # endif
 #endif /* PROFILING or PAR */
@@ -463,7 +462,7 @@ usage_text[] = {
 "",
 #if defined(DEBUG)
 "  -Ds  DEBUG: scheduler",
-"  -De  DEBUG: evaluator",
+"  -Di  DEBUG: interpreter",
 "  -Dc  DEBUG: codegen",
 "  -Dw  DEBUG: weak",
 "  -DG  DEBUG: gccafs",
@@ -529,7 +528,7 @@ splitRtsFlags(char *s, int *rts_argc, char *rts_argv[])
        if (c1 == c2) { break; }
        
        if (*rts_argc < MAX_RTS_ARGS-1) {
-           s = malloc(c2-c1+1);
+           s = stgMallocBytes(c2-c1+1, "RtsFlags.c:splitRtsFlags()");
            strncpy(s, c1, c2-c1);
            s[c2-c1] = '\0';
            rts_argv[(*rts_argc)++] = s;
@@ -569,7 +568,7 @@ setupRtsFlags(int *argc, char *argv[], int *rts_argc, char *rts_argv[])
        }
     }
 
-    // process arguments from the GHCRTS environment variable first
+    // process arguments from the GHCRTS environment variable next
     // (arguments from the command line override these).
     {
        char *ghc_rts = getenv("GHCRTS");
@@ -733,8 +732,8 @@ error = rtsTrue;
                      case 's':
                          RtsFlags.DebugFlags.scheduler = rtsTrue;
                          break;
-                     case 'e':
-                         RtsFlags.DebugFlags.evaluator = rtsTrue;
+                     case 'i':
+                         RtsFlags.DebugFlags.interpreter = rtsTrue;
                          break;
                      case 'c':
                          RtsFlags.DebugFlags.codegen = rtsTrue;
@@ -769,6 +768,9 @@ error = rtsTrue;
                      case 'l':
                          RtsFlags.DebugFlags.linker = rtsTrue;
                          break;
+                     case 'a':
+                         RtsFlags.DebugFlags.apply = rtsTrue;
+                         break;
                      default:
                          bad_option( rts_argv[arg] );
                      }
@@ -1118,8 +1120,15 @@ error = rtsTrue;
 
                   case 'c': /* Debugging tool: show current cost centre on an exception */
                     PROFILING_BUILD_ONLY(
-                    RtsFlags.ProfFlags.showCCSOnException = rtsTrue;
-                    ) break;
+                       RtsFlags.ProfFlags.showCCSOnException = rtsTrue;
+                       );
+                   break;
+
+               case 't':  /* Include memory used by TSOs in a heap profile */
+                   PROFILING_BUILD_ONLY(
+                       RtsFlags.ProfFlags.includeTSOs = rtsTrue;
+                       );
+                   break;
 
                   /* The option prefix '-xx' is reserved for future extension.  KSW 1999-11. */