mscoree: Update for mono profiler api v2.

Vincent Povirk vincent at codeweavers.com
Fri Jul 21 13:27:07 CDT 2017


Mono completely changed this API last month.

Signed-off-by: Vincent Povirk <vincent at codeweavers.com>
---
 dlls/mscoree/metahost.c        | 17 ++++++++++++++++-
 dlls/mscoree/mscoree_private.h |  3 +++
 2 files changed, 19 insertions(+), 1 deletion(-)

diff --git a/dlls/mscoree/metahost.c b/dlls/mscoree/metahost.c
index a99880d..998a335 100644
--- a/dlls/mscoree/metahost.c
+++ b/dlls/mscoree/metahost.c
@@ -96,6 +96,8 @@ MonoMethod* (CDECL *mono_object_get_virtual_method)(MonoObject *obj, MonoMethod
 MonoObject* (CDECL *mono_object_new)(MonoDomain *domain, MonoClass *klass);
 void* (CDECL *mono_object_unbox)(MonoObject *obj);
 static void (CDECL *mono_profiler_install)(MonoProfiler *prof, MonoProfileFunc shutdown_callback);
+static MonoProfilerHandle (CDECL *mono_profiler_install_v2)(MonoProfiler *prof);
+static void (CDECL *mono_profiler_set_runtime_shutdown_begin_callback)(MonoProfilerHandle handle, MonoProfilerRuntimeShutdownBeginCallback cb);
 MonoType* (CDECL *mono_reflection_type_from_name)(char *name, MonoImage *image);
 MonoObject* (CDECL *mono_runtime_invoke)(MonoMethod *method, void *obj, void **params, MonoObject **exc);
 void (CDECL *mono_runtime_object_init)(MonoObject *this_obj);
@@ -222,13 +224,26 @@ static HRESULT load_mono(LPCWSTR mono_path)
 } while (0);
 
         LOAD_OPT_MONO_FUNCTION(mono_image_open_from_module_handle, image_open_module_handle_dummy);
+        LOAD_OPT_MONO_FUNCTION(mono_profiler_set_runtime_shutdown_begin_callback, NULL);
         LOAD_OPT_MONO_FUNCTION(mono_set_crash_chaining, set_crash_chaining_dummy);
         LOAD_OPT_MONO_FUNCTION(mono_trace_set_print_handler, set_print_handler_dummy);
         LOAD_OPT_MONO_FUNCTION(mono_trace_set_printerr_handler, set_print_handler_dummy);
 
 #undef LOAD_OPT_MONO_FUNCTION
 
-        mono_profiler_install(NULL, mono_shutdown_callback_fn);
+        mono_profiler_install_v2 = (void*)mono_profiler_install;
+
+        if (mono_profiler_set_runtime_shutdown_begin_callback != NULL)
+        {
+            /* Profiler API v2 */
+            MonoProfilerHandle handle = mono_profiler_install_v2(NULL);
+            mono_profiler_set_runtime_shutdown_begin_callback(handle, mono_shutdown_callback_fn);
+        }
+        else
+        {
+            /* Profiler API v1 */
+            mono_profiler_install(NULL, mono_shutdown_callback_fn);
+        }
 
         mono_set_crash_chaining(TRUE);
 
diff --git a/dlls/mscoree/mscoree_private.h b/dlls/mscoree/mscoree_private.h
index 9df41d2..000a580 100644
--- a/dlls/mscoree/mscoree_private.h
+++ b/dlls/mscoree/mscoree_private.h
@@ -56,6 +56,7 @@ typedef struct _MonoObject MonoObject;
 typedef struct _MonoString MonoString;
 typedef struct _MonoMethod MonoMethod;
 typedef struct _MonoProfiler MonoProfiler;
+typedef struct _MonoProfilerDesc *MonoProfilerHandle;
 typedef struct _MonoThread MonoThread;
 
 typedef struct RuntimeHost RuntimeHost;
@@ -135,6 +136,8 @@ typedef MonoAssembly* (CDECL *MonoAssemblyPreLoadFunc)(MonoAssemblyName *aname,
 
 typedef void (CDECL *MonoProfileFunc)(MonoProfiler *prof);
 
+typedef void (CDECL *MonoProfilerRuntimeShutdownBeginCallback) (MonoProfiler *prof);
+
 typedef void (CDECL *MonoPrintCallback) (const char *string, INT is_stdout);
 
 extern BOOL is_mono_started DECLSPEC_HIDDEN;
-- 
2.7.4




More information about the wine-patches mailing list