2005-07-21 Atsushi Enomoto <atsushi@ximian.com>
[mono.git] / mono / metadata / mono-debug-debugger.c
index b9a64cb91334b81ff4197fa784320fed77fd4280..b20f440d4fa95b7df626dfc67a5b21c140de6ba0 100644 (file)
@@ -18,7 +18,7 @@
 static guint32 debugger_lock_level = 0;
 static CRITICAL_SECTION debugger_lock_mutex;
 static gboolean must_reload_symtabs = FALSE;
-static gboolean mono_debugger_initialized = FALSE;
+static gboolean mono_debugger_use_debugger = FALSE;
 static MonoObject *last_exception = NULL;
 
 struct _MonoDebuggerMetadataInfo {
@@ -68,11 +68,6 @@ MonoDebuggerIOLayer mono_debugger_io_layer = {
 void
 mono_debugger_lock (void)
 {
-       if (!mono_debugger_initialized) {
-               debugger_lock_level++;
-               return;
-       }
-
        EnterCriticalSection (&debugger_lock_mutex);
        debugger_lock_level++;
 }
@@ -80,23 +75,8 @@ mono_debugger_lock (void)
 void
 mono_debugger_unlock (void)
 {
-       if (debugger_lock_level <= 0) {
-               g_warning (G_STRLOC ": Attempting to release a lock which you do not own.");
-               /*
-                * Turn the assertion into a warning if we're not running in the debugger.
-                * This should never happen, though.  See bug #74830.
-                */
-               g_assert (!mono_debugger_initialized);
-               return;
-       }
-
-       if (!mono_debugger_initialized) {
-               debugger_lock_level--;
-               return;
-       }
-
        if (debugger_lock_level == 1) {
-               if (must_reload_symtabs) {
+               if (must_reload_symtabs && mono_debugger_use_debugger) {
                        mono_debugger_event (MONO_DEBUGGER_EVENT_RELOAD_SYMTABS, 0, 0);
                        must_reload_symtabs = FALSE;
                }
@@ -107,20 +87,20 @@ mono_debugger_unlock (void)
 }
 
 void
-mono_debugger_initialize (void)
+mono_debugger_initialize (gboolean use_debugger)
 {
        MONO_GC_REGISTER_ROOT (last_exception);
        
-       g_assert (!mono_debugger_initialized);
+       g_assert (!mono_debugger_use_debugger);
 
        InitializeCriticalSection (&debugger_lock_mutex);
-       mono_debugger_initialized = TRUE;
+       mono_debugger_use_debugger = use_debugger;
 }
 
 void
 mono_debugger_add_symbol_file (MonoDebugHandle *handle)
 {
-       g_assert (mono_debugger_initialized);
+       g_assert (mono_debugger_use_debugger);
 
        mono_debugger_lock ();
        mono_debugger_event (MONO_DEBUGGER_EVENT_ADD_MODULE, GPOINTER_TO_UINT (handle), 0);
@@ -321,7 +301,7 @@ mono_debugger_breakpoint_callback (MonoMethod *method, guint32 index)
 gboolean
 mono_debugger_unhandled_exception (gpointer addr, gpointer stack, MonoObject *exc)
 {
-       if (!mono_debugger_initialized)
+       if (!mono_debugger_use_debugger)
                return FALSE;
 
        // Prevent the object from being finalized.
@@ -336,7 +316,7 @@ mono_debugger_handle_exception (gpointer addr, gpointer stack, MonoObject *exc)
 {
        MonoDebuggerExceptionInfo info;
 
-       if (!mono_debugger_initialized)
+       if (!mono_debugger_use_debugger)
                return;
 
        // Prevent the object from being finalized.
@@ -355,7 +335,7 @@ mono_debugger_throw_exception (gpointer addr, gpointer stack, MonoObject *exc)
 {
        MonoDebuggerExceptionInfo info;
 
-       if (!mono_debugger_initialized)
+       if (!mono_debugger_use_debugger)
                return FALSE;
 
        // Prevent the object from being finalized.
@@ -414,9 +394,6 @@ mono_debugger_runtime_invoke (MonoMethod *method, void *obj, void **params, Mono
        MonoObject *retval;
        gchar *message;
 
-       //      g_message (G_STRLOC ": %p - %p - %p - %p", method, obj, params, exc);
-       //      g_message (G_STRLOC ": %s.%s", method->klass->name, method->name);
-
        if (!strcmp (method->name, ".ctor")) {
                retval = obj = mono_object_new (mono_domain_get (), method->klass);