Browse Source

PersistentValue merged into Variable

git-svn-id: svn://svn.sharpdevelop.net/sharpdevelop/trunk@1558 1ccf3a8d-04fe-1044-b7c0-cef0b8235c61
shortcuts
David Srbecký 19 years ago
parent
commit
b0b1372c8d
  1. 2
      src/AddIns/Misc/Debugger/Debugger.AddIn/Project/Src/Pads/TreeListViewDebuggerItem.cs
  2. 4
      src/AddIns/Misc/Debugger/Debugger.AddIn/Project/Src/Service/DynamicTreeDebuggerRow.cs
  3. 5
      src/AddIns/Misc/Debugger/Debugger.Core/Project/Debugger.Core.csproj
  4. 42
      src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Boo/InterpreterWrapper.cs
  5. 4
      src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Threads/Exception.cs
  6. 25
      src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Threads/Function.cs
  7. 4
      src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Threads/Thread.cs
  8. 11
      src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Variables/ArrayValue.cs
  9. 12
      src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Variables/Evals/Eval.CallFunctionEval.cs
  10. 22
      src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Variables/Evals/Eval.cs
  11. 2
      src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Variables/NullValue.cs
  12. 42
      src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Variables/ObjectValue.cs
  13. 69
      src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Variables/PersistentValue.cs
  14. 4
      src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Variables/PrimitiveValue.cs
  15. 2
      src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Variables/UnavailableValue.cs
  16. 14
      src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Variables/Value.cs
  17. 113
      src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Variables/Variable.cs
  18. 2
      src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Variables/VariableCollection.cs
  19. 12
      src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Variables/VariableEventArgs.cs
  20. 14
      src/AddIns/Misc/Debugger/Debugger.Tests/Project/Src/DebuggerTests.cs

2
src/AddIns/Misc/Debugger/Debugger.AddIn/Project/Src/Pads/TreeListViewDebuggerItem.cs

@ -98,7 +98,7 @@ namespace ICSharpCode.SharpDevelop.Gui.Pads
Items.Clear(); Items.Clear();
// Do not sort names of array items // Do not sort names of array items
this.Items.SortOrder = variable.Value is ArrayValue ? SortOrder.None : SortOrder.Ascending; this.Items.SortOrder = variable.Value is ArrayValue ? SortOrder.None : SortOrder.Ascending;
LocalVarPad.AddVariableCollectionToTree(variable.SubVariables, this.Items); LocalVarPad.AddVariableCollectionToTree(variable.Value.SubVariables, this.Items);
populated = true; populated = true;
} }
} }

4
src/AddIns/Misc/Debugger/Debugger.AddIn/Project/Src/Service/DynamicTreeDebuggerRow.cs

