The following methods can be used by dynamic profiler methods to monitor different aspects of the program.
A custom profiler will have one public method defined in the shared library which is the entry point that Mono calls at startup, it has the following signature:
void mono_profiler_startup (const char *desc)
Where "desc" is the set of arguments that were passed from the command line. This routine will call mono_profiler_install to activate the profiler and will install one or more filters (one of the various mono_profiler_install_ functions).
In addition, a profiler developer will typically call mono_profiler_set_events to register which kinds of traces should be enabled, these can be an OR-ed combination of the following:
MONO_PROFILE_NONE MONO_PROFILE_APPDOMAIN_EVENTS MONO_PROFILE_ASSEMBLY_EVENTS MONO_PROFILE_MODULE_EVENTS MONO_PROFILE_CLASS_EVENTS MONO_PROFILE_JIT_COMPILATION MONO_PROFILE_INLINING MONO_PROFILE_EXCEPTIONS MONO_PROFILE_ALLOCATIONS MONO_PROFILE_GC MONO_PROFILE_THREADS MONO_PROFILE_REMOTING MONO_PROFILE_TRANSITIONS MONO_PROFILE_ENTER_LEAVE MONO_PROFILE_COVERAGE MONO_PROFILE_INS_COVERAGE MONO_PROFILE_STATISTICAL
Developers can change the set of monitored events at runtime by calling mono_profiler_set_events.
Parameters
Remarksprof: a MonoProfiler structure pointer, or a pointer to a derived structure. callback: the function to invoke at shutdown
Use mono_profiler_install to activate profiling in the Mono runtime. Typically developers of new profilers will create a new structure whose first field is a MonoProfiler and put any extra information that they need to access from the various profiling callbacks there.
Parameters
Remarksenter: the routine to be called on each method entry fleave: the routine to be called each time a method returns
Use this routine to install routines that will be called everytime a method enters and leaves. The routines will receive as an argument the MonoMethod representing the method that is entering or leaving.
Parameters
Remarksstart: the routine to be called when the JIT process starts. end: the routine to be called when the JIT process ends.
Use this routine to install routines that will be called when JIT compilation of a method starts and completes.
Parameters
Remarksevents: an ORed set of values made up of MONO_PROFILER_ flags
The events descriped in the events argument is a set of flags that represent which profiling events must be triggered. For example if you have registered a set of methods for tracking JIT compilation start and end with mono_profiler_install_jit_compile, you will want to pass the MONO_PROFILE_JIT_COMPILATION flag to this routine. You can call mono_profile_set_events more than once and you can do this at runtime to modify which methods are invoked.
Remarks
Returns a list of active events that will be intercepted.
To support profiling modules that need to do code coverage analysis, the following routines is provided: