Skip to content

Commit

Permalink
[Mono]: Fix Mono profiler EventPipe provider instrumentation feature. (
Browse files Browse the repository at this point in the history
…dotnet#110618)

In .NET 8 the mono profiler EventPipe provider was disabled by default.
Part of that change, the creation of Mono profiler instance was moved
but call to setup call instrumentation could do an early call to setup
callback using a profiler instance that has not yet been allocated.

Fix move call to a point where the provider has been created. Fix also
makes sure that providing a callspec at startup make sure the call
instrumentation callback lives for the lifetime of the process.
  • Loading branch information
lateralusX authored Dec 12, 2024
1 parent dfb2b8a commit 2df2fea
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/mono/mono/eventpipe/ep-rt-mono-profiler-provider.c
Original file line number Diff line number Diff line change
Expand Up @@ -2929,7 +2929,7 @@ eventpipe_provider_callback (
mono_profiler_set_thread_name_callback (_mono_profiler_provider, NULL);
}

if (_mono_profiler_provider_callspec.enabled) {
if (!_mono_profiler_provider_callspec.enabled) {
if (is_keword_enabled(live_keywords, METHOD_INSTRUMENTATION_KEYWORD)) {
mono_profiler_set_call_instrumentation_filter_callback (_mono_profiler_provider, method_instrumentation_filter_callback);
} else {
Expand Down Expand Up @@ -3012,6 +3012,8 @@ ep_rt_mono_profiler_provider_component_init (void)
if (_mono_profiler_provider_enabled) {
_mono_profiler_provider = mono_profiler_create (NULL);
_mono_heap_dump_profiler_provider = mono_profiler_create (NULL);
if (_mono_profiler_provider && _mono_profiler_provider_callspec.enabled)
mono_profiler_set_call_instrumentation_filter_callback (_mono_profiler_provider, method_instrumentation_filter_callback);
}
}

Expand Down Expand Up @@ -3172,8 +3174,6 @@ ep_rt_mono_profiler_provider_parse_options (const char *options)
mono_trace (G_LOG_LEVEL_ERROR, MONO_TRACE_DIAGNOSTICS, "Failed parsing '%s': %s", options, errstr);
g_free (errstr);
mono_callspec_cleanup (&_mono_profiler_provider_callspec);
} else {
mono_profiler_set_call_instrumentation_filter_callback (_mono_profiler_provider, method_instrumentation_filter_callback);
}
return true;
} else {
Expand Down

0 comments on commit 2df2fea

Please sign in to comment.