Trace.h 21.9 KB
Newer Older
Simon Marlow's avatar
Simon Marlow committed
1 2
/* -----------------------------------------------------------------------------
 *
3
 * (c) The GHC Team, 2008-2009
Simon Marlow's avatar
Simon Marlow committed
4
 *
5
 * Support for fast binary event logging and user-space dtrace probes.
Simon Marlow's avatar
Simon Marlow committed
6 7 8 9 10 11
 *
 * ---------------------------------------------------------------------------*/

#ifndef TRACE_H
#define TRACE_H

12 13 14
#include "rts/EventLogFormat.h"
#include "Capability.h"

15 16 17 18
#if defined(DTRACE)
#include "RtsProbes.h"
#endif /* defined(DTRACE) */

19
#include "BeginPrivate.h"
20

21 22 23
// -----------------------------------------------------------------------------
// EventLog API
// -----------------------------------------------------------------------------
Simon Marlow's avatar
Simon Marlow committed
24

25
#if defined(TRACING)
Simon Marlow's avatar
Simon Marlow committed
26

27 28 29
void initTracing (void);
void endTracing  (void);
void freeTracing (void);
30
void resetTracing (void);
31
void tracingAddCapapilities (nat from, nat to);
Simon Marlow's avatar
Simon Marlow committed
32

33
#endif /* TRACING */
Simon Marlow's avatar
Simon Marlow committed
34

35 36 37 38 39 40
typedef StgWord32 CapsetID;
typedef StgWord16 CapsetType;
enum CapsetType { CapsetTypeCustom = CAPSET_TYPE_CUSTOM,
                  CapsetTypeOsProcess = CAPSET_TYPE_OSPROCESS,
                  CapsetTypeClockdomain = CAPSET_TYPE_CLOCKDOMAIN };
#define CAPSET_OSPROCESS_DEFAULT 0
41
#define CAPSET_CLOCKDOMAIN_DEFAULT 1
42

Simon Marlow's avatar
Simon Marlow committed
43
// -----------------------------------------------------------------------------
44
// Message classes
Simon Marlow's avatar
Simon Marlow committed
45 46 47
// -----------------------------------------------------------------------------

// debugging flags, set with +RTS -D<something>
48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63
extern int DEBUG_sched;
extern int DEBUG_interp;
extern int DEBUG_weak;
extern int DEBUG_gccafs;
extern int DEBUG_gc;
extern int DEBUG_block_alloc;
extern int DEBUG_sanity;
extern int DEBUG_stable;
extern int DEBUG_stm;
extern int DEBUG_prof;
extern int DEBUG_gran;
extern int DEBUG_par;
extern int DEBUG_linker;
extern int DEBUG_squeeze;
extern int DEBUG_hpc;
extern int DEBUG_sparks;
64 65

// events
66
extern int TRACE_sched;
67
extern int TRACE_gc;
68 69
extern int TRACE_spark_sampled;
extern int TRACE_spark_full;
70
/* extern int TRACE_user; */  // only used in Trace.c
Simon Marlow's avatar
Simon Marlow committed
71 72

// -----------------------------------------------------------------------------
73 74 75 76 77 78 79
// Posting events
//
// We use macros rather than inline functions deliberately.  We want
// the not-taken case to be as efficient as possible, a simple
// test-and-jump, and with inline functions gcc seemed to move some of
// the instructions from the branch up before the test.
// 
Simon Marlow's avatar
Simon Marlow committed
80 81
// -----------------------------------------------------------------------------

82 83 84 85
#ifdef DEBUG
void traceBegin (const char *str, ...);
void traceEnd (void);
#endif
86

87
#ifdef TRACING
Simon Marlow's avatar
Simon Marlow committed
88

89 90 91 92 93
/* 
 * Record a scheduler event
 */
#define traceSchedEvent(cap, tag, tso, other)   \
    if (RTS_UNLIKELY(TRACE_sched)) {            \
94 95 96 97 98 99
        traceSchedEvent_(cap, tag, tso, other, 0); \
    }

#define traceSchedEvent2(cap, tag, tso, info1, info2) \
    if (RTS_UNLIKELY(TRACE_sched)) {            \
        traceSchedEvent_(cap, tag, tso, info1, info2); \
100
    }
101 102

