Add capability sets to the event system. Contains code from Duncan Coutts.
[ghc-hetmet.git] / rts / eventlog / EventLog.h
1 /* -----------------------------------------------------------------------------
2  *
3  * (c) The GHC Team, 2008-2009
4  *
5  * Support for fast binary event logging.
6  *
7  * ---------------------------------------------------------------------------*/
8
9 #ifndef EVENTLOG_H
10 #define EVENTLOG_H
11
12 #include "rts/EventLogFormat.h"
13 #include "Capability.h"
14
15 #include "BeginPrivate.h"
16
17 #ifdef TRACING
18
19 /*
20  * Descriptions of EventTags for events.
21  */
22 extern char *EventTagDesc[];
23
24 void initEventLogging(void);
25 void endEventLogging(void);
26 void freeEventLogging(void);
27 void abortEventLogging(void); // #4512 - after fork child needs to abort
28 void flushEventLog(void);     // event log inherited from parent
29
30 /* 
31  * Post a scheduler event to the capability's event buffer (an event
32  * that has an associated thread).
33  */
34 void postSchedEvent(Capability *cap, EventTypeNum tag, 
35                     StgThreadID id, StgWord info1, StgWord info2);
36
37 /*
38  * Post a capability set modification event
39  */
40 void postCapsetModifyEvent (EventTypeNum tag,
41                             EventCapsetID capset,
42                             StgWord32 other,
43                             StgWord32 other2);
44
45 /*
46  * Post a capability set event with a string payload
47  */
48 void postCapsetStrEvent (EventTypeNum tag,
49                          EventCapsetID capset,
50                          char *msg);
51
52 /*
53  * Post a capability set event with several strings payload
54  */
55 void postCapsetVecEvent (EventTypeNum tag,
56                          EventCapsetID capset,
57                          int argc,
58                          char *msg[]);
59
60 /*
61  * Post a nullary event.
62  */
63 void postEvent(Capability *cap, EventTypeNum tag);
64
65 void postMsg(char *msg, va_list ap);
66
67 void postUserMsg(Capability *cap, char *msg, va_list ap);
68
69 void postCapMsg(Capability *cap, char *msg, va_list ap);
70
71 #else /* !TRACING */
72
73 INLINE_HEADER void postSchedEvent (Capability *cap  STG_UNUSED,
74                                    EventTypeNum tag STG_UNUSED,
75                                    StgThreadID id   STG_UNUSED,
76                                    StgWord info1    STG_UNUSED,
77                                    StgWord info2    STG_UNUSED)
78 { /* nothing */ }
79
80 INLINE_HEADER void postCapsetModifyEvent (EventTypeNum tag     STG_UNUSED,
81                                           EventCapsetID capset STG_UNUSED,
82                                           StgWord32 other      STG_UNUSED,
83                                           StgWord32 other2     STG_UNUSED)
84 { /* nothing */ }
85
86 INLINE_HEADER void postEvent (Capability *cap  STG_UNUSED,
87                               EventTypeNum tag STG_UNUSED)
88 { /* nothing */ }
89
90 INLINE_HEADER void postMsg (char *msg STG_UNUSED, 
91                             va_list ap STG_UNUSED)
92 { /* nothing */ }
93
94 INLINE_HEADER void postCapMsg (Capability *cap STG_UNUSED,
95                                char *msg STG_UNUSED, 
96                                va_list ap STG_UNUSED)
97 { /* nothing */ }
98
99 #endif
100
101 #include "EndPrivate.h"
102
103 #endif /* TRACING_H */