Improve error reporting for kind errors (fix Trac #1633)
[ghc-hetmet.git] / rts / RtsFlags.c
index 829e600..0794dc4 100644 (file)
@@ -176,11 +176,14 @@ void initRtsFlagsDefaults(void)
     RtsFlags.DebugFlags.stable         = rtsFalse;
     RtsFlags.DebugFlags.stm             = rtsFalse;
     RtsFlags.DebugFlags.prof           = rtsFalse;
+    RtsFlags.DebugFlags.eventlog        = rtsFalse;
     RtsFlags.DebugFlags.gran           = rtsFalse;
     RtsFlags.DebugFlags.par            = rtsFalse;
+    RtsFlags.DebugFlags.apply          = rtsFalse;
     RtsFlags.DebugFlags.linker         = rtsFalse;
     RtsFlags.DebugFlags.squeeze                = rtsFalse;
     RtsFlags.DebugFlags.hpc            = rtsFalse;
+    RtsFlags.DebugFlags.timestamp      = rtsFalse;
 #endif
 
 #if defined(PROFILING) || defined(PAR)
@@ -204,16 +207,25 @@ void initRtsFlagsDefaults(void)
     RtsFlags.ProfFlags.bioSelector        = NULL;
 #endif
 
+#ifdef EVENTLOG
+    RtsFlags.EventLogFlags.doEventLogging = rtsFalse;
+#endif
+
     RtsFlags.MiscFlags.tickInterval    = 20;  /* In milliseconds */
     RtsFlags.ConcFlags.ctxtSwitchTime  = 20;  /* In milliseconds */
 
     RtsFlags.MiscFlags.install_signal_handlers = rtsTrue;
+    RtsFlags.MiscFlags.machineReadable = rtsFalse;
+    RtsFlags.MiscFlags.linkerMemBase    = 0;
 
 #ifdef THREADED_RTS
     RtsFlags.ParFlags.nNodes           = 1;
     RtsFlags.ParFlags.migrate           = rtsTrue;
     RtsFlags.ParFlags.wakeupMigrate     = rtsFalse;
-    RtsFlags.ParFlags.gcThreads         = 1;
+    RtsFlags.ParFlags.parGcEnabled      = 1;
+    RtsFlags.ParFlags.parGcGen          = 1;
+    RtsFlags.ParFlags.parGcLoadBalancing = 1;
+    RtsFlags.ParFlags.setAffinity       = 0;
 #endif
 
 #ifdef PAR
@@ -316,10 +328,6 @@ void initRtsFlagsDefaults(void)
     RtsFlags.TickyFlags.tickyFile       = NULL;
 #endif
 
-    RtsFlags.TraceFlags.timestamp      = rtsFalse;
-    RtsFlags.TraceFlags.sched          = rtsFalse;
-    RtsFlags.TraceFlags.gc             = rtsFalse;
-
 #ifdef USE_PAPI
     /* By default no special measurements taken */
     RtsFlags.PapiFlags.eventType        = 0;
@@ -345,7 +353,7 @@ usage_text[] = {
 "  -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",
 "",
-"  -A<size> Sets the minimum allocation area size (default 256k) Egs: -A1m -A10k",
+"  -A<size> Sets the minimum allocation area size (default 512k) Egs: -A1m -A10k",
 "  -M<size> Sets the maximum heap size (default unlimited)  Egs: -M256k -M1G",
 "  -H<size> Sets the minimum heap size (default 0M)   Egs: -H24m  -H1G",
 "  -m<n>    Minimum % of heap which must be available (default 3%)",
@@ -406,6 +414,13 @@ usage_text[] = {
 "",
 # endif
 #endif /* PROFILING or PAR */
+
+#ifdef EVENTLOG
+"",
+"  -l       Log runtime events (generates binary trace file <program>.eventlog)",
+"",
+#endif
+
 #if !defined(PROFILING)
 "",
 "  -hT      Heap residency profile (output file <program>.hp)",
@@ -427,8 +442,7 @@ usage_text[] = {
 "            This sets the resolution for -C and the profile timer -i.",
 "            Default: 0.02 sec.",
 "",
-"  -vs       Trace scheduler events (see also -Ds with -debug)",
-"  -vt       Time-stamp trace messages",
+"  -vt       Time-stamp debug messages",
 "",
 #if defined(DEBUG)
 "  -Ds  DEBUG: scheduler",
@@ -440,8 +454,10 @@ usage_text[] = {
 "  -DS  DEBUG: sanity",
 "  -Dt  DEBUG: stable",
 "  -Dp  DEBUG: prof",
+"  -De  DEBUG: event logging",
 "  -Dr  DEBUG: gran",
 "  -DP  DEBUG: par",
+"  -Da  DEBUG: apply",
 "  -Dl  DEBUG: linker",
 "  -Dm  DEBUG: stm",
 "  -Dz  DEBUG: stack squezing",
@@ -449,8 +465,12 @@ usage_text[] = {
 "",
 #endif /* DEBUG */
 #if defined(THREADED_RTS) && !defined(NOSMP)
-"  -N<n>     Use <n> OS threads (default: 1) (also sets -g)",
-"  -g<n>     Use <n> OS threads for GC (default: 1)",
+"  -N<n>     Use <n> processors (default: 1)",
+"  -N        Determine the number of processors to use automatically",
+"  -q1       Use one OS thread for GC (turns off parallel GC)",
+"  -qg<n>    Use parallel GC only for generations >= <n> (default: 1)",
+"  -qb       Disable load-balancing in the parallel GC",
+"  -qa       Use the OS to set thread affinity",
 "  -qm       Don't automatically migrate threads between CPUs",
 "  -qw       Migrate a thread to the current CPU when it is woken up",
 #endif
@@ -476,6 +496,10 @@ usage_text[] = {
 #if defined(GRAN)  /* ToDo: fill in decent Docu here */
 "  -b...     All GranSim options start with -b; see GranSim User's Guide for details",
 #endif
+#if defined(x86_64_HOST_ARCH)
+"  -xm       Base address to mmap memory in the GHCi linker",
+"            (hex; must be <80000000)",
+#endif
 #if defined(USE_PAPI)
 "  -aX       CPU performance counter measurements using PAPI",
 "            (use with the -s<file> option).  X is one of:",
@@ -640,6 +664,14 @@ errorBelch("not built for: -prof"); \
 error = rtsTrue;
 #endif
 
+#ifdef EVENTLOG
+# define EVENTLOG_BUILD_ONLY(x)   x
+#else
+# define EVENTLOG_BUILD_ONLY(x) \
+errorBelch("not built for: -par-prof"); \
+error = rtsTrue;
+#endif
+
 #ifdef PAR
 # define PAR_BUILD_ONLY(x)      x
 #else
@@ -689,6 +721,10 @@ error = rtsTrue;
                                &rts_argv[arg][2])) {
                       RtsFlags.MiscFlags.install_signal_handlers = rtsFalse;
                   }
+                  else if (strequal("machine-readable",
+                               &rts_argv[arg][2])) {
+                      RtsFlags.MiscFlags.machineReadable = rtsTrue;
+                  }
                   else if (strequal("info",
                                &rts_argv[arg][2])) {
                       printRtsInfo();
@@ -797,6 +833,9 @@ error = rtsTrue;
                      case 'p':
                          RtsFlags.DebugFlags.prof = rtsTrue;
                          break;
+                     case 'e':
+                         RtsFlags.DebugFlags.eventlog = rtsTrue;
+                          break;
                      case 'r':
                          RtsFlags.DebugFlags.gran = rtsTrue;
                          break;
@@ -931,6 +970,14 @@ error = rtsTrue;
 
              /* =========== PROFILING ========================== */
 
+              case 'l':
+#ifdef EVENTLOG
+                  RtsFlags.EventLogFlags.doEventLogging = rtsTrue;
+#else
+                  errorBelch("not built for: -eventlog");
+#endif
+                  break;
+
              case 'P': /* detailed cost centre profiling (time/alloc) */
              case 'p': /* cost centre profiling (time/alloc) */
                COST_CENTRE_USING_BUILD_ONLY(
@@ -1124,11 +1171,15 @@ error = rtsTrue;
 #if defined(THREADED_RTS) && !defined(NOSMP)
              case 'N':
                THREADED_BUILD_ONLY(
-               if (rts_argv[arg][2] != '\0') {
+               if (rts_argv[arg][2] == '\0') {
+#if defined(PROFILING)
+                   RtsFlags.ParFlags.nNodes = 1;
+#else
+                    RtsFlags.ParFlags.nNodes = getNumberOfProcessors();
+#endif
+               } else {
                    RtsFlags.ParFlags.nNodes
                      = strtol(rts_argv[arg]+2, (char **) NULL, 10);
-                    // set -g at the same time as -N by default
-                   RtsFlags.ParFlags.gcThreads = RtsFlags.ParFlags.nNodes;
                    if (RtsFlags.ParFlags.nNodes <= 0) {
                      errorBelch("bad value for -N");
                      error = rtsTrue;
@@ -1144,15 +1195,17 @@ error = rtsTrue;
 
              case 'g':
                THREADED_BUILD_ONLY(
-               if (rts_argv[arg][2] != '\0') {
-                   RtsFlags.ParFlags.gcThreads
-                     = strtol(rts_argv[arg]+2, (char **) NULL, 10);
-                   if (RtsFlags.ParFlags.nNodes <= 0) {
-                     errorBelch("bad value for -g");
-                     error = rtsTrue;
-                   }
-               }
-               ) break;
+                   switch (rts_argv[arg][2]) {
+                    case '1':
+                        // backwards compat only
+                        RtsFlags.ParFlags.parGcEnabled = rtsFalse;
+                        break;
+                   default:
+                       errorBelch("unknown RTS option: %s",rts_argv[arg]);
+                       error = rtsTrue;
+                       break;
+                    }
+                    ) break;
 
              case 'q':
                    switch (rts_argv[arg][2]) {
@@ -1160,6 +1213,24 @@ error = rtsTrue;
                        errorBelch("incomplete RTS option: %s",rts_argv[arg]);
                        error = rtsTrue;
                        break;
+                    case '1':
+                        RtsFlags.ParFlags.parGcEnabled = rtsFalse;
+                        break;
+                    case 'g':
+                        if (rts_argv[arg][3] != '\0') {
+                            RtsFlags.ParFlags.parGcGen
+                                = strtol(rts_argv[arg]+3, (char **) NULL, 10);
+                        } else {
+                            errorBelch("bad value for -qg");
+                            error = rtsTrue;
+                        }
+                        break;
+                   case 'b':
+                       RtsFlags.ParFlags.parGcLoadBalancing = rtsFalse;
+                       break;
+                   case 'a':
+                       RtsFlags.ParFlags.setAffinity = rtsTrue;
+                       break;
                    case 'm':
                        RtsFlags.ParFlags.migrate = rtsFalse;
                        break;
@@ -1225,13 +1296,11 @@ error = rtsTrue;
                    error = rtsTrue;
                    break;
                case 't':
-                   RtsFlags.TraceFlags.timestamp = rtsTrue;
+                   RtsFlags.DebugFlags.timestamp = rtsTrue;
                    break;
                case 's':
-                   RtsFlags.TraceFlags.sched = rtsTrue;
-                   break;
                case 'g':
-                   RtsFlags.TraceFlags.gc = rtsTrue;
+                    // ignored for backwards-compat
                    break;
                default:
                    errorBelch("unknown RTS option: %s",rts_argv[arg]);
@@ -1259,7 +1328,22 @@ error = rtsTrue;
                     }
                     break;
 
-                  case 'c': /* Debugging tool: show current cost centre on an exception */
+#if defined(x86_64_HOST_ARCH)
+                case 'm': /* linkerMemBase */
+                    if (rts_argv[arg][3] != '\0') {
+                        RtsFlags.MiscFlags.linkerMemBase
+                            = strtol(rts_argv[arg]+3, (char **) NULL, 16);
+                        if (RtsFlags.MiscFlags.linkerMemBase > 0x80000000) {
+                            errorBelch("-xm: value must be <80000000");
+                            error = rtsTrue;
+                        }
+                    } else {
+                        RtsFlags.MiscFlags.linkerMemBase = 0;
+                    }
+                    break;
+#endif
+
+                case 'c': /* Debugging tool: show current cost centre on an exception */
                     PROFILING_BUILD_ONLY(
                        RtsFlags.ProfFlags.showCCSOnException = rtsTrue;
                        );