#include "Threads.h"
#include "Printer.h"
+#ifdef DEBUG
// debugging flags, set with +RTS -D<something>
int DEBUG_sched;
int DEBUG_interp;
int DEBUG_squeeze;
int DEBUG_hpc;
int DEBUG_sparks;
+#endif
// events
int TRACE_sched;
static Mutex trace_utx;
#endif
+static rtsBool eventlog_enabled;
+
/* ---------------------------------------------------------------------------
Starting up / shuttting down the tracing facilities
--------------------------------------------------------------------------- */
class = RtsFlags.DebugFlags.name ? 1 : 0;
DEBUG_FLAG(scheduler, DEBUG_sched);
- DEBUG_FLAG(scheduler, TRACE_sched); // -Ds enabled all sched events
DEBUG_FLAG(interpreter, DEBUG_interp);
DEBUG_FLAG(weak, DEBUG_weak);
DEBUG_FLAG(sparks, DEBUG_sparks);
#endif
-#define TRACE_FLAG(name, class) \
- class = RtsFlags.TraceFlags.name ? 1 : 0;
+ // -Ds turns on scheduler tracing too
+ TRACE_sched =
+ RtsFlags.TraceFlags.scheduler ||
+ RtsFlags.DebugFlags.scheduler;
- TRACE_FLAG(scheduler, TRACE_sched);
+ eventlog_enabled = RtsFlags.TraceFlags.tracing == TRACE_EVENTLOG;
- initEventLogging();
+ if (eventlog_enabled) {
+ initEventLogging();
+ }
}
void endTracing (void)
{
- endEventLogging();
+ if (eventlog_enabled) {
+ endEventLogging();
+ }
}
void freeTracing (void)
{
- freeEventLogging();
+ if (eventlog_enabled) {
+ freeEventLogging();
+ }
}
/* ---------------------------------------------------------------------------
StgTSO *tso, StgWord64 other)
{
#ifdef DEBUG
- if (RtsFlags.TraceFlags.trace_stderr) {
+ if (RtsFlags.TraceFlags.tracing == TRACE_STDERR) {
traceSchedEvent_stderr(cap, tag, tso, other);
} else
#endif
va_start(ap,msg);
#ifdef DEBUG
- if (RtsFlags.TraceFlags.trace_stderr) {
+ if (RtsFlags.TraceFlags.tracing == TRACE_STDERR) {
traceCap_stderr(cap, msg, ap);
} else
#endif
va_start(ap,msg);
#ifdef DEBUG
- if (RtsFlags.TraceFlags.trace_stderr) {
+ if (RtsFlags.TraceFlags.tracing == TRACE_STDERR) {
trace_stderr(msg, ap);
} else
#endif
va_end(ap);
}
+void traceUserMsg(Capability *cap, char *msg)
+{
+#ifdef DEBUG
+ if (RtsFlags.TraceFlags.tracing == TRACE_STDERR) {
+ traceCap_stderr(cap, msg, NULL);
+ } else
+#endif
+ {
+ if (eventlog_enabled) {
+ postUserMsg(cap, msg);
+ }
+ }
+}
+
void traceThreadStatus_ (StgTSO *tso USED_IF_DEBUG)
{
#ifdef DEBUG
- if (RtsFlags.TraceFlags.trace_stderr) {
+ if (RtsFlags.TraceFlags.tracing == TRACE_STDERR) {
printThreadStatus(tso);
} else
#endif