Browse Source

Added NewObjectEval;

Removed some eval events

git-svn-id: svn://svn.sharpdevelop.net/sharpdevelop/trunk@1655 1ccf3a8d-04fe-1044-b7c0-cef0b8235c61
shortcuts
David Srbecký 20 years ago
parent
commit
d077473538
  1. 1
      src/AddIns/Misc/Debugger/Debugger.Core/Project/Debugger.Core.csproj
  2. 20
      src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Debugger/Internal/ManagedCallback.cs
  3. 10
      src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Debugger/NDebugger.cs
  4. 4
      src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Threads/Stepper.cs
  5. 2
      src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Threads/StepperEventArgs.cs
  6. 4
      src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Variables/Evals/Eval.CallFunctionEval.cs
  7. 57
      src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Variables/Evals/Eval.NewObjectEval.cs
  8. 4
      src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Variables/Evals/Eval.NewStringEval.cs
  9. 28
      src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Variables/Evals/Eval.cs
  10. 97
      src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Variables/Evals/NDebugger-Evals.cs

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

@ -382,6 +382,7 @@
<Compile Include="Src\Variables\Variable.cs" /> <Compile Include="Src\Variables\Variable.cs" />
<Compile Include="Src\Variables\ObjectValue.cs" /> <Compile Include="Src\Variables\ObjectValue.cs" />
<Compile Include="Src\Debugger\Util.cs" /> <Compile Include="Src\Debugger\Util.cs" />
<Compile Include="Src\Variables\Evals\Eval.NewObjectEval.cs" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<Content Include="README.TXT" /> <Content Include="README.TXT" />

20
src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Debugger/Internal/ManagedCallback.cs

@ -24,6 +24,7 @@ namespace Debugger
{ {
NDebugger debugger; NDebugger debugger;
bool pauseProcessInsteadOfContinue; bool pauseProcessInsteadOfContinue;
bool skipEventsDuringEvaluation;
public NDebugger Debugger { public NDebugger Debugger {
get { get {
@ -31,6 +32,15 @@ namespace Debugger
} }
} }
public bool SkipEventsDuringEvaluation {
get {
return skipEventsDuringEvaluation;
}
set {
skipEventsDuringEvaluation = value;
}
}
public ManagedCallback(NDebugger debugger) public ManagedCallback(NDebugger debugger)
{ {
this.debugger = debugger; this.debugger = debugger;
@ -86,7 +96,7 @@ namespace Debugger
void ExitCallback_Paused() void ExitCallback_Paused()
{ {
if (debugger.Evaluating) { if (debugger.Evaluating && skipEventsDuringEvaluation) {
// Ignore events during property evaluation // Ignore events during property evaluation
ExitCallback_Continue(); ExitCallback_Continue();
} else { } else {
@ -236,12 +246,10 @@ namespace Debugger
// Let the eval know it that the CorEval has finished // Let the eval know it that the CorEval has finished
// this will also remove the eval form PendingEvals collection // this will also remove the eval form PendingEvals collection
Eval eval = debugger.GetEval(corEval); Eval eval = debugger.GetEval(corEval);
if (eval != null) { eval.NotifyEvaluationComplete(!exception);
eval.NotifyEvaluationComplete(!exception); debugger.NotifyEvaluationComplete(eval);
}
if (debugger.PendingEvals.Count > 0) { if (debugger.SetupNextEvaluation()) {
debugger.SetupNextEvaluation(debugger.GetThread(pThread));
ExitCallback_Continue(); ExitCallback_Continue();
} else { } else {
ExitCallback_Paused(); ExitCallback_Paused();

10
src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Debugger/NDebugger.cs

@ -49,6 +49,15 @@ namespace Debugger
return managedCallback; return managedCallback;
} }
} }
public bool SkipEventsDuringEvaluation {
get {
return managedCallback.SkipEventsDuringEvaluation;
}
set {
managedCallback.SkipEventsDuringEvaluation = value;
}
}
public NDebugger() public NDebugger()
{ {
@ -127,7 +136,6 @@ namespace Debugger
pauseSession = null; pauseSession = null;
pendingEvalsCollection.Clear(); pendingEvalsCollection.Clear();
evaluating = false;
TraceMessage("Reset done"); TraceMessage("Reset done");

4
src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Threads/Stepper.cs

@ -11,7 +11,7 @@ using Debugger.Wrappers.CorDebug;
namespace Debugger namespace Debugger
{ {
class Stepper public class Stepper
{ {
public enum StepperOperation {Idle, StepIn, StepOver, StepOut}; public enum StepperOperation {Idle, StepIn, StepOver, StepOut};
@ -87,7 +87,7 @@ namespace Debugger
} }
} }
public bool IsCorStepper(ICorDebugStepper corStepper) internal bool IsCorStepper(ICorDebugStepper corStepper)
{ {
return this.corStepper == corStepper; return this.corStepper == corStepper;
} }

2
src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Threads/StepperEventArgs.cs

@ -10,7 +10,7 @@ using System;
namespace Debugger namespace Debugger
{ {
[Serializable] [Serializable]
class StepperEventArgs: DebuggerEventArgs public class StepperEventArgs: DebuggerEventArgs
{ {
Stepper stepper; Stepper stepper;

4
src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Variables/Evals/Eval.CallFunctionEval.cs

@ -95,13 +95,13 @@ namespace Debugger
if ((uint)e.ErrorCode == 0x80131C26) { if ((uint)e.ErrorCode == 0x80131C26) {
OnError("Can not evaluate in optimized code"); OnError("Can not evaluate in optimized code");
return false; return false;
} else {
throw;
} }
} }
EvalState = EvalState.Evaluating; EvalState = EvalState.Evaluating;
OnEvalStarted(new EvalEventArgs(this));
return true; return true;
} }
} }

57
src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Variables/Evals/Eval.NewObjectEval.cs

@ -0,0 +1,57 @@
// <file>
// <copyright see="prj:///doc/copyright.txt"/>
// <license see="prj:///doc/license.txt"/>
// <owner name="David Srbecký" email="dsrbecky@gmail.com"/>
// <version>$Revision$</version>
// </file>
using System;
using System.Collections;
using System.Collections.Generic;
using System.Runtime.InteropServices;
using Debugger.Wrappers.CorDebug;
namespace Debugger
{
public partial class Eval
{
class NewObjectEval: Eval
{
ICorDebugClass classToCreate;
public NewObjectEval(NDebugger debugger, ICorDebugClass classToCreate):base(debugger, false, new IExpirable[] {})
{
this.classToCreate = classToCreate;
}
internal override bool SetupEvaluation(Thread targetThread)
{
debugger.AssertPaused();
if (targetThread.IsLastFunctionNative) {
OnError("Can not evaluate because native frame is on top of stack");
return false;
}
// TODO: What if this thread is not suitable?
corEval = targetThread.CorThread.CreateEval();
try {
corEval.NewObjectNoConstructor(classToCreate);
} catch (COMException e) {
if ((uint)e.ErrorCode == 0x80131C26) {
OnError("Can not evaluate in optimized code");
return false;
} else {
throw;
}
}
EvalState = EvalState.Evaluating;
return true;
}
}
}
}

4
src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Variables/Evals/Eval.NewStringEval.cs

@ -43,13 +43,13 @@ namespace Debugger
if ((uint)e.ErrorCode == 0x80131C26) { if ((uint)e.ErrorCode == 0x80131C26) {
OnError("Can not evaluate in optimized code"); OnError("Can not evaluate in optimized code");
return false; return false;
} else {
throw;
} }
} }
EvalState = EvalState.Evaluating; EvalState = EvalState.Evaluating;
OnEvalStarted(new EvalEventArgs(this));
return true; return true;
} }
} }

