Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Fetching contributors…

Octocat-spinner-32-eaf2f5

Cannot retrieve contributors at this time

file 158 lines (125 sloc) 4.122 kb
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157
/* -----------------------------------------------------------------------------
*
* (c) The GHC Team, 2008-2009
*
* Support for fast binary event logging.
*
* ---------------------------------------------------------------------------*/

#ifndef TRACE_H
#define TRACE_H

#include "rts/EventLogFormat.h"
#include "Capability.h"

BEGIN_RTS_PRIVATE

// -----------------------------------------------------------------------------
// EventLog API
// -----------------------------------------------------------------------------

#if defined(TRACING)

void initTracing (void);
void endTracing (void);
void freeTracing (void);

#endif /* TRACING */

// -----------------------------------------------------------------------------
// Message classes
// -----------------------------------------------------------------------------

// debugging flags, set with +RTS -D<something>
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;

// events
extern int TRACE_sched;

// -----------------------------------------------------------------------------
// 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.
//
// -----------------------------------------------------------------------------

#ifdef DEBUG
void traceBegin (const char *str, ...);
void traceEnd (void);
#endif

#ifdef TRACING

/*
* Record a scheduler event
*/
#define traceSchedEvent(cap, tag, tso, other) \
if (RTS_UNLIKELY(TRACE_sched)) { \
traceSchedEvent_(cap, tag, tso, other); \
}

void traceSchedEvent_ (Capability *cap, EventTypeNum tag,
                       StgTSO *tso, StgWord64 other);


/*
* Record a nullary event
*/
#define traceEvent(cap, tag) \
if (RTS_UNLIKELY(TRACE_sched)) { \
traceEvent_(cap, tag); \
}

void traceEvent_ (Capability *cap, EventTypeNum tag);

// 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).

/*
* Emit a trace message on a particular Capability
*/
#define traceCap(class, cap, msg, ...) \
if (RTS_UNLIKELY(class)) { \
traceCap_(cap, msg, ##__VA_ARGS__); \
}

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

/*
* Emit a trace message
*/
#define trace(class, msg, ...) \
if (RTS_UNLIKELY(class)) { \
trace_(msg, ##__VA_ARGS__); \
}

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

/*
* A message or event emitted by the program
*/
void traceUserMsg(Capability *cap, char *msg);

/*
* Emit a debug message (only when DEBUG is defined)
*/
#ifdef DEBUG
#define debugTrace(class, msg, ...) \
if (RTS_UNLIKELY(class)) { \
trace_(msg, ##__VA_ARGS__); \
}
#else
#define debugTrace(class, str, ...) /* nothing */
#endif

/*
* Emit a message/event describing the state of a thread
*/
#define traceThreadStatus(class, tso) \
if (RTS_UNLIKELY(class)) { \
traceThreadStatus_(tso); \
}

void traceThreadStatus_ (StgTSO *tso);

#else /* !TRACING */

#define traceSchedEvent(cap, tag, tso, other) /* nothing */
#define traceEvent(cap, tag) /* nothing */
#define traceCap(class, cap, msg, ...) /* nothing */
#define trace(class, msg, ...) /* nothing */
#define debugTrace(class, str, ...) /* nothing */
#define traceThreadStatus(class, tso) /* nothing */

#endif /* TRACING */

END_RTS_PRIVATE

#endif /* TRACE_H */
Something went wrong with that request. Please try again.