EventLog.c 40.5 KB
Newer Older
Simon Marlow's avatar
Simon Marlow committed
1 2 3 4 5 6 7 8
/* -----------------------------------------------------------------------------
 *
 * (c) The GHC Team, 2008-2009
 *
 * Support for fast binary event logging.
 *
 * ---------------------------------------------------------------------------*/

Simon Marlow's avatar
Simon Marlow committed
9
#include "PosixSource.h"
Simon Marlow's avatar
Simon Marlow committed
10
#include "Rts.h"
Simon Marlow's avatar
Simon Marlow committed
11

Ben Gamari's avatar
Ben Gamari committed
12
#if defined(TRACING)
13 14

#include "Trace.h"
Simon Marlow's avatar
Simon Marlow committed
15 16 17
#include "Capability.h"
#include "RtsUtils.h"
#include "Stats.h"
18
#include "EventLog.h"
Simon Marlow's avatar
Simon Marlow committed
19

20
#include <string.h>
Simon Marlow's avatar
Simon Marlow committed
21
#include <stdio.h>
Ben Gamari's avatar
Ben Gamari committed
22
#if defined(HAVE_SYS_TYPES_H)
23 24
#include <sys/types.h>
#endif
Ben Gamari's avatar
Ben Gamari committed
25
#if defined(HAVE_UNISTD_H)
26 27 28
#include <unistd.h>
#endif

29
static const EventLogWriter *event_log_writer;
Simon Marlow's avatar
Simon Marlow committed
30 31 32 33 34 35 36 37 38

#define EVENT_LOG_SIZE 2 * (1024 * 1024) // 2MB

static int flushCount;

// Struct for record keeping of buffer to store event types and events.
typedef struct _EventsBuf {
  StgInt8 *begin;
  StgInt8 *pos;
Simon Marlow's avatar
Simon Marlow committed
39
  StgInt8 *marker;
Simon Marlow's avatar
Simon Marlow committed
40
  StgWord64 size;
41
  EventCapNo capno; // which capability this buffer belongs to, or -1
Simon Marlow's avatar
Simon Marlow committed
42 43
} EventsBuf;

44 45 46
EventsBuf *capEventBuf; // one EventsBuf for each Capability

EventsBuf eventBuf; // an EventsBuf not associated with any Capability
Ben Gamari's avatar
Ben Gamari committed
47
#if defined(THREADED_RTS)
48 49
Mutex eventBufMutex; // protected by this mutex
#endif
Simon Marlow's avatar
Simon Marlow committed
50 51

char *EventDesc[] = {
52 53 54 55 56 57
  [EVENT_CREATE_THREAD]       = "Create thread",
  [EVENT_RUN_THREAD]          = "Run thread",
  [EVENT_STOP_THREAD]         = "Stop thread",
  [EVENT_THREAD_RUNNABLE]     = "Thread runnable",
  [EVENT_MIGRATE_THREAD]      = "Migrate thread",
  [EVENT_THREAD_WAKEUP]       = "Wakeup thread",
58
  [EVENT_THREAD_LABEL]        = "Thread label",
59 60 61 62
  [EVENT_CAP_CREATE]          = "Create capability",
  [EVENT_CAP_DELETE]          = "Delete capability",
  [EVENT_CAP_DISABLE]         = "Disable capability",
  [EVENT_CAP_ENABLE]          = "Enable capability",
63 64 65 66
  [EVENT_GC_START]            = "Starting GC",
  [EVENT_GC_END]              = "Finished GC",
  [EVENT_REQUEST_SEQ_GC]      = "Request sequential GC",
  [EVENT_REQUEST_PAR_GC]      = "Request parallel GC",
67
  [EVENT_GC_GLOBAL_SYNC]      = "Synchronise stop-the-world GC",
68 69 70 71 72
  [EVENT_GC_STATS_GHC]        = "GC statistics",
  [EVENT_HEAP_INFO_GHC]       = "Heap static parameters",
  [EVENT_HEAP_ALLOCATED]      = "Total heap mem ever allocated",
  [EVENT_HEAP_SIZE]           = "Current heap size",
  [EVENT_HEAP_LIVE]           = "Current heap live data",
73 74
  [EVENT_CREATE_SPARK_THREAD] = "Create spark thread",
  [EVENT_LOG_MSG]             = "Log message",
75
  [EVENT_USER_MSG]            = "User message",
76
  [EVENT_USER_MARKER]         = "User marker",
77 78 79
  [EVENT_GC_IDLE]             = "GC idle",
  [EVENT_GC_WORK]             = "GC working",
  [EVENT_GC_DONE]             = "GC done",
80 81 82 83
  [EVENT_BLOCK_MARKER]        = "Block marker",
  [EVENT_CAPSET_CREATE]       = "Create capability set",
  [EVENT_CAPSET_DELETE]       = "Delete capability set",
  [EVENT_CAPSET_ASSIGN_CAP]   = "Add capability to capability set",
84 85 86 87 88
  [EVENT_CAPSET_REMOVE_CAP]   = "Remove capability from capability set",
  [EVENT_RTS_IDENTIFIER]      = "RTS name and version",
  [EVENT_PROGRAM_ARGS]        = "Program arguments",
  [EVENT_PROGRAM_ENV]         = "Program environment variables",
  [EVENT_OSPROCESS_PID]       = "Process ID",
Duncan Coutts's avatar
Duncan Coutts committed
89
  [EVENT_OSPROCESS_PPID]      = "Parent process ID",
90
  [EVENT_WALL_CLOCK_TIME]     = "Wall clock time",
91 92 93 94 95 96 97 98
  [EVENT_SPARK_COUNTERS]      = "Spark counters",
  [EVENT_SPARK_CREATE]        = "Spark create",
  [EVENT_SPARK_DUD]           = "Spark dud",
  [EVENT_SPARK_OVERFLOW]      = "Spark overflow",
  [EVENT_SPARK_RUN]           = "Spark run",
  [EVENT_SPARK_STEAL]         = "Spark steal",
  [EVENT_SPARK_FIZZLE]        = "Spark fizzle",
  [EVENT_SPARK_GC]            = "Spark GC",
99 100 101
  [EVENT_TASK_CREATE]         = "Task create",
  [EVENT_TASK_MIGRATE]        = "Task migrate",
  [EVENT_TASK_DELETE]         = "Task delete",
102
  [EVENT_HACK_BUG_T9003]      = "Empty event for bug #9003",
103 104 105 106 107
  [EVENT_HEAP_PROF_BEGIN]     = "Start of heap profile",
  [EVENT_HEAP_PROF_COST_CENTRE]   = "Cost center definition",
  [EVENT_HEAP_PROF_SAMPLE_BEGIN]  = "Start of heap profile sample",
  [EVENT_HEAP_PROF_SAMPLE_STRING] = "Heap profile string sample",
  [EVENT_HEAP_PROF_SAMPLE_COST_CENTRE] = "Heap profile cost-centre sample",
Mitsutoshi Aoe's avatar
Mitsutoshi Aoe committed
108
  [EVENT_USER_BINARY_MSG]     = "User binary message"
Simon Marlow's avatar
Simon Marlow committed
109 110
};