@ -74,7 +74,7 @@ namespace ICSharpCode.SharpDevelop.Services
Update(); Update();
} }
void Update(object sender, PersistentValueEventArgs e) void Update(object sender, VariableEventArgs e)
{ {
dirty = true; dirty = true;
Update(); Update();
@ -182,7 +182,7 @@ namespace ICSharpCode.SharpDevelop.Services
List<Variable> privateStatic = new List<Variable>(); List<Variable> privateStatic = new List<Variable>();
List<Variable> privateInstance = new List<Variable>(); List<Variable> privateInstance = new List<Variable>();
foreach(Variable variable in this.Variable.SubVariables) { foreach(Variable variable in this.Variable.Value.SubVariables) {
if (variable.IsPublic) { if (variable.IsPublic) {
if (variable.IsStatic) { if (variable.IsStatic) {
publicStatic.Add(variable); publicStatic.Add(variable);

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

@ -195,7 +195,6 @@
<Compile Include="Src\Variables\Value.cs" /> <Compile Include="Src\Variables\Value.cs" />
<Compile Include="Src\Variables\ValueEventArgs.cs" /> <Compile Include="Src\Variables\ValueEventArgs.cs" />
<Compile Include="Src\Variables\VariableCollection.cs" /> <Compile Include="Src\Variables\VariableCollection.cs" />
<Compile Include="Src\Variables\Variable.cs" />
<Compile Include="Src\Threads\Stepper.cs" /> <Compile Include="Src\Threads\Stepper.cs" />
<Compile Include="Src\Threads\StepperEventArgs.cs" /> <Compile Include="Src\Threads\StepperEventArgs.cs" />
<Compile Include="Src\Interop\CorSym\_FILETIME.cs" /> <Compile Include="Src\Interop\CorSym\_FILETIME.cs" />
@ -376,12 +375,12 @@
<Compile Include="Src\Threads\FrameID.cs" /> <Compile Include="Src\Threads\FrameID.cs" />
<Compile Include="Src\Wrappers\CorDebug\ICorDebugChain.cs" /> <Compile Include="Src\Wrappers\CorDebug\ICorDebugChain.cs" />
<Compile Include="Src\Wrappers\CorDebug\ICorDebugFrame.cs" /> <Compile Include="Src\Wrappers\CorDebug\ICorDebugFrame.cs" />
<Compile Include="Src\Variables\PersistentValue.cs" /> <Compile Include="Src\Variables\VariableEventArgs.cs" />
<Compile Include="Src\Variables\PersistentValueEventArgs.cs" />
<Compile Include="Src\Debugger\IExpirable.cs" /> <Compile Include="Src\Debugger\IExpirable.cs" />
<Compile Include="Src\Boo\InterpreterWrapper.cs" /> <Compile Include="Src\Boo\InterpreterWrapper.cs" />
<Compile Include="Src\Variables\Evals\Eval.CallFunctionEval.cs" /> <Compile Include="Src\Variables\Evals\Eval.CallFunctionEval.cs" />
<Compile Include="Src\Variables\Evals\Eval.NewStringEval.cs" /> <Compile Include="Src\Variables\Evals\Eval.NewStringEval.cs" />
<Compile Include="Src\Variables\PersistentValue.cs" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<Content Include="README.TXT" /> <Content Include="README.TXT" />

42
src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Boo/InterpreterWrapper.cs

@ -19,7 +19,7 @@ namespace Debugger
const string booDll = "Boo.Lang.Interpreter.dll"; const string booDll = "Boo.Lang.Interpreter.dll";
NDebugger debugger; NDebugger debugger;
PersistentValue interpreter; Variable interpreter;
public NDebugger Debugger { public NDebugger Debugger {
get { get {
@ -36,49 +36,49 @@ namespace Debugger
{ {
this.debugger = debugger; this.debugger = debugger;
PersistentValue assemblyPath = Eval.NewString(debugger, booInterpreterPath).EvaluateNow(); Variable assemblyPath = Eval.NewString(debugger, booInterpreterPath).EvaluateNow();
PersistentValue assembly = Eval.CallFunction(debugger, "mscorlib.dll", "System.Reflection.Assembly", "LoadFrom", false, null, new PersistentValue[] {assemblyPath}).EvaluateNow(); Variable assembly = Eval.CallFunction(debugger, "mscorlib.dll", "System.Reflection.Assembly", "LoadFrom", false, null, new Variable[] {assemblyPath}).EvaluateNow();
PersistentValue interpreterType = Eval.NewString(debugger, "Boo.Lang.Interpreter.InteractiveInterpreter").EvaluateNow(); Variable interpreterType = Eval.NewString(debugger, "Boo.Lang.Interpreter.InteractiveInterpreter").EvaluateNow();
interpreter = Eval.CallFunction(debugger, "mscorlib.dll", "System.Reflection.Assembly", "CreateInstance", false, assembly, new PersistentValue[] {interpreterType}).EvaluateNow(); interpreter = Eval.CallFunction(debugger, "mscorlib.dll", "System.Reflection.Assembly", "CreateInstance", false, assembly, new Variable[] {interpreterType}).EvaluateNow();
RunCommand("interpreter.RememberLastValue = true"); RunCommand("interpreter.RememberLastValue = true");
// Testing: // Testing:
RunCommand("1 + 2"); RunCommand("1 + 2");
PersistentValue res = GetLastValue(); Variable res = GetLastValue();
SetValue("a", res); SetValue("a", res);
RunCommand("a = a + 100"); RunCommand("a = a + 100");
PersistentValue a = GetValue("a"); Variable a = GetValue("a");
PersistentValue sug = SuggestCodeCompletion("interpreter.__codecomplete__"); Variable sug = SuggestCodeCompletion("interpreter.__codecomplete__");
} }
public void RunCommand(string code) public void RunCommand(string code)
{ {
PersistentValue cmd = Eval.NewString(debugger, code).EvaluateNow(); Variable cmd = Eval.NewString(debugger, code).EvaluateNow();
Eval.CallFunction(debugger, booDll, "Boo.Lang.Interpreter.InteractiveInterpreter", "LoopEval", false, interpreter, new PersistentValue[] {cmd}).EvaluateNow(); Eval.CallFunction(debugger, booDll, "Boo.Lang.Interpreter.InteractiveInterpreter", "LoopEval", false, interpreter, new Variable[] {cmd}).EvaluateNow();
} }
public void SetValue(string valueName, PersistentValue newValue) public void SetValue(string valueName, Variable newValue)
{ {
PersistentValue name = Eval.NewString(debugger, valueName).EvaluateNow(); Variable name = Eval.NewString(debugger, valueName).EvaluateNow();
Eval.CallFunction(debugger, booDll, "Boo.Lang.Interpreter.InteractiveInterpreter", "SetValue", false, interpreter, new PersistentValue[] {name, newValue}).EvaluateNow(); Eval.CallFunction(debugger, booDll, "Boo.Lang.Interpreter.InteractiveInterpreter", "SetValue", false, interpreter, new Variable[] {name, newValue}).EvaluateNow();
} }
public PersistentValue GetValue(string valueName) public Variable GetValue(string valueName)
{ {
PersistentValue name = Eval.NewString(debugger, valueName).EvaluateNow(); Variable name = Eval.NewString(debugger, valueName).EvaluateNow();
return Eval.CallFunction(debugger, booDll, "Boo.Lang.Interpreter.InteractiveInterpreter", "GetValue", false, interpreter, new PersistentValue[] {name}).EvaluateNow(); return Eval.CallFunction(debugger, booDll, "Boo.Lang.Interpreter.InteractiveInterpreter", "GetValue", false, interpreter, new Variable[] {name}).EvaluateNow();
} }
public PersistentValue GetLastValue() public Variable GetLastValue()
{ {
return Eval.CallFunction(debugger, booDll, "Boo.Lang.Interpreter.InteractiveInterpreter", "get_LastValue", false, interpreter, new PersistentValue[] {}).EvaluateNow(); return Eval.CallFunction(debugger, booDll, "Boo.Lang.Interpreter.InteractiveInterpreter", "get_LastValue", false, interpreter, new Variable[] {}).EvaluateNow();
} }
public PersistentValue SuggestCodeCompletion(string code) public Variable SuggestCodeCompletion(string code)
{ {
PersistentValue cmd = Eval.NewString(debugger, code).EvaluateNow(); Variable cmd = Eval.NewString(debugger, code).EvaluateNow();
return Eval.CallFunction(debugger, booDll, "Boo.Lang.Interpreter.AbstractInterpreter", "SuggestCodeCompletion", false, interpreter, new PersistentValue[] {cmd}).EvaluateNow(); return Eval.CallFunction(debugger, booDll, "Boo.Lang.Interpreter.AbstractInterpreter", "SuggestCodeCompletion", false, interpreter, new Variable[] {cmd}).EvaluateNow();
} }
} }
} }

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

@ -41,7 +41,9 @@ namespace Debugger
this.thread = thread; this.thread = thread;
corValue = thread.CorThread.CurrentException; corValue = thread.CorThread.CurrentException;
exceptionType = thread.CurrentExceptionType; exceptionType = thread.CurrentExceptionType;
runtimeValue = new PersistentValue(debugger, runtimeValue = new Variable(debugger,
"$exception",
Variable.Flags.Default,
new IExpirable[] {debugger.PauseSession}, new IExpirable[] {debugger.PauseSession},
corValue).Value; corValue).Value;
runtimeValueException = runtimeValue as ObjectValue; runtimeValueException = runtimeValue as ObjectValue;

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

@ -363,8 +363,7 @@ namespace Debugger
IEnumerable<Variable> GetVariables() IEnumerable<Variable> GetVariables()
{ {
if (!IsStatic) { if (!IsStatic) {
yield return new Variable("this", yield return ThisVariable;
ThisValue);
} }
foreach(Variable var in ArgumentVariables) { foreach(Variable var in ArgumentVariables) {
yield return var; yield return var;
@ -377,9 +376,11 @@ namespace Debugger
} }
} }
public PersistentValue ThisValue { public Variable ThisVariable {
get { get {
return new PersistentValue(debugger, return new Variable(debugger,
"this",
Variable.Flags.Default,
new IExpirable[] {this}, new IExpirable[] {this},
delegate { return ThisCorValue; }); delegate { return ThisCorValue; });
} }
@ -403,7 +404,7 @@ namespace Debugger
get { get {
// TODO: Should work for static // TODO: Should work for static
if (!IsStatic) { if (!IsStatic) {
foreach(Variable var in ThisValue.Value.SubVariables) { foreach(Variable var in ThisVariable.Value.SubVariables) {
yield return var; yield return var;
} }
} }
@ -433,10 +434,11 @@ namespace Debugger
public Variable GetArgumentVariable(int index) public Variable GetArgumentVariable(int index)
{ {
return new Variable(GetParameterName(index), return new Variable(debugger,
new PersistentValue(debugger, GetParameterName(index),
Variable.Flags.Default,
new IExpirable[] {this}, new IExpirable[] {this},
delegate { return GetArgumentCorValue(index); } )); delegate { return GetArgumentCorValue(index); } );
} }
ICorDebugValue GetArgumentCorValue(int index) ICorDebugValue GetArgumentCorValue(int index)
@ -487,10 +489,11 @@ namespace Debugger
Variable GetLocalVariable(ISymUnmanagedVariable symVar) Variable GetLocalVariable(ISymUnmanagedVariable symVar)
{ {
return new Variable(symVar.Name, return new Variable(debugger,
new PersistentValue(debugger, symVar.Name,
Variable.Flags.Default,
new IExpirable[] {this}, new IExpirable[] {this},
delegate { return GetCorValueOfLocalVariable(symVar); })); delegate { return GetCorValueOfLocalVariable(symVar); });
} }
ICorDebugValue GetCorValueOfLocalVariable(ISymUnmanagedVariable symVar) ICorDebugValue GetCorValueOfLocalVariable(ISymUnmanagedVariable symVar)

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

@ -114,7 +114,9 @@ namespace Debugger
if (!HasBeenLoaded) throw new DebuggerException("Thread has not started jet"); if (!HasBeenLoaded) throw new DebuggerException("Thread has not started jet");
process.AssertPaused(); process.AssertPaused();
return new PersistentValue(debugger, return new Variable(debugger,
"thread" + id,
Variable.Flags.Default,
new IExpirable[] {debugger.PauseSession}, new IExpirable[] {debugger.PauseSession},
corThread.Object).Value; corThread.Object).Value;
} }

11
src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Variables/ArrayValue.cs

@ -60,7 +60,7 @@ namespace Debugger
} }
internal unsafe ArrayValue(NDebugger debugger, PersistentValue pValue):base(debugger, pValue) internal unsafe ArrayValue(NDebugger debugger, Variable variable):base(debugger, variable)
{ {
corElementType = (CorElementType)CorArrayValue.ElementType; corElementType = (CorElementType)CorArrayValue.ElementType;
@ -118,10 +118,11 @@ namespace Debugger
elementName += indices[i].ToString() + ","; elementName += indices[i].ToString() + ",";
elementName = elementName.TrimEnd(new char[] {','}) + "]"; elementName = elementName.TrimEnd(new char[] {','}) + "]";
return new Variable(elementName, return new Variable(debugger,
new PersistentValue(debugger, elementName,
new IExpirable[] {this.PersistentValue}, Variable.Flags.Default,
delegate { return GetCorValueOfItem(indices); })); new IExpirable[] {this.Variable},
delegate { return GetCorValueOfItem(indices); });
} }
unsafe ICorDebugValue GetCorValueOfItem(uint[] indices) unsafe ICorDebugValue GetCorValueOfItem(uint[] indices)

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

@ -22,8 +22,8 @@ namespace Debugger
string containgType; string containgType;
string functionName; string functionName;
ICorDebugFunction corFunction; ICorDebugFunction corFunction;
PersistentValue thisValue; Variable thisValue;
PersistentValue[] args; Variable[] args;
static List<T> MergeLists<T>(IEnumerable<T> a, IEnumerable<T> b) static List<T> MergeLists<T>(IEnumerable<T> a, IEnumerable<T> b)
{ {
@ -33,7 +33,7 @@ namespace Debugger
return newList; return newList;
} }
public CallFunctionEval(NDebugger debugger, string moduleName, string containgType, string functionName, bool reevaluateAfterDebuggeeStateChange, PersistentValue thisValue, PersistentValue[] args) public CallFunctionEval(NDebugger debugger, string moduleName, string containgType, string functionName, bool reevaluateAfterDebuggeeStateChange, Variable thisValue, Variable[] args)
:this(debugger, null, reevaluateAfterDebuggeeStateChange, thisValue, args) :this(debugger, null, reevaluateAfterDebuggeeStateChange, thisValue, args)
{ {
this.moduleName = moduleName; this.moduleName = moduleName;
@ -41,8 +41,8 @@ namespace Debugger
this.functionName = functionName; this.functionName = functionName;
} }
public CallFunctionEval(NDebugger debugger, ICorDebugFunction corFunction, bool reevaluateAfterDebuggeeStateChange, PersistentValue thisValue, PersistentValue[] args) public CallFunctionEval(NDebugger debugger, ICorDebugFunction corFunction, bool reevaluateAfterDebuggeeStateChange, Variable thisValue, Variable[] args)
:base(debugger, reevaluateAfterDebuggeeStateChange, thisValue == null? args : MergeLists(new PersistentValue[] {thisValue}, args).ToArray()) :base(debugger, reevaluateAfterDebuggeeStateChange, thisValue == null? args : MergeLists(new Variable[] {thisValue}, args).ToArray())
{ {
this.corFunction = corFunction; this.corFunction = corFunction;
this.thisValue = thisValue; this.thisValue = thisValue;
@ -81,7 +81,7 @@ namespace Debugger
} }
corArgs.Add(thisValue.SoftReference); corArgs.Add(thisValue.SoftReference);
} }
foreach(PersistentValue arg in args) { foreach(Variable arg in args) {
corArgs.Add(arg.SoftReference); corArgs.Add(arg.SoftReference);
} }
} catch (CannotGetValueException e) { } catch (CannotGetValueException e) {

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

@ -23,7 +23,7 @@ namespace Debugger
{ {
NDebugger debugger; NDebugger debugger;
PersistentValue pValue; Variable variablele;
ICorDebugEval corEval; ICorDebugEval corEval;
bool reevaluateAfterDebuggeeStateChange; bool reevaluateAfterDebuggeeStateChange;
@ -51,7 +51,7 @@ namespace Debugger
debugeeStateOfResult = debugger.DebugeeState; debugeeStateOfResult = debugger.DebugeeState;
OnEvalComplete(new EvalEventArgs(this)); OnEvalComplete(new EvalEventArgs(this));
} }
pValue.NotifyValueChange(); variablele.NotifyValueChange();
} }
} }
@ -64,9 +64,9 @@ namespace Debugger
} }
} }
public PersistentValue Result { public Variable Result {
get { get {
return pValue; return variablele;
} }
} }
@ -81,13 +81,15 @@ namespace Debugger
this.debugger = debugger; this.debugger = debugger;
this.reevaluateAfterDebuggeeStateChange = reevaluateAfterDebuggeeStateChange; this.reevaluateAfterDebuggeeStateChange = reevaluateAfterDebuggeeStateChange;
pValue = new PersistentValue(debugger, variablele = new Variable(debugger,
String.Empty,
Variable.Flags.Default,
dependencies, dependencies,
delegate { return GetCorValue(); }); delegate { return GetCorValue(); });
foreach(IExpirable dependency in dependencies) { foreach(IExpirable dependency in dependencies) {
if (dependency is PersistentValue) { if (dependency is Variable) {
((PersistentValue)dependency).ValueChanged += delegate { EvalState = EvalState.WaitingForRequest; }; ((Variable)dependency).ValueChanged += delegate { EvalState = EvalState.WaitingForRequest; };
} }
} }
if (reevaluateAfterDebuggeeStateChange) { if (reevaluateAfterDebuggeeStateChange) {
@ -95,12 +97,12 @@ namespace Debugger
} }
} }
public static Eval CallFunction(NDebugger debugger, string moduleName, string containgType, string functionName, bool reevaluateAfterDebuggeeStateChange, PersistentValue thisValue, PersistentValue[] args) public static Eval CallFunction(NDebugger debugger, string moduleName, string containgType, string functionName, bool reevaluateAfterDebuggeeStateChange, Variable thisValue, Variable[] args)
{ {
return new CallFunctionEval(debugger, moduleName, containgType, functionName, reevaluateAfterDebuggeeStateChange, thisValue, args); return new CallFunctionEval(debugger, moduleName, containgType, functionName, reevaluateAfterDebuggeeStateChange, thisValue, args);
} }
public static Eval CallFunction(NDebugger debugger, ICorDebugFunction corFunction, bool reevaluateAfterDebuggeeStateChange, PersistentValue thisValue, PersistentValue[] args) public static Eval CallFunction(NDebugger debugger, ICorDebugFunction corFunction, bool reevaluateAfterDebuggeeStateChange, Variable thisValue, Variable[] args)
{ {
return new CallFunctionEval(debugger, corFunction, reevaluateAfterDebuggeeStateChange, thisValue, args); return new CallFunctionEval(debugger, corFunction, reevaluateAfterDebuggeeStateChange, thisValue, args);
} }
@ -138,7 +140,7 @@ namespace Debugger
/// <returns>True if setup was successful</returns> /// <returns>True if setup was successful</returns>
internal abstract bool SetupEvaluation(Thread targetThread); internal abstract bool SetupEvaluation(Thread targetThread);
public PersistentValue EvaluateNow() public Variable EvaluateNow()
{ {
while (EvalState == EvalState.WaitingForRequest) { while (EvalState == EvalState.WaitingForRequest) {
ScheduleEvaluation(); ScheduleEvaluation();

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

@ -36,7 +36,7 @@ namespace Debugger
} }
} }
internal unsafe NullValue(NDebugger debugger, PersistentValue pValue):base(debugger, pValue) internal unsafe NullValue(NDebugger debugger, Variable variable):base(debugger, variable)
{ {
} }

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

