RtsFlags.c 78.5 KB
Newer Older
1
/* -----------------------------------------------------------------------------
2 3
 *
 * (c) The AQUA Project, Glasgow University, 1994-1997
Simon Marlow's avatar
Simon Marlow committed
4
 * (c) The GHC Team, 1998-2006
5 6 7 8 9
 *
 * Functions for parsing the argument list.
 *
 * ---------------------------------------------------------------------------*/

10
#include "PosixSource.h"
11 12 13
#include "Rts.h"
#include "RtsFlags.h"
#include "RtsUtils.h"
14
#include "Profiling.h"
15

16 17
#ifdef HAVE_CTYPE_H
#include <ctype.h>
18 19
#endif

20 21 22 23 24 25 26 27
#ifdef HAVE_UNISTD_H
#include <unistd.h>
#endif

#ifdef HAVE_WINDOWS_H
#include <windows.h>
#endif

28 29 30
#include <stdlib.h>
#include <string.h>

31 32
// Flag Structure
RTS_FLAGS RtsFlags;
33 34 35 36

/*
 * Split argument lists
 */
sof's avatar
sof committed
37
int     prog_argc = 0;    /* an "int" so as to match normal "argc" */
38
char  **prog_argv = NULL;
39 40
int     full_prog_argc = 0;    /* an "int" so as to match normal "argc" */
char  **full_prog_argv = NULL;
sof's avatar
sof committed
41
char   *prog_name = NULL; /* 'basename' of prog_argv[0] */
42
int     rts_argc = 0;  /* ditto */
43 44 45 46 47 48 49 50
char   *rts_argv[MAX_RTS_ARGS];

/*
 * constants, used later 
 */
#define RTS 1
#define PGM 0

51 52
#if defined(GRAN)

sof's avatar
sof committed
53
static char *gran_debug_opts_strs[] = {
54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71
  "DEBUG (-bDe, -bD1): event_trace; printing event trace.\n",
  "DEBUG (-bDE, -bD2): event_stats; printing event statistics.\n",
  "DEBUG (-bDb, -bD4): bq; check blocking queues\n",
  "DEBUG (-bDG, -bD8): pack; routines for (un-)packing graph structures.\n",
  "DEBUG (-bDq, -bD16): checkSparkQ; check consistency of the spark queues.\n",
  "DEBUG (-bDf, -bD32): thunkStealing; print forwarding of fetches.\n",
  "DEBUG (-bDr, -bD64): randomSteal; stealing sparks/threads from random PEs.\n",
  "DEBUG (-bDF, -bD128): findWork; searching spark-pools (local & remote), thread queues for work.\n",
  "DEBUG (-bDu, -bD256): unused; currently unused flag.\n",
  "DEBUG (-bDS, -bD512): pri; priority sparking or scheduling.\n",
  "DEBUG (-bD:, -bD1024): checkLight; check GranSim-Light setup.\n",
  "DEBUG (-bDo, -bD2048): sortedQ; check whether spark/thread queues are sorted.\n",
  "DEBUG (-bDz, -bD4096): blockOnFetch; check for blocked on fetch.\n",
  "DEBUG (-bDP, -bD8192): packBuffer; routines handling pack buffer (GranSim internal!).\n",
  "DEBUG (-bDt, -bD16384): blockOnFetch_sanity; check for TSO asleep on fetch.\n",
};

/* one character codes for the available debug options */
sof's avatar
sof committed
72
static char gran_debug_opts_flags[] = {
73 74 75 76 77
  'e', 'E', 'b', 'G', 'q', 'f', 'r', 'F', 'u', 'S', ':', 'o', 'z', 'P', 't'
};

#elif defined(PAR)

sof's avatar
sof committed
78
static char *par_debug_opts_strs[] = {
79
  "DEBUG (-qDv, -qD1): verbose; be generally verbose with parallel related stuff.\n",
80
  "DEBUG (-qDq, -qD2): bq; print blocking queues.\n",
81 82 83
  "DEBUG (-qDs, -qD4): schedule; scheduling of parallel threads.\n",
  "DEBUG (-qDe, -qD8): free; free messages.\n",
  "DEBUG (-qDr, -qD16): resume; resume messages.\n",
84
  "DEBUG (-qDw, -qD32): weight; print weights and distrib GC stuff.\n",
85
  "DEBUG (-qDF, -qD64): fetch; fetch messages.\n",
86 87 88 89 90
  // "DEBUG (-qDa, -qD128): ack; ack messages.\n",
  "DEBUG (-qDf, -qD128): fish; fish messages.\n",
  //"DEBUG (-qDo, -qD512): forward; forwarding messages to other PEs.\n",
  "DEBUG (-qDl, -qD256): tables; print internal LAGA etc tables.\n",
  "DEBUG (-qDo, -qD512): packet; packets and graph structures when packing.\n",
91 92
  "DEBUG (-qDp, -qD1024): pack; packing and unpacking graphs.\n",
  "DEBUG (-qDz, -qD2048): paranoia; ridiculously detailed output (excellent for filling a partition).\n"
93 94 95
};

/* one character codes for the available debug options */
sof's avatar
sof committed
96
static char par_debug_opts_flags[] = {
97
  'v', 'q', 's', 'e', 'r', 'w', 'F', 'f', 'l', 'o', 'p', 'z'
98 99 100 101
};

#endif /* PAR */

102 103 104 105
/* -----------------------------------------------------------------------------
   Static function decls
   -------------------------------------------------------------------------- */

106
static int		/* return NULL on error */
107 108 109 110
open_stats_file (
    I_ arg,
    int argc, char *argv[],
    int rts_argc, char *rts_argv[],
111 112
    const char *FILENAME_FMT,
    FILE **file_ret);
113 114 115 116

static I_ decode(const char *s);
static void bad_option(const char *s);

117 118 119 120 121 122 123 124 125 126 127
#if defined(GRAN)
static void enable_GranSimLight(void);
static void process_gran_option(int arg, int *rts_argc, char *rts_argv[], rtsBool *error);
static void set_GranSim_debug_options(nat n);
static void help_GranSim_debug_options(nat n);
#elif defined(PAR)
static void process_par_option(int arg, int *rts_argc, char *rts_argv[], rtsBool *error);
static void set_par_debug_options(nat n);
static void help_par_debug_options(nat n);
#endif

