1 /* -----------------------------------------------------------------------------
3 * (c) The GHC Team, 2008-2009
5 * Support for fast binary event logging.
7 * ---------------------------------------------------------------------------*/
12 #include "rts/EventLogFormat.h"
13 #include "Capability.h"
17 // -----------------------------------------------------------------------------
19 // -----------------------------------------------------------------------------
23 void initTracing (void);
24 void endTracing (void);
25 void freeTracing (void);
29 // -----------------------------------------------------------------------------
31 // -----------------------------------------------------------------------------
33 // debugging flags, set with +RTS -D<something>
34 extern int DEBUG_sched;
35 extern int DEBUG_interp;
36 extern int DEBUG_weak;
37 extern int DEBUG_gccafs;
39 extern int DEBUG_block_alloc;
40 extern int DEBUG_sanity;
41 extern int DEBUG_stable;
43 extern int DEBUG_prof;
44 extern int DEBUG_gran;
46 extern int DEBUG_linker;
47 extern int DEBUG_squeeze;
49 extern int DEBUG_sparks;
52 extern int TRACE_sched;
54 // -----------------------------------------------------------------------------
57 // We use macros rather than inline functions deliberately. We want
58 // the not-taken case to be as efficient as possible, a simple
59 // test-and-jump, and with inline functions gcc seemed to move some of
60 // the instructions from the branch up before the test.
62 // -----------------------------------------------------------------------------
65 void traceBegin (const char *str, ...);
72 * Record a scheduler event
74 #define traceSchedEvent(cap, tag, tso, other) \
75 if (RTS_UNLIKELY(TRACE_sched)) { \
76 traceSchedEvent_(cap, tag, tso, other); \
79 void traceSchedEvent_ (Capability *cap, EventTypeNum tag,
80 StgTSO *tso, StgWord64 other);
84 * Record a nullary event
86 #define traceEvent(cap, tag) \
87 if (RTS_UNLIKELY(TRACE_sched)) { \
88 traceEvent_(cap, tag); \
91 void traceEvent_ (Capability *cap, EventTypeNum tag);
93 // variadic macros are C99, and supported by gcc. However, the
94 // ##__VA_ARGS syntax is a gcc extension, which allows the variable
95 // argument list to be empty (see gcc docs for details).
98 * Emit a trace message on a particular Capability
100 #define traceCap(class, cap, msg, ...) \
101 if (RTS_UNLIKELY(class)) { \
102 traceCap_(cap, msg, ##__VA_ARGS__); \
105 void traceCap_(Capability *cap, char *msg, ...);
108 * Emit a trace message
110 #define trace(class, msg, ...) \
111 if (RTS_UNLIKELY(class)) { \
112 trace_(msg, ##__VA_ARGS__); \
115 void trace_(char *msg, ...);
118 * A message or event emitted by the program
120 void traceUserMsg(Capability *cap, char *msg);
123 * Emit a debug message (only when DEBUG is defined)
126 #define debugTrace(class, msg, ...) \
127 if (RTS_UNLIKELY(class)) { \
128 trace_(msg, ##__VA_ARGS__); \
131 #define debugTrace(class, str, ...) /* nothing */
135 * Emit a message/event describing the state of a thread
137 #define traceThreadStatus(class, tso) \
138 if (RTS_UNLIKELY(class)) { \
139 traceThreadStatus_(tso); \
142 void traceThreadStatus_ (StgTSO *tso);
146 #define traceSchedEvent(cap, tag, tso, other) /* nothing */
147 #define traceEvent(cap, tag) /* nothing */
148 #define traceCap(class, cap, msg, ...) /* nothing */
149 #define trace(class, msg, ...) /* nothing */
150 #define debugTrace(class, str, ...) /* nothing */
151 #define traceThreadStatus(class, tso) /* nothing */