diff --git a/src/AddIns/Misc/Debugger/Debugger.AddIn/Project/Src/Pads/CallStackPad.cs b/src/AddIns/Misc/Debugger/Debugger.AddIn/Project/Src/Pads/CallStackPad.cs index d8f2edf90f..4dd5d8cae1 100644 --- a/src/AddIns/Misc/Debugger/Debugger.AddIn/Project/Src/Pads/CallStackPad.cs +++ b/src/AddIns/Misc/Debugger/Debugger.AddIn/Project/Src/Pads/CallStackPad.cs @@ -219,7 +219,7 @@ namespace ICSharpCode.SharpDevelop.Gui.Pads } if (showArgumentValues) { try { - argValue = f.GetArgumentVariable(i).AsString.ToString(); + argValue = f.GetArgumentVariable(i).Value.AsString; } catch { } } if (parameterName != null && argValue != null) { diff --git a/src/AddIns/Misc/Debugger/Debugger.AddIn/Project/Src/Pads/LocalVarPad.cs b/src/AddIns/Misc/Debugger/Debugger.AddIn/Project/Src/Pads/LocalVarPad.cs index d06cc3a857..1ccaa6dc61 100644 --- a/src/AddIns/Misc/Debugger/Debugger.AddIn/Project/Src/Pads/LocalVarPad.cs +++ b/src/AddIns/Misc/Debugger/Debugger.AddIn/Project/Src/Pads/LocalVarPad.cs @@ -128,7 +128,7 @@ namespace ICSharpCode.SharpDevelop.Gui.Pads } } - static VariableItem FindVariableItem(TreeListViewItemCollection items, Value variable) + static VariableItem FindVariableItem(TreeListViewItemCollection items, Variable variable) { foreach (VariableListItem item in items) { VariableItem variableItem = item as VariableItem; @@ -142,7 +142,7 @@ namespace ICSharpCode.SharpDevelop.Gui.Pads public static void UpdateVariables(TreeListViewItemCollection items, VariableCollection variables) { // Add new variables and refresh existing ones - foreach (Value variable in variables) { + foreach (Variable variable in variables) { VariableItem item = FindVariableItem(items, variable); if (item != null) { item.Variable = variable; diff --git a/src/AddIns/Misc/Debugger/Debugger.AddIn/Project/Src/Pads/VariableListItems/BaseClassItem.cs b/src/AddIns/Misc/Debugger/Debugger.AddIn/Project/Src/Pads/VariableListItems/BaseClassItem.cs index ece25db19a..109a0d1a8f 100644 --- a/src/AddIns/Misc/Debugger/Debugger.AddIn/Project/Src/Pads/VariableListItems/BaseClassItem.cs +++ b/src/AddIns/Misc/Debugger/Debugger.AddIn/Project/Src/Pads/VariableListItems/BaseClassItem.cs @@ -14,11 +14,11 @@ namespace ICSharpCode.SharpDevelop.Gui.Pads { class BaseClassItem: VariableItem { - public BaseClassItem(Value uncastedVariable) + public BaseClassItem(Variable uncastedVariable) { - ObjectValue variable = uncastedVariable as ObjectValue; - if (variable != null && variable.HasBaseClass && variable.BaseClass.Type != "System.Object") { - this.Variable = variable.BaseClass; + ObjectValue objectValue = uncastedVariable.Value as ObjectValue; + if (objectValue != null && objectValue.HasBaseClass && objectValue.BaseClass.Type != "System.Object") { + this.Variable = VariableFactory.CreateVariable(objectValue.BaseClass, uncastedVariable.Name); } else { this.Variable = null; } @@ -32,15 +32,15 @@ namespace ICSharpCode.SharpDevelop.Gui.Pads } SetTexts("", - Variable.AsString.ToString(), - Variable.Type); + Variable.Value.AsString.ToString(), + Variable.Value.Type); ImageIndex = 0; // Class if (IsExpanded) { UpdateSubVariables(); } else { - if (Variable.MayHaveSubVariables) { // Always true + if (Variable.Value.MayHaveSubVariables) { // Always true Items.Add(new PlaceHolderItem()); // Show plus icon } } diff --git a/src/AddIns/Misc/Debugger/Debugger.AddIn/Project/Src/Pads/VariableListItems/VariableItem.cs b/src/AddIns/Misc/Debugger/Debugger.AddIn/Project/Src/Pads/VariableListItems/VariableItem.cs index d45a9c9585..88703bd5b7 100644 --- a/src/AddIns/Misc/Debugger/Debugger.AddIn/Project/Src/Pads/VariableListItems/VariableItem.cs +++ b/src/AddIns/Misc/Debugger/Debugger.AddIn/Project/Src/Pads/VariableListItems/VariableItem.cs @@ -15,11 +15,11 @@ namespace ICSharpCode.SharpDevelop.Gui.Pads { class VariableItem: VariableListItem { - Value variable; + Variable variable; bool baseClassItemAdded = false; - public Value Variable { + public Variable Variable { get { return variable; } @@ -40,7 +40,7 @@ namespace ICSharpCode.SharpDevelop.Gui.Pads } - public VariableItem(Value variable): base() + public VariableItem(Variable variable): base() { this.variable = variable; Refresh(); @@ -58,10 +58,10 @@ namespace ICSharpCode.SharpDevelop.Gui.Pads } SetTexts(variable.Name, - variable.AsString.ToString(), - variable.Type); + variable.Value.AsString, + variable.Value.Type); - if (variable is ObjectValue) { + if (variable.Value is ObjectValue) { ImageIndex = 0; // Class } else if (variable is PropertyVariable){ ImageIndex = 2; // Property @@ -72,7 +72,7 @@ namespace ICSharpCode.SharpDevelop.Gui.Pads if (IsExpanded) { UpdateSubVariables(); } else { - if (variable.MayHaveSubVariables) { + if (variable.Value.MayHaveSubVariables) { Items.Add(new PlaceHolderItem()); // Show plus icon } } @@ -88,13 +88,13 @@ namespace ICSharpCode.SharpDevelop.Gui.Pads } // Do not sort names of array items - if (Variable is ArrayValue) { + if (Variable.Value is ArrayValue) { this.Items.SortOrder = SortOrder.None; } else { this.Items.SortOrder = SortOrder.Ascending; } - LocalVarPad.UpdateVariables(this.Items, Variable.SubVariables); + LocalVarPad.UpdateVariables(this.Items, Variable.Value.SubVariables); } } } 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 268073c60d..02f1828198 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 @@ -19,9 +19,9 @@ namespace ICSharpCode.SharpDevelop.Services // 2 = text // 3 = value - Value variable; + Variable variable; - public Value Variable { + public Variable Variable { get { return variable; } @@ -34,16 +34,16 @@ namespace ICSharpCode.SharpDevelop.Services { } - public DynamicTreeDebuggerRow(Value variable) + public DynamicTreeDebuggerRow(Variable variable) { if (variable == null) throw new ArgumentNullException("variable"); this.variable = variable; this[2].Text = variable.Name; - this[3].Text = variable.ToString(); + this[3].Text = variable.Value.AsString; - if (!variable.MayHaveSubVariables) + if (!variable.Value.MayHaveSubVariables) this.ShowPlus = false; this.ShowMinusWhileExpanded = true; } diff --git a/src/AddIns/Misc/Debugger/Debugger.AddIn/Project/Src/Service/WindowsDebugger.cs b/src/AddIns/Misc/Debugger/Debugger.AddIn/Project/Src/Service/WindowsDebugger.cs index ce91ee89e8..dac8476c16 100644 --- a/src/AddIns/Misc/Debugger/Debugger.AddIn/Project/Src/Service/WindowsDebugger.cs +++ b/src/AddIns/Misc/Debugger/Debugger.AddIn/Project/Src/Service/WindowsDebugger.cs @@ -195,7 +195,7 @@ namespace ICSharpCode.SharpDevelop.Services /// Gets variable of given name. /// Returns null if unsuccessful. /// - public Value GetVariableFromName(string variableName) + public Variable GetVariableFromName(string variableName) { if (debugger == null || debugger.IsRunning) return null; @@ -217,12 +217,12 @@ namespace ICSharpCode.SharpDevelop.Services /// public string GetValueAsString(string variableName) { - Value variable = GetVariableFromName(variableName); + Variable variable = GetVariableFromName(variableName); if (variable == null) { return null; } else { - return variable.ToString(); + return variable.Value.AsString; } } @@ -232,7 +232,7 @@ namespace ICSharpCode.SharpDevelop.Services /// public DebuggerGridControl GetTooltipControl(string variableName) { - Value variable = GetVariableFromName(variableName); + Variable variable = GetVariableFromName(variableName); if (variable == null) { return null; @@ -251,7 +251,7 @@ namespace ICSharpCode.SharpDevelop.Services { DynamicTreeDebuggerRow row = (DynamicTreeDebuggerRow) sender; row.ChildRows.Clear(); - foreach(Value variable in row.Variable.SubVariables) { + foreach(Variable variable in row.Variable.Value.SubVariables) { DynamicTreeDebuggerRow newRow = new DynamicTreeDebuggerRow(variable); DebuggerGridControl.AddColumns(newRow.ChildColumns); newRow.Expanding += TooltipControlRowExpanding; 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 ac0ec29924..2b9c9855ea 100644 --- a/src/AddIns/Misc/Debugger/Debugger.Core/Project/Debugger.Core.csproj +++ b/src/AddIns/Misc/Debugger/Debugger.Core/Project/Debugger.Core.csproj @@ -205,6 +205,9 @@ + + + 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 b832dc5e50..abaa7dafa8 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 @@ -20,8 +20,8 @@ namespace Debugger NDebugger debugger; Thread thread; ICorDebugValue corValue; - Value runtimeVariable; - ObjectValue runtimeVariableException; + Value runtimeValue; + ObjectValue runtimeValueException; ExceptionType exceptionType; SourcecodeSegment location; DateTime creationTime; @@ -42,17 +42,17 @@ namespace Debugger this.thread = thread; thread.CorThread.GetCurrentException(out corValue); exceptionType = thread.CurrentExceptionType; - runtimeVariable = ValueFactory.CreateValue(debugger, corValue, "$exception"); - runtimeVariableException = runtimeVariable as ObjectValue; - if (runtimeVariableException != null) { - while (runtimeVariableException.Type != "System.Exception") { - if (runtimeVariableException.HasBaseClass == false) { - runtimeVariableException = null; + runtimeValue = ValueFactory.CreateValue(debugger, corValue); + runtimeValueException = runtimeValue as ObjectValue; + if (runtimeValueException != null) { + while (runtimeValueException.Type != "System.Exception") { + if (runtimeValueException.HasBaseClass == false) { + runtimeValueException = null; break; } - runtimeVariableException = runtimeVariableException.BaseClass; + runtimeValueException = runtimeValueException.BaseClass; } - message = runtimeVariableException.SubVariables["_message"].AsString.ToString(); + message = runtimeValueException.SubVariables["_message"].Value.AsString; } if (thread.LastFunctionWithLoadedSymbols != null) { @@ -76,13 +76,13 @@ namespace Debugger callstackItems++; } - type = runtimeVariable.Type; + type = runtimeValue.Type; } public override string ToString() { - return "Exception data:\n" + runtimeVariable.ToString() + "\n" + + return "Exception data:\n" + runtimeValue.ToString() + "\n" + "---------------\n" + - runtimeVariableException.SubVariables.ToString(); + runtimeValueException.SubVariables.ToString(); } public string Type { 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 6b54f0c616..8a5bd534b4 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 @@ -72,7 +72,7 @@ namespace Debugger } else { ICorDebugValue argThis = null; corILFrame.GetArgument(0, out argThis); - return new ObjectValue(debugger, argThis, "this", ContaingClass); + return new ObjectValue(debugger, argThis, ContaingClass); } } } @@ -411,9 +411,9 @@ namespace Debugger return arg; } - public Value GetArgumentVariable(int index) + public Variable GetArgumentVariable(int index) { - return ValueFactory.CreateValue(debugger, GetArgumentValue(index), GetParameterName(index)); + return VariableFactory.CreateVariable(debugger, GetArgumentValue(index), GetParameterName(index)); } public VariableCollection GetArgumentVariables() @@ -476,7 +476,7 @@ namespace Debugger { ICorDebugValue runtimeVar; corILFrame.GetLocalVariable((uint)symVar.AddressField1, out runtimeVar); - collection.Add(ValueFactory.CreateValue(debugger, runtimeVar, symVar.Name)); + collection.Add(VariableFactory.CreateVariable(debugger, runtimeVar, symVar.Name)); } } } 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 952756adf1..0bb2e7384c 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 @@ -107,21 +107,21 @@ namespace Debugger if (!HasBeenLoaded) return lastPriority; if (process.IsRunning) return lastPriority; - Value runTimeVar = RuntimeVariable; - if (runTimeVar is NullValue) return ThreadPriority.Normal; - lastPriority = (ThreadPriority)(int)(runTimeVar.SubVariables["m_Priority"] as PrimitiveValue).Primitive; + Value runTimeValue = RuntimeValue; + if (runTimeValue is NullValue) return ThreadPriority.Normal; + lastPriority = (ThreadPriority)(int)(runTimeValue.SubVariables["m_Priority"].Value as PrimitiveValue).Primitive; return lastPriority; } } - public Value RuntimeVariable { + public Value RuntimeValue { get { if (!HasBeenLoaded) throw new DebuggerException("Thread has not started jet"); process.AssertPaused(); ICorDebugValue corValue; corThread.GetObject(out corValue); - return ValueFactory.CreateValue(debugger, corValue, "Thread" + ID); + return ValueFactory.CreateValue(debugger, corValue); } } @@ -129,9 +129,9 @@ namespace Debugger get { if (!HasBeenLoaded) return lastName; if (process.IsRunning) return lastName; - Value runtimeVar = RuntimeVariable; + Value runtimeVar = RuntimeValue; if (runtimeVar is NullValue) return lastName; - Value runtimeName = runtimeVar.SubVariables["m_Name"]; + Value runtimeName = runtimeVar.SubVariables["m_Name"].Value; if (runtimeName is NullValue) return string.Empty; lastName = runtimeName.AsString.ToString(); return lastName; 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 a9cb0b3f51..8cd5968ca8 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 @@ -54,7 +54,7 @@ namespace Debugger } - internal unsafe ArrayValue(NDebugger debugger, ICorDebugValue corValue, string name):base(debugger, corValue, name) + internal unsafe ArrayValue(NDebugger debugger, ICorDebugValue corValue):base(debugger, corValue) { corArrayValue = (ICorDebugArrayValue)this.corValue; uint corElementTypeRaw; @@ -70,25 +70,25 @@ namespace Debugger } - public Value this[uint index] { + public Variable this[uint index] { get { return this[new uint[] {index}]; } } - public Value this[uint index1, uint index2] { + public Variable this[uint index1, uint index2] { get { return this[new uint[] {index1, index2}]; } } - public Value this[uint index1, uint index2, uint index3] { + public Variable this[uint index1, uint index2, uint index3] { get { return this[new uint[] {index1, index2, index3}]; } } - public unsafe Value this[uint[] indices] { + public unsafe Variable this[uint[] indices] { get { if (indices.Length != rank) throw new DebuggerException("Given indicies does not match array size."); @@ -101,7 +101,7 @@ namespace Debugger fixed (void* pIndices = indices) corArrayValue.GetElement(rank, new IntPtr(pIndices), out element); - return ValueFactory.CreateValue(debugger, element, elementName); + return VariableFactory.CreateVariable(debugger, element, elementName); } } 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 de2b3f6944..0c62d2a37f 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 @@ -117,7 +117,7 @@ namespace Debugger ICorDebugValue corValue; corEval.GetResult(out corValue); - result = ValueFactory.CreateValue(debugger, corValue, "eval result"); + result = ValueFactory.CreateValue(debugger, corValue); if (EvalComplete != null) { EvalComplete(this, e); 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 edb8e088d4..4b593cbc1f 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, ICorDebugValue corValue, string name):base(debugger, corValue, name) + internal unsafe NullValue(NDebugger debugger, ICorDebugValue corValue):base(debugger, corValue) { } 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 a6b21caa7f..1e89b9e8ab 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 @@ -38,13 +38,13 @@ namespace Debugger } - internal unsafe ObjectValue(NDebugger debugger, ICorDebugValue corValue, string name):base(debugger, corValue, name) + internal unsafe ObjectValue(NDebugger debugger, ICorDebugValue corValue):base(debugger, corValue) { ((ICorDebugObjectValue)this.corValue).GetClass(out corClass); InitObjectVariable(); } - internal unsafe ObjectValue(NDebugger debugger, ICorDebugValue corValue, string name, ICorDebugClass corClass):base(debugger, corValue, name) + internal unsafe ObjectValue(NDebugger debugger, ICorDebugValue corValue, ICorDebugClass corClass):base(debugger, corValue) { this.corClass = corClass; InitObjectVariable(); @@ -94,9 +94,9 @@ namespace Debugger ((ICorDebugObjectValue)corValue).GetFieldValue(corClass, field.Token, out fieldValue); } - subVariables.Add(ValueFactory.CreateValue(debugger, fieldValue, field.Name)); + subVariables.Add(VariableFactory.CreateVariable(debugger, fieldValue, field.Name)); } catch { - subVariables.Add(new UnavailableValue(debugger, null, field.Name)); + subVariables.Add(VariableFactory.CreateVariable(new UnavailableValue(debugger), field.Name)); } } @@ -155,7 +155,7 @@ namespace Debugger } else { ICorDebugClass superClass; corModuleSuperclass.GetClassFromToken(classProps.SuperClassToken, out superClass); - return new ObjectValue(debugger, corValue, Name, superClass); + return new ObjectValue(debugger, corValue, superClass); } } } 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 e07cd655fc..eb2152d6a1 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 @@ -79,7 +79,7 @@ namespace Debugger } } - internal PrimitiveValue(NDebugger debugger, ICorDebugValue corValue, string name):base(debugger, corValue, name) + internal PrimitiveValue(NDebugger debugger, ICorDebugValue corValue):base(debugger, corValue) { } diff --git a/src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Variables/PropertyVariable.cs b/src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Variables/PropertyVariable.cs index 552d8580aa..07da3f8220 100644 --- a/src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Variables/PropertyVariable.cs +++ b/src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Variables/PropertyVariable.cs @@ -11,7 +11,7 @@ using Debugger.Interop.CorDebug; namespace Debugger { - public class PropertyVariable: Value + public class PropertyVariable: Variable { Eval eval; @@ -30,77 +30,33 @@ namespace Debugger } } - public override string AsString { + public override Value Value { get { if (IsEvaluated) { if (eval.Result != null) { - return eval.Result.AsString; + return eval.Result; } else { - return String.Empty; + return new UnavailableValue(debugger, "No return value"); } } else { if (eval.Evaluating) { - return "Evaluating..."; + return new UnavailableValue(debugger, "Evaluating..."); } else { - return "Evaluation pending"; + return new UnavailableValue(debugger, "Evaluation pending"); } } } } - public override string Type { - get { - if (IsEvaluated) { - if (eval.Result != null) { - return eval.Result.Type; - } else { - return String.Empty; - } - } else { - return String.Empty; - } - } - } - - public override bool MayHaveSubVariables { - get { - if (IsEvaluated) { - if (eval.Result != null) { - return eval.Result.MayHaveSubVariables; - } else { - return true; - } - } else { - return true; - } - } - } - - protected override VariableCollection GetSubVariables() - { - if (IsEvaluated) { - if (eval.Result != null) { - return eval.Result.SubVariables; - } else { - return VariableCollection.Empty; - } - } else { - return VariableCollection.Empty; - } - } - void EvalStarted(object sender, EvalEventArgs args) { - OnValueChanged(new ValueEventArgs(this)); + OnValueChanged(); } void EvalComplete(object sender, EvalEventArgs args) { - if (eval.Result != null) { - eval.Result.Name = this.Name; - } OnValueEvaluated(); - OnValueChanged(new ValueEventArgs(this)); + OnValueChanged(); } protected void OnValueEvaluated() 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 949e5c6ef3..3248b83d99 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 @@ -14,22 +14,29 @@ namespace Debugger { public class UnavailableValue: Value { + string message; + public override string AsString { get { - return ""; + return message; } } public override string Type { get { - return ""; + return String.Empty; } } - - internal unsafe UnavailableValue(NDebugger debugger, ICorDebugValue corValue, string name):base(debugger, corValue, name) + + internal UnavailableValue(NDebugger debugger): this(debugger, "Value is not available") { } + + internal UnavailableValue(NDebugger debugger, string message):base(debugger, null) + { + this.message = message; + } public override bool MayHaveSubVariables { get { diff --git a/src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Variables/UnknownValue.cs b/src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Variables/UnknownValue.cs index b4514839b4..a151fb650f 100644 --- a/src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Variables/UnknownValue.cs +++ b/src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Variables/UnknownValue.cs @@ -26,7 +26,7 @@ namespace Debugger } } - internal unsafe UnknownValue(NDebugger debugger, ICorDebugValue corValue, string name):base(debugger, corValue, name) + internal unsafe UnknownValue(NDebugger debugger, ICorDebugValue corValue):base(debugger, corValue) { } 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 b2b9057851..9f689e1cbe 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,12 +16,8 @@ namespace Debugger { protected NDebugger debugger; - string name; protected ICorDebugValue corValue; VariableCollection subVariables; - CorElementType? corType; - - public event EventHandler ValueChanged; public NDebugger Debugger { get { @@ -29,22 +25,6 @@ namespace Debugger } } - protected virtual void OnValueChanged(ValueEventArgs e) - { - if (ValueChanged != null) { - ValueChanged(this, e); - } - } - - public string Name { - get{ - return name; - } - set { - name = value; - } - } - internal ICorDebugValue CorValue { get { return corValue; @@ -57,10 +37,7 @@ namespace Debugger internal CorElementType CorType { get { - if (!corType.HasValue) { - corType = GetCorType(corValue); - } - return corType.Value; + return GetCorType(corValue); } } @@ -75,19 +52,12 @@ namespace Debugger } public VariableCollection SubVariables { - get{ - if (subVariables == null) subVariables = GetSubVariables(); + get { + if (subVariables == null) { + subVariables = GetSubVariables(); + } return subVariables; - } - } - - internal Value(NDebugger debugger, ICorDebugValue corValue, string name) - { - this.debugger = debugger; - if (corValue != null) { - this.corValue = DereferenceUnbox(corValue); } - this.name = name; } protected virtual VariableCollection GetSubVariables() @@ -95,20 +65,18 @@ namespace Debugger return new VariableCollection(); } - public override string ToString() + internal Value(NDebugger debugger, ICorDebugValue corValue) { - //return String.Format("Name = {0,-25} Value = {1,-30} Type = {2,-30}", Name, Value, Type); - - if (AsString == null) { - return ""; - } else if (AsString is string) { - return "\"" + AsString.ToString() + "\""; - } else { - return AsString.ToString(); + this.debugger = debugger; + if (corValue != null) { + this.corValue = DereferenceUnbox(corValue); } } - + public override string ToString() + { + return AsString; + } internal static CorElementType GetCorType(ICorDebugValue corValue) { diff --git a/src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Variables/ValueEventArgs.cs b/src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Variables/ValueEventArgs.cs index 72312c240f..742ba351f7 100644 --- a/src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Variables/ValueEventArgs.cs +++ b/src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Variables/ValueEventArgs.cs @@ -18,9 +18,6 @@ namespace Debugger get { return val; } - set { - val = value; - } } public ValueEventArgs(Value val): base(val.Debugger) diff --git a/src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Variables/ValueFactory.cs b/src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Variables/ValueFactory.cs index 27c442b226..e8587b774a 100644 --- a/src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Variables/ValueFactory.cs +++ b/src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Variables/ValueFactory.cs @@ -13,13 +13,13 @@ namespace Debugger { static class ValueFactory { - public static Value CreateValue(NDebugger debugger, ICorDebugValue corValue, string name) + public static Value CreateValue(NDebugger debugger, ICorDebugValue corValue) { CorElementType type = Value.GetCorType(corValue); if (Value.DereferenceUnbox(corValue) == null) { - return new NullValue(debugger, corValue, name); + return new NullValue(debugger, corValue); } switch(type) @@ -39,19 +39,19 @@ namespace Debugger case CorElementType.I: case CorElementType.U: case CorElementType.STRING: - return new PrimitiveValue(debugger, corValue, name); + return new PrimitiveValue(debugger, corValue); case CorElementType.ARRAY: case CorElementType.SZARRAY: // Short-cut for single dimension zero lower bound array - return new ArrayValue(debugger, corValue, name); + return new ArrayValue(debugger, corValue); case CorElementType.VALUETYPE: case CorElementType.CLASS: case CorElementType.OBJECT: // Short-cut for Class "System.Object" - return new ObjectValue(debugger, corValue, name); + return new ObjectValue(debugger, corValue); default: // Unknown type - return new UnknownValue(debugger, corValue, name); + return new UnknownValue(debugger, corValue); } } } 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 new file mode 100644 index 0000000000..e6240c272b --- /dev/null +++ b/src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Variables/Variable.cs @@ -0,0 +1,53 @@ +// +// 2002-2005 AlphaSierraPapa +// GNU General Public License +// +// $Revision$ +// + +using System; + +namespace Debugger +{ + public class Variable: RemotingObjectBase + { + protected NDebugger debugger; + + string name; + Value val; + + public event EventHandler ValueChanged; + + public NDebugger Debugger { + get { + return debugger; + } + } + + public virtual string Name { + get{ + return name; + } + } + + public virtual Value Value { + get { + return val; + } + } + + protected virtual void OnValueChanged() + { + if (ValueChanged != null) { + ValueChanged(this, new VariableEventArgs(this)); + } + } + + public Variable(NDebugger debugger, Value val, string name) + { + this.debugger = debugger; + this.val = val; + this.name = name; + } + } +} 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 c7fa053d35..7fa58646ee 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 @@ -19,8 +19,8 @@ namespace Debugger bool readOnly = false; - public event EventHandler VariableAdded; - public event EventHandler VariableRemoved; + public event EventHandler VariableAdded; + public event EventHandler VariableRemoved; internal event EventHandler Updating; internal VariableCollection() @@ -45,9 +45,9 @@ namespace Debugger Empty.readOnly = true; } - public bool Contains(Value variable) + public bool Contains(Variable variable) { - foreach (Value v in InnerList) { + foreach (Variable v in InnerList) { if (v == variable) { return true; } @@ -57,7 +57,7 @@ namespace Debugger public bool Contains(string variableName) { - foreach (Value v in InnerList) { + foreach (Variable v in InnerList) { if (v.Name == variableName) { return true; } @@ -65,25 +65,25 @@ namespace Debugger return false; } - internal void Add(Value variable) + internal void Add(Variable variable) { if (readOnly) { throw new DebuggerException("VariableCollection is marked as read only"); } if (variable != null) { InnerList.Add(variable); - OnVariableAdded(new ValueEventArgs(variable)); + OnVariableAdded(new VariableEventArgs(variable)); } } - internal void Remove(Value variable) + internal void Remove(Variable variable) { if (readOnly) { throw new DebuggerException("VariableCollection is marked as read only"); } if (variable != null) { InnerList.Remove(variable); - OnVariableRemoved(new ValueEventArgs(variable)); + OnVariableRemoved(new VariableEventArgs(variable)); } } @@ -92,27 +92,27 @@ namespace Debugger /// internal void Clear() { - foreach(Value variable in InnerList) { + foreach(Variable variable in InnerList) { Remove(variable); } Updating = null; } - public Value this[int index] { + public Variable this[int index] { get { - return (Value) InnerList[index]; + return (Variable) InnerList[index]; } } - public Value this[string variableName] { + public Variable this[string variableName] { get { int index = variableName.IndexOf('.'); 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 (Value v in InnerList) { + foreach (Variable v in InnerList) { if (v.Name == variableName) { return v; } @@ -139,7 +139,7 @@ namespace Debugger mergedCollection.Update(); // Update existing variables - foreach(Value variable in mergedCollection) { + foreach(Variable variable in mergedCollection) { if (this.Contains(variable.Name)) { this.Remove(this[variable.Name]); this.Add(variable); @@ -147,28 +147,28 @@ namespace Debugger } // Add new variables - foreach(Value variable in mergedCollection) { + foreach(Variable variable in mergedCollection) { if (!this.Contains(variable.Name)) { this.Add(variable); } } // Remove variables that are not in merged collection - foreach(Value variable in this) { + foreach(Variable variable in this) { if (!mergedCollection.Contains(variable.Name)) { this.Remove(variable); } } } - protected virtual void OnVariableAdded(ValueEventArgs e) + protected virtual void OnVariableAdded(VariableEventArgs e) { if (VariableAdded != null) { VariableAdded(this, e); } } - protected virtual void OnVariableRemoved(ValueEventArgs e) + protected virtual void OnVariableRemoved(VariableEventArgs e) { if (VariableRemoved != null) { VariableRemoved(this, e); @@ -184,7 +184,7 @@ namespace Debugger public override string ToString() { string txt = ""; - foreach(Value v in this) { + foreach(Variable v in this) { txt += v.ToString() + "\n"; } @@ -202,14 +202,14 @@ namespace Debugger { // Add items of subcollections and ensure the stay in sync foreach(VariableCollection collection in collections) { - foreach(Value variable in collection) { + foreach(Variable variable in collection) { this.Add(variable); } - collection.VariableAdded += delegate(object sender, ValueEventArgs e) { - this.Add(e.Value); + collection.VariableAdded += delegate(object sender, VariableEventArgs e) { + this.Add(e.Variable); }; - collection.VariableRemoved += delegate(object sender, ValueEventArgs e) { - this.Remove(e.Value); + collection.VariableRemoved += delegate(object sender, VariableEventArgs e) { + this.Remove(e.Variable); }; } diff --git a/src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Variables/VariableEventArgs.cs b/src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Variables/VariableEventArgs.cs new file mode 100644 index 0000000000..06d6480eb8 --- /dev/null +++ b/src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Variables/VariableEventArgs.cs @@ -0,0 +1,28 @@ +// +// 2002-2005 AlphaSierraPapa +// GNU General Public License +// +// $Revision$ +// + +using System; + +namespace Debugger +{ + [Serializable] + public class VariableEventArgs : DebuggerEventArgs + { + Variable variable; + + public Variable Variable { + get { + return variable; + } + } + + public VariableEventArgs(Variable variable): base(variable.Debugger) + { + this.variable = variable; + } + } +} diff --git a/src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Variables/VariableFactory.cs b/src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Variables/VariableFactory.cs new file mode 100644 index 0000000000..650817d50f --- /dev/null +++ b/src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Variables/VariableFactory.cs @@ -0,0 +1,27 @@ +// +// 2002-2005 AlphaSierraPapa +// GNU General Public License +// +// $Revision$ +// + +using System; + +using Debugger.Interop.CorDebug; + +namespace Debugger +{ + public static class VariableFactory + { + internal static Variable CreateVariable(NDebugger debugger, ICorDebugValue corValue, string name) + { + Value val = ValueFactory.CreateValue(debugger, corValue); + return CreateVariable(val, name); + } + + public static Variable CreateVariable(Value val, string name) + { + return new Variable(val.Debugger, val, name); + } + } +}