128 129 130 131 132 133 134 135 136
/* -----------------------------------------------------------------------------
 * Command-line option parsing routines.
 * ---------------------------------------------------------------------------*/

void initRtsFlagsDefaults(void)
{
    RtsFlags.GcFlags.statsFile		= NULL;
    RtsFlags.GcFlags.giveStats		= NO_GC_STATS;

137
    RtsFlags.GcFlags.maxStkSize		= (8 * 1024 * 1024) / sizeof(W_);
138 139
    RtsFlags.GcFlags.initialStkSize	= 1024 / sizeof(W_);

140
    RtsFlags.GcFlags.minAllocAreaSize   = (512 * 1024)        / BLOCK_SIZE;
141
    RtsFlags.GcFlags.minOldGenSize      = (1024 * 1024)       / BLOCK_SIZE;
142
    RtsFlags.GcFlags.maxHeapSize	= 0;    /* off by default */
143
    RtsFlags.GcFlags.heapSizeSuggestion	= 0;    /* none */
144
    RtsFlags.GcFlags.pcFreeHeap		= 3;	/* 3% */
145
    RtsFlags.GcFlags.oldGenFactor       = 2;
146 147 148 149 150 151
#if defined(PAR)
    /* A hack currently needed for GUM -- HWL */
    RtsFlags.GcFlags.generations        = 1;
    RtsFlags.GcFlags.steps              = 2;
    RtsFlags.GcFlags.squeezeUpdFrames	= rtsFalse;
#else
152
    RtsFlags.GcFlags.generations        = 2;
153
    RtsFlags.GcFlags.steps              = 2;
154
    RtsFlags.GcFlags.squeezeUpdFrames	= rtsTrue;
155
#endif
156
    RtsFlags.GcFlags.compact            = rtsFalse;
157
    RtsFlags.GcFlags.compactThreshold   = 30.0;
158
    RtsFlags.GcFlags.sweep              = rtsFalse;
159 160 161
#ifdef RTS_GTK_FRONTPANEL
    RtsFlags.GcFlags.frontpanel         = rtsFalse;
#endif
162
    RtsFlags.GcFlags.idleGCDelayTime    = 300; /* millisecs */
163

164 165 166 167 168 169 170 171 172 173 174 175
#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

176 177
#ifdef DEBUG
    RtsFlags.DebugFlags.scheduler	= rtsFalse;
178
    RtsFlags.DebugFlags.interpreter	= rtsFalse;
179 180 181 182 183 184
    RtsFlags.DebugFlags.weak		= rtsFalse;
    RtsFlags.DebugFlags.gccafs		= rtsFalse;
    RtsFlags.DebugFlags.gc		= rtsFalse;
    RtsFlags.DebugFlags.block_alloc	= rtsFalse;
    RtsFlags.DebugFlags.sanity		= rtsFalse;
    RtsFlags.DebugFlags.stable		= rtsFalse;
185
    RtsFlags.DebugFlags.stm             = rtsFalse;
186
    RtsFlags.DebugFlags.prof		= rtsFalse;
Simon Marlow's avatar
Simon Marlow committed
187
    RtsFlags.DebugFlags.eventlog        = rtsFalse;
188 189
    RtsFlags.DebugFlags.gran		= rtsFalse;
    RtsFlags.DebugFlags.par		= rtsFalse;
190
    RtsFlags.DebugFlags.apply		= rtsFalse;
191
    RtsFlags.DebugFlags.linker		= rtsFalse;
192
    RtsFlags.DebugFlags.squeeze		= rtsFalse;
193
    RtsFlags.DebugFlags.hpc		= rtsFalse;
Simon Marlow's avatar
Simon Marlow committed
194
    RtsFlags.DebugFlags.timestamp	= rtsFalse;
195 196
#endif

197 198 199 200
#if defined(PROFILING) || defined(PAR)
    RtsFlags.CcFlags.doCostCentres	= 0;
#endif /* PROFILING or PAR */

201
    RtsFlags.ProfFlags.doHeapProfile      = rtsFalse;
202
    RtsFlags.ProfFlags.profileInterval    = 100;
203 204

#ifdef PROFILING
205
    RtsFlags.ProfFlags.includeTSOs        = rtsFalse;
206
    RtsFlags.ProfFlags.showCCSOnException = rtsFalse;
207
    RtsFlags.ProfFlags.maxRetainerSetSize = 8;
ravi@bluespec.com's avatar
ravi@bluespec.com committed
208
    RtsFlags.ProfFlags.ccsLength          = 25;
209 210 211 212
    RtsFlags.ProfFlags.modSelector        = NULL;
    RtsFlags.ProfFlags.descrSelector      = NULL;
    RtsFlags.ProfFlags.typeSelector       = NULL;
    RtsFlags.ProfFlags.ccSelector         = NULL;
213
    RtsFlags.ProfFlags.ccsSelector        = NULL;
214 215
    RtsFlags.ProfFlags.retainerSelector   = NULL;
    RtsFlags.ProfFlags.bioSelector        = NULL;
216 217
#endif

Simon Marlow's avatar
Simon Marlow committed
218 219 220 221
#ifdef EVENTLOG
    RtsFlags.EventLogFlags.doEventLogging = rtsFalse;
#endif

222 223
    RtsFlags.MiscFlags.tickInterval	= 20;  /* In milliseconds */
    RtsFlags.ConcFlags.ctxtSwitchTime	= 20;  /* In milliseconds */
224

225
    RtsFlags.MiscFlags.install_signal_handlers = rtsTrue;
Ian Lynagh's avatar
Ian Lynagh committed
226
    RtsFlags.MiscFlags.machineReadable = rtsFalse;
227
    RtsFlags.MiscFlags.linkerMemBase    = 0;
228

229
#ifdef THREADED_RTS
230
    RtsFlags.ParFlags.nNodes	        = 1;
231 232
    RtsFlags.ParFlags.migrate           = rtsTrue;
    RtsFlags.ParFlags.wakeupMigrate     = rtsFalse;
233 234
    RtsFlags.ParFlags.parGcEnabled      = 1;
    RtsFlags.ParFlags.parGcGen          = 1;
235
    RtsFlags.ParFlags.parGcLoadBalancing = 1;
236
#endif
237

238
#ifdef PAR
239
    RtsFlags.ParFlags.ParStats.Full   	  = rtsFalse;
240
    RtsFlags.ParFlags.ParStats.Suppressed = rtsFalse;
241 242 243 244 245 246
    RtsFlags.ParFlags.ParStats.Binary 	  = rtsFalse;
    RtsFlags.ParFlags.ParStats.Sparks 	  = rtsFalse;
    RtsFlags.ParFlags.ParStats.Heap   	  = rtsFalse;
    RtsFlags.ParFlags.ParStats.NewLogfile = rtsFalse;
    RtsFlags.ParFlags.ParStats.Global     = rtsFalse;

247
    RtsFlags.ParFlags.outputDisabled	= rtsFalse;
248 249 250 251 252
#ifdef DIST
    RtsFlags.ParFlags.doFairScheduling  = rtsTrue;  /* fair sched by def */
#else
    RtsFlags.ParFlags.doFairScheduling  = rtsFalse;  /* unfair sched by def */
#endif
253
    RtsFlags.ParFlags.packBufferSize	= 1024;
254 255
    RtsFlags.ParFlags.thunksToPack      = 1; /* 0 ... infinity; */
    RtsFlags.ParFlags.globalising       = 1; /* 0 ... everything */
256 257 258
    RtsFlags.ParFlags.maxThreads        = 1024;
    RtsFlags.ParFlags.maxFishes        = MAX_FISHES;
    RtsFlags.ParFlags.fishDelay         = FISH_DELAY;
259 260
#endif

261
#if defined(PAR) || defined(THREADED_RTS)
262
    RtsFlags.ParFlags.maxLocalSparks	= 4096;
263
#endif /* PAR || THREADED_RTS */
264 265 266

#if defined(GRAN)
    /* ToDo: check defaults for GranSim and GUM */
267
    RtsFlags.GcFlags.maxStkSize		= (8 * 1024 * 1024) / sizeof(W_);
268 269
    RtsFlags.GcFlags.initialStkSize	= 1024 / sizeof(W_);

270
    RtsFlags.GranFlags.maxThreads	= 65536; // refers to mandatory threads
271 272 273 274 275 276 277
    RtsFlags.GranFlags.GranSimStats.Full	= rtsFalse;
    RtsFlags.GranFlags.GranSimStats.Suppressed	= rtsFalse;
    RtsFlags.GranFlags.GranSimStats.Binary      = rtsFalse;
    RtsFlags.GranFlags.GranSimStats.Sparks      = rtsFalse;
    RtsFlags.GranFlags.GranSimStats.Heap        = rtsFalse;
    RtsFlags.GranFlags.GranSimStats.NewLogfile  = rtsFalse;
    RtsFlags.GranFlags.GranSimStats.Global      = rtsFalse;
278 279 280 281

    RtsFlags.GranFlags.packBufferSize	= 1024;
    RtsFlags.GranFlags.packBufferSize_internal = GRANSIM_DEFAULT_PACK_BUFFER_SIZE;

282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320
    RtsFlags.GranFlags.proc         = MAX_PROC;
    RtsFlags.GranFlags.Fishing      = rtsFalse;
    RtsFlags.GranFlags.maxFishes   = MAX_FISHES;
    RtsFlags.GranFlags.time_slice   = GRAN_TIME_SLICE;
    RtsFlags.GranFlags.Light        = rtsFalse;

    RtsFlags.GranFlags.Costs.latency =             LATENCY;          
    RtsFlags.GranFlags.Costs.additional_latency =  ADDITIONAL_LATENCY; 
    RtsFlags.GranFlags.Costs.fetchtime =           FETCHTIME; 
    RtsFlags.GranFlags.Costs.lunblocktime =        LOCALUNBLOCKTIME; 
    RtsFlags.GranFlags.Costs.gunblocktime =        GLOBALUNBLOCKTIME;
    RtsFlags.GranFlags.Costs.mpacktime =           MSGPACKTIME;      
    RtsFlags.GranFlags.Costs.munpacktime =         MSGUNPACKTIME;
    RtsFlags.GranFlags.Costs.mtidytime =           MSGTIDYTIME;

    RtsFlags.GranFlags.Costs.threadcreatetime =         THREADCREATETIME;
    RtsFlags.GranFlags.Costs.threadqueuetime =          THREADQUEUETIME;
    RtsFlags.GranFlags.Costs.threaddescheduletime =     THREADDESCHEDULETIME;
    RtsFlags.GranFlags.Costs.threadscheduletime =       THREADSCHEDULETIME;
    RtsFlags.GranFlags.Costs.threadcontextswitchtime =  THREADCONTEXTSWITCHTIME;

    RtsFlags.GranFlags.Costs.arith_cost =         ARITH_COST;       
    RtsFlags.GranFlags.Costs.branch_cost =        BRANCH_COST; 
    RtsFlags.GranFlags.Costs.load_cost =          LOAD_COST;        
    RtsFlags.GranFlags.Costs.store_cost =         STORE_COST; 
    RtsFlags.GranFlags.Costs.float_cost =         FLOAT_COST;       

    RtsFlags.GranFlags.Costs.heapalloc_cost =     HEAPALLOC_COST;

    RtsFlags.GranFlags.Costs.pri_spark_overhead = PRI_SPARK_OVERHEAD;        
    RtsFlags.GranFlags.Costs.pri_sched_overhead = PRI_SCHED_OVERHEAD;        

    RtsFlags.GranFlags.DoFairSchedule           = rtsFalse;             
    RtsFlags.GranFlags.DoAsyncFetch             = rtsFalse;        
    RtsFlags.GranFlags.DoStealThreadsFirst      = rtsFalse;        
    RtsFlags.GranFlags.DoAlwaysCreateThreads    = rtsFalse;      
    RtsFlags.GranFlags.DoBulkFetching           = rtsFalse;             
    RtsFlags.GranFlags.DoThreadMigration        = rtsFalse;          
    RtsFlags.GranFlags.FetchStrategy            = 2;                     
321
    RtsFlags.GranFlags.PreferSparksOfLocalNodes = rtsFalse;   
322 323 324 325 326 327 328 329 330
    RtsFlags.GranFlags.DoPrioritySparking       = rtsFalse;         
    RtsFlags.GranFlags.DoPriorityScheduling     = rtsFalse;       
    RtsFlags.GranFlags.SparkPriority            = 0;
    RtsFlags.GranFlags.SparkPriority2           = 0; 
    RtsFlags.GranFlags.RandomPriorities         = rtsFalse;           
    RtsFlags.GranFlags.InversePriorities        = rtsFalse;          
    RtsFlags.GranFlags.IgnorePriorities         = rtsFalse;           
    RtsFlags.GranFlags.ThunksToPack             = 0;                      
    RtsFlags.GranFlags.RandomSteal              = rtsTrue;
331 332 333
#endif

#ifdef TICKY_TICKY
334 335
    RtsFlags.TickyFlags.showTickyStats	 = rtsFalse;
    RtsFlags.TickyFlags.tickyFile	 = NULL;
336
#endif
Simon Marlow's avatar
Simon Marlow committed
337

338
#ifdef USE_PAPI
339 340
    /* By default no special measurements taken */
    RtsFlags.PapiFlags.eventType        = 0;
341
    RtsFlags.PapiFlags.numUserEvents    = 0;
342
#endif
343 344 345 346 347 348 349 350 351 352 353 354 355 356
}

