Basic heap profile support without -prof
[ghc-hetmet.git] / rts / RtsFlags.c
index b2bb9e7..1cf7700 100644 (file)
@@ -165,15 +165,17 @@ void initRtsFlagsDefaults(void)
     RtsFlags.DebugFlags.par            = rtsFalse;
     RtsFlags.DebugFlags.linker         = rtsFalse;
     RtsFlags.DebugFlags.squeeze                = rtsFalse;
+    RtsFlags.DebugFlags.hpc            = rtsFalse;
 #endif
 
 #if defined(PROFILING) || defined(PAR)
     RtsFlags.CcFlags.doCostCentres     = 0;
 #endif /* PROFILING or PAR */
 
-#ifdef PROFILING
     RtsFlags.ProfFlags.doHeapProfile      = rtsFalse;
     RtsFlags.ProfFlags.profileInterval    = 100;
+
+#ifdef PROFILING
     RtsFlags.ProfFlags.includeTSOs        = rtsFalse;
     RtsFlags.ProfFlags.showCCSOnException = rtsFalse;
     RtsFlags.ProfFlags.maxRetainerSetSize = 8;
@@ -185,14 +187,13 @@ void initRtsFlagsDefaults(void)
     RtsFlags.ProfFlags.ccsSelector        = NULL;
     RtsFlags.ProfFlags.retainerSelector   = NULL;
     RtsFlags.ProfFlags.bioSelector        = NULL;
-
-#elif defined(DEBUG)
-    RtsFlags.ProfFlags.doHeapProfile      = rtsFalse;
 #endif
 
     RtsFlags.MiscFlags.tickInterval    = 50;  /* In milliseconds */
     RtsFlags.ConcFlags.ctxtSwitchTime  = 50;  /* In milliseconds */
 
+    RtsFlags.MiscFlags.install_signal_handlers = rtsTrue;
+
 #ifdef THREADED_RTS
     RtsFlags.ParFlags.nNodes           = 1;
     RtsFlags.ParFlags.migrate           = rtsTrue;
@@ -303,7 +304,8 @@ void initRtsFlagsDefaults(void)
     RtsFlags.TraceFlags.sched          = rtsFalse;
 
 #ifdef USE_PAPI
-    RtsFlags.PapiFlags.eventType        = PAPI_FLAG_BRANCH;
+    /* By default no special measurements taken */
+    RtsFlags.PapiFlags.eventType        = 0;
 #endif
 }
 