111
// Event type.
Simon Marlow's avatar
Simon Marlow committed
112 113 114

typedef struct _EventType {
  EventTypeNum etNum;  // Event Type number.
115
  uint32_t   size;     // size of the payload in bytes
Simon Marlow's avatar
Simon Marlow committed
116 117 118
  char *desc;     // Description
} EventType;

119
EventType eventTypes[NUM_GHC_EVENT_TAGS];
Simon Marlow's avatar
Simon Marlow committed
120

121
static void initEventsBuf(EventsBuf* eb, StgWord64 size, EventCapNo capno);
Simon Marlow's avatar
Simon Marlow committed
122
static void resetEventsBuf(EventsBuf* eb);
Simon Marlow's avatar
Simon Marlow committed
123
static void printAndClearEventBuf (EventsBuf *eventsBuf);
Simon Marlow's avatar
Simon Marlow committed
124 125 126

static void postEventType(EventsBuf *eb, EventType *et);

127
static void postLogMsg(EventsBuf *eb, EventTypeNum type, char *msg, va_list ap);
128

Simon Marlow's avatar
Simon Marlow committed
129 130 131
static void postBlockMarker(EventsBuf *eb);
static void closeBlockMarker(EventsBuf *ebuf);

Simon Marlow's avatar
Simon Marlow committed
132
static StgBool hasRoomForEvent(EventsBuf *eb, EventTypeNum eNum);
133
static StgBool hasRoomForVariableEvent(EventsBuf *eb, uint32_t payload_bytes);
Simon Marlow's avatar
Simon Marlow committed
134

135 136 137
static void ensureRoomForEvent(EventsBuf *eb, EventTypeNum tag);
static int ensureRoomForVariableEvent(EventsBuf *eb, StgWord16 size);

138 139
static inline void postWord8(EventsBuf *eb, StgWord8 i)
{
140
    *(eb->pos++) = i;
141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160
}

static inline void postWord16(EventsBuf *eb, StgWord16 i)
{
    postWord8(eb, (StgWord8)(i >> 8));
    postWord8(eb, (StgWord8)i);
}

static inline void postWord32(EventsBuf *eb, StgWord32 i)
{
    postWord16(eb, (StgWord16)(i >> 16));
    postWord16(eb, (StgWord16)i);
}

static inline void postWord64(EventsBuf *eb, StgWord64 i)
{
    postWord32(eb, (StgWord32)(i >> 32));
    postWord32(eb, (StgWord32)i);
}

161
static inline void postBuf(EventsBuf *eb, StgWord8 *buf, uint32_t size)
162 163 164 165 166
{
    memcpy(eb->pos, buf, size);
    eb->pos += size;
}

167 168 169 170 171 172 173
/* Post a null-terminated string to the event log.
 * It is the caller's responsibility to ensure that there is
 * enough room for strlen(buf)+1 bytes.
 */
static inline void postString(EventsBuf *eb, const char *buf)
{
    if (buf) {
174
        const int len = strlen(buf);
175 176 177 178 179 180 181 182
        ASSERT(eb->begin + eb->size > eb->pos + len);
        memcpy(eb->pos, buf, len);
        eb->pos += len;
    }
    *eb->pos = 0;
    eb->pos++;
}

Simon Marlow's avatar
Simon Marlow committed
183
static inline StgWord64 time_ns(void)
Simon Marlow's avatar
Simon Marlow committed
184
{ return TimeToNS(stat_getElapsedTime()); }
Simon Marlow's avatar
Simon Marlow committed
185

186 187 188
static inline void postEventTypeNum(EventsBuf *eb, EventTypeNum etNum)
{ postWord16(eb, etNum); }

Simon Marlow's avatar
Simon Marlow committed
189 190
static inline void postTimestamp(EventsBuf *eb)
{ postWord64(eb, time_ns()); }
191

192
static inline void postThreadID(EventsBuf *eb, EventThreadID id)
193 194
{ postWord32(eb,id); }

195
static inline void postCapNo(EventsBuf *eb, EventCapNo no)
196 197
{ postWord16(eb,no); }

198 199 200 201 202 203
static inline void postCapsetID(EventsBuf *eb, EventCapsetID id)
{ postWord32(eb,id); }

static inline void postCapsetType(EventsBuf *eb, EventCapsetType type)
{ postWord16(eb,type); }

204 205 206 207 208 209 210 211 212
static inline void postOSProcessId(EventsBuf *eb, pid_t pid)
{ postWord32(eb, pid); }

static inline void postKernelThreadId(EventsBuf *eb, EventKernelThreadId tid)
{ postWord64(eb, tid); }

static inline void postTaskId(EventsBuf *eb, EventTaskId tUniq)
{ postWord64(eb, tUniq); }

213 214 215
static inline void postPayloadSize(EventsBuf *eb, EventPayloadSize size)
{ postWord16(eb,size); }

Simon Marlow's avatar
Simon Marlow committed
216 217 218 219
static inline void postEventHeader(EventsBuf *eb, EventTypeNum type)
{
    postEventTypeNum(eb, type);
    postTimestamp(eb);
220
}
Simon Marlow's avatar
Simon Marlow committed
221

222 223 224 225 226 227
static inline void postInt8(EventsBuf *eb, StgInt8 i)
{ postWord8(eb, (StgWord8)i); }

static inline void postInt32(EventsBuf *eb, StgInt32 i)
{ postWord32(eb, (StgWord32)i); }

