Browse Source

Added Debugger.Variable

git-svn-id: svn://svn.sharpdevelop.net/sharpdevelop/trunk@751 1ccf3a8d-04fe-1044-b7c0-cef0b8235c61
shortcuts
David Srbecký 20 years ago
parent
commit
18d989267c
  1. 2
      src/AddIns/Misc/Debugger/Debugger.AddIn/Project/Src/Pads/CallStackPad.cs
  2. 4
      src/AddIns/Misc/Debugger/Debugger.AddIn/Project/Src/Pads/LocalVarPad.cs
  3. 14
      src/AddIns/Misc/Debugger/Debugger.AddIn/Project/Src/Pads/VariableListItems/BaseClassItem.cs
  4. 18
      src/AddIns/Misc/Debugger/Debugger.AddIn/Project/Src/Pads/VariableListItems/VariableItem.cs
  5. 10
      src/AddIns/Misc/Debugger/Debugger.AddIn/Project/Src/Service/DynamicTreeDebuggerRow.cs
  6. 10
      src/AddIns/Misc/Debugger/Debugger.AddIn/Project/Src/Service/WindowsDebugger.cs
  7. 3
      src/AddIns/Misc/Debugger/Debugger.Core/Project/Debugger.Core.csproj
  8. 26
      src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Threads/Exception.cs
  9. 8
      src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Threads/Function.cs
  10. 14
      src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Threads/Thread.cs
  11. 12
      src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Variables/ArrayValue.cs
  12. 2
      src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Variables/Evals/Eval.cs
  13. 2
      src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Variables/NullValue.cs
  14. 10
      src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Variables/ObjectValue.cs
  15. 2
      src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Variables/PrimitiveValue.cs
  16. 60
      src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Variables/PropertyVariable.cs
  17. 15
      src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Variables/UnavailableValue.cs
  18. 2
      src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Variables/UnknownValue.cs
  19. 58
      src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Variables/Value.cs
  20. 3
      src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Variables/ValueEventArgs.cs
  21. 12
      src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Variables/ValueFactory.cs
  22. 53
      src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Variables/Variable.cs
  23. 52
      src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Variables/VariableCollection.cs
  24. 28
      src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Variables/VariableEventArgs.cs
  25. 27
      src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Variables/VariableFactory.cs

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

