X-Git-Url: http://git.megacz.com/?a=blobdiff_plain;f=rts%2FRtsFlags.c;h=93482f50b43cd2dcc8e9d4aca91e4e85c01fd133;hb=refs%2Ftags%2F2010-03-16;hp=12121e84eefbe190c509cae27bc7617aa7ed72d0;hpb=7cb1d9274e84ee2fc2dd610aa4f7686586ca0357;p=ghc-hetmet.git diff --git a/rts/RtsFlags.c b/rts/RtsFlags.c index 12121e8..93482f5 100644 --- a/rts/RtsFlags.c +++ b/rts/RtsFlags.c @@ -10,6 +10,7 @@ #include "PosixSource.h" #include "Rts.h" +#include "RtsOpts.h" #include "RtsUtils.h" #include "Profiling.h" @@ -53,6 +54,9 @@ open_stats_file ( static StgWord64 decodeSize(const char *flag, nat offset, StgWord64 min, StgWord64 max); static void bad_option(const char *s); +#ifdef TRACING +static void read_trace_flags(char *arg); +#endif /* ----------------------------------------------------------------------------- * Command-line option parsing routines. @@ -74,7 +78,6 @@ void initRtsFlagsDefaults(void) RtsFlags.GcFlags.pcFreeHeap = 3; /* 3% */ RtsFlags.GcFlags.oldGenFactor = 2; RtsFlags.GcFlags.generations = 2; - RtsFlags.GcFlags.steps = 2; RtsFlags.GcFlags.squeezeUpdFrames = rtsTrue; RtsFlags.GcFlags.compact = rtsFalse; RtsFlags.GcFlags.compactThreshold = 30.0; @@ -198,7 +201,6 @@ usage_text[] = { " -H Sets the minimum heap size (default 0M) Egs: -H24m -H1G", " -m Minimum % of heap which must be available (default 3%)", " -G Number of generations (default: 2)", -" -T Number of steps in younger generations (default: 2)", " -c Use in-place compaction instead of copying in the oldest generation", " when live data is at least % of the maximum heap size set with", " -M (default: 30%)", @@ -253,18 +255,20 @@ usage_text[] = { " -xt Include threads (TSOs) in a heap profile", "", " -xc Show current cost centre stack on raising an exception", -"", # endif #endif /* PROFILING or PAR */ #ifdef TRACING "", -" -v Log events to stderr", -" -l Log events in binary format to the file .eventlog", -" -vt Include time stamps when tracing events to stderr with -v", -"", -" -ls Log scheduler events", -"", +" -l[flags] Log events in binary format to the file .eventlog", +# ifdef DEBUG +" -v[flags] Log events to stderr", +# endif +" where [flags] can contain:", +" s scheduler events", +# ifdef DEBUG +" t add time stamps (only useful with -v)", +# endif #endif #if !defined(PROFILING) @@ -302,7 +306,7 @@ usage_text[] = { " -Dc DEBUG: program coverage", " -Dr DEBUG: sparks", "", -" NOTE: all -D options also enable -v automatically. Use -l to create a", +" NOTE: DEBUG events are sent to stderr by default; add -l to create a", " binary event log file instead.", "", #endif /* DEBUG */ @@ -410,7 +414,13 @@ setupRtsFlags(int *argc, char *argv[], int *rts_argc, char *rts_argv[]) char *ghc_rts = getenv("GHCRTS"); if (ghc_rts != NULL) { - splitRtsFlags(ghc_rts, rts_argc, rts_argv); + if (rtsOptsEnabled) { + splitRtsFlags(ghc_rts, rts_argc, rts_argv); + } + else { + errorBelch("Warning: Ignoring GHCRTS variable as RTS options are disabled.\n Link with -rtsopts to enable them."); + // We don't actually exit, just warn + } } } @@ -429,7 +439,13 @@ setupRtsFlags(int *argc, char *argv[], int *rts_argc, char *rts_argv[]) break; } else if (strequal("+RTS", argv[arg])) { - mode = RTS; + if (rtsOptsEnabled) { + mode = RTS; + } + else { + errorBelch("RTS options are disabled. Link with -rtsopts to enable them."); + stg_exit(EXIT_FAILURE); + } } else if (strequal("-RTS", argv[arg])) { mode = PGM; @@ -472,7 +488,7 @@ setupRtsFlags(int *argc, char *argv[], int *rts_argc, char *rts_argv[]) # define TICKY_BUILD_ONLY(x) x #else # define TICKY_BUILD_ONLY(x) \ -errorBelch("not built for: ticky-ticky stats"); \ +errorBelch("the flag %s requires the program to be built with -ticky", rts_argv[arg]); \ error = rtsTrue; #endif @@ -480,7 +496,7 @@ error = rtsTrue; # define PROFILING_BUILD_ONLY(x) x #else # define PROFILING_BUILD_ONLY(x) \ -errorBelch("not built for: -prof"); \ +errorBelch("the flag %s requires the program to be built with -prof", rts_argv[arg]); \ error = rtsTrue; #endif @@ -488,7 +504,7 @@ error = rtsTrue; # define TRACING_BUILD_ONLY(x) x #else # define TRACING_BUILD_ONLY(x) \ -errorBelch("not built for: -par-prof"); \ +errorBelch("the flag %s requires the program to be built with -eventlog or -debug", rts_argv[arg]); \ error = rtsTrue; #endif @@ -496,7 +512,15 @@ error = rtsTrue; # define THREADED_BUILD_ONLY(x) x #else # define THREADED_BUILD_ONLY(x) \ -errorBelch("not built for: -smp"); \ +errorBelch("the flag %s requires the program to be built with -threaded", rts_argv[arg]); \ +error = rtsTrue; +#endif + +#ifdef DEBUG +# define DEBUG_BUILD_ONLY(x) x +#else +# define DEBUG_BUILD_ONLY(x) \ +errorBelch("the flag %s requires the program to be built with -debug", rts_argv[arg]); \ error = rtsTrue; #endif @@ -593,8 +617,8 @@ error = rtsTrue; bad_option( rts_argv[arg] ); break; -#ifdef DEBUG case 'D': + DEBUG_BUILD_ONLY( { char *c; @@ -652,9 +676,8 @@ error = rtsTrue; // -Dx also turns on -v. Use -l to direct trace // events to the .eventlog file instead. RtsFlags.TraceFlags.tracing = TRACE_STDERR; - break; - } -#endif + }) + break; case 'K': RtsFlags.GcFlags.maxStkSize = @@ -685,11 +708,6 @@ error = rtsTrue; decodeSize(rts_argv[arg], 2, 1, HS_INT_MAX); break; - case 'T': - RtsFlags.GcFlags.steps = - decodeSize(rts_argv[arg], 2, 1, HS_INT_MAX); - break; - case 'H': if (rts_argv[arg][2] == '\0') { RtsFlags.GcFlags.heapSizeSuggestionAuto = rtsTrue; @@ -745,26 +763,6 @@ error = rtsTrue; /* =========== PROFILING ========================== */ - case 'l': -#ifdef TRACING - switch(rts_argv[arg][2]) { - case '\0': - RtsFlags.TraceFlags.tracing = TRACE_EVENTLOG; - break; - case 's': - RtsFlags.TraceFlags.tracing = TRACE_EVENTLOG; - RtsFlags.TraceFlags.scheduler = rtsTrue; - break; - default: - errorBelch("unknown RTS option: %s",rts_argv[arg]); - error = rtsTrue; - break; - } -#else - errorBelch("not built for: -eventlog"); -#endif - break; - case 'P': /* detailed cost centre profiling (time/alloc) */ case 'p': /* cost centre profiling (time/alloc) */ PROFILING_BUILD_ONLY( @@ -955,7 +953,7 @@ error = rtsTrue; } break; -#if defined(THREADED_RTS) && !defined(NOSMP) +#if !defined(NOSMP) case 'N': THREADED_BUILD_ONLY( if (rts_argv[arg][2] == '\0') { @@ -995,6 +993,7 @@ error = rtsTrue; ) break; case 'q': + THREADED_BUILD_ONLY( switch (rts_argv[arg][2]) { case '\0': errorBelch("incomplete RTS option: %s",rts_argv[arg]); @@ -1033,7 +1032,7 @@ error = rtsTrue; error = rtsTrue; break; } - break; + ) break; #endif /* =========== PARALLEL =========================== */ case 'e': @@ -1066,26 +1065,19 @@ error = rtsTrue; /* =========== TRACING ---------=================== */ + case 'l': + TRACING_BUILD_ONLY( + RtsFlags.TraceFlags.tracing = TRACE_EVENTLOG; + read_trace_flags(&rts_argv[arg][2]); + ); + break; + case 'v': - switch(rts_argv[arg][2]) { -#ifdef TRACING - case '\0': - RtsFlags.TraceFlags.tracing = TRACE_STDERR; - break; - case 't': - RtsFlags.TraceFlags.timestamp = rtsTrue; - break; -#endif - case 's': - case 'g': - // ignored for backwards-compat - break; - default: - errorBelch("unknown RTS option: %s",rts_argv[arg]); - error = rtsTrue; - break; - } - break; + DEBUG_BUILD_ONLY( + RtsFlags.TraceFlags.tracing = TRACE_STDERR; + read_trace_flags(&rts_argv[arg][2]); + ); + break; /* =========== EXTENDED OPTIONS =================== */ @@ -1308,6 +1300,32 @@ decodeSize(const char *flag, nat offset, StgWord64 min, StgWord64 max) return val; } +#if defined(TRACING) +static void read_trace_flags(char *arg) +{ + char *c; + + for (c = arg; *c != '\0'; c++) { + switch(*c) { + case '\0': + break; + case 's': + RtsFlags.TraceFlags.scheduler = rtsTrue; + break; + case 't': + RtsFlags.TraceFlags.timestamp = rtsTrue; + break; + case 'g': + // ignored for backwards-compat + break; + default: + errorBelch("unknown trace option: %c",*c); + break; + } + } +} +#endif + static void GNU_ATTRIBUTE(__noreturn__) bad_option(const char *s) {