@ -59,7 +59,7 @@ namespace Debugger
get { get {
ICorDebugClass currentClass = corClass; ICorDebugClass currentClass = corClass;
do { do {
yield return new ObjectValue(debugger, this.PersistentValue, currentClass); yield return new ObjectValue(debugger, this.Variable, currentClass);
currentClass = GetSuperClass(debugger, currentClass); currentClass = GetSuperClass(debugger, currentClass);
} while (currentClass != null); } while (currentClass != null);
} }
@ -77,7 +77,7 @@ namespace Debugger
get { get {
ICorDebugClass superClass = GetSuperClass(debugger, corClass); ICorDebugClass superClass = GetSuperClass(debugger, corClass);
if (superClass == null) throw new DebuggerException("Does not have a base class"); if (superClass == null) throw new DebuggerException("Does not have a base class");
return new ObjectValue(debugger, this.PersistentValue, superClass); return new ObjectValue(debugger, this.Variable, superClass);
} }
} }
@ -87,12 +87,12 @@ namespace Debugger
} }
} }
internal ObjectValue(NDebugger debugger, PersistentValue pValue):base(debugger, pValue) internal ObjectValue(NDebugger debugger, Variable variable):base(debugger, variable)
{ {
InitObjectValue(this.CorObjectValue.Class); InitObjectValue(this.CorObjectValue.Class);
} }
internal ObjectValue(NDebugger debugger, PersistentValue pValue, ICorDebugClass corClass):base(debugger, pValue) internal ObjectValue(NDebugger debugger, Variable variable, ICorDebugClass corClass):base(debugger, variable)
{ {
InitObjectValue(corClass); InitObjectValue(corClass);
} }
@ -159,12 +159,12 @@ namespace Debugger
FieldProps field = f; // One per scope/delegate FieldProps field = f; // One per scope/delegate
if (field.IsStatic && field.IsLiteral) continue; // Skip field if (field.IsStatic && field.IsLiteral) continue; // Skip field
if (!field.IsStatic && CorValue == null) continue; // Skip field if (!field.IsStatic && CorValue == null) continue; // Skip field
yield return new Variable(field.Name, yield return new Variable(debugger,
field.IsStatic, field.Name,
field.IsPublic, (field.IsStatic ? Variable.Flags.Static : Variable.Flags.None) |
new PersistentValue(debugger, (field.IsPublic ? Variable.Flags.Public : Variable.Flags.None),
new IExpirable[] {this.PersistentValue}, new IExpirable[] {this.Variable},
delegate { return GetCorValueOfField(field); })); delegate { return GetCorValueOfField(field); });
} }
} }
@ -197,12 +197,13 @@ namespace Debugger
Eval eval = Eval.CallFunction(debugger, Eval eval = Eval.CallFunction(debugger,
Module.CorModule.GetFunctionFromToken(method.Token), Module.CorModule.GetFunctionFromToken(method.Token),
true, // reevaluateAfterDebuggeeStateChange true, // reevaluateAfterDebuggeeStateChange
method.IsStatic? null : this.PersistentValue, method.IsStatic? null : this.Variable,
new PersistentValue[] {}); new Variable[] {});
yield return new Variable(method.Name.Remove(0, 4), Variable var = eval.Result;
method.IsStatic, var.Name = method.Name.Remove(0, 4);
method.IsPublic, var.VariableFlags = (method.IsStatic ? Variable.Flags.Static : Variable.Flags.None) |
eval.Result); (method.IsPublic ? Variable.Flags.Public : Variable.Flags.None);
yield return var;
} }
} }
} }
@ -210,10 +211,11 @@ namespace Debugger
public Variable GetBaseClassVariable() public Variable GetBaseClassVariable()
{ {
if (HasBaseClass) { if (HasBaseClass) {
return new Variable("<Base class>", return new Variable(debugger,
new PersistentValue(debugger, "<Base class>",
new IExpirable[] {this.PersistentValue}, Variable.Flags.Default,
delegate { return GetBaseClassValue(); })); new IExpirable[] {this.Variable},
delegate { return GetBaseClassValue(); });
} else { } else {
return null; return null;
} }

69
src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Variables/PersistentValue.cs

@ -12,7 +12,7 @@ using Debugger.Wrappers.CorDebug;
namespace Debugger namespace Debugger
{ {
/// <summary> /// <summary>
/// PersistentValue is a container which holds data necessaty to obtain /// Variable is a container which holds data necessaty to obtain
/// the value of a given object even after continue. This level of /// the value of a given object even after continue. This level of
/// abstraction is necessary because the type of a value can change /// abstraction is necessary because the type of a value can change
/// (eg for local variable of type object) /// (eg for local variable of type object)
@ -24,7 +24,7 @@ namespace Debugger
/// ValueChange: ValueChange event is called whenever DebugeeState changes /// ValueChange: ValueChange event is called whenever DebugeeState changes
/// or when NotifyValueChange() is called. /// or when NotifyValueChange() is called.
/// </summary> /// </summary>
public class PersistentValue: IExpirable public class Variable: IExpirable
{ {
/// <summary> /// <summary>
/// Delegate that is used to get value. This delegate may be called at any time and should never return null. /// Delegate that is used to get value. This delegate may be called at any time and should never return null.
@ -32,16 +32,21 @@ namespace Debugger
public delegate Value ValueGetter(); public delegate Value ValueGetter();
public delegate ICorDebugValue CorValueGetter(); public delegate ICorDebugValue CorValueGetter();
[Flags]
public enum Flags { Default = Public, None = 0, Public = 1, Static = 2};
NDebugger debugger; NDebugger debugger;
string name;
Flags flags;
CorValueGetter corValueGetter; CorValueGetter corValueGetter;
ValueGetter valueGetter; ValueGetter valueGetter;
bool isExpired = false; bool isExpired = false;
public event EventHandler Expired; public event EventHandler Expired;
public event EventHandler<PersistentValueEventArgs> ValueChanged; public event EventHandler<VariableEventArgs> ValueChanged;
public NDebugger Debugger { public NDebugger Debugger {
get { get {
@ -49,9 +54,18 @@ namespace Debugger
} }
} }
public string Name {
get {
return name;
}
set {
name = value;
}
}
public ICorDebugValue CorValue { public ICorDebugValue CorValue {
get { get {
return PersistentValue.DereferenceUnbox(RawCorValue); return DereferenceUnbox(RawCorValue);
} }
} }
@ -78,6 +92,27 @@ namespace Debugger
} }
} }
public Flags VariableFlags {
get {
return flags;
}
set {
flags = value;
}
}
public bool IsStatic {
get {
return (flags & Flags.Static) != 0;
}
}
public bool IsPublic {
get {
return (flags & Flags.Public) != 0;
}
}
public ICorDebugValue SoftReference { public ICorDebugValue SoftReference {
get { get {
if (this.HasExpired) throw new DebuggerException("CorValue has expired"); if (this.HasExpired) throw new DebuggerException("CorValue has expired");
@ -86,7 +121,7 @@ namespace Debugger
if (corValue != null && corValue.Is<ICorDebugHandleValue>()) { if (corValue != null && corValue.Is<ICorDebugHandleValue>()) {
return corValue; return corValue;
} }
corValue = PersistentValue.DereferenceUnbox(corValue); corValue = DereferenceUnbox(corValue);
if (corValue != null && corValue.Is<ICorDebugHeapValue2>()) { if (corValue != null && corValue.Is<ICorDebugHeapValue2>()) {
return corValue.As<ICorDebugHeapValue2>().CreateHandle(CorDebugHandleType.HANDLE_WEAK_TRACK_RESURRECTION).CastTo<ICorDebugValue>(); return corValue.As<ICorDebugHeapValue2>().CreateHandle(CorDebugHandleType.HANDLE_WEAK_TRACK_RESURRECTION).CastTo<ICorDebugValue>();
} else { } else {
@ -95,9 +130,19 @@ namespace Debugger
} }
} }
PersistentValue(NDebugger debugger, IExpirable[] dependencies) Variable(NDebugger debugger, string name, Flags flags, IExpirable[] dependencies)
{ {
this.debugger = debugger; this.debugger = debugger;
this.name = name;
this.flags = flags;
if (name.StartsWith("<") && name.Contains(">") && name != "<Base class>") {
string middle = name.TrimStart('<').Split('>')[0]; // Get text between '<' and '>'
if (middle != "") {
this.name = middle;
}
}
foreach(IExpirable exp in dependencies) { foreach(IExpirable exp in dependencies) {
AddDependency(exp); AddDependency(exp);
} }
@ -105,19 +150,19 @@ namespace Debugger
debugger.DebuggeeStateChanged += NotifyValueChange; debugger.DebuggeeStateChanged += NotifyValueChange;
} }
public PersistentValue(NDebugger debugger, IExpirable[] dependencies, ValueGetter valueGetter):this(debugger, dependencies) public Variable(NDebugger debugger, string name, Flags flags, IExpirable[] dependencies, ValueGetter valueGetter):this(debugger, name, flags, dependencies)
{ {
this.corValueGetter = delegate { throw new CannotGetValueException("CorValue not available for custom value"); }; this.corValueGetter = delegate { throw new CannotGetValueException("CorValue not available for custom value"); };
this.valueGetter = valueGetter; this.valueGetter = valueGetter;
} }
public PersistentValue(NDebugger debugger, IExpirable[] dependencies, ICorDebugValue corValue):this(debugger, dependencies) public Variable(NDebugger debugger, string name, Flags flags, IExpirable[] dependencies, ICorDebugValue corValue):this(debugger, name, flags, dependencies)
{ {
this.corValueGetter = delegate { return corValue; }; this.corValueGetter = delegate { return corValue; };
this.valueGetter = delegate { return CreateValue(); }; this.valueGetter = delegate { return CreateValue(); };
} }
public PersistentValue(NDebugger debugger, IExpirable[] dependencies, CorValueGetter corValueGetter):this(debugger, dependencies) public Variable(NDebugger debugger, string name, Flags flags, IExpirable[] dependencies, CorValueGetter corValueGetter):this(debugger, name, flags, dependencies)
{ {
this.corValueGetter = corValueGetter; this.corValueGetter = corValueGetter;
this.valueGetter = delegate { return CreateValue(); }; this.valueGetter = delegate { return CreateValue(); };
@ -136,7 +181,7 @@ namespace Debugger
{ {
if (!isExpired) { if (!isExpired) {
isExpired = true; isExpired = true;
OnExpired(new PersistentValueEventArgs(this)); OnExpired(new VariableEventArgs(this));
debugger.DebuggeeStateChanged -= NotifyValueChange; debugger.DebuggeeStateChanged -= NotifyValueChange;
} }
} }
@ -149,11 +194,11 @@ namespace Debugger
internal void NotifyValueChange() internal void NotifyValueChange()
{ {
if (!isExpired) { if (!isExpired) {
OnValueChanged(new PersistentValueEventArgs(this)); OnValueChanged(new VariableEventArgs(this));
} }
} }
protected virtual void OnValueChanged(PersistentValueEventArgs e) protected virtual void OnValueChanged(VariableEventArgs e)
{ {
if (ValueChanged != null) { if (ValueChanged != null) {
ValueChanged(this, e); ValueChanged(this, e);

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

@ -47,11 +47,11 @@ namespace Debugger
} else { } else {
(CorValue.CastTo<ICorDebugGenericValue>()).Value = newValue; (CorValue.CastTo<ICorDebugGenericValue>()).Value = newValue;
} }
PersistentValue.NotifyValueChange(); this.Variable.NotifyValueChange();
} }
} }
internal PrimitiveValue(NDebugger debugger, PersistentValue pValue):base(debugger, pValue) internal PrimitiveValue(NDebugger debugger, Variable variable):base(debugger, variable)
{ {
} }

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

@ -28,7 +28,7 @@ namespace Debugger
} }
} }
internal UnavailableValue(NDebugger debugger, PersistentValue pValue, string message):base(debugger, pValue) internal UnavailableValue(NDebugger debugger, Variable variable, string message):base(debugger, variable)
{ {
this.message = message; this.message = message;
} }

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

