-
-void
-mono_debugger_check_breakpoints (MonoMethod *method, MonoDebugMethodAddress *debug_info)
-{
- int i;
-
- if (method->is_inflated)
- method = ((MonoMethodInflated *) method)->declaring;
-
- 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;
-
- mono_debugger_event (MONO_DEBUGGER_EVENT_JIT_BREAKPOINT,
- (guint64) (gsize) debug_info, info->index);
- }
- }
-
- 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;
-
- mono_debugger_event (MONO_DEBUGGER_EVENT_JIT_BREAKPOINT,
- (guint64) (gsize) debug_info, info->index);
- }
- }
-}
-
-MonoClass *
-mono_debugger_register_class_init_callback (MonoImage *image, const gchar *full_name,
- guint32 method_token, guint32 index)
-{
- ClassInitCallback *info;
- MonoClass *klass;
- gchar *name_space, *name, *pos;
-
- name = g_strdup (full_name);
-
- pos = strrchr (name, '.');
- if (pos) {
- name_space = name;
- *pos = 0;
- name = pos + 1;
- } else {
- name_space = NULL;
- }
-
- mono_loader_lock ();
-
- klass = mono_class_from_name (image, name_space ? name_space : "", name);
-
- info = g_new0 (ClassInitCallback, 1);
- info->image = image;
- info->index = index;
- info->token = method_token;
- info->name_space = name_space;
- info->name = name;
-
- if (!class_init_callbacks)
- class_init_callbacks = g_ptr_array_new ();
-
- g_ptr_array_add (class_init_callbacks, info);
- mono_loader_unlock ();
- return klass;
-}
-
-void
-mono_debugger_remove_class_init_callback (int index)
-{
- int i;
-
- 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 (info->index != index)
- continue;
-
- g_ptr_array_remove (class_init_callbacks, info);
- if (info->name_space)
- g_free (info->name_space);
- else
- g_free (info->name);
- g_free (info);
- }
-}
-
-void
-mono_debugger_class_initialized (MonoClass *klass)
-{
- int i;
-
- if (!class_init_callbacks)
- return;
-
- again:
- for (i = 0; i < class_init_callbacks->len; i++) {
- ClassInitCallback *info = g_ptr_array_index (class_init_callbacks, i);
-
- if (info->name_space && strcmp (info->name_space, klass->name_space))
- continue;
- if (strcmp (info->name, klass->name))
- continue;
-
- mono_debugger_event (MONO_DEBUGGER_EVENT_CLASS_INITIALIZED,
- (guint64) (gsize) klass, info->index);
-
- if (info->token) {
- int j;
-
- for (j = 0; j < klass->method.count; j++) {
- if (klass->methods [j]->token != info->token)
- continue;
-
- mono_debugger_insert_method_breakpoint (klass->methods [j], info->index);
- }
- }
-
- g_ptr_array_remove (class_init_callbacks, info);
- if (info->name_space)
- g_free (info->name_space);
- else
- g_free (info->name);
- g_free (info);
- goto again;
- }
-}