Browse Source

ToString() evaluated in local variables pad

git-svn-id: svn://svn.sharpdevelop.net/sharpdevelop/trunk@778 1ccf3a8d-04fe-1044-b7c0-cef0b8235c61
shortcuts
David Srbecký 20 years ago
parent
commit
85efc7e17c
  1. 10
      src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Variables/Evals/Eval.cs
  2. 55
      src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Variables/ObjectValue.cs
  3. 8
      src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Variables/PrimitiveValue.cs
  4. 2
      src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Variables/PropertyVariable.cs
  5. 8
      src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Variables/Value.cs
  6. 4
      src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Variables/Variable.cs
  7. 6
      src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Variables/VariableCollection.cs

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

@ -79,7 +79,15 @@ namespace Debugger @@ -79,7 +79,15 @@ namespace Debugger
public Value Result {
get {
if (completed) {
return result;
if (successful) {
return result;
} else {
ObjectValue exception = (ObjectValue)result;
while (exception.Type != "System.Exception") {
exception = exception.BaseClass;
}
return new UnavailableValue(debugger, result.Type + ": " + exception["_message"].Value.AsString);
}
} else {
return null;
}

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

@ -23,12 +23,52 @@ namespace Debugger @@ -23,12 +23,52 @@ namespace Debugger
MetaData metaData;
ICorDebugModule corModuleSuperclass;
ObjectValue baseClass;
internal string toString;
Eval toStringEval;
TypeDefProps classProps;
public override string AsString {
get{
return "{" + Type + "}";
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();
};
}
}
}
return "{" + Type + "}";
}
}
}
@ -38,6 +78,17 @@ namespace Debugger @@ -38,6 +78,17 @@ namespace Debugger
}
}
public Module Module {
get {
return debugger.GetModule(corModule);
}
}
public uint ClassToken {
get {
return classProps.Token;
}
}
internal unsafe ObjectValue(NDebugger debugger, ICorDebugValue corValue):base(debugger, corValue)
{
@ -56,7 +107,7 @@ namespace Debugger @@ -56,7 +107,7 @@ namespace Debugger
uint classToken;
corClass.GetToken(out classToken);
corClass.GetModule(out corModule);
metaData = debugger.GetModule(corModule).MetaData;
metaData = Module.MetaData;
classProps = metaData.GetTypeDefProps(classToken);

8
src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Variables/PrimitiveValue.cs

@ -15,14 +15,6 @@ namespace Debugger @@ -15,14 +15,6 @@ namespace Debugger
{
public class PrimitiveValue: Value
{
public event EventHandler<ValueEventArgs> ValueChanged;
protected virtual void OnValueChanged() {
if (ValueChanged != null) {
ValueChanged(this, new ValueEventArgs(this));
}
}
public override string AsString {
get {
if (Primitive != null) {

2
src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Variables/PropertyVariable.cs

@ -17,7 +17,7 @@ namespace Debugger @@ -17,7 +17,7 @@ namespace Debugger
public event EventHandler<DebuggerEventArgs> ValueEvaluated;
internal PropertyVariable(Eval eval, string name):base(eval.Debugger, null, name)
internal PropertyVariable(Eval eval, string name):base(eval.Debugger, new UnavailableValue(eval.Debugger), name)
{
this.Eval = eval;
}

8
src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Variables/Value.cs

@ -19,6 +19,8 @@ namespace Debugger @@ -19,6 +19,8 @@ namespace Debugger
protected ICorDebugValue corValue;
public event EventHandler<ValueEventArgs> ValueChanged;
public NDebugger Debugger {
get {
return debugger;
@ -47,6 +49,12 @@ namespace Debugger @@ -47,6 +49,12 @@ namespace Debugger
}
}
protected virtual void OnValueChanged() {
if (ValueChanged != null) {
ValueChanged(this, new ValueEventArgs(this));
}
}
public virtual Type ManagedType {
get {
return CorTypeToManagedType(CorType);

4
src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Variables/Variable.cs

@ -38,9 +38,7 @@ namespace Debugger @@ -38,9 +38,7 @@ namespace Debugger
}
internal set {
val = value;
if (val is PrimitiveValue) {
((PrimitiveValue)val).ValueChanged += delegate { OnValueChanged(); };
}
val.ValueChanged += delegate { OnValueChanged(); };
OnValueChanged();
}
}

6
src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Variables/VariableCollection.cs

@ -159,9 +159,11 @@ namespace Debugger @@ -159,9 +159,11 @@ namespace Debugger
if (this.Contains(newVariable.Name)) {
Variable oldVariable = this[newVariable.Name];
// Update existing variable
if (oldVariable.Value is ObjectValue && newVariable.Value is ObjectValue && debugger.PausedReason == PausedReason.AllEvalsComplete) {
((ObjectValue)newVariable.Value).toString = ((ObjectValue)oldVariable.Value).toString;
}
if (oldVariable is PropertyVariable) {
Eval newEval = ((PropertyVariable)newVariable).Eval;
((PropertyVariable)oldVariable).Eval = newEval;
((PropertyVariable)oldVariable).Eval = ((PropertyVariable)newVariable).Eval;
} else {
oldVariable.Value = newVariable.Value;
}

Loading…
Cancel
Save