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