1 #ifndef __MONO_PROFILER_H__
2 #define __MONO_PROFILER_H__
4 #include <mono/metadata/object.h>
5 #include <mono/metadata/appdomain.h>
9 #define MONO_PROFILER_MAX_STAT_CALL_CHAIN_DEPTH 128
12 MONO_PROFILE_NONE
= 0,
13 MONO_PROFILE_APPDOMAIN_EVENTS
= 1 << 0,
14 MONO_PROFILE_ASSEMBLY_EVENTS
= 1 << 1,
15 MONO_PROFILE_MODULE_EVENTS
= 1 << 2,
16 MONO_PROFILE_CLASS_EVENTS
= 1 << 3,
17 MONO_PROFILE_JIT_COMPILATION
= 1 << 4,
18 MONO_PROFILE_INLINING
= 1 << 5,
19 MONO_PROFILE_EXCEPTIONS
= 1 << 6,
20 MONO_PROFILE_ALLOCATIONS
= 1 << 7,
21 MONO_PROFILE_GC
= 1 << 8,
22 MONO_PROFILE_THREADS
= 1 << 9,
23 MONO_PROFILE_REMOTING
= 1 << 10,
24 MONO_PROFILE_TRANSITIONS
= 1 << 11,
25 MONO_PROFILE_ENTER_LEAVE
= 1 << 12,
26 MONO_PROFILE_COVERAGE
= 1 << 13,
27 MONO_PROFILE_INS_COVERAGE
= 1 << 14,
28 MONO_PROFILE_STATISTICAL
= 1 << 15,
29 MONO_PROFILE_METHOD_EVENTS
= 1 << 16,
30 MONO_PROFILE_MONITOR_EVENTS
= 1 << 17,
31 MONO_PROFILE_IOMAP_EVENTS
= 1 << 18, /* this should likely be removed, too */
32 MONO_PROFILE_GC_MOVES
= 1 << 19
42 MONO_GC_EVENT_MARK_START
,
43 MONO_GC_EVENT_MARK_END
,
44 MONO_GC_EVENT_RECLAIM_START
,
45 MONO_GC_EVENT_RECLAIM_END
,
47 MONO_GC_EVENT_PRE_STOP_WORLD
,
48 MONO_GC_EVENT_POST_STOP_WORLD
,
49 MONO_GC_EVENT_PRE_START_WORLD
,
50 MONO_GC_EVENT_POST_START_WORLD
61 } MonoProfileCoverageEntry
;
63 /* executable code buffer info */
65 MONO_PROFILER_CODE_BUFFER_UNKNOWN
,
66 MONO_PROFILER_CODE_BUFFER_METHOD
,
67 MONO_PROFILER_CODE_BUFFER_LAST
68 } MonoProfilerCodeBufferType
;
70 typedef struct _MonoProfiler MonoProfiler
;
73 MONO_PROFILER_MONITOR_CONTENTION
= 1,
74 MONO_PROFILER_MONITOR_DONE
= 2,
75 MONO_PROFILER_MONITOR_FAIL
= 3
76 } MonoProfilerMonitorEvent
;
79 MONO_PROFILER_CALL_CHAIN_NONE
= 0,
80 MONO_PROFILER_CALL_CHAIN_NATIVE
= 1,
81 MONO_PROFILER_CALL_CHAIN_GLIBC
= 2,
82 MONO_PROFILER_CALL_CHAIN_MANAGED
= 3,
83 MONO_PROFILER_CALL_CHAIN_INVALID
= 4
84 } MonoProfilerCallChainStrategy
;
87 * Functions that the runtime will call on the profiler.
90 typedef void (*MonoProfileFunc
) (MonoProfiler
*prof
);
92 typedef void (*MonoProfileAppDomainFunc
) (MonoProfiler
*prof
, MonoDomain
*domain
);
93 typedef void (*MonoProfileMethodFunc
) (MonoProfiler
*prof
, MonoMethod
*method
);
94 typedef void (*MonoProfileClassFunc
) (MonoProfiler
*prof
, MonoClass
*klass
);
95 typedef void (*MonoProfileModuleFunc
) (MonoProfiler
*prof
, MonoImage
*module
);
96 typedef void (*MonoProfileAssemblyFunc
) (MonoProfiler
*prof
, MonoAssembly
*assembly
);
97 typedef void (*MonoProfileMonitorFunc
) (MonoProfiler
*prof
, MonoObject
*obj
, MonoProfilerMonitorEvent event
);
99 typedef void (*MonoProfileExceptionFunc
) (MonoProfiler
*prof
, MonoObject
*object
);
100 typedef void (*MonoProfileExceptionClauseFunc
) (MonoProfiler
*prof
, MonoMethod
*method
, int clause_type
, int clause_num
);
102 typedef void (*MonoProfileAppDomainResult
)(MonoProfiler
*prof
, MonoDomain
*domain
, int result
);
103 typedef void (*MonoProfileMethodResult
) (MonoProfiler
*prof
, MonoMethod
*method
, int result
);
104 typedef void (*MonoProfileJitResult
) (MonoProfiler
*prof
, MonoMethod
*method
, MonoJitInfo
* jinfo
, int result
);
105 typedef void (*MonoProfileClassResult
) (MonoProfiler
*prof
, MonoClass
*klass
, int result
);
106 typedef void (*MonoProfileModuleResult
) (MonoProfiler
*prof
, MonoImage
*module
, int result
);
107 typedef void (*MonoProfileAssemblyResult
) (MonoProfiler
*prof
, MonoAssembly
*assembly
, int result
);
109 typedef void (*MonoProfileMethodInline
) (MonoProfiler
*prof
, MonoMethod
*parent
, MonoMethod
*child
, int *ok
);
111 typedef void (*MonoProfileThreadFunc
) (MonoProfiler
*prof
, intptr_t tid
);
112 typedef void (*MonoProfileAllocFunc
) (MonoProfiler
*prof
, MonoObject
*obj
, MonoClass
*klass
);
113 typedef void (*MonoProfileStatFunc
) (MonoProfiler
*prof
, mono_byte
*ip
, void *context
);
114 typedef void (*MonoProfileStatCallChainFunc
) (MonoProfiler
*prof
, int call_chain_depth
, mono_byte
**ip
, void *context
);
115 typedef void (*MonoProfileGCFunc
) (MonoProfiler
*prof
, MonoGCEvent event
, int generation
);
116 typedef void (*MonoProfileGCMoveFunc
) (MonoProfiler
*prof
, void **objects
, int num
);
117 typedef void (*MonoProfileGCResizeFunc
) (MonoProfiler
*prof
, int64_t new_size
);
119 typedef void (*MonoProfileIomapFunc
) (MonoProfiler
*prof
, const char *report
, const char *pathname
, const char *new_pathname
);
121 typedef mono_bool (*MonoProfileCoverageFilterFunc
) (MonoProfiler
*prof
, MonoMethod
*method
);
123 typedef void (*MonoProfileCoverageFunc
) (MonoProfiler
*prof
, const MonoProfileCoverageEntry
*entry
);
125 typedef void (*MonoProfilerCodeChunkNew
) (MonoProfiler
*prof
, void* chunk
, int size
);
126 typedef void (*MonoProfilerCodeChunkDestroy
) (MonoProfiler
*prof
, void* chunk
);
127 typedef void (*MonoProfilerCodeBufferNew
) (MonoProfiler
*prof
, void* buffer
, int size
, MonoProfilerCodeBufferType type
, void *data
);
130 * Function the profiler may call.
132 void mono_profiler_install (MonoProfiler
*prof
, MonoProfileFunc shutdown_callback
);
133 void mono_profiler_set_events (MonoProfileFlags events
);
135 MonoProfileFlags
mono_profiler_get_events (void);
137 void mono_profiler_install_appdomain (MonoProfileAppDomainFunc start_load
, MonoProfileAppDomainResult end_load
,
138 MonoProfileAppDomainFunc start_unload
, MonoProfileAppDomainFunc end_unload
);
139 void mono_profiler_install_assembly (MonoProfileAssemblyFunc start_load
, MonoProfileAssemblyResult end_load
,
140 MonoProfileAssemblyFunc start_unload
, MonoProfileAssemblyFunc end_unload
);
141 void mono_profiler_install_module (MonoProfileModuleFunc start_load
, MonoProfileModuleResult end_load
,
142 MonoProfileModuleFunc start_unload
, MonoProfileModuleFunc end_unload
);
143 void mono_profiler_install_class (MonoProfileClassFunc start_load
, MonoProfileClassResult end_load
,
144 MonoProfileClassFunc start_unload
, MonoProfileClassFunc end_unload
);
146 void mono_profiler_install_jit_compile (MonoProfileMethodFunc start
, MonoProfileMethodResult end
);
147 void mono_profiler_install_jit_end (MonoProfileJitResult end
);
148 void mono_profiler_install_method_free (MonoProfileMethodFunc callback
);
149 void mono_profiler_install_method_invoke (MonoProfileMethodFunc start
, MonoProfileMethodFunc end
);
150 void mono_profiler_install_enter_leave (MonoProfileMethodFunc enter
, MonoProfileMethodFunc fleave
);
151 void mono_profiler_install_thread (MonoProfileThreadFunc start
, MonoProfileThreadFunc end
);
152 void mono_profiler_install_transition (MonoProfileMethodResult callback
);
153 void mono_profiler_install_allocation (MonoProfileAllocFunc callback
);
154 void mono_profiler_install_monitor (MonoProfileMonitorFunc callback
);
155 void mono_profiler_install_statistical (MonoProfileStatFunc callback
);
156 void mono_profiler_install_statistical_call_chain (MonoProfileStatCallChainFunc callback
, int call_chain_depth
, MonoProfilerCallChainStrategy call_chain_strategy
);
157 void mono_profiler_install_exception (MonoProfileExceptionFunc throw_callback
, MonoProfileMethodFunc exc_method_leave
, MonoProfileExceptionClauseFunc clause_callback
);
158 void mono_profiler_install_coverage_filter (MonoProfileCoverageFilterFunc callback
);
159 void mono_profiler_coverage_get (MonoProfiler
*prof
, MonoMethod
*method
, MonoProfileCoverageFunc func
);
160 void mono_profiler_install_gc (MonoProfileGCFunc callback
, MonoProfileGCResizeFunc heap_resize_callback
);
161 void mono_profiler_install_gc_moves (MonoProfileGCMoveFunc callback
);
162 void mono_profiler_install_runtime_initialized (MonoProfileFunc runtime_initialized_callback
);
164 void mono_profiler_install_code_chunk_new (MonoProfilerCodeChunkNew callback
);
165 void mono_profiler_install_code_chunk_destroy (MonoProfilerCodeChunkDestroy callback
);
166 void mono_profiler_install_code_buffer_new (MonoProfilerCodeBufferNew callback
);
168 void mono_profiler_install_iomap (MonoProfileIomapFunc callback
);
170 void mono_profiler_load (const char *desc
);
174 #endif /* __MONO_PROFILER_H__ */