--- /dev/null
+// Licensed to the .NET Foundation under one or more agreements.
+// The .NET Foundation licenses this file to you under the MIT license.
+// See the LICENSE file in the project root for more information.
+
+using System;
+using System.Runtime.CompilerServices;
+using System.Runtime.InteropServices;
+
+namespace Mono.Profiler.Log {
+
+ public static class LogProfiler {
+
+ static bool? _attached;
+
+ public static bool IsAttached {
+ get {
+ if (_attached != null)
+ return (bool) _attached;
+
+ try {
+ GetMaxStackTraceFrames ();
+ return (bool) (_attached = true);
+ } catch (MissingMethodException) {
+ return (bool) (_attached = false);
+ }
+ }
+ }
+
+ [MethodImpl (MethodImplOptions.InternalCall)]
+ extern static int GetMaxStackTraceFrames ();
+
+ public static int MaxStackTraceFrames {
+ get { return GetMaxStackTraceFrames (); }
+ }
+
+ [MethodImpl (MethodImplOptions.InternalCall)]
+ extern static int GetStackTraceFrames ();
+
+ [MethodImpl (MethodImplOptions.InternalCall)]
+ extern static void SetStackTraceFrames (int value);
+
+ public static int StackTraceFrames {
+ get { return GetStackTraceFrames (); }
+ set {
+ var max = MaxStackTraceFrames;
+
+ if (value < 0 || value > max)
+ throw new ArgumentOutOfRangeException (nameof (value), value, $"Value must be between 0 and {max}.");
+
+ SetStackTraceFrames (value);
+ }
+ }
+
+ [MethodImpl (MethodImplOptions.InternalCall)]
+ extern static LogHeapshotMode GetHeapshotMode ();
+
+ [MethodImpl (MethodImplOptions.InternalCall)]
+ extern static void SetHeapshotMode (LogHeapshotMode value);
+
+ public static LogHeapshotMode HeapshotMode {
+ get { return GetHeapshotMode (); }
+ set {
+ if (!Enum.IsDefined (typeof (LogHeapshotMode), value))
+ throw new ArgumentException ("Invalid heapshot mode.", nameof (value));
+
+ SetHeapshotMode (value);
+ }
+ }
+
+ [MethodImpl (MethodImplOptions.InternalCall)]
+ extern static int GetHeapshotMillisecondsFrequency ();
+
+ [MethodImpl (MethodImplOptions.InternalCall)]
+ extern static void SetHeapshotMillisecondsFrequency (int value);
+
+ public static int HeapshotMillisecondsFrequency {
+ get { return GetHeapshotMillisecondsFrequency (); }
+ set {
+ if (value < 0)
+ throw new ArgumentOutOfRangeException (nameof (value), value, "Value must be non-negative.");
+
+ SetHeapshotMillisecondsFrequency (value);
+ }
+ }
+
+ [MethodImpl (MethodImplOptions.InternalCall)]
+ extern static int GetHeapshotCollectionsFrequency ();
+
+ [MethodImpl (MethodImplOptions.InternalCall)]
+ extern static void SetHeapshotCollectionsFrequency (int value);
+
+ public static int HeapshotCollectionsFrequency {
+ get { return GetHeapshotCollectionsFrequency (); }
+ set {
+ if (value < 0)
+ throw new ArgumentOutOfRangeException (nameof (value), value, "Value must be non-negative.");
+
+ SetHeapshotCollectionsFrequency (value);
+ }
+ }
+
+ [MethodImpl (MethodImplOptions.InternalCall)]
+ extern static int GetCallDepth ();
+
+ [MethodImpl (MethodImplOptions.InternalCall)]
+ extern static void SetCallDepth (int value);
+
+ public static int CallDepth {
+ get { return GetCallDepth (); }
+ set {
+ if (value < 0)
+ throw new ArgumentOutOfRangeException (nameof (value), value, "Value must be non-negative.");
+
+ SetCallDepth (value);
+ }
+ }
+
+ [MethodImpl (MethodImplOptions.InternalCall)]
+ extern static void GetSampleMode (out LogSampleMode mode, out int frequency);
+
+ [MethodImpl (MethodImplOptions.InternalCall)]
+ extern static bool SetSampleMode (LogSampleMode value, int frequency);
+
+ public static LogSampleMode SampleMode {
+ get {
+ GetSampleMode (out var mode, out var _);
+
+ return mode;
+ }
+ }
+
+ public static int SampleFrequency {
+ get {
+ GetSampleMode (out var _, out var frequency);
+
+ return frequency;
+ }
+ }
+
+ public static bool SetSampleParameters (LogSampleMode mode, int frequency)
+ {
+ if (!Enum.IsDefined (typeof (LogSampleMode), mode))
+ throw new ArgumentException ("Invalid sample mode.", nameof (mode));
+
+ if (frequency < 1)
+ throw new ArgumentOutOfRangeException (nameof (frequency), frequency, "Frequency must be positive.");
+
+ return SetSampleMode (mode, frequency);
+ }
+
+ [MethodImpl (MethodImplOptions.InternalCall)]
+ extern static bool GetExceptionEvents ();
+
+ [MethodImpl (MethodImplOptions.InternalCall)]
+ extern static void SetExceptionEvents (bool value);
+
+ public static bool ExceptionEventsEnabled {
+ get { return GetExceptionEvents (); }
+ set { SetExceptionEvents (value); }
+ }
+
+ [MethodImpl (MethodImplOptions.InternalCall)]
+ extern static bool GetMonitorEvents ();
+
+ [MethodImpl (MethodImplOptions.InternalCall)]
+ extern static void SetMonitorEvents (bool value);
+
+ public static bool MonitorEventsEnabled {
+ get { return GetMonitorEvents (); }
+ set { SetMonitorEvents (value); }
+ }
+
+ [MethodImpl (MethodImplOptions.InternalCall)]
+ extern static bool GetGCEvents ();
+
+ [MethodImpl (MethodImplOptions.InternalCall)]
+ extern static void SetGCEvents (bool value);
+
+ public static bool GCEventsEnabled {
+ get { return GetGCEvents (); }
+ set { SetGCEvents (value); }
+ }
+
+ [MethodImpl (MethodImplOptions.InternalCall)]
+ extern static bool GetGCAllocationEvents ();
+
+ [MethodImpl (MethodImplOptions.InternalCall)]
+ extern static void SetGCAllocationEvents (bool value);
+
+ public static bool GCAllocationEventsEnabled {
+ get { return GetGCAllocationEvents (); }
+ set { SetGCAllocationEvents (value); }
+ }
+
+ [MethodImpl (MethodImplOptions.InternalCall)]
+ extern static bool GetGCMoveEvents ();
+
+ [MethodImpl (MethodImplOptions.InternalCall)]
+ extern static void SetGCMoveEvents (bool value);
+
+ public static bool GCMoveEventsEnabled {
+ get { return GetGCMoveEvents (); }
+ set { SetGCMoveEvents (value); }
+ }
+
+ [MethodImpl (MethodImplOptions.InternalCall)]
+ extern static bool GetGCRootEvents ();
+
+ [MethodImpl (MethodImplOptions.InternalCall)]
+ extern static void SetGCRootEvents (bool value);
+
+ public static bool GCRootEventsEnabled {
+ get { return GetGCRootEvents (); }
+ set { SetGCRootEvents (value); }
+ }
+
+ [MethodImpl (MethodImplOptions.InternalCall)]
+ extern static bool GetGCHandleEvents ();
+
+ [MethodImpl (MethodImplOptions.InternalCall)]
+ extern static void SetGCHandleEvents (bool value);
+
+ public static bool GCHandleEventsEnabled {
+ get { return GetGCHandleEvents (); }
+ set { SetGCHandleEvents (value); }
+ }
+
+ [MethodImpl (MethodImplOptions.InternalCall)]
+ extern static bool GetGCFinalizationEvents ();
+
+ [MethodImpl (MethodImplOptions.InternalCall)]
+ extern static void SetGCFinalizationEvents (bool value);
+
+ public static bool GCFinalizationEventsEnabled {
+ get { return GetGCFinalizationEvents (); }
+ set { SetGCFinalizationEvents (value); }
+ }
+
+ [MethodImpl (MethodImplOptions.InternalCall)]
+ extern static bool GetCounterEvents ();
+
+ [MethodImpl (MethodImplOptions.InternalCall)]
+ extern static void SetCounterEvents (bool value);
+
+ public static bool CounterEventsEnabled {
+ get { return GetCounterEvents (); }
+ set { SetCounterEvents (value); }
+ }
+
+ [MethodImpl (MethodImplOptions.InternalCall)]
+ extern static bool GetJitEvents ();
+
+ [MethodImpl (MethodImplOptions.InternalCall)]
+ extern static void SetJitEvents (bool value);
+
+ public static bool JitEventsEnabled {
+ get { return GetJitEvents (); }
+ set { SetJitEvents (value); }
+ }
+ }
+}
#include <config.h>
#include <mono/metadata/assembly.h>
+#include <mono/metadata/class-internals.h>
#include <mono/metadata/debug-helpers.h>
-#include "../metadata/metadata-internals.h"
+#include <mono/metadata/loader.h>
+#include <mono/metadata/metadata-internals.h>
#include <mono/metadata/mono-config.h>
#include <mono/metadata/mono-gc.h>
#include <mono/metadata/mono-perfcounters.h>
#include <mono/utils/lock-free-alloc.h>
#include <mono/utils/lock-free-queue.h>
#include <mono/utils/mono-conc-hashtable.h>
+#include <mono/utils/mono-coop-mutex.h>
#include <mono/utils/mono-counters.h>
#include <mono/utils/mono-logger-internals.h>
#include <mono/utils/mono-linked-list-set.h>
#endif
}
-#define ENABLED(EVT) (log_config.effective_mask & (EVT))
+#define ENABLED(EVT) (!!(log_config.effective_mask & (EVT)))
+#define ENABLE(EVT) do { log_config.effective_mask |= (EVT); } while (0)
+#define DISABLE(EVT) do { log_config.effective_mask &= ~(EVT); } while (0)
/*
* These macros should be used when writing an event to a log buffer. They
guint32 coverage_previous_offset;
guint32 coverage_method_id;
+
+ MonoCoopMutex api_mutex;
};
static ProfilerConfig log_config;
finalize_end (MonoProfiler *prof)
{
trigger_on_demand_heapshot ();
- if (ENABLED (PROFLOG_FINALIZATION_EVENTS)) {
+ if (ENABLED (PROFLOG_GC_FINALIZATION_EVENTS)) {
ENTER_LOG (&finalize_ends_ctr, buf,
EVENT_SIZE /* event */
);
mono_os_mutex_destroy (&log_profiler.coverage_mutex);
}
+ mono_coop_mutex_destroy (&log_profiler.api_mutex);
+
PROF_TLS_FREE ();
g_free (prof->args);
mono_counters_register (name, MONO_COUNTER_UINT | MONO_COUNTER_PROFILER | MONO_COUNTER_MONOTONIC, counter);
}
+ICALL_EXPORT gint32
+proflog_icall_GetMaxStackTraceFrames (void)
+{
+ return MAX_FRAMES;
+}
+
+ICALL_EXPORT gint32
+proflog_icall_GetStackTraceFrames (void)
+{
+ return log_config.num_frames;
+}
+
+ICALL_EXPORT void
+proflog_icall_SetStackTraceFrames (gint32 value)
+{
+ log_config.num_frames = value;
+}
+
+ICALL_EXPORT MonoProfilerHeapshotMode
+proflog_icall_GetHeapshotMode (void)
+{
+ return log_config.hs_mode;
+}
+
+ICALL_EXPORT void
+proflog_icall_SetHeapshotMode (MonoProfilerHeapshotMode value)
+{
+ log_config.hs_mode = value;
+}
+
+ICALL_EXPORT gint32
+proflog_icall_GetHeapshotMillisecondsFrequency (void)
+{
+ return log_config.hs_freq_ms;
+}
+
+ICALL_EXPORT void
+proflog_icall_SetHeapshotMillisecondsFrequency (gint32 value)
+{
+ log_config.hs_freq_ms = value;
+}
+
+ICALL_EXPORT gint32
+proflog_icall_GetHeapshotCollectionsFrequency (void)
+{
+ return log_config.hs_freq_gc;
+}
+
+ICALL_EXPORT void
+proflog_icall_SetHeapshotCollectionsFrequency (gint32 value)
+{
+ log_config.hs_freq_gc = value;
+}
+
+ICALL_EXPORT gint32
+proflog_icall_GetCallDepth (void)
+{
+ return log_config.max_call_depth;
+}
+
+ICALL_EXPORT void
+proflog_icall_SetCallDepth (gint32 value)
+{
+ log_config.max_call_depth = value;
+}
+
+ICALL_EXPORT void
+proflog_icall_GetSampleMode (MonoProfilerSampleMode *mode, gint32 *frequency)
+{
+ guint64 freq;
+
+ mono_profiler_get_sample_mode (log_profiler.handle, mode, &freq);
+
+ *frequency = freq;
+}
+
+ICALL_EXPORT MonoBoolean
+proflog_icall_SetSampleMode (MonoProfilerSampleMode mode, gint32 frequency)
+{
+ mono_coop_mutex_lock (&log_profiler.api_mutex);
+
+ mono_bool result = mono_profiler_set_sample_mode (log_profiler.handle, mode, frequency);
+
+ if (mode != MONO_PROFILER_SAMPLE_MODE_NONE) {
+ ENABLE (PROFLOG_SAMPLE_EVENTS);
+ mono_profiler_set_sample_hit_callback (log_profiler.handle, mono_sample_hit);
+ } else {
+ DISABLE (PROFLOG_SAMPLE_EVENTS);
+ mono_profiler_set_sample_hit_callback (log_profiler.handle, NULL);
+ }
+
+ mono_coop_mutex_unlock (&log_profiler.api_mutex);
+
+ return result;
+}
+
+ICALL_EXPORT MonoBoolean
+proflog_icall_GetExceptionEvents (void)
+{
+ return ENABLED (PROFLOG_EXCEPTION_EVENTS);
+}
+
+ICALL_EXPORT void
+proflog_icall_SetExceptionEvents (MonoBoolean value)
+{
+ mono_coop_mutex_lock (&log_profiler.api_mutex);
+
+ if (value) {
+ ENABLE (PROFLOG_EXCEPTION_EVENTS);
+ mono_profiler_set_exception_throw_callback (log_profiler.handle, throw_exc);
+ mono_profiler_set_exception_clause_callback (log_profiler.handle, clause_exc);
+ } else {
+ DISABLE (PROFLOG_EXCEPTION_EVENTS);
+ mono_profiler_set_exception_throw_callback (log_profiler.handle, NULL);
+ mono_profiler_set_exception_clause_callback (log_profiler.handle, NULL);
+ }
+
+ mono_coop_mutex_unlock (&log_profiler.api_mutex);
+}
+
+ICALL_EXPORT MonoBoolean
+proflog_icall_GetMonitorEvents (void)
+{
+ return ENABLED (PROFLOG_MONITOR_EVENTS);
+}
+
+ICALL_EXPORT void
+proflog_icall_SetMonitorEvents (MonoBoolean value)
+{
+ mono_coop_mutex_lock (&log_profiler.api_mutex);
+
+ if (value) {
+ ENABLE (PROFLOG_EXCEPTION_EVENTS);
+ mono_profiler_set_monitor_contention_callback (log_profiler.handle, monitor_contention);
+ mono_profiler_set_monitor_acquired_callback (log_profiler.handle, monitor_acquired);
+ mono_profiler_set_monitor_failed_callback (log_profiler.handle, monitor_failed);
+ } else {
+ DISABLE (PROFLOG_EXCEPTION_EVENTS);
+ mono_profiler_set_monitor_contention_callback (log_profiler.handle, NULL);
+ mono_profiler_set_monitor_acquired_callback (log_profiler.handle, NULL);
+ mono_profiler_set_monitor_failed_callback (log_profiler.handle, NULL);
+ }
+
+ mono_coop_mutex_unlock (&log_profiler.api_mutex);
+}
+
+ICALL_EXPORT MonoBoolean
+proflog_icall_GetGCEvents (void)
+{
+ return ENABLED (PROFLOG_GC_EVENTS);
+}
+
+ICALL_EXPORT void
+proflog_icall_SetGCEvents (MonoBoolean value)
+{
+ mono_coop_mutex_lock (&log_profiler.api_mutex);
+
+ if (value)
+ ENABLE (PROFLOG_GC_EVENTS);
+ else
+ DISABLE (PROFLOG_GC_EVENTS);
+
+ mono_coop_mutex_unlock (&log_profiler.api_mutex);
+}
+
+ICALL_EXPORT MonoBoolean
+proflog_icall_GetGCAllocationEvents (void)
+{
+ return ENABLED (PROFLOG_GC_ALLOCATION_EVENTS);
+}
+
+ICALL_EXPORT void
+proflog_icall_SetGCAllocationEvents (MonoBoolean value)
+{
+ mono_coop_mutex_lock (&log_profiler.api_mutex);
+
+ if (value) {
+ ENABLE (PROFLOG_GC_ALLOCATION_EVENTS);
+ mono_profiler_set_gc_allocation_callback (log_profiler.handle, gc_alloc);
+ } else {
+ DISABLE (PROFLOG_GC_ALLOCATION_EVENTS);
+ mono_profiler_set_gc_allocation_callback (log_profiler.handle, NULL);
+ }
+
+ mono_coop_mutex_unlock (&log_profiler.api_mutex);
+}
+
+ICALL_EXPORT MonoBoolean
+proflog_icall_GetGCMoveEvents (void)
+{
+ return ENABLED (PROFLOG_GC_MOVE_EVENTS);
+}
+
+ICALL_EXPORT void
+proflog_icall_SetGCMoveEvents (MonoBoolean value)
+{
+ mono_coop_mutex_lock (&log_profiler.api_mutex);
+
+ if (value) {
+ ENABLE (PROFLOG_GC_MOVE_EVENTS);
+ mono_profiler_set_gc_moves_callback (log_profiler.handle, gc_moves);
+ } else {
+ DISABLE (PROFLOG_GC_MOVE_EVENTS);
+ mono_profiler_set_gc_moves_callback (log_profiler.handle, NULL);
+ }
+
+ mono_coop_mutex_unlock (&log_profiler.api_mutex);
+}
+
+ICALL_EXPORT MonoBoolean
+proflog_icall_GetGCRootEvents (void)
+{
+ return ENABLED (PROFLOG_GC_ROOT_EVENTS);
+}
+
+ICALL_EXPORT void
+proflog_icall_SetGCRootEvents (MonoBoolean value)
+{
+ mono_coop_mutex_lock (&log_profiler.api_mutex);
+
+ if (value)
+ ENABLE (PROFLOG_GC_ROOT_EVENTS);
+ else
+ DISABLE (PROFLOG_GC_ROOT_EVENTS);
+
+ mono_coop_mutex_unlock (&log_profiler.api_mutex);
+}
+
+ICALL_EXPORT MonoBoolean
+proflog_icall_GetGCHandleEvents (void)
+{
+ return ENABLED (PROFLOG_GC_HANDLE_EVENTS);
+}
+
+ICALL_EXPORT void
+proflog_icall_SetGCHandleEvents (MonoBoolean value)
+{
+ mono_coop_mutex_lock (&log_profiler.api_mutex);
+
+ if (value) {
+ ENABLE (PROFLOG_GC_HANDLE_EVENTS);
+ mono_profiler_set_gc_handle_created_callback (log_profiler.handle, gc_handle_created);
+ mono_profiler_set_gc_handle_deleted_callback (log_profiler.handle, gc_handle_deleted);
+ } else {
+ DISABLE (PROFLOG_GC_HANDLE_EVENTS);
+ mono_profiler_set_gc_handle_created_callback (log_profiler.handle, NULL);
+ mono_profiler_set_gc_handle_deleted_callback (log_profiler.handle, NULL);
+ }
+
+ mono_coop_mutex_unlock (&log_profiler.api_mutex);
+}
+
+ICALL_EXPORT MonoBoolean
+proflog_icall_GetGCFinalizationEvents (void)
+{
+ return ENABLED (PROFLOG_GC_FINALIZATION_EVENTS);
+}
+
+ICALL_EXPORT void
+proflog_icall_SetGCFinalizationEvents (MonoBoolean value)
+{
+ mono_coop_mutex_lock (&log_profiler.api_mutex);
+
+ if (value) {
+ ENABLE (PROFLOG_GC_FINALIZATION_EVENTS);
+ mono_profiler_set_gc_finalizing_callback (log_profiler.handle, finalize_begin);
+ mono_profiler_set_gc_finalizing_object_callback (log_profiler.handle, finalize_object_begin);
+ mono_profiler_set_gc_finalized_object_callback (log_profiler.handle, finalize_object_end);
+ } else {
+ DISABLE (PROFLOG_GC_FINALIZATION_EVENTS);
+ mono_profiler_set_gc_finalizing_callback (log_profiler.handle, NULL);
+ mono_profiler_set_gc_finalizing_object_callback (log_profiler.handle, NULL);
+ mono_profiler_set_gc_finalized_object_callback (log_profiler.handle, NULL);
+ }
+
+ mono_coop_mutex_unlock (&log_profiler.api_mutex);
+}
+
+ICALL_EXPORT MonoBoolean
+proflog_icall_GetCounterEvents (void)
+{
+ return ENABLED (PROFLOG_COUNTER_EVENTS);
+}
+
+ICALL_EXPORT void
+proflog_icall_SetCounterEvents (MonoBoolean value)
+{
+ mono_coop_mutex_lock (&log_profiler.api_mutex);
+
+ if (value)
+ ENABLE (PROFLOG_COUNTER_EVENTS);
+ else
+ DISABLE (PROFLOG_COUNTER_EVENTS);
+
+ mono_coop_mutex_unlock (&log_profiler.api_mutex);
+}
+
+ICALL_EXPORT MonoBoolean
+proflog_icall_GetJitEvents (void)
+{
+ return ENABLED (PROFLOG_JIT_EVENTS);
+}
+
+ICALL_EXPORT void
+proflog_icall_SetJitEvents (MonoBoolean value)
+{
+ mono_coop_mutex_lock (&log_profiler.api_mutex);
+
+ if (value) {
+ ENABLE (PROFLOG_JIT_EVENTS);
+ mono_profiler_set_jit_code_buffer_callback (log_profiler.handle, code_buffer_new);
+ } else {
+ DISABLE (PROFLOG_JIT_EVENTS);
+ mono_profiler_set_jit_code_buffer_callback (log_profiler.handle, NULL);
+ }
+
+ mono_coop_mutex_unlock (&log_profiler.api_mutex);
+}
+
static void
runtime_initialized (MonoProfiler *profiler)
{
start_helper_thread ();
start_writer_thread ();
start_dumper_thread ();
+
+ mono_coop_mutex_init (&log_profiler.api_mutex);
+
+#define ADD_ICALL(NAME) \
+ mono_add_internal_call ("Mono.Profiler.Log.LogProfiler::" EGLIB_STRINGIFY (NAME), proflog_icall_ ## NAME);
+
+ ADD_ICALL (GetMaxStackTraceFrames);
+ ADD_ICALL (GetStackTraceFrames);
+ ADD_ICALL (SetStackTraceFrames);
+ ADD_ICALL (GetHeapshotMode);
+ ADD_ICALL (SetHeapshotMode);
+ ADD_ICALL (GetHeapshotMillisecondsFrequency);
+ ADD_ICALL (SetHeapshotMillisecondsFrequency);
+ ADD_ICALL (GetHeapshotCollectionsFrequency);
+ ADD_ICALL (SetHeapshotCollectionsFrequency);
+ ADD_ICALL (GetCallDepth);
+ ADD_ICALL (SetCallDepth);
+ ADD_ICALL (GetSampleMode);
+ ADD_ICALL (SetSampleMode);
+ ADD_ICALL (GetExceptionEvents);
+ ADD_ICALL (SetExceptionEvents);
+ ADD_ICALL (GetMonitorEvents);
+ ADD_ICALL (SetMonitorEvents);
+ ADD_ICALL (GetGCEvents);
+ ADD_ICALL (SetGCEvents);
+ ADD_ICALL (GetGCAllocationEvents);
+ ADD_ICALL (SetGCAllocationEvents);
+ ADD_ICALL (GetGCMoveEvents);
+ ADD_ICALL (SetGCMoveEvents);
+ ADD_ICALL (GetGCRootEvents);
+ ADD_ICALL (SetGCRootEvents);
+ ADD_ICALL (GetGCHandleEvents);
+ ADD_ICALL (SetGCHandleEvents);
+ ADD_ICALL (GetGCFinalizationEvents);
+ ADD_ICALL (SetGCFinalizationEvents);
+ ADD_ICALL (GetCounterEvents);
+ ADD_ICALL (SetCounterEvents);
+ ADD_ICALL (GetJitEvents);
+ ADD_ICALL (SetJitEvents);
+
+#undef ADD_ICALL
}
static void
if (ENABLED (PROFLOG_GC_EVENTS))
mono_profiler_set_gc_resize_callback (handle, gc_resize);
- if (ENABLED (PROFLOG_GC_ALLOCATION_EVENTS)) {
- mono_profiler_enable_allocations ();
+ if (ENABLED (PROFLOG_GC_ALLOCATION_EVENTS))
mono_profiler_set_gc_allocation_callback (handle, gc_alloc);
- }
if (ENABLED (PROFLOG_GC_MOVE_EVENTS))
mono_profiler_set_gc_moves_callback (handle, gc_moves);
mono_profiler_set_gc_handle_deleted_callback (handle, gc_handle_deleted);
}
- if (ENABLED (PROFLOG_FINALIZATION_EVENTS)) {
+ if (ENABLED (PROFLOG_GC_FINALIZATION_EVENTS)) {
mono_profiler_set_gc_finalizing_callback (handle, finalize_begin);
mono_profiler_set_gc_finalized_callback (handle, finalize_end);
mono_profiler_set_gc_finalizing_object_callback (handle, finalize_object_begin);
- mono_profiler_set_gc_finalized_object_callback (handle, finalize_object_end);
- } else if (log_config.hs_mode == MONO_PROFILER_HEAPSHOT_ON_DEMAND) {
- //On Demand heapshot uses the finalizer thread to force a collection and thus a heapshot
- mono_profiler_set_gc_finalized_callback (handle, finalize_end);
}
+ //On Demand heapshot uses the finalizer thread to force a collection and thus a heapshot
+ mono_profiler_set_gc_finalized_callback (handle, finalize_end);
+
if (ENABLED (PROFLOG_SAMPLE_EVENTS))
mono_profiler_set_sample_hit_callback (handle, mono_sample_hit);
if (log_config.collect_coverage)
mono_profiler_set_coverage_filter_callback (handle, coverage_filter);
+ mono_profiler_enable_allocations ();
mono_profiler_enable_sampling (handle);
/*