#define TYPE_TABLE_PTR_CHUNK_SIZE 256
#define TYPE_TABLE_CHUNK_SIZE 65536
+static guint32 debugger_lock_level = 0;
static CRITICAL_SECTION debugger_lock_mutex;
static gboolean mono_debugger_initialized = FALSE;
+static gboolean must_reload_symtabs = FALSE;
+
static GHashTable *images = NULL;
static GHashTable *type_table = NULL;
static GHashTable *class_table = NULL;
void
mono_debugger_lock (void)
{
- if (mono_debugger_initialized)
- EnterCriticalSection (&debugger_lock_mutex);
+ if (!mono_debugger_initialized) {
+ debugger_lock_level++;
+ return;
+ }
+
+ EnterCriticalSection (&debugger_lock_mutex);
+ debugger_lock_level++;
}
void
mono_debugger_unlock (void)
{
- if (mono_debugger_initialized)
- LeaveCriticalSection (&debugger_lock_mutex);
+ g_assert (debugger_lock_level > 0);
+
+ if (!mono_debugger_initialized) {
+ debugger_lock_level--;
+ return;
+ }
+
+ if (debugger_lock_level == 1) {
+ if (must_reload_symtabs) {
+ mono_debugger_event (MONO_DEBUGGER_EVENT_RELOAD_SYMTABS, NULL, 0);
+ must_reload_symtabs = FALSE;
+ }
+ }
+
+ debugger_lock_level--;
+ LeaveCriticalSection (&debugger_lock_mutex);
}
static MonoDebuggerSymbolFile *
g_assert (!mono_debugger_initialized);
InitializeCriticalSection (&debugger_lock_mutex);
+ mono_debugger_initialized = TRUE;
mono_debugger_lock ();
class_info_table = g_hash_table_new (g_direct_hash, g_direct_equal);
mono_debugger_symbol_table = symbol_table;
- mono_debugger_initialized = TRUE;
mono_debugger_unlock ();
}
mono_debugger_lock ();
info = g_hash_table_lookup (images, handle->image);
- if (info)
+ if (info) {
+ mono_debugger_unlock ();
return info;
+ }
info = allocate_symbol_file_entry (mono_debugger_symbol_table);
info->symfile = handle->symfile;
cinfo->type_info = write_class (mono_debugger_symbol_table, klass);
- mono_debugger_event (MONO_DEBUGGER_EVENT_TYPE_ADDED, NULL, 0);
+ must_reload_symtabs = TRUE;
mono_debugger_unlock ();
}
}
}
- mono_debugger_event (MONO_DEBUGGER_EVENT_METHOD_ADDED, NULL, 0);
+ must_reload_symtabs = TRUE;
}
static MonoDebuggerRangeInfo *
if (method->flags & METHOD_ATTRIBUTE_SPECIAL_NAME)
continue;
- if (g_hash_table_lookup (method_slots, GUINT_TO_POINTER (method->slot)))
- continue;
- g_hash_table_insert (method_slots, GUINT_TO_POINTER (method->slot), method);
+
+ if (method->slot != -1) {
+ if (g_hash_table_lookup (method_slots, GUINT_TO_POINTER (method->slot)))
+ continue;
+ g_hash_table_insert (method_slots, GUINT_TO_POINTER (method->slot), method);
+ }
if (method->flags & METHOD_ATTRIBUTE_STATIC) {
++num_static_methods;
MonoDebuggerSymbolFile *symfile = mono_debugger_symbol_table->symbol_files [i];
MonoType *type;
guint32 offset;
+ gchar *name;
- type = mono_reflection_type_from_name (type_name, symfile->image);
+ name = g_strdup (type_name);
+ type = mono_reflection_type_from_name (name, symfile->image);
+ g_free (name);
if (!type)
continue;
mono_debugger_unlock ();
return 0;
}
+
+gint32
+mono_debugger_lookup_assembly (const gchar *name)
+{
+ MonoAssembly *assembly;
+ MonoImageOpenStatus status;
+ int i;
+
+ mono_debugger_lock ();
+
+ again:
+ for (i = 0; i < mono_debugger_symbol_table->num_symbol_files; i++) {
+ MonoDebuggerSymbolFile *symfile = mono_debugger_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;
+}