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

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

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

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

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

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

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

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

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

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

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

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

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

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

@ -32,9 +32,6 @@ namespace Debugger @@ -32,9 +32,6 @@ namespace Debugger
DebugeeState debugeeStateOfResult;
string error;
public event EventHandler<EvalEventArgs> EvalStarted;
public event EventHandler<EvalEventArgs> EvalComplete;
public NDebugger Debugger {
get {
return debugger;
@ -49,7 +46,6 @@ namespace Debugger @@ -49,7 +46,6 @@ namespace Debugger
evalState = value;
if (Evaluated) {
debugeeStateOfResult = debugger.DebugeeState;
OnEvalComplete(new EvalEventArgs(this));
}
variablele.NotifyValueChange();
}
@ -119,6 +115,11 @@ namespace Debugger @@ -119,6 +115,11 @@ namespace Debugger
return new NewStringEval(debugger, textToCreate);
}
public static Eval NewObject(NDebugger debugger, ICorDebugClass classToCreate)
{
return new NewObjectEval(debugger, classToCreate);
}
ICorDebugValue GetCorValue()
{
switch(this.EvalState) {
@ -136,10 +137,7 @@ namespace Debugger @@ -136,10 +137,7 @@ namespace Debugger
public void ScheduleEvaluation()
{
if (Evaluated || EvalState == EvalState.WaitingForRequest) {
debugger.AddEval(this);
debugger.MTA2STA.AsyncCall(delegate {
if (debugger.IsPaused) debugger.StartEvaluation();
});
debugger.PerformEval(this);
EvalState = EvalState.EvaluationScheduled;
}
}
@ -163,20 +161,6 @@ namespace Debugger @@ -163,20 +161,6 @@ namespace Debugger
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)
{
// 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 @@ -14,49 +14,18 @@ namespace Debugger
{
public partial class NDebugger
{
List<Eval> pendingEvalsCollection = new List<Eval>();
bool evaluating = false;
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();
}
}
List<Eval> activeEvals = new List<Eval>();
Queue<Eval> pendingEvalsCollection = new Queue<Eval>();
public bool Evaluating {
get {
return evaluating;
return activeEvals.Count > 0;
}
}
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>
@ -64,59 +33,39 @@ namespace Debugger @@ -64,59 +33,39 @@ namespace Debugger
/// 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
/// </summary>
internal Eval AddEval(Eval eval)
internal void PerformEval(Eval eval)
{
pendingEvalsCollection.Add(eval);
eval.EvalComplete += EvalComplete;
OnEvalAdded(new EvalEventArgs(eval));
return eval;
pendingEvalsCollection.Enqueue(eval);
this.MTA2STA.AsyncCall(delegate { StartEvaluation(); });
}
// Removes eval from collection and fires events for the eval
void EvalComplete(object sender, EvalEventArgs e)
void StartEvaluation()
{
pendingEvalsCollection.Remove(e.Eval);
OnEvalCompleted(e);
if (pendingEvalsCollection.Count == 0) {
evaluating = false;
OnAllEvelsCompleted(new DebuggerEventArgs(this));
if (this.IsPaused) {
if (this.SetupNextEvaluation()) {
this.Continue();
}
}
}
// return true if there was eval to setup and it was setup
internal bool SetupNextEvaluation(Thread targetThread)
internal void NotifyEvaluationComplete(Eval eval)
{
if (pendingEvalsCollection.Count > 0) {
if (pendingEvalsCollection[0].SetupEvaluation(targetThread)) {
return true;
} else {
return SetupNextEvaluation(targetThread);
}
} else {
return false;
}
activeEvals.Remove(eval);
}
/// <summary>
/// Starts evaluation of pending evals.
/// </summary>
public bool StartEvaluation()
// return true if there was eval to setup and it was setup
internal bool SetupNextEvaluation()
{
this.AssertPaused();
// TODO: Investigate other threads, are they alowed to run?
if (SetupNextEvaluation(SelectedThread)) {
evaluating = true;
this.Continue();
return true;
} else {
return false;
while (pendingEvalsCollection.Count > 0) {
Eval nextEval = pendingEvalsCollection.Dequeue();
if (nextEval.SetupEvaluation(this.SelectedThread)) {
activeEvals.Add(nextEval);
return true;
}
}
return false;
}
}
}

Loading…
Cancel
Save