228
#define EVENT_SIZE_DYNAMIC (-1)
Simon Marlow's avatar
Simon Marlow committed
229

230 231
static void
initEventLogWriter(void)
Simon Marlow's avatar
Simon Marlow committed
232
{
233 234 235
    if (event_log_writer != NULL &&
            event_log_writer->initEventLogWriter != NULL) {
        event_log_writer->initEventLogWriter();
236
    }
237
}
Simon Marlow's avatar
Simon Marlow committed
238

239 240 241 242 243 244 245 246 247 248
static bool
writeEventLog(void *eventlog, size_t eventlog_size)
{
    if (event_log_writer != NULL &&
            event_log_writer->writeEventLog != NULL) {
        return event_log_writer->writeEventLog(eventlog, eventlog_size);
    } else {
        return false;
    }
}
Simon Marlow's avatar
Simon Marlow committed
249

250 251 252 253 254 255
static void
stopEventLogWriter(void)
{
    if (event_log_writer != NULL &&
            event_log_writer->stopEventLogWriter != NULL) {
        event_log_writer->stopEventLogWriter();
Simon Marlow's avatar
Simon Marlow committed
256
    }
257
}
258

259 260 261 262 263 264
void
flushEventLog(void)
{
    if (event_log_writer != NULL &&
            event_log_writer->flushEventLog != NULL) {
        event_log_writer->flushEventLog();
265
    }
266 267 268 269 270 271 272 273 274
}