static const char *
usage_text[] = {
"",
"Usage: <prog> <args> [+RTS <rtsopts> | -RTS <args>] ... --RTS <args>",
"",
"   +RTS    Indicates run time system options follow",
"   -RTS    Indicates program arguments follow",
"  --RTS    Indicates that ALL subsequent arguments will be given to the",
"           program (including any of these RTS flags)",
"",
"The following run time system options are available:",
"",
357
"  -?       Prints this message and exits; the program is not executed",
358
"  --info   Print information about the RTS used by this program",
359
"",
360
"  -K<size> Sets the maximum stack size (default 8M)  Egs: -K32k   -K512k",
sof's avatar
sof committed
361
"  -k<size> Sets the initial thread stack size (default 1k)  Egs: -k4k   -k2m",
362 363
"",
"  -A<size> Sets the minimum allocation area size (default 256k) Egs: -A1m -A10k",
364
"  -M<size> Sets the maximum heap size (default unlimited)  Egs: -M256k -M1G",
365
"  -H<size> Sets the minimum heap size (default 0M)   Egs: -H24m  -H1G",
366
"  -m<n>    Minimum % of heap which must be available (default 3%)",
367
"  -G<n>    Number of generations (default: 2)",
368
"  -T<n>    Number of steps in younger generations (default: 2)",
369 370
"  -c<n>    Auto-enable compaction of the oldest generation when live data is",
"           at least <n>% of the maximum heap size set with -M (default: 30%)",
371
"  -c       Enable compaction for all major collections",
372
"  -w       Use mark-region for the oldest generation (experimental)",
373
#if defined(THREADED_RTS)
374 375
"  -I<sec>  Perform full GC after <sec> idle time (default: 0.3, 0 == off)",
#endif
376
"",
377 378 379
"  -t[<file>] One-line GC statistics (if <file> omitted, uses stderr)",
"  -s[<file>] Summary  GC statistics (if <file> omitted, uses stderr)",
"  -S[<file>] Detailed GC statistics (if <file> omitted, uses stderr)",
380 381 382
#ifdef RTS_GTK_FRONTPANEL
"  -f       Display front panel (requires X11 & GTK+)",
#endif
383 384 385 386 387 388
"",
"",
"  -Z       Don't squeeze out update frames on stack overflow",
"  -B       Sound the bell at the start of each garbage collection",
#if defined(PROFILING) || defined(PAR)
"",
389
"  -px      Time/allocation profile (XML)  (output file <program>.prof)",
andy's avatar
andy committed
390 391 392
"  -p       Time/allocation profile        (output file <program>.prof)",
"  -P       More detailed Time/Allocation profile",
"  -Pa      Give information about *all* cost centres",
393

394 395
# if defined(PROFILING)
"",
396 397 398 399 400 401 402 403
"  -hx            Heap residency profile (XML)   (output file <program>.prof)",
"  -h<break-down> Heap residency profile (hp2ps) (output file <program>.hp)",
"     break-down: c = cost centre stack (default)",
"                 m = module",
"                 d = closure description",
"                 y = type description",
"                 r = retainer",
"                 b = biography (LAG,DRAG,VOID,USE)",
404
"  A subset of closures may be selected thusly:",
405 406
"    -hc<cc>,...  specific cost centre(s) (top of stack only)",
"    -hC<cc>,...  specific cost centre(s) (anywhere in stack)",
407 408 409 410 411
"    -hm<mod>...  all cost centres from the specified modules(s)",
"    -hd<des>,... closures with specified closure descriptions",
"    -hy<typ>...  closures with specified type descriptions",
"    -hr<cc>...   closures with specified retainers",
"    -hb<bio>...  closures with specified biographies (lag,drag,void,use)",
412 413
"",
"  -R<size>       Set the maximum retainer set size (default: 8)",
ravi@bluespec.com's avatar
ravi@bluespec.com committed
414 415 416
"", 
"  -L<chars>      Maximum length of a cost-centre stack in a heap profile",
"                 (default: 25)",
417
"",
418 419
"  -xt            Include threads (TSOs) in a heap profile",
"",
420
"  -xc      Show current cost centre stack on raising an exception",
421
"",
422 423
# endif
#endif /* PROFILING or PAR */
Simon Marlow's avatar
Simon Marlow committed
424 425 426 427 428 429 430

#ifdef EVENTLOG
"",
"  -l       Log runtime events (generates binary trace file <program>.eventlog)",
"",
#endif

431
#if !defined(PROFILING)
432
"",
433
"  -hT      Heap residency profile (output file <program>.hp)",
434
#endif
435
"  -i<sec>  Time between heap samples (seconds, default: 0.1)",
436 437
"",
#if defined(TICKY_TICKY)
438
"  -r<file>  Produce ticky-ticky statistics (with -rstderr for stderr)",
439 440
"",
#endif
441
#if defined(PAR)
442 443
"  -N<n>     Use <n> PVMish processors in parallel (default: 2)",
/* NB: the -N<n> is implemented by the driver!! */
444
#endif
445 446 447
"  -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.",
448
"  -V<secs>  Master tick interval in seconds (0 == disable timer).",
449 450
"            This sets the resolution for -C and the profile timer -i.",
"            Default: 0.02 sec.",
451
"",
Simon Marlow's avatar
Simon Marlow committed
452
"  -vt       Time-stamp debug messages",
Simon Marlow's avatar
Simon Marlow committed
453
"",
454 455
#if defined(DEBUG)
"  -Ds  DEBUG: scheduler",
456
"  -Di  DEBUG: interpreter",
457 458 459 460 461 462 463
"  -Dw  DEBUG: weak",
"  -DG  DEBUG: gccafs",
"  -Dg  DEBUG: gc",
"  -Db  DEBUG: block",
"  -DS  DEBUG: sanity",
"  -Dt  DEBUG: stable",
"  -Dp  DEBUG: prof",
Simon Marlow's avatar
Simon Marlow committed
464
"  -De  DEBUG: event logging",
465 466
"  -Dr  DEBUG: gran",
"  -DP  DEBUG: par",
467
"  -Da  DEBUG: apply",
468
"  -Dl  DEBUG: linker",
469
"  -Dm  DEBUG: stm",
470
"  -Dz  DEBUG: stack squezing",
471
"  -Dc  DEBUG: program coverage",
472
"",
473
#endif /* DEBUG */
474
#if defined(THREADED_RTS) && !defined(NOSMP)
475 476
"  -N<n>     Use <n> processors (default: 1)",
"  -N        Determine the number of processors to use automatically",
477 478
"  -q1       Use one OS thread for GC (turns off parallel GC)",
"  -qg<n>    Use parallel GC only for generations >= <n> (default: 1)",
479 480
"  -qm       Don't automatically migrate threads between CPUs",
"  -qw       Migrate a thread to the current CPU when it is woken up",
481
#endif
482 483
"  --install-signal-handlers=<yes|no>",
"            Install signal handlers (default: yes)",
484
#if defined(THREADED_RTS) || defined(PAR)
485 486 487
"  -e<size>  Size of spark pools (default 100)",
#endif
#if defined(PAR)
488 489 490 491 492
"  -t<num>   Set maximum number of advisory threads per PE (default 32)",
"  -qP       Enable activity profile (output files in ~/<program>*.gr)",
"  -qQ<size> Set pack-buffer size (default: 1024)",
"  -qd       Turn on PVM-ish debugging",
"  -qO       Disable output for performance measurement",
493
#endif
494
#if defined(THREADED_RTS) || defined(PAR)
495 496
"  -e<n>     Maximum number of outstanding local sparks (default: 4096)",
#endif
497
#if defined(PAR)
498 499
"  -d        Turn on PVM-ish debugging",
"  -O        Disable output for performance measurement",
500 501
#endif /* PAR */
#if defined(GRAN)  /* ToDo: fill in decent Docu here */
502
"  -b...     All GranSim options start with -b; see GranSim User's Guide for details",
503
#endif
504 505 506 507
#if defined(x86_64_HOST_ARCH)
"  -xm       Base address to mmap memory in the GHCi linker",
"            (hex; must be <80000000)",
#endif
508
#if defined(USE_PAPI)
509 510
"  -aX       CPU performance counter measurements using PAPI",
"            (use with the -s<file> option).  X is one of:",
511 512 513 514 515 516
"",
/* "            y - cycles", */
"            1 - level 1 cache misses",
"            2 - level 2 cache misses",
"            b - branch mispredictions",
"            s - stalled cycles",
517
"            e - cache miss and branch misprediction events",
518
#endif
519
"",
520 521
"RTS options may also be specified using the GHCRTS environment variable.",
"",
522 523 524 525 526 527
"Other RTS options may be available for programs compiled a different way.",
"The GHC User's Guide has full details.",
"",
0
};

