e36c97353ee782e5a2a4bc390f0ba288b40bae40
[ghc.git] / rts / eventlog / EventLog.h
1 /* -----------------------------------------------------------------------------
2 *
3 * (c) The GHC Team, 2008-2009
4 *
5 * Support for fast binary event logging.
6 *
7 * ---------------------------------------------------------------------------*/
8
9 #ifndef EVENTLOG_H
10 #define EVENTLOG_H
11
12 #include "rts/EventLogFormat.h"
13 #include "rts/EventLogWriter.h"
14 #include "Capability.h"
15
16 #include "BeginPrivate.h"
17
18 #ifdef TRACING
19
20 /*
21 * Descriptions of EventTags for events.
22 */
23 extern char *EventTagDesc[];
24
25 void initEventLogging(const EventLogWriter *writer);
26 void endEventLogging(void);
27 void freeEventLogging(void);
28 void abortEventLogging(void); // #4512 - after fork child needs to abort
29 void flushEventLog(void); // event log inherited from parent
30 void moreCapEventBufs (uint32_t from, uint32_t to);
31
32 /*
33 * Post a scheduler event to the capability's event buffer (an event
34 * that has an associated thread).
35 */
36 void postSchedEvent(Capability *cap, EventTypeNum tag,
37 StgThreadID id, StgWord info1, StgWord info2);
38
39 /*
40 * Post a nullary event.
41 */
42 void postEvent(Capability *cap, EventTypeNum tag);
43
44 void postEventAtTimestamp (Capability *cap, EventTimestamp ts,
45 EventTypeNum tag);
46
47 void postMsg(char *msg, va_list ap);
48
49 void postUserEvent(Capability *cap, EventTypeNum type, char *msg);
50
51 void postCapMsg(Capability *cap, char *msg, va_list ap);
52
53 /*
54 * Post an event relating to a capability itself (create/delete/etc)
55 */
56 void postCapEvent (EventTypeNum tag,
57 EventCapNo capno);
58
59 /*
60 * Post an event that is associated with a capability set
61 */
62 void postCapsetEvent (EventTypeNum tag,
63 EventCapsetID capset,
64 StgWord info);
65
66 /*
67 * Post a capability set event with a string payload
68 */
69 void postCapsetStrEvent (EventTypeNum tag,
70 EventCapsetID capset,
71 char *msg);
72
73 /*
74 * Post a capability set event with several strings payload
75 */
76 void postCapsetVecEvent (EventTypeNum tag,
77 EventCapsetID capset,
78 int argc,
79 char *msg[]);
80
81 void postWallClockTime (EventCapsetID capset);
82
83 /*
84 * Post a `par` spark event
85 */
86 void postSparkEvent(Capability *cap, EventTypeNum tag, StgWord info1);
87
88 /*
89 * Post an event with several counters relating to `par` sparks.
90 */
91 void postSparkCountersEvent (Capability *cap,
92 SparkCounters counters,
93 StgWord remaining);
94
95 /*
96 * Post an event to annotate a thread with a label
97 */
98 void postThreadLabel(Capability *cap,
99 EventThreadID id,
100 char *label);
101
102 /*
103 * Various GC and heap events
104 */
105 void postHeapEvent (Capability *cap,
106 EventTypeNum tag,
107 EventCapsetID heap_capset,
108 W_ info1);
109
110 void postEventHeapInfo (EventCapsetID heap_capset,
111 uint32_t gens,
112 W_ maxHeapSize,
113 W_ allocAreaSize,
114 W_ mblockSize,
115 W_ blockSize);
116
117 void postEventGcStats (Capability *cap,
118 EventCapsetID heap_capset,
119 uint32_t gen,
120 W_ copied,
121 W_ slop,
122 W_ fragmentation,
123 uint32_t par_n_threads,
124 W_ par_max_copied,
125 W_ par_tot_copied);
126
127 void postTaskCreateEvent (EventTaskId taskId,
128 EventCapNo cap,
129 EventKernelThreadId tid);
130
131 void postTaskMigrateEvent (EventTaskId taskId,
132 EventCapNo capno,
133 EventCapNo new_capno);
134
135 void postTaskDeleteEvent (EventTaskId taskId);
136
137 void postHeapProfBegin(StgWord8 profile_id);
138
139 void postHeapProfSampleBegin(StgInt era);
140
141 void postHeapProfSampleString(StgWord8 profile_id,
142 const char *label,
143 StgWord64 residency);
144
145 #ifdef PROFILING
146 void postHeapProfCostCentre(StgWord32 ccID,
147 const char *label,
148 const char *module,
149 const char *srcloc,
150 StgBool is_caf);
151
152 void postHeapProfSampleCostCentre(StgWord8 profile_id,
153 CostCentreStack *stack,
154 StgWord64 residency);
155 #endif /* PROFILING */
156
157 #else /* !TRACING */
158
159 INLINE_HEADER void postSchedEvent (Capability *cap STG_UNUSED,
160 EventTypeNum tag STG_UNUSED,
161 StgThreadID id STG_UNUSED,
162 StgWord info1 STG_UNUSED,
163 StgWord info2 STG_UNUSED)
164 { /* nothing */ }
165
166 INLINE_HEADER void postEvent (Capability *cap STG_UNUSED,
167 EventTypeNum tag STG_UNUSED)
168 { /* nothing */ }
169
170 INLINE_HEADER void postMsg (char *msg STG_UNUSED,
171 va_list ap STG_UNUSED)
172 { /* nothing */ }
173
174 INLINE_HEADER void postCapMsg (Capability *cap STG_UNUSED,
175 char *msg STG_UNUSED,
176 va_list ap STG_UNUSED)
177 { /* nothing */ }
178
179
180 INLINE_HEADER void postThreadLabel(Capability *cap STG_UNUSED,
181 EventThreadID id STG_UNUSED,
182 char *label STG_UNUSED)
183 { /* nothing */ }
184
185 #endif
186
187 #include "EndPrivate.h"
188
189 #endif /* TRACING_H */