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