Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Newer
Older
100644 572 lines (488 sloc) 20.15 kb
5a2769f New tracing interface
Simon Marlow authored
1 /* -----------------------------------------------------------------------------
2 *
a5288c5 @simonmar Unify event logging and debug tracing.
simonmar authored
3 * (c) The GHC Team, 2008-2009
5a2769f New tracing interface
Simon Marlow authored
4 *
015d3d4 @mchakravarty Expose all EventLog events as DTrace probes
mchakravarty authored
5 * Support for fast binary event logging and user-space dtrace probes.
5a2769f New tracing interface
Simon Marlow authored
6 *
7 * ---------------------------------------------------------------------------*/
8
9 #ifndef TRACE_H
10 #define TRACE_H
11
a5288c5 @simonmar Unify event logging and debug tracing.
simonmar authored
12 #include "rts/EventLogFormat.h"
13 #include "Capability.h"
14
015d3d4 @mchakravarty Expose all EventLog events as DTrace probes
mchakravarty authored
15 #if defined(DTRACE)
16 #include "RtsProbes.h"
17 #endif /* defined(DTRACE) */
18
51b8503 @simonmar Fix the symbol visibility pragmas
simonmar authored
19 #include "BeginPrivate.h"
7d7c187 @simonmar Declare RTS-private prototypes with __attribute__((visibility("hidden"))...
simonmar authored
20
5a2769f New tracing interface
Simon Marlow authored
21 // -----------------------------------------------------------------------------
a5288c5 @simonmar Unify event logging and debug tracing.
simonmar authored
22 // EventLog API
23 // -----------------------------------------------------------------------------
8b18fae @simonmar Add fast event logging
simonmar authored
24
a5288c5 @simonmar Unify event logging and debug tracing.
simonmar authored
25 #if defined(TRACING)
8b18fae @simonmar Add fast event logging
simonmar authored
26
a5288c5 @simonmar Unify event logging and debug tracing.
simonmar authored
27 void initTracing (void);
28 void endTracing (void);
29 void freeTracing (void);
00a4cdf @simonmar Only reset the event log if logging is turned on (addendum to #4512)
simonmar authored
30 void resetTracing (void);
5a2769f New tracing interface
Simon Marlow authored
31
a5288c5 @simonmar Unify event logging and debug tracing.
simonmar authored
32 #endif /* TRACING */
5a2769f New tracing interface
Simon Marlow authored
33
43c7d55 @dcoutts Add capability sets to the tracing/events system
dcoutts authored
34 typedef StgWord32 CapsetID;
35 typedef StgWord16 CapsetType;
36 enum CapsetType { CapsetTypeCustom = CAPSET_TYPE_CUSTOM,
37 CapsetTypeOsProcess = CAPSET_TYPE_OSPROCESS,
38 CapsetTypeClockdomain = CAPSET_TYPE_CLOCKDOMAIN };
39 #define CAPSET_OSPROCESS_DEFAULT 0
40
5a2769f New tracing interface
Simon Marlow authored
41 // -----------------------------------------------------------------------------
0645623 @simonmar Optimise the code generated at trace points
simonmar authored
42 // Message classes
5a2769f New tracing interface
Simon Marlow authored
43 // -----------------------------------------------------------------------------
44
45 // debugging flags, set with +RTS -D<something>
0645623 @simonmar Optimise the code generated at trace points
simonmar authored
46 extern int DEBUG_sched;
47 extern int DEBUG_interp;
48 extern int DEBUG_weak;
49 extern int DEBUG_gccafs;
50 extern int DEBUG_gc;
51 extern int DEBUG_block_alloc;
52 extern int DEBUG_sanity;
53 extern int DEBUG_stable;
54 extern int DEBUG_stm;
55 extern int DEBUG_prof;
56 extern int DEBUG_gran;
57 extern int DEBUG_par;
58 extern int DEBUG_linker;
59 extern int DEBUG_squeeze;
60 extern int DEBUG_hpc;
61 extern int DEBUG_sparks;
a5288c5 @simonmar Unify event logging and debug tracing.
simonmar authored
62
63 // events
0645623 @simonmar Optimise the code generated at trace points
simonmar authored
64 extern int TRACE_sched;
46b7074 @dcoutts Move GC tracing into a separate trace class
dcoutts authored
65 extern int TRACE_gc;
084b64f @dcoutts Add new fully-accurate per-spark trace/eventlog events
dcoutts authored
66 extern int TRACE_spark_sampled;
67 extern int TRACE_spark_full;
5a2769f New tracing interface
Simon Marlow authored
68
69 // -----------------------------------------------------------------------------
0645623 @simonmar Optimise the code generated at trace points
simonmar authored
70 // Posting events
71 //
72 // We use macros rather than inline functions deliberately. We want
73 // the not-taken case to be as efficient as possible, a simple
74 // test-and-jump, and with inline functions gcc seemed to move some of
75 // the instructions from the branch up before the test.
76 //
5a2769f New tracing interface
Simon Marlow authored
77 // -----------------------------------------------------------------------------
78
0645623 @simonmar Optimise the code generated at trace points
simonmar authored
79 #ifdef DEBUG
80 void traceBegin (const char *str, ...);
81 void traceEnd (void);
82 #endif
a5288c5 @simonmar Unify event logging and debug tracing.
simonmar authored
83
0645623 @simonmar Optimise the code generated at trace points
simonmar authored
84 #ifdef TRACING
5a2769f New tracing interface
Simon Marlow authored
85
0645623 @simonmar Optimise the code generated at trace points
simonmar authored
86 /*
87 * Record a scheduler event
88 */
89 #define traceSchedEvent(cap, tag, tso, other) \
90 if (RTS_UNLIKELY(TRACE_sched)) { \
784e214 @simonmar Annotate thread stop events with the owner of the black hole
simonmar authored
91 traceSchedEvent_(cap, tag, tso, other, 0); \
92 }
93
94 #define traceSchedEvent2(cap, tag, tso, info1, info2) \
95 if (RTS_UNLIKELY(TRACE_sched)) { \
96 traceSchedEvent_(cap, tag, tso, info1, info2); \
0645623 @simonmar Optimise the code generated at trace points
simonmar authored
97 }
a5288c5 @simonmar Unify event logging and debug tracing.
simonmar authored
98
99 void traceSchedEvent_ (Capability *cap, EventTypeNum tag,
784e214 @simonmar Annotate thread stop events with the owner of the black hole
simonmar authored
100 StgTSO *tso, StgWord info1, StgWord info2);
a5288c5 @simonmar Unify event logging and debug tracing.
simonmar authored
101
46b7074 @dcoutts Move GC tracing into a separate trace class
dcoutts authored
102 /*
103 * Record a GC event
1f56fae @simonmar Add events to show when GC threads are idle/working
simonmar authored
104 */
46b7074 @dcoutts Move GC tracing into a separate trace class
dcoutts authored
105 #define traceGcEvent(cap, tag) \
106 if (RTS_UNLIKELY(TRACE_gc)) { \
107 traceGcEvent_(cap, tag); \
1f56fae @simonmar Add events to show when GC threads are idle/working
simonmar authored
108 }
109
46b7074 @dcoutts Move GC tracing into a separate trace class
dcoutts authored
110 void traceGcEvent_ (Capability *cap, EventTypeNum tag);
1f56fae @simonmar Add events to show when GC threads are idle/working
simonmar authored
111
084b64f @dcoutts Add new fully-accurate per-spark trace/eventlog events
dcoutts authored
112 /*
113 * Record a spark event
114 */
115 #define traceSparkEvent(cap, tag) \
116 if (RTS_UNLIKELY(TRACE_spark_full)) { \
117 traceSparkEvent_(cap, tag, 0); \
118 }
119
120 #define traceSparkEvent2(cap, tag, other) \
121 if (RTS_UNLIKELY(TRACE_spark_full)) { \
122 traceSparkEvent_(cap, tag, other); \
123 }
124
125 void traceSparkEvent_ (Capability *cap, EventTypeNum tag, StgWord info1);
126
0645623 @simonmar Optimise the code generated at trace points
simonmar authored
127 // variadic macros are C99, and supported by gcc. However, the
128 // ##__VA_ARGS syntax is a gcc extension, which allows the variable
129 // argument list to be empty (see gcc docs for details).
130
a5288c5 @simonmar Unify event logging and debug tracing.
simonmar authored
131 /*
0645623 @simonmar Optimise the code generated at trace points
simonmar authored
132 * Emit a trace message on a particular Capability
a5288c5 @simonmar Unify event logging and debug tracing.
simonmar authored
133 */
0645623 @simonmar Optimise the code generated at trace points
simonmar authored
134 #define traceCap(class, cap, msg, ...) \
135 if (RTS_UNLIKELY(class)) { \
136 traceCap_(cap, msg, ##__VA_ARGS__); \
a5288c5 @simonmar Unify event logging and debug tracing.
simonmar authored
137 }
138
0645623 @simonmar Optimise the code generated at trace points
simonmar authored
139 void traceCap_(Capability *cap, char *msg, ...);
a5288c5 @simonmar Unify event logging and debug tracing.
simonmar authored
140
141 /*
0645623 @simonmar Optimise the code generated at trace points
simonmar authored
142 * Emit a trace message
a5288c5 @simonmar Unify event logging and debug tracing.
simonmar authored
143 */
0645623 @simonmar Optimise the code generated at trace points
simonmar authored
144 #define trace(class, msg, ...) \
145 if (RTS_UNLIKELY(class)) { \
146 trace_(msg, ##__VA_ARGS__); \
a5288c5 @simonmar Unify event logging and debug tracing.
simonmar authored
147 }
148
0645623 @simonmar Optimise the code generated at trace points
simonmar authored
149 void trace_(char *msg, ...);
a5288c5 @simonmar Unify event logging and debug tracing.
simonmar authored
150
151 /*
5407ad8 @simonmar Add a way to generate tracing events programmatically
simonmar authored
152 * A message or event emitted by the program
153 */
154 void traceUserMsg(Capability *cap, char *msg);
155
156 /*
0645623 @simonmar Optimise the code generated at trace points
simonmar authored
157 * Emit a debug message (only when DEBUG is defined)
a5288c5 @simonmar Unify event logging and debug tracing.
simonmar authored
158 */
159 #ifdef DEBUG
0645623 @simonmar Optimise the code generated at trace points
simonmar authored
160 #define debugTrace(class, msg, ...) \
161 if (RTS_UNLIKELY(class)) { \
162 trace_(msg, ##__VA_ARGS__); \
a5288c5 @simonmar Unify event logging and debug tracing.
simonmar authored
163 }
164 #else
165 #define debugTrace(class, str, ...) /* nothing */
166 #endif
167
7408b39 @simonmar Use message-passing to implement throwTo in the RTS
simonmar authored
168 #ifdef DEBUG
169 #define debugTraceCap(class, cap, msg, ...) \
170 if (RTS_UNLIKELY(class)) { \
171 traceCap_(cap, msg, ##__VA_ARGS__); \
172 }
173 #else
174 #define debugTraceCap(class, cap, str, ...) /* nothing */
175 #endif
176
0645623 @simonmar Optimise the code generated at trace points
simonmar authored
177 /*
178 * Emit a message/event describing the state of a thread
179 */
180 #define traceThreadStatus(class, tso) \
181 if (RTS_UNLIKELY(class)) { \
182 traceThreadStatus_(tso); \
a5288c5 @simonmar Unify event logging and debug tracing.
simonmar authored
183 }
184
0645623 @simonmar Optimise the code generated at trace points
simonmar authored
185 void traceThreadStatus_ (StgTSO *tso);
a5288c5 @simonmar Unify event logging and debug tracing.
simonmar authored
186
c4f9b98 @dcoutts Make the tracing of the startup event more regular
dcoutts authored
187 void traceEventStartup_ (int n_caps);
188
43c7d55 @dcoutts Add capability sets to the tracing/events system
dcoutts authored
189 /*
190 * Events for describing capability sets in the eventlog
191 *
192 * Note: unlike other events, these are not conditional on TRACE_sched or
193 * similar because they are not "real" events themselves but provide
194 * information and context for other "real" events. Other events depend on
195 * the capset info events so for simplicity, rather than working out if
196 * they're necessary we always emit them. They should be very low volume.
197 */
198 void traceCapsetModify_ (EventTypeNum tag,
199 CapsetID capset,
200 StgWord32 other);
201
e8832eb @dcoutts Emit various bits of OS process info into the eventlog
dcoutts authored
202 void traceOSProcessInfo_ (void);
203
d77df1c @dcoutts Add spark counter tracing
dcoutts authored
204 void traceSparkCounters_ (Capability *cap,
205 SparkCounters counters,
206 StgWord remaining);
207
0645623 @simonmar Optimise the code generated at trace points
simonmar authored
208 #else /* !TRACING */
a5288c5 @simonmar Unify event logging and debug tracing.
simonmar authored
209
0645623 @simonmar Optimise the code generated at trace points
simonmar authored
210 #define traceSchedEvent(cap, tag, tso, other) /* nothing */
784e214 @simonmar Annotate thread stop events with the owner of the black hole
simonmar authored
211 #define traceSchedEvent2(cap, tag, tso, other, info) /* nothing */
46b7074 @dcoutts Move GC tracing into a separate trace class
dcoutts authored
212 #define traceGcEvent(cap, tag) /* nothing */
084b64f @dcoutts Add new fully-accurate per-spark trace/eventlog events
dcoutts authored
213 #define traceSparkEvent(cap, tag) /* nothing */
214 #define traceSparkEvent2(cap, tag, other) /* nothing */
0645623 @simonmar Optimise the code generated at trace points
simonmar authored
215 #define traceCap(class, cap, msg, ...) /* nothing */
216 #define trace(class, msg, ...) /* nothing */
a5288c5 @simonmar Unify event logging and debug tracing.
simonmar authored
217 #define debugTrace(class, str, ...) /* nothing */
7408b39 @simonmar Use message-passing to implement throwTo in the RTS
simonmar authored
218 #define debugTraceCap(class, cap, str, ...) /* nothing */
0645623 @simonmar Optimise the code generated at trace points
simonmar authored
219 #define traceThreadStatus(class, tso) /* nothing */
0a6f26f @igfoo Fix gcc 4.6 warnings; fixes #5176
igfoo authored
220 INLINE_HEADER void traceEventStartup_ (int n_caps STG_UNUSED) {};
43c7d55 @dcoutts Add capability sets to the tracing/events system
dcoutts authored
221 #define traceCapsetModify_(tag, capset, other) /* nothing */
e8832eb @dcoutts Emit various bits of OS process info into the eventlog
dcoutts authored
222 #define traceOSProcessInfo_() /* nothing */
d77df1c @dcoutts Add spark counter tracing
dcoutts authored
223 #define traceSparkCounters_(cap, counters, remaining) /* nothing */
a5288c5 @simonmar Unify event logging and debug tracing.
simonmar authored
224
225 #endif /* TRACING */
5a2769f New tracing interface
Simon Marlow authored
226
015d3d4 @mchakravarty Expose all EventLog events as DTrace probes
mchakravarty authored
227 // If DTRACE is enabled, but neither DEBUG nor TRACING, we need a C land
228 // wrapper for the user-msg probe (as we can't expand that in PrimOps.cmm)
229 //
230 #if !defined(DEBUG) && !defined(TRACING) && defined(DTRACE)
231
232 void dtraceUserMsgWrapper(Capability *cap, char *msg);
233
234 #endif /* !defined(DEBUG) && !defined(TRACING) && defined(DTRACE) */
235
236 // -----------------------------------------------------------------------------
237 // Aliases for static dtrace probes if dtrace is available
238 // -----------------------------------------------------------------------------
239
240 #if defined(DTRACE)
241
242 #define dtraceCreateThread(cap, tid) \
243 HASKELLEVENT_CREATE_THREAD(cap, tid)
244 #define dtraceRunThread(cap, tid) \
245 HASKELLEVENT_RUN_THREAD(cap, tid)
784e214 @simonmar Annotate thread stop events with the owner of the black hole
simonmar authored
246 #define dtraceStopThread(cap, tid, status, info) \
247 HASKELLEVENT_STOP_THREAD(cap, tid, status, info)
015d3d4 @mchakravarty Expose all EventLog events as DTrace probes
mchakravarty authored
248 #define dtraceThreadRunnable(cap, tid) \
249 HASKELLEVENT_THREAD_RUNNABLE(cap, tid)
250 #define dtraceMigrateThread(cap, tid, new_cap) \
251 HASKELLEVENT_MIGRATE_THREAD(cap, tid, new_cap)
252 #define dtraceShutdown(cap) \
253 HASKELLEVENT_SHUTDOWN(cap)
254 #define dtraceThreadWakeup(cap, tid, other_cap) \
255 HASKELLEVENT_THREAD_WAKEUP(cap, tid, other_cap)
256 #define dtraceGcStart(cap) \
257 HASKELLEVENT_GC_START(cap)
258 #define dtraceGcEnd(cap) \
259 HASKELLEVENT_GC_END(cap)
260 #define dtraceRequestSeqGc(cap) \
261 HASKELLEVENT_REQUEST_SEQ_GC(cap)
262 #define dtraceRequestParGc(cap) \
263 HASKELLEVENT_REQUEST_PAR_GC(cap)
264 #define dtraceCreateSparkThread(cap, spark_tid) \
265 HASKELLEVENT_CREATE_SPARK_THREAD(cap, spark_tid)
676bc14 @igfoo Fix build on OS X: Correct silly errors in Trace.h
igfoo authored
266 INLINE_HEADER void dtraceStartup (int num_caps) {
267 HASKELLEVENT_STARTUP(num_caps);
0a6f26f @igfoo Fix gcc 4.6 warnings; fixes #5176
igfoo authored
268 }
015d3d4 @mchakravarty Expose all EventLog events as DTrace probes
mchakravarty authored
269 #define dtraceUserMsg(cap, msg) \
270 HASKELLEVENT_USER_MSG(cap, msg)
271 #define dtraceGcIdle(cap) \
272 HASKELLEVENT_GC_IDLE(cap)
273 #define dtraceGcWork(cap) \
274 HASKELLEVENT_GC_WORK(cap)
275 #define dtraceGcDone(cap) \
276 HASKELLEVENT_GC_DONE(cap)
43c7d55 @dcoutts Add capability sets to the tracing/events system
dcoutts authored
277 #define dtraceCapsetCreate(capset, capset_type) \
278 HASKELLEVENT_CAPSET_CREATE(capset, capset_type)
279 #define dtraceCapsetDelete(capset) \
280 HASKELLEVENT_CAPSET_DELETE(capset)
281 #define dtraceCapsetAssignCap(capset, capno) \
282 HASKELLEVENT_CAPSET_ASSIGN_CAP(capset, capno)
283 #define dtraceCapsetRemoveCap(capset, capno) \
284 HASKELLEVENT_CAPSET_REMOVE_CAP(capset, capno)
d77df1c @dcoutts Add spark counter tracing
dcoutts authored
285 #define dtraceSparkCounters(cap, a, b, c, d, e, f, g) \
286 HASKELLEVENT_SPARK_COUNTERS(cap, a, b, c, d, e, f, g)
084b64f @dcoutts Add new fully-accurate per-spark trace/eventlog events
dcoutts authored
287 #define dtraceSparkCreate(cap) \
288 HASKELLEVENT_SPARK_CREATE(cap)
289 #define dtraceSparkDud(cap) \
290 HASKELLEVENT_SPARK_DUD(cap)
291 #define dtraceSparkOverflow(cap) \
292 HASKELLEVENT_SPARK_OVERFLOW(cap)
293 #define dtraceSparkRun(cap) \
294 HASKELLEVENT_SPARK_RUN(cap)
295 #define dtraceSparkSteal(cap, victim_cap) \
296 HASKELLEVENT_SPARK_STEAL(cap, victim_cap)
297 #define dtraceSparkFizzle(cap) \
298 HASKELLEVENT_SPARK_FIZZLE(cap)
299 #define dtraceSparkGc(cap) \
300 HASKELLEVENT_SPARK_GC(cap)
015d3d4 @mchakravarty Expose all EventLog events as DTrace probes
mchakravarty authored
301
302 #else /* !defined(DTRACE) */
303
304 #define dtraceCreateThread(cap, tid) /* nothing */
305 #define dtraceRunThread(cap, tid) /* nothing */
784e214 @simonmar Annotate thread stop events with the owner of the black hole
simonmar authored
306 #define dtraceStopThread(cap, tid, status, info) /* nothing */
015d3d4 @mchakravarty Expose all EventLog events as DTrace probes
mchakravarty authored
307 #define dtraceThreadRunnable(cap, tid) /* nothing */
308 #define dtraceMigrateThread(cap, tid, new_cap) /* nothing */
309 #define dtraceShutdown(cap) /* nothing */
310 #define dtraceThreadWakeup(cap, tid, other_cap) /* nothing */
311 #define dtraceGcStart(cap) /* nothing */
312 #define dtraceGcEnd(cap) /* nothing */
313 #define dtraceRequestSeqGc(cap) /* nothing */
314 #define dtraceRequestParGc(cap) /* nothing */
315 #define dtraceCreateSparkThread(cap, spark_tid) /* nothing */
676bc14 @igfoo Fix build on OS X: Correct silly errors in Trace.h
igfoo authored
316 INLINE_HEADER void dtraceStartup (int num_caps STG_UNUSED) {};
015d3d4 @mchakravarty Expose all EventLog events as DTrace probes
mchakravarty authored
317 #define dtraceUserMsg(cap, msg) /* nothing */
318 #define dtraceGcIdle(cap) /* nothing */
319 #define dtraceGcWork(cap) /* nothing */
320 #define dtraceGcDone(cap) /* nothing */
43c7d55 @dcoutts Add capability sets to the tracing/events system
dcoutts authored
321 #define dtraceCapsetCreate(capset, capset_type) /* nothing */
322 #define dtraceCapsetDelete(capset) /* nothing */
323 #define dtraceCapsetAssignCap(capset, capno) /* nothing */
324 #define dtraceCapsetRemoveCap(capset, capno) /* nothing */
d77df1c @dcoutts Add spark counter tracing
dcoutts authored
325 #define dtraceSparkCounters(cap, a, b, c, d, e, f, g) /* nothing */
084b64f @dcoutts Add new fully-accurate per-spark trace/eventlog events
dcoutts authored
326 #define dtraceSparkCreate(cap) /* nothing */
327 #define dtraceSparkDud(cap) /* nothing */
328 #define dtraceSparkOverflow(cap) /* nothing */
329 #define dtraceSparkRun(cap) /* nothing */
330 #define dtraceSparkSteal(cap, victim_cap) /* nothing */
331 #define dtraceSparkFizzle(cap) /* nothing */
332 #define dtraceSparkGc(cap) /* nothing */
015d3d4 @mchakravarty Expose all EventLog events as DTrace probes
mchakravarty authored
333
334 #endif
335
336 // -----------------------------------------------------------------------------
337 // Trace probes dispatching to various tracing frameworks
338 //
339 // In order to avoid accumulating multiple calls to tracing calls at trace
340 // points, we define inline probe functions that contain the various
341 // invocations.
342 //
343 // Dtrace - dtrace probes are unconditionally added as probe activation is
344 // handled by the dtrace component of the kernel, and inactive probes are
345 // very cheap — usually, one no-op. Consequently, dtrace can be used with
346 // all flavours of the RTS. In addition, we still support logging events to
347 // a file, even in the presence of dtrace. This is, eg, useful when tracing
348 // on a server, but browsing trace information with ThreadScope on a local
349 // client.
350 //
351 // -----------------------------------------------------------------------------
352
353 INLINE_HEADER void traceEventCreateThread(Capability *cap STG_UNUSED,
354 StgTSO *tso STG_UNUSED)
355 {
f30d527 @simonmar Implement stack chunks and separate TSO/STACK objects
simonmar authored
356 traceSchedEvent(cap, EVENT_CREATE_THREAD, tso, tso->stackobj->stack_size);
015d3d4 @mchakravarty Expose all EventLog events as DTrace probes
mchakravarty authored
357 dtraceCreateThread((EventCapNo)cap->no, (EventThreadID)tso->id);
358 }
359
360 INLINE_HEADER void traceEventRunThread(Capability *cap STG_UNUSED,
361 StgTSO *tso STG_UNUSED)
362 {
363 traceSchedEvent(cap, EVENT_RUN_THREAD, tso, tso->what_next);
364 dtraceRunThread((EventCapNo)cap->no, (EventThreadID)tso->id);
365 }
366
367 INLINE_HEADER void traceEventStopThread(Capability *cap STG_UNUSED,
368 StgTSO *tso STG_UNUSED,
784e214 @simonmar Annotate thread stop events with the owner of the black hole
simonmar authored
369 StgThreadReturnCode status STG_UNUSED,
370 StgWord32 info STG_UNUSED)
015d3d4 @mchakravarty Expose all EventLog events as DTrace probes
mchakravarty authored
371 {
784e214 @simonmar Annotate thread stop events with the owner of the black hole
simonmar authored
372 traceSchedEvent2(cap, EVENT_STOP_THREAD, tso, status, info);
015d3d4 @mchakravarty Expose all EventLog events as DTrace probes
mchakravarty authored
373 dtraceStopThread((EventCapNo)cap->no, (EventThreadID)tso->id,
784e214 @simonmar Annotate thread stop events with the owner of the black hole
simonmar authored
374 (EventThreadStatus)status, (EventThreadID)info);
015d3d4 @mchakravarty Expose all EventLog events as DTrace probes
mchakravarty authored
375 }
376
377 // needs to be EXTERN_INLINE as it is used in another EXTERN_INLINE function
378 EXTERN_INLINE void traceEventThreadRunnable(Capability *cap STG_UNUSED,
379 StgTSO *tso STG_UNUSED);
380
381 EXTERN_INLINE void traceEventThreadRunnable(Capability *cap STG_UNUSED,
382 StgTSO *tso STG_UNUSED)
383 {
384 traceSchedEvent(cap, EVENT_THREAD_RUNNABLE, tso, 0);
385 dtraceThreadRunnable((EventCapNo)cap->no, (EventThreadID)tso->id);
386 }
387
388 INLINE_HEADER void traceEventMigrateThread(Capability *cap STG_UNUSED,
389 StgTSO *tso STG_UNUSED,
390 nat new_cap STG_UNUSED)
391 {
392 traceSchedEvent(cap, EVENT_MIGRATE_THREAD, tso, new_cap);
393 dtraceMigrateThread((EventCapNo)cap->no, (EventThreadID)tso->id,
394 (EventCapNo)new_cap);
395 }
396
397 INLINE_HEADER void traceEventShutdown(Capability *cap STG_UNUSED)
398 {
399 traceSchedEvent(cap, EVENT_SHUTDOWN, 0, 0);
400 dtraceShutdown((EventCapNo)cap->no);
401 }
402
403 INLINE_HEADER void traceEventThreadWakeup(Capability *cap STG_UNUSED,
404 StgTSO *tso STG_UNUSED,
405 nat other_cap STG_UNUSED)
406 {
407 traceSchedEvent(cap, EVENT_THREAD_WAKEUP, tso, other_cap);
408 dtraceThreadWakeup((EventCapNo)cap->no, (EventThreadID)tso->id,
409 (EventCapNo)other_cap);
410 }
411
412 INLINE_HEADER void traceEventGcStart(Capability *cap STG_UNUSED)
413 {
46b7074 @dcoutts Move GC tracing into a separate trace class
dcoutts authored
414 traceGcEvent(cap, EVENT_GC_START);
015d3d4 @mchakravarty Expose all EventLog events as DTrace probes
mchakravarty authored
415 dtraceGcStart((EventCapNo)cap->no);
416 }
417
418 INLINE_HEADER void traceEventGcEnd(Capability *cap STG_UNUSED)
419 {
46b7074 @dcoutts Move GC tracing into a separate trace class
dcoutts authored
420 traceGcEvent(cap, EVENT_GC_END);
015d3d4 @mchakravarty Expose all EventLog events as DTrace probes
mchakravarty authored
421 dtraceGcEnd((EventCapNo)cap->no);
422 }
423
424 INLINE_HEADER void traceEventRequestSeqGc(Capability *cap STG_UNUSED)
425 {
46b7074 @dcoutts Move GC tracing into a separate trace class
dcoutts authored
426 traceGcEvent(cap, EVENT_REQUEST_SEQ_GC);
015d3d4 @mchakravarty Expose all EventLog events as DTrace probes
mchakravarty authored
427 dtraceRequestSeqGc((EventCapNo)cap->no);
428 }
429
430 INLINE_HEADER void traceEventRequestParGc(Capability *cap STG_UNUSED)
431 {
46b7074 @dcoutts Move GC tracing into a separate trace class
dcoutts authored
432 traceGcEvent(cap, EVENT_REQUEST_PAR_GC);
015d3d4 @mchakravarty Expose all EventLog events as DTrace probes
mchakravarty authored
433 dtraceRequestParGc((EventCapNo)cap->no);
434 }
435
46b7074 @dcoutts Move GC tracing into a separate trace class
dcoutts authored
436 INLINE_HEADER void traceEventGcIdle(Capability *cap STG_UNUSED)
437 {
438 traceGcEvent(cap, EVENT_GC_IDLE);
439 dtraceGcIdle((EventCapNo)cap->no);
440 }
441
442 INLINE_HEADER void traceEventGcWork(Capability *cap STG_UNUSED)
443 {
444 traceGcEvent(cap, EVENT_GC_WORK);
445 dtraceGcWork((EventCapNo)cap->no);
446 }
447
448 INLINE_HEADER void traceEventGcDone(Capability *cap STG_UNUSED)
449 {
450 traceGcEvent(cap, EVENT_GC_DONE);
451 dtraceGcDone((EventCapNo)cap->no);
452 }
453
c4f9b98 @dcoutts Make the tracing of the startup event more regular
dcoutts authored
454 INLINE_HEADER void traceEventStartup(void)
015d3d4 @mchakravarty Expose all EventLog events as DTrace probes
mchakravarty authored
455 {
c4f9b98 @dcoutts Make the tracing of the startup event more regular
dcoutts authored
456 int n_caps;
015d3d4 @mchakravarty Expose all EventLog events as DTrace probes
mchakravarty authored
457 #ifdef THREADED_RTS
12b9388 @igfoo Fix a typo in a comment
igfoo authored
458 // XXX n_capabilities hasn't been initialised yet
c4f9b98 @dcoutts Make the tracing of the startup event more regular
dcoutts authored
459 n_caps = RtsFlags.ParFlags.nNodes;
015d3d4 @mchakravarty Expose all EventLog events as DTrace probes
mchakravarty authored
460 #else
c4f9b98 @dcoutts Make the tracing of the startup event more regular
dcoutts authored
461 n_caps = 1;
015d3d4 @mchakravarty Expose all EventLog events as DTrace probes
mchakravarty authored
462 #endif
c4f9b98 @dcoutts Make the tracing of the startup event more regular
dcoutts authored
463
464 traceEventStartup_(n_caps);
465 dtraceStartup(n_caps);
015d3d4 @mchakravarty Expose all EventLog events as DTrace probes
mchakravarty authored
466 }
467
43c7d55 @dcoutts Add capability sets to the tracing/events system
dcoutts authored
468 INLINE_HEADER void traceCapsetCreate(CapsetID capset STG_UNUSED,
469 CapsetType capset_type STG_UNUSED)
470 {
471 traceCapsetModify_(EVENT_CAPSET_CREATE, capset, capset_type);
472 dtraceCapsetCreate(capset, capset_type);
473 }
474
475 INLINE_HEADER void traceCapsetDelete(CapsetID capset STG_UNUSED)
476 {
477 traceCapsetModify_(EVENT_CAPSET_DELETE, capset, 0);
478 dtraceCapsetDelete(capset);
479 }
480
481 INLINE_HEADER void traceCapsetAssignCap(CapsetID capset STG_UNUSED,
482 nat capno STG_UNUSED)
483 {
484 traceCapsetModify_(EVENT_CAPSET_ASSIGN_CAP, capset, capno);
485 dtraceCapsetAssignCap(capset, capno);
486 }
487
488 INLINE_HEADER void traceCapsetRemoveCap(CapsetID capset STG_UNUSED,
489 nat capno STG_UNUSED)
490 {
491 traceCapsetModify_(EVENT_CAPSET_REMOVE_CAP, capset, capno);
492 dtraceCapsetRemoveCap(capset, capno);
493 }
494
e8832eb @dcoutts Emit various bits of OS process info into the eventlog
dcoutts authored
495 INLINE_HEADER void traceOSProcessInfo(void)
496 {
497 traceOSProcessInfo_();
498 /* Note: no DTrace equivalent because all this OS process info
499 * is available to DTrace directly */
500 }
501
084b64f @dcoutts Add new fully-accurate per-spark trace/eventlog events
dcoutts authored
502 INLINE_HEADER void traceEventCreateSparkThread(Capability *cap STG_UNUSED,
503 StgThreadID spark_tid STG_UNUSED)
504 {
505 traceSparkEvent2(cap, EVENT_CREATE_SPARK_THREAD, spark_tid);
506 dtraceCreateSparkThread((EventCapNo)cap->no, (EventThreadID)spark_tid);
507 }
508
d77df1c @dcoutts Add spark counter tracing
dcoutts authored
509 INLINE_HEADER void traceSparkCounters(Capability *cap STG_UNUSED)
510 {
511 #ifdef THREADED_RTS
084b64f @dcoutts Add new fully-accurate per-spark trace/eventlog events
dcoutts authored
512 if (RTS_UNLIKELY(TRACE_spark_sampled)) {
d77df1c @dcoutts Add spark counter tracing
dcoutts authored
513 traceSparkCounters_(cap, cap->spark_stats, sparkPoolSize(cap->sparks));
514 }
515 dtraceSparkCounters((EventCapNo)cap->no,
516 cap->spark_stats.created,
517 cap->spark_stats.dud,
518 cap->spark_stats.overflowed,
519 cap->spark_stats.converted,
520 cap->spark_stats.gcd,
521 cap->spark_stats.fizzled,
522 sparkPoolSize(cap->sparks));
e06ffb5 @benl23x5 Fix build on OSX, thanks to David Peixotto
benl23x5 authored
523 #endif
d77df1c @dcoutts Add spark counter tracing
dcoutts authored
524 }
525
084b64f @dcoutts Add new fully-accurate per-spark trace/eventlog events
dcoutts authored
526 INLINE_HEADER void traceEventSparkCreate(Capability *cap STG_UNUSED)
527 {
528 traceSparkEvent(cap, EVENT_SPARK_CREATE);
529 dtraceSparkCreate((EventCapNo)cap->no);
530 }
531
532 INLINE_HEADER void traceEventSparkDud(Capability *cap STG_UNUSED)
533 {
534 traceSparkEvent(cap, EVENT_SPARK_DUD);
535 dtraceSparkDud((EventCapNo)cap->no);
536 }
537
538 INLINE_HEADER void traceEventSparkOverflow(Capability *cap STG_UNUSED)
539 {
540 traceSparkEvent(cap, EVENT_SPARK_OVERFLOW);
541 dtraceSparkOverflow((EventCapNo)cap->no);
542 }
543
544 INLINE_HEADER void traceEventSparkRun(Capability *cap STG_UNUSED)
545 {
546 traceSparkEvent(cap, EVENT_SPARK_RUN);
547 dtraceSparkRun((EventCapNo)cap->no);
548 }
549
550 INLINE_HEADER void traceEventSparkSteal(Capability *cap STG_UNUSED,
551 nat victim_cap STG_UNUSED)
552 {
553 traceSparkEvent2(cap, EVENT_SPARK_STEAL, victim_cap);
554 dtraceSparkSteal((EventCapNo)cap->no, (EventCapNo)victim_cap);
555 }
556
557 INLINE_HEADER void traceEventSparkFizzle(Capability *cap STG_UNUSED)
558 {
559 traceSparkEvent(cap, EVENT_SPARK_FIZZLE);
560 dtraceSparkFizzle((EventCapNo)cap->no);
561 }
562
563 INLINE_HEADER void traceEventSparkGC(Capability *cap STG_UNUSED)
564 {
565 traceSparkEvent(cap, EVENT_SPARK_GC);
566 dtraceSparkGc((EventCapNo)cap->no);
567 }
d77df1c @dcoutts Add spark counter tracing
dcoutts authored
568
51b8503 @simonmar Fix the symbol visibility pragmas
simonmar authored
569 #include "EndPrivate.h"
7d7c187 @simonmar Declare RTS-private prototypes with __attribute__((visibility("hidden"))...
simonmar authored
570
5a2769f New tracing interface
Simon Marlow authored
571 #endif /* TRACE_H */
Something went wrong with that request. Please try again.