Retrieve thread lazily and avoid special case for defer. We were trying to get thread...
authorJonathan Chambers <joncham@gmail.com>
Fri, 25 Aug 2017 07:46:34 +0000 (03:46 -0400)
committerZoltan Varga <vargaz@gmail.com>
Fri, 25 Aug 2017 07:46:34 +0000 (03:46 -0400)
mono/mini/debugger-agent.c

index e2df12bb6e649fee475908f0c64a3e95a6e3a226..dae5ed21a1c9c053dc50fad0398c06549942855e 100644 (file)
@@ -3662,13 +3662,10 @@ process_event (EventKind event, gpointer arg, gint32 il_offset, MonoContext *ctx
                        return;
 
                if (agent_config.defer) {
-                       /* Make sure the thread id is always set when doing deferred debugging */
                        if (is_debugger_thread ()) {
                                /* Don't suspend on events from the debugger thread */
                                suspend_policy = SUSPEND_POLICY_NONE;
-                               thread = mono_thread_get_main ();
                        }
-                       else thread = mono_thread_current ();
                } else {
                        if (is_debugger_thread () && event != EVENT_KIND_VM_DEATH)
                                // FIXME: Send these with a NULL thread, don't suspend the current thread
@@ -3691,7 +3688,7 @@ process_event (EventKind event, gpointer arg, gint32 il_offset, MonoContext *ctx
                        thread = NULL;
                } else {
                        if (!thread)
-                               thread = mono_thread_current ();
+                               thread = is_debugger_thread () ? mono_thread_get_main () : mono_thread_current ();
 
                        if (event == EVENT_KIND_VM_START && arg != NULL)
                                thread = (MonoThread *)arg;