/* -----------------------------------------------------------------------------
- * $Id: RtsFlags.c,v 1.53 2001/11/26 16:54:21 simonmar Exp $
+ * $Id: RtsFlags.c,v 1.61 2002/10/05 22:18:45 panne Exp $
*
* (c) The AQUA Project, Glasgow University, 1994-1997
* (c) The GHC Team, 1998-1999
#include <ctype.h>
#endif
+#include <stdlib.h>
+#include <string.h>
+
extern struct RTS_FLAGS RtsFlags;
/*
#define RTS 1
#define PGM 0
-char *debug_opts_strs[] = {
- "DEBUG (-D1): scheduler\n",
- "DEBUG (-D2): evaluator\n",
- "DEBUG (-D4): codegen\n",
- "DEBUG (-D8): weak\n",
- "DEBUG (-D16): gccafs\n",
- "DEBUG (-D32): gc\n",
- "DEBUG (-D64): block\n",
- "DEBUG (-D128): sanity\n",
- "DEBUG (-D256): stable\n",
- "DEBUG (-D512): prof\n",
- "DEBUG (-D1024): gran\n",
- "DEBUG (-D2048): par\n",
- "DEBUG (-D4096): linker\n"
-};
-
char *debug_opts_prefix[] = {
"_-", /* scheduler */
"_.", /* evaluator */
static void set_par_debug_options(nat n);
static void help_par_debug_options(nat n);
#endif
-#if defined(DEBUG)
-static void set_debug_options(nat n);
-static void help_debug_options(nat n);
-#endif
//@node Command-line option parsing routines, GranSim specific options, Static function decls
//@subsection Command-line option parsing routines
RtsFlags.GcFlags.frontpanel = rtsFalse;
#endif
+#ifdef DEBUG
+ RtsFlags.DebugFlags.scheduler = rtsFalse;
+ RtsFlags.DebugFlags.evaluator = rtsFalse;
+ RtsFlags.DebugFlags.codegen = rtsFalse;
+ 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;
+ RtsFlags.DebugFlags.prof = rtsFalse;
+ RtsFlags.DebugFlags.gran = rtsFalse;
+ RtsFlags.DebugFlags.par = rtsFalse;
+ RtsFlags.DebugFlags.linker = rtsFalse;
+#endif
+
#if defined(PROFILING) || defined(PAR)
RtsFlags.CcFlags.doCostCentres = 0;
#endif /* PROFILING or PAR */
#ifdef PROFILING
RtsFlags.ProfFlags.doHeapProfile = rtsFalse;
- RtsFlags.ProfFlags.profileInterval = 20;
+ RtsFlags.ProfFlags.profileInterval = 100;
RtsFlags.ProfFlags.showCCSOnException = rtsFalse;
RtsFlags.ProfFlags.maxRetainerSetSize = 8;
RtsFlags.ProfFlags.modSelector = NULL;
RtsFlags.ProfFlags.descrSelector = NULL;
RtsFlags.ProfFlags.typeSelector = NULL;
RtsFlags.ProfFlags.ccSelector = NULL;
+ RtsFlags.ProfFlags.ccsSelector = NULL;
RtsFlags.ProfFlags.retainerSelector = NULL;
RtsFlags.ProfFlags.bioSelector = NULL;
" r = retainer",
" b = biography (LAG,DRAG,VOID,USE)",
" A subset of closures may be selected thusly:",
-" -hc{cc,cc ...} specific cost centre(s) (NOT STACKS!)",
-" -hm{mod,mod...} all cost centres from the specified modules(s)",
-" -hd{des,des...} closures with specified closure descriptions",
-" -hy{typ,typ...} closures with specified type descriptions",
-" -hr{cc,cc...} closures with specified retainers",
-" -hb{bio,bio...} closures with specified biographies (lag,drag,void,use)",
+" -hc<cc>,... specific cost centre(s) (top of stack only)",
+" -hC<cc>,... specific cost centre(s) (anywhere in stack)",
+" -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)",
"",
" -R<size> Set the maximum retainer set size (default: 8)",
"",
-" -i<msec> Time between heap samples (msec, default: 20)",
+" -i<sec> Time between heap samples (seconds, default: 0.1)",
"",
" -xc Show current cost centre stack on raising an exception",
# endif
" -C<secs> Context-switch interval in seconds",
" (0 or no argument means switch as often as possible)",
" the default is .02 sec; resolution is .02 sec",
+"",
+#if defined(DEBUG)
+" -Ds DEBUG: scheduler",
+" -De DEBUG: evaluator",
+" -Dc DEBUG: codegen",
+" -Dw DEBUG: weak",
+" -DG DEBUG: gccafs",
+" -Dg DEBUG: gc",
+" -Db DEBUG: block",
+" -DS DEBUG: sanity",
+" -Dt DEBUG: stable",
+" -Dp DEBUG: prof",
+" -Dr DEBUG: gran",
+" -DP DEBUG: par",
+" -Dl DEBUG: linker",
+"",
+#endif // DEBUG
#if defined(SMP)
" -N<n> Use <n> OS threads (default: 1)",
#endif
#ifdef DEBUG
case 'D':
- if (isdigit(rts_argv[arg][2])) {/* Set all debugging options in one */
- /* hack warning: interpret the flags as a binary number */
- nat n = decode(rts_argv[arg]+2);
- set_debug_options(n);
- }
- break;
+ {
+ char *c;
+
+ for (c = rts_argv[arg] + 2; *c != '\0'; c++) {
+ switch (*c) {
+ case 's':
+ RtsFlags.DebugFlags.scheduler = rtsTrue;
+ break;
+ case 'e':
+ RtsFlags.DebugFlags.evaluator = rtsTrue;
+ break;
+ case 'c':
+ RtsFlags.DebugFlags.codegen = rtsTrue;
+ 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;
+ case 'r':
+ RtsFlags.DebugFlags.gran = rtsTrue;
+ break;
+ case 'P':
+ RtsFlags.DebugFlags.par = rtsTrue;
+ break;
+ case 'l':
+ RtsFlags.DebugFlags.linker = rtsTrue;
+ break;
+ default:
+ bad_option( rts_argv[arg] );
+ }
+ }
+ break;
+ }
#endif
case 'K':
case 'R':
PROFILING_BUILD_ONLY(
RtsFlags.ProfFlags.maxRetainerSetSize = atof(rts_argv[arg]+2);
-
- if (RtsFlags.ProfFlags.maxRetainerSetSize < 0)
- bad_option( rts_argv[arg] );
- break;
) break;
case 'h': /* serial heap profile */
{
char *left = strchr(rts_argv[arg], '{');
char *right = strrchr(rts_argv[arg], '}');
- if (! left || ! right ||
- strrchr(rts_argv[arg], '{') != left ||
- strchr(rts_argv[arg], '}') != right) {
- prog_belch(
- "Invalid heap profiling selection bracketing\n %s\n",
- rts_argv[arg]);
- error = rtsTrue;
- } else {
- *right = '\0';
- switch (rts_argv[arg][2]) {
- case 'C':
- case 'c': // cost centre label select
- RtsFlags.ProfFlags.ccSelector = left + 1;
- break;
- case 'M':
- case 'm': // cost centre module select
- RtsFlags.ProfFlags.modSelector = left + 1;
- break;
- case 'D':
- case 'd': // closure descr select
- RtsFlags.ProfFlags.descrSelector = left + 1;
- break;
- case 'Y':
- case 'y': // closure type select
- RtsFlags.ProfFlags.typeSelector = left + 1;
- break;
- case 'R':
- case 'r': // retainer select
- RtsFlags.ProfFlags.retainerSelector = left + 1;
- break;
- case 'B':
- case 'b': // biography select
- RtsFlags.ProfFlags.bioSelector = left + 1;
- break;
- }
+
+ // 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;
+ case 'C':
+ RtsFlags.ProfFlags.ccsSelector = left;
+ break;
+ 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;
}
}
break;
}
-
+
if (RtsFlags.ProfFlags.doHeapProfile != 0) {
prog_belch("multiple heap profile options");
error = rtsTrue;
} else if (RtsFlags.GranFlags.proc > MAX_PROC ||
RtsFlags.GranFlags.proc < 1)
{
- fprintf(stderr,"setupRtsFlags: no more than %u processors
-allowed\n",
+ fprintf(stderr,"setupRtsFlags: no more than %u processors allowed\n",
MAX_PROC);
*error = rtsTrue;
}
#endif /* PAR */
-#ifdef DEBUG
-static void
-set_debug_options(nat n) {
- nat i;
-
- for (i=0; i<=MAX_DEBUG_OPTION; i++)
- if ((n>>i)&1) {
- fprintf(stderr, debug_opts_strs[i]);
- switch (i) {
- case 0: RtsFlags.DebugFlags.scheduler = rtsTrue; break;
- case 1: RtsFlags.DebugFlags.evaluator = rtsTrue; break;
- case 2: RtsFlags.DebugFlags.codegen = rtsTrue; break;
- case 3: RtsFlags.DebugFlags.weak = rtsTrue; break;
- case 4: RtsFlags.DebugFlags.gccafs = rtsTrue; break;
- case 5: RtsFlags.DebugFlags.gc = rtsTrue; break;
- case 6: RtsFlags.DebugFlags.block_alloc = rtsTrue; break;
- case 7: RtsFlags.DebugFlags.sanity = rtsTrue; break;
- case 8: RtsFlags.DebugFlags.stable = rtsTrue; break;
- case 9: RtsFlags.DebugFlags.prof = rtsTrue; break;
- case 10: RtsFlags.DebugFlags.gran = rtsTrue; break;
- case 11: RtsFlags.DebugFlags.par = rtsTrue; break;
- case 12: RtsFlags.DebugFlags.linker = rtsTrue; break;
- default: barf("set_debug_options: only %d debug options expected",
- MAX_DEBUG_OPTION);
- } /* switch */
- } /* if */
-}
-
-static void
-help_debug_options(nat n) {
- nat i;
-
- for (i=0; i<=MAX_DEBUG_OPTION; i++)
- if ((n>>i)&1)
- fprintf(stderr, debug_opts_strs[i]);
-}
-#endif /* DEBUG */
-
//@node Aux fcts, , GranSim specific options
//@subsection Aux fcts