diff options
author | Duncan Coutts <duncan@well-typed.com> | 2011-07-14 17:31:16 +0100 |
---|---|---|
committer | Duncan Coutts <duncan@well-typed.com> | 2011-07-18 16:31:18 +0100 |
commit | 46b70749971341678c3e4d5cdb2b1ab1a13d039e (patch) | |
tree | c409612c7868e165fa559fcd27cfecfb30ddd994 /rts/Trace.c | |
parent | 02871adf5f27de9e8748c0a24d086f5be5827203 (diff) | |
download | haskell-46b70749971341678c3e4d5cdb2b1ab1a13d039e.tar.gz |
Move GC tracing into a separate trace class
Previously GC was included in the scheduler trace class. It can be
enabled specifically with +RTS -vg or -lg, though note that both -v
and -l on their own now default to a sensible set of trace classes,
currently: scheduler, gc and sparks.
Diffstat (limited to 'rts/Trace.c')
-rw-r--r-- | rts/Trace.c | 90 |
1 files changed, 56 insertions, 34 deletions
diff --git a/rts/Trace.c b/rts/Trace.c index 7d856d6dd7..7f70957fcf 100644 --- a/rts/Trace.c +++ b/rts/Trace.c @@ -47,6 +47,7 @@ int DEBUG_sparks; // events int TRACE_sched; +int TRACE_gc; int TRACE_spark; #ifdef THREADED_RTS @@ -91,6 +92,11 @@ void initTracing (void) RtsFlags.TraceFlags.scheduler || RtsFlags.DebugFlags.scheduler; + // -Dg turns on gc tracing too + TRACE_gc = + RtsFlags.TraceFlags.gc || + RtsFlags.DebugFlags.gc; + // -Dr turns on spark tracing TRACE_spark = RtsFlags.TraceFlags.sparks || @@ -222,27 +228,6 @@ static void traceSchedEvent_stderr (Capability *cap, EventTypeNum tag, case EVENT_SHUTDOWN: // (cap) debugBelch("cap %d: shutting down\n", cap->no); break; - case EVENT_REQUEST_SEQ_GC: // (cap) - debugBelch("cap %d: requesting sequential GC\n", cap->no); - break; - case EVENT_REQUEST_PAR_GC: // (cap) - debugBelch("cap %d: requesting parallel GC\n", cap->no); - break; - case EVENT_GC_START: // (cap) - debugBelch("cap %d: starting GC\n", cap->no); - break; - case EVENT_GC_END: // (cap) - debugBelch("cap %d: finished GC\n", cap->no); - break; - case EVENT_GC_IDLE: // (cap) - debugBelch("cap %d: GC idle\n", cap->no); - break; - case EVENT_GC_WORK: // (cap) - debugBelch("cap %d: GC working\n", cap->no); - break; - case EVENT_GC_DONE: // (cap) - debugBelch("cap %d: GC done\n", cap->no); - break; default: debugBelch("cap %d: thread %lu: event %d\n\n", cap->no, (lnat)tso->id, tag); @@ -266,6 +251,56 @@ void traceSchedEvent_ (Capability *cap, EventTypeNum tag, } } +#ifdef DEBUG +static void traceGcEvent_stderr (Capability *cap, EventTypeNum tag) +{ + ACQUIRE_LOCK(&trace_utx); + + tracePreface(); + switch (tag) { + case EVENT_REQUEST_SEQ_GC: // (cap) + debugBelch("cap %d: requesting sequential GC\n", cap->no); + break; + case EVENT_REQUEST_PAR_GC: // (cap) + debugBelch("cap %d: requesting parallel GC\n", cap->no); + break; + case EVENT_GC_START: // (cap) + debugBelch("cap %d: starting GC\n", cap->no); + break; + case EVENT_GC_END: // (cap) + debugBelch("cap %d: finished GC\n", cap->no); + break; + case EVENT_GC_IDLE: // (cap) + debugBelch("cap %d: GC idle\n", cap->no); + break; + case EVENT_GC_WORK: // (cap) + debugBelch("cap %d: GC working\n", cap->no); + break; + case EVENT_GC_DONE: // (cap) + debugBelch("cap %d: GC done\n", cap->no); + break; + default: + barf("traceGcEvent: unknown event tag %d", tag); + break; + } + + RELEASE_LOCK(&trace_utx); +} +#endif + +void traceGcEvent_ (Capability *cap, EventTypeNum tag) +{ +#ifdef DEBUG + if (RtsFlags.TraceFlags.tracing == TRACE_STDERR) { + traceGcEvent_stderr(cap, tag); + } else +#endif + { + /* currently all GC events are nullary events */ + postEvent(cap, tag); + } +} + void traceCapsetModify_ (EventTypeNum tag, CapsetID capset, StgWord32 other) @@ -360,19 +395,6 @@ void traceSparkCounters_ (Capability *cap, } } - -void traceEvent_ (Capability *cap, EventTypeNum tag) -{ -#ifdef DEBUG - if (RtsFlags.TraceFlags.tracing == TRACE_STDERR) { - traceSchedEvent_stderr(cap, tag, 0, 0, 0); - } else -#endif - { - postEvent(cap,tag); - } -} - #ifdef DEBUG static void traceCap_stderr(Capability *cap, char *msg, va_list ap) { |