2009-08-10 Gonzalo Paniagua Javier <gonzalo@novell.com>
[mono.git] / mono / metadata / mono-debug-debugger.c
index 1e6976af1760df6fc52624b9025bc4c48a2bab54..6755f63630980bd65f60e80a3cea1df44182be44 100644 (file)
@@ -21,6 +21,7 @@
 #include <mono/metadata/gc-internal.h>
 #include <mono/metadata/object-internals.h>
 #include <mono/metadata/class-internals.h>
+#include <mono/metadata/domain-internals.h>
 #include <mono/metadata/exception.h>
 #include <mono/metadata/mono-debug.h>
 #include <mono/metadata/mono-debug-debugger.h>
@@ -49,6 +50,14 @@ typedef struct {
        gchar *name;
 } ClassInitCallback;
 
+typedef struct {
+       guint32 id;
+       guint32 shadow_path_len;
+       gchar *shadow_path;
+       MonoDomain *domain;
+       MonoAppDomainSetup *setup;
+} AppDomainSetupInfo;
+
 static GPtrArray *class_init_callbacks = NULL;
 
 static int initialized = 0;
@@ -88,6 +97,28 @@ mono_debugger_event (MonoDebuggerEvent event, guint64 data, guint64 arg)
                (* mono_debugger_event_handler) (event, data, arg);
 }
 
+void
+mono_debugger_event_create_appdomain (MonoDomain *domain, gchar *shadow_path)
+{
+       AppDomainSetupInfo info;
+
+       info.id = mono_domain_get_id (domain);
+       info.shadow_path_len = shadow_path ? strlen (shadow_path) : 0;
+       info.shadow_path = shadow_path;
+
+       info.domain = domain;
+       info.setup = domain->setup;
+
+       mono_debugger_event (MONO_DEBUGGER_EVENT_CREATE_APPDOMAIN, (guint64) (gsize) &info, 0);
+}
+
+void
+mono_debugger_event_unload_appdomain (MonoDomain *domain)
+{
+       mono_debugger_event (MONO_DEBUGGER_EVENT_UNLOAD_APPDOMAIN,
+                            (guint64) (gsize) domain, (guint64) mono_domain_get_id (domain));
+}
+
 void
 mono_debugger_cleanup (void)
 {
@@ -163,33 +194,31 @@ mono_debugger_check_breakpoints (MonoMethod *method, MonoDebugMethodAddress *deb
 {
        int i;
 
-       if (!method_breakpoints)
-               return;
-
        if (method->is_inflated)
                method = ((MonoMethodInflated *) method)->declaring;
 
-       for (i = 0; i < method_breakpoints->len; i++) {
-               MethodBreakpointInfo *info = g_ptr_array_index (method_breakpoints, i);
+       if (method_breakpoints) {
+               for (i = 0; i < method_breakpoints->len; i++) {
+                       MethodBreakpointInfo *info = g_ptr_array_index (method_breakpoints, i);
 
-               if (method != info->method)
-                       continue;
+                       if (method != info->method)
+                               continue;
 
-               mono_debugger_event (MONO_DEBUGGER_EVENT_JIT_BREAKPOINT,
-                                    (guint64) (gsize) debug_info, info->index);
+                       mono_debugger_event (MONO_DEBUGGER_EVENT_JIT_BREAKPOINT,
+                                            (guint64) (gsize) debug_info, info->index);
+               }
        }
 
-       if (!class_init_callbacks)
-               return;
-
-       for (i = 0; i < class_init_callbacks->len; i++) {
-               ClassInitCallback *info = g_ptr_array_index (class_init_callbacks, i);
+       if (class_init_callbacks) {
+               for (i = 0; i < class_init_callbacks->len; i++) {
+                       ClassInitCallback *info = g_ptr_array_index (class_init_callbacks, i);
 
-               if ((method->token != info->token) || (method->klass->image != info->image))
-                       continue;
+                       if ((method->token != info->token) || (method->klass->image != info->image))
+                               continue;
 
-               mono_debugger_event (MONO_DEBUGGER_EVENT_JIT_BREAKPOINT,
-                                    (guint64) (gsize) debug_info, info->index);
+                       mono_debugger_event (MONO_DEBUGGER_EVENT_JIT_BREAKPOINT,
+                                            (guint64) (gsize) debug_info, info->index);
+               }
        }
 }
 
@@ -215,10 +244,6 @@ mono_debugger_register_class_init_callback (MonoImage *image, const gchar *full_
        mono_loader_lock ();
 
        klass = mono_class_from_name (image, name_space ? name_space : "", name);
-       if (klass && klass->inited && klass->methods) {
-               mono_loader_unlock ();
-               return klass;
-       }
 
        info = g_new0 (ClassInitCallback, 1);
        info->image = image;
@@ -232,7 +257,7 @@ mono_debugger_register_class_init_callback (MonoImage *image, const gchar *full_
 
        g_ptr_array_add (class_init_callbacks, info);
        mono_loader_unlock ();
-       return NULL;
+       return klass;
 }
 
 void