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 @@ -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) {

4
src/AddIns/Misc/Debugger/Debugger.AddIn/Project/Src/Pads/LocalVarPad.cs

@ -128,7 +128,7 @@ namespace ICSharpCode.SharpDevelop.Gui.Pads @@ -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 @@ -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;

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

@ -14,11 +14,11 @@ namespace ICSharpCode.SharpDevelop.Gui.Pads @@ -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 @@ -32,15 +32,15 @@ namespace ICSharpCode.SharpDevelop.Gui.Pads
}
SetTexts("<Base class>",
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
}
}

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

@ -15,11 +15,11 @@ namespace ICSharpCode.SharpDevelop.Gui.Pads @@ -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 @@ -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 @@ -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 @@ -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 @@ -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);
}
}
}

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

@ -19,9 +19,9 @@ namespace ICSharpCode.SharpDevelop.Services @@ -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 @@ -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;
}

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

@ -195,7 +195,7 @@ namespace ICSharpCode.SharpDevelop.Services @@ -195,7 +195,7 @@ namespace ICSharpCode.SharpDevelop.Services
/// Gets variable of given name.
/// Returns null if unsuccessful.
/// </summary>
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 @@ -217,12 +217,12 @@ namespace ICSharpCode.SharpDevelop.Services
/// </summary>
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 @@ -232,7 +232,7 @@ namespace ICSharpCode.SharpDevelop.Services
/// </summary>
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 @@ -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;

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

@ -205,6 +205,9 @@ @@ -205,6 +205,9 @@
<Compile Include="Src\Variables\ValueEventArgs.cs" />
<Compile Include="Src\Variables\ValueFactory.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>
<Content Include="README.TXT" />

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

@ -20,8 +20,8 @@ namespace Debugger @@ -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 @@ -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 @@ -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 {

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

@ -72,7 +72,7 @@ namespace Debugger @@ -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 @@ -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 @@ -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));
}
}
}

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

@ -107,21 +107,21 @@ namespace Debugger @@ -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 @@ -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;

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

@ -54,7 +54,7 @@ namespace Debugger @@ -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 @@ -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 @@ -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);
}
}

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

@ -117,7 +117,7 @@ namespace Debugger @@ -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);

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

@ -36,7 +36,7 @@ namespace Debugger @@ -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 @@ -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 @@ -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 @@ -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);
}
}
}

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

@ -79,7 +79,7 @@ namespace Debugger @@ -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; @@ -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 @@ -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()

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

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

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

@ -26,7 +26,7 @@ namespace Debugger @@ -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 @@ -16,12 +16,8 @@ namespace Debugger
{
protected NDebugger debugger;
string name;
protected ICorDebugValue corValue;
VariableCollection subVariables;
CorElementType? corType;
public event EventHandler<ValueEventArgs> ValueChanged;
public NDebugger Debugger {
get {
@ -29,22 +25,6 @@ namespace Debugger @@ -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 @@ -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 @@ -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 @@ -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 "<null>";
} 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)
{

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

@ -18,9 +18,6 @@ namespace Debugger @@ -18,9 +18,6 @@ namespace Debugger
get {
return val;
}
set {
val = value;
}
}
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 @@ -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 @@ -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);
}
}
}

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

@ -0,0 +1,53 @@ @@ -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 @@ -19,8 +19,8 @@ namespace Debugger
bool readOnly = false;
public event EventHandler<ValueEventArgs> VariableAdded;
public event EventHandler<ValueEventArgs> VariableRemoved;
public event EventHandler<VariableEventArgs> VariableAdded;
public event EventHandler<VariableEventArgs> VariableRemoved;
internal event EventHandler Updating;
internal VariableCollection()
@ -45,9 +45,9 @@ namespace Debugger @@ -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 @@ -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 @@ -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 @@ -92,27 +92,27 @@ namespace Debugger
/// </summary>
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 @@ -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 @@ -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 @@ -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 @@ -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);
};
}

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

@ -0,0 +1,28 @@ @@ -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 @@ @@ -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