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);
82 // variadic macros are C99, and supported by gcc. However, the
83 // ##__VA_ARGS syntax is a gcc extension, which allows the variable
84 // argument list to be empty (see gcc docs for details).
87 * Emit a trace message on a particular Capability
89 #define traceCap(class, cap, msg, ...) \
90 if (RTS_UNLIKELY(class)) { \
91 traceCap_(cap, msg, ##__VA_ARGS__); \
94 void traceCap_(Capability *cap, char *msg, ...);
97 * Emit a trace message
99 #define trace(class, msg, ...) \
100 if (RTS_UNLIKELY(class)) { \
101 trace_(msg, ##__VA_ARGS__); \
104 void trace_(char *msg, ...);
107 * A message or event emitted by the program
109 void traceUserMsg(Capability *cap, char *msg);
112 * Emit a debug message (only when DEBUG is defined)
115 #define debugTrace(class, msg, ...) \
116 if (RTS_UNLIKELY(class)) { \
117 trace_(msg, ##__VA_ARGS__); \
120 #define debugTrace(class, str, ...) /* nothing */
124 * Emit a message/event describing the state of a thread
126 #define traceThreadStatus(class, tso) \
127 if (RTS_UNLIKELY(class)) { \
128 traceThreadStatus_(tso); \
131 void traceThreadStatus_ (StgTSO *tso);
135 #define traceSchedEvent(cap, tag, tso, other) /* nothing */
136 #define traceCap(class, cap, msg, ...) /* nothing */
137 #define trace(class, msg, ...) /* nothing */
138 #define debugTrace(class, str, ...) /* nothing */
139 #define traceThreadStatus(class, tso) /* nothing */