Add +RTS -vg flag for requesting some GC trace messages, outside DEBUG
[ghc-hetmet.git] / rts / RtsFlags.c
index 1e8654d..4f69f49 100644 (file)
@@ -212,6 +212,7 @@ void initRtsFlagsDefaults(void)
     RtsFlags.ParFlags.nNodes           = 1;
     RtsFlags.ParFlags.migrate           = rtsTrue;
     RtsFlags.ParFlags.wakeupMigrate     = rtsFalse;
+    RtsFlags.ParFlags.gcThreads         = 1;
 #endif
 
 #ifdef PAR
@@ -316,10 +317,12 @@ void initRtsFlagsDefaults(void)
 
     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;
+    RtsFlags.PapiFlags.numUserEvents    = 0;
 #endif
 }
 
@@ -336,6 +339,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",
@@ -444,6 +448,7 @@ usage_text[] = {
 #endif /* DEBUG */
 #if defined(THREADED_RTS) && !defined(NOSMP)
 "  -N<n>     Use <n> OS threads (default: 1)",
+"  -g<n>     Use <n> OS threads for GC (default: 1)",
 "  -qm       Don't automatically migrate threads between CPUs",
 "  -qw       Migrate a thread to the current CPU when it is woken up",
 #endif
@@ -684,12 +689,7 @@ error = rtsTrue;
                   }
                   else if (strequal("info",
                                &rts_argv[arg][2])) {
-                      printf("RTS info:\n");
-                      printf("RTS from GHC " ProjectVersion "\n");
-                      printf("RTS way " RtsWay "\n");
-                      printf("Host platform " HostPlatform "\n");
-                      printf("Build platform " BuildPlatform "\n");
-                      printf("Target platform " TargetPlatform "\n");
+                      printRtsInfo();
                       exit(0);
                   }
                   else {
@@ -723,6 +723,14 @@ error = rtsTrue;
                case 'e':
                  RtsFlags.PapiFlags.eventType = PAPI_FLAG_CB_EVENTS;
                  break;
+                case '+':
+                  if (RtsFlags.PapiFlags.numUserEvents >= MAX_PAPI_USER_EVENTS) {
+                      errorBelch("maximum number of PAPI events reached");
+                      stg_exit(EXIT_FAILURE);
+                  }
+                  RtsFlags.PapiFlags.eventType = PAPI_USER_EVENTS;
+                  RtsFlags.PapiFlags.userEvents[RtsFlags.PapiFlags.numUserEvents++] = rts_argv[arg] + 3;
+                  break;
                default:
                  bad_option( rts_argv[arg] );
                }
@@ -863,10 +871,6 @@ error = rtsTrue;
              case 'H':
                RtsFlags.GcFlags.heapSizeSuggestion = 
                  decode(rts_argv[arg]+2) / BLOCK_SIZE;
-
-               if (RtsFlags.GcFlags.heapSizeSuggestion <= 0) {
-                 bad_option(rts_argv[arg]);
-               }
                break;
 
 #ifdef RTS_GTK_FRONTPANEL
@@ -1124,6 +1128,24 @@ error = rtsTrue;
                }
                ) break;
 
+             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;
+                   }
+#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;
+
              case 'q':
                    switch (rts_argv[arg][2]) {
                    case '\0':
@@ -1200,6 +1222,9 @@ error = rtsTrue;
                case 's':
                    RtsFlags.TraceFlags.sched = rtsTrue;
                    break;
+               case 'g':
+                   RtsFlags.TraceFlags.gc = rtsTrue;
+                   break;
                default:
                    errorBelch("unknown RTS option: %s",rts_argv[arg]);
                    error = rtsTrue;