From b0b1372c8d500178b47d899b8c7840f3de078162 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?David=20Srbeck=C3=BD?= Date: Mon, 10 Jul 2006 17:32:30 +0000 Subject: [PATCH] PersistentValue merged into Variable git-svn-id: svn://svn.sharpdevelop.net/sharpdevelop/trunk@1558 1ccf3a8d-04fe-1044-b7c0-cef0b8235c61 --- .../Src/Pads/TreeListViewDebuggerItem.cs | 2 +- .../Src/Service/DynamicTreeDebuggerRow.cs | 4 +- .../Project/Debugger.Core.csproj | 5 +- .../Project/Src/Boo/InterpreterWrapper.cs | 42 +++---- .../Project/Src/Threads/Exception.cs | 8 +- .../Project/Src/Threads/Function.cs | 33 ++--- .../Project/Src/Threads/Thread.cs | 8 +- .../Project/Src/Variables/ArrayValue.cs | 11 +- .../Variables/Evals/Eval.CallFunctionEval.cs | 12 +- .../Project/Src/Variables/Evals/Eval.cs | 26 ++-- .../Project/Src/Variables/NullValue.cs | 2 +- .../Project/Src/Variables/ObjectValue.cs | 42 +++---- .../Project/Src/Variables/PersistentValue.cs | 69 +++++++++-- .../Project/Src/Variables/PrimitiveValue.cs | 4 +- .../Project/Src/Variables/UnavailableValue.cs | 2 +- .../Project/Src/Variables/Value.cs | 14 +-- .../Project/Src/Variables/Variable.cs | 113 ------------------ .../Src/Variables/VariableCollection.cs | 2 +- ...ValueEventArgs.cs => VariableEventArgs.cs} | 12 +- .../Project/Src/DebuggerTests.cs | 14 +-- 20 files changed, 184 insertions(+), 241 deletions(-) delete mode 100644 src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Variables/Variable.cs rename src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Variables/{PersistentValueEventArgs.cs => VariableEventArgs.cs} (52%) diff --git a/src/AddIns/Misc/Debugger/Debugger.AddIn/Project/Src/Pads/TreeListViewDebuggerItem.cs b/src/AddIns/Misc/Debugger/Debugger.AddIn/Project/Src/Pads/TreeListViewDebuggerItem.cs index 4875910d21..40474370b6 100644 --- a/src/AddIns/Misc/Debugger/Debugger.AddIn/Project/Src/Pads/TreeListViewDebuggerItem.cs +++ b/src/AddIns/Misc/Debugger/Debugger.AddIn/Project/Src/Pads/TreeListViewDebuggerItem.cs @@ -98,7 +98,7 @@ namespace ICSharpCode.SharpDevelop.Gui.Pads Items.Clear(); // Do not sort names of array items 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; } } diff --git a/src/AddIns/Misc/Debugger/Debugger.AddIn/Project/Src/Service/DynamicTreeDebuggerRow.cs b/src/AddIns/Misc/Debugger/Debugger.AddIn/Project/Src/Service/DynamicTreeDebuggerRow.cs index 1776cb0051..dcb9d5a68e 100644 --- a/src/AddIns/Misc/Debugger/Debugger.AddIn/Project/Src/Service/DynamicTreeDebuggerRow.cs +++ b/src/AddIns/Misc/Debugger/Debugger.AddIn/Project/Src/Service/DynamicTreeDebuggerRow.cs @@ -74,7 +74,7 @@ namespace ICSharpCode.SharpDevelop.Services Update(); } - void Update(object sender, PersistentValueEventArgs e) + void Update(object sender, VariableEventArgs e) { dirty = true; Update(); @@ -182,7 +182,7 @@ namespace ICSharpCode.SharpDevelop.Services List privateStatic = new List(); List privateInstance = new List(); - foreach(Variable variable in this.Variable.SubVariables) { + foreach(Variable variable in this.Variable.Value.SubVariables) { if (variable.IsPublic) { if (variable.IsStatic) { publicStatic.Add(variable); diff --git a/src/AddIns/Misc/Debugger/Debugger.Core/Project/Debugger.Core.csproj b/src/AddIns/Misc/Debugger/Debugger.Core/Project/Debugger.Core.csproj index 0cc222e695..7156de988d 100644 --- a/src/AddIns/Misc/Debugger/Debugger.Core/Project/Debugger.Core.csproj +++ b/src/AddIns/Misc/Debugger/Debugger.Core/Project/Debugger.Core.csproj @@ -195,7 +195,6 @@ - @@ -376,12 +375,12 @@ - - + + diff --git a/src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Boo/InterpreterWrapper.cs b/src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Boo/InterpreterWrapper.cs index a3d49b9f5f..fa83aa7a04 100644 --- a/src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Boo/InterpreterWrapper.cs +++ b/src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Boo/InterpreterWrapper.cs @@ -19,7 +19,7 @@ namespace Debugger const string booDll = "Boo.Lang.Interpreter.dll"; NDebugger debugger; - PersistentValue interpreter; + Variable interpreter; public NDebugger Debugger { get { @@ -36,49 +36,49 @@ namespace Debugger { this.debugger = debugger; - PersistentValue assemblyPath = Eval.NewString(debugger, booInterpreterPath).EvaluateNow(); - PersistentValue assembly = Eval.CallFunction(debugger, "mscorlib.dll", "System.Reflection.Assembly", "LoadFrom", false, null, new PersistentValue[] {assemblyPath}).EvaluateNow(); - PersistentValue 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(); + Variable assemblyPath = Eval.NewString(debugger, booInterpreterPath).EvaluateNow(); + Variable assembly = Eval.CallFunction(debugger, "mscorlib.dll", "System.Reflection.Assembly", "LoadFrom", false, null, new Variable[] {assemblyPath}).EvaluateNow(); + Variable interpreterType = Eval.NewString(debugger, "Boo.Lang.Interpreter.InteractiveInterpreter").EvaluateNow(); + interpreter = Eval.CallFunction(debugger, "mscorlib.dll", "System.Reflection.Assembly", "CreateInstance", false, assembly, new Variable[] {interpreterType}).EvaluateNow(); RunCommand("interpreter.RememberLastValue = true"); // Testing: RunCommand("1 + 2"); - PersistentValue res = GetLastValue(); + Variable res = GetLastValue(); SetValue("a", res); RunCommand("a = a + 100"); - PersistentValue a = GetValue("a"); - PersistentValue sug = SuggestCodeCompletion("interpreter.__codecomplete__"); + Variable a = GetValue("a"); + Variable sug = SuggestCodeCompletion("interpreter.__codecomplete__"); } public void RunCommand(string code) { - PersistentValue cmd = Eval.NewString(debugger, code).EvaluateNow(); - Eval.CallFunction(debugger, booDll, "Boo.Lang.Interpreter.InteractiveInterpreter", "LoopEval", false, interpreter, new PersistentValue[] {cmd}).EvaluateNow(); + Variable cmd = Eval.NewString(debugger, code).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(); - Eval.CallFunction(debugger, booDll, "Boo.Lang.Interpreter.InteractiveInterpreter", "SetValue", false, interpreter, new PersistentValue[] {name, newValue}).EvaluateNow(); + Variable name = Eval.NewString(debugger, valueName).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(); - return Eval.CallFunction(debugger, booDll, "Boo.Lang.Interpreter.InteractiveInterpreter", "GetValue", false, interpreter, new PersistentValue[] {name}).EvaluateNow(); + Variable name = Eval.NewString(debugger, valueName).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(); - return Eval.CallFunction(debugger, booDll, "Boo.Lang.Interpreter.AbstractInterpreter", "SuggestCodeCompletion", false, interpreter, new PersistentValue[] {cmd}).EvaluateNow(); + Variable cmd = Eval.NewString(debugger, code).EvaluateNow(); + return Eval.CallFunction(debugger, booDll, "Boo.Lang.Interpreter.AbstractInterpreter", "SuggestCodeCompletion", false, interpreter, new Variable[] {cmd}).EvaluateNow(); } } } diff --git a/src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Threads/Exception.cs b/src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Threads/Exception.cs index 54620c3882..6d83322dc2 100644 --- a/src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Threads/Exception.cs +++ b/src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Threads/Exception.cs @@ -41,9 +41,11 @@ namespace Debugger this.thread = thread; corValue = thread.CorThread.CurrentException; exceptionType = thread.CurrentExceptionType; - runtimeValue = new PersistentValue(debugger, - new IExpirable[] {debugger.PauseSession}, - corValue).Value; + runtimeValue = new Variable(debugger, + "$exception", + Variable.Flags.Default, + new IExpirable[] {debugger.PauseSession}, + corValue).Value; runtimeValueException = runtimeValue as ObjectValue; if (runtimeValueException != null) { while (runtimeValueException.Type != "System.Exception") { diff --git a/src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Threads/Function.cs b/src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Threads/Function.cs index e65c530b4f..f2e617ee67 100644 --- a/src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Threads/Function.cs +++ b/src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Threads/Function.cs @@ -363,8 +363,7 @@ namespace Debugger IEnumerable GetVariables() { if (!IsStatic) { - yield return new Variable("this", - ThisValue); + yield return ThisVariable; } foreach(Variable var in ArgumentVariables) { yield return var; @@ -377,11 +376,13 @@ namespace Debugger } } - public PersistentValue ThisValue { + public Variable ThisVariable { get { - return new PersistentValue(debugger, - new IExpirable[] {this}, - delegate { return ThisCorValue; }); + return new Variable(debugger, + "this", + Variable.Flags.Default, + new IExpirable[] {this}, + delegate { return ThisCorValue; }); } } @@ -403,7 +404,7 @@ namespace Debugger get { // TODO: Should work for static if (!IsStatic) { - foreach(Variable var in ThisValue.Value.SubVariables) { + foreach(Variable var in ThisVariable.Value.SubVariables) { yield return var; } } @@ -433,10 +434,11 @@ namespace Debugger public Variable GetArgumentVariable(int index) { - return new Variable(GetParameterName(index), - new PersistentValue(debugger, - new IExpirable[] {this}, - delegate { return GetArgumentCorValue(index); } )); + return new Variable(debugger, + GetParameterName(index), + Variable.Flags.Default, + new IExpirable[] {this}, + delegate { return GetArgumentCorValue(index); } ); } ICorDebugValue GetArgumentCorValue(int index) @@ -487,10 +489,11 @@ namespace Debugger Variable GetLocalVariable(ISymUnmanagedVariable symVar) { - return new Variable(symVar.Name, - new PersistentValue(debugger, - new IExpirable[] {this}, - delegate { return GetCorValueOfLocalVariable(symVar); })); + return new Variable(debugger, + symVar.Name, + Variable.Flags.Default, + new IExpirable[] {this}, + delegate { return GetCorValueOfLocalVariable(symVar); }); } ICorDebugValue GetCorValueOfLocalVariable(ISymUnmanagedVariable symVar) diff --git a/src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Threads/Thread.cs b/src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Threads/Thread.cs index f25d990061..b22230eb08 100644 --- a/src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Threads/Thread.cs +++ b/src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Threads/Thread.cs @@ -114,9 +114,11 @@ namespace Debugger if (!HasBeenLoaded) throw new DebuggerException("Thread has not started jet"); process.AssertPaused(); - return new PersistentValue(debugger, - new IExpirable[] {debugger.PauseSession}, - corThread.Object).Value; + return new Variable(debugger, + "thread" + id, + Variable.Flags.Default, + new IExpirable[] {debugger.PauseSession}, + corThread.Object).Value; } } diff --git a/src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Variables/ArrayValue.cs b/src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Variables/ArrayValue.cs index c112297dd8..0579d98371 100644 --- a/src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Variables/ArrayValue.cs +++ b/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; @@ -118,10 +118,11 @@ namespace Debugger elementName += indices[i].ToString() + ","; elementName = elementName.TrimEnd(new char[] {','}) + "]"; - return new Variable(elementName, - new PersistentValue(debugger, - new IExpirable[] {this.PersistentValue}, - delegate { return GetCorValueOfItem(indices); })); + return new Variable(debugger, + elementName, + Variable.Flags.Default, + new IExpirable[] {this.Variable}, + delegate { return GetCorValueOfItem(indices); }); } unsafe ICorDebugValue GetCorValueOfItem(uint[] indices) diff --git a/src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Variables/Evals/Eval.CallFunctionEval.cs b/src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Variables/Evals/Eval.CallFunctionEval.cs index 1c9afa5dd1..bfc1e3f8cf 100644 --- a/src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Variables/Evals/Eval.CallFunctionEval.cs +++ b/src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Variables/Evals/Eval.CallFunctionEval.cs @@ -22,8 +22,8 @@ namespace Debugger string containgType; string functionName; ICorDebugFunction corFunction; - PersistentValue thisValue; - PersistentValue[] args; + Variable thisValue; + Variable[] args; static List MergeLists(IEnumerable a, IEnumerable b) { @@ -33,7 +33,7 @@ namespace Debugger 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.moduleName = moduleName; @@ -41,8 +41,8 @@ namespace Debugger this.functionName = functionName; } - public CallFunctionEval(NDebugger debugger, ICorDebugFunction corFunction, bool reevaluateAfterDebuggeeStateChange, PersistentValue thisValue, PersistentValue[] args) - :base(debugger, reevaluateAfterDebuggeeStateChange, thisValue == null? args : MergeLists(new PersistentValue[] {thisValue}, args).ToArray()) + public CallFunctionEval(NDebugger debugger, ICorDebugFunction corFunction, bool reevaluateAfterDebuggeeStateChange, Variable thisValue, Variable[] args) + :base(debugger, reevaluateAfterDebuggeeStateChange, thisValue == null? args : MergeLists(new Variable[] {thisValue}, args).ToArray()) { this.corFunction = corFunction; this.thisValue = thisValue; @@ -81,7 +81,7 @@ namespace Debugger } corArgs.Add(thisValue.SoftReference); } - foreach(PersistentValue arg in args) { + foreach(Variable arg in args) { corArgs.Add(arg.SoftReference); } } catch (CannotGetValueException e) { diff --git a/src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Variables/Evals/Eval.cs b/src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Variables/Evals/Eval.cs index 350a320d80..bd599b2a52 100644 --- a/src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Variables/Evals/Eval.cs +++ b/src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Variables/Evals/Eval.cs @@ -23,7 +23,7 @@ namespace Debugger { NDebugger debugger; - PersistentValue pValue; + Variable variablele; ICorDebugEval corEval; bool reevaluateAfterDebuggeeStateChange; @@ -51,7 +51,7 @@ namespace Debugger debugeeStateOfResult = debugger.DebugeeState; OnEvalComplete(new EvalEventArgs(this)); } - pValue.NotifyValueChange(); + variablele.NotifyValueChange(); } } @@ -64,9 +64,9 @@ namespace Debugger } } - public PersistentValue Result { + public Variable Result { get { - return pValue; + return variablele; } } @@ -81,13 +81,15 @@ namespace Debugger this.debugger = debugger; this.reevaluateAfterDebuggeeStateChange = reevaluateAfterDebuggeeStateChange; - pValue = new PersistentValue(debugger, - dependencies, - delegate { return GetCorValue(); }); + variablele = new Variable(debugger, + String.Empty, + Variable.Flags.Default, + dependencies, + delegate { return GetCorValue(); }); foreach(IExpirable dependency in dependencies) { - if (dependency is PersistentValue) { - ((PersistentValue)dependency).ValueChanged += delegate { EvalState = EvalState.WaitingForRequest; }; + if (dependency is Variable) { + ((Variable)dependency).ValueChanged += delegate { EvalState = EvalState.WaitingForRequest; }; } } 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); } - 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); } @@ -138,7 +140,7 @@ namespace Debugger /// True if setup was successful internal abstract bool SetupEvaluation(Thread targetThread); - public PersistentValue EvaluateNow() + public Variable EvaluateNow() { while (EvalState == EvalState.WaitingForRequest) { ScheduleEvaluation(); diff --git a/src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Variables/NullValue.cs b/src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Variables/NullValue.cs index 5d737f0a94..a832294232 100644 --- a/src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Variables/NullValue.cs +++ b/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) { } diff --git a/src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Variables/ObjectValue.cs b/src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Variables/ObjectValue.cs index 279e3edb80..08f1c5e267 100644 --- a/src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Variables/ObjectValue.cs +++ b/src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Variables/ObjectValue.cs @@ -59,7 +59,7 @@ namespace Debugger get { ICorDebugClass currentClass = corClass; do { - yield return new ObjectValue(debugger, this.PersistentValue, currentClass); + yield return new ObjectValue(debugger, this.Variable, currentClass); currentClass = GetSuperClass(debugger, currentClass); } while (currentClass != null); } @@ -77,7 +77,7 @@ namespace Debugger get { ICorDebugClass superClass = GetSuperClass(debugger, corClass); 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); } - internal ObjectValue(NDebugger debugger, PersistentValue pValue, ICorDebugClass corClass):base(debugger, pValue) + internal ObjectValue(NDebugger debugger, Variable variable, ICorDebugClass corClass):base(debugger, variable) { InitObjectValue(corClass); } @@ -159,12 +159,12 @@ namespace Debugger FieldProps field = f; // One per scope/delegate if (field.IsStatic && field.IsLiteral) continue; // Skip field if (!field.IsStatic && CorValue == null) continue; // Skip field - yield return new Variable(field.Name, - field.IsStatic, - field.IsPublic, - new PersistentValue(debugger, - new IExpirable[] {this.PersistentValue}, - delegate { return GetCorValueOfField(field); })); + yield return new Variable(debugger, + field.Name, + (field.IsStatic ? Variable.Flags.Static : Variable.Flags.None) | + (field.IsPublic ? Variable.Flags.Public : Variable.Flags.None), + new IExpirable[] {this.Variable}, + delegate { return GetCorValueOfField(field); }); } } @@ -197,12 +197,13 @@ namespace Debugger Eval eval = Eval.CallFunction(debugger, Module.CorModule.GetFunctionFromToken(method.Token), true, // reevaluateAfterDebuggeeStateChange - method.IsStatic? null : this.PersistentValue, - new PersistentValue[] {}); - yield return new Variable(method.Name.Remove(0, 4), - method.IsStatic, - method.IsPublic, - eval.Result); + method.IsStatic? null : this.Variable, + new Variable[] {}); + Variable var = eval.Result; + var.Name = method.Name.Remove(0, 4); + var.VariableFlags = (method.IsStatic ? Variable.Flags.Static : Variable.Flags.None) | + (method.IsPublic ? Variable.Flags.Public : Variable.Flags.None); + yield return var; } } } @@ -210,10 +211,11 @@ namespace Debugger public Variable GetBaseClassVariable() { if (HasBaseClass) { - return new Variable("", - new PersistentValue(debugger, - new IExpirable[] {this.PersistentValue}, - delegate { return GetBaseClassValue(); })); + return new Variable(debugger, + "", + Variable.Flags.Default, + new IExpirable[] {this.Variable}, + delegate { return GetBaseClassValue(); }); } else { return null; } diff --git a/src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Variables/PersistentValue.cs b/src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Variables/PersistentValue.cs index aaece7d832..1053ab8e48 100644 --- a/src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Variables/PersistentValue.cs +++ b/src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Variables/PersistentValue.cs @@ -12,7 +12,7 @@ using Debugger.Wrappers.CorDebug; namespace Debugger { /// - /// 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 /// abstraction is necessary because the type of a value can change /// (eg for local variable of type object) @@ -24,7 +24,7 @@ namespace Debugger /// ValueChange: ValueChange event is called whenever DebugeeState changes /// or when NotifyValueChange() is called. /// - public class PersistentValue: IExpirable + public class Variable: IExpirable { /// /// 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 ICorDebugValue CorValueGetter(); + [Flags] + public enum Flags { Default = Public, None = 0, Public = 1, Static = 2}; + NDebugger debugger; + string name; + Flags flags; CorValueGetter corValueGetter; ValueGetter valueGetter; bool isExpired = false; public event EventHandler Expired; - public event EventHandler ValueChanged; + public event EventHandler ValueChanged; public NDebugger Debugger { get { @@ -49,9 +54,18 @@ namespace Debugger } } + public string Name { + get { + return name; + } + set { + name = value; + } + } + public ICorDebugValue CorValue { 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 { get { if (this.HasExpired) throw new DebuggerException("CorValue has expired"); @@ -86,7 +121,7 @@ namespace Debugger if (corValue != null && corValue.Is()) { return corValue; } - corValue = PersistentValue.DereferenceUnbox(corValue); + corValue = DereferenceUnbox(corValue); if (corValue != null && corValue.Is()) { return corValue.As().CreateHandle(CorDebugHandleType.HANDLE_WEAK_TRACK_RESURRECTION).CastTo(); } 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.name = name; + this.flags = flags; + + if (name.StartsWith("<") && name.Contains(">") && name != "") { + string middle = name.TrimStart('<').Split('>')[0]; // Get text between '<' and '>' + if (middle != "") { + this.name = middle; + } + } + foreach(IExpirable exp in dependencies) { AddDependency(exp); } @@ -105,19 +150,19 @@ namespace Debugger 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.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.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.valueGetter = delegate { return CreateValue(); }; @@ -136,7 +181,7 @@ namespace Debugger { if (!isExpired) { isExpired = true; - OnExpired(new PersistentValueEventArgs(this)); + OnExpired(new VariableEventArgs(this)); debugger.DebuggeeStateChanged -= NotifyValueChange; } } @@ -149,11 +194,11 @@ namespace Debugger internal void NotifyValueChange() { 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) { ValueChanged(this, e); diff --git a/src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Variables/PrimitiveValue.cs b/src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Variables/PrimitiveValue.cs index 824dedbc24..c7795b7514 100644 --- a/src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Variables/PrimitiveValue.cs +++ b/src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Variables/PrimitiveValue.cs @@ -47,11 +47,11 @@ namespace Debugger } else { (CorValue.CastTo()).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) { } diff --git a/src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Variables/UnavailableValue.cs b/src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Variables/UnavailableValue.cs index c303b1048e..5d55fc5927 100644 --- a/src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Variables/UnavailableValue.cs +++ b/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; } diff --git a/src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Variables/Value.cs b/src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Variables/Value.cs index 589708eb1b..fd8772c6bc 100644 --- a/src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Variables/Value.cs +++ b/src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Variables/Value.cs @@ -16,7 +16,7 @@ namespace Debugger public abstract class Value: RemotingObjectBase { protected NDebugger debugger; - PersistentValue pValue; + Variable variable; public NDebugger Debugger { get { @@ -24,21 +24,21 @@ namespace Debugger } } - public PersistentValue PersistentValue { + public Variable Variable { get { - return pValue; + return variable; } } internal ICorDebugValue CorValue { get { - return pValue.CorValue; + return variable.CorValue; } } protected Value FreshValue { 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.pValue = pValue; + this.variable = variable; } public override string ToString() diff --git a/src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Variables/Variable.cs b/src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Variables/Variable.cs deleted file mode 100644 index 36aa0a962d..0000000000 --- a/src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Variables/Variable.cs +++ /dev/null @@ -1,113 +0,0 @@ -// -// -// -// -// $Revision$ -// - -using System; - -using Debugger.Wrappers.CorDebug; - -namespace Debugger -{ - public class Variable: RemotingObjectBase, IExpirable - { - string name; - PersistentValue pValue; - bool isStatic; - bool isPublic; - - public event EventHandler 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 != "") { - string middle = name.TrimStart('<').Split('>')[0]; // Get text between '<' and '>' - if (middle != "") { - this.name = middle; - } - } - } - } -} diff --git a/src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Variables/VariableCollection.cs b/src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Variables/VariableCollection.cs index 6e6fa6ea76..ee7b71e56a 100644 --- a/src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Variables/VariableCollection.cs +++ b/src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Variables/VariableCollection.cs @@ -41,7 +41,7 @@ namespace Debugger if (index != -1) { string rootVariable = variableName.Substring(0, index); string subVariable = variableName.Substring(index + 1); - return this[rootVariable].SubVariables[subVariable]; + return this[rootVariable].Value.SubVariables[subVariable]; } else { foreach (Variable v in this) { if (v.Name == variableName) return v; diff --git a/src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Variables/PersistentValueEventArgs.cs b/src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Variables/VariableEventArgs.cs similarity index 52% rename from src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Variables/PersistentValueEventArgs.cs rename to src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Variables/VariableEventArgs.cs index 97b80606dc..427c4992bb 100644 --- a/src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Variables/PersistentValueEventArgs.cs +++ b/src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Variables/VariableEventArgs.cs @@ -9,19 +9,19 @@ using System; namespace Debugger { - public class PersistentValueEventArgs: EventArgs + public class VariableEventArgs: EventArgs { - PersistentValue persistentValue; + Variable variable; - public PersistentValue PersistentValue { + public Variable Variable { get { - return persistentValue; + return variable; } } - public PersistentValueEventArgs(PersistentValue persistentValue) + public VariableEventArgs(Variable variable) { - this.persistentValue = persistentValue; + this.variable = variable; } } } diff --git a/src/AddIns/Misc/Debugger/Debugger.Tests/Project/Src/DebuggerTests.cs b/src/AddIns/Misc/Debugger/Debugger.Tests/Project/Src/DebuggerTests.cs index f4153e4745..bd1169e65c 100644 --- a/src/AddIns/Misc/Debugger/Debugger.Tests/Project/Src/DebuggerTests.cs +++ b/src/AddIns/Misc/Debugger/Debugger.Tests/Project/Src/DebuggerTests.cs @@ -447,10 +447,10 @@ namespace Debugger.Tests local = var; break; } 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("{System.Int32[5]}", local.Value.AsString); - foreach(Variable var in local.SubVariables) { + foreach(Variable var in local.Value.SubVariables) { subVars.Add(var); } for(int i = 0; i < 5; i++) { @@ -475,10 +475,10 @@ namespace Debugger.Tests local = var; } 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("{Debugger.Tests.TestPrograms.ObjectValue}", local.Value.AsString); - foreach(Variable var in local.SubVariables) { + foreach(Variable var in local.Value.SubVariables) { subVars.Add(var); } Assert.AreEqual("privateField", subVars[1].Name); @@ -515,7 +515,7 @@ namespace Debugger.Tests foreach(Variable var in debugger.SelectedFunction.LocalVariables) { local = var; } - foreach(Variable var in local.SubVariables) { + foreach(Variable var in local.Value.SubVariables) { subVars.Add(var); } Assert.AreEqual("PrivateProperty", subVars[1].Name); @@ -563,7 +563,7 @@ namespace Debugger.Tests Assert.AreEqual("form", local.Name); 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); debugger.StartEvaluation(); WaitForPause(PausedReason.EvalComplete, null); @@ -573,7 +573,7 @@ namespace Debugger.Tests debugger.Continue(); 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); } debugger.StartEvaluation();