1 /* -----------------------------------------------------------------------------
3 * (c) The GHC Team 2006
5 * Debug and performance tracing.
7 * This is a layer over RtsMessages, which provides for generating
8 * trace messages with timestamps and thread 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. Additionally, we
13 * generate timestamped trace messages for consumption by profiling
14 * tools using this API.
16 * ---------------------------------------------------------------------------*/
21 // -----------------------------------------------------------------------------
23 // -----------------------------------------------------------------------------
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));
46 #define debugTrace(class, str, ...) trace(class,str, ## __VA_ARGS__)
47 // variable arg macros are C99, and supported by gcc.
48 #define debugTraceBegin(str, ...) traceBegin(str, ## __VA_ARGS__)
49 #define debugTraceEnd() traceEnd()
51 #define debugTrace(class, str, ...) /* nothing */
52 #define debugTraceBegin(str, ...) /* nothing */
53 #define debugTraceEnd() /* nothing */
57 // -----------------------------------------------------------------------------
58 // Message classes, these may be OR-ed together
59 // -----------------------------------------------------------------------------
61 // debugging flags, set with +RTS -D<something>
62 #define DEBUG_sched (1<<0)
63 #define DEBUG_interp (1<<1)
64 #define DEBUG_weak (1<<2)
65 #define DEBUG_gccafs (1<<3)
66 #define DEBUG_gc (1<<4)
67 #define DEBUG_block_alloc (1<<5)
68 #define DEBUG_sanity (1<<6)
69 #define DEBUG_stable (1<<7)
70 #define DEBUG_stm (1<<8)
71 #define DEBUG_prof (1<<9)
72 #define DEBUG_gran (1<<10)
73 #define DEBUG_par (1<<11)
74 #define DEBUG_linker (1<<12)
75 #define DEBUG_squeeze (1<<13)
77 // PAR debugging flags, set with +RTS -qD<something>
78 #define PAR_DEBUG_verbose (1<<14)
79 #define PAR_DEBUG_bq (1<<15)
80 #define PAR_DEBUG_schedule (1<<16)
81 #define PAR_DEBUG_free (1<<17)
82 #define PAR_DEBUG_resume (1<<18)
83 #define PAR_DEBUG_weight (1<<19)
84 #define PAR_DEBUG_fetch (1<<21)
85 #define PAR_DEBUG_fish (1<<22)
86 #define PAR_DEBUG_tables (1<<23)
87 #define PAR_DEBUG_packet (1<<24)
88 #define PAR_DEBUG_pack (1<<25)
89 #define PAR_DEBUG_paranoia (1<<26)
91 // GRAN and PAR don't coexist, so we re-use the PAR values for GRAN.
92 #define GRAN_DEBUG_event_trace (1<<14)
93 #define GRAN_DEBUG_event_stats (1<<15)
94 #define GRAN_DEBUG_bq (1<<16)
95 #define GRAN_DEBUG_pack (1<<17)
96 #define GRAN_DEBUG_checkSparkQ (1<<18)
97 #define GRAN_DEBUG_thunkStealing (1<<19)
98 #define GRAN_DEBUG_randomSteal (1<<20)
99 #define GRAN_DEBUG_findWork (1<<21)
100 #define GRAN_DEBUG_unused (1<<22)
101 #define GRAN_DEBUG_pri (1<<23)
102 #define GRAN_DEBUG_checkLight (1<<24)
103 #define GRAN_DEBUG_sortedQ (1<<25)
104 #define GRAN_DEBUG_blockOnFetch (1<<26)
105 #define GRAN_DEBUG_packBuffer (1<<27)
106 #define GRAN_DEBUG_BOF_sanity (1<<28)
109 #define TRACE_sched (1<<29)
112 #define DEBUG_hpc (1<<30)
114 // -----------------------------------------------------------------------------
115 // PRIVATE below here
116 // -----------------------------------------------------------------------------
118 extern StgWord32 classes_enabled;
120 INLINE_HEADER rtsBool
121 traceClass (StgWord32 class) { return (classes_enabled & class); }
123 // -----------------------------------------------------------------------------