From 63612c3c6d7efcfdfd602061a198dfbff33d043b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?David=20Srbeck=C3=BD?= Date: Sat, 5 Dec 2009 14:51:58 +0000 Subject: [PATCH] Hopefully fixed "Process not synchronized." at ICorDebugThread.GetUserState git-svn-id: svn://svn.sharpdevelop.net/sharpdevelop/trunk@5293 1ccf3a8d-04fe-1044-b7c0-cef0b8235c61 --- .../Debugger/Debugger.Core/Interop/MTA2STA.cs | 5 ++++- .../Debugger/Debugger.Core/ManagedCallback.cs | 17 ++++++++++------- src/AddIns/Debugger/Debugger.Core/Process.cs | 3 ++- 3 files changed, 16 insertions(+), 9 deletions(-) diff --git a/src/AddIns/Debugger/Debugger.Core/Interop/MTA2STA.cs b/src/AddIns/Debugger/Debugger.Core/Interop/MTA2STA.cs index 5282a9811b..f5dc8e8599 100644 --- a/src/AddIns/Debugger/Debugger.Core/Interop/MTA2STA.cs +++ b/src/AddIns/Debugger/Debugger.Core/Interop/MTA2STA.cs @@ -70,7 +70,10 @@ namespace Debugger /// /// Performs all waiting calls on the current thread /// - public bool PerformCall() + /// + /// Private - user should always drain the queue - otherwise Prcoess.RaisePausedEvents might fail + /// + bool PerformCall() { MethodInvoker nextMethod; lock (pendingCalls) { diff --git a/src/AddIns/Debugger/Debugger.Core/ManagedCallback.cs b/src/AddIns/Debugger/Debugger.Core/ManagedCallback.cs index 003280051e..e5b92eb54a 100644 --- a/src/AddIns/Debugger/Debugger.Core/ManagedCallback.cs +++ b/src/AddIns/Debugger/Debugger.Core/ManagedCallback.cs @@ -5,13 +5,6 @@ // $Revision$ // -// Regular expresion: -// ^{\t*}{(:Ll| )*{:i} *\(((.# {:i}, |\))|())^6\)*}\n\t*\{(.|\n)@\} -// Output: \1 - intention \2 - declaration \3 - function name \4-9 parameters - -// Replace with: -// \1\2\n\1{\n\1\tEnterCallback(PausedReason.Other, "\3");\n\1\t\n\1\tExitCallback_Continue();\n\1} - using System; using System.Runtime.InteropServices; using Debugger.Interop; @@ -22,6 +15,12 @@ namespace Debugger /// /// Handles all callbacks of a given process /// + /// + /// Note that there can be a queued callback after almost any callback. + /// In particular: + /// - After 'break' there may be more callbacks + /// - After EvalComplete there may be more callbacks (eg CreateThread from other thread) + /// class ManagedCallback { Process process; @@ -109,13 +108,17 @@ namespace Debugger { if (process.PauseSession.PausedReason == PausedReason.EvalComplete || process.PauseSession.PausedReason == PausedReason.ExceptionIntercepted) { + // TODO: There might be qued callback after EvalComplete making this unrealiable process.DisableAllSteppers(); process.CheckSelectedStackFrames(); // Do not set selected stack frame // Do not raise events } else { // Raise the pause event outside the callback + // Warning: Make sure that process in not resumed in the meantime process.Debugger.MTA2STA.AsyncCall(process.RaisePausedEvents); + + // The event might probably get called out of order when the process is running again } } diff --git a/src/AddIns/Debugger/Debugger.Core/Process.cs b/src/AddIns/Debugger/Debugger.Core/Process.cs index 682474f88f..80edab580d 100644 --- a/src/AddIns/Debugger/Debugger.Core/Process.cs +++ b/src/AddIns/Debugger/Debugger.Core/Process.cs @@ -308,6 +308,7 @@ namespace Debugger /// Sets up the eviroment and raises user events internal void RaisePausedEvents() { + AssertPaused(); DisableAllSteppers(); CheckSelectedStackFrames(); SelectMostRecentStackFrameWithLoadedSymbols(); @@ -592,7 +593,7 @@ namespace Debugger if (timeLeft <= TimeSpan.FromMilliseconds(10)) break; //this.TraceMessage("Time left: " + timeLeft.TotalMilliseconds); debugger.MTA2STA.WaitForCall(timeLeft); - debugger.MTA2STA.PerformCall(); + debugger.MTA2STA.PerformAllCalls(); } if (this.HasExited) throw new ProcessExitedException(); }