28
src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Variables/Evals/Eval.cs

@ -32,9 +32,6 @@ namespace Debugger
DebugeeState debugeeStateOfResult; DebugeeState debugeeStateOfResult;
string error; string error;
public event EventHandler<EvalEventArgs> EvalStarted;
public event EventHandler<EvalEventArgs> EvalComplete;
public NDebugger Debugger { public NDebugger Debugger {
get { get {
return debugger; return debugger;
@ -49,7 +46,6 @@ namespace Debugger
evalState = value; evalState = value;
if (Evaluated) { if (Evaluated) {
debugeeStateOfResult = debugger.DebugeeState; debugeeStateOfResult = debugger.DebugeeState;
OnEvalComplete(new EvalEventArgs(this));
} }
variablele.NotifyValueChange(); variablele.NotifyValueChange();
} }
@ -119,6 +115,11 @@ namespace Debugger
return new NewStringEval(debugger, textToCreate); return new NewStringEval(debugger, textToCreate);
} }
public static Eval NewObject(NDebugger debugger, ICorDebugClass classToCreate)
{
return new NewObjectEval(debugger, classToCreate);
}
ICorDebugValue GetCorValue() ICorDebugValue GetCorValue()
{ {
switch(this.EvalState) { switch(this.EvalState) {
@ -136,10 +137,7 @@ namespace Debugger
public void ScheduleEvaluation() public void ScheduleEvaluation()
{ {
if (Evaluated || EvalState == EvalState.WaitingForRequest) { if (Evaluated || EvalState == EvalState.WaitingForRequest) {
debugger.AddEval(this); debugger.PerformEval(this);
debugger.MTA2STA.AsyncCall(delegate {
if (debugger.IsPaused) debugger.StartEvaluation();
});
EvalState = EvalState.EvaluationScheduled; EvalState = EvalState.EvaluationScheduled;
} }
} }
@ -163,20 +161,6 @@ namespace Debugger
EvalState = EvalState.EvaluatedError; EvalState = EvalState.EvaluatedError;
} }
protected virtual void OnEvalStarted(EvalEventArgs e)
{
if (EvalStarted != null) {
EvalStarted(this, e);
}
}
protected virtual void OnEvalComplete(EvalEventArgs e)
{
if (EvalComplete != null) {
EvalComplete(this, e);
}
}
internal void NotifyEvaluationComplete(bool successful) internal void NotifyEvaluationComplete(bool successful)
{ {
// Eval result should be ICorDebugHandleValue so it should survive Continue() // Eval result should be ICorDebugHandleValue so it should survive Continue()

97
src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Variables/Evals/NDebugger-Evals.cs

@ -14,49 +14,18 @@ namespace Debugger
{ {
public partial class NDebugger public partial class NDebugger
{ {
List<Eval> pendingEvalsCollection = new List<Eval>(); List<Eval> activeEvals = new List<Eval>();
bool evaluating = false; Queue<Eval> pendingEvalsCollection = new Queue<Eval>();
public event EventHandler<EvalEventArgs> EvalAdded;
public event EventHandler<EvalEventArgs> EvalCompleted;
public event EventHandler<DebuggerEventArgs> AllEvelsCompleted;
protected virtual void OnEvalAdded(EvalEventArgs e)
{
if (EvalAdded != null) {
EvalAdded(this, e);
}
}
protected virtual void OnEvalCompleted(EvalEventArgs e)
{
if (EvalCompleted != null) {
EvalCompleted(this, e);
}
}
protected virtual void OnAllEvelsCompleted(DebuggerEventArgs e)
{
if (AllEvelsCompleted != null) {
AllEvelsCompleted(this, e);
}
}
public IList<Eval> PendingEvals {
get {
return pendingEvalsCollection.AsReadOnly();
}
}
public bool Evaluating { public bool Evaluating {
get { get {
return evaluating; return activeEvals.Count > 0;
} }
} }
internal Eval GetEval(ICorDebugEval corEval) internal Eval GetEval(ICorDebugEval corEval)
{ {
return pendingEvalsCollection.Find(delegate (Eval eval) {return eval.CorEval == corEval;}); return activeEvals.Find(delegate (Eval eval) {return eval.CorEval == corEval;});
} }
/// <summary> /// <summary>
@ -64,59 +33,39 @@ namespace Debugger
/// The evaluation of pending evals should be started by calling StartEvaluation in paused stated. /// The evaluation of pending evals should be started by calling StartEvaluation in paused stated.
/// The the debugger will continue until all evals are done and will stop with PausedReason.AllEvalsComplete /// The the debugger will continue until all evals are done and will stop with PausedReason.AllEvalsComplete
/// </summary> /// </summary>
internal Eval AddEval(Eval eval) internal void PerformEval(Eval eval)
{ {
pendingEvalsCollection.Add(eval); pendingEvalsCollection.Enqueue(eval);
this.MTA2STA.AsyncCall(delegate { StartEvaluation(); });
eval.EvalComplete += EvalComplete;
OnEvalAdded(new EvalEventArgs(eval));
return eval;
} }
// Removes eval from collection and fires events for the eval void StartEvaluation()
void EvalComplete(object sender, EvalEventArgs e)
{ {
pendingEvalsCollection.Remove(e.Eval); if (this.IsPaused) {
if (this.SetupNextEvaluation()) {
OnEvalCompleted(e); this.Continue();
}
if (pendingEvalsCollection.Count == 0) {
evaluating = false;
OnAllEvelsCompleted(new DebuggerEventArgs(this));
} }
} }
// return true if there was eval to setup and it was setup internal void NotifyEvaluationComplete(Eval eval)
internal bool SetupNextEvaluation(Thread targetThread)
{ {
if (pendingEvalsCollection.Count > 0) { activeEvals.Remove(eval);
if (pendingEvalsCollection[0].SetupEvaluation(targetThread)) {
return true;
} else {
return SetupNextEvaluation(targetThread);
}
} else {
return false;
}
} }
/// <summary> // return true if there was eval to setup and it was setup
/// Starts evaluation of pending evals. internal bool SetupNextEvaluation()
/// </summary>
public bool StartEvaluation()
{ {
this.AssertPaused(); this.AssertPaused();
// TODO: Investigate other threads, are they alowed to run? while (pendingEvalsCollection.Count > 0) {
if (SetupNextEvaluation(SelectedThread)) { Eval nextEval = pendingEvalsCollection.Dequeue();
evaluating = true; if (nextEval.SetupEvaluation(this.SelectedThread)) {
this.Continue(); activeEvals.Add(nextEval);
return true; return true;
} else { }
return false;
} }
return false;
} }
} }
} }

Loading…
Cancel
Save