void
initEventLogging(const EventLogWriter *ev_writer)
{
    uint32_t n_caps;

    event_log_writer = ev_writer;
    initEventLogWriter();
275

276 277
    if (sizeof(EventDesc) / sizeof(char*) != NUM_GHC_EVENT_TAGS) {
        barf("EventDesc array has the wrong number of elements");
Simon Marlow's avatar
Simon Marlow committed
278 279
    }

280
    /*
Simon Marlow's avatar
Simon Marlow committed
281 282 283 284 285 286
     * Allocate buffer(s) to store events.
     * Create buffer large enough for the header begin marker, all event
     * types, and header end marker to prevent checking if buffer has room
     * for each of these steps, and remove the need to flush the buffer to
     * disk during initialization.
     *
287
     * Use a single buffer to store the header with event types, then flush
Simon Marlow's avatar
Simon Marlow committed
288 289
     * the buffer so all buffers are empty for writing events.
     */
Ben Gamari's avatar
Ben Gamari committed
290
#if defined(THREADED_RTS)
291
    // XXX n_capabilities hasn't been initialized yet
Simon Marlow's avatar
Simon Marlow committed
292
    n_caps = RtsFlags.ParFlags.nCapabilities;
293 294 295
#else
    n_caps = 1;
#endif
296
    moreCapEventBufs(0, n_caps);
297

298
    initEventsBuf(&eventBuf, EVENT_LOG_SIZE, (EventCapNo)(-1));
Simon Marlow's avatar
Simon Marlow committed
299 300

    // Write in buffer: the header begin marker.
Simon Marlow's avatar
Simon Marlow committed
301
    postInt32(&eventBuf, EVENT_HEADER_BEGIN);
Simon Marlow's avatar
Simon Marlow committed
302 303

    // Mark beginning of event types in the header.
Simon Marlow's avatar
Simon Marlow committed
304
    postInt32(&eventBuf, EVENT_HET_BEGIN);
305
    for (int t = 0; t < NUM_GHC_EVENT_TAGS; ++t) {
Simon Marlow's avatar
Simon Marlow committed
306 307 308 309 310 311 312 313

        eventTypes[t].etNum = t;
        eventTypes[t].desc = EventDesc[t];

        switch (t) {
        case EVENT_CREATE_THREAD:   // (cap, thread)
        case EVENT_RUN_THREAD:      // (cap, thread)
        case EVENT_THREAD_RUNNABLE: // (cap, thread)
314
        case EVENT_CREATE_SPARK_THREAD: // (cap, spark_thread)
315
            eventTypes[t].size = sizeof(EventThreadID);
316 317
            break;

Simon Marlow's avatar
Simon Marlow committed
318 319 320
        case EVENT_MIGRATE_THREAD:  // (cap, thread, new_cap)
        case EVENT_THREAD_WAKEUP:   // (cap, thread, other_cap)
            eventTypes[t].size =
321
                sizeof(EventThreadID) + sizeof(EventCapNo);
Simon Marlow's avatar
Simon Marlow committed
322 323 324
            break;

        case EVENT_STOP_THREAD:     // (cap, thread, status)
325 326 327
            eventTypes[t].size = sizeof(EventThreadID)
                               + sizeof(StgWord16)
                               + sizeof(EventThreadID);
Simon Marlow's avatar
Simon Marlow committed
328 329
            break;

330 331 332 333
        case EVENT_CAP_CREATE:      // (cap)
        case EVENT_CAP_DELETE:      // (cap)
        case EVENT_CAP_ENABLE:      // (cap)
        case EVENT_CAP_DISABLE:     // (cap)
334 335 336
            eventTypes[t].size = sizeof(EventCapNo);
            break;

337 338 339 340 341 342 343 344 345 346 347 348 349 350 351
        case EVENT_CAPSET_CREATE:   // (capset, capset_type)
            eventTypes[t].size =
                sizeof(EventCapsetID) + sizeof(EventCapsetType);
            break;

        case EVENT_CAPSET_DELETE:   // (capset)
            eventTypes[t].size = sizeof(EventCapsetID);
            break;

        case EVENT_CAPSET_ASSIGN_CAP:  // (capset, cap)
        case EVENT_CAPSET_REMOVE_CAP:
            eventTypes[t].size =
                sizeof(EventCapsetID) + sizeof(EventCapNo);
            break;

352 353 354 355 356 357
        case EVENT_OSPROCESS_PID:   // (cap, pid)
        case EVENT_OSPROCESS_PPID:
            eventTypes[t].size =
                sizeof(EventCapsetID) + sizeof(StgWord32);
            break;

358 359 360 361 362
        case EVENT_WALL_CLOCK_TIME: // (capset, unix_epoch_seconds, nanoseconds)
            eventTypes[t].size =
                sizeof(EventCapsetID) + sizeof(StgWord64) + sizeof(StgWord32);
            break;

363 364 365 366 367
        case EVENT_SPARK_STEAL:     // (cap, victim_cap)
            eventTypes[t].size =
                sizeof(EventCapNo);
            break;

Simon Marlow's avatar
Simon Marlow committed
368 369 370 371
        case EVENT_REQUEST_SEQ_GC:  // (cap)
        case EVENT_REQUEST_PAR_GC:  // (cap)
        case EVENT_GC_START:        // (cap)
        case EVENT_GC_END:          // (cap)
372 373 374
        case EVENT_GC_IDLE:
        case EVENT_GC_WORK:
        case EVENT_GC_DONE:
375
        case EVENT_GC_GLOBAL_SYNC:  // (cap)
376 377 378 379 380 381
        case EVENT_SPARK_CREATE:    // (cap)
        case EVENT_SPARK_DUD:       // (cap)
        case EVENT_SPARK_OVERFLOW:  // (cap)
        case EVENT_SPARK_RUN:       // (cap)
        case EVENT_SPARK_FIZZLE:    // (cap)
        case EVENT_SPARK_GC:        // (cap)
382
            eventTypes[t].size = 0;
Simon Marlow's avatar
Simon Marlow committed
383
            break;
384 385

        case EVENT_LOG_MSG:          // (msg)
386
        case EVENT_USER_MSG:         // (msg)
387
        case EVENT_USER_MARKER:      // (markername)
388 389 390
        case EVENT_RTS_IDENTIFIER:   // (capset, str)
        case EVENT_PROGRAM_ARGS:     // (capset, strvec)
        case EVENT_PROGRAM_ENV:      // (capset, strvec)
391
        case EVENT_THREAD_LABEL:     // (thread, str)
392 393 394
            eventTypes[t].size = 0xffff;
            break;

Duncan Coutts's avatar
Duncan Coutts committed
395 396 397 398
        case EVENT_SPARK_COUNTERS:   // (cap, 7*counter)
            eventTypes[t].size = 7 * sizeof(StgWord64);
            break;

399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415
        case EVENT_HEAP_ALLOCATED:    // (heap_capset, alloc_bytes)
        case EVENT_HEAP_SIZE:         // (heap_capset, size_bytes)
        case EVENT_HEAP_LIVE:         // (heap_capset, live_bytes)
            eventTypes[t].size = sizeof(EventCapsetID) + sizeof(StgWord64);
            break;

        case EVENT_HEAP_INFO_GHC:     // (heap_capset, n_generations,
                                      //  max_heap_size, alloc_area_size,
                                      //  mblock_size, block_size)
            eventTypes[t].size = sizeof(EventCapsetID)
                               + sizeof(StgWord16)
                               + sizeof(StgWord64) * 4;
            break;

        case EVENT_GC_STATS_GHC:      // (heap_capset, generation,
                                      //  copied_bytes, slop_bytes, frag_bytes,
                                      //  par_n_threads,
416 417 418
                                      //  par_max_copied, par_tot_copied,
                                      //  par_balanced_copied
                                      //  )
419 420 421 422
            eventTypes[t].size = sizeof(EventCapsetID)
                               + sizeof(StgWord16)
                               + sizeof(StgWord64) * 3
                               + sizeof(StgWord32)
423
                               + sizeof(StgWord64) * 3;
424 425
            break;

426
        case EVENT_TASK_CREATE:   // (taskId, cap, tid)
427 428 429
            eventTypes[t].size = sizeof(EventTaskId)
                               + sizeof(EventCapNo)
                               + sizeof(EventKernelThreadId);
430 431 432 433 434 435 436 437 438 439 440
            break;

        case EVENT_TASK_MIGRATE:   // (taskId, cap, new_cap)
            eventTypes[t].size =
                sizeof(EventTaskId) + sizeof(EventCapNo) + sizeof(EventCapNo);
            break;

        case EVENT_TASK_DELETE:   // (taskId)
            eventTypes[t].size = sizeof(EventTaskId);
            break;

Simon Marlow's avatar
Simon Marlow committed
441
        case EVENT_BLOCK_MARKER:
442
            eventTypes[t].size = sizeof(StgWord32) + sizeof(EventTimestamp) +
443
                sizeof(EventCapNo);
Simon Marlow's avatar
Simon Marlow committed
444 445
            break;

446 447 448 449
        case EVENT_HACK_BUG_T9003:
            eventTypes[t].size = 0;
            break;

450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469
        case EVENT_HEAP_PROF_BEGIN:
            eventTypes[t].size = EVENT_SIZE_DYNAMIC;
            break;

        case EVENT_HEAP_PROF_COST_CENTRE:
            eventTypes[t].size = EVENT_SIZE_DYNAMIC;
            break;

        case EVENT_HEAP_PROF_SAMPLE_BEGIN:
            eventTypes[t].size = 8;
            break;

        case EVENT_HEAP_PROF_SAMPLE_STRING:
            eventTypes[t].size = EVENT_SIZE_DYNAMIC;
            break;

        case EVENT_HEAP_PROF_SAMPLE_COST_CENTRE:
            eventTypes[t].size = EVENT_SIZE_DYNAMIC;
            break;

Mitsutoshi Aoe's avatar
Mitsutoshi Aoe committed
470 471 472 473
        case EVENT_USER_BINARY_MSG:
            eventTypes[t].size = EVENT_SIZE_DYNAMIC;
            break;

474 475
        default:
            continue; /* ignore deprecated events */
Simon Marlow's avatar
Simon Marlow committed
476 477 478
        }

        // Write in buffer: the start event type.
479
        postEventType(&eventBuf, &eventTypes[t]);
Simon Marlow's avatar
Simon Marlow committed
480 481 482
    }

    // Mark end of event types in the header.
Simon Marlow's avatar
Simon Marlow committed
483
    postInt32(&eventBuf, EVENT_HET_END);
484

Simon Marlow's avatar
Simon Marlow committed
485
    // Write in buffer: the header end marker.
Simon Marlow's avatar
Simon Marlow committed
486
    postInt32(&eventBuf, EVENT_HEADER_END);
487

Simon Marlow's avatar
Simon Marlow committed
488
    // Prepare event buffer for events (data).
Simon Marlow's avatar
Simon Marlow committed
489
    postInt32(&eventBuf, EVENT_DATA_BEGIN);
490

491
    // Flush capEventBuf with header.
Simon Marlow's avatar
Simon Marlow committed
492 493 494 495
    /*
     * Flush header and data begin marker to the file, thus preparing the
     * file to have events written to it.
     */
496
    printAndClearEventBuf(&eventBuf);
Simon Marlow's avatar
Simon Marlow committed
497

498
    for (uint32_t c = 0; c < n_caps; ++c) {
Simon Marlow's avatar
Simon Marlow committed
499 500
        postBlockMarker(&capEventBuf[c]);
    }
501

Ben Gamari's avatar
Ben Gamari committed
502
#if defined(THREADED_RTS)
503 504
    initMutex(&eventBufMutex);
#endif
Simon Marlow's avatar
Simon Marlow committed
505 506 507 508 509 510
}