@ -16,7 +16,7 @@ namespace Debugger
public abstract class Value: RemotingObjectBase public abstract class Value: RemotingObjectBase
{ {
protected NDebugger debugger; protected NDebugger debugger;
PersistentValue pValue; Variable variable;
public NDebugger Debugger { public NDebugger Debugger {
get { get {
@ -24,21 +24,21 @@ namespace Debugger
} }
} }
public PersistentValue PersistentValue { public Variable Variable {
get { get {
return pValue; return variable;
} }
} }
internal ICorDebugValue CorValue { internal ICorDebugValue CorValue {
get { get {
return pValue.CorValue; return variable.CorValue;
} }
} }
protected Value FreshValue { protected Value FreshValue {
get { get {
return pValue.Value; return variable.Value;
} }
} }
@ -88,10 +88,10 @@ namespace Debugger
} }
} }
protected Value(NDebugger debugger, PersistentValue pValue) protected Value(NDebugger debugger, Variable variable)
{ {
this.debugger = debugger; this.debugger = debugger;
this.pValue = pValue; this.variable = variable;
} }
public override string ToString() public override string ToString()

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

@ -1,113 +0,0 @@
// <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 Debugger.Wrappers.CorDebug;
namespace Debugger
{
public class Variable: RemotingObjectBase, IExpirable
{
string name;
PersistentValue pValue;
bool isStatic;
bool isPublic;
public event EventHandler<PersistentValueEventArgs> ValueChanged {
add {
pValue.ValueChanged += value;
}
remove {
pValue.ValueChanged -= value;
}
}
public event EventHandler Expired {
add {
pValue.Expired += value;
}
remove {
pValue.Expired -= value;
}
}
public bool HasExpired {
get {
return pValue.HasExpired;
}
}
public NDebugger Debugger {
get {
return pValue.Debugger;
}
}
public virtual string Name {
get{
return name;
}
}
public PersistentValue PersistentValue {
get {
return pValue;
}
}
public bool IsStatic {
get {
return isStatic;
}
}
public bool IsPublic {
get {
return isPublic;
}
}
public Value Value {
get {
return pValue.Value;
}
}
public bool MayHaveSubVariables {
get {
return pValue.Value.MayHaveSubVariables;
}
}
public VariableCollection SubVariables {
get {
return pValue.Value.SubVariables;
}
}
public Variable(string name, PersistentValue pValue):this(name, false, true, pValue)
{
}
public Variable(string name, bool isStatic, bool isPublic, PersistentValue pValue)
{
this.name = name;
this.isStatic = isStatic;
this.isPublic = isPublic;
this.pValue = pValue;
if (name.StartsWith("<") && name.Contains(">") && name != "<Base class>") {
string middle = name.TrimStart('<').Split('>')[0]; // Get text between '<' and '>'
if (middle != "") {
this.name = middle;
}
}
}
}
}

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