void traceSchedEvent_ (Capability *cap, EventTypeNum tag, 
103
                       StgTSO *tso, StgWord info1, StgWord info2);
104

105 106
/* 
 * Record a GC event
107
 */
108 109 110
#define traceGcEvent(cap, tag)    \
    if (RTS_UNLIKELY(TRACE_gc)) { \
        traceGcEvent_(cap, tag);  \
111 112
    }

113
void traceGcEvent_ (Capability *cap, EventTypeNum tag);
114

115 116 117 118 119 120 121 122 123 124 125 126 127 128 129
/* 
 * Record a spark event
 */
#define traceSparkEvent(cap, tag)         \
    if (RTS_UNLIKELY(TRACE_spark_full)) { \
        traceSparkEvent_(cap, tag, 0);    \
    }

#define traceSparkEvent2(cap, tag, other)  \
    if (RTS_UNLIKELY(TRACE_spark_full)) {  \
        traceSparkEvent_(cap, tag, other); \
    }

void traceSparkEvent_ (Capability *cap, EventTypeNum tag, StgWord info1);

130 131 132 133
// variadic macros are C99, and supported by gcc.  However, the
// ##__VA_ARGS syntax is a gcc extension, which allows the variable
// argument list to be empty (see gcc docs for details).

134
/* 
135
 * Emit a trace message on a particular Capability
136
 */
