[profiler] Implement call context introspection for enter/leave events.
[mono.git] / mono / profiler / log.c
index aab2036e6c177ea6d09155cba007b9c111c0874a..90f7309884796a55ac57dfb19aa89a76a192bffd 100644 (file)
@@ -1760,7 +1760,7 @@ class_loaded (MonoProfiler *prof, MonoClass *klass)
 }
 
 static void
-method_enter (MonoProfiler *prof, MonoMethod *method)
+method_enter (MonoProfiler *prof, MonoMethod *method, MonoProfilerCallContext *ctx)
 {
        if (get_thread ()->call_depth++ <= log_config.max_call_depth) {
                ENTER_LOG (&method_entries_ctr, logbuffer,
@@ -1776,7 +1776,7 @@ method_enter (MonoProfiler *prof, MonoMethod *method)
 }
 
 static void
-method_leave (MonoProfiler *prof, MonoMethod *method)
+method_leave (MonoProfiler *prof, MonoMethod *method, MonoProfilerCallContext *ctx)
 {
        if (--get_thread ()->call_depth <= log_config.max_call_depth) {
                ENTER_LOG (&method_exits_ctr, logbuffer,
@@ -3523,7 +3523,7 @@ log_shutdown (MonoProfiler *prof)
        char c = 1;
 
        if (write (prof->pipes [1], &c, 1) != 1) {
-               mono_profiler_printf_err ("Could not write to log profiler pipe: %s", strerror (errno));
+               mono_profiler_printf_err ("Could not write to log profiler pipe: %s", g_strerror (errno));
                exit (1);
        }
 
@@ -3737,7 +3737,7 @@ helper_thread (void *arg)
                        if (errno == EINTR)
                                continue;
 
-                       mono_profiler_printf_err ("Could not poll in log profiler helper thread: %s", strerror (errno));
+                       mono_profiler_printf_err ("Could not poll in log profiler helper thread: %s", g_strerror (errno));
                        exit (1);
                }
 
@@ -3815,14 +3815,14 @@ static void
 start_helper_thread (void)
 {
        if (pipe (log_profiler.pipes) == -1) {
-               mono_profiler_printf_err ("Could not create log profiler pipe: %s", strerror (errno));
+               mono_profiler_printf_err ("Could not create log profiler pipe: %s", g_strerror (errno));
                exit (1);
        }
 
        log_profiler.server_socket = socket (PF_INET, SOCK_STREAM, 0);
 
        if (log_profiler.server_socket == -1) {
-               mono_profiler_printf_err ("Could not create log profiler server socket: %s", strerror (errno));
+               mono_profiler_printf_err ("Could not create log profiler server socket: %s", g_strerror (errno));
                exit (1);
        }
 
@@ -3834,13 +3834,13 @@ start_helper_thread (void)
        server_address.sin_port = htons (log_profiler.command_port);
 
        if (bind (log_profiler.server_socket, (struct sockaddr *) &server_address, sizeof (server_address)) == -1) {
-               mono_profiler_printf_err ("Could not bind log profiler server socket on port %d: %s", log_profiler.command_port, strerror (errno));
+               mono_profiler_printf_err ("Could not bind log profiler server socket on port %d: %s", log_profiler.command_port, g_strerror (errno));
                close (log_profiler.server_socket);
                exit (1);
        }
 
        if (listen (log_profiler.server_socket, 1) == -1) {
-               mono_profiler_printf_err ("Could not listen on log profiler server socket: %s", strerror (errno));
+               mono_profiler_printf_err ("Could not listen on log profiler server socket: %s", g_strerror (errno));
                close (log_profiler.server_socket);
                exit (1);
        }
@@ -3848,7 +3848,7 @@ start_helper_thread (void)
        socklen_t slen = sizeof (server_address);
 
        if (getsockname (log_profiler.server_socket, (struct sockaddr *) &server_address, &slen)) {
-               mono_profiler_printf_err ("Could not retrieve assigned port for log profiler server socket: %s", strerror (errno));
+               mono_profiler_printf_err ("Could not retrieve assigned port for log profiler server socket: %s", g_strerror (errno));
                close (log_profiler.server_socket);
                exit (1);
        }
@@ -4626,28 +4626,11 @@ create_profiler (const char *args, const char *filename, GPtrArray *filters)
        log_profiler.startup_time = current_time ();
 }
 
-/*
- * declaration to silence the compiler: this is the entry point that
- * mono will load from the shared library and call.
- */
-extern void
-mono_profiler_init (const char *desc);
-
-extern void
+MONO_API void
 mono_profiler_init_log (const char *desc);
 
-/*
- * this is the entry point that will be used when the profiler
- * is embedded inside the main executable.
- */
 void
 mono_profiler_init_log (const char *desc)
-{
-       mono_profiler_init (desc);
-}
-
-void
-mono_profiler_init (const char *desc)
 {
        GPtrArray *filters = NULL;
 
@@ -4670,7 +4653,7 @@ mono_profiler_init (const char *desc)
 
        mono_lls_init (&log_profiler.profiler_thread_list, NULL);
 
-       MonoProfilerHandle handle = log_profiler.handle = mono_profiler_install (&log_profiler);
+       MonoProfilerHandle handle = log_profiler.handle = mono_profiler_create (&log_profiler);
 
        /*
         * Required callbacks. These are either necessary for the profiler itself