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