@ -41,7 +41,7 @@ namespace Debugger
if (index != -1) { if (index != -1) {
string rootVariable = variableName.Substring(0, index); string rootVariable = variableName.Substring(0, index);
string subVariable = variableName.Substring(index + 1); string subVariable = variableName.Substring(index + 1);
return this[rootVariable].SubVariables[subVariable]; return this[rootVariable].Value.SubVariables[subVariable];
} else { } else {
foreach (Variable v in this) { foreach (Variable v in this) {
if (v.Name == variableName) return v; if (v.Name == variableName) return v;

12
src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Variables/PersistentValueEventArgs.cs → src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Variables/VariableEventArgs.cs

@ -9,19 +9,19 @@ using System;
namespace Debugger namespace Debugger
{ {
public class PersistentValueEventArgs: EventArgs public class VariableEventArgs: EventArgs
{ {
PersistentValue persistentValue; Variable variable;
public PersistentValue PersistentValue { public Variable Variable {
get { get {
return persistentValue; return variable;
} }
} }
public PersistentValueEventArgs(PersistentValue persistentValue) public VariableEventArgs(Variable variable)
{ {
this.persistentValue = persistentValue; this.variable = variable;
} }
} }
} }

14
src/AddIns/Misc/Debugger/Debugger.Tests/Project/Src/DebuggerTests.cs

@ -447,10 +447,10 @@ namespace Debugger.Tests
local = var; break; local = var; break;
} }
Assert.AreEqual("array", local.Name); Assert.AreEqual("array", local.Name);
Assert.AreEqual(true, local.MayHaveSubVariables); Assert.AreEqual(true, local.Value.MayHaveSubVariables);
Assert.AreEqual(typeof(ArrayValue), local.Value.GetType()); Assert.AreEqual(typeof(ArrayValue), local.Value.GetType());
Assert.AreEqual("{System.Int32[5]}", local.Value.AsString); Assert.AreEqual("{System.Int32[5]}", local.Value.AsString);
foreach(Variable var in local.SubVariables) { foreach(Variable var in local.Value.SubVariables) {
subVars.Add(var); subVars.Add(var);
} }
for(int i = 0; i < 5; i++) { for(int i = 0; i < 5; i++) {
@ -475,10 +475,10 @@ namespace Debugger.Tests
local = var; local = var;
} }
Assert.AreEqual("val", local.Name); Assert.AreEqual("val", local.Name);
Assert.AreEqual(true, local.MayHaveSubVariables); Assert.AreEqual(true, local.Value.MayHaveSubVariables);
Assert.AreEqual(typeof(ObjectValue), local.Value.GetType()); Assert.AreEqual(typeof(ObjectValue), local.Value.GetType());
Assert.AreEqual("{Debugger.Tests.TestPrograms.ObjectValue}", local.Value.AsString); Assert.AreEqual("{Debugger.Tests.TestPrograms.ObjectValue}", local.Value.AsString);
foreach(Variable var in local.SubVariables) { foreach(Variable var in local.Value.SubVariables) {
subVars.Add(var); subVars.Add(var);
} }
Assert.AreEqual("privateField", subVars[1].Name); Assert.AreEqual("privateField", subVars[1].Name);
@ -515,7 +515,7 @@ namespace Debugger.Tests
foreach(Variable var in debugger.SelectedFunction.LocalVariables) { foreach(Variable var in debugger.SelectedFunction.LocalVariables) {
local = var; local = var;
} }
foreach(Variable var in local.SubVariables) { foreach(Variable var in local.Value.SubVariables) {
subVars.Add(var); subVars.Add(var);
} }
Assert.AreEqual("PrivateProperty", subVars[1].Name); Assert.AreEqual("PrivateProperty", subVars[1].Name);
@ -563,7 +563,7 @@ namespace Debugger.Tests
Assert.AreEqual("form", local.Name); Assert.AreEqual("form", local.Name);
Assert.AreEqual(typeof(Variable), local.GetType()); Assert.AreEqual(typeof(Variable), local.GetType());
foreach(Variable var in local.SubVariables) { foreach(Variable var in local.Value.SubVariables) {
Assert.AreEqual(typeof(UnavailableValue), var.Value.GetType(), "Variable name: " + var.Name); Assert.AreEqual(typeof(UnavailableValue), var.Value.GetType(), "Variable name: " + var.Name);
debugger.StartEvaluation(); debugger.StartEvaluation();
WaitForPause(PausedReason.EvalComplete, null); WaitForPause(PausedReason.EvalComplete, null);
@ -573,7 +573,7 @@ namespace Debugger.Tests
debugger.Continue(); debugger.Continue();
WaitForPause(PausedReason.Break, null); WaitForPause(PausedReason.Break, null);
foreach(Variable var in local.SubVariables) { foreach(Variable var in local.Value.SubVariables) {
Assert.AreEqual(typeof(UnavailableValue), var.Value.GetType(), "Variable name: " + var.Name); Assert.AreEqual(typeof(UnavailableValue), var.Value.GetType(), "Variable name: " + var.Name);
} }
debugger.StartEvaluation(); debugger.StartEvaluation();

Loading…
Cancel
Save