diff options
author | Simon Marlow <marlowsd@gmail.com> | 2009-09-25 15:02:43 +0000 |
---|---|---|
committer | Simon Marlow <marlowsd@gmail.com> | 2009-09-25 15:02:43 +0000 |
commit | 5407ad8e0a5c08ac5193c1a9ede2a12570baee0b (patch) | |
tree | 0676ae90bb68e88ad42fd05a0c0282cd48c8b140 /rts/eventlog | |
parent | e43a5e498520b933a0d9f4c7e9ddfb7ed2032cfd (diff) | |
download | haskell-5407ad8e0a5c08ac5193c1a9ede2a12570baee0b.tar.gz |
Add a way to generate tracing events programmatically
added:
primop TraceEventOp "traceEvent#" GenPrimOp
Addr# -> State# s -> State# s
{ Emits an event via the RTS tracing framework. The contents
of the event is the zero-terminated byte string passed as the first
argument. The event will be emitted either to the .eventlog file,
or to stderr, depending on the runtime RTS flags. }
and added the required RTS functionality to support it. Also a bit of
refactoring in the RTS tracing code.
Diffstat (limited to 'rts/eventlog')
-rw-r--r-- | rts/eventlog/EventLog.c | 17 | ||||
-rw-r--r-- | rts/eventlog/EventLog.h | 2 |
2 files changed, 14 insertions, 5 deletions
diff --git a/rts/eventlog/EventLog.c b/rts/eventlog/EventLog.c index e5e71e65c8..65eff8a012 100644 --- a/rts/eventlog/EventLog.c +++ b/rts/eventlog/EventLog.c @@ -62,6 +62,7 @@ char *EventDesc[] = { [EVENT_REQUEST_PAR_GC] = "Request parallel GC", [EVENT_CREATE_SPARK_THREAD] = "Create spark thread", [EVENT_LOG_MSG] = "Log message", + [EVENT_USER_MSG] = "User message", [EVENT_STARTUP] = "Startup", [EVENT_BLOCK_MARKER] = "Block marker" }; @@ -82,7 +83,7 @@ static void printAndClearEventBuf (EventsBuf *eventsBuf); static void postEventType(EventsBuf *eb, EventType *et); -static void postLogMsg(EventsBuf *eb, char *msg, va_list ap); +static void postLogMsg(EventsBuf *eb, EventTypeNum type, char *msg, va_list ap); static void postBlockMarker(EventsBuf *eb); static void closeBlockMarker(EventsBuf *ebuf); @@ -242,6 +243,7 @@ initEventLogging(void) break; case EVENT_LOG_MSG: // (msg) + case EVENT_USER_MSG: // (msg) eventTypes[t].size = 0xffff; break; @@ -393,7 +395,7 @@ postSchedEvent (Capability *cap, #define BUF 512 -void postLogMsg(EventsBuf *eb, char *msg, va_list ap) +void postLogMsg(EventsBuf *eb, EventTypeNum type, char *msg, va_list ap) { char buf[BUF]; nat size; @@ -409,7 +411,7 @@ void postLogMsg(EventsBuf *eb, char *msg, va_list ap) printAndClearEventBuf(eb); } - postEventHeader(eb, EVENT_LOG_MSG); + postEventHeader(eb, type); postPayloadSize(eb, size); postBuf(eb,(StgWord8*)buf,size); } @@ -417,15 +419,20 @@ void postLogMsg(EventsBuf *eb, char *msg, va_list ap) void postMsg(char *msg, va_list ap) { ACQUIRE_LOCK(&eventBufMutex); - postLogMsg(&eventBuf, msg, ap); + postLogMsg(&eventBuf, EVENT_LOG_MSG, msg, ap); RELEASE_LOCK(&eventBufMutex); } void postCapMsg(Capability *cap, char *msg, va_list ap) { - postLogMsg(&capEventBuf[cap->no], msg, ap); + postLogMsg(&capEventBuf[cap->no], EVENT_LOG_MSG, msg, ap); } +void postUserMsg(Capability *cap, char *msg) +{ + postLogMsg(&capEventBuf[cap->no], EVENT_USER_MSG, msg, NULL); +} + void closeBlockMarker (EventsBuf *ebuf) { StgInt8* save_pos; diff --git a/rts/eventlog/EventLog.h b/rts/eventlog/EventLog.h index 364d12a3a6..557ee775dd 100644 --- a/rts/eventlog/EventLog.h +++ b/rts/eventlog/EventLog.h @@ -33,6 +33,8 @@ void postSchedEvent(Capability *cap, EventTypeNum tag, void postMsg(char *msg, va_list ap); +void postUserMsg(Capability *cap, char *msg); + void postCapMsg(Capability *cap, char *msg, va_list ap); #else /* !TRACING */ |