Declare RTS-private prototypes with __attribute__((visibility("hidden")))
[ghc.git] / rts / Trace.h
1 /* -----------------------------------------------------------------------------
2 *
3 * (c) The GHC Team 2006
4 *
5 * Debug tracing.
6 *
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.
11 *
12 * All debug trace messages go through here.
13 *
14 * ---------------------------------------------------------------------------*/
15
16 #ifndef TRACE_H
17 #define TRACE_H
18
19 #pragma GCC visibility push(hidden)
20
21 // -----------------------------------------------------------------------------
22 // Tracing functions
23 // -----------------------------------------------------------------------------
24
25 #ifdef DEBUG
26
27 void initTracing (void);
28
29 // The simple way:
30 void trace (StgWord32 class, const char *str, ...)
31 GNUC3_ATTRIBUTE(format (printf, 2, 3));
32
33 // The harder way: sometimes we want to generate a trace message that
34 // consists of multiple components generated by different functions.
35 // So we provide the functionality of trace() split into 3 parts:
36 // - traceClass(): a check that the required class is enabled
37 // - traceBegin(): print the beginning of the trace message
38 // - traceEnd(): complete the trace message (release the lock too).
39 //
40 INLINE_HEADER rtsBool traceClass (StgWord32 class);
41
42 void traceBegin (const char *str, ...)
43 GNUC3_ATTRIBUTE(format (printf, 1, 2));
44
45 void traceEnd (void);
46
47 #define debugTrace(class, str, ...) trace(class,str, ## __VA_ARGS__)
48 // variable arg macros are C99, and supported by gcc.
49 #define debugTraceBegin(str, ...) traceBegin(str, ## __VA_ARGS__)
50 #define debugTraceEnd() traceEnd()
51
52 #else /* !DEBUG */
53
54 #define debugTrace(class, str, ...) /* nothing */
55 #define debugTraceBegin(str, ...) /* nothing */
56 #define debugTraceEnd() /* nothing */
57
58 #endif
59
60 // -----------------------------------------------------------------------------
61 // Message classes, these may be OR-ed together
62 // -----------------------------------------------------------------------------
63
64 // debugging flags, set with +RTS -D<something>
65 #define DEBUG_sched (1<<0)
66 #define DEBUG_interp (1<<1)
67 #define DEBUG_weak (1<<2)
68 #define DEBUG_gccafs (1<<3)
69 #define DEBUG_gc (1<<4)
70 #define DEBUG_block_alloc (1<<5)
71 #define DEBUG_sanity (1<<6)
72 #define DEBUG_stable (1<<7)
73 #define DEBUG_stm (1<<8)
74 #define DEBUG_prof (1<<9)
75 #define DEBUG_gran (1<<10)
76 #define DEBUG_par (1<<11)
77 #define DEBUG_linker (1<<12)
78 #define DEBUG_squeeze (1<<13)
79 #define DEBUG_hpc (1<<14)
80 #define DEBUG_eventlog (1<<15)
81
82 // -----------------------------------------------------------------------------
83 // PRIVATE below here
84 // -----------------------------------------------------------------------------
85
86 extern StgWord32 classes_enabled;
87
88 INLINE_HEADER rtsBool
89 traceClass (StgWord32 class) { return (classes_enabled & class); }
90
91 // -----------------------------------------------------------------------------
92
93 #pragma GCC visibility pop
94
95 #endif /* TRACE_H */