don't make -ddump-if-trace imply -no-recomp
[ghc-hetmet.git] / rts / RtsFlags.c
index 1cf7700..f8c8403 100644 (file)
@@ -28,6 +28,8 @@ RTS_FLAGS RtsFlags;
  */
 int     prog_argc = 0;    /* an "int" so as to match normal "argc" */
 char  **prog_argv = NULL;
+int     full_prog_argc = 0;    /* an "int" so as to match normal "argc" */
+char  **full_prog_argv = NULL;
 char   *prog_name = NULL; /* 'basename' of prog_argv[0] */
 int     rts_argc = 0;  /* ditto */
 char   *rts_argv[MAX_RTS_ARGS];
@@ -150,6 +152,18 @@ void initRtsFlagsDefaults(void)
 #endif
     RtsFlags.GcFlags.idleGCDelayTime    = 300; /* millisecs */
 
+#if osf3_HOST_OS
+/* ToDo: Perhaps by adjusting this value we can make linking without
+ * -static work (i.e., not generate a core-dumping executable)? */
+# if SIZEOF_VOID_P == 8
+    RtsFlags.GcFlags.heapBase           = 0x180000000L;
+# else
+#  error I have no idea where to begin the heap on a non-64-bit osf3 machine.
+# endif
+#else
+    RtsFlags.GcFlags.heapBase           = 0;   /* means don't care */
+#endif
+
 #ifdef DEBUG
     RtsFlags.DebugFlags.scheduler      = rtsFalse;
     RtsFlags.DebugFlags.interpreter    = rtsFalse;
@@ -189,8 +203,8 @@ void initRtsFlagsDefaults(void)
     RtsFlags.ProfFlags.bioSelector        = NULL;
 #endif
 
-    RtsFlags.MiscFlags.tickInterval    = 50;  /* In milliseconds */
-    RtsFlags.ConcFlags.ctxtSwitchTime  = 50;  /* In milliseconds */
+    RtsFlags.MiscFlags.tickInterval    = 20;  /* In milliseconds */
+    RtsFlags.ConcFlags.ctxtSwitchTime  = 20;  /* In milliseconds */
 
     RtsFlags.MiscFlags.install_signal_handlers = rtsTrue;
 
@@ -322,6 +336,7 @@ usage_text[] = {
 "The following run time system options are available:",
 "",
 "  -?       Prints this message and exits; the program is not executed",
+"  --info   Print information about the RTS used by this program",
 "",
 "  -K<size> Sets the maximum stack size (default 8M)  Egs: -K32k   -K512k",
 "  -k<size> Sets the initial thread stack size (default 1k)  Egs: -k4k   -k2m",
@@ -403,7 +418,7 @@ usage_text[] = {
 "  -C<secs>  Context-switch interval in seconds.",
 "            0 or no argument means switch as often as possible.",
 "            Default: 0.02 sec; resolution is set by -V below.",
-"  -V<secs>  Master tick interval in seconds.",
+"  -V<secs>  Master tick interval in seconds (0 == disable timer).",
 "            This sets the resolution for -C and the profile timer -i.",
 "            Default: 0.02 sec.",
 "",
@@ -668,6 +683,11 @@ error = rtsTrue;
                                &rts_argv[arg][2])) {
                       RtsFlags.MiscFlags.install_signal_handlers = rtsFalse;
                   }
+                  else if (strequal("info",
+                               &rts_argv[arg][2])) {
+                      printRtsInfo();
+                      exit(0);
+                  }
                   else {
                      errorBelch("unknown RTS option: %s",rts_argv[arg]);
                      error = rtsTrue;
@@ -1097,6 +1117,12 @@ error = rtsTrue;
                      errorBelch("bad value for -N");
                      error = rtsTrue;
                    }
