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); } } }
void mono_debug_domain_unload (MonoDomain *domain) { MonoDebugDataTable *table; if (!mono_debug_initialized) return; mono_debugger_lock (); table = g_hash_table_lookup (data_table_hash, domain); if (!table) { g_warning (G_STRLOC ": unloading unknown domain %p / %d", domain, mono_domain_get_id (domain)); mono_debugger_unlock (); return; } mono_debugger_event (MONO_DEBUGGER_EVENT_DOMAIN_UNLOAD, (guint64) (gsize) table, mono_domain_get_id (domain)); g_hash_table_remove (data_table_hash, domain); mono_debugger_unlock (); }
void mini_debugger_init (void) { if (mono_debugger_event_handler) { g_warning (G_STRLOC ": duplicate call to mono_debugger_init()!"); return; } debugger_executable_code_buffer = mono_global_codeman_reserve (EXECUTABLE_CODE_BUFFER_SIZE); mono_debugger_event_handler = debugger_event_handler; /* * Use an indirect call so gcc can't optimize it away. */ MONO_DEBUGGER__debugger_info.initialize (); debugger_init_threads (); /* * Initialize the thread manager. * * NOTE: We only reference the `MONO_DEBUGGER__debugger_info_ptr' here to prevent the * linker from removing the .mdb_debug_info section. */ mono_debugger_event (MONO_DEBUGGER_EVENT_INITIALIZE_THREAD_MANAGER, (guint64) (gssize) MONO_DEBUGGER__debugger_info_ptr, 0); }
int mini_debugger_main (MonoDomain *domain, MonoAssembly *assembly, int argc, char **argv) { MainThreadArgs main_args; MonoImage *image; MonoMethod *main_method; /* * Get and compile the main function. */ image = mono_assembly_get_image (assembly); main_method = mono_get_method (image, mono_image_get_entry_point (image), NULL); /* * Initialize managed code. */ mono_debugger_event (MONO_DEBUGGER_EVENT_INITIALIZE_MANAGED_CODE, (guint64) (gssize) main_method, 0); /* * Start the main thread and wait until it's ready. */ main_args.domain = domain; main_args.method = main_method; main_args.argc = argc; main_args.argv = argv; #if RUN_IN_SUBTHREAD mono_thread_create (domain, main_thread_handler, &main_args); #else main_thread_handler (&main_args); #endif mono_thread_manage (); /* * This will never return. */ mono_debugger_event (MONO_DEBUGGER_EVENT_WRAPPER_MAIN, 0, 0); return 0; }
/* * INTERNAL USE ONLY ! */ void _mono_debug_init_corlib (MonoDomain *domain) { if (!mono_debug_initialized) return; mono_symbol_table->corlib = mono_debug_open_image (mono_defaults.corlib, NULL, 0); mono_debugger_event (MONO_DEBUGGER_EVENT_INITIALIZE_CORLIB, (guint64) (gsize) mono_symbol_table->corlib, 0); }
void mono_debugger_check_interruption (void) { if (!_mono_debugger_interruption_request) return; mono_debugger_lock (); mono_debugger_event (MONO_DEBUGGER_EVENT_INTERRUPTION_REQUEST, 0, 0); mono_debugger_unlock (); }
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_debug_domain_create (MonoDomain *domain) { MonoDebugDataTable *table; if (!mono_debug_initialized) return; mono_debugger_lock (); table = create_data_table (domain); mono_debugger_event (MONO_DEBUGGER_EVENT_DOMAIN_CREATE, (guint64) (gsize) table, mono_domain_get_id (domain)); mono_debugger_unlock (); }
static MonoDebugHandle * mono_debug_open_image (MonoImage *image, const guint8 *raw_contents, int size) { MonoDebugHandle *handle; if (mono_image_is_dynamic (image)) return NULL; mono_debugger_lock (); handle = _mono_debug_get_image (image); if (handle != NULL) { mono_debugger_unlock (); return handle; } handle = g_new0 (MonoDebugHandle, 1); handle->index = ++next_symbol_file_id; handle->image = image; mono_image_addref (image); handle->image_file = g_strdup (mono_image_get_filename (image)); handle->type_table = create_data_table (NULL); handle->symfile = mono_debug_open_mono_symbols ( handle, raw_contents, size, _mono_debug_using_mono_debugger); mono_debug_list_add (&mono_symbol_table->symbol_files, handle); g_hash_table_insert (mono_debug_handles, image, handle); if (mono_symbol_table->corlib) mono_debugger_event (MONO_DEBUGGER_EVENT_LOAD_MODULE, (guint64) (gsize) handle, 0); mono_debugger_unlock (); return handle; }
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; } }
void mono_debug_close_image (MonoImage *image) { MonoDebugHandle *handle; if (!mono_debug_initialized) return; mono_debugger_lock (); handle = _mono_debug_get_image (image); if (!handle) { mono_debugger_unlock (); return; } mono_debugger_event (MONO_DEBUGGER_EVENT_UNLOAD_MODULE, (guint64) (gsize) handle, handle->index); mono_debug_list_remove (&mono_symbol_table->symbol_files, handle); g_hash_table_remove (mono_debug_handles, image); mono_debugger_unlock (); }
void mono_debugger_cleanup (void) { mono_debugger_event (MONO_DEBUGGER_EVENT_FINALIZE_MANAGED_CODE, 0, 0); mono_debugger_event_handler = NULL; }
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)); }
static void debugger_gc_start_world (void) { mono_debugger_event (MONO_DEBUGGER_EVENT_RELEASE_GLOBAL_THREAD_LOCK, 0, 0); }
static void debugger_gc_stop_world (void) { mono_debugger_event (MONO_DEBUGGER_EVENT_ACQUIRE_GLOBAL_THREAD_LOCK, 0, 0); }
static void debugger_gc_thread_exited (pthread_t thread, void *stack_ptr) { mono_debugger_event (MONO_DEBUGGER_EVENT_GC_THREAD_EXITED, (guint64) (gsize) stack_ptr, thread); }