X-Git-Url: http://git.megacz.com/?a=blobdiff_plain;f=rts%2FTrace.c;h=53fc25a249fa1fd65bcfca90c20a48474b2bd95e;hb=8625c675de45bdb8bcfa795572ce7c47687c147c;hp=7cfb78cc9ad987e29aede2e6e5925bd1b4fe9b3b;hpb=1f56fae4a10f7fb56b8fbab5ab9ad95add1ed1dd;p=ghc-hetmet.git diff --git a/rts/Trace.c b/rts/Trace.c index 7cfb78c..53fc25a 100644 --- a/rts/Trace.c +++ b/rts/Trace.c @@ -9,10 +9,11 @@ // external headers #include "Rts.h" -#ifdef TRACING - // internal headers #include "Trace.h" + +#ifdef TRACING + #include "GetTime.h" #include "Stats.h" #include "eventlog/EventLog.h" @@ -105,6 +106,14 @@ void freeTracing (void) } } +void resetTracing (void) +{ + if (eventlog_enabled) { + abortEventLogging(); // abort eventlog inherited from parent + initEventLogging(); // child starts its own eventlog + } +} + /* --------------------------------------------------------------------------- Emitting trace messages/events --------------------------------------------------------------------------- */ @@ -203,7 +212,7 @@ static void traceSchedEvent_stderr (Capability *cap, EventTypeNum tag, debugBelch("cap %d: GC done\n", cap->no); break; default: - debugBelch("cap %2d: thread %lu: event %d\n\n", + debugBelch("cap %d: thread %lu: event %d\n\n", cap->no, (lnat)tso->id, tag); break; } @@ -243,7 +252,7 @@ static void traceCap_stderr(Capability *cap, char *msg, va_list ap) ACQUIRE_LOCK(&trace_utx); tracePreface(); - debugBelch("cap %2d: ", cap->no); + debugBelch("cap %d: ", cap->no); vdebugBelch(msg,ap); debugBelch("\n"); @@ -298,18 +307,27 @@ void trace_(char *msg, ...) va_end(ap); } -void traceUserMsg(Capability *cap, char *msg) +static void traceFormatUserMsg(Capability *cap, char *msg, ...) { + va_list ap; + va_start(ap,msg); + #ifdef DEBUG if (RtsFlags.TraceFlags.tracing == TRACE_STDERR) { - traceCap_stderr(cap, msg, NULL); + traceCap_stderr(cap, msg, ap); } else #endif { if (eventlog_enabled) { - postUserMsg(cap, msg); + postUserMsg(cap, msg, ap); } } + dtraceUserMsg(cap->no, msg); +} + +void traceUserMsg(Capability *cap, char *msg) +{ + traceFormatUserMsg(cap, "%s", msg); } void traceThreadStatus_ (StgTSO *tso USED_IF_DEBUG) @@ -345,3 +363,15 @@ void traceEnd (void) #endif /* DEBUG */ #endif /* TRACING */ + +// If DTRACE is enabled, but neither DEBUG nor TRACING, we need a C land +// wrapper for the user-msg probe (as we can't expand that in PrimOps.cmm) +// +#if !defined(DEBUG) && !defined(TRACING) && defined(DTRACE) + +void dtraceUserMsgWrapper(Capability *cap, char *msg) +{ + dtraceUserMsg(cap->no, msg); +} + +#endif /* !defined(DEBUG) && !defined(TRACING) && defined(DTRACE) */