137 138 139
#define traceCap(class, cap, msg, ...)          \
    if (RTS_UNLIKELY(class)) {                  \
        traceCap_(cap, msg, ##__VA_ARGS__);     \
140 141
    }

142
void traceCap_(Capability *cap, char *msg, ...);
143 144

/* 
145
 * Emit a trace message
146
 */
147 148 149
#define trace(class, msg, ...)                  \
    if (RTS_UNLIKELY(class)) {                  \
        trace_(msg, ##__VA_ARGS__);             \
150 151
    }

152
void trace_(char *msg, ...);
153

154 155
/* 
 * A message or event emitted by the program
156
 * Used by Debug.Trace.{traceEvent, traceEventIO}
157 158 159
 */
void traceUserMsg(Capability *cap, char *msg);

160 161 162 163 164 165 166 167
/*
 * An event to record a Haskell thread's label/name
 * Used by GHC.Conc.labelThread
 */
void traceThreadLabel_(Capability *cap,
                       StgTSO     *tso,
                       char       *label);

168
/* 
169
 * Emit a debug message (only when DEBUG is defined)
170 171
 */
#ifdef DEBUG
172 173 174
#define debugTrace(class, msg, ...)             \
    if (RTS_UNLIKELY(class)) {                  \
        trace_(msg, ##__VA_ARGS__);             \
175 176 177 178 179
    }
#else
#define debugTrace(class, str, ...) /* nothing */
#endif

180 181 182 183 184 185 186 187 188
#ifdef DEBUG
#define debugTraceCap(class, cap, msg, ...)      \
    if (RTS_UNLIKELY(class)) {                  \
        traceCap_(cap, msg, ##__VA_ARGS__);     \
    }
#else
#define debugTraceCap(class, cap, str, ...) /* nothing */
#endif

189 190 191 192 193 194
/* 
 * Emit a message/event describing the state of a thread
 */
#define traceThreadStatus(class, tso)           \
    if (RTS_UNLIKELY(class)) {                  \
        traceThreadStatus_(tso);                \
195 196
    }

197
void traceThreadStatus_ (StgTSO *tso);
198

199 200
void traceEventStartup_ (int n_caps);

201
/*
202
 * Events for describing capabilities and capability sets in the eventlog
203 204
 *
 * Note: unlike other events, these are not conditional on TRACE_sched or
205 206 207 208
 * similar because capabilities and capability sets are important
 * context for other events. Since other events depend on these events
 * then for simplicity we always emit them, rather than working out if
 * they're necessary . They should be very low volume.
209
 */
210 211 212 213 214 215
void traceCapEvent (Capability   *cap,
                    EventTypeNum  tag);

void traceCapsetEvent (EventTypeNum tag,
                       CapsetID     capset,
                       StgWord      info);
216

217 218
void traceWallClockTime_(void);

219 220
void traceOSProcessInfo_ (void);

Duncan Coutts's avatar
Duncan Coutts committed
221 222 223 224
void traceSparkCounters_ (Capability *cap,
                          SparkCounters counters,
                          StgWord remaining);

225
#else /* !TRACING */
226

227
#define traceSchedEvent(cap, tag, tso, other) /* nothing */
228
#define traceSchedEvent2(cap, tag, tso, other, info) /* nothing */
229
#define traceGcEvent(cap, tag) /* nothing */
230 231
#define traceSparkEvent(cap, tag) /* nothing */
#define traceSparkEvent2(cap, tag, other) /* nothing */
232 233
#define traceCap(class, cap, msg, ...) /* nothing */
#define trace(class, msg, ...) /* nothing */
234
#define debugTrace(class, str, ...) /* nothing */
235
#define debugTraceCap(class, cap, str, ...) /* nothing */
236
#define traceThreadStatus(class, tso) /* nothing */
237
#define traceThreadLabel_(cap, tso, label) /* nothing */
Ian Lynagh's avatar
Ian Lynagh committed
238
INLINE_HEADER void traceEventStartup_ (int n_caps STG_UNUSED) {};
239 240
#define traceCapEvent(cap, tag) /* nothing */
#define traceCapsetEvent(tag, capset, info) /* nothing */
241
#define traceWallClockTime_() /* nothing */
242
#define traceOSProcessInfo_() /* nothing */
Duncan Coutts's avatar
Duncan Coutts committed
243
#define traceSparkCounters_(cap, counters, remaining) /* nothing */
244 245

#endif /* TRACING */
Simon Marlow's avatar
Simon Marlow committed
246

247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265
// If DTRACE is enabled, but neither DEBUG nor TRACING, we need a C land
// wrapper for the user-msg probe (as we can't expand that in PrimOps.cmm)
//
#if !defined(DEBUG) && !defined(TRACING) && defined(DTRACE)

void dtraceUserMsgWrapper(Capability *cap, char *msg);

#endif /* !defined(DEBUG) && !defined(TRACING) && defined(DTRACE) */

// -----------------------------------------------------------------------------
// Aliases for static dtrace probes if dtrace is available
// -----------------------------------------------------------------------------

#if defined(DTRACE)

#define dtraceCreateThread(cap, tid)                    \
    HASKELLEVENT_CREATE_THREAD(cap, tid)
#define dtraceRunThread(cap, tid)                       \
    HASKELLEVENT_RUN_THREAD(cap, tid)
266 267
#define dtraceStopThread(cap, tid, status, info)        \
    HASKELLEVENT_STOP_THREAD(cap, tid, status, info)
268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283
#define dtraceThreadRunnable(cap, tid)                  \
    HASKELLEVENT_THREAD_RUNNABLE(cap, tid)
#define dtraceMigrateThread(cap, tid, new_cap)          \
    HASKELLEVENT_MIGRATE_THREAD(cap, tid, new_cap)
#define dtraceThreadWakeup(cap, tid, other_cap)         \
    HASKELLEVENT_THREAD_WAKEUP(cap, tid, other_cap)
#define dtraceGcStart(cap)                              \
    HASKELLEVENT_GC_START(cap)
#define dtraceGcEnd(cap)                                \
    HASKELLEVENT_GC_END(cap)
#define dtraceRequestSeqGc(cap)                         \
    HASKELLEVENT_REQUEST_SEQ_GC(cap)
#define dtraceRequestParGc(cap)                         \
    HASKELLEVENT_REQUEST_PAR_GC(cap)
#define dtraceCreateSparkThread(cap, spark_tid)         \
    HASKELLEVENT_CREATE_SPARK_THREAD(cap, spark_tid)
284 285
#define dtraceThreadLabel(cap, tso, label)              \
    HASKELLEVENT_THREAD_LABEL(cap, tso, label)
286 287
INLINE_HEADER void dtraceStartup (int num_caps) {
    HASKELLEVENT_STARTUP(num_caps);
Ian Lynagh's avatar
Ian Lynagh committed
288
}
289 290 291 292 293 294 295 296
#define dtraceCapCreate(cap)                            \
    HASKELLEVENT_CAP_CREATE(cap)
#define dtraceCapDelete(cap)                            \
    HASKELLEVENT_CAP_DELETE(cap)
#define dtraceCapEnable(cap)                            \
    HASKELLEVENT_CAP_ENABLE(cap)
#define dtraceCapDisable(cap)                           \
    HASKELLEVENT_CAP_DISABLE(cap)
297 298 299 300 301 302 303 304
#define dtraceUserMsg(cap, msg)                         \
    HASKELLEVENT_USER_MSG(cap, msg)
#define dtraceGcIdle(cap)                               \
    HASKELLEVENT_GC_IDLE(cap)
#define dtraceGcWork(cap)                               \
    HASKELLEVENT_GC_WORK(cap)
#define dtraceGcDone(cap)                               \
    HASKELLEVENT_GC_DONE(cap)
305 306 307 308 309 310 311 312
#define dtraceCapsetCreate(capset, capset_type)         \
    HASKELLEVENT_CAPSET_CREATE(capset, capset_type)
#define dtraceCapsetDelete(capset)                      \
    HASKELLEVENT_CAPSET_DELETE(capset)
#define dtraceCapsetAssignCap(capset, capno)            \
    HASKELLEVENT_CAPSET_ASSIGN_CAP(capset, capno)
#define dtraceCapsetRemoveCap(capset, capno)            \
    HASKELLEVENT_CAPSET_REMOVE_CAP(capset, capno)
Duncan Coutts's avatar
Duncan Coutts committed
313 314
#define dtraceSparkCounters(cap, a, b, c, d, e, f, g) \
    HASKELLEVENT_SPARK_COUNTERS(cap, a, b, c, d, e, f, g)
315 316 317 318 319 320 321 322 323 324 325 326 327 328
#define dtraceSparkCreate(cap)                         \
    HASKELLEVENT_SPARK_CREATE(cap)
#define dtraceSparkDud(cap)                             \
    HASKELLEVENT_SPARK_DUD(cap)
#define dtraceSparkOverflow(cap)                        \
    HASKELLEVENT_SPARK_OVERFLOW(cap)
#define dtraceSparkRun(cap)                             \
    HASKELLEVENT_SPARK_RUN(cap)
#define dtraceSparkSteal(cap, victim_cap)               \
    HASKELLEVENT_SPARK_STEAL(cap, victim_cap)
#define dtraceSparkFizzle(cap)                          \
    HASKELLEVENT_SPARK_FIZZLE(cap)
#define dtraceSparkGc(cap)                              \
    HASKELLEVENT_SPARK_GC(cap)
329 330 331 332 333

#else /* !defined(DTRACE) */

#define dtraceCreateThread(cap, tid)                    /* nothing */
#define dtraceRunThread(cap, tid)                       /* nothing */
334
#define dtraceStopThread(cap, tid, status, info)        /* nothing */
335 336 337 338 339 340 341 342
#define dtraceThreadRunnable(cap, tid)                  /* nothing */
#define dtraceMigrateThread(cap, tid, new_cap)          /* nothing */
#define dtraceThreadWakeup(cap, tid, other_cap)         /* nothing */
#define dtraceGcStart(cap)                              /* nothing */
#define dtraceGcEnd(cap)                                /* nothing */
#define dtraceRequestSeqGc(cap)                         /* nothing */
#define dtraceRequestParGc(cap)                         /* nothing */
#define dtraceCreateSparkThread(cap, spark_tid)         /* nothing */
343
#define dtraceThreadLabel(cap, tso, label)              /* nothing */
344
INLINE_HEADER void dtraceStartup (int num_caps STG_UNUSED) {};
345 346 347 348
#define dtraceUserMsg(cap, msg)                         /* nothing */
#define dtraceGcIdle(cap)                               /* nothing */
#define dtraceGcWork(cap)                               /* nothing */
#define dtraceGcDone(cap)                               /* nothing */
349 350 351 352
#define dtraceCapCreate(cap)                            /* nothing */
#define dtraceCapDelete(cap)                            /* nothing */
#define dtraceCapEnable(cap)                            /* nothing */
#define dtraceCapDisable(cap)                           /* nothing */
353 354 355 356
#define dtraceCapsetCreate(capset, capset_type)         /* nothing */
#define dtraceCapsetDelete(capset)                      /* nothing */
#define dtraceCapsetAssignCap(capset, capno)            /* nothing */
#define dtraceCapsetRemoveCap(capset, capno)            /* nothing */
Duncan Coutts's avatar
Duncan Coutts committed
357
#define dtraceSparkCounters(cap, a, b, c, d, e, f, g)   /* nothing */
358 359 360 361 362 363 364
#define dtraceSparkCreate(cap)                          /* nothing */
#define dtraceSparkDud(cap)                             /* nothing */
#define dtraceSparkOverflow(cap)                        /* nothing */
#define dtraceSparkRun(cap)                             /* nothing */
#define dtraceSparkSteal(cap, victim_cap)               /* nothing */
#define dtraceSparkFizzle(cap)                          /* nothing */
#define dtraceSparkGc(cap)                              /* nothing */
365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387

#endif

// -----------------------------------------------------------------------------
// Trace probes dispatching to various tracing frameworks
//
// In order to avoid accumulating multiple calls to tracing calls at trace
// points, we define inline probe functions that contain the various
// invocations.
//
// Dtrace - dtrace probes are unconditionally added as probe activation is
//   handled by the dtrace component of the kernel, and inactive probes are
//   very cheap — usually, one no-op.  Consequently, dtrace can be used with
//   all flavours of the RTS.  In addition, we still support logging events to
//   a file, even in the presence of dtrace.  This is, eg, useful when tracing
//   on a server, but browsing trace information with ThreadScope on a local
//   client.
// 
// -----------------------------------------------------------------------------

INLINE_HEADER void traceEventCreateThread(Capability *cap STG_UNUSED, 
                                          StgTSO     *tso STG_UNUSED)
{
388
    traceSchedEvent(cap, EVENT_CREATE_THREAD, tso, tso->stackobj->stack_size);
389 390 391 392 393 394 395 396 397 398 399 400
    dtraceCreateThread((EventCapNo)cap->no, (EventThreadID)tso->id);
}

INLINE_HEADER void traceEventRunThread(Capability *cap STG_UNUSED, 
                                       StgTSO     *tso STG_UNUSED)
{
    traceSchedEvent(cap, EVENT_RUN_THREAD, tso, tso->what_next);
    dtraceRunThread((EventCapNo)cap->no, (EventThreadID)tso->id);
}

INLINE_HEADER void traceEventStopThread(Capability          *cap    STG_UNUSED, 
                                        StgTSO              *tso    STG_UNUSED, 
401 402
                                        StgThreadReturnCode  status STG_UNUSED,
                                        StgWord32           info    STG_UNUSED)
403
{
404
    traceSchedEvent2(cap, EVENT_STOP_THREAD, tso, status, info);
405
    dtraceStopThread((EventCapNo)cap->no, (EventThreadID)tso->id,
406
                     (EventThreadStatus)status, (EventThreadID)info);
407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428
}

// needs to be EXTERN_INLINE as it is used in another EXTERN_INLINE function
EXTERN_INLINE void traceEventThreadRunnable(Capability *cap STG_UNUSED, 
                                            StgTSO     *tso STG_UNUSED);

EXTERN_INLINE void traceEventThreadRunnable(Capability *cap STG_UNUSED, 
                                            StgTSO     *tso STG_UNUSED)
{
    traceSchedEvent(cap, EVENT_THREAD_RUNNABLE, tso, 0);
    dtraceThreadRunnable((EventCapNo)cap->no, (EventThreadID)tso->id);
}

INLINE_HEADER void traceEventMigrateThread(Capability *cap     STG_UNUSED, 
                                           StgTSO     *tso     STG_UNUSED,
                                           nat         new_cap STG_UNUSED)
{
    traceSchedEvent(cap, EVENT_MIGRATE_THREAD, tso, new_cap);
    dtraceMigrateThread((EventCapNo)cap->no, (EventThreadID)tso->id,
                        (EventCapNo)new_cap);
}

429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447
INLINE_HEADER void traceCapCreate(Capability *cap STG_UNUSED)
{
    traceCapEvent(cap, EVENT_CAP_CREATE);
    dtraceCapCreate((EventCapNo)cap->no);
}

INLINE_HEADER void traceCapDelete(Capability *cap STG_UNUSED)
{
    traceCapEvent(cap, EVENT_CAP_DELETE);
    dtraceCapDelete((EventCapNo)cap->no);
}

INLINE_HEADER void traceCapEnable(Capability *cap STG_UNUSED)
{
    traceCapEvent(cap, EVENT_CAP_ENABLE);
    dtraceCapEnable((EventCapNo)cap->no);
}

INLINE_HEADER void traceCapDisable(Capability *cap STG_UNUSED)
448
{
449 450
    traceCapEvent(cap, EVENT_CAP_DISABLE);
    dtraceCapDisable((EventCapNo)cap->no);
451 452 453 454 455 456 457 458 459 460 461
}

INLINE_HEADER void traceEventThreadWakeup(Capability *cap       STG_UNUSED, 
                                          StgTSO     *tso       STG_UNUSED,
                                          nat         other_cap STG_UNUSED)
{
    traceSchedEvent(cap, EVENT_THREAD_WAKEUP, tso, other_cap);
    dtraceThreadWakeup((EventCapNo)cap->no, (EventThreadID)tso->id,
                       (EventCapNo)other_cap);
}

462 463 464 465 466 467 468 469 470 471
INLINE_HEADER void traceThreadLabel(Capability *cap   STG_UNUSED,
                                    StgTSO     *tso   STG_UNUSED,
                                    char       *label STG_UNUSED)
{
    if (RTS_UNLIKELY(TRACE_sched)) {
        traceThreadLabel_(cap, tso, label);
    }
    dtraceThreadLabel((EventCapNo)cap->no, (EventThreadID)tso->id, label);
}

472 473
INLINE_HEADER void traceEventGcStart(Capability *cap STG_UNUSED)
{
474
    traceGcEvent(cap, EVENT_GC_START);
475 476 477 478 479
    dtraceGcStart((EventCapNo)cap->no);
}

INLINE_HEADER void traceEventGcEnd(Capability *cap STG_UNUSED)
{
480
    traceGcEvent(cap, EVENT_GC_END);
481 482 483 484 485
    dtraceGcEnd((EventCapNo)cap->no);
}

INLINE_HEADER void traceEventRequestSeqGc(Capability *cap STG_UNUSED)
{
486
    traceGcEvent(cap, EVENT_REQUEST_SEQ_GC);
487 488 489 490 491
    dtraceRequestSeqGc((EventCapNo)cap->no);
}

INLINE_HEADER void traceEventRequestParGc(Capability *cap STG_UNUSED)
{
492
    traceGcEvent(cap, EVENT_REQUEST_PAR_GC);
493 494 495
    dtraceRequestParGc((EventCapNo)cap->no);
}

496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513
INLINE_HEADER void traceEventGcIdle(Capability *cap STG_UNUSED)
{
    traceGcEvent(cap, EVENT_GC_IDLE);
    dtraceGcIdle((EventCapNo)cap->no);
}

INLINE_HEADER void traceEventGcWork(Capability *cap STG_UNUSED)
{
    traceGcEvent(cap, EVENT_GC_WORK);
    dtraceGcWork((EventCapNo)cap->no);
}

INLINE_HEADER void traceEventGcDone(Capability *cap STG_UNUSED)
{
    traceGcEvent(cap, EVENT_GC_DONE);
    dtraceGcDone((EventCapNo)cap->no);
}

514
INLINE_HEADER void traceEventStartup(void)
515
{
516
    int n_caps;
517
#ifdef THREADED_RTS
Ian Lynagh's avatar
Ian Lynagh committed
518
    // XXX n_capabilities hasn't been initialised yet
519
    n_caps = RtsFlags.ParFlags.nNodes;
520
#else
521
    n_caps = 1;
522
#endif
523 524 525

    traceEventStartup_(n_caps);
    dtraceStartup(n_caps);
526 527
}

528 529 530
INLINE_HEADER void traceCapsetCreate(CapsetID   capset      STG_UNUSED,
                                     CapsetType capset_type STG_UNUSED)
{
531
    traceCapsetEvent(EVENT_CAPSET_CREATE, capset, capset_type);
532 533 534 535 536
    dtraceCapsetCreate(capset, capset_type);
}

INLINE_HEADER void traceCapsetDelete(CapsetID capset STG_UNUSED)
{
537
    traceCapsetEvent(EVENT_CAPSET_DELETE, capset, 0);
538 539 540 541 542 543
    dtraceCapsetDelete(capset);
}

INLINE_HEADER void traceCapsetAssignCap(CapsetID capset STG_UNUSED,
                                        nat      capno  STG_UNUSED)
{
544
    traceCapsetEvent(EVENT_CAPSET_ASSIGN_CAP, capset, capno);
545 546 547 548 549 550
    dtraceCapsetAssignCap(capset, capno);
}

INLINE_HEADER void traceCapsetRemoveCap(CapsetID capset STG_UNUSED,
                                        nat      capno  STG_UNUSED)
{
551
    traceCapsetEvent(EVENT_CAPSET_REMOVE_CAP, capset, capno);
552 553 554
    dtraceCapsetRemoveCap(capset, capno);
}

555 556 557 558 559 560
INLINE_HEADER void traceWallClockTime(void)
{
    traceWallClockTime_();
    /* Note: no DTrace equivalent because it is available to DTrace directly */
}

561 562 563 564 565 566 567
INLINE_HEADER void traceOSProcessInfo(void)
{
    traceOSProcessInfo_();
    /* Note: no DTrace equivalent because all this OS process info
     * is available to DTrace directly */
}

568 569 570 571 572 573 574
INLINE_HEADER void traceEventCreateSparkThread(Capability  *cap      STG_UNUSED, 
                                               StgThreadID spark_tid STG_UNUSED)
{
    traceSparkEvent2(cap, EVENT_CREATE_SPARK_THREAD, spark_tid);
    dtraceCreateSparkThread((EventCapNo)cap->no, (EventThreadID)spark_tid);
}

Duncan Coutts's avatar
Duncan Coutts committed
575 576 577
INLINE_HEADER void traceSparkCounters(Capability *cap STG_UNUSED)
{
#ifdef THREADED_RTS
578
    if (RTS_UNLIKELY(TRACE_spark_sampled)) {
Duncan Coutts's avatar
Duncan Coutts committed
579 580 581 582 583 584 585 586 587 588
        traceSparkCounters_(cap, cap->spark_stats, sparkPoolSize(cap->sparks));
    }
    dtraceSparkCounters((EventCapNo)cap->no,
                        cap->spark_stats.created,
                        cap->spark_stats.dud,
                        cap->spark_stats.overflowed,
                        cap->spark_stats.converted,
                        cap->spark_stats.gcd,
                        cap->spark_stats.fizzled,
                        sparkPoolSize(cap->sparks));
589
#endif
Duncan Coutts's avatar
Duncan Coutts committed
590 591
}

592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633
INLINE_HEADER void traceEventSparkCreate(Capability *cap STG_UNUSED)
{
    traceSparkEvent(cap, EVENT_SPARK_CREATE);
    dtraceSparkCreate((EventCapNo)cap->no);
}

INLINE_HEADER void traceEventSparkDud(Capability *cap STG_UNUSED)
{
    traceSparkEvent(cap, EVENT_SPARK_DUD);
    dtraceSparkDud((EventCapNo)cap->no);
}

INLINE_HEADER void traceEventSparkOverflow(Capability *cap STG_UNUSED)
{
    traceSparkEvent(cap, EVENT_SPARK_OVERFLOW);
    dtraceSparkOverflow((EventCapNo)cap->no);
}

INLINE_HEADER void traceEventSparkRun(Capability *cap STG_UNUSED)
{
    traceSparkEvent(cap, EVENT_SPARK_RUN);
    dtraceSparkRun((EventCapNo)cap->no);
}

INLINE_HEADER void traceEventSparkSteal(Capability *cap STG_UNUSED,
                                        nat         victim_cap STG_UNUSED)
{
    traceSparkEvent2(cap, EVENT_SPARK_STEAL, victim_cap);
    dtraceSparkSteal((EventCapNo)cap->no, (EventCapNo)victim_cap);
}

INLINE_HEADER void traceEventSparkFizzle(Capability *cap STG_UNUSED)
{
    traceSparkEvent(cap, EVENT_SPARK_FIZZLE);
    dtraceSparkFizzle((EventCapNo)cap->no);
}

INLINE_HEADER void traceEventSparkGC(Capability *cap STG_UNUSED)
{
    traceSparkEvent(cap, EVENT_SPARK_GC);
    dtraceSparkGc((EventCapNo)cap->no);
}
Duncan Coutts's avatar
Duncan Coutts committed
634

635
#include "EndPrivate.h"
636

Simon Marlow's avatar
Simon Marlow committed
637
#endif /* TRACE_H */