+#ifdef TRACING
+
+/*
+ * Record a scheduler event
+ */
+#define traceSchedEvent(cap, tag, tso, other) \
+ if (RTS_UNLIKELY(TRACE_sched)) { \
+ traceSchedEvent_(cap, tag, tso, other); \
+ }
+
+void traceSchedEvent_ (Capability *cap, EventTypeNum tag,
+ StgTSO *tso, StgWord64 other);
+
+
+/*
+ * Record a nullary event
+ */
+#define traceEvent(cap, tag) \
+ if (RTS_UNLIKELY(TRACE_sched)) { \
+ traceEvent_(cap, tag); \
+ }
+
+void traceEvent_ (Capability *cap, EventTypeNum tag);
+
+// variadic macros are C99, and supported by gcc. However, the
+// ##__VA_ARGS syntax is a gcc extension, which allows the variable
+// argument list to be empty (see gcc docs for details).
+
+/*
+ * Emit a trace message on a particular Capability
+ */
+#define traceCap(class, cap, msg, ...) \
+ if (RTS_UNLIKELY(class)) { \
+ traceCap_(cap, msg, ##__VA_ARGS__); \
+ }
+
+void traceCap_(Capability *cap, char *msg, ...);
+
+/*
+ * Emit a trace message
+ */
+#define trace(class, msg, ...) \
+ if (RTS_UNLIKELY(class)) { \
+ trace_(msg, ##__VA_ARGS__); \
+ }
+
+void trace_(char *msg, ...);
+
+/*
+ * A message or event emitted by the program
+ */
+void traceUserMsg(Capability *cap, char *msg);
+
+/*
+ * Emit a debug message (only when DEBUG is defined)
+ */