void
endEventLogging(void)
{
    // Flush all events remaining in the buffers.
511
    for (uint32_t c = 0; c < n_capabilities; ++c) {
512
        printAndClearEventBuf(&capEventBuf[c]);
Simon Marlow's avatar
Simon Marlow committed
513
    }
514
    printAndClearEventBuf(&eventBuf);
515
    resetEventsBuf(&eventBuf); // we don't want the block marker
Simon Marlow's avatar
Simon Marlow committed
516 517

    // Mark end of events (data).
Simon Marlow's avatar
Simon Marlow committed
518
    postEventTypeNum(&eventBuf, EVENT_DATA_END);
Simon Marlow's avatar
Simon Marlow committed
519 520

    // Flush the end of data marker.
521
    printAndClearEventBuf(&eventBuf);
Simon Marlow's avatar
Simon Marlow committed
522

523
    stopEventLogWriter();
Simon Marlow's avatar
Simon Marlow committed
524 525
}

526
void
527
moreCapEventBufs (uint32_t from, uint32_t to)
528 529 530 531 532 533 534 535 536
{
    if (from > 0) {
        capEventBuf = stgReallocBytes(capEventBuf, to * sizeof(EventsBuf),
                                      "moreCapEventBufs");
    } else {
        capEventBuf = stgMallocBytes(to * sizeof(EventsBuf),
                                     "moreCapEventBufs");
    }

537
    for (uint32_t c = from; c < to; ++c) {
538 539
        initEventsBuf(&capEventBuf[c], EVENT_LOG_SIZE, c);
    }
540 541 542 543

    // The from == 0 already covered in initEventLogging, so we are interested
    // only in case when we are increasing capabilities number
    if (from > 0) {
544
        for (uint32_t c = from; c < to; ++c) {
545 546 547
           postBlockMarker(&capEventBuf[c]);
        }
    }
548 549 550 551
}


void
Simon Marlow's avatar
Simon Marlow committed
552 553 554
freeEventLogging(void)
{
    // Free events buffer.
555
    for (uint32_t c = 0; c < n_capabilities; ++c) {
556
        if (capEventBuf[c].begin != NULL)
557
            stgFree(capEventBuf[c].begin);
Simon Marlow's avatar
Simon Marlow committed
558
    }
559 560
    if (capEventBuf != NULL)  {
        stgFree(capEventBuf);
Simon Marlow's avatar
Simon Marlow committed
561
    }
562 563
}

564
void
565 566 567
abortEventLogging(void)
{
    freeEventLogging();
568
    stopEventLogWriter();
569
}
570

Simon Marlow's avatar
Simon Marlow committed
571 572 573 574 575
/*
 * Post an event message to the capability's eventlog buffer.
 * If the buffer is full, prints out the buffer and clears it.
 */
void
576 577 578
postSchedEvent (Capability *cap,
                EventTypeNum tag,
                StgThreadID thread,
579 580
                StgWord info1,
                StgWord info2)
Simon Marlow's avatar
Simon Marlow committed
581
{
582
    EventsBuf *eb = &capEventBuf[cap->no];
583
    ensureRoomForEvent(eb, tag);
584

Simon Marlow's avatar
Simon Marlow committed
585
    postEventHeader(eb, tag);
Simon Marlow's avatar
Simon Marlow committed
586 587 588 589 590 591

    switch (tag) {
    case EVENT_CREATE_THREAD:   // (cap, thread)
    case EVENT_RUN_THREAD:      // (cap, thread)
    case EVENT_THREAD_RUNNABLE: // (cap, thread)
    {
592
        postThreadID(eb,thread);
Simon Marlow's avatar
Simon Marlow committed
593 594 595
        break;
    }

596
    case EVENT_CREATE_SPARK_THREAD: // (cap, spark_thread)
597
    {
598
        postThreadID(eb,info1 /* spark_thread */);
599 600 601
        break;
    }

Simon Marlow's avatar
Simon Marlow committed
602 603 604
    case EVENT_MIGRATE_THREAD:  // (cap, thread, new_cap)
    case EVENT_THREAD_WAKEUP:   // (cap, thread, other_cap)
    {
605
        postThreadID(eb,thread);
606
        postCapNo(eb,info1 /* new_cap | victim_cap | other_cap */);
Simon Marlow's avatar
Simon Marlow committed
607
        break;
608
   }
Simon Marlow's avatar
Simon Marlow committed
609 610 611

    case EVENT_STOP_THREAD:     // (cap, thread, status)
    {
612
        postThreadID(eb,thread);
613 614
        postWord16(eb,info1 /* status */);
        postThreadID(eb,info2 /* blocked on thread */);
Simon Marlow's avatar
Simon Marlow committed
615 616 617 618
        break;
    }

    default:
619
        barf("postSchedEvent: unknown event tag %d", tag);
Simon Marlow's avatar
Simon Marlow committed
620
    }
621 622
}

623 624 625 626 627
void
postSparkEvent (Capability *cap,
                EventTypeNum tag,
                StgWord info1)
{
628
    EventsBuf *eb = &capEventBuf[cap->no];
629
    ensureRoomForEvent(eb, tag);
630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660

    postEventHeader(eb, tag);

    switch (tag) {
    case EVENT_CREATE_SPARK_THREAD: // (cap, spark_thread)
    {
        postThreadID(eb,info1 /* spark_thread */);
        break;
    }

    case EVENT_SPARK_STEAL:         // (cap, victim_cap)
    {
        postCapNo(eb,info1 /* victim_cap */);
        break;
   }

    case EVENT_SPARK_CREATE:        // (cap)
    case EVENT_SPARK_DUD:           // (cap)
    case EVENT_SPARK_OVERFLOW:      // (cap)
    case EVENT_SPARK_RUN:           // (cap)
    case EVENT_SPARK_FIZZLE:        // (cap)
    case EVENT_SPARK_GC:            // (cap)
    {
        break;
    }

    default:
        barf("postSparkEvent: unknown event tag %d", tag);
    }
}