sof's avatar
sof committed
528
STATIC_INLINE rtsBool
529 530 531 532 533
strequal(const char *a, const char * b)
{
    return(strcmp(a, b) == 0);
}

534 535 536 537 538 539 540 541 542 543 544 545 546 547
static void
splitRtsFlags(char *s, int *rts_argc, char *rts_argv[])
{
    char *c1, *c2;

    c1 = s;
    do {
	while (isspace(*c1)) { c1++; };
	c2 = c1;
	while (!isspace(*c2) && *c2 != '\0') { c2++; };
	
	if (c1 == c2) { break; }
	
	if (*rts_argc < MAX_RTS_ARGS-1) {
sof's avatar
sof committed
548
	    s = stgMallocBytes(c2-c1+1, "RtsFlags.c:splitRtsFlags()");
549 550 551 552 553 554 555 556 557 558 559
	    strncpy(s, c1, c2-c1);
	    s[c2-c1] = '\0';
	    rts_argv[(*rts_argc)++] = s;
	} else {
	    barf("too many RTS arguments (max %d)", MAX_RTS_ARGS-1);
	}
	
	c1 = c2;
    } while (*c1 != '\0');
}
    
560 561 562 563 564 565 566
void
setupRtsFlags(int *argc, char *argv[], int *rts_argc, char *rts_argv[])
{
    rtsBool error = rtsFalse;
    I_ mode;
    I_ arg, total_arg;

567
    setProgName (argv);
568 569 570 571 572 573
    total_arg = *argc;
    arg = 1;

    *argc = 1;
    *rts_argc = 0;

574 575 576 577 578 579 580 581 582
    // process arguments from the ghc_rts_opts global variable first.
    // (arguments from the GHCRTS environment variable and the command
    // line override these).
    {
	if (ghc_rts_opts != NULL) {
	    splitRtsFlags(ghc_rts_opts, rts_argc, rts_argv);
	}
    }

583
    // process arguments from the GHCRTS environment variable next
584
    // (arguments from the command line override these).
585 586 587 588
    {
	char *ghc_rts = getenv("GHCRTS");

	if (ghc_rts != NULL) {
589
	    splitRtsFlags(ghc_rts, rts_argc, rts_argv);
590 591
	}
    }
592

593 594 595
    // Split arguments (argv) into PGM (argv) and RTS (rts_argv) parts
    //   argv[0] must be PGM argument -- leave in argv

596 597 598 599 600 601 602 603 604 605 606 607
    for (mode = PGM; arg < total_arg; arg++) {
	// The '--RTS' argument disables all future +RTS ... -RTS processing.
	if (strequal("--RTS", argv[arg])) {
	    arg++;
	    break;
	}
	// The '--' argument is passed through to the program, but
	// disables all further +RTS ... -RTS processing.
	else if (strequal("--", argv[arg])) {
	    break;
	}
	else if (strequal("+RTS", argv[arg])) {
608 609 610 611 612 613 614 615 616 617 618 619 620 621 622
	    mode = RTS;
	}
	else if (strequal("-RTS", argv[arg])) {
	    mode = PGM;
	}
	else if (mode == RTS && *rts_argc < MAX_RTS_ARGS-1) {
	    rts_argv[(*rts_argc)++] = argv[arg];
	}
	else if (mode == PGM) {
	    argv[(*argc)++] = argv[arg];
	}
	else {
	  barf("too many RTS arguments (max %d)", MAX_RTS_ARGS-1);
	}
    }
623 624 625
    // process remaining program arguments
    for (; arg < total_arg; arg++) {
	argv[(*argc)++] = argv[arg];
626 627 628 629 630
    }
    argv[*argc] = (char *) 0;
    rts_argv[*rts_argc] = (char *) 0;

    // Process RTS (rts_argv) part: mainly to determine statsfile
631 632 633
    for (arg = 0; arg < *rts_argc; arg++) {
	if (rts_argv[arg][0] != '-') {
	    fflush(stdout);
634
	    errorBelch("unexpected RTS argument: %s", rts_argv[arg]);
635 636 637 638 639 640 641 642 643 644
	    error = rtsTrue;

        } else {
	    switch(rts_argv[arg][1]) {

	      /* process: general args, then PROFILING-only ones,
		 then CONCURRENT-only, PARallel-only, GRAN-only,
		 TICKY-only (same order as defined in RtsFlags.lh);
		 within those groups, mostly in case-insensitive
		 alphabetical order.
645
                 Final group is x*, which allows for more options.
646 647 648 649 650 651
	      */

#ifdef TICKY_TICKY
# define TICKY_BUILD_ONLY(x) x
#else
# define TICKY_BUILD_ONLY(x) \
652
errorBelch("not built for: ticky-ticky stats"); \
653 654 655 656 657 658 659
error = rtsTrue;
#endif

#if defined(PROFILING) 
# define COST_CENTRE_USING_BUILD_ONLY(x) x
#else
# define COST_CENTRE_USING_BUILD_ONLY(x) \
660
errorBelch("not built for: -prof or -parallel"); \
661 662 663 664 665 666 667
error = rtsTrue;
#endif

#ifdef PROFILING
# define PROFILING_BUILD_ONLY(x)   x
#else
# define PROFILING_BUILD_ONLY(x) \
668
errorBelch("not built for: -prof"); \
669 670 671
error = rtsTrue;
#endif

Simon Marlow's avatar
Simon Marlow committed
672 673 674 675 676 677 678 679
#ifdef EVENTLOG
# define EVENTLOG_BUILD_ONLY(x)   x
#else
# define EVENTLOG_BUILD_ONLY(x) \
errorBelch("not built for: -par-prof"); \
error = rtsTrue;
#endif

680 681 682 683
#ifdef PAR
# define PAR_BUILD_ONLY(x)      x
#else
# define PAR_BUILD_ONLY(x) \
684
errorBelch("not built for: -parallel"); \
685 686 687
error = rtsTrue;
#endif

688 689 690 691 692 693 694 695 696 697
#ifdef THREADED_RTS
# define THREADED_BUILD_ONLY(x)      x
#else
# define THREADED_BUILD_ONLY(x) \
errorBelch("not built for: -smp"); \
error = rtsTrue;
#endif

#if defined(THREADED_RTS) || defined(PAR)
# define PAR_OR_THREADED_BUILD_ONLY(x)      x
698
#else
699
# define PAR_OR_THREADED_BUILD_ONLY(x) \
700
errorBelch("not built for: -parallel or -smp"); \
701 702 703 704 705 706 707
error = rtsTrue;
#endif

#ifdef GRAN
# define GRAN_BUILD_ONLY(x)     x
#else
# define GRAN_BUILD_ONLY(x) \
708
errorBelch("not built for: -gransim"); \
709 710 711 712 713 714 715 716
error = rtsTrue;
#endif

	      /* =========== GENERAL ========================== */
	      case '?':
		error = rtsTrue;
		break;

717 718 719 720 721 722 723 724 725 726 727 728
              /* 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;
                  }
Ian Lynagh's avatar
Ian Lynagh committed
729 730 731 732
                  else if (strequal("machine-readable",
                               &rts_argv[arg][2])) {
                      RtsFlags.MiscFlags.machineReadable = rtsTrue;
                  }
733 734
                  else if (strequal("info",
                               &rts_argv[arg][2])) {
735
                      printRtsInfo();
736 737
                      exit(0);
                  }
738 739 740 741 742
                  else {
		      errorBelch("unknown RTS option: %s",rts_argv[arg]);
		      error = rtsTrue;
                  }
		  break;
743 744 745 746 747 748 749 750
	      case 'A':
		RtsFlags.GcFlags.minAllocAreaSize
		  = decode(rts_argv[arg]+2) / BLOCK_SIZE;
		if (RtsFlags.GcFlags.minAllocAreaSize <= 0) {
		  bad_option(rts_argv[arg]);
		}
		break;

751 752 753 754 755 756 757 758 759 760 761 762 763 764 765
#ifdef USE_PAPI
	      case 'a':
		switch(rts_argv[arg][2]) {
		case '1':
		  RtsFlags.PapiFlags.eventType = PAPI_FLAG_CACHE_L1;
		  break;
		case '2':
		  RtsFlags.PapiFlags.eventType = PAPI_FLAG_CACHE_L2;
		  break;
		case 'b':
		  RtsFlags.PapiFlags.eventType = PAPI_FLAG_BRANCH;
		  break;
		case 's':
		  RtsFlags.PapiFlags.eventType = PAPI_FLAG_STALLS;
		  break;
766 767 768
		case 'e':
		  RtsFlags.PapiFlags.eventType = PAPI_FLAG_CB_EVENTS;
		  break;
769 770 771 772 773 774 775 776
                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;
777 778 779 780 781 782
		default:
		  bad_option( rts_argv[arg] );
		}
		break;
#endif

783 784 785 786
	      case 'B':
		RtsFlags.GcFlags.ringBell = rtsTrue;
		break;

787
	      case 'c':
788 789 790 791
		  if (rts_argv[arg][2] != '\0') {
		      RtsFlags.GcFlags.compactThreshold =
			  atof(rts_argv[arg]+2);
		  } else {
792
		      RtsFlags.GcFlags.compact = rtsTrue;
793 794
		  }
		  break;
795

796 797 798 799
              case 'w':
		RtsFlags.GcFlags.sweep = rtsTrue;
		break;

800 801 802 803 804 805 806
	      case 'F':
	        RtsFlags.GcFlags.oldGenFactor = atof(rts_argv[arg]+2);
	      
		if (RtsFlags.GcFlags.oldGenFactor < 0)
		  bad_option( rts_argv[arg] );
		break;
	      
807 808
#ifdef DEBUG
	      case 'D':
809 810 811 812 813 814 815 816
	      { 
		  char *c;

		  for (c  = rts_argv[arg] + 2; *c != '\0'; c++) {
		      switch (*c) {
		      case 's':
			  RtsFlags.DebugFlags.scheduler = rtsTrue;
			  break;
817 818
		      case 'i':
			  RtsFlags.DebugFlags.interpreter = rtsTrue;
819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840
			  break;
		      case 'w':
			  RtsFlags.DebugFlags.weak = rtsTrue;
			  break;
		      case 'G':
			  RtsFlags.DebugFlags.gccafs = rtsTrue;
			  break;
		      case 'g':
			  RtsFlags.DebugFlags.gc = rtsTrue;
			  break;
		      case 'b':
			  RtsFlags.DebugFlags.block_alloc = rtsTrue;
			  break;
		      case 'S':
			  RtsFlags.DebugFlags.sanity = rtsTrue;
			  break;
		      case 't':
			  RtsFlags.DebugFlags.stable = rtsTrue;
			  break;
		      case 'p':
			  RtsFlags.DebugFlags.prof = rtsTrue;
			  break;
Simon Marlow's avatar
Simon Marlow committed
841 842 843
		      case 'e':
			  RtsFlags.DebugFlags.eventlog = rtsTrue;
                          break;
844 845 846 847 848 849 850 851 852
		      case 'r':
			  RtsFlags.DebugFlags.gran = rtsTrue;
			  break;
		      case 'P':
			  RtsFlags.DebugFlags.par = rtsTrue;
			  break;
		      case 'l':
			  RtsFlags.DebugFlags.linker = rtsTrue;
			  break;
853 854 855
		      case 'a':
			  RtsFlags.DebugFlags.apply = rtsTrue;
			  break;
856 857 858
		      case 'm':
			  RtsFlags.DebugFlags.stm = rtsTrue;
			  break;
859 860 861
		      case 'z':
			  RtsFlags.DebugFlags.squeeze = rtsTrue;
			  break;
862 863 864
		      case 'c':
			  RtsFlags.DebugFlags.hpc = rtsTrue;
			  break;
865 866 867 868 869 870
		      default:
			  bad_option( rts_argv[arg] );
		      }
		  }
		  break;
	      }
871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906
#endif

	      case 'K':
		RtsFlags.GcFlags.maxStkSize = 
		  decode(rts_argv[arg]+2) / sizeof(W_);

		if (RtsFlags.GcFlags.maxStkSize == 0) 
		  bad_option( rts_argv[arg] );
		break;

	      case 'k':
		RtsFlags.GcFlags.initialStkSize = 
		  decode(rts_argv[arg]+2) / sizeof(W_);

		if (RtsFlags.GcFlags.initialStkSize == 0) 
		  bad_option( rts_argv[arg] );
		break;

	      case 'M':
		RtsFlags.GcFlags.maxHeapSize = 
		  decode(rts_argv[arg]+2) / BLOCK_SIZE;
		/* user give size in *bytes* but "maxHeapSize" is in *blocks* */

		if (RtsFlags.GcFlags.maxHeapSize <= 0) {
		  bad_option(rts_argv[arg]);
		}
		break;

	      case 'm':
		RtsFlags.GcFlags.pcFreeHeap = atof(rts_argv[arg]+2);

		if (RtsFlags.GcFlags.pcFreeHeap < 0 || 
		    RtsFlags.GcFlags.pcFreeHeap > 100)
		  bad_option( rts_argv[arg] );
		break;

907 908
	      case 'G':
		RtsFlags.GcFlags.generations = decode(rts_argv[arg]+2);
909
		if (RtsFlags.GcFlags.generations < 1) {
910 911 912 913
		  bad_option(rts_argv[arg]);
		}
		break;

914 915 916 917 918 919 920
	      case 'T':
		RtsFlags.GcFlags.steps = decode(rts_argv[arg]+2);
		if (RtsFlags.GcFlags.steps < 1) {
		  bad_option(rts_argv[arg]);
		}
		break;

921
	      case 'H':
922 923
		RtsFlags.GcFlags.heapSizeSuggestion = 
		  decode(rts_argv[arg]+2) / BLOCK_SIZE;
924 925
		break;

926 927 928 929 930 931
#ifdef RTS_GTK_FRONTPANEL
	      case 'f':
		  RtsFlags.GcFlags.frontpanel = rtsTrue;
		  break;
#endif

932 933 934 935 936 937
    	      case 'I':	/* idle GC delay */
		if (rts_argv[arg][2] == '\0') {
		  /* use default */
		} else {
		    I_ cst; /* tmp */

938
		    /* Convert to millisecs */
939
		    cst = (I_) ((atof(rts_argv[arg]+2) * 1000));
940
		    RtsFlags.GcFlags.idleGCDelayTime = cst;
941 942 943
		}
		break;

944
	      case 'S':
945 946
		  RtsFlags.GcFlags.giveStats = VERBOSE_GC_STATS;
		  goto stats;
947

948
	      case 's':
949 950
		  RtsFlags.GcFlags.giveStats = SUMMARY_GC_STATS;
		  goto stats;
951 952

	      case 't':
953 954
		  RtsFlags.GcFlags.giveStats = ONELINE_GC_STATS;
		  goto stats;
955

956
	    stats:
957
#ifdef PAR
958 959
		/* Opening all those files would almost certainly fail... */
		// RtsFlags.ParFlags.ParStats.Full = rtsTrue;
960
		RtsFlags.GcFlags.statsFile = NULL; /* temporary; ToDo: rm */
961
#else
962 963 964
		{ 
		    int r;
		    r = open_stats_file(arg, *argc, argv,
965
					*rts_argc, rts_argv, NULL,
966 967 968
					&RtsFlags.GcFlags.statsFile);
		    if (r == -1) { error = rtsTrue; }
		}
969
#endif
970
		  break;
971 972 973 974 975 976 977

	      case 'Z':
		RtsFlags.GcFlags.squeezeUpdFrames = rtsFalse;
		break;

	      /* =========== PROFILING ========================== */

Simon Marlow's avatar
Simon Marlow committed
978 979 980 981 982 983 984 985
              case 'l':
#ifdef EVENTLOG
                  RtsFlags.EventLogFlags.doEventLogging = rtsTrue;
#else
                  errorBelch("not built for: -eventlog");
#endif
                  break;

986 987 988 989
	      case 'P': /* detailed cost centre profiling (time/alloc) */
	      case 'p': /* cost centre profiling (time/alloc) */
		COST_CENTRE_USING_BUILD_ONLY(
		switch (rts_argv[arg][2]) {
990 991
		  case 'x':
		    RtsFlags.CcFlags.doCostCentres = COST_CENTRES_XML;
992
		    break;
andy's avatar
andy committed
993 994 995
		  case 'a':
		    RtsFlags.CcFlags.doCostCentres = COST_CENTRES_ALL;
		    break;
996
		  default:
997 998 999 1000 1001 1002 1003 1004
		      if (rts_argv[arg][1] == 'P') {
			  RtsFlags.CcFlags.doCostCentres =
			      COST_CENTRES_VERBOSE;
		      } else {
			  RtsFlags.CcFlags.doCostCentres =
			      COST_CENTRES_SUMMARY;
		      }
		      break;
1005 1006 1007
		}
		) break;

1008 1009 1010 1011
	      case 'R':
		  PROFILING_BUILD_ONLY(
		      RtsFlags.ProfFlags.maxRetainerSetSize = atof(rts_argv[arg]+2);
  	          ) break;
ravi@bluespec.com's avatar
ravi@bluespec.com committed
1012 1013 1014 1015 1016 1017 1018
	      case 'L':
		  PROFILING_BUILD_ONLY(
		      RtsFlags.ProfFlags.ccsLength = atof(rts_argv[arg]+2);
                      if(RtsFlags.ProfFlags.ccsLength <= 0) {
			bad_option(rts_argv[arg]);
                      }
		  ) break;
1019
	      case 'h': /* serial heap profile */
1020
#if !defined(PROFILING)
1021 1022 1023 1024 1025 1026
		switch (rts_argv[arg][2]) {
		  case '\0':
		  case 'T':
		    RtsFlags.ProfFlags.doHeapProfile = HEAP_BY_CLOSURE_TYPE;
		    break;
		  default:
1027
		    errorBelch("invalid heap profile option: %s",rts_argv[arg]);
1028 1029 1030 1031 1032
		    error = rtsTrue;
		}
#else
		PROFILING_BUILD_ONLY(
		switch (rts_argv[arg][2]) {
1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049
		case '\0':
		case 'C':
		case 'c':
		case 'M':
		case 'm':
		case 'D':
		case 'd':
		case 'Y':
		case 'y':
		case 'R':
		case 'r':
		case 'B':
		case 'b':
		    if (rts_argv[arg][2] != '\0' && rts_argv[arg][3] != '\0') {
			{
			    char *left  = strchr(rts_argv[arg], '{');
			    char *right = strrchr(rts_argv[arg], '}');
1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066

			    // curly braces are optional, for
			    // backwards compat.
			    if (left)
				left = left+1;
			    else
				left = rts_argv[arg] + 3;

			    if (!right)
				right = rts_argv[arg] + strlen(rts_argv[arg]);

			    *right = '\0';

			    switch (rts_argv[arg][2]) {
			    case 'c': // cost centre label select
				RtsFlags.ProfFlags.ccSelector = left;
				break;
1067 1068 1069
			    case 'C':
				RtsFlags.ProfFlags.ccsSelector = left;
				break;
1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089
			    case 'M':
			    case 'm': // cost centre module select
				RtsFlags.ProfFlags.modSelector = left;
				break;
			    case 'D':
			    case 'd': // closure descr select 
				RtsFlags.ProfFlags.descrSelector = left;
				break;
			    case 'Y':
			    case 'y': // closure type select
				RtsFlags.ProfFlags.typeSelector = left;
				break;
			    case 'R':
			    case 'r': // retainer select
				RtsFlags.ProfFlags.retainerSelector = left;
				break;
			    case 'B':
			    case 'b': // biography select
				RtsFlags.ProfFlags.bioSelector = left;
				break;
1090 1091 1092 1093
			    }
			}
			break;
		    }
1094

1095
		    if (RtsFlags.ProfFlags.doHeapProfile != 0) {
1096
			errorBelch("multiple heap profile options");
1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108
			error = rtsTrue;
			break;
		    }

		    switch (rts_argv[arg][2]) {
		    case '\0':
		    case 'C':
		    case 'c':
			RtsFlags.ProfFlags.doHeapProfile = HEAP_BY_CCS;
			break;
		    case 'M':
		    case 'm':
1109 1110
			  RtsFlags.ProfFlags.doHeapProfile = HEAP_BY_MOD;
			  break;
simonmar's avatar