Merge pull request #392 from baulig/master
[mono.git] / mono / metadata / profiler.h
index 6ca895dc125a2c339652dfd13a29b2cde61df6c5..09299a7cfd7449ff68560bf6e781667375282ef0 100644 (file)
@@ -4,7 +4,9 @@
 #include <mono/metadata/object.h>
 #include <mono/metadata/appdomain.h>
 
-G_BEGIN_DECLS
+MONO_BEGIN_DECLS
+
+#define MONO_PROFILER_MAX_STAT_CALL_CHAIN_DEPTH 128
 
 typedef enum {
        MONO_PROFILE_NONE = 0,
@@ -23,7 +25,12 @@ typedef enum {
        MONO_PROFILE_ENTER_LEAVE      = 1 << 12,
        MONO_PROFILE_COVERAGE         = 1 << 13,
        MONO_PROFILE_INS_COVERAGE     = 1 << 14,
-       MONO_PROFILE_STATISTICAL      = 1 << 15
+       MONO_PROFILE_STATISTICAL      = 1 << 15,
+       MONO_PROFILE_METHOD_EVENTS    = 1 << 16,
+       MONO_PROFILE_MONITOR_EVENTS   = 1 << 17,
+       MONO_PROFILE_IOMAP_EVENTS     = 1 << 18, /* this should likely be removed, too */
+       MONO_PROFILE_GC_MOVES         = 1 << 19,
+       MONO_PROFILE_GC_ROOTS         = 1 << 20
 } MonoProfileFlags;
 
 typedef enum {
@@ -37,7 +44,11 @@ typedef enum {
        MONO_GC_EVENT_MARK_END,
        MONO_GC_EVENT_RECLAIM_START,
        MONO_GC_EVENT_RECLAIM_END,
-       MONO_GC_EVENT_END
+       MONO_GC_EVENT_END,
+       MONO_GC_EVENT_PRE_STOP_WORLD,
+       MONO_GC_EVENT_POST_STOP_WORLD,
+       MONO_GC_EVENT_PRE_START_WORLD,
+       MONO_GC_EVENT_POST_START_WORLD
 } MonoGCEvent;
 
 /* coverage info */
@@ -50,8 +61,46 @@ typedef struct {
        int col;
 } MonoProfileCoverageEntry;
 
+/* executable code buffer info */
+typedef enum {
+       MONO_PROFILER_CODE_BUFFER_UNKNOWN,
+       MONO_PROFILER_CODE_BUFFER_METHOD,
+       MONO_PROFILER_CODE_BUFFER_LAST
+} MonoProfilerCodeBufferType;
+
 typedef struct _MonoProfiler MonoProfiler;
 
+typedef enum {
+       MONO_PROFILER_MONITOR_CONTENTION = 1,
+       MONO_PROFILER_MONITOR_DONE = 2,
+       MONO_PROFILER_MONITOR_FAIL = 3
+} MonoProfilerMonitorEvent;
+
+typedef enum {
+       MONO_PROFILER_CALL_CHAIN_NONE = 0,
+       MONO_PROFILER_CALL_CHAIN_NATIVE = 1,
+       MONO_PROFILER_CALL_CHAIN_GLIBC = 2,
+       MONO_PROFILER_CALL_CHAIN_MANAGED = 3,
+       MONO_PROFILER_CALL_CHAIN_INVALID = 4
+} MonoProfilerCallChainStrategy;
+
+typedef enum {
+       MONO_PROFILER_GC_HANDLE_CREATED,
+       MONO_PROFILER_GC_HANDLE_DESTROYED
+} MonoProfileGCHandleEvent;
+
+typedef enum {
+       MONO_PROFILE_GC_ROOT_PINNING  = 1 << 8,
+       MONO_PROFILE_GC_ROOT_WEAKREF  = 2 << 8,
+       MONO_PROFILE_GC_ROOT_INTERIOR = 4 << 8,
+       /* the above are flags, the type is in the low 2 bytes */
+       MONO_PROFILE_GC_ROOT_STACK = 0,
+       MONO_PROFILE_GC_ROOT_FINALIZER = 1,
+       MONO_PROFILE_GC_ROOT_HANDLE = 2,
+       MONO_PROFILE_GC_ROOT_OTHER = 3,
+       MONO_PROFILE_GC_ROOT_MISC = 4, /* could be stack, handle, etc. */
+       MONO_PROFILE_GC_ROOT_TYPEMASK = 0xff
+} MonoProfileGCRootType;
 
 /*
  * Functions that the runtime will call on the profiler.
@@ -64,25 +113,41 @@ typedef void (*MonoProfileMethodFunc)   (MonoProfiler *prof, MonoMethod   *metho
 typedef void (*MonoProfileClassFunc)    (MonoProfiler *prof, MonoClass    *klass);
 typedef void (*MonoProfileModuleFunc)   (MonoProfiler *prof, MonoImage    *module);
 typedef void (*MonoProfileAssemblyFunc) (MonoProfiler *prof, MonoAssembly *assembly);
+typedef void (*MonoProfileMonitorFunc)  (MonoProfiler *prof, MonoObject *obj, MonoProfilerMonitorEvent event);
+
+typedef void (*MonoProfileExceptionFunc) (MonoProfiler *prof, MonoObject *object);
+typedef void (*MonoProfileExceptionClauseFunc) (MonoProfiler *prof, MonoMethod *method, int clause_type, int clause_num);
 
 typedef void (*MonoProfileAppDomainResult)(MonoProfiler *prof, MonoDomain   *domain,   int result);
 typedef void (*MonoProfileMethodResult)   (MonoProfiler *prof, MonoMethod   *method,   int result);
+typedef void (*MonoProfileJitResult)      (MonoProfiler *prof, MonoMethod   *method,   MonoJitInfo* jinfo,   int result);
 typedef void (*MonoProfileClassResult)    (MonoProfiler *prof, MonoClass    *klass,    int result);
 typedef void (*MonoProfileModuleResult)   (MonoProfiler *prof, MonoImage    *module,   int result);
 typedef void (*MonoProfileAssemblyResult) (MonoProfiler *prof, MonoAssembly *assembly, int result);
 
 typedef void (*MonoProfileMethodInline)   (MonoProfiler *prof, MonoMethod   *parent, MonoMethod *child, int *ok);
 
-typedef void (*MonoProfileThreadFunc)     (MonoProfiler *prof, guint32 tid);
+typedef void (*MonoProfileThreadFunc)     (MonoProfiler *prof, uintptr_t tid);
+typedef void (*MonoProfileThreadNameFunc) (MonoProfiler *prof, uintptr_t tid, const char *name);
 typedef void (*MonoProfileAllocFunc)      (MonoProfiler *prof, MonoObject *obj, MonoClass *klass);
-typedef void (*MonoProfileStatFunc)       (MonoProfiler *prof, guchar *ip, void *context);
+typedef void (*MonoProfileStatFunc)       (MonoProfiler *prof, mono_byte *ip, void *context);
+typedef void (*MonoProfileStatCallChainFunc) (MonoProfiler *prof, int call_chain_depth, mono_byte **ip, void *context);
 typedef void (*MonoProfileGCFunc)         (MonoProfiler *prof, MonoGCEvent event, int generation);
-typedef void (*MonoProfileGCResizeFunc)   (MonoProfiler *prof, gint64 new_size);
+typedef void (*MonoProfileGCMoveFunc)     (MonoProfiler *prof, void **objects, int num);
+typedef void (*MonoProfileGCResizeFunc)   (MonoProfiler *prof, int64_t new_size);
+typedef void (*MonoProfileGCHandleFunc)   (MonoProfiler *prof, int op, int type, uintptr_t handle, MonoObject *obj);
+typedef void (*MonoProfileGCRootFunc)     (MonoProfiler *prof, int num_roots, void **objects, int *root_types, uintptr_t *extra_info);
+
+typedef void (*MonoProfileIomapFunc) (MonoProfiler *prof, const char *report, const char *pathname, const char *new_pathname);
 
-typedef gboolean (*MonoProfileCoverageFilterFunc)   (MonoProfiler *prof, MonoMethod *method);
+typedef mono_bool (*MonoProfileCoverageFilterFunc)   (MonoProfiler *prof, MonoMethod *method);
 
 typedef void (*MonoProfileCoverageFunc)   (MonoProfiler *prof, const MonoProfileCoverageEntry *entry);
 
+typedef void (*MonoProfilerCodeChunkNew) (MonoProfiler *prof, void* chunk, int size);
+typedef void (*MonoProfilerCodeChunkDestroy) (MonoProfiler *prof, void* chunk);
+typedef void (*MonoProfilerCodeBufferNew) (MonoProfiler *prof, void* buffer, int size, MonoProfilerCodeBufferType type, void *data);
+
 /*
  * Function the profiler may call.
  */
@@ -101,18 +166,34 @@ void mono_profiler_install_class       (MonoProfileClassFunc start_load, MonoPro
                                         MonoProfileClassFunc start_unload, MonoProfileClassFunc end_unload);
 
 void mono_profiler_install_jit_compile (MonoProfileMethodFunc start, MonoProfileMethodResult end);
+void mono_profiler_install_jit_end (MonoProfileJitResult end);
+void mono_profiler_install_method_free (MonoProfileMethodFunc callback);
+void mono_profiler_install_method_invoke (MonoProfileMethodFunc start, MonoProfileMethodFunc end);
 void mono_profiler_install_enter_leave (MonoProfileMethodFunc enter, MonoProfileMethodFunc fleave);
 void mono_profiler_install_thread      (MonoProfileThreadFunc start, MonoProfileThreadFunc end);
+void mono_profiler_install_thread_name (MonoProfileThreadNameFunc thread_name_cb);
 void mono_profiler_install_transition  (MonoProfileMethodResult callback);
 void mono_profiler_install_allocation  (MonoProfileAllocFunc callback);
+void mono_profiler_install_monitor     (MonoProfileMonitorFunc callback);
 void mono_profiler_install_statistical (MonoProfileStatFunc callback);
+void mono_profiler_install_statistical_call_chain (MonoProfileStatCallChainFunc callback, int call_chain_depth, MonoProfilerCallChainStrategy call_chain_strategy);
+void mono_profiler_install_exception   (MonoProfileExceptionFunc throw_callback, MonoProfileMethodFunc exc_method_leave, MonoProfileExceptionClauseFunc clause_callback);
 void mono_profiler_install_coverage_filter (MonoProfileCoverageFilterFunc callback);
 void mono_profiler_coverage_get  (MonoProfiler *prof, MonoMethod *method, MonoProfileCoverageFunc func);
 void mono_profiler_install_gc    (MonoProfileGCFunc callback, MonoProfileGCResizeFunc heap_resize_callback);
+void mono_profiler_install_gc_moves    (MonoProfileGCMoveFunc callback);
+void mono_profiler_install_gc_roots    (MonoProfileGCHandleFunc handle_callback, MonoProfileGCRootFunc roots_callback);
+void mono_profiler_install_runtime_initialized (MonoProfileFunc runtime_initialized_callback);
+
+void mono_profiler_install_code_chunk_new (MonoProfilerCodeChunkNew callback);
+void mono_profiler_install_code_chunk_destroy (MonoProfilerCodeChunkDestroy callback);
+void mono_profiler_install_code_buffer_new (MonoProfilerCodeBufferNew callback);
+
+void mono_profiler_install_iomap (MonoProfileIomapFunc callback);
 
 void mono_profiler_load             (const char *desc);
 
-G_END_DECLS
+MONO_END_DECLS
 
 #endif /* __MONO_PROFILER_H__ */