Browse Source

ToString disabled; Property evaluation automatically started on demand

git-svn-id: svn://svn.sharpdevelop.net/sharpdevelop/trunk@876 1ccf3a8d-04fe-1044-b7c0-cef0b8235c61
shortcuts
David Srbecký 20 years ago
parent
commit
7e99ed0dc2
  1. 36
      src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Debugger/Internal/MTA2STA.cs
  2. 8
      src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Debugger/Internal/ManagedCallback.cs
  3. 14
      src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Threads/Function.cs
  4. 21
      src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Variables/Evals/Eval.cs
  5. 86
      src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Variables/ObjectValue.cs

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

@ -94,6 +94,16 @@ namespace Debugger @@ -94,6 +94,16 @@ namespace Debugger
PerformAllCalls();
}
/// <summary>
/// Schedules invocation of method and returns immediately
/// </summary>
public WaitHandle AsyncCall(MethodInvoker callDelegate)
{
WaitHandle callDone = EnqueueCall(callDelegate);
TriggerInvoke();
return callDone;
}
public T Call<T>(MethodInvokerWithReturnValue<T> callDelegate)
{
T returnValue = default(T);
@ -117,6 +127,21 @@ namespace Debugger @@ -117,6 +127,21 @@ namespace Debugger
}
// We have the call waiting in queue, we need to call it (not waiting for it to finish)
TriggerInvoke();
// Wait for the call to finish
if (!hasReturnValue && callMethod == CallMethod.HiddenFormWithTimeout) {
// Give it 5 seconds to run
if (!callDone.WaitOne(5000, true)) {
System.Console.WriteLine("Call time out! Continuing...");
}
} else {
callDone.WaitOne();
}
}
void TriggerInvoke()
{
switch (callMethod) {
case CallMethod.DirectCall:
PerformAllCalls();
@ -129,19 +154,8 @@ namespace Debugger @@ -129,19 +154,8 @@ namespace Debugger
hiddenForm.BeginInvoke((MethodInvoker)PerformAllCalls);
break;
}
// Wait for the call to finish
if (!hasReturnValue && callMethod == CallMethod.HiddenFormWithTimeout) {
// Give it 5 seconds to run
if (!callDone.WaitOne(5000, true)) {
System.Console.WriteLine("Call time out! Continuing...");
}
} else {
callDone.WaitOne();
}
}
public static object MarshalParamTo(object param, Type outputType)
{
if (param is IntPtr) {

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

@ -395,13 +395,7 @@ namespace Debugger @@ -395,13 +395,7 @@ namespace Debugger
if (debugger.Processes.Count == 0) {
// Exit callback and then terminate the debugger
new System.Threading.Thread(
delegate() {
debugger.MTA2STA.Call(
delegate {
debugger.TerminateDebugger();
});
}).Start();
debugger.MTA2STA.AsyncCall( delegate { debugger.TerminateDebugger(); } );
}
}

14
src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Threads/Function.cs

@ -505,17 +505,19 @@ namespace Debugger @@ -505,17 +505,19 @@ namespace Debugger
Eval CreatePropertyEval(MethodProps method)
{
ICorDebugValue[] evalArgs;
ICorDebugFunction evalCorFunction;
Module.CorModule.GetFunctionFromToken(method.Token, out evalCorFunction);
return new Eval(debugger, evalCorFunction, GetEvalArgs);
}
ICorDebugValue[] GetEvalArgs()
{
if (IsStatic) {
evalArgs = new ICorDebugValue[0];
return new ICorDebugValue[0];
} else {
evalArgs = new ICorDebugValue[] {ThisValue.CorValue};
return new ICorDebugValue[] {ThisValue.CorValue};
}
Eval eval = new Eval(debugger, evalCorFunction, evalArgs);
debugger.AddEval(eval);
return eval;
}
IEnumerable<Variable> GetLocalVariablesInScope(ISymbolScope symScope)

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

@ -15,6 +15,8 @@ using Debugger.Interop.MetaData; @@ -15,6 +15,8 @@ using Debugger.Interop.MetaData;
namespace Debugger
{
delegate ICorDebugValue[] CorValuesGetter();
/// <summary>
/// This class holds information about function evaluation.
/// </summary>
@ -26,7 +28,7 @@ namespace Debugger @@ -26,7 +28,7 @@ namespace Debugger
ICorDebugEval corEval;
ICorDebugFunction corFunction;
ICorDebugValue[] args;
CorValuesGetter getArgs;
bool evaluating = false;
bool evaluated = false;
@ -77,7 +79,8 @@ namespace Debugger @@ -77,7 +79,8 @@ namespace Debugger
public bool HasExpired {
get {
return debugeeStateIDatCreation != debugger.DebugeeStateID;
return debugeeStateIDatCreation != debugger.DebugeeStateID ||
Result.IsExpired;
}
}
@ -116,12 +119,20 @@ namespace Debugger @@ -116,12 +119,20 @@ namespace Debugger
}
}
internal Eval(NDebugger debugger, ICorDebugFunction corFunction, ICorDebugValue[] args)
internal Eval(NDebugger debugger, ICorDebugFunction corFunction, CorValuesGetter getArgs)
{
this.debugger = debugger;
this.corFunction = corFunction;
this.args = args;
this.getArgs = getArgs;
this.debugeeStateIDatCreation = debugger.DebugeeStateID;
// Schedule the eval for evaluation
debugger.AddEval(this);
debugger.MTA2STA.AsyncCall(delegate {
if (debugger.IsPaused && !this.HasExpired) {
debugger.StartEvaluation();
}
});
}
/// <returns>True is setup was successful</returns>
@ -129,6 +140,8 @@ namespace Debugger @@ -129,6 +140,8 @@ namespace Debugger
{
if (!debugger.ManagedCallback.HandlingCallback) debugger.AssertPaused();
ICorDebugValue[] args = getArgs();
// TODO: What if this thread is not suitable?
targetThread.CorThread.CreateEval(out corEval);

86
src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Variables/ObjectValue.cs

@ -23,55 +23,57 @@ namespace Debugger @@ -23,55 +23,57 @@ namespace Debugger
MetaData metaData;
ICorDebugModule corModuleSuperclass;
ObjectValue baseClass;
internal string toString;
Eval toStringEval;
TypeDefProps classProps;
public override string AsString {
get{
if (toString != null) {
return toString;
} else {
if (toStringEval == null) {
// Set up eval of ToString()
ObjectValue baseClass = this;
while (baseClass.HasBaseClass) {
baseClass = baseClass.BaseClass;
}
foreach(MethodProps method in baseClass.Module.MetaData.EnumMethods(baseClass.ClassToken)) {
if (method.Name == "ToString") {
ICorDebugValue[] evalArgs;
ICorDebugFunction evalCorFunction;
baseClass.Module.CorModule.GetFunctionFromToken(method.Token, out evalCorFunction);
// We need to pass reference
ICorDebugHeapValue2 heapValue = this.CorValue as ICorDebugHeapValue2;
if (heapValue == null) {
toString = "{" + Type + "}";
return toString;
}
ICorDebugHandleValue corHandle;
heapValue.CreateHandle(CorDebugHandleType.HANDLE_WEAK_TRACK_RESURRECTION, out corHandle);
evalArgs = new ICorDebugValue[] {corHandle};
toStringEval = new Eval(debugger, evalCorFunction, evalArgs);
// Do not add evals if we just evaluated them, otherwise we get infinite loop
if (debugger.IsPaused && debugger.PausedReason != PausedReason.AllEvalsComplete) {
debugger.AddEval(toStringEval);
//toStringEval.SetupEvaluation(debugger.CurrentThread);
}
toStringEval.EvalComplete += delegate {
toString = toStringEval.Result.AsString;
this.OnValueChanged();
};
}
public override string AsString {
get {
return "{" + Type + "}";
}
}
public ObjectValue BaseClassObject {
get {
ObjectValue baseClass = this;
while (baseClass.HasBaseClass) {
baseClass = baseClass.BaseClass;
}
return baseClass;
}
}
IEnumerable<MethodProps> Methods {
get {
return this.Module.MetaData.EnumMethods(this.ClassToken);
}
}
/*
// May return null
public Eval ToStringEval {
get {
ObjectValue baseClassObject = this.BaseClassObject;
foreach(MethodProps method in baseClassObject.Methods) {
if (method.Name == "ToString") {
ICorDebugValue[] evalArgs;
ICorDebugFunction evalCorFunction;
baseClassObject.Module.CorModule.GetFunctionFromToken(method.Token, out evalCorFunction);
// We need to pass reference
ICorDebugHeapValue2 heapValue = this.CorValue as ICorDebugHeapValue2;
if (heapValue == null) { // TODO: Investigate
return null;
}
ICorDebugHandleValue corHandle;
heapValue.CreateHandle(CorDebugHandleType.HANDLE_WEAK_TRACK_RESURRECTION, out corHandle);
evalArgs = new ICorDebugValue[] {corHandle};
return new Eval(debugger, evalCorFunction, evalArgs);
}
return "{" + Type + "}";
}
throw new DebuggerException("ToString method not found");
}
}
*/
public override string Type {
get{
return classProps.Name;

Loading…
Cancel
Save