Duncan Coutts's avatar
Duncan Coutts committed
661
void
662
postSparkCountersEvent (Capability *cap,
Duncan Coutts's avatar
Duncan Coutts committed
663 664 665
                        SparkCounters counters,
                        StgWord remaining)
{
666
    EventsBuf *eb = &capEventBuf[cap->no];
667
    ensureRoomForEvent(eb, EVENT_SPARK_COUNTERS);
668

Duncan Coutts's avatar
Duncan Coutts committed
669
    postEventHeader(eb, EVENT_SPARK_COUNTERS);
670
    /* EVENT_SPARK_COUNTERS (crt,dud,ovf,cnv,gcd,fiz,rem) */
Duncan Coutts's avatar
Duncan Coutts committed
671 672 673 674 675 676 677 678 679
    postWord64(eb,counters.created);
    postWord64(eb,counters.dud);
    postWord64(eb,counters.overflowed);
    postWord64(eb,counters.converted);
    postWord64(eb,counters.gcd);
    postWord64(eb,counters.fizzled);
    postWord64(eb,remaining);
}

680 681 682 683 684
void
postCapEvent (EventTypeNum  tag,
              EventCapNo    capno)
{
    ACQUIRE_LOCK(&eventBufMutex);
685
    ensureRoomForEvent(&eventBuf, tag);
686

687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705
    postEventHeader(&eventBuf, tag);

    switch (tag) {
    case EVENT_CAP_CREATE:   // (cap)
    case EVENT_CAP_DELETE:   // (cap)
    case EVENT_CAP_ENABLE:   // (cap)
    case EVENT_CAP_DISABLE:  // (cap)
    {
        postCapNo(&eventBuf,capno);
        break;
    }

    default:
        barf("postCapEvent: unknown event tag %d", tag);
    }

    RELEASE_LOCK(&eventBufMutex);
}

706 707 708
void postCapsetEvent (EventTypeNum tag,
                      EventCapsetID capset,
                      StgWord info)
709 710
{
    ACQUIRE_LOCK(&eventBufMutex);
711
    ensureRoomForEvent(&eventBuf, tag);
712 713 714 715 716 717 718

    postEventHeader(&eventBuf, tag);
    postCapsetID(&eventBuf, capset);

    switch (tag) {
    case EVENT_CAPSET_CREATE:   // (capset, capset_type)
    {
719
        postCapsetType(&eventBuf, info /* capset_type */);
720 721 722 723 724 725 726 727 728 729 730
        break;
    }

    case EVENT_CAPSET_DELETE:   // (capset)
    {
        break;
    }

    case EVENT_CAPSET_ASSIGN_CAP:  // (capset, capno)
    case EVENT_CAPSET_REMOVE_CAP:  // (capset, capno)
    {
731
        postCapNo(&eventBuf, info /* capno */);
732 733
        break;
    }
734 735 736
    case EVENT_OSPROCESS_PID:   // (capset, pid)
    case EVENT_OSPROCESS_PPID:  // (capset, parent_pid)
    {
737
        postOSProcessId(&eventBuf, info);
738 739
        break;
    }
740
    default:
741
        barf("postCapsetEvent: unknown event tag %d", tag);
742 743 744 745 746
    }

    RELEASE_LOCK(&eventBufMutex);
}

747 748 749 750 751
void postCapsetStrEvent (EventTypeNum tag,
                         EventCapsetID capset,
                         char *msg)
{
    int strsize = strlen(msg);
752
    int size = strsize + sizeof(EventCapsetID);
Mitsutoshi Aoe's avatar
Mitsutoshi Aoe committed
753 754 755 756
    if (size > EVENT_PAYLOAD_SIZE_MAX) {
        errorBelch("Event size exceeds EVENT_PAYLOAD_SIZE_MAX, bail out");
        return;
    }
757 758 759 760 761 762 763

    ACQUIRE_LOCK(&eventBufMutex);

    if (!hasRoomForVariableEvent(&eventBuf, size)){
        printAndClearEventBuf(&eventBuf);

        if (!hasRoomForVariableEvent(&eventBuf, size)){
Mitsutoshi Aoe's avatar
Mitsutoshi Aoe committed
764
            errorBelch("Event size exceeds buffer size, bail out");
765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783
            RELEASE_LOCK(&eventBufMutex);
            return;
        }
    }

    postEventHeader(&eventBuf, tag);
    postPayloadSize(&eventBuf, size);
    postCapsetID(&eventBuf, capset);

    postBuf(&eventBuf, (StgWord8*) msg, strsize);

    RELEASE_LOCK(&eventBufMutex);
}

void postCapsetVecEvent (EventTypeNum tag,
                         EventCapsetID capset,
                         int argc,
                         char *argv[])
{
784
    int size = sizeof(EventCapsetID);
785

786
    for (int i = 0; i < argc; i++) {
787 788 789 790 791 792 793 794 795 796
        // 1 + strlen to account for the trailing \0, used as separator
        size += 1 + strlen(argv[i]);
    }

    ACQUIRE_LOCK(&eventBufMutex);

    if (!hasRoomForVariableEvent(&eventBuf, size)){
        printAndClearEventBuf(&eventBuf);

        if(!hasRoomForVariableEvent(&eventBuf, size)){
Mitsutoshi Aoe's avatar
Mitsutoshi Aoe committed
797
            errorBelch("Event size exceeds buffer size, bail out");
798 799 800 801 802 803 804 805 806
            RELEASE_LOCK(&eventBufMutex);
            return;
        }
    }

    postEventHeader(&eventBuf, tag);
    postPayloadSize(&eventBuf, size);
    postCapsetID(&eventBuf, capset);

807
    for (int i = 0; i < argc; i++) {
808 809 810 811 812 813 814
        // again, 1 + to account for \0
        postBuf(&eventBuf, (StgWord8*) argv[i], 1 + strlen(argv[i]));
    }

    RELEASE_LOCK(&eventBufMutex);
}

