[RTS] Make -po work
authorBartosz Nitka <niteria@gmail.com>
Thu, 14 Sep 2017 09:50:05 +0000 (02:50 -0700)
committerBen Gamari <ben@smart-cactus.org>
Tue, 3 Oct 2017 14:15:24 +0000 (10:15 -0400)
db2a667655506c43dd3c8260d29031bde55f1bee added `-po` option, but
the part that parses it was missing.

Test Plan:
On a simple file:
```
./inplace/bin/ghc-stage2 A.hs -prof -main-is A; ./A +RTS -P -potest
```
produced test.prof file and didn't produce A.prof file.

```
./A +RTS -P
```
produced A.prof file

Reviewers: simonmar, bgamari, austin, erikd

Reviewed By: bgamari

Subscribers: rwbarton, thomie

Differential Revision: https://phabricator.haskell.org/D3946

(cherry picked from commit b6b56dd1b6adc9051593955eecaef85c9d6e96b8)

rts/RtsFlags.c

index 0a12ba3..c2de960 100644 (file)
@@ -183,11 +183,12 @@ void initRtsFlagsDefaults(void)
     RtsFlags.DebugFlags.compact         = false;
 
 #if defined(PROFILING)
-    RtsFlags.CcFlags.doCostCentres      = 0;
+    RtsFlags.CcFlags.doCostCentres      = COST_CENTRES_NONE;
+    RtsFlags.CcFlags.outputFileNameStem = NULL;
 #endif /* PROFILING */
 
     RtsFlags.ProfFlags.doHeapProfile      = false;
-    RtsFlags.ProfFlags. heapProfileInterval = USToTime(100000); // 100ms
+    RtsFlags.ProfFlags.heapProfileInterval = USToTime(100000); // 100ms
 
 #ifdef PROFILING
     RtsFlags.ProfFlags.includeTSOs        = false;
@@ -1072,6 +1073,14 @@ error = true;
                   case 'j':
                       RtsFlags.CcFlags.doCostCentres = COST_CENTRES_JSON;
                       break;
+                  case 'o':
+                      if (rts_argv[arg][3] == '\0') {
+                        errorBelch("flag -po expects an argument");
+                        error = true;
+                        break;
+                      }
+                      RtsFlags.CcFlags.outputFileNameStem = rts_argv[arg]+3;
+                      break;
                   case '\0':
                       if (rts_argv[arg][1] == 'P') {
                           RtsFlags.CcFlags.doCostCentres = COST_CENTRES_VERBOSE;