// external headers
#include "Rts.h"
-#ifdef TRACING
-
// internal headers
#include "Trace.h"
+
+#ifdef TRACING
+
#include "GetTime.h"
#include "Stats.h"
#include "eventlog/EventLog.h"
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.trace_stderr && (
- TRACE_sched
-#ifdef DEBUG
- | DEBUG_sched
- | DEBUG_interp
- | DEBUG_weak
- | DEBUG_gccafs
- | DEBUG_gc
- | DEBUG_block_alloc
- | DEBUG_sanity
- | DEBUG_stable
- | DEBUG_stm
- | DEBUG_prof
- | DEBUG_linker
- | DEBUG_squeeze
- | DEBUG_hpc
-#endif
- );
+ eventlog_enabled = RtsFlags.TraceFlags.tracing == TRACE_EVENTLOG;
if (eventlog_enabled) {
initEventLogging();
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 %2d: thread %lu: event %d\n\n",
+ debugBelch("cap %d: thread %lu: event %d\n\n",
cap->no, (lnat)tso->id, tag);
break;
}
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
}
}
+void traceEvent_ (Capability *cap, EventTypeNum tag)
+{
+#ifdef DEBUG
+ if (RtsFlags.TraceFlags.tracing == TRACE_STDERR) {
+ traceSchedEvent_stderr(cap, tag, 0, 0);
+ } else
+#endif
+ {
+ postEvent(cap,tag);
+ }
+}
+
#ifdef DEBUG
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");
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);
}
+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, ap);
+ } else
+#endif
+ {
+ if (eventlog_enabled) {
+ 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)
{
#ifdef DEBUG
- if (RtsFlags.TraceFlags.trace_stderr) {
+ if (RtsFlags.TraceFlags.tracing == TRACE_STDERR) {
printThreadStatus(tso);
} else
#endif
#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) */