815 816 817 818 819 820 821
void postWallClockTime (EventCapsetID capset)
{
    StgWord64 ts;
    StgWord64 sec;
    StgWord32 nsec;

    ACQUIRE_LOCK(&eventBufMutex);
822

823 824 825 826 827 828 829 830 831 832 833 834 835 836 837
    /* The EVENT_WALL_CLOCK_TIME event is intended to allow programs
       reading the eventlog to match up the event timestamps with wall
       clock time. The normal event timestamps measure time since the
       start of the program. To align eventlogs from concurrent
       processes we need to be able to match up the timestamps. One way
       to do this is if we know how the timestamps and wall clock time
       match up (and of course if both processes have sufficiently
       synchronised clocks).

       So we want to make sure that the timestamp that we generate for
       this event matches up very closely with the wall clock time.
       Unfortunately we currently have to use two different APIs to get
       the elapsed time vs the wall clock time. So to minimise the
       difference we just call them very close together.
     */
838

839 840
    getUnixEpochTime(&sec, &nsec);  /* Get the wall clock time */
    ts = time_ns();                 /* Get the eventlog timestamp */
841
    ensureRoomForEvent(&eventBuf, EVENT_WALL_CLOCK_TIME);
842 843 844 845 846 847

    /* Normally we'd call postEventHeader(), but that generates its own
       timestamp, so we go one level lower so we can write out the
       timestamp we already generated above. */
    postEventTypeNum(&eventBuf, EVENT_WALL_CLOCK_TIME);
    postWord64(&eventBuf, ts);
848

849 850 851 852 853 854 855 856
    /* EVENT_WALL_CLOCK_TIME (capset, unix_epoch_seconds, nanoseconds) */
    postCapsetID(&eventBuf, capset);
    postWord64(&eventBuf, sec);
    postWord32(&eventBuf, nsec);

    RELEASE_LOCK(&eventBufMutex);
}

857 858 859 860 861 862
/*
 * Various GC and heap events
 */
void postHeapEvent (Capability    *cap,
                    EventTypeNum   tag,
                    EventCapsetID  heap_capset,
863
                    W_           info1)
864
{
865
    EventsBuf *eb = &capEventBuf[cap->no];
866
    ensureRoomForEvent(eb, tag);
867

868 869 870 871 872 873 874 875
    postEventHeader(eb, tag);

    switch (tag) {
    case EVENT_HEAP_ALLOCATED:     // (heap_capset, alloc_bytes)
    case EVENT_HEAP_SIZE:          // (heap_capset, size_bytes)
    case EVENT_HEAP_LIVE:          // (heap_capset, live_bytes)
    {
        postCapsetID(eb, heap_capset);
876
        postWord64(eb, info1 /* alloc/size/live_bytes */);
877 878 879 880 881 882 883 884 885
        break;
    }

    default:
        barf("postHeapEvent: unknown event tag %d", tag);
    }
}

void postEventHeapInfo (EventCapsetID heap_capset,
886
                        uint32_t    gens,
887 888 889 890
                        W_          maxHeapSize,
                        W_          allocAreaSize,
                        W_          mblockSize,
                        W_          blockSize)
891 892
{
    ACQUIRE_LOCK(&eventBufMutex);
893
    ensureRoomForEvent(&eventBuf, EVENT_HEAP_INFO_GHC);
894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910

    postEventHeader(&eventBuf, EVENT_HEAP_INFO_GHC);
    /* EVENT_HEAP_INFO_GHC (heap_capset, n_generations,
                            max_heap_size, alloc_area_size,
                            mblock_size, block_size) */
    postCapsetID(&eventBuf, heap_capset);
    postWord16(&eventBuf, gens);
    postWord64(&eventBuf, maxHeapSize);
    postWord64(&eventBuf, allocAreaSize);
    postWord64(&eventBuf, mblockSize);
    postWord64(&eventBuf, blockSize);

    RELEASE_LOCK(&eventBufMutex);
}

void postEventGcStats  (Capability    *cap,
                        EventCapsetID  heap_capset,
911
                        uint32_t     gen,
912 913 914
                        W_           copied,
                        W_           slop,
                        W_           fragmentation,
915
                        uint32_t     par_n_threads,
916
                        W_           par_max_copied,
917 918
                        W_           par_tot_copied,
                        W_           par_balanced_copied)
919
{
920
    EventsBuf *eb = &capEventBuf[cap->no];
921
    ensureRoomForEvent(eb, EVENT_GC_STATS_GHC);
922

923 924 925
    postEventHeader(eb, EVENT_GC_STATS_GHC);
    /* EVENT_GC_STATS_GHC (heap_capset, generation,
                           copied_bytes, slop_bytes, frag_bytes,
926 927
                           par_n_threads, par_max_copied,
                           par_tot_copied, par_balanced_copied) */
928 929 930 931 932 933 934 935
    postCapsetID(eb, heap_capset);
    postWord16(eb, gen);
    postWord64(eb, copied);
    postWord64(eb, slop);
    postWord64(eb, fragmentation);
    postWord32(eb, par_n_threads);
    postWord64(eb, par_max_copied);
    postWord64(eb, par_tot_copied);
936
    postWord64(eb, par_balanced_copied);
937 938
}

939 940 941 942 943
void postTaskCreateEvent (EventTaskId taskId,
                          EventCapNo capno,
                          EventKernelThreadId tid)
{
    ACQUIRE_LOCK(&eventBufMutex);
944
    ensureRoomForEvent(&eventBuf, EVENT_TASK_CREATE);
945 946 947 948 949 950 951 952 953 954 955 956 957 958 959

    postEventHeader(&eventBuf, EVENT_TASK_CREATE);
    /* EVENT_TASK_CREATE (taskID, cap, tid) */
    postTaskId(&eventBuf, taskId);
    postCapNo(&eventBuf, capno);
    postKernelThreadId(&eventBuf, tid);

    RELEASE_LOCK(&eventBufMutex);
}

void postTaskMigrateEvent (EventTaskId taskId,
                           EventCapNo capno,
                           EventCapNo new_capno)
{
    ACQUIRE_LOCK(&eventBufMutex);
960
    ensureRoomForEvent(&eventBuf, EVENT_TASK_MIGRATE);
961 962 963 964 965 966 967 968 969 970 971 972 973

    postEventHeader(&eventBuf, EVENT_TASK_MIGRATE);
    /* EVENT_TASK_MIGRATE (taskID, cap, new_cap) */
    postTaskId(&eventBuf, taskId);
    postCapNo(&eventBuf, capno);
    postCapNo(&eventBuf, new_capno);

    RELEASE_LOCK(&eventBufMutex);
}

