X-Git-Url: http://git.megacz.com/?a=blobdiff_plain;f=rts%2Feventlog%2FEventLog.c;h=bd887afa8ea84500b696d6f81ac3799daf20cca5;hb=b0758d03f1a00ab0adf57f8157602ef22e8cdd13;hp=990820fd925d222d20074c278dd042cc30d9a466;hpb=b97043f3f4ba6d24c5c8216414801b307463ee49;p=ghc-hetmet.git diff --git a/rts/eventlog/EventLog.c b/rts/eventlog/EventLog.c index 990820f..bd887af 100644 --- a/rts/eventlog/EventLog.c +++ b/rts/eventlog/EventLog.c @@ -8,12 +8,15 @@ #ifdef EVENTLOG +#include "PosixSource.h" #include "Rts.h" + #include "EventLog.h" #include "Capability.h" #include "Trace.h" #include "RtsUtils.h" #include "Stats.h" + #include #include @@ -36,21 +39,22 @@ typedef struct _EventsBuf { EventsBuf *eventsBuf; char *EventDesc[] = { - "Create thread", - "Run thread", - "Stop thread", - "Thread runnable", - "Migrate thread", - "Run spark", - "Steal spark", - "Shutdown", - "Wakeup thread", - "Starting GC", - "Finished GC", - "Request sequential GC", - "Request parallel GC", - "Create spark", - "Spark to thread" + [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_RUN_SPARK] = "Run spark", + [EVENT_STEAL_SPARK] = "Steal spark", + [EVENT_SHUTDOWN] = "Shutdown", + [EVENT_THREAD_WAKEUP] = "Wakeup thread", + [EVENT_GC_START] = "Starting GC", + [EVENT_GC_END] = "Finished GC", + [EVENT_REQUEST_SEQ_GC] = "Request sequential GC", + [EVENT_REQUEST_PAR_GC] = "Request parallel GC", + [EVENT_CREATE_SPARK] = "Create spark", + [EVENT_SPARK_TO_THREAD] = "Spark to thread", /* DEPRECATED! */ + [EVENT_CREATE_SPARK_THREAD] = "Create spark thread" }; // Event type. @@ -106,13 +110,13 @@ static inline void postWord64(EventsBuf *eb, StgWord64 i) static inline void postEventTypeNum(EventsBuf *eb, EventTypeNum etNum) { postWord16(eb, etNum); } -static inline void postTimestamp(EventsBuf *eb, Timestamp t) +static inline void postTimestamp(EventsBuf *eb, EventTimestamp t) { postWord64(eb,t); } -static inline void postThreadID(EventsBuf *eb, ThreadID id) +static inline void postThreadID(EventsBuf *eb, EventThreadID id) { postWord32(eb,id); } -static inline void postCapNo(EventsBuf *eb, CapNo no) +static inline void postCapNo(EventsBuf *eb, EventCapNo no) { postWord16(eb,no); } static inline void postInt8(EventsBuf *eb, StgInt8 i) @@ -135,7 +139,7 @@ initEventLogging(void) debugTrace(DEBUG_eventlog, "intiEventLog: start"); - event_log_filename = stgMallocBytes(strlen(prog_name) + 9, + event_log_filename = stgMallocBytes(strlen(prog_name) + 10, "initEventLogging"); if (sizeof(EventDesc) / sizeof(char*) != NUM_EVENT_TAGS) { @@ -183,24 +187,20 @@ initEventLogging(void) case EVENT_THREAD_RUNNABLE: // (cap, thread) case EVENT_CREATE_SPARK: // (cap, thread) case EVENT_RUN_SPARK: // (cap, thread) - eventTypes[t].size = sizeof(CapNo) + sizeof(ThreadID); - break; - - case EVENT_SPARK_TO_THREAD: // (cap, thread, spark_thread) - eventTypes[t].size = - sizeof(CapNo) + sizeof(ThreadID) + sizeof(ThreadID); + case EVENT_CREATE_SPARK_THREAD: // (cap, spark_thread) + eventTypes[t].size = sizeof(EventCapNo) + sizeof(EventThreadID); break; case EVENT_MIGRATE_THREAD: // (cap, thread, new_cap) case EVENT_STEAL_SPARK: // (cap, thread, victim_cap) case EVENT_THREAD_WAKEUP: // (cap, thread, other_cap) eventTypes[t].size = - sizeof(CapNo) + sizeof(ThreadID) + sizeof(CapNo); + sizeof(EventCapNo) + sizeof(EventThreadID) + sizeof(EventCapNo); break; case EVENT_STOP_THREAD: // (cap, thread, status) eventTypes[t].size = - sizeof(CapNo) + sizeof(ThreadID) + sizeof(StgWord16); + sizeof(EventCapNo) + sizeof(EventThreadID) + sizeof(StgWord16); break; case EVENT_SHUTDOWN: // (cap) @@ -208,7 +208,7 @@ initEventLogging(void) case EVENT_REQUEST_PAR_GC: // (cap) case EVENT_GC_START: // (cap) case EVENT_GC_END: // (cap) - eventTypes[t].size = sizeof(CapNo); + eventTypes[t].size = sizeof(EventCapNo); break; } @@ -315,9 +315,8 @@ postEvent_(Capability *cap, EventTypeNum tag, StgThreadID thread, StgWord64 othe break; } - case EVENT_SPARK_TO_THREAD: // (cap, thread, spark_thread) + case EVENT_CREATE_SPARK_THREAD: // (cap, spark_thread) { - postThreadID(eb,thread); postThreadID(eb,other /* spark_thread */); break; } @@ -400,7 +399,7 @@ printAndClearEventLog(Capability *cap) void initEventsBuf(EventsBuf* eb, StgWord64 size) { - eb->begin = eb->pos = malloc(size); + eb->begin = eb->pos = stgMallocBytes(size, "initEventsBuf"); eb->size = size; } @@ -445,7 +444,7 @@ StgBool hasRoomForEvent(EventsBuf *eb, EventTypeNum eNum) { nat size = 0; - size += sizeof(EventTypeNum) + sizeof(Timestamp) + eventTypes[eNum].size; + size += sizeof(EventTypeNum) + sizeof(EventTimestamp) + eventTypes[eNum].size; if (eb->pos + size > eb->begin + eb->size) { return 0; // Not enough space.