This commit was manufactured by cvs2svn to create branch 'mono-1-0'.
[mono.git] / mono / metadata / profiler.h
1 #ifndef __MONO_PROFILER_H__
2 #define __MONO_PROFILER_H__
3
4 #include <mono/metadata/object.h>
5 #include <mono/metadata/appdomain.h>
6
7 typedef enum {
8         MONO_PROFILE_NONE = 0,
9         MONO_PROFILE_APPDOMAIN_EVENTS = 1 << 0,
10         MONO_PROFILE_ASSEMBLY_EVENTS  = 1 << 1,
11         MONO_PROFILE_MODULE_EVENTS    = 1 << 2,
12         MONO_PROFILE_CLASS_EVENTS     = 1 << 3,
13         MONO_PROFILE_JIT_COMPILATION  = 1 << 4,
14         MONO_PROFILE_INLINING         = 1 << 5,
15         MONO_PROFILE_EXCEPTIONS       = 1 << 6,
16         MONO_PROFILE_ALLOCATIONS      = 1 << 7,
17         MONO_PROFILE_GC               = 1 << 8,
18         MONO_PROFILE_THREADS          = 1 << 9,
19         MONO_PROFILE_REMOTING         = 1 << 10,
20         MONO_PROFILE_TRANSITIONS      = 1 << 11,
21         MONO_PROFILE_ENTER_LEAVE      = 1 << 12,
22         MONO_PROFILE_COVERAGE         = 1 << 13,
23         MONO_PROFILE_INS_COVERAGE     = 1 << 14
24 } MonoProfileFlags;
25
26 typedef enum {
27         MONO_PROFILE_OK,
28         MONO_PROFILE_FAILED
29 } MonoProfileResult;
30
31 /* coverage info */
32 typedef struct {
33         MonoMethod *method;
34         int iloffset;
35         int counter;
36         const char *filename;
37         int line;
38         int col;
39 } MonoProfileCoverageEntry;
40
41 typedef struct _MonoProfiler MonoProfiler;
42
43 /*
44  * Functions that the runtime will call on the profiler.
45  */
46
47 typedef void (*MonoProfileFunc) (MonoProfiler *prof);
48
49 typedef void (*MonoProfileAppDomainFunc) (MonoProfiler *prof, MonoDomain   *domain);
50 typedef void (*MonoProfileMethodFunc)   (MonoProfiler *prof, MonoMethod   *method);
51 typedef void (*MonoProfileClassFunc)    (MonoProfiler *prof, MonoClass    *klass);
52 typedef void (*MonoProfileModuleFunc)   (MonoProfiler *prof, MonoImage    *module);
53 typedef void (*MonoProfileAssemblyFunc) (MonoProfiler *prof, MonoAssembly *assembly);
54
55 typedef void (*MonoProfileAppDomainResult)(MonoProfiler *prof, MonoDomain   *domain,   int result);
56 typedef void (*MonoProfileMethodResult)   (MonoProfiler *prof, MonoMethod   *method,   int result);
57 typedef void (*MonoProfileClassResult)    (MonoProfiler *prof, MonoClass    *klass,    int result);
58 typedef void (*MonoProfileModuleResult)   (MonoProfiler *prof, MonoImage    *module,   int result);
59 typedef void (*MonoProfileAssemblyResult) (MonoProfiler *prof, MonoAssembly *assembly, int result);
60
61 typedef void (*MonoProfileMethodInline)   (MonoProfiler *prof, MonoMethod   *parent, MonoMethod *child, int *ok);
62
63 typedef void (*MonoProfileThreadFunc)     (MonoProfiler *prof, guint32 tid);
64 typedef void (*MonoProfileAllocFunc)      (MonoProfiler *prof, MonoObject *obj, MonoClass *klass);
65
66 typedef gboolean (*MonoProfileCoverageFilterFunc)   (MonoProfiler *prof, MonoMethod *method);
67
68 typedef void (*MonoProfileCoverageFunc)   (MonoProfiler *prof, const MonoProfileCoverageEntry *entry);
69
70 /*
71  * Function the profiler may call.
72  */
73 void mono_profiler_install       (MonoProfiler *prof, MonoProfileFunc shutdown_callback);
74 void mono_profiler_set_events    (MonoProfileFlags events);
75
76 MonoProfileFlags mono_profiler_get_events (void);
77
78 void mono_profiler_install_appdomain   (MonoProfileAppDomainFunc start_load, MonoProfileAppDomainResult end_load,
79                                         MonoProfileAppDomainFunc start_unload, MonoProfileAppDomainFunc end_unload);
80 void mono_profiler_install_assembly    (MonoProfileAssemblyFunc start_load, MonoProfileAssemblyResult end_load,
81                                         MonoProfileAssemblyFunc start_unload, MonoProfileAssemblyFunc end_unload);
82 void mono_profiler_install_module      (MonoProfileModuleFunc start_load, MonoProfileModuleResult end_load,
83                                         MonoProfileModuleFunc start_unload, MonoProfileModuleFunc end_unload);
84 void mono_profiler_install_class       (MonoProfileClassFunc start_load, MonoProfileClassResult end_load,
85                                         MonoProfileClassFunc start_unload, MonoProfileClassFunc end_unload);
86
87 void mono_profiler_install_jit_compile (MonoProfileMethodFunc start, MonoProfileMethodResult end);
88 void mono_profiler_install_enter_leave (MonoProfileMethodFunc enter, MonoProfileMethodFunc fleave);
89 void mono_profiler_install_thread      (MonoProfileThreadFunc start, MonoProfileThreadFunc end);
90 void mono_profiler_install_transition  (MonoProfileMethodResult callback);
91 void mono_profiler_install_allocation  (MonoProfileAllocFunc callback);
92 void mono_profiler_install_coverage_filter (MonoProfileCoverageFilterFunc callback);
93 void mono_profiler_coverage_get  (MonoProfiler *prof, MonoMethod *method, MonoProfileCoverageFunc func);
94
95 void mono_profiler_load             (const char *desc);
96
97 #endif /* __MONO_PROFILER_H__ */
98