1 /* -----------------------------------------------------------------------------
3 * (c) The GHC Team 2006
7 * This is a layer over RtsMessages, which provides for generating
8 * trace messages with timestamps and task IDs attached
9 * automatically. Also, multiple classes of messages are supported,
10 * which can be enabled separately via RTS flags.
12 * All debug trace messages go through here.
14 * ---------------------------------------------------------------------------*/
19 // -----------------------------------------------------------------------------
21 // -----------------------------------------------------------------------------
25 void initTracing (void);
28 void trace (StgWord32 class, const char *str, ...)
29 GNUC3_ATTRIBUTE(format (printf, 2, 3));
31 // The harder way: sometimes we want to generate a trace message that
32 // consists of multiple components generated by different functions.
33 // So we provide the functionality of trace() split into 3 parts:
34 // - traceClass(): a check that the required class is enabled
35 // - traceBegin(): print the beginning of the trace message
36 // - traceEnd(): complete the trace message (release the lock too).
38 INLINE_HEADER rtsBool traceClass (StgWord32 class);
40 void traceBegin (const char *str, ...)
41 GNUC3_ATTRIBUTE(format (printf, 1, 2));
45 #define debugTrace(class, str, ...) trace(class,str, ## __VA_ARGS__)
46 // variable arg macros are C99, and supported by gcc.
47 #define debugTraceBegin(str, ...) traceBegin(str, ## __VA_ARGS__)
48 #define debugTraceEnd() traceEnd()
52 #define debugTrace(class, str, ...) /* nothing */
53 #define debugTraceBegin(str, ...) /* nothing */
54 #define debugTraceEnd() /* nothing */
58 // -----------------------------------------------------------------------------
59 // Message classes, these may be OR-ed together
60 // -----------------------------------------------------------------------------
62 // debugging flags, set with +RTS -D<something>
63 #define DEBUG_sched (1<<0)
64 #define DEBUG_interp (1<<1)
65 #define DEBUG_weak (1<<2)
66 #define DEBUG_gccafs (1<<3)
67 #define DEBUG_gc (1<<4)
68 #define DEBUG_block_alloc (1<<5)
69 #define DEBUG_sanity (1<<6)
70 #define DEBUG_stable (1<<7)
71 #define DEBUG_stm (1<<8)
72 #define DEBUG_prof (1<<9)
73 #define DEBUG_gran (1<<10)
74 #define DEBUG_par (1<<11)
75 #define DEBUG_linker (1<<12)
76 #define DEBUG_squeeze (1<<13)
77 #define DEBUG_hpc (1<<14)
78 #define DEBUG_eventlog (1<<15)
80 // -----------------------------------------------------------------------------
82 // -----------------------------------------------------------------------------
84 extern StgWord32 classes_enabled;
87 traceClass (StgWord32 class) { return (classes_enabled & class); }
89 // -----------------------------------------------------------------------------