@@ -378,23 +380,20 @@ usage_text[] = {
 "  -L<chars>      Maximum length of a cost-centre stack in a heap profile",
 "                 (default: 25)",
 "",
-"  -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 */
-#if !defined(PROFILING) && defined(DEBUG)
+#if !defined(PROFILING)
 "",
-"  -h<break-down> Debugging Heap residency profile",
-"                 (output file <program>.hp)",
-"     break-down: L = closure label (default)",
-"                 T = closure type (constructor, thunk etc.)",
+"  -hT      Heap residency profile (output file <program>.hp)",
 #endif
+"  -i<sec>  Time between heap samples (seconds, default: 0.1)",
 "",
 #if defined(TICKY_TICKY)
-"  -r<file>  Produce reduction profiling statistics (with -rstderr for stderr)",
+"  -r<file>  Produce ticky-ticky statistics (with -rstderr for stderr)",
 "",
 #endif
 #if defined(PAR)
@@ -426,6 +425,7 @@ usage_text[] = {
 "  -Dl  DEBUG: linker",
 "  -Dm  DEBUG: stm",
 "  -Dz  DEBUG: stack squezing",
+"  -Dc  DEBUG: program coverage",
 "",
 #endif /* DEBUG */
 #if defined(THREADED_RTS) && !defined(NOSMP)
@@ -433,6 +433,8 @@ usage_text[] = {
 "  -qm       Don't automatically migrate threads between CPUs",
 "  -qw       Migrate a thread to the current CPU when it is woken up",
 #endif
+"  --install-signal-handlers=<yes|no>",
+"            Install signal handlers (default: yes)",
 #if defined(THREADED_RTS) || defined(PAR)
 "  -e<size>  Size of spark pools (default 100)",
 #endif
@@ -454,14 +456,15 @@ usage_text[] = {
 "  -b...     All GranSim options start with -b; see GranSim User's Guide for details",
 #endif
 #if defined(USE_PAPI)
-"  -aX       Perform measurements using PAPI, it should be used with the -s<file> option.",
-"            Where X is one of:",
+"  -aX       CPU performance counter measurements using PAPI",
+"            (use with the -s<file> option).  X is one of:",
 "",
 /* "            y - cycles", */
 "            1 - level 1 cache misses",
 "            2 - level 2 cache misses",
 "            b - branch mispredictions",
 "            s - stalled cycles",
+"            e - cache miss and branch misprediction events",
 #endif
 "",
 "RTS options may also be specified using the GHCRTS environment variable.",
@@ -653,6 +656,23 @@ error = rtsTrue;
                error = rtsTrue;
                break;
 
+              /* This isn't going to allow us to keep related options
+                 together as we add more --* flags. We really need a
+                 proper options parser. */
+             case '-':
+                  if (strequal("install-signal-handlers=yes",
+                               &rts_argv[arg][2])) {
+                      RtsFlags.MiscFlags.install_signal_handlers = rtsTrue;
+                  }
+                  else if (strequal("install-signal-handlers=no",
+                               &rts_argv[arg][2])) {
+                      RtsFlags.MiscFlags.install_signal_handlers = rtsFalse;
+                  }
+                  else {
+                     errorBelch("unknown RTS option: %s",rts_argv[arg]);
+                     error = rtsTrue;
+                  }
+                 break;
              case 'A':
                RtsFlags.GcFlags.minAllocAreaSize
                  = decode(rts_argv[arg]+2) / BLOCK_SIZE;
@@ -676,6 +696,9 @@ error = rtsTrue;
                case 's':
                  RtsFlags.PapiFlags.eventType = PAPI_FLAG_STALLS;
                  break;
+               case 'e':
+                 RtsFlags.PapiFlags.eventType = PAPI_FLAG_CB_EVENTS;
+                 break;
                default:
                  bad_option( rts_argv[arg] );
                }
@@ -754,6 +777,9 @@ error = rtsTrue;
                      case 'z':
                          RtsFlags.DebugFlags.squeeze = rtsTrue;
                          break;
+                     case 'c':
+                         RtsFlags.DebugFlags.hpc = rtsTrue;
+                         break;
                      default:
                          bad_option( rts_argv[arg] );
                      }
@@ -905,12 +931,9 @@ error = rtsTrue;
                       }
                  ) break;
              case 'h': /* serial heap profile */
-#if !defined(PROFILING) && defined(DEBUG)
+#if !defined(PROFILING)
                switch (rts_argv[arg][2]) {
                  case '\0':
-                 case 'L':
-                   RtsFlags.ProfFlags.doHeapProfile = HEAP_BY_INFOPTR;
-                   break;
                  case 'T':
                    RtsFlags.ProfFlags.doHeapProfile = HEAP_BY_CLOSURE_TYPE;
                    break;
@@ -1026,7 +1049,6 @@ error = rtsTrue;
 #endif /* PROFILING */
                break;
 
-#if defined(PROFILING) 
              case 'i': /* heap sample interval */
                if (rts_argv[arg][2] == '\0') {
                  /* use default */
@@ -1038,7 +1060,6 @@ error = rtsTrue;
                    RtsFlags.ProfFlags.profileInterval = cst;
                }
                break;
-#endif
 
              /* =========== CONCURRENT ========================= */
              case 'C': /* context switch interval */
@@ -1220,13 +1241,11 @@ error = rtsTrue;
                     RtsFlags.MiscFlags.tickInterval);
     }
 
-#ifdef PROFILING
     if (RtsFlags.ProfFlags.profileInterval > 0) {
         RtsFlags.MiscFlags.tickInterval =
             stg_min(RtsFlags.ProfFlags.profileInterval,
                     RtsFlags.MiscFlags.tickInterval);
     }
-#endif
 
     if (RtsFlags.ConcFlags.ctxtSwitchTime > 0) {
         RtsFlags.ConcFlags.ctxtSwitchTicks =
@@ -1236,10 +1255,8 @@ error = rtsTrue;
         RtsFlags.ConcFlags.ctxtSwitchTicks = 0;
     }
 
-#ifdef PROFILING
     RtsFlags.ProfFlags.profileIntervalTicks =
         RtsFlags.ProfFlags.profileInterval / RtsFlags.MiscFlags.tickInterval;
-#endif
 
     if (error) {
        const char **p;