2003-01-05 Martin Baulig <martin@ximian.com>
authorMartin Baulig <martin@novell.com>
Sun, 5 Jan 2003 00:59:40 +0000 (00:59 -0000)
committerMartin Baulig <martin@novell.com>
Sun, 5 Jan 2003 00:59:40 +0000 (00:59 -0000)
* debug.c (mono_debugger_jit_exec): Custom version of mono_jit_exec();
this is used when we're running inside the Mono Debugger
(mono_debugger_wait): Put the waiting code into a function of its own.

* mono.c (main): Call mono_debugger_jit_exec() instead of
mono_jit_exec() if we're running inside the Mono Debugger.

svn path=/trunk/mono/; revision=10160

mono/jit/ChangeLog
mono/jit/debug.c
mono/jit/debug.h
mono/jit/mono.c

index 418f1194aa90a546b83a3b55f0ebc4a9a52fbed3..2e7d155610e9194e1f1b8da62769d7a48b4a3165 100644 (file)
@@ -1,3 +1,12 @@
+2003-01-05  Martin Baulig  <martin@ximian.com>
+
+       * debug.c (mono_debugger_jit_exec): Custom version of mono_jit_exec();
+       this is used when we're running inside the Mono Debugger 
+       (mono_debugger_wait): Put the waiting code into a function of its own.
+
+       * mono.c (main): Call mono_debugger_jit_exec() instead of
+       mono_jit_exec() if we're running inside the Mono Debugger.
+       
 2003-01-05  Martin Baulig  <martin@ximian.com>
 
        * debug.h (MonoDebugFormat): Added
index 59dfbe996183879810dcee2414b96d98dc76a8f1..ac340626d9300b287420753fd909198ca5e29a5b 100644 (file)
@@ -93,25 +93,25 @@ mono_debugger_unlock (void)
 }
 
 static void
-mono_debugger_signal (gboolean modified, gboolean wait_until_finished)
+mono_debugger_signal (gboolean modified)
 {
 #ifndef PLATFORM_WIN32
-       mono_debugger_lock ();
+       if (modified)
+               debugger_symbol_file_table_modified = TRUE;
        if (!debugger_signalled) {
                debugger_signalled = TRUE;
-               if (modified)
-                       debugger_symbol_file_table_modified = TRUE;
                pthread_cond_signal (&debugger_thread_cond);
        }
-       if (wait_until_finished)
-               must_send_finished = TRUE;
-       mono_debugger_unlock ();
+#endif
+}
 
-       if (wait_until_finished) {
-               pthread_mutex_lock (&debugger_finished_mutex);
-               pthread_cond_wait (&debugger_finished_cond, &debugger_finished_mutex);
-               pthread_mutex_unlock (&debugger_finished_mutex);
-       }
+static void
+mono_debugger_wait (void)
+{
+#ifndef PLATFORM_WIN32
+       pthread_mutex_lock (&debugger_finished_mutex);
+       pthread_cond_wait (&debugger_finished_cond, &debugger_finished_mutex);
+       pthread_mutex_unlock (&debugger_finished_mutex);
 #endif
 }
 
@@ -994,7 +994,7 @@ mono_debug_add_type (MonoClass *klass)
        if (info->symfile) {
                mono_debugger_lock ();
                mono_debug_symfile_add_type (info->symfile, klass);
-               mono_debugger_signal (TRUE, FALSE);
+               mono_debugger_signal (TRUE);
                mono_debugger_unlock ();
        }
 }
@@ -1164,7 +1164,7 @@ mono_debug_add_method (MonoFlowGraph *cfg)
 
        if (info->symfile) {
                mono_debug_symfile_add_method (info->symfile, method);
-               mono_debugger_signal (TRUE, FALSE);
+               mono_debugger_signal (TRUE);
        }
 
        mono_debugger_unlock ();
@@ -1401,6 +1401,11 @@ initialize_debugger_support ()
         * debugger attached to it.
         */
        pthread_cond_wait (&debugger_start_cond, &debugger_start_mutex);
+
+       /*
+        * We keep this mutex until mono_debugger_jit_exec().
+        */
+       pthread_mutex_lock (&debugger_thread_mutex);
 #endif
 }
 
@@ -1467,7 +1472,7 @@ debugger_compile_method (MonoMethod *method)
 
        mono_debugger_lock ();
        retval = mono_compile_method (method);
-       mono_debugger_signal (FALSE, FALSE);
+       mono_debugger_signal (FALSE);
        mono_debugger_unlock ();
        return retval;
 }
@@ -1516,5 +1521,41 @@ mono_method_has_breakpoint (MonoMethod* method, gboolean use_trampoline)
 void
 mono_debugger_trampoline_breakpoint_callback (void)
 {
-       mono_debugger_signal (FALSE, TRUE);
+       mono_debugger_lock ();
+       must_send_finished = TRUE;
+       mono_debugger_signal (FALSE);
+       mono_debugger_unlock ();
+
+       mono_debugger_wait ();
+}
+
+/*
+ * This is a custom version of mono_jit_exec() which is used when we're being run inside
+ * the Mono Debugger.
+ */
+int 
+mono_debugger_jit_exec (MonoDomain *domain, MonoAssembly *assembly, int argc, char *argv[])
+{
+       MonoImage *image = assembly->image;
+       MonoMethod *method;
+       gpointer addr;
+
+       method = mono_get_method (image, mono_image_get_entry_point (image), NULL);
+
+       addr = mono_compile_method (method);
+
+       /*
+        * The mutex has been locked in initialize_debugger_support(); we keep it locked
+        * until we compiled the main method and signalled the debugger.
+        */
+       must_send_finished = TRUE;
+       mono_debugger_signal (TRUE);
+       mono_debugger_unlock ();
+
+       /*
+        * Wait until the debugger has loaded the initial symbol tables.
+        */
+       mono_debugger_wait ();
+
+       return mono_runtime_run_main (method, argc, argv, NULL);
 }
index 39bad0eaf5ea1238d1e1c204eb080b019991dc17..d23e3983409a64ea90d18a354cece3376830f607 100644 (file)
@@ -80,6 +80,8 @@ int            mono_remove_breakpoint (int breakpint_id);
 
 void           mono_debugger_trampoline_breakpoint_callback (void);
 
+int            mono_debugger_jit_exec (MonoDomain *domain, MonoAssembly *assembly, int argc, char *argv[]);
+
 
 /* DEBUGGER PUBLIC FUNCTION:
  *
index 48aa1ec548ac715b52ad352310b7a3a9702103ca..611e39f3805f0e426ca9811f23d328cbf0586501 100644 (file)
@@ -346,7 +346,10 @@ main (int argc, char *argv [])
                        mono_insert_breakpoint_full (desc, FALSE);
                }
 
-               retval = mono_jit_exec (domain, assembly, argc - i, argv + i);
+               if (mono_debug_format == MONO_DEBUG_FORMAT_MONO_DEBUGGER)
+                       retval = mono_debugger_jit_exec (domain, assembly, argc - i, argv + i);
+               else
+                       retval = mono_jit_exec (domain, assembly, argc - i, argv + i);
        }
 
        mono_profiler_shutdown ();