@ -219,7 +219,7 @@ namespace ICSharpCode.SharpDevelop.Gui.Pads
} }
if (showArgumentValues) { if (showArgumentValues) {
try { try {
argValue = f.GetArgumentVariable(i).AsString.ToString(); argValue = f.GetArgumentVariable(i).Value.AsString;
} catch { } } catch { }
} }
if (parameterName != null && argValue != null) { if (parameterName != null && argValue != null) {

4
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) { foreach (VariableListItem item in items) {
VariableItem variableItem = item as VariableItem; VariableItem variableItem = item as VariableItem;
@ -142,7 +142,7 @@ namespace ICSharpCode.SharpDevelop.Gui.Pads
public static void UpdateVariables(TreeListViewItemCollection items, VariableCollection variables) public static void UpdateVariables(TreeListViewItemCollection items, VariableCollection variables)
{ {
// Add new variables and refresh existing ones // Add new variables and refresh existing ones
foreach (Value variable in variables) { foreach (Variable variable in variables) {
VariableItem item = FindVariableItem(items, variable); VariableItem item = FindVariableItem(items, variable);
if (item != null) { if (item != null) {
item.Variable = variable; item.Variable = variable;

14
src/AddIns/Misc/Debugger/Debugger.AddIn/Project/Src/Pads/VariableListItems/BaseClassItem.cs

@ -14,11 +14,11 @@ namespace ICSharpCode.SharpDevelop.Gui.Pads
{ {
class BaseClassItem: VariableItem class BaseClassItem: VariableItem
{ {
public BaseClassItem(Value uncastedVariable) public BaseClassItem(Variable uncastedVariable)
{ {
ObjectValue variable = uncastedVariable as ObjectValue; ObjectValue objectValue = uncastedVariable.Value as ObjectValue;
if (variable != null && variable.HasBaseClass && variable.BaseClass.Type != "System.Object") { if (objectValue != null && objectValue.HasBaseClass && objectValue.BaseClass.Type != "System.Object") {
this.Variable = variable.BaseClass; this.Variable = VariableFactory.CreateVariable(objectValue.BaseClass, uncastedVariable.Name);
} else { } else {
this.Variable = null; this.Variable = null;
} }
@ -32,15 +32,15 @@ namespace ICSharpCode.SharpDevelop.Gui.Pads
} }
SetTexts("<Base class>", SetTexts("<Base class>",
Variable.AsString.ToString(), Variable.Value.AsString.ToString(),
Variable.Type); Variable.Value.Type);
ImageIndex = 0; // Class ImageIndex = 0; // Class
if (IsExpanded) { if (IsExpanded) {
UpdateSubVariables(); UpdateSubVariables();
} else { } else {
if (Variable.MayHaveSubVariables) { // Always true if (Variable.Value.MayHaveSubVariables) { // Always true
Items.Add(new PlaceHolderItem()); // Show plus icon Items.Add(new PlaceHolderItem()); // Show plus icon
} }
} }

18
src/AddIns/Misc/Debugger/Debugger.AddIn/Project/Src/Pads/VariableListItems/VariableItem.cs

@ -15,11 +15,11 @@ namespace ICSharpCode.SharpDevelop.Gui.Pads
{ {
class VariableItem: VariableListItem class VariableItem: VariableListItem
{ {
Value variable; Variable variable;
bool baseClassItemAdded = false; bool baseClassItemAdded = false;
public Value Variable { public Variable Variable {
get { get {
return variable; return variable;
} }
@ -40,7 +40,7 @@ namespace ICSharpCode.SharpDevelop.Gui.Pads
} }
public VariableItem(Value variable): base() public VariableItem(Variable variable): base()
{ {
this.variable = variable; this.variable = variable;
Refresh(); Refresh();
@ -58,10 +58,10 @@ namespace ICSharpCode.SharpDevelop.Gui.Pads
} }
SetTexts(variable.Name, SetTexts(variable.Name,
variable.AsString.ToString(), variable.Value.AsString,
variable.Type); variable.Value.Type);
if (variable is ObjectValue) { if (variable.Value is ObjectValue) {
ImageIndex = 0; // Class ImageIndex = 0; // Class
} else if (variable is PropertyVariable){ } else if (variable is PropertyVariable){
ImageIndex = 2; // Property ImageIndex = 2; // Property
@ -72,7 +72,7 @@ namespace ICSharpCode.SharpDevelop.Gui.Pads
if (IsExpanded) { if (IsExpanded) {
UpdateSubVariables(); UpdateSubVariables();
} else { } else {
if (variable.MayHaveSubVariables) { if (variable.Value.MayHaveSubVariables) {
Items.Add(new PlaceHolderItem()); // Show plus icon Items.Add(new PlaceHolderItem()); // Show plus icon
} }
} }
@ -88,13 +88,13 @@ namespace ICSharpCode.SharpDevelop.Gui.Pads
} }
// Do not sort names of array items // Do not sort names of array items
if (Variable is ArrayValue) { if (Variable.Value is ArrayValue) {
this.Items.SortOrder = SortOrder.None; this.Items.SortOrder = SortOrder.None;
} else { } else {
this.Items.SortOrder = SortOrder.Ascending; this.Items.SortOrder = SortOrder.Ascending;
} }
LocalVarPad.UpdateVariables(this.Items, Variable.SubVariables); LocalVarPad.UpdateVariables(this.Items, Variable.Value.SubVariables);
} }
} }
} }

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

@ -19,9 +19,9 @@ namespace ICSharpCode.SharpDevelop.Services
// 2 = text // 2 = text
// 3 = value // 3 = value
Value variable; Variable variable;
public Value Variable { public Variable Variable {
get { get {
return variable; 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"); if (variable == null) throw new ArgumentNullException("variable");
this.variable = variable; this.variable = variable;
this[2].Text = variable.Name; 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.ShowPlus = false;
this.ShowMinusWhileExpanded = true; this.ShowMinusWhileExpanded = true;
} }

10
src/AddIns/Misc/Debugger/Debugger.AddIn/Project/Src/Service/WindowsDebugger.cs

@ -195,7 +195,7 @@ namespace ICSharpCode.SharpDevelop.Services
/// Gets variable of given name. /// Gets variable of given name.
/// Returns null if unsuccessful. /// Returns null if unsuccessful.
/// </summary> /// </summary>
public Value GetVariableFromName(string variableName) public Variable GetVariableFromName(string variableName)
{ {
if (debugger == null || debugger.IsRunning) return null; if (debugger == null || debugger.IsRunning) return null;
@ -217,12 +217,12 @@ namespace ICSharpCode.SharpDevelop.Services
/// </summary> /// </summary>
public string GetValueAsString(string variableName) public string GetValueAsString(string variableName)
{ {
Value variable = GetVariableFromName(variableName); Variable variable = GetVariableFromName(variableName);
if (variable == null) { if (variable == null) {
return null; return null;
} else { } else {
return variable.ToString(); return variable.Value.AsString;
} }
} }
@ -232,7 +232,7 @@ namespace ICSharpCode.SharpDevelop.Services
/// </summary> /// </summary>
public DebuggerGridControl GetTooltipControl(string variableName) public DebuggerGridControl GetTooltipControl(string variableName)
{ {
Value variable = GetVariableFromName(variableName); Variable variable = GetVariableFromName(variableName);
if (variable == null) { if (variable == null) {
return null; return null;
@ -251,7 +251,7 @@ namespace ICSharpCode.SharpDevelop.Services
{ {
DynamicTreeDebuggerRow row = (DynamicTreeDebuggerRow) sender; DynamicTreeDebuggerRow row = (DynamicTreeDebuggerRow) sender;
row.ChildRows.Clear(); row.ChildRows.Clear();
foreach(Value variable in row.Variable.SubVariables) { foreach(Variable variable in row.Variable.Value.SubVariables) {
DynamicTreeDebuggerRow newRow = new DynamicTreeDebuggerRow(variable); DynamicTreeDebuggerRow newRow = new DynamicTreeDebuggerRow(variable);
DebuggerGridControl.AddColumns(newRow.ChildColumns); DebuggerGridControl.AddColumns(newRow.ChildColumns);
newRow.Expanding += TooltipControlRowExpanding; newRow.Expanding += TooltipControlRowExpanding;

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

@ -205,6 +205,9 @@
<Compile Include="Src\Variables\ValueEventArgs.cs" /> <Compile Include="Src\Variables\ValueEventArgs.cs" />
<Compile Include="Src\Variables\ValueFactory.cs" /> <Compile Include="Src\Variables\ValueFactory.cs" />
<Compile Include="Src\Variables\VariableCollection.cs" /> <Compile Include="Src\Variables\VariableCollection.cs" />
<Compile Include="Src\Variables\Variable.cs" />
<Compile Include="Src\Variables\VariableEventArgs.cs" />
<Compile Include="Src\Variables\VariableFactory.cs" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<Content Include="README.TXT" /> <Content Include="README.TXT" />

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

@ -20,8 +20,8 @@ namespace Debugger
NDebugger debugger; NDebugger debugger;
Thread thread; Thread thread;
ICorDebugValue corValue; ICorDebugValue corValue;
Value runtimeVariable; Value runtimeValue;
ObjectValue runtimeVariableException; ObjectValue runtimeValueException;
ExceptionType exceptionType; ExceptionType exceptionType;
SourcecodeSegment location; SourcecodeSegment location;
DateTime creationTime; DateTime creationTime;
@ -42,17 +42,17 @@ namespace Debugger
this.thread = thread; this.thread = thread;
thread.CorThread.GetCurrentException(out corValue); thread.CorThread.GetCurrentException(out corValue);
exceptionType = thread.CurrentExceptionType; exceptionType = thread.CurrentExceptionType;
runtimeVariable = ValueFactory.CreateValue(debugger, corValue, "$exception"); runtimeValue = ValueFactory.CreateValue(debugger, corValue);
runtimeVariableException = runtimeVariable as ObjectValue; runtimeValueException = runtimeValue as ObjectValue;
if (runtimeVariableException != null) { if (runtimeValueException != null) {
while (runtimeVariableException.Type != "System.Exception") { while (runtimeValueException.Type != "System.Exception") {
if (runtimeVariableException.HasBaseClass == false) { if (runtimeValueException.HasBaseClass == false) {
runtimeVariableException = null; runtimeValueException = null;
break; break;
} }
runtimeVariableException = runtimeVariableException.BaseClass; runtimeValueException = runtimeValueException.BaseClass;
} }
message = runtimeVariableException.SubVariables["_message"].AsString.ToString(); message = runtimeValueException.SubVariables["_message"].Value.AsString;
} }
if (thread.LastFunctionWithLoadedSymbols != null) { if (thread.LastFunctionWithLoadedSymbols != null) {
@ -76,13 +76,13 @@ namespace Debugger
callstackItems++; callstackItems++;
} }
type = runtimeVariable.Type; type = runtimeValue.Type;
} }
public override string ToString() { public override string ToString() {
return "Exception data:\n" + runtimeVariable.ToString() + "\n" + return "Exception data:\n" + runtimeValue.ToString() + "\n" +
"---------------\n" + "---------------\n" +
runtimeVariableException.SubVariables.ToString(); runtimeValueException.SubVariables.ToString();
} }
public string Type { public string Type {

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

@ -72,7 +72,7 @@ namespace Debugger
} else { } else {
ICorDebugValue argThis = null; ICorDebugValue argThis = null;
corILFrame.GetArgument(0, out argThis); 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; 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() public VariableCollection GetArgumentVariables()
@ -476,7 +476,7 @@ namespace Debugger
{ {
ICorDebugValue runtimeVar; ICorDebugValue runtimeVar;
corILFrame.GetLocalVariable((uint)symVar.AddressField1, out runtimeVar); corILFrame.GetLocalVariable((uint)symVar.AddressField1, out runtimeVar);
collection.Add(ValueFactory.CreateValue(debugger, runtimeVar, symVar.Name)); collection.Add(VariableFactory.CreateVariable(debugger, runtimeVar, symVar.Name));
} }
} }
} }

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

@ -107,21 +107,21 @@ namespace Debugger
if (!HasBeenLoaded) return lastPriority; if (!HasBeenLoaded) return lastPriority;
if (process.IsRunning) return lastPriority; if (process.IsRunning) return lastPriority;
Value runTimeVar = RuntimeVariable; Value runTimeValue = RuntimeValue;
if (runTimeVar is NullValue) return ThreadPriority.Normal; if (runTimeValue is NullValue) return ThreadPriority.Normal;
lastPriority = (ThreadPriority)(int)(runTimeVar.SubVariables["m_Priority"] as PrimitiveValue).Primitive; lastPriority = (ThreadPriority)(int)(runTimeValue.SubVariables["m_Priority"].Value as PrimitiveValue).Primitive;
return lastPriority; return lastPriority;
} }
} }
public Value RuntimeVariable { public Value RuntimeValue {
get { get {
if (!HasBeenLoaded) throw new DebuggerException("Thread has not started jet"); if (!HasBeenLoaded) throw new DebuggerException("Thread has not started jet");
process.AssertPaused(); process.AssertPaused();
ICorDebugValue corValue; ICorDebugValue corValue;
corThread.GetObject(out corValue); corThread.GetObject(out corValue);
return ValueFactory.CreateValue(debugger, corValue, "Thread" + ID); return ValueFactory.CreateValue(debugger, corValue);
} }
} }
@ -129,9 +129,9 @@ namespace Debugger
get { get {
if (!HasBeenLoaded) return lastName; if (!HasBeenLoaded) return lastName;
if (process.IsRunning) return lastName; if (process.IsRunning) return lastName;
Value runtimeVar = RuntimeVariable; Value runtimeVar = RuntimeValue;
if (runtimeVar is NullValue) return lastName; 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; if (runtimeName is NullValue) return string.Empty;
lastName = runtimeName.AsString.ToString(); lastName = runtimeName.AsString.ToString();
return lastName; return lastName;

12
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; corArrayValue = (ICorDebugArrayValue)this.corValue;
uint corElementTypeRaw; uint corElementTypeRaw;
@ -70,25 +70,25 @@ namespace Debugger
} }
public Value this[uint index] { public Variable this[uint index] {
get { get {
return this[new uint[] {index}]; return this[new uint[] {index}];
} }
} }
public Value this[uint index1, uint index2] { public Variable this[uint index1, uint index2] {
get { get {
return this[new uint[] {index1, index2}]; 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 { get {
return this[new uint[] {index1, index2, index3}]; return this[new uint[] {index1, index2, index3}];
} }
} }
public unsafe Value this[uint[] indices] { public unsafe Variable this[uint[] indices] {
get { get {
if (indices.Length != rank) throw new DebuggerException("Given indicies does not match array size."); if (indices.Length != rank) throw new DebuggerException("Given indicies does not match array size.");
@ -101,7 +101,7 @@ namespace Debugger
fixed (void* pIndices = indices) fixed (void* pIndices = indices)
corArrayValue.GetElement(rank, new IntPtr(pIndices), out element); corArrayValue.GetElement(rank, new IntPtr(pIndices), out element);
return ValueFactory.CreateValue(debugger, element, elementName); return VariableFactory.CreateVariable(debugger, element, elementName);
} }
} }

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

@ -117,7 +117,7 @@ namespace Debugger
ICorDebugValue corValue; ICorDebugValue corValue;
corEval.GetResult(out corValue); corEval.GetResult(out corValue);
result = ValueFactory.CreateValue(debugger, corValue, "eval result"); result = ValueFactory.CreateValue(debugger, corValue);
if (EvalComplete != null) { if (EvalComplete != null) {
EvalComplete(this, e); EvalComplete(this, e);

2
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)
{ {
} }

10
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); ((ICorDebugObjectValue)this.corValue).GetClass(out corClass);
InitObjectVariable(); 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; this.corClass = corClass;
InitObjectVariable(); InitObjectVariable();
@ -94,9 +94,9 @@ namespace Debugger
((ICorDebugObjectValue)corValue).GetFieldValue(corClass, field.Token, out fieldValue); ((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 { } 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 { } else {
ICorDebugClass superClass; ICorDebugClass superClass;
corModuleSuperclass.GetClassFromToken(classProps.SuperClassToken, out superClass); corModuleSuperclass.GetClassFromToken(classProps.SuperClassToken, out superClass);
return new ObjectValue(debugger, corValue, Name, superClass); return new ObjectValue(debugger, corValue, superClass);
} }
} }
} }

2
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)
{ {
} }

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

@ -11,7 +11,7 @@ using Debugger.Interop.CorDebug;
namespace Debugger namespace Debugger
{ {
public class PropertyVariable: Value public class PropertyVariable: Variable
{ {
Eval eval; Eval eval;
@ -30,77 +30,33 @@ namespace Debugger
} }
} }
public override string AsString { public override Value Value {
get { get {
if (IsEvaluated) { if (IsEvaluated) {
if (eval.Result != null) { if (eval.Result != null) {
return eval.Result.AsString; return eval.Result;
} else { } else {
return String.Empty; return new UnavailableValue(debugger, "No return value");
} }
} else { } else {
if (eval.Evaluating) { if (eval.Evaluating) {
return "Evaluating..."; return new UnavailableValue(debugger, "Evaluating...");
} else { } 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) void EvalStarted(object sender, EvalEventArgs args)
{ {
OnValueChanged(new ValueEventArgs(this)); OnValueChanged();
} }
void EvalComplete(object sender, EvalEventArgs args) void EvalComplete(object sender, EvalEventArgs args)
{ {
if (eval.Result != null) {
eval.Result.Name = this.Name;
}
OnValueEvaluated(); OnValueEvaluated();
OnValueChanged(new ValueEventArgs(this)); OnValueChanged();
} }
protected void OnValueEvaluated() protected void OnValueEvaluated()

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

@ -14,22 +14,29 @@ namespace Debugger
{ {
public class UnavailableValue: Value public class UnavailableValue: Value
{ {
string message;
public override string AsString { public override string AsString {
get { get {
return "<unavailable>"; return message;
} }
} }
public override string Type { public override string Type {
get { get {
return "<unknown>"; 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 { public override bool MayHaveSubVariables {
get { get {

2
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)
{ {
} }

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

@ -16,12 +16,8 @@ namespace Debugger
{ {
protected NDebugger debugger; protected NDebugger debugger;
string name;
protected ICorDebugValue corValue; protected ICorDebugValue corValue;
VariableCollection subVariables; VariableCollection subVariables;
CorElementType? corType;
public event EventHandler<ValueEventArgs> ValueChanged;
public NDebugger Debugger { public NDebugger Debugger {
get { 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 { internal ICorDebugValue CorValue {
get { get {
return corValue; return corValue;
@ -57,10 +37,7 @@ namespace Debugger
internal CorElementType CorType { internal CorElementType CorType {
get { get {
if (!corType.HasValue) { return GetCorType(corValue);
corType = GetCorType(corValue);
}
return corType.Value;
} }
} }
@ -75,19 +52,12 @@ namespace Debugger
} }
public VariableCollection SubVariables { public VariableCollection SubVariables {
get{ get {
if (subVariables == null) subVariables = GetSubVariables(); if (subVariables == null) {
subVariables = GetSubVariables();
}
return subVariables; 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() protected virtual VariableCollection GetSubVariables()
@ -95,20 +65,18 @@ namespace Debugger
return new VariableCollection(); 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); this.debugger = debugger;
if (corValue != null) {
if (AsString == null) { this.corValue = DereferenceUnbox(corValue);
return "<null>";
} else if (AsString is string) {
return "\"" + AsString.ToString() + "\"";
} else {
return AsString.ToString();
} }
} }
public override string ToString()
{
return AsString;
}
internal static CorElementType GetCorType(ICorDebugValue corValue) internal static CorElementType GetCorType(ICorDebugValue corValue)
{ {

3
src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Variables/ValueEventArgs.cs

@ -18,9 +18,6 @@ namespace Debugger
get { get {
return val; return val;
} }
set {
val = value;
}
} }
public ValueEventArgs(Value val): base(val.Debugger) public ValueEventArgs(Value val): base(val.Debugger)

12
src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Variables/ValueFactory.cs

@ -13,13 +13,13 @@ namespace Debugger
{ {
static class ValueFactory 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); CorElementType type = Value.GetCorType(corValue);
if (Value.DereferenceUnbox(corValue) == null) if (Value.DereferenceUnbox(corValue) == null)
{ {
return new NullValue(debugger, corValue, name); return new NullValue(debugger, corValue);
} }
switch(type) switch(type)
@ -39,19 +39,19 @@ namespace Debugger
case CorElementType.I: case CorElementType.I:
case CorElementType.U: case CorElementType.U:
case CorElementType.STRING: case CorElementType.STRING:
return new PrimitiveValue(debugger, corValue, name); return new PrimitiveValue(debugger, corValue);
case CorElementType.ARRAY: case CorElementType.ARRAY:
case CorElementType.SZARRAY: // Short-cut for single dimension zero lower bound 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.VALUETYPE:
case CorElementType.CLASS: case CorElementType.CLASS:
case CorElementType.OBJECT: // Short-cut for Class "System.Object" case CorElementType.OBJECT: // Short-cut for Class "System.Object"
return new ObjectValue(debugger, corValue, name); return new ObjectValue(debugger, corValue);
default: // Unknown type default: // Unknown type
return new UnknownValue(debugger, corValue, name); return new UnknownValue(debugger, corValue);
} }
} }
} }

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

@ -0,0 +1,53 @@
// <file>
// <copyright see="prj:///doc/copyright.txt">2002-2005 AlphaSierraPapa</copyright>
// <license see="prj:///doc/license.txt">GNU General Public License</license>
// <owner name="David Srbecký" email="dsrbecky@gmail.com"/>
// <version>$Revision$</version>
// </file>
using System;
namespace Debugger
{
public class Variable: RemotingObjectBase
{
protected NDebugger debugger;
string name;
Value val;
public event EventHandler<VariableEventArgs> 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;
}
}
}

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

@ -19,8 +19,8 @@ namespace Debugger
bool readOnly = false; bool readOnly = false;
public event EventHandler<ValueEventArgs> VariableAdded; public event EventHandler<VariableEventArgs> VariableAdded;
public event EventHandler<ValueEventArgs> VariableRemoved; public event EventHandler<VariableEventArgs> VariableRemoved;
internal event EventHandler Updating; internal event EventHandler Updating;
internal VariableCollection() internal VariableCollection()
@ -45,9 +45,9 @@ namespace Debugger
Empty.readOnly = true; 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) { if (v == variable) {
return true; return true;
} }
@ -57,7 +57,7 @@ namespace Debugger
public bool Contains(string variableName) public bool Contains(string variableName)
{ {
foreach (Value v in InnerList) { foreach (Variable v in InnerList) {
if (v.Name == variableName) { if (v.Name == variableName) {
return true; return true;
} }
@ -65,25 +65,25 @@ namespace Debugger
return false; return false;
} }
internal void Add(Value variable) internal void Add(Variable variable)
{ {
if (readOnly) { if (readOnly) {
throw new DebuggerException("VariableCollection is marked as read only"); throw new DebuggerException("VariableCollection is marked as read only");
} }
if (variable != null) { if (variable != null) {
InnerList.Add(variable); InnerList.Add(variable);
OnVariableAdded(new ValueEventArgs(variable)); OnVariableAdded(new VariableEventArgs(variable));
} }
} }
internal void Remove(Value variable) internal void Remove(Variable variable)
{ {
if (readOnly) { if (readOnly) {
throw new DebuggerException("VariableCollection is marked as read only"); throw new DebuggerException("VariableCollection is marked as read only");
} }
if (variable != null) { if (variable != null) {
InnerList.Remove(variable); InnerList.Remove(variable);
OnVariableRemoved(new ValueEventArgs(variable)); OnVariableRemoved(new VariableEventArgs(variable));
} }
} }
@ -92,27 +92,27 @@ namespace Debugger
/// </summary> /// </summary>
internal void Clear() internal void Clear()
{ {
foreach(Value variable in InnerList) { foreach(Variable variable in InnerList) {
Remove(variable); Remove(variable);
} }
Updating = null; Updating = null;
} }
public Value this[int index] { public Variable this[int index] {
get { get {
return (Value) InnerList[index]; return (Variable) InnerList[index];
} }
} }
public Value this[string variableName] { public Variable this[string variableName] {
get { get {
int index = variableName.IndexOf('.'); int index = variableName.IndexOf('.');
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 (Value v in InnerList) { foreach (Variable v in InnerList) {
if (v.Name == variableName) { if (v.Name == variableName) {
return v; return v;
} }
@ -139,7 +139,7 @@ namespace Debugger
mergedCollection.Update(); mergedCollection.Update();
// Update existing variables // Update existing variables
foreach(Value variable in mergedCollection) { foreach(Variable variable in mergedCollection) {
if (this.Contains(variable.Name)) { if (this.Contains(variable.Name)) {
this.Remove(this[variable.Name]); this.Remove(this[variable.Name]);
this.Add(variable); this.Add(variable);
@ -147,28 +147,28 @@ namespace Debugger
} }
// Add new variables // Add new variables
foreach(Value variable in mergedCollection) { foreach(Variable variable in mergedCollection) {
if (!this.Contains(variable.Name)) { if (!this.Contains(variable.Name)) {
this.Add(variable); this.Add(variable);
} }
} }
// Remove variables that are not in merged collection // Remove variables that are not in merged collection
foreach(Value variable in this) { foreach(Variable variable in this) {
if (!mergedCollection.Contains(variable.Name)) { if (!mergedCollection.Contains(variable.Name)) {
this.Remove(variable); this.Remove(variable);
} }
} }
} }
protected virtual void OnVariableAdded(ValueEventArgs e) protected virtual void OnVariableAdded(VariableEventArgs e)
{ {
if (VariableAdded != null) { if (VariableAdded != null) {
VariableAdded(this, e); VariableAdded(this, e);
} }
} }
protected virtual void OnVariableRemoved(ValueEventArgs e) protected virtual void OnVariableRemoved(VariableEventArgs e)
{ {
if (VariableRemoved != null) { if (VariableRemoved != null) {
VariableRemoved(this, e); VariableRemoved(this, e);
@ -184,7 +184,7 @@ namespace Debugger
public override string ToString() { public override string ToString() {
string txt = ""; string txt = "";
foreach(Value v in this) { foreach(Variable v in this) {
txt += v.ToString() + "\n"; txt += v.ToString() + "\n";
} }
@ -202,14 +202,14 @@ namespace Debugger
{ {
// Add items of subcollections and ensure the stay in sync // Add items of subcollections and ensure the stay in sync
foreach(VariableCollection collection in collections) { foreach(VariableCollection collection in collections) {
foreach(Value variable in collection) { foreach(Variable variable in collection) {
this.Add(variable); this.Add(variable);
} }
collection.VariableAdded += delegate(object sender, ValueEventArgs e) { collection.VariableAdded += delegate(object sender, VariableEventArgs e) {
this.Add(e.Value); this.Add(e.Variable);
}; };
collection.VariableRemoved += delegate(object sender, ValueEventArgs e) { collection.VariableRemoved += delegate(object sender, VariableEventArgs e) {
this.Remove(e.Value); this.Remove(e.Variable);
}; };
} }

28
src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Variables/VariableEventArgs.cs

@ -0,0 +1,28 @@
// <file>
// <copyright see="prj:///doc/copyright.txt">2002-2005 AlphaSierraPapa</copyright>
// <license see="prj:///doc/license.txt">GNU General Public License</license>
// <owner name="David Srbecký" email="dsrbecky@gmail.com"/>
// <version>$Revision$</version>
// </file>
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;
}
}
}

27
src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Variables/VariableFactory.cs

@ -0,0 +1,27 @@
// <file>
// <copyright see="prj:///doc/copyright.txt">2002-2005 AlphaSierraPapa</copyright>
// <license see="prj:///doc/license.txt">GNU General Public License</license>
// <owner name="David Srbecký" email="dsrbecky@gmail.com"/>
// <version>$Revision$</version>
// </file>
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);
}
}
}
Loading…
Cancel
Save