void postTaskDeleteEvent (EventTaskId taskId)
{
    ACQUIRE_LOCK(&eventBufMutex);
974
    ensureRoomForEvent(&eventBuf, EVENT_TASK_DELETE);
975 976 977 978 979 980 981 982

    postEventHeader(&eventBuf, EVENT_TASK_DELETE);
    /* EVENT_TASK_DELETE (taskID) */
    postTaskId(&eventBuf, taskId);

    RELEASE_LOCK(&eventBufMutex);
}

983 984 985
void
postEvent (Capability *cap, EventTypeNum tag)
{
986
    EventsBuf *eb = &capEventBuf[cap->no];
987
    ensureRoomForEvent(eb, tag);
988 989 990
    postEventHeader(eb, tag);
}

991 992 993
void
postEventAtTimestamp (Capability *cap, EventTimestamp ts, EventTypeNum tag)
{
994
    EventsBuf *eb = &capEventBuf[cap->no];
995
    ensureRoomForEvent(eb, tag);
996 997 998 999 1000 1001 1002 1003

    /* Normally we'd call postEventHeader(), but that generates its own
       timestamp, so we go one level lower so we can write out
       the timestamp we received as an argument. */
    postEventTypeNum(eb, tag);
    postWord64(eb, ts);
}

1004 1005
#define BUF 512

1006
void postLogMsg(EventsBuf *eb, EventTypeNum type, char *msg, va_list ap)
1007 1008
{
    char buf[BUF];
1009
    uint32_t size = vsnprintf(buf, BUF, msg,ap);
1010 1011 1012 1013 1014
    if (size > BUF) {
        buf[BUF-1] = '\0';
        size = BUF;
    }

1015
    ensureRoomForVariableEvent(eb, size);
1016

1017
    postEventHeader(eb, type);
1018 1019
    postPayloadSize(eb, size);
    postBuf(eb,(StgWord8*)buf,size);
1020
}
1021

1022 1023 1024
void postMsg(char *msg, va_list ap)
{
    ACQUIRE_LOCK(&eventBufMutex);
1025
    postLogMsg(&eventBuf, EVENT_LOG_MSG, msg, ap);
1026 1027 1028 1029 1030
    RELEASE_LOCK(&eventBufMutex);
}

void postCapMsg(Capability *cap, char *msg, va_list ap)
{
1031
    postLogMsg(&capEventBuf[cap->no], EVENT_LOG_MSG, msg, ap);
Simon Marlow's avatar
Simon Marlow committed
1032 1033
}

1034
void postUserEvent(Capability *cap, EventTypeNum type, char *msg)
1035
{
Mitsutoshi Aoe's avatar
Mitsutoshi Aoe committed
1036 1037 1038 1039 1040 1041
    const size_t size = strlen(msg);
    if (size > EVENT_PAYLOAD_SIZE_MAX) {
        errorBelch("Event size exceeds EVENT_PAYLOAD_SIZE_MAX, bail out");
        return;
    }

1042
    EventsBuf *eb = &capEventBuf[cap->no];
Mitsutoshi Aoe's avatar
Mitsutoshi Aoe committed
1043 1044 1045 1046 1047 1048 1049 1050
    if (!hasRoomForVariableEvent(eb, size)){
        printAndClearEventBuf(eb);

        if (!hasRoomForVariableEvent(eb, size)){
            errorBelch("Event size exceeds buffer size, bail out");
            return;
        }
    }
1051

Mitsutoshi Aoe's avatar
Mitsutoshi Aoe committed
1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067
    postEventHeader(eb, type);
    postPayloadSize(eb, size);
    postBuf(eb, (StgWord8*) msg, size);
}

void postUserBinaryEvent(Capability   *cap,
                         EventTypeNum  type,
                         uint8_t      *msg,
                         size_t        size)
{
    if (size > EVENT_PAYLOAD_SIZE_MAX) {
        errorBelch("Event size exceeds EVENT_PAYLOAD_SIZE_MAX, bail out");
        return;
    }

    EventsBuf *eb = &capEventBuf[cap->no];
1068 1069 1070 1071
    if (!hasRoomForVariableEvent(eb, size)){
        printAndClearEventBuf(eb);

        if (!hasRoomForVariableEvent(eb, size)){
Mitsutoshi Aoe's avatar
Mitsutoshi Aoe committed
1072
            errorBelch("Event size exceeds buffer size, bail out");
1073 1074 1075 1076
            return;
        }
    }

1077
    postEventHeader(eb, type);
1078
    postPayloadSize(eb, size);
1079
    postBuf(eb, (StgWord8*) msg, size);
1080 1081
}

1082 1083 1084 1085
void postThreadLabel(Capability    *cap,
                     EventThreadID  id,
                     char          *label)
{
1086 1087
    const int strsize = strlen(label);
    const int size = strsize + sizeof(EventThreadID);
Mitsutoshi Aoe's avatar
Mitsutoshi Aoe committed
1088 1089 1090 1091
    if (size > EVENT_PAYLOAD_SIZE_MAX) {
        errorBelch("Event size exceeds EVENT_PAYLOAD_SIZE_MAX, bail out");
        return;
    }
1092

Mitsutoshi Aoe's avatar
Mitsutoshi Aoe committed
1093
    EventsBuf *eb = &capEventBuf[cap->no];
1094 1095 1096 1097
    if (!hasRoomForVariableEvent(eb, size)){
        printAndClearEventBuf(eb);

        if (!hasRoomForVariableEvent(eb, size)){
Mitsutoshi Aoe's avatar
Mitsutoshi Aoe committed
1098
            errorBelch("Event size exceeds buffer size, bail out");
1099 1100 1101 1102 1103 1104 1105 1106 1107 1108
            return;
        }
    }

    postEventHeader(eb, EVENT_THREAD_LABEL);
    postPayloadSize(eb, size);
    postThreadID(eb, id);
    postBuf(eb, (StgWord8*) label, strsize);
}

Simon Marlow's avatar
Simon Marlow committed
1109 1110