Browse Source

Abort Evals that take more the 500 ms

git-svn-id: svn://svn.sharpdevelop.net/sharpdevelop/trunk@2903 1ccf3a8d-04fe-1044-b7c0-cef0b8235c61
shortcuts
David Srbecký 18 years ago
parent
commit
4a30ba8bb7
  1. 1
      src/AddIns/Misc/Debugger/Debugger.AddIn/Project/Debugger.AddIn.csproj
  2. 2
      src/AddIns/Misc/Debugger/Debugger.AddIn/Project/Src/TreeModel/ErrorNode.cs
  3. 24
      src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Control/Eval.cs
  4. 13
      src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Control/Process-StateControl.cs
  5. 34
      src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Internal/MTA2STA.cs

1
src/AddIns/Misc/Debugger/Debugger.AddIn/Project/Debugger.AddIn.csproj

@ -127,7 +127,6 @@ @@ -127,7 +127,6 @@
<Folder Include="Src\Expressions" />
<Folder Include="Src\TreeModel" />
<Folder Include="Src\TreeModel\Adapters" />
<Folder Include="Src\Variables" />
<ProjectReference Include="..\..\..\..\..\Libraries\NRefactory\Project\NRefactory.csproj">
<Project>{3A9AE6AA-BC07-4A2F-972C-581E3AE2F195}</Project>
<Name>NRefactory</Name>

2
src/AddIns/Misc/Debugger/Debugger.AddIn/Project/Src/TreeModel/ErrorNode.cs

@ -45,7 +45,7 @@ namespace Debugger.AddIn.TreeModel @@ -45,7 +45,7 @@ namespace Debugger.AddIn.TreeModel
ToolStripMenuItem showError;
showError = new ToolStripMenuItem();
showError.Text = ResourceService.GetString("MainWindow.Windows.Debug.LocalVariables.ShowFullError");
showError.Text = StringParser.Parse("${res:MainWindow.Windows.Debug.LocalVariables.ShowFullError}");
showError.Checked = false;
showError.Click += delegate {
using (ExceptionBox box = new ExceptionBox(error, null, false)) {

24
src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Control/Eval.cs

@ -19,6 +19,7 @@ namespace Debugger @@ -19,6 +19,7 @@ namespace Debugger
EvaluatedSuccessfully,
EvaluatedException,
EvaluatedNoResult,
EvaluatedTimeOut,
};
/// <summary>
@ -54,6 +55,7 @@ namespace Debugger @@ -54,6 +55,7 @@ namespace Debugger
case EvalState.EvaluatedSuccessfully: return result;
case EvalState.EvaluatedException: return result;
case EvalState.EvaluatedNoResult: throw new GetValueException("No return value");
case EvalState.EvaluatedTimeOut: throw new GetValueException("Timeout");
default: throw new DebuggerException("Unknown state");
}
}
@ -67,7 +69,8 @@ namespace Debugger @@ -67,7 +69,8 @@ namespace Debugger
get {
return state == EvalState.EvaluatedSuccessfully ||
state == EvalState.EvaluatedException ||
state == EvalState.EvaluatedNoResult;
state == EvalState.EvaluatedNoResult ||
state == EvalState.EvaluatedTimeOut;
}
}
@ -127,6 +130,21 @@ namespace Debugger @@ -127,6 +130,21 @@ namespace Debugger
Value WaitForResult()
{
process.WaitForPause(TimeSpan.FromMilliseconds(500));
if (!Evaluated) {
state = EvalState.EvaluatedTimeOut;
process.TraceMessage("Aboring eval: " + Description);
corEval.Abort();
process.WaitForPause(TimeSpan.FromMilliseconds(500));
if (!Evaluated) {
process.TraceMessage("Rude aboring eval: " + Description);
corEval.CastTo<ICorDebugEval2>().RudeAbort();
process.WaitForPause(TimeSpan.FromMilliseconds(500));
if (!Evaluated) {
throw new DebuggerException("Evaluation can not be stopped");
}
}
}
process.WaitForPause();
return this.Result;
}
@ -134,7 +152,9 @@ namespace Debugger @@ -134,7 +152,9 @@ namespace Debugger
internal void NotifyEvaluationComplete(bool successful)
{
// Eval result should be ICorDebugHandleValue so it should survive Continue()
if (state == EvalState.EvaluatedTimeOut) {
return;
}
if (corEval.Result == null) {
state = EvalState.EvaluatedNoResult;
} else {

13
src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Control/Process-StateControl.cs

@ -264,6 +264,19 @@ namespace Debugger @@ -264,6 +264,19 @@ namespace Debugger
if (this.HasExpired) throw new DebuggerException("Process exited before pausing");
}
public void WaitForPause(TimeSpan timeout)
{
DateTime endTime = Util.HighPrecisionTimer.Now + timeout;
while(this.IsRunning && !this.HasExpired) {
TimeSpan timeLeft = endTime - Util.HighPrecisionTimer.Now;
if (timeLeft <= TimeSpan.FromMilliseconds(10)) break;
//this.TraceMessage("Time left: " + timeLeft.TotalMilliseconds);
debugger.MTA2STA.WaitForCall(timeLeft);
debugger.MTA2STA.PerformCall();
}
if (this.HasExpired) throw new DebuggerException("Process exited before pausing");
}
/// <summary>
/// Waits until the precesses exits.
/// </summary>

34
src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Internal/MTA2STA.cs

@ -50,23 +50,39 @@ namespace Debugger.Interop @@ -50,23 +50,39 @@ namespace Debugger.Interop
pendingCallsNotEmpty.WaitOne();
}
public void WaitForCall(TimeSpan timeout)
{
pendingCallsNotEmpty.WaitOne(timeout, false);
}
/// <summary>
/// Performs all waiting calls on the current thread
/// </summary>
public void PerformAllCalls()
{
while (true) {
MethodInvoker nextMethod;
lock (pendingCalls) {
if (pendingCalls.Count > 0) {
nextMethod = pendingCalls.Dequeue();
} else {
pendingCallsNotEmpty.Reset();
return;
}
if (!PerformCall()) {
return;
}
}
}
/// <summary>
/// Performs all waiting calls on the current thread
/// </summary>
public bool PerformCall()
{
MethodInvoker nextMethod;
lock (pendingCalls) {
if (pendingCalls.Count > 0) {
nextMethod = pendingCalls.Dequeue();
} else {
pendingCallsNotEmpty.Reset();
return false;
}
nextMethod();
}
nextMethod();
return true;
}
public CallMethod CallMethod {

Loading…
Cancel
Save