-
-int
-mono_debugger_insert_breakpoint (const gchar *method_name, gboolean include_namespace)
-{
- MonoMethodDesc *desc;
-
- desc = mono_method_desc_new (method_name, include_namespace);
- if (!desc)
- return 0;
-
- return mono_debugger_insert_breakpoint_full (desc);
-}
-
-int
-mono_debugger_method_has_breakpoint (MonoMethod *method)
-{
- int i;
-
- if (!breakpoints || (method->wrapper_type != MONO_WRAPPER_NONE))
- return 0;
-
- for (i = 0; i < breakpoints->len; i++) {
- MonoDebuggerBreakpointInfo *info = g_ptr_array_index (breakpoints, i);
-
- if (!mono_method_desc_full_match (info->desc, method))
- continue;
-
- return info->index;
- }
-
- return 0;
-}
-
-void
-mono_debugger_breakpoint_callback (MonoMethod *method, guint32 index)
-{
- mono_debugger_event (MONO_DEBUGGER_EVENT_JIT_BREAKPOINT, (guint64) (gsize) method, index);
-}
-
-gboolean
-mono_debugger_unhandled_exception (gpointer addr, gpointer stack, MonoObject *exc)
-{
- const gchar *name;
-
- if (!mono_debugger_use_debugger)
- return FALSE;
-
- // Prevent the object from being finalized.
- last_exception = exc;
-
- name = mono_class_get_name (mono_object_get_class (exc));
- if (!strcmp (name, "ThreadAbortException")) {
- MonoThread *thread = mono_thread_current ();
- mono_debugger_event (MONO_DEBUGGER_EVENT_THREAD_ABORT, 0, thread->tid);
- mono_thread_exit ();
- }
-
- mono_debugger_event (MONO_DEBUGGER_EVENT_UNHANDLED_EXCEPTION,
- (guint64) (gsize) exc, (guint64) (gsize) addr);
- return TRUE;
-}
-
-void
-mono_debugger_handle_exception (gpointer addr, gpointer stack, MonoObject *exc)
-{
- MonoDebuggerExceptionInfo info;
-
- if (!mono_debugger_use_debugger)
- return;
-
- // Prevent the object from being finalized.
- last_exception = exc;
-
- info.stack_pointer = stack;
- info.exception_obj = exc;
- info.stop = 0;
-
- mono_debugger_event (MONO_DEBUGGER_EVENT_HANDLE_EXCEPTION, (guint64) (gsize) &info,
- (guint64) (gsize) addr);
-}
-
-gboolean
-mono_debugger_throw_exception (gpointer addr, gpointer stack, MonoObject *exc)
-{
- MonoDebuggerExceptionInfo info;
-
- if (!mono_debugger_use_debugger)
- return FALSE;
-
- // Prevent the object from being finalized.
- last_exception = exc;
-
- info.stack_pointer = stack;
- info.exception_obj = exc;
- info.stop = 0;
-
- mono_debugger_event (MONO_DEBUGGER_EVENT_THROW_EXCEPTION, (guint64) (gsize) &info,
- (guint64) (gsize) addr);
- return info.stop != 0;
-}
-
-static gchar *
-get_exception_message (MonoObject *exc)
-{
- char *message = NULL;
- MonoString *str;
- MonoMethod *method;
- MonoClass *klass;
- gint i;
-
- if (mono_object_isinst (exc, mono_defaults.exception_class)) {
- klass = exc->vtable->klass;
- method = NULL;
- while (klass && method == NULL) {
- for (i = 0; i < klass->method.count; ++i) {
- method = klass->methods [i];
- if (!strcmp ("ToString", method->name) &&
- mono_method_signature (method)->param_count == 0 &&
- method->flags & METHOD_ATTRIBUTE_VIRTUAL &&
- method->flags & METHOD_ATTRIBUTE_PUBLIC) {
- break;
- }
- method = NULL;
- }
-
- if (method == NULL)
- klass = klass->parent;
- }
-
- g_assert (method);
-
- str = (MonoString *) mono_runtime_invoke (method, exc, NULL, NULL);
- if (str)
- message = mono_string_to_utf8 (str);
- }
-
- return message;
-}
-
-MonoObject *
-mono_debugger_runtime_invoke (MonoMethod *method, void *obj, void **params, MonoObject **exc)
-{
- MonoObject *retval;
- gchar *message;
-
- if (!strcmp (method->name, ".ctor")) {
- retval = obj = mono_object_new (mono_domain_get (), method->klass);
-
- mono_runtime_invoke (method, obj, params, exc);
- } else
- retval = mono_runtime_invoke (method, obj, params, exc);
-
- if (!exc || (*exc == NULL))
- return retval;
-
- message = get_exception_message (*exc);
- if (message) {
- *exc = (MonoObject *) mono_string_new_wrapper (message);
- g_free (message);
- }
-
- return retval;
-}
-
-gboolean
-mono_debugger_lookup_type (const gchar *type_name)
-{
- int i;
- mono_debugger_lock ();
-
- for (i = 0; i < mono_symbol_table->num_symbol_files; i++) {
- MonoDebugHandle *symfile = mono_symbol_table->symbol_files [i];
- MonoType *type;
- MonoClass* klass;
- gchar *name;
-
- name = g_strdup (type_name);
- type = mono_reflection_type_from_name (name, symfile->image);
- g_free (name);
- if (!type)
- continue;
-
- klass = mono_class_from_mono_type (type);
- if (klass)
- mono_class_init (klass);
-
- mono_debugger_unlock ();
- return TRUE;
- }
-
- mono_debugger_unlock ();
- return FALSE;
-}
-
-gint32
-mono_debugger_lookup_assembly (const gchar *name)
-{
- MonoAssembly *assembly;
- MonoImageOpenStatus status;
- int i;
-
- mono_debugger_lock ();
-
- again:
- for (i = 0; i < mono_symbol_table->num_symbol_files; i++) {
- MonoDebugHandle *symfile = mono_symbol_table->symbol_files [i];
-
- if (!strcmp (symfile->image_file, name)) {
- mono_debugger_unlock ();
- return i;
- }
- }
-
- assembly = mono_assembly_open (name, &status);
-
- if (status != MONO_IMAGE_OK) {
- g_warning (G_STRLOC ": Cannot open image `%s'", name);
- mono_debugger_unlock ();
- return -1;
- }
-
- must_reload_symtabs = TRUE;
- goto again;
-}
-