+#if defined(PROFILING)
+                    if (RtsFlags.ParFlags.nNodes > 1) {
+                        errorBelch("bad option %s: only -N1 is supported with profiling", rts_argv[arg]);
+                     error = rtsTrue;
+                    }
+#endif
                }
                ) break;
 
@@ -1192,6 +1218,16 @@ error = rtsTrue;
                    error = rtsTrue;
                    break;
 
+                case 'b': /* heapBase in hex; undocumented */
+                    if (rts_argv[arg][3] != '\0') {
+                        RtsFlags.GcFlags.heapBase
+                            = strtol(rts_argv[arg]+3, (char **) NULL, 16);
+                    } else {
+                        errorBelch("-xb: requires argument");
+                        error = rtsTrue;
+                    }
+                    break;
+
                   case 'c': /* Debugging tool: show current cost centre on an exception */
                     PROFILING_BUILD_ONLY(
                        RtsFlags.ProfFlags.showCCSOnException = rtsTrue;
@@ -1222,13 +1258,20 @@ error = rtsTrue;
        }
     }
 
-    // Determine what tick interval we should use for the RTS timer
-    // by taking the shortest of the various intervals that we need to
-    // monitor.
-    if (RtsFlags.MiscFlags.tickInterval <= 0) {
+    if (RtsFlags.MiscFlags.tickInterval < 0) {
         RtsFlags.MiscFlags.tickInterval = 50;
     }
 
+    // If the master timer is disabled, turn off the other timers.
+    if (RtsFlags.MiscFlags.tickInterval == 0) {
+        RtsFlags.ConcFlags.ctxtSwitchTime  = 0;
+        RtsFlags.GcFlags.idleGCDelayTime   = 0;
+        RtsFlags.ProfFlags.profileInterval = 0;
+    }
+
+    // Determine what tick interval we should use for the RTS timer
+    // by taking the shortest of the various intervals that we need to
+    // monitor.
     if (RtsFlags.ConcFlags.ctxtSwitchTime > 0) {
         RtsFlags.MiscFlags.tickInterval =
             stg_min(RtsFlags.ConcFlags.ctxtSwitchTime,
@@ -1255,8 +1298,13 @@ error = rtsTrue;
         RtsFlags.ConcFlags.ctxtSwitchTicks = 0;
     }
 
-    RtsFlags.ProfFlags.profileIntervalTicks =
-        RtsFlags.ProfFlags.profileInterval / RtsFlags.MiscFlags.tickInterval;
+    if (RtsFlags.ProfFlags.profileInterval > 0) {
+        RtsFlags.ProfFlags.profileIntervalTicks =
+            RtsFlags.ProfFlags.profileInterval / 
+            RtsFlags.MiscFlags.tickInterval;
+    } else {
+        RtsFlags.ProfFlags.profileIntervalTicks = 0;
+    }
 
     if (error) {
        const char **p;
@@ -2377,3 +2425,29 @@ setProgArgv(int argc, char *argv[])
    prog_argv = argv;
    setProgName(prog_argv);
 }
+
+/* These functions record and recall the full arguments, including the
+   +RTS ... -RTS options. The reason for adding them was so that the
+   ghc-inplace program can pass /all/ the arguments on to the real ghc. */
+void
+getFullProgArgv(int *argc, char **argv[])
+{
+    if (argc) { *argc = full_prog_argc; }
+    if (argv) { *argv = full_prog_argv; }
+}
+
+void
+setFullProgArgv(int argc, char *argv[])
+{
+    int i;
+    full_prog_argc = argc;
+    full_prog_argv = stgCallocBytes(argc + 1, sizeof (char *),
+                                    "setFullProgArgv 1");
+    for (i = 0; i < argc; i++) {
+        full_prog_argv[i] = stgMallocBytes(strlen(argv[i]) + 1,
+                                           "setFullProgArgv 2");
+        strcpy(full_prog_argv[i], argv[i]);
+    }
+    full_prog_argv[argc] = NULL;
+}
+