Merge pull request #5573 from lateralusX/lateralusX/windows-invalid-socket-error
[mono.git] / mono / profiler / log.h
1 #ifndef __MONO_PROFLOG_H__
2 #define __MONO_PROFLOG_H__
3
4 #include <glib.h>
5 #define MONO_PROFILER_UNSTABLE_GC_ROOTS
6 #include <mono/metadata/profiler.h>
7
8 #define BUF_ID 0x4D504C01
9 #define LOG_HEADER_ID 0x4D505A01
10 #define LOG_VERSION_MAJOR 2
11 #define LOG_VERSION_MINOR 0
12 #define LOG_DATA_VERSION 14
13
14 /*
15  * Changes in major/minor versions:
16  * version 1.0: removed sysid field from header
17  *              added args, arch, os fields to header
18  *
19  * Changes in data versions:
20  * version 2: added offsets in heap walk
21  * version 3: added GC roots
22  * version 4: added sample/statistical profiling
23  * version 5: added counters sampling
24  * version 6: added optional backtrace in sampling info
25  * version 8: added TYPE_RUNTIME and JIT helpers/trampolines
26  * version 9: added MONO_PROFILER_CODE_BUFFER_EXCEPTION_HANDLING
27  * version 10: added TYPE_COVERAGE
28  * version 11: added thread ID to TYPE_SAMPLE_HIT
29                added more load/unload events
30                    unload for class
31                    unload for image
32                    load/unload for appdomain
33                    load/unload for contexts
34                    load/unload/name for assemblies
35                removed TYPE_LOAD_ERR flag (profiler never generated it, now removed from the format itself)
36                added TYPE_GC_HANDLE_{CREATED,DESTROYED}_BT
37                TYPE_JIT events are no longer guaranteed to have code start/size info (can be zero)
38  * version 12: added MONO_COUNTER_PROFILER
39  * version 13: added MONO_GC_EVENT_{PRE_STOP_WORLD_LOCKED,POST_START_WORLD_UNLOCKED}
40                added TYPE_META + TYPE_SYNC_POINT
41                removed il and native offset in TYPE_SAMPLE_HIT
42                methods in backtraces are now encoded as proper method pointers
43                removed flags in backtrace format
44                removed flags in metadata events
45                changed the following fields to a single byte rather than leb128
46                    TYPE_GC_EVENT: event_type, generation
47                    TYPE_HEAP_ROOT: root_type
48                    TYPE_JITHELPER: type
49                    TYPE_SAMPLE_HIT: sample_type
50                    TYPE_CLAUSE: clause_type
51                    TYPE_SAMPLE_COUNTERS_DESC: type, unit, variance
52                    TYPE_SAMPLE_COUNTERS: type
53                added time fields to all events that were missing one
54                    TYPE_HEAP_OBJECT
55                    TYPE_HEAP_ROOT
56                    TYPE_SAMPLE_USYM
57                    TYPE_SAMPLE_COUNTERS_DESC
58                    TYPE_COVERAGE_METHOD
59                    TYPE_COVERAGE_STATEMENT
60                    TYPE_COVERAGE_CLASS
61                    TYPE_COVERAGE_ASSEMBLY
62                moved the time field in TYPE_SAMPLE_HIT to right after the event byte, now encoded as a regular time field
63                changed the time field in TYPE_SAMPLE_COUNTERS to be encoded as a regular time field (in nanoseconds)
64                added TYPE_GC_FINALIZE_{START,END,OBJECT_START,OBJECT_END}
65  * version 14: added event field to TYPE_MONITOR instead of encoding it in the extended info
66                all TYPE_MONITOR events can now contain backtraces
67                changed address field in TYPE_SAMPLE_UBIN to be based on ptr_base
68                added an image pointer field to assembly load events
69                added an exception object field to TYPE_CLAUSE
70                class unload events no longer exist (they were never emitted)
71                removed type field from TYPE_SAMPLE_HIT
72                removed MONO_GC_EVENT_{MARK,RECLAIM}_{START,END}
73                reverted the root_type field back to uleb128
74  */
75
76 /*
77  * file format:
78  * [header] [buffer]*
79  *
80  * The file is composed by a header followed by 0 or more buffers.
81  * Each buffer contains events that happened on a thread: for a given thread
82  * buffers that appear later in the file are guaranteed to contain events
83  * that happened later in time. Buffers from separate threads could be interleaved,
84  * though.
85  * Buffers are not required to be aligned.
86  *
87  * header format:
88  * [id: 4 bytes] constant value: LOG_HEADER_ID
89  * [major: 1 byte] [minor: 1 byte] major and minor version of the log profiler
90  * [format: 1 byte] version of the data format for the rest of the file
91  * [ptrsize: 1 byte] size in bytes of a pointer in the profiled program
92  * [startup time: 8 bytes] time in milliseconds since the unix epoch when the program started
93  * [timer overhead: 4 bytes] approximate overhead in nanoseconds of the timer
94  * [flags: 4 bytes] file format flags, should be 0 for now
95  * [pid: 4 bytes] pid of the profiled process
96  * [port: 2 bytes] tcp port for server if != 0
97  * [args size: 4 bytes] size of args
98  * [args: string] arguments passed to the profiler
99  * [arch size: 4 bytes] size of arch
100  * [arch: string] architecture the profiler is running on
101  * [os size: 4 bytes] size of os
102  * [os: string] operating system the profiler is running on
103  *
104  * The multiple byte integers are in little-endian format.
105  *
106  * buffer format:
107  * [buffer header] [event]*
108  * Buffers have a fixed-size header followed by 0 or more bytes of event data.
109  * Timing information and other values in the event data are usually stored
110  * as uleb128 or sleb128 integers. To save space, as noted for each item below,
111  * some data is represented as a difference between the actual value and
112  * either the last value of the same type (like for timing information) or
113  * as the difference from a value stored in a buffer header.
114  *
115  * For timing information the data is stored as uleb128, since timing
116  * increases in a monotonic way in each thread: the value is the number of
117  * nanoseconds to add to the last seen timing data in a buffer. The first value
118  * in a buffer will be calculated from the time_base field in the buffer head.
119  *
120  * Object or heap sizes are stored as uleb128.
121  * Pointer differences are stored as sleb128, instead.
122  *
123  * If an unexpected value is found, the rest of the buffer should be ignored,
124  * as generally the later values need the former to be interpreted correctly.
125  *
126  * buffer header format:
127  * [bufid: 4 bytes] constant value: BUF_ID
128  * [len: 4 bytes] size of the data following the buffer header
129  * [time_base: 8 bytes] time base in nanoseconds since an unspecified epoch
130  * [ptr_base: 8 bytes] base value for pointers
131  * [obj_base: 8 bytes] base value for object addresses
132  * [thread id: 8 bytes] system-specific thread ID (pthread_t for example)
133  * [method_base: 8 bytes] base value for MonoMethod pointers
134  *
135  * event format:
136  * [extended info: upper 4 bits] [type: lower 4 bits]
137  * [time diff: uleb128] nanoseconds since last timing
138  * [data]*
139  * The data that follows depends on type and the extended info.
140  * Type is one of the enum values in mono-profiler-log.h: TYPE_ALLOC, TYPE_GC,
141  * TYPE_METADATA, TYPE_METHOD, TYPE_EXCEPTION, TYPE_MONITOR, TYPE_HEAP.
142  * The extended info bits are interpreted based on type, see
143  * each individual event description below.
144  * strings are represented as a 0-terminated utf8 sequence.
145  *
146  * backtrace format:
147  * [num: uleb128] number of frames following
148  * [frame: sleb128]* mum MonoMethod* as a pointer difference from the last such
149  * pointer or the buffer method_base
150  *
151  * type alloc format:
152  * type: TYPE_ALLOC
153  * exinfo: zero or TYPE_ALLOC_BT
154  * [ptr: sleb128] class as a byte difference from ptr_base
155  * [obj: sleb128] object address as a byte difference from obj_base
156  * [size: uleb128] size of the object in the heap
157  * If exinfo == TYPE_ALLOC_BT, a backtrace follows.
158  *
159  * type GC format:
160  * type: TYPE_GC
161  * exinfo: one of TYPE_GC_EVENT, TYPE_GC_RESIZE, TYPE_GC_MOVE, TYPE_GC_HANDLE_CREATED[_BT],
162  * TYPE_GC_HANDLE_DESTROYED[_BT], TYPE_GC_FINALIZE_START, TYPE_GC_FINALIZE_END,
163  * TYPE_GC_FINALIZE_OBJECT_START, TYPE_GC_FINALIZE_OBJECT_END
164  * if exinfo == TYPE_GC_RESIZE
165  *      [heap_size: uleb128] new heap size
166  * if exinfo == TYPE_GC_EVENT
167  *      [event type: byte] GC event (MONO_GC_EVENT_* from profiler.h)
168  *      [generation: byte] GC generation event refers to
169  * if exinfo == TYPE_GC_MOVE
170  *      [num_objects: uleb128] number of object moves that follow
171  *      [objaddr: sleb128]+ num_objects object pointer differences from obj_base
172  *      num is always an even number: the even items are the old
173  *      addresses, the odd numbers are the respective new object addresses
174  * if exinfo == TYPE_GC_HANDLE_CREATED[_BT]
175  *      [handle_type: uleb128] MonoGCHandleType enum value
176  *      upper bits reserved as flags
177  *      [handle: uleb128] GC handle value
178  *      [objaddr: sleb128] object pointer differences from obj_base
179  *      If exinfo == TYPE_GC_HANDLE_CREATED_BT, a backtrace follows.
180  * if exinfo == TYPE_GC_HANDLE_DESTROYED[_BT]
181  *      [handle_type: uleb128] MonoGCHandleType enum value
182  *      upper bits reserved as flags
183  *      [handle: uleb128] GC handle value
184  *      If exinfo == TYPE_GC_HANDLE_DESTROYED_BT, a backtrace follows.
185  * if exinfo == TYPE_GC_FINALIZE_OBJECT_{START,END}
186  *      [object: sleb128] the object as a difference from obj_base
187  *
188  * type metadata format:
189  * type: TYPE_METADATA
190  * exinfo: one of: TYPE_END_LOAD, TYPE_END_UNLOAD (optional for TYPE_THREAD and TYPE_DOMAIN,
191  * doesn't occur for TYPE_CLASS)
192  * [mtype: byte] metadata type, one of: TYPE_CLASS, TYPE_IMAGE, TYPE_ASSEMBLY, TYPE_DOMAIN,
193  * TYPE_THREAD, TYPE_CONTEXT
194  * [pointer: sleb128] pointer of the metadata type depending on mtype
195  * if mtype == TYPE_CLASS
196  *      [image: sleb128] MonoImage* as a pointer difference from ptr_base
197  *      [name: string] full class name
198  * if mtype == TYPE_IMAGE
199  *      [name: string] image file name
200  * if mtype == TYPE_ASSEMBLY
201  *      [image: sleb128] MonoImage* as a pointer difference from ptr_base
202  *      [name: string] assembly name
203  * if mtype == TYPE_DOMAIN && exinfo == 0
204  *      [name: string] domain friendly name
205  * if mtype == TYPE_CONTEXT
206  *      [domain: sleb128] domain id as pointer
207  * if mtype == TYPE_THREAD && exinfo == 0
208  *      [name: string] thread name
209  *
210  * type method format:
211  * type: TYPE_METHOD
212  * exinfo: one of: TYPE_LEAVE, TYPE_ENTER, TYPE_EXC_LEAVE, TYPE_JIT
213  * [method: sleb128] MonoMethod* as a pointer difference from the last such
214  * pointer or the buffer method_base
215  * if exinfo == TYPE_JIT
216  *      [code address: sleb128] pointer to the native code as a diff from ptr_base
217  *      [code size: uleb128] size of the generated code
218  *      [name: string] full method name
219  *
220  * type exception format:
221  * type: TYPE_EXCEPTION
222  * exinfo: zero, TYPE_CLAUSE, or TYPE_THROW_BT
223  * if exinfo == TYPE_CLAUSE
224  *      [clause type: byte] MonoExceptionEnum enum value
225  *      [clause index: uleb128] index of the current clause
226  *      [method: sleb128] MonoMethod* as a pointer difference from the last such
227  *      pointer or the buffer method_base
228  *      [object: sleb128] the exception object as a difference from obj_base
229  * else
230  *      [object: sleb128] the exception object as a difference from obj_base
231  *      If exinfo == TYPE_THROW_BT, a backtrace follows.
232  *
233  * type runtime format:
234  * type: TYPE_RUNTIME
235  * exinfo: one of: TYPE_JITHELPER
236  * if exinfo == TYPE_JITHELPER
237  *      [type: byte] MonoProfilerCodeBufferType enum value
238  *      [buffer address: sleb128] pointer to the native code as a diff from ptr_base
239  *      [buffer size: uleb128] size of the generated code
240  *      if type == MONO_PROFILER_CODE_BUFFER_SPECIFIC_TRAMPOLINE
241  *              [name: string] buffer description name
242  *
243  * type monitor format:
244  * type: TYPE_MONITOR
245  * exinfo: zero or TYPE_MONITOR_BT
246  * [type: byte] MonoProfilerMonitorEvent enum value
247  * [object: sleb128] the lock object as a difference from obj_base
248  * If exinfo == TYPE_MONITOR_BT, a backtrace follows.
249  *
250  * type heap format
251  * type: TYPE_HEAP
252  * exinfo: one of TYPE_HEAP_START, TYPE_HEAP_END, TYPE_HEAP_OBJECT, TYPE_HEAP_ROOT
253  * if exinfo == TYPE_HEAP_OBJECT
254  *      [object: sleb128] the object as a difference from obj_base
255  *      [class: sleb128] the object MonoClass* as a difference from ptr_base
256  *      [size: uleb128] size of the object on the heap
257  *      [num_refs: uleb128] number of object references
258  *      each referenced objref is preceded by a uleb128 encoded offset: the
259  *      first offset is from the object address and each next offset is relative
260  *      to the previous one
261  *      [objrefs: sleb128]+ object referenced as a difference from obj_base
262  *      The same object can appear multiple times, but only the first time
263  *      with size != 0: in the other cases this data will only be used to
264  *      provide additional referenced objects.
265  * if exinfo == TYPE_HEAP_ROOT
266  *      [num_roots: uleb128] number of root references
267  *      [num_gc: uleb128] number of major gcs
268  *      [object: sleb128] the object as a difference from obj_base
269  *      [root_type: uleb128] the root_type: MonoProfileGCRootType (profiler.h)
270  *      [extra_info: uleb128] the extra_info value
271  *      object, root_type and extra_info are repeated num_roots times
272  *
273  * type sample format
274  * type: TYPE_SAMPLE
275  * exinfo: one of TYPE_SAMPLE_HIT, TYPE_SAMPLE_USYM, TYPE_SAMPLE_UBIN, TYPE_SAMPLE_COUNTERS_DESC, TYPE_SAMPLE_COUNTERS
276  * if exinfo == TYPE_SAMPLE_HIT
277  *      [thread: sleb128] thread id as difference from ptr_base
278  *      [count: uleb128] number of following instruction addresses
279  *      [ip: sleb128]* instruction pointer as difference from ptr_base
280  *      [mbt_count: uleb128] number of managed backtrace frames
281  *      [method: sleb128]* MonoMethod* as a pointer difference from the last such
282  *      pointer or the buffer method_base (the first such method can be also indentified by ip, but this is not neccessarily true)
283  * if exinfo == TYPE_SAMPLE_USYM
284  *      [address: sleb128] symbol address as a difference from ptr_base
285  *      [size: uleb128] symbol size (may be 0 if unknown)
286  *      [name: string] symbol name
287  * if exinfo == TYPE_SAMPLE_UBIN
288  *      [address: sleb128] address where binary has been loaded as a difference from ptr_base
289  *      [offset: uleb128] file offset of mapping (the same file can be mapped multiple times)
290  *      [size: uleb128] memory size
291  *      [name: string] binary name
292  * if exinfo == TYPE_SAMPLE_COUNTERS_DESC
293  *      [len: uleb128] number of counters
294  *      for i = 0 to len
295  *              [section: uleb128] section of counter
296  *              if section == MONO_COUNTER_PERFCOUNTERS:
297  *                      [section_name: string] section name of counter
298  *              [name: string] name of counter
299  *              [type: byte] type of counter
300  *              [unit: byte] unit of counter
301  *              [variance: byte] variance of counter
302  *              [index: uleb128] unique index of counter
303  * if exinfo == TYPE_SAMPLE_COUNTERS
304  *      while true:
305  *              [index: uleb128] unique index of counter
306  *              if index == 0:
307  *                      break
308  *              [type: byte] type of counter value
309  *              if type == string:
310  *                      if value == null:
311  *                              [0: byte] 0 -> value is null
312  *                      else:
313  *                              [1: byte] 1 -> value is not null
314  *                              [value: string] counter value
315  *              else:
316  *                      [value: uleb128/sleb128/double] counter value, can be sleb128, uleb128 or double (determined by using type)
317  *
318  * type coverage format
319  * type: TYPE_COVERAGE
320  * exinfo: one of TYPE_COVERAGE_METHOD, TYPE_COVERAGE_STATEMENT, TYPE_COVERAGE_ASSEMBLY, TYPE_COVERAGE_CLASS
321  * if exinfo == TYPE_COVERAGE_METHOD
322  *  [assembly: string] name of assembly
323  *  [class: string] name of the class
324  *  [name: string] name of the method
325  *  [signature: string] the signature of the method
326  *  [filename: string] the file path of the file that contains this method
327  *  [token: uleb128] the method token
328  *  [method_id: uleb128] an ID for this data to associate with the buffers of TYPE_COVERAGE_STATEMENTS
329  *  [len: uleb128] the number of TYPE_COVERAGE_BUFFERS associated with this method
330  * if exinfo == TYPE_COVERAGE_STATEMENTS
331  *  [method_id: uleb128] an the TYPE_COVERAGE_METHOD buffer to associate this with
332  *  [offset: uleb128] the il offset relative to the previous offset
333  *  [counter: uleb128] the counter for this instruction
334  *  [line: uleb128] the line of filename containing this instruction
335  *  [column: uleb128] the column containing this instruction
336  * if exinfo == TYPE_COVERAGE_ASSEMBLY
337  *  [name: string] assembly name
338  *  [guid: string] assembly GUID
339  *  [filename: string] assembly filename
340  *  [number_of_methods: uleb128] the number of methods in this assembly
341  *  [fully_covered: uleb128] the number of fully covered methods
342  *  [partially_covered: uleb128] the number of partially covered methods
343  *    currently partially_covered will always be 0, and fully_covered is the
344  *    number of methods that are fully and partially covered.
345  * if exinfo == TYPE_COVERAGE_CLASS
346  *  [name: string] assembly name
347  *  [class: string] class name
348  *  [number_of_methods: uleb128] the number of methods in this class
349  *  [fully_covered: uleb128] the number of fully covered methods
350  *  [partially_covered: uleb128] the number of partially covered methods
351  *    currently partially_covered will always be 0, and fully_covered is the
352  *    number of methods that are fully and partially covered.
353  *
354  * type meta format:
355  * type: TYPE_META
356  * exinfo: one of: TYPE_SYNC_POINT
357  * if exinfo == TYPE_SYNC_POINT
358  *      [type: byte] MonoProfilerSyncPointType enum value
359  */
360
361 enum {
362         TYPE_ALLOC,
363         TYPE_GC,
364         TYPE_METADATA,
365         TYPE_METHOD,
366         TYPE_EXCEPTION,
367         TYPE_MONITOR,
368         TYPE_HEAP,
369         TYPE_SAMPLE,
370         TYPE_RUNTIME,
371         TYPE_COVERAGE,
372         TYPE_META,
373         /* extended type for TYPE_HEAP */
374         TYPE_HEAP_START  = 0 << 4,
375         TYPE_HEAP_END    = 1 << 4,
376         TYPE_HEAP_OBJECT = 2 << 4,
377         TYPE_HEAP_ROOT   = 3 << 4,
378         /* extended type for TYPE_METADATA */
379         TYPE_END_LOAD     = 2 << 4,
380         TYPE_END_UNLOAD   = 4 << 4,
381         /* extended type for TYPE_GC */
382         TYPE_GC_EVENT  = 1 << 4,
383         TYPE_GC_RESIZE = 2 << 4,
384         TYPE_GC_MOVE   = 3 << 4,
385         TYPE_GC_HANDLE_CREATED      = 4 << 4,
386         TYPE_GC_HANDLE_DESTROYED    = 5 << 4,
387         TYPE_GC_HANDLE_CREATED_BT   = 6 << 4,
388         TYPE_GC_HANDLE_DESTROYED_BT = 7 << 4,
389         TYPE_GC_FINALIZE_START = 8 << 4,
390         TYPE_GC_FINALIZE_END = 9 << 4,
391         TYPE_GC_FINALIZE_OBJECT_START = 10 << 4,
392         TYPE_GC_FINALIZE_OBJECT_END = 11 << 4,
393         /* extended type for TYPE_METHOD */
394         TYPE_LEAVE     = 1 << 4,
395         TYPE_ENTER     = 2 << 4,
396         TYPE_EXC_LEAVE = 3 << 4,
397         TYPE_JIT       = 4 << 4,
398         /* extended type for TYPE_EXCEPTION */
399         TYPE_THROW_NO_BT = 0 << 7,
400         TYPE_THROW_BT    = 1 << 7,
401         TYPE_CLAUSE      = 1 << 4,
402         /* extended type for TYPE_ALLOC */
403         TYPE_ALLOC_NO_BT  = 0 << 4,
404         TYPE_ALLOC_BT     = 1 << 4,
405         /* extended type for TYPE_MONITOR */
406         TYPE_MONITOR_NO_BT  = 0 << 7,
407         TYPE_MONITOR_BT     = 1 << 7,
408         /* extended type for TYPE_SAMPLE */
409         TYPE_SAMPLE_HIT           = 0 << 4,
410         TYPE_SAMPLE_USYM          = 1 << 4,
411         TYPE_SAMPLE_UBIN          = 2 << 4,
412         TYPE_SAMPLE_COUNTERS_DESC = 3 << 4,
413         TYPE_SAMPLE_COUNTERS      = 4 << 4,
414         /* extended type for TYPE_RUNTIME */
415         TYPE_JITHELPER = 1 << 4,
416         /* extended type for TYPE_COVERAGE */
417         TYPE_COVERAGE_ASSEMBLY = 0 << 4,
418         TYPE_COVERAGE_METHOD   = 1 << 4,
419         TYPE_COVERAGE_STATEMENT = 2 << 4,
420         TYPE_COVERAGE_CLASS = 3 << 4,
421         /* extended type for TYPE_META */
422         TYPE_SYNC_POINT = 0 << 4,
423 };
424
425 enum {
426         /* metadata type byte for TYPE_METADATA */
427         TYPE_CLASS    = 1,
428         TYPE_IMAGE    = 2,
429         TYPE_ASSEMBLY = 3,
430         TYPE_DOMAIN   = 4,
431         TYPE_THREAD   = 5,
432         TYPE_CONTEXT  = 6,
433 };
434
435 typedef enum {
436         SYNC_POINT_PERIODIC = 0,
437         SYNC_POINT_WORLD_STOP = 1,
438         SYNC_POINT_WORLD_START = 2,
439 } MonoProfilerSyncPointType;
440
441 typedef enum {
442         MONO_PROFILER_MONITOR_CONTENTION = 1,
443         MONO_PROFILER_MONITOR_DONE = 2,
444         MONO_PROFILER_MONITOR_FAIL = 3,
445 } MonoProfilerMonitorEvent;
446
447 enum {
448         MONO_PROFILER_GC_HANDLE_CREATED = 0,
449         MONO_PROFILER_GC_HANDLE_DESTROYED = 1,
450 };
451
452 typedef enum {
453         MONO_PROFILER_HEAPSHOT_NONE = 0,
454         MONO_PROFILER_HEAPSHOT_MAJOR = 1,
455         MONO_PROFILER_HEAPSHOT_ON_DEMAND = 2,
456         MONO_PROFILER_HEAPSHOT_X_GC = 3,
457         MONO_PROFILER_HEAPSHOT_X_MS = 4,
458 } MonoProfilerHeapshotMode;
459
460 // If you alter MAX_FRAMES, you may need to alter SAMPLE_BLOCK_SIZE too.
461 #define MAX_FRAMES 32
462
463 //The following flags control emitting individual events
464 #define PROFLOG_EXCEPTION_EVENTS (1 << 0)
465 #define PROFLOG_MONITOR_EVENTS (1 << 1)
466 #define PROFLOG_GC_EVENTS (1 << 2)
467 #define PROFLOG_GC_ALLOCATION_EVENTS (1 << 3)
468 #define PROFLOG_GC_MOVE_EVENTS (1 << 4)
469 #define PROFLOG_GC_ROOT_EVENTS (1 << 5)
470 #define PROFLOG_GC_HANDLE_EVENTS (1 << 6)
471 #define PROFLOG_GC_FINALIZATION_EVENTS (1 << 7)
472 #define PROFLOG_COUNTER_EVENTS (1 << 8)
473 #define PROFLOG_SAMPLE_EVENTS (1 << 9)
474 #define PROFLOG_JIT_EVENTS (1 << 10)
475
476 #define PROFLOG_ALLOC_ALIAS (PROFLOG_GC_EVENTS | PROFLOG_GC_ALLOCATION_EVENTS | PROFLOG_GC_MOVE_EVENTS)
477 #define PROFLOG_HEAPSHOT_ALIAS (PROFLOG_GC_EVENTS | PROFLOG_GC_ROOT_EVENTS)
478 #define PROFLOG_LEGACY_ALIAS (PROFLOG_EXCEPTION_EVENTS | PROFLOG_MONITOR_EVENTS | PROFLOG_GC_EVENTS | PROFLOG_GC_MOVE_EVENTS | PROFLOG_GC_ROOT_EVENTS | PROFLOG_GC_HANDLE_EVENTS | PROFLOG_GC_FINALIZATION_EVENTS | PROFLOG_COUNTER_EVENTS)
479
480 typedef struct {
481         //Events explicitly enabled
482         int enable_mask;
483
484         //Events explicitly disabled
485         int disable_mask;
486
487         // Actual mask the profiler should use. Can be changed at runtime.
488         int effective_mask;
489
490         // Whether to do method prologue/epilogue instrumentation. Only used at startup.
491         gboolean enter_leave;
492
493         // Whether to collect code coverage by instrumenting basic blocks.
494         gboolean collect_coverage;
495
496         //Emit a report at the end of execution
497         gboolean do_report;
498
499         //Enable profiler internal debugging
500         gboolean do_debug;
501
502         //Where to compress the output file
503         gboolean use_zip;
504
505         // Heapshot mode (every major, on demand, XXgc, XXms). Can be changed at runtime.
506         MonoProfilerHeapshotMode hs_mode;
507
508         // Heapshot frequency in milliseconds (for MONO_HEAPSHOT_X_MS). Can be changed at runtime.
509         unsigned int hs_freq_ms;
510
511         // Heapshot frequency in number of collections (for MONO_HEAPSHOT_X_GC). Can be changed at runtime.
512         unsigned int hs_freq_gc;
513
514         // Whether to do a heapshot on shutdown.
515         gboolean hs_on_shutdown;
516
517         // Sample frequency in Hertz. Only used at startup.
518         int sample_freq;
519
520         // Maximum number of frames to collect. Can be changed at runtime.
521         int num_frames;
522
523         // Max depth to record enter/leave events. Can be changed at runtime.
524         int max_call_depth;
525
526         //Name of the generated mlpd file
527         const char *output_filename;
528
529         //Filter files used by the code coverage mode
530         GPtrArray *cov_filter_files;
531
532         // Port to listen for profiling commands (e.g. "heapshot" for on-demand heapshot).
533         int command_port;
534
535         // Maximum number of SampleHit structures. We'll drop samples if this number is not sufficient.
536         int max_allocated_sample_hits;
537
538         // Sample mode. Only used at startup.
539         MonoProfilerSampleMode sampling_mode;
540 } ProfilerConfig;
541
542 void proflog_parse_args (ProfilerConfig *config, const char *desc);
543
544 #endif /* __MONO_PROFLOG_H__ */