[sgen] Add worker index to the binary protocol entries
[mono-project.git] / mono / sgen / sgen-protocol.h
blobb0892f4478fd09effd1ee58ce2c7e2db5bbe3e9b
1 /*
2 * sgen-protocol.h: Binary protocol of internal activity, to aid
3 * debugging.
5 * Copyright 2001-2003 Ximian, Inc
6 * Copyright 2003-2010 Novell, Inc.
7 * Copyright (C) 2012 Xamarin Inc
9 * Licensed under the MIT license. See LICENSE file in the project root for full license information.
12 #ifndef __MONO_SGENPROTOCOL_H__
13 #define __MONO_SGENPROTOCOL_H__
15 #include "sgen-gc.h"
17 #define PROTOCOL_HEADER_CHECK 0xde7ec7ab1ec0de
19 * The version needs to be bumped every time we introduce breaking changes (like
20 * adding new protocol entries or various format changes). The latest protocol grepper
21 * should be able to handle all the previous versions, while an old grepper will
22 * be able to tell if it cannot handle the format.
24 #define PROTOCOL_HEADER_VERSION 2
26 /* Special indices returned by MATCH_INDEX. */
27 #define BINARY_PROTOCOL_NO_MATCH (-1)
28 #define BINARY_PROTOCOL_MATCH (-2)
30 #define PROTOCOL_ID(method) method ## _id
31 #define PROTOCOL_STRUCT(method) method ## _struct
32 #define CLIENT_PROTOCOL_NAME(method) sgen_client_ ## method
34 #ifndef TYPE_INT
35 #define TYPE_INT int
36 #endif
37 #ifndef TYPE_LONGLONG
38 #define TYPE_LONGLONG long long
39 #endif
40 #ifndef TYPE_SIZE
41 #define TYPE_SIZE size_t
42 #endif
43 #ifndef TYPE_POINTER
44 #define TYPE_POINTER gpointer
45 #endif
46 #ifndef TYPE_BOOL
47 #define TYPE_BOOL gboolean
48 #endif
50 enum {
51 #define BEGIN_PROTOCOL_ENTRY0(method) PROTOCOL_ID(method),
52 #define BEGIN_PROTOCOL_ENTRY1(method,t1,f1) PROTOCOL_ID(method),
53 #define BEGIN_PROTOCOL_ENTRY2(method,t1,f1,t2,f2) PROTOCOL_ID(method),
54 #define BEGIN_PROTOCOL_ENTRY3(method,t1,f1,t2,f2,t3,f3) PROTOCOL_ID(method),
55 #define BEGIN_PROTOCOL_ENTRY4(method,t1,f1,t2,f2,t3,f3,t4,f4) PROTOCOL_ID(method),
56 #define BEGIN_PROTOCOL_ENTRY5(method,t1,f1,t2,f2,t3,f3,t4,f4,t5,f5) PROTOCOL_ID(method),
57 #define BEGIN_PROTOCOL_ENTRY6(method,t1,f1,t2,f2,t3,f3,t4,f4,t5,f5,t6,f6) PROTOCOL_ID(method),
58 #define BEGIN_PROTOCOL_ENTRY_HEAVY0(method) PROTOCOL_ID(method),
59 #define BEGIN_PROTOCOL_ENTRY_HEAVY1(method,t1,f1) PROTOCOL_ID(method),
60 #define BEGIN_PROTOCOL_ENTRY_HEAVY2(method,t1,f1,t2,f2) PROTOCOL_ID(method),
61 #define BEGIN_PROTOCOL_ENTRY_HEAVY3(method,t1,f1,t2,f2,t3,f3) PROTOCOL_ID(method),
62 #define BEGIN_PROTOCOL_ENTRY_HEAVY4(method,t1,f1,t2,f2,t3,f3,t4,f4) PROTOCOL_ID(method),
63 #define BEGIN_PROTOCOL_ENTRY_HEAVY5(method,t1,f1,t2,f2,t3,f3,t4,f4,t5,f5) PROTOCOL_ID(method),
64 #define BEGIN_PROTOCOL_ENTRY_HEAVY6(method,t1,f1,t2,f2,t3,f3,t4,f4,t5,f5,t6,f6) PROTOCOL_ID(method),
66 #define DEFAULT_PRINT()
67 #define CUSTOM_PRINT(_)
69 #define IS_ALWAYS_MATCH(_)
70 #define MATCH_INDEX(_)
71 #define IS_VTABLE_MATCH(_)
73 #define END_PROTOCOL_ENTRY
74 #define END_PROTOCOL_ENTRY_FLUSH
75 #define END_PROTOCOL_ENTRY_HEAVY
77 #include "sgen-protocol-def.h"
80 /* We pack all protocol structs by default unless specified otherwise */
81 #ifndef PROTOCOL_STRUCT_ATTR
83 #define PROTOCOL_PACK_STRUCTS
85 #if defined(__GNUC__)
86 #define PROTOCOL_STRUCT_ATTR __attribute__ ((packed))
87 #else
88 #define PROTOCOL_STRUCT_ATTR
89 #endif
91 #endif
93 #define BEGIN_PROTOCOL_ENTRY0(method)
94 #define BEGIN_PROTOCOL_ENTRY1(method,t1,f1) \
95 typedef struct PROTOCOL_STRUCT_ATTR { \
96 t1 f1; \
97 } PROTOCOL_STRUCT(method);
98 #define BEGIN_PROTOCOL_ENTRY2(method,t1,f1,t2,f2) \
99 typedef struct PROTOCOL_STRUCT_ATTR { \
100 t1 f1; \
101 t2 f2; \
102 } PROTOCOL_STRUCT(method);
103 #define BEGIN_PROTOCOL_ENTRY3(method,t1,f1,t2,f2,t3,f3) \
104 typedef struct PROTOCOL_STRUCT_ATTR { \
105 t1 f1; \
106 t2 f2; \
107 t3 f3; \
108 } PROTOCOL_STRUCT(method);
109 #define BEGIN_PROTOCOL_ENTRY4(method,t1,f1,t2,f2,t3,f3,t4,f4) \
110 typedef struct PROTOCOL_STRUCT_ATTR { \
111 t1 f1; \
112 t2 f2; \
113 t3 f3; \
114 t4 f4; \
115 } PROTOCOL_STRUCT(method);
116 #define BEGIN_PROTOCOL_ENTRY5(method,t1,f1,t2,f2,t3,f3,t4,f4,t5,f5) \
117 typedef struct PROTOCOL_STRUCT_ATTR { \
118 t1 f1; \
119 t2 f2; \
120 t3 f3; \
121 t4 f4; \
122 t5 f5; \
123 } PROTOCOL_STRUCT(method);
124 #define BEGIN_PROTOCOL_ENTRY6(method,t1,f1,t2,f2,t3,f3,t4,f4,t5,f5,t6,f6) \
125 typedef struct PROTOCOL_STRUCT_ATTR { \
126 t1 f1; \
127 t2 f2; \
128 t3 f3; \
129 t4 f4; \
130 t5 f5; \
131 t6 f6; \
132 } PROTOCOL_STRUCT(method);
134 #define BEGIN_PROTOCOL_ENTRY_HEAVY0(method) \
135 BEGIN_PROTOCOL_ENTRY0 (method)
136 #define BEGIN_PROTOCOL_ENTRY_HEAVY1(method,t1,f1) \
137 BEGIN_PROTOCOL_ENTRY1 (method,t1,f1)
138 #define BEGIN_PROTOCOL_ENTRY_HEAVY2(method,t1,f1,t2,f2) \
139 BEGIN_PROTOCOL_ENTRY2 (method,t1,f1,t2,f2)
140 #define BEGIN_PROTOCOL_ENTRY_HEAVY3(method,t1,f1,t2,f2,t3,f3) \
141 BEGIN_PROTOCOL_ENTRY3 (method,t1,f1,t2,f2,t3,f3)
142 #define BEGIN_PROTOCOL_ENTRY_HEAVY4(method,t1,f1,t2,f2,t3,f3,t4,f4) \
143 BEGIN_PROTOCOL_ENTRY4 (method,t1,f1,t2,f2,t3,f3,t4,f4)
144 #define BEGIN_PROTOCOL_ENTRY_HEAVY5(method,t1,f1,t2,f2,t3,f3,t4,f4,t5,f5) \
145 BEGIN_PROTOCOL_ENTRY5 (method,t1,f1,t2,f2,t3,f3,t4,f4,t5,f5)
146 #define BEGIN_PROTOCOL_ENTRY_HEAVY6(method,t1,f1,t2,f2,t3,f3,t4,f4,t5,f5,t6,f6) \
147 BEGIN_PROTOCOL_ENTRY6 (method,t1,f1,t2,f2,t3,f3,t4,f4,t5,f5,t6,f6)
149 #define DEFAULT_PRINT()
150 #define CUSTOM_PRINT(_)
152 #define IS_ALWAYS_MATCH(_)
153 #define MATCH_INDEX(_)
154 #define IS_VTABLE_MATCH(_)
156 #define END_PROTOCOL_ENTRY
157 #define END_PROTOCOL_ENTRY_FLUSH
158 #define END_PROTOCOL_ENTRY_HEAVY
160 #if defined(_MSC_VER) && defined(PROTOCOL_PACK_STRUCTS)
161 #pragma pack(push)
162 #pragma pack(1)
163 #endif
164 #include "sgen-protocol-def.h"
165 #if defined(_MSC_VER) && defined(PROTOCOL_PACK_STRUCTS)
166 #pragma pack(pop)
167 #undef PROTOCOL_PACK_STRUCTS
168 #endif
170 /* missing: finalizers, roots, non-store wbarriers */
172 void binary_protocol_init (const char *filename, long long limit);
173 gboolean binary_protocol_is_enabled (void);
175 gboolean binary_protocol_flush_buffers (gboolean force);
177 #define BEGIN_PROTOCOL_ENTRY0(method) \
178 void method (void);
179 #define BEGIN_PROTOCOL_ENTRY1(method,t1,f1) \
180 void method (t1 f1);
181 #define BEGIN_PROTOCOL_ENTRY2(method,t1,f1,t2,f2) \
182 void method (t1 f1, t2 f2);
183 #define BEGIN_PROTOCOL_ENTRY3(method,t1,f1,t2,f2,t3,f3) \
184 void method (t1 f1, t2 f2, t3 f3);
185 #define BEGIN_PROTOCOL_ENTRY4(method,t1,f1,t2,f2,t3,f3,t4,f4) \
186 void method (t1 f1, t2 f2, t3 f3, t4 f4);
187 #define BEGIN_PROTOCOL_ENTRY5(method,t1,f1,t2,f2,t3,f3,t4,f4,t5,f5) \
188 void method (t1 f1, t2 f2, t3 f3, t4 f4, t5 f5);
189 #define BEGIN_PROTOCOL_ENTRY6(method,t1,f1,t2,f2,t3,f3,t4,f4,t5,f5,t6,f6) \
190 void method (t1 f1, t2 f2, t3 f3, t4 f4, t5 f5, t6 f6);
192 #ifdef SGEN_HEAVY_BINARY_PROTOCOL
193 #define binary_protocol_is_heavy_enabled() binary_protocol_is_enabled ()
195 #define BEGIN_PROTOCOL_ENTRY_HEAVY0(method) \
196 BEGIN_PROTOCOL_ENTRY0 (method)
197 #define BEGIN_PROTOCOL_ENTRY_HEAVY1(method,t1,f1) \
198 BEGIN_PROTOCOL_ENTRY1 (method,t1,f1)
199 #define BEGIN_PROTOCOL_ENTRY_HEAVY2(method,t1,f1,t2,f2) \
200 BEGIN_PROTOCOL_ENTRY2 (method,t1,f1,t2,f2)
201 #define BEGIN_PROTOCOL_ENTRY_HEAVY3(method,t1,f1,t2,f2,t3,f3) \
202 BEGIN_PROTOCOL_ENTRY3 (method,t1,f1,t2,f2,t3,f3)
203 #define BEGIN_PROTOCOL_ENTRY_HEAVY4(method,t1,f1,t2,f2,t3,f3,t4,f4) \
204 BEGIN_PROTOCOL_ENTRY4 (method,t1,f1,t2,f2,t3,f3,t4,f4)
205 #define BEGIN_PROTOCOL_ENTRY_HEAVY5(method,t1,f1,t2,f2,t3,f3,t4,f4,t5,f5) \
206 BEGIN_PROTOCOL_ENTRY5 (method,t1,f1,t2,f2,t3,f3,t4,f4,t5,f5)
207 #define BEGIN_PROTOCOL_ENTRY_HEAVY6(method,t1,f1,t2,f2,t3,f3,t4,f4,t5,f5,t6,f6) \
208 BEGIN_PROTOCOL_ENTRY6 (method,t1,f1,t2,f2,t3,f3,t4,f4,t5,f5,t6,f6)
209 #else
210 #define binary_protocol_is_heavy_enabled() FALSE
212 #define BEGIN_PROTOCOL_ENTRY_HEAVY0(method) \
213 static inline void method (void) {}
214 #define BEGIN_PROTOCOL_ENTRY_HEAVY1(method,t1,f1) \
215 static inline void method (t1 f1) {}
216 #define BEGIN_PROTOCOL_ENTRY_HEAVY2(method,t1,f1,t2,f2) \
217 static inline void method (t1 f1, t2 f2) {}
218 #define BEGIN_PROTOCOL_ENTRY_HEAVY3(method,t1,f1,t2,f2,t3,f3) \
219 static inline void method (t1 f1, t2 f2, t3 f3) {}
220 #define BEGIN_PROTOCOL_ENTRY_HEAVY4(method,t1,f1,t2,f2,t3,f3,t4,f4) \
221 static inline void method (t1 f1, t2 f2, t3 f3, t4 f4) {}
222 #define BEGIN_PROTOCOL_ENTRY_HEAVY5(method,t1,f1,t2,f2,t3,f3,t4,f4,t5,f5) \
223 static inline void method (t1 f1, t2 f2, t3 f3, t4 f4, t5 f5) {}
224 #define BEGIN_PROTOCOL_ENTRY_HEAVY6(method,t1,f1,t2,f2,t3,f3,t4,f4,t5,f5,t6,f6) \
225 static inline void method (t1 f1, t2 f2, t3 f3, t4 f4, t5 f5, t6 f6) {}
226 #endif
228 #define DEFAULT_PRINT()
229 #define CUSTOM_PRINT(_)
231 #define IS_ALWAYS_MATCH(_)
232 #define MATCH_INDEX(_)
233 #define IS_VTABLE_MATCH(_)
235 #define END_PROTOCOL_ENTRY
236 #define END_PROTOCOL_ENTRY_FLUSH
237 #define END_PROTOCOL_ENTRY_HEAVY
239 #include "sgen-protocol-def.h"
241 #undef TYPE_INT
242 #undef TYPE_LONGLONG
243 #undef TYPE_SIZE
244 #undef TYPE_POINTER
245 #undef TYPE_BOOL
247 #endif