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 // -----------------------------------------------------------------------------
21 INLINE_HEADER void trace (StgWord32 class, char *msg, ...);
24 INLINE_HEADER void debugTrace (StgWord32 class, char *msg, ...);
27 INLINE_HEADER void traceSchedEvent (Capability *cap, EventTypeNum tag,
28 StgTSO *tso, StgWord64 other);
30 INLINE_HEADER void traceCap (StgWord32 class, Capability *cap,
33 INLINE_HEADER void traceThreadStatus (StgWord32 class, StgTSO *tso);
35 INLINE_HEADER rtsBool traceClass (StgWord32 class);
38 void traceBegin (const char *str, ...);
42 // -----------------------------------------------------------------------------
44 // -----------------------------------------------------------------------------
48 void initTracing (void);
49 void endTracing (void);
50 void freeTracing (void);
54 // -----------------------------------------------------------------------------
55 // Message classes, these may be OR-ed together
56 // -----------------------------------------------------------------------------
58 // debugging flags, set with +RTS -D<something>
59 #define DEBUG_sched (1<<0)
60 #define DEBUG_interp (1<<1)
61 #define DEBUG_weak (1<<2)
62 #define DEBUG_gccafs (1<<3)
63 #define DEBUG_gc (1<<4)
64 #define DEBUG_block_alloc (1<<5)
65 #define DEBUG_sanity (1<<6)
66 #define DEBUG_stable (1<<7)
67 #define DEBUG_stm (1<<8)
68 #define DEBUG_prof (1<<9)
69 #define DEBUG_gran (1<<10)
70 #define DEBUG_par (1<<11)
71 #define DEBUG_linker (1<<12)
72 #define DEBUG_squeeze (1<<13)
73 #define DEBUG_hpc (1<<14)
74 #define DEBUG_sparks (1<<15)
77 #define TRACE_sched (1<<16)
79 // -----------------------------------------------------------------------------
81 // -----------------------------------------------------------------------------
85 extern StgWord32 classes_enabled;
87 INLINE_HEADER rtsBool traceClass (StgWord32 class)
88 { return (classes_enabled & class); }
90 void traceSchedEvent_ (Capability *cap, EventTypeNum tag,
91 StgTSO *tso, StgWord64 other);
94 * Trace an event to the capability's event buffer.
96 INLINE_HEADER void traceSchedEvent(Capability *cap, EventTypeNum tag,
97 StgTSO *tso, StgWord64 other)
99 if (traceClass(TRACE_sched)) {
100 traceSchedEvent_(cap, tag, tso, other);
104 void traceCap_(Capability *cap, char *msg, va_list ap);
107 * Trace a log message
109 INLINE_HEADER void traceCap (StgWord32 class, Capability *cap, char *msg, ...)
113 if (traceClass(class)) {
114 traceCap_(cap, msg, ap);
119 void trace_(char *msg, va_list ap);
122 * Trace a log message
124 INLINE_HEADER void trace (StgWord32 class, char *msg, ...)
128 if (traceClass(class)) {
135 INLINE_HEADER void debugTrace (StgWord32 class, char *msg, ...)
139 if (traceClass(class)) {
146 #define debugTrace(class, str, ...) /* nothing */
147 // variable arg macros are C99, and supported by gcc.
151 void traceThreadStatus_ (StgTSO *tso);
153 INLINE_HEADER void traceThreadStatus (StgWord32 class, StgTSO *tso)
155 if (traceClass(class)) {
156 traceThreadStatus_(tso);
162 INLINE_HEADER rtsBool traceClass (StgWord32 class STG_UNUSED)
165 INLINE_HEADER void traceSchedEvent (Capability *cap STG_UNUSED,
166 EventTypeNum tag STG_UNUSED,
167 StgTSO *tso STG_UNUSED,
168 StgWord64 other STG_UNUSED)
171 INLINE_HEADER void traceCap (StgWord32 class STG_UNUSED,
172 Capability *cap STG_UNUSED,
173 char *msg STG_UNUSED, ...)
176 INLINE_HEADER void trace (StgWord32 class STG_UNUSED,
177 char *msg STG_UNUSED, ...)
180 #define debugTrace(class, str, ...) /* nothing */
181 // variable arg macros are C99, and supported by gcc.
183 INLINE_HEADER void traceThreadStatus (StgWord32 class STG_UNUSED,
184 StgTSO *tso STG_UNUSED)