#include <ws2tcpip.h>
#endif
-#ifdef PLATFORM_ANDROID
+#ifdef HOST_ANDROID
#include <linux/in.h>
#include <linux/tcp.h>
#include <sys/endian.h>
MonoClass *klass;
} EventInfo;
-/* Dummy structure used for the profiler callbacks */
-typedef struct {
- void* dummy;
-} DebuggerProfiler;
-
typedef struct {
guint8 *buf, *p, *end;
} Buffer;
#define DEBUG(level,s) do { if (G_UNLIKELY ((level) <= log_level)) { s; fflush (log_file); } } while (0)
-#ifdef PLATFORM_ANDROID
+#ifdef HOST_ANDROID
#define DEBUG_PRINTF(level, ...) do { if (G_UNLIKELY ((level) <= log_level)) { g_print (__VA_ARGS__); } } while (0)
#else
#define DEBUG_PRINTF(level, ...) do { if (G_UNLIKELY ((level) <= log_level)) { fprintf (log_file, __VA_ARGS__); fflush (log_file); } } while (0)
/* Mutex for the cond var above */
static MonoCoopMutex debugger_thread_exited_mutex;
-static DebuggerProfiler debugger_profiler;
-
/* The single step request instance */
static SingleStepReq *ss_req;
static void thread_end (MonoProfiler *prof, uintptr_t tid);
-static void appdomain_load (MonoProfiler *prof, MonoDomain *domain, int result);
+static void appdomain_load (MonoProfiler *prof, MonoDomain *domain);
static void appdomain_start_unload (MonoProfiler *prof, MonoDomain *domain);
static void invalidate_each_thread (gpointer key, gpointer value, gpointer user_data);
-static void assembly_load (MonoProfiler *prof, MonoAssembly *assembly, int result);
+static void assembly_load (MonoProfiler *prof, MonoAssembly *assembly);
static void assembly_unload (MonoProfiler *prof, MonoAssembly *assembly);
static void emit_type_load (gpointer key, gpointer type, gpointer user_data);
-static void jit_end (MonoProfiler *prof, MonoMethod *method, MonoJitInfo *jinfo, int result);
+static void jit_done (MonoProfiler *prof, MonoMethod *method, MonoJitInfo *jinfo);
+
+static void jit_failed (MonoProfiler *prof, MonoMethod *method);
+
+static void jit_end (MonoProfiler *prof, MonoMethod *method, MonoJitInfo *jinfo);
static void add_pending_breakpoints (MonoMethod *method, MonoJitInfo *jinfo);
mono_coop_mutex_init (&debugger_thread_exited_mutex);
mono_coop_cond_init (&debugger_thread_exited_cond);
- mono_profiler_install ((MonoProfiler*)&debugger_profiler, runtime_shutdown);
- mono_profiler_set_events ((MonoProfileFlags)(MONO_PROFILE_APPDOMAIN_EVENTS | MONO_PROFILE_THREADS | MONO_PROFILE_ASSEMBLY_EVENTS | MONO_PROFILE_JIT_COMPILATION | MONO_PROFILE_METHOD_EVENTS));
- mono_profiler_install_runtime_initialized (runtime_initialized);
- mono_profiler_install_appdomain (NULL, appdomain_load, appdomain_start_unload, appdomain_unload);
- mono_profiler_install_thread (thread_startup, thread_end);
- mono_profiler_install_assembly (NULL, assembly_load, assembly_unload, NULL);
- mono_profiler_install_jit_end (jit_end);
+ MonoProfilerHandle prof = mono_profiler_create (NULL);
+ mono_profiler_set_runtime_shutdown_end_callback (prof, runtime_shutdown);
+ mono_profiler_set_runtime_initialized_callback (prof, runtime_initialized);
+ mono_profiler_set_domain_loaded_callback (prof, appdomain_load);
+ mono_profiler_set_domain_unloading_callback (prof, appdomain_start_unload);
+ mono_profiler_set_domain_unloaded_callback (prof, appdomain_unload);
+ mono_profiler_set_thread_started_callback (prof, thread_startup);
+ mono_profiler_set_thread_stopped_callback (prof, thread_end);
+ mono_profiler_set_assembly_loaded_callback (prof, assembly_load);
+ mono_profiler_set_assembly_unloading_callback (prof, assembly_unload);
+ mono_profiler_set_jit_done_callback (prof, jit_done);
+ mono_profiler_set_jit_failed_callback (prof, jit_failed);
mono_native_tls_alloc (&debugger_tls_id, NULL);
return;
if (agent_config.defer) {
- /* Make sure the thread id is always set when doing deferred debugging */
if (is_debugger_thread ()) {
/* Don't suspend on events from the debugger thread */
suspend_policy = SUSPEND_POLICY_NONE;
- thread = mono_thread_get_main ();
}
- else thread = mono_thread_current ();
} else {
if (is_debugger_thread () && event != EVENT_KIND_VM_DEATH)
// FIXME: Send these with a NULL thread, don't suspend the current thread
thread = NULL;
} else {
if (!thread)
- thread = mono_thread_current ();
+ thread = is_debugger_thread () ? mono_thread_get_main () : mono_thread_current ();
if (event == EVENT_KIND_VM_START && arg != NULL)
thread = (MonoThread *)arg;
}
static void
-appdomain_load (MonoProfiler *prof, MonoDomain *domain, int result)
+appdomain_load (MonoProfiler *prof, MonoDomain *domain)
{
mono_loader_lock ();
g_hash_table_insert (domains, domain, domain);
}
static void
-assembly_load (MonoProfiler *prof, MonoAssembly *assembly, int result)
+assembly_load (MonoProfiler *prof, MonoAssembly *assembly)
{
/* Sent later in jit_end () */
dbg_lock ();
}
static void
-jit_end (MonoProfiler *prof, MonoMethod *method, MonoJitInfo *jinfo, int result)
+jit_done (MonoProfiler *prof, MonoMethod *method, MonoJitInfo *jinfo)
+{
+ jit_end (prof, method, jinfo);
+}
+
+static void
+jit_failed (MonoProfiler *prof, MonoMethod *method)
+{
+ jit_end (prof, method, NULL);
+}
+
+static void
+jit_end (MonoProfiler *prof, MonoMethod *method, MonoJitInfo *jinfo)
{
/*
* We emit type load events when the first method of the type is JITted,
send_type_load (method->klass);
- if (!result && jinfo)
+ if (jinfo)
add_pending_breakpoints (method, jinfo);
}
static MonoMethod* notify_debugger_of_wait_completion_method_cache = NULL;
static MonoMethod*
-get_notify_debugger_of_wait_completion_method ()
+get_notify_debugger_of_wait_completion_method (void)
{
if (notify_debugger_of_wait_completion_method_cache != NULL)
return notify_debugger_of_wait_completion_method_cache;
return agent_config.enabled;
}
-#if defined(PLATFORM_ANDROID) || defined(TARGET_ANDROID)
+#if defined(HOST_ANDROID) || defined(TARGET_ANDROID)
void
mono_debugger_agent_unhandled_exception (MonoException *exc)
{
MonoMethodSignature *sig;
guint8 **arg_buf;
void **args;
- MonoObject *this_arg, *res, *exc;
+ MonoObject *this_arg, *res, *exc = NULL;
MonoDomain *domain;
guint8 *this_buf;
#ifdef MONO_ARCH_SOFT_DEBUG_SUPPORTED
mono_stopwatch_start (&watch);
res = mono_runtime_try_invoke (m, m->klass->valuetype ? (gpointer) this_buf : (gpointer) this_arg, args, &exc, &error);
- if (exc == NULL && !mono_error_ok (&error)) {
+ if (!mono_error_ok (&error) && exc == NULL) {
exc = (MonoObject*) mono_error_convert_to_exception (&error);
} else {
mono_error_cleanup (&error); /* FIXME report error */