2006-04-25 Martin Baulig <martin@ximian.com>
authorMartin Baulig <martin@novell.com>
Tue, 25 Apr 2006 12:00:02 +0000 (12:00 -0000)
committerMartin Baulig <martin@novell.com>
Tue, 25 Apr 2006 12:00:02 +0000 (12:00 -0000)
* mono-debug.h (MONO_DEBUGGER_VERSION): Bump to 56.

* threads.c (mono_thread_attach): Set `thread->stack_ptr' and call
debugger_thread_created().
(debugger_gc_push_all_stacks): Don't handle the main thread in any
special way.
(mono_debugger_init_threads): Removed the `main_thread_stack' arg.
(mono_debugger_finalize_threads): New function; undo the effects
of mono_debugger_init_threads().

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

mono/metadata/ChangeLog
mono/metadata/mono-debug.h
mono/metadata/threads.c
mono/metadata/threads.h

index 4fce4bc2c5afa7f4fae28bd320cf02fa18587d35..588f3413960cec354386ca1c5f94e89029baab0b 100644 (file)
@@ -1,3 +1,15 @@
+2006-04-25  Martin Baulig  <martin@ximian.com>
+
+       * mono-debug.h (MONO_DEBUGGER_VERSION): Bump to 56.
+
+       * threads.c (mono_thread_attach): Set `thread->stack_ptr' and call
+       debugger_thread_created().
+       (debugger_gc_push_all_stacks): Don't handle the main thread in any
+       special way.
+       (mono_debugger_init_threads): Removed the `main_thread_stack' arg.
+       (mono_debugger_finalize_threads): New function; undo the effects
+       of mono_debugger_init_threads().        
+
 2006-04-24  Zoltan Varga  <vargaz@gmail.com>
 
        * image.c (mono_image_close): Tidy up trace messages.
index 89babde20a4655f9173d4a20e65197b6cc15e843..6a96d5f41986fec444c7a34edeca36c57cbe56ee 100644 (file)
@@ -177,7 +177,7 @@ struct _MonoDebugVarInfo {
        guint32 end_scope;
 };
 
-#define MONO_DEBUGGER_VERSION                          55
+#define MONO_DEBUGGER_VERSION                          56
 #define MONO_DEBUGGER_MAGIC                            0x7aff65af4253d427ULL
 
 extern MonoSymbolTable *mono_symbol_table;
index a5ef0b3e84d4322e0d18e70c505e89af280f398c..63a7d9eb043d433aa880c9cabb803727ed2997cf 100644 (file)
@@ -447,6 +447,7 @@ mono_thread_attach (MonoDomain *domain)
 
        thread->handle=thread_handle;
        thread->tid=tid;
+       thread->stack_ptr = &tid;
        MONO_OBJECT_SETREF (thread, synch_lock, mono_object_new (domain, mono_defaults.object_class));
 
        THREAD_DEBUG (g_message ("%s: Attached thread ID %"G_GSIZE_FORMAT" (handle %p)", __func__, tid, thread_handle));
@@ -458,6 +459,8 @@ mono_thread_attach (MonoDomain *domain)
        SET_CURRENT_OBJECT (thread);
        mono_domain_set (domain, TRUE);
 
+       debugger_thread_created (thread);
+
        thread_adjust_static_data (thread);
 
        if (mono_thread_attach_cb) {
@@ -2817,10 +2820,6 @@ mono_debugger_create_all_threads (void)
 
 #if MONO_DEBUGGER_SUPPORTED
 
-static guint64 debugger_main_thread_id = -1;
-static gpointer debugger_main_thread_stack_ptr = NULL;
-static gpointer debugger_main_thread_end_stack = NULL;
-
 extern void GC_push_all_stack (gpointer b, gpointer t);
 
 static void
@@ -2836,8 +2835,10 @@ debugger_gc_push_stack (gpointer key, gpointer value, gpointer user)
 
        end_stack = (thread->tid == GetCurrentThreadId ()) ? &key : thread->end_stack;
 
-       if (!end_stack || !thread->stack_ptr)
+       if (!end_stack || !thread->stack_ptr) {
+               g_warning (G_STRLOC ": Cannot push stack of thread %Lx", thread->tid);
                return;
+       }
 
        GC_push_all_stack (end_stack, thread->stack_ptr);
 }
@@ -2848,11 +2849,6 @@ debugger_gc_push_stack (gpointer key, gpointer value, gpointer user)
 static void
 debugger_gc_push_all_stacks (void)
 {
-       gpointer end_stack = (debugger_main_thread_id == GetCurrentThreadId ()) ?
-               &end_stack : debugger_main_thread_end_stack;
-
-       GC_push_all_stack (end_stack, debugger_main_thread_stack_ptr);
-
        if (threads != NULL)
                mono_g_hash_table_foreach (threads, debugger_gc_push_stack, NULL);
 }
@@ -2891,28 +2887,44 @@ static GCThreadFunctions debugger_thread_vtable = {
        debugger_gc_start_world
 };
 
+static GCThreadFunctions *old_gc_thread_vtable = NULL;
+
 /**
  * mono_debugger_init_threads:
  *
  * This is used when running inside the Mono Debugger.
  */
 void
-mono_debugger_init_threads (gpointer main_thread_stack)
+mono_debugger_init_threads (void)
 {
+       old_gc_thread_vtable = gc_thread_vtable;
        gc_thread_vtable = &debugger_thread_vtable;
+       debugger_thread_created (mono_thread_current ());
+}
 
-       debugger_main_thread_id = GetCurrentThreadId ();
-       debugger_main_thread_stack_ptr = main_thread_stack;
-
-       mono_debugger_event (MONO_DEBUGGER_EVENT_THREAD_CREATED,
-                            (guint64) (gsize) &debugger_main_thread_end_stack,
-                            debugger_main_thread_id);
+/**
+ * mono_debugger_finalize_threads:
+ *
+ * This is used when running inside the Mono Debugger.
+ * Undo the effects of mono_debugger_init_threads(); this is called
+ * prior to detaching from a process.
+ */
+void
+mono_debugger_finalize_threads (void)
+{
+       gc_thread_vtable = old_gc_thread_vtable;
 }
 
 #else /* WITH_INCLUDED_LIBGC */
 
 void
-mono_debugger_init_threads (gpointer main_thread_stack)
+mono_debugger_init_threads (void)
+{
+       g_assert_not_reached ();
+}
+
+void
+mono_debugger_finalize_threads (void)
 {
        g_assert_not_reached ();
 }
index c5acefbd284d186cc0c0e8b00e219bae402b1953..575d1529a70acf377f86434460f9949c0d50fb06 100644 (file)
@@ -64,7 +64,8 @@ extern void mono_thread_interruption_checkpoint (void);
 extern void mono_thread_force_interruption_checkpoint (void);
 extern gint32* mono_thread_interruption_request_flag (void);
 extern void mono_debugger_create_all_threads (void);
-extern void mono_debugger_init_threads (gpointer main_thread_stack);
+extern void mono_debugger_init_threads (void);
+extern void mono_debugger_finalize_threads (void);
 
 G_END_DECLS