Browse Source

Hopefully fixed "Process not synchronized." at ICorDebugThread.GetUserState

git-svn-id: svn://svn.sharpdevelop.net/sharpdevelop/trunk@5293 1ccf3a8d-04fe-1044-b7c0-cef0b8235c61
pull/1/head
David Srbecký 16 years ago
parent
commit
63612c3c6d
  1. 5
      src/AddIns/Debugger/Debugger.Core/Interop/MTA2STA.cs
  2. 17
      src/AddIns/Debugger/Debugger.Core/ManagedCallback.cs
  3. 3
      src/AddIns/Debugger/Debugger.Core/Process.cs

5
src/AddIns/Debugger/Debugger.Core/Interop/MTA2STA.cs

@ -70,7 +70,10 @@ namespace Debugger
/// <summary> /// <summary>
/// Performs all waiting calls on the current thread /// Performs all waiting calls on the current thread
/// </summary> /// </summary>
public bool PerformCall() /// <remarks>
/// Private - user should always drain the queue - otherwise Prcoess.RaisePausedEvents might fail
/// </remarks>
bool PerformCall()
{ {
MethodInvoker nextMethod; MethodInvoker nextMethod;
lock (pendingCalls) { lock (pendingCalls) {

17
src/AddIns/Debugger/Debugger.Core/ManagedCallback.cs

@ -5,13 +5,6 @@
// <version>$Revision$</version> // <version>$Revision$</version>
// </file> // </file>
// 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;
using System.Runtime.InteropServices; using System.Runtime.InteropServices;
using Debugger.Interop; using Debugger.Interop;
@ -22,6 +15,12 @@ namespace Debugger
/// <summary> /// <summary>
/// Handles all callbacks of a given process /// Handles all callbacks of a given process
/// </summary> /// </summary>
/// <remarks>
/// 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)
/// </remarks>
class ManagedCallback class ManagedCallback
{ {
Process process; Process process;
@ -109,13 +108,17 @@ namespace Debugger
{ {
if (process.PauseSession.PausedReason == PausedReason.EvalComplete || if (process.PauseSession.PausedReason == PausedReason.EvalComplete ||
process.PauseSession.PausedReason == PausedReason.ExceptionIntercepted) { process.PauseSession.PausedReason == PausedReason.ExceptionIntercepted) {
// TODO: There might be qued callback after EvalComplete making this unrealiable
process.DisableAllSteppers(); process.DisableAllSteppers();
process.CheckSelectedStackFrames(); process.CheckSelectedStackFrames();
// Do not set selected stack frame // Do not set selected stack frame
// Do not raise events // Do not raise events
} else { } else {
// Raise the pause event outside the callback // Raise the pause event outside the callback
// Warning: Make sure that process in not resumed in the meantime
process.Debugger.MTA2STA.AsyncCall(process.RaisePausedEvents); process.Debugger.MTA2STA.AsyncCall(process.RaisePausedEvents);
// The event might probably get called out of order when the process is running again
} }
} }

3
src/AddIns/Debugger/Debugger.Core/Process.cs

@ -308,6 +308,7 @@ namespace Debugger
/// <summary> Sets up the eviroment and raises user events </summary> /// <summary> Sets up the eviroment and raises user events </summary>
internal void RaisePausedEvents() internal void RaisePausedEvents()
{ {
AssertPaused();
DisableAllSteppers(); DisableAllSteppers();
CheckSelectedStackFrames(); CheckSelectedStackFrames();
SelectMostRecentStackFrameWithLoadedSymbols(); SelectMostRecentStackFrameWithLoadedSymbols();
@ -592,7 +593,7 @@ namespace Debugger
if (timeLeft <= TimeSpan.FromMilliseconds(10)) break; if (timeLeft <= TimeSpan.FromMilliseconds(10)) break;
//this.TraceMessage("Time left: " + timeLeft.TotalMilliseconds); //this.TraceMessage("Time left: " + timeLeft.TotalMilliseconds);
debugger.MTA2STA.WaitForCall(timeLeft); debugger.MTA2STA.WaitForCall(timeLeft);
debugger.MTA2STA.PerformCall(); debugger.MTA2STA.PerformAllCalls();
} }
if (this.HasExited) throw new ProcessExitedException(); if (this.HasExited) throw new ProcessExitedException();
} }

Loading…
Cancel
Save