Browse Source

Variable spit into Variable and Value; Value is taking most of the control

git-svn-id: svn://svn.sharpdevelop.net/sharpdevelop/trunk@2022 1ccf3a8d-04fe-1044-b7c0-cef0b8235c61
shortcuts
David Srbecký 19 years ago
parent
commit
15bcad7d39
  1. 30
      src/AddIns/Misc/Debugger/Debugger.BooInterpreter/Project/Src/DebugeeInterpreterContext.cs
  2. 5
      src/AddIns/Misc/Debugger/Debugger.Core/Project/Debugger.Core.csproj
  3. 4
      src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Threads/Exception.cs
  4. 47
      src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Threads/Function.cs
  5. 14
      src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Threads/Thread.cs
  6. 29
      src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Variables/ArrayElement.cs
  7. 16
      src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Variables/ArrayValue.cs
  8. 15
      src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Variables/Evals/CallFunctionEval.cs
  9. 53
      src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Variables/Evals/Eval.cs
  10. 7
      src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Variables/Evals/NewObjectEval.cs
  11. 7
      src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Variables/Evals/NewStringEval.cs
  12. 22
      src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Variables/LocalVariable.cs
  13. 31
      src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Variables/MethodArgument.cs
  14. 2
      src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Variables/NullValue.cs
  15. 50
      src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Variables/ObjectMember.cs
  16. 16
      src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Variables/ObjectValue.cs
  17. 54
      src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Variables/ObjectValueClass.cs
  18. 4
      src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Variables/PrimitiveValue.cs
  19. 2
      src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Variables/UnavailableValue.cs
  20. 20
      src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Variables/Value.cs
  21. 6
      src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Variables/ValueEventArgs.cs
  22. 71
      src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Variables/Variable.cs
  23. 91
      src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Variables/Variable2.cs
  24. 2
      src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Variables/VariableEventArgs.cs

30
src/AddIns/Misc/Debugger/Debugger.BooInterpreter/Project/Src/DebugeeInterpreterContext.cs

@ -24,8 +24,8 @@ namespace Debugger @@ -24,8 +24,8 @@ namespace Debugger
public class DebugeeInterpreterContext: InterpreterContext
{
Process process;
Variable interpreter;
Variable interpreter_localVariable;
Value interpreter;
Value interpreter_localVariable;
public DebugeeInterpreterContext()
{
@ -60,15 +60,15 @@ namespace Debugger @@ -60,15 +60,15 @@ namespace Debugger
process.LogMessage -= OnDebuggerLogMessage;
process.LogMessage += OnDebuggerLogMessage;
Variable assembly;
Value assembly;
// Boo.Lang.Interpreter.dll
string path = Path.Combine(Path.GetDirectoryName(typeof(InterpreterContext).Assembly.Location), "Boo.Lang.Interpreter.dll");
assembly = LoadAssembly(path);
// Debugger.BooInterpreter.dll
assembly = LoadAssembly(typeof(DebugeeInteractiveInterpreter).Assembly.Location);
Variable interpreterType = Eval.NewString(process, typeof(DebugeeInteractiveInterpreter).FullName);
interpreter = Eval.CallFunction(process, typeof(Assembly), "CreateInstance", assembly, new Variable[] {interpreterType});
interpreter_localVariable = interpreter.ValueProxy.SubVariables["localVariable"];
Value interpreterType = Eval.NewString(process, typeof(DebugeeInteractiveInterpreter).FullName);
interpreter = Eval.CallFunction(process, typeof(Assembly), "CreateInstance", assembly, new Value[] {interpreterType});
interpreter_localVariable = interpreter.ValueProxy.SubVariables["localVariable"].Value;
RunCommand(
"import System\n" +
"import System.IO\n" +
@ -79,18 +79,18 @@ namespace Debugger @@ -79,18 +79,18 @@ namespace Debugger
return true;
}
Variable LoadAssembly(string path)
Value LoadAssembly(string path)
{
Variable assemblyPath = Eval.NewString(process, path);
Variable assembly = Eval.CallFunction(process, typeof(Assembly), "LoadFrom", null, new Variable[] {assemblyPath});
Value assemblyPath = Eval.NewString(process, path);
Value assembly = Eval.CallFunction(process, typeof(Assembly), "LoadFrom", null, new Value[] {assemblyPath});
return assembly;
}
public override void RunCommand(string code)
{
if (CanLoadInterpreter) {
Variable cmd = Eval.NewString(process, code);
Eval.CallFunction(process, typeof(InteractiveInterpreter), "LoopEval", interpreter, new Variable[] {cmd});
Value cmd = Eval.NewString(process, code);
Eval.CallFunction(process, typeof(InteractiveInterpreter), "LoopEval", interpreter, new Value[] {cmd});
}
}
@ -102,8 +102,8 @@ namespace Debugger @@ -102,8 +102,8 @@ namespace Debugger
public override string[] SuggestCodeCompletion(string code)
{
if (CanLoadInterpreter) {
Variable cmd = Eval.NewString(process, code);
Eval.CallFunction(process, typeof(AbstractInterpreter), "SuggestCodeCompletion", interpreter, new Variable[] {cmd});
Value cmd = Eval.NewString(process, code);
Eval.CallFunction(process, typeof(AbstractInterpreter), "SuggestCodeCompletion", interpreter, new Value[] {cmd});
return null;
} else {
return null;
@ -140,7 +140,7 @@ namespace Debugger @@ -140,7 +140,7 @@ namespace Debugger
Stepper stepOut = new Stepper(process.SelectedThread.LastFunction, "Boo interperter");
stepOut.StepComplete += delegate {
process.Debugger.MTA2STA.AsyncCall(delegate {
if (!interpreter_localVariable.SetValue(localVar)) {
if (!interpreter_localVariable.SetValue(localVar.Value)) {
PrintLine("Getting of local variable " + name + " failed");
}
process.Continue();
@ -158,7 +158,7 @@ namespace Debugger @@ -158,7 +158,7 @@ namespace Debugger
return;
}
PrintLine("Setting local variable " + name);
localVar.SetValue(interpreter_localVariable);
localVar.Value.SetValue(interpreter_localVariable);
}
}
}

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

@ -384,6 +384,11 @@ @@ -384,6 +384,11 @@
<Compile Include="Src\Debugger\IMutable.cs" />
<Compile Include="Src\Debugger\ExceptionEventArgs.cs" />
<Compile Include="Src\Debugger\Internal\ManagedCallbackSwitch.cs" />
<Compile Include="Src\Variables\Variable2.cs" />
<Compile Include="Src\Variables\ObjectMember.cs" />
<Compile Include="Src\Variables\MethodArgument.cs" />
<Compile Include="Src\Variables\LocalVariable.cs" />
<Compile Include="Src\Variables\ArrayElement.cs" />
</ItemGroup>
<ItemGroup>
<Content Include="README.TXT" />

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

@ -37,9 +37,7 @@ namespace Debugger @@ -37,9 +37,7 @@ namespace Debugger
this.thread = thread;
corValue = thread.CorThread.CurrentException;
exceptionType = thread.CurrentExceptionType;
runtimeValue = new Variable(process,
"$exception",
Variable.Flags.Default,
runtimeValue = new Value(process,
new IExpirable[] {process.PauseSession},
new IMutable[] {},
delegate { return corValue; } ).ValueProxy;

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

@ -362,7 +362,7 @@ namespace Debugger @@ -362,7 +362,7 @@ namespace Debugger
IEnumerable<Variable> GetVariables()
{
if (!IsStatic) {
yield return ThisVariable;
yield return new Variable("this", ThisValue);
}
foreach(Variable var in ArgumentVariables) {
yield return var;
@ -375,14 +375,14 @@ namespace Debugger @@ -375,14 +375,14 @@ namespace Debugger
}
}
public Variable ThisVariable {
public Value ThisValue {
get {
return new Variable(process,
"this",
Variable.Flags.Default,
return new Value(
process,
new IExpirable[] {this},
new IMutable[] {},
delegate { return ThisCorValue; });
delegate { return ThisCorValue; }
);
}
}
@ -404,7 +404,7 @@ namespace Debugger @@ -404,7 +404,7 @@ namespace Debugger
get {
// TODO: Should work for static
if (!IsStatic) {
foreach(Variable var in ThisVariable.ValueProxy.SubVariables) {
foreach(Variable var in ThisValue.ValueProxy.SubVariables) {
yield return var;
}
}
@ -432,14 +432,18 @@ namespace Debugger @@ -432,14 +432,18 @@ namespace Debugger
}
}
public Variable GetArgumentVariable(int index)
public MethodArgument GetArgumentVariable(int index)
{
return new Variable(process,
return new MethodArgument(
GetParameterName(index),
Variable.Flags.Default,
index,
new Value(
process,
new IExpirable[] {this},
new IMutable[] {process.DebugeeState},
delegate { return GetArgumentCorValue(index); } );
delegate { return GetArgumentCorValue(index); }
)
);
}
ICorDebugValue GetArgumentCorValue(int index)
@ -455,7 +459,7 @@ namespace Debugger @@ -455,7 +459,7 @@ namespace Debugger
}
}
public IEnumerable<Variable> ArgumentVariables {
public IEnumerable<MethodArgument> ArgumentVariables {
get {
for (int i = 0; i < ArgumentCount; i++) {
yield return GetArgumentVariable(i);
@ -463,11 +467,11 @@ namespace Debugger @@ -463,11 +467,11 @@ namespace Debugger
}
}
public IEnumerable<Variable> LocalVariables {
public IEnumerable<LocalVariable> LocalVariables {
get {
if (symMethod != null) { // TODO: Is this needed?
ISymUnmanagedScope symRootScope = symMethod.RootScope;
foreach(Variable var in GetLocalVariablesInScope(symRootScope)) {
foreach(LocalVariable var in GetLocalVariablesInScope(symRootScope)) {
if (!var.Name.StartsWith("CS$")) { // TODO: Generalize
yield return var;
}
@ -476,26 +480,29 @@ namespace Debugger @@ -476,26 +480,29 @@ namespace Debugger
}
}
IEnumerable<Variable> GetLocalVariablesInScope(ISymUnmanagedScope symScope)
IEnumerable<LocalVariable> GetLocalVariablesInScope(ISymUnmanagedScope symScope)
{
foreach (ISymUnmanagedVariable symVar in symScope.Locals) {
yield return GetLocalVariable(symVar);
}
foreach(ISymUnmanagedScope childScope in symScope.Children) {
foreach(Variable var in GetLocalVariablesInScope(childScope)) {
foreach(LocalVariable var in GetLocalVariablesInScope(childScope)) {
yield return var;
}
}
}
Variable GetLocalVariable(ISymUnmanagedVariable symVar)
LocalVariable GetLocalVariable(ISymUnmanagedVariable symVar)
{
return new Variable(process,
return new LocalVariable(
symVar.Name,
Variable.Flags.Default,
new Value(
process,
new IExpirable[] {this},
new IMutable[] {process.DebugeeState},
delegate { return GetCorValueOfLocalVariable(symVar); });
delegate { return GetCorValueOfLocalVariable(symVar); }
)
);
}
ICorDebugValue GetCorValueOfLocalVariable(ISymUnmanagedVariable symVar)

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

@ -149,24 +149,24 @@ namespace Debugger @@ -149,24 +149,24 @@ namespace Debugger
if (!HasBeenLoaded) return lastPriority;
if (process.IsRunning) return lastPriority;
ValueProxy runTimeValue = RuntimeValue;
ValueProxy runTimeValue = RuntimeValue.ValueProxy;
if (runTimeValue is NullValue) return ThreadPriority.Normal;
lastPriority = (ThreadPriority)(int)(runTimeValue["m_Priority"].ValueProxy as PrimitiveValue).Primitive;
return lastPriority;
}
}
public ValueProxy RuntimeValue {
public Value RuntimeValue {
get {
if (!HasBeenLoaded) throw new DebuggerException("Thread has not started jet");
process.AssertPaused();
return new Variable(process,
"thread" + id,
Variable.Flags.Default,
return new Value(
process,
new IExpirable[] {process.PauseSession},
new IMutable[] {},
delegate { return CorThread.Object;} ).ValueProxy;
delegate { return CorThread.Object;}
);
}
}
@ -174,7 +174,7 @@ namespace Debugger @@ -174,7 +174,7 @@ namespace Debugger
get {
if (!HasBeenLoaded) return lastName;
if (process.IsRunning) return lastName;
ValueProxy runtimeVar = RuntimeValue;
ValueProxy runtimeVar = RuntimeValue.ValueProxy;
if (runtimeVar is NullValue) return lastName;
ValueProxy runtimeName = runtimeVar["m_Name"].ValueProxy;
if (runtimeName is NullValue) return string.Empty;

29
src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Variables/ArrayElement.cs

@ -0,0 +1,29 @@ @@ -0,0 +1,29 @@
// <file>
// <copyright see="prj:///doc/copyright.txt"/>
// <license see="prj:///doc/license.txt"/>
// <owner name="David Srbecký" email="dsrbecky@gmail.com"/>
// <version>$Revision$</version>
// </file>
using System;
using System.Collections.Generic;
using Debugger.Wrappers.CorDebug;
namespace Debugger
{
public class ArrayElement: Variable
{
uint[] indicies;
public uint[] Indicies {
get { return indicies; }
}
public ArrayElement(string name, uint[] indicies, Value @value)
:base (name, @value)
{
this.indicies = indicies;
}
}
}

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

@ -57,7 +57,7 @@ namespace Debugger @@ -57,7 +57,7 @@ namespace Debugger
}
internal unsafe ArrayValue(Variable variable):base(variable)
internal unsafe ArrayValue(Value @value):base(@value)
{
corElementType = (CorElementType)CorArrayValue.ElementType;
@ -115,12 +115,16 @@ namespace Debugger @@ -115,12 +115,16 @@ namespace Debugger
elementName += indices[i].ToString() + ",";
elementName = elementName.TrimEnd(new char[] {','}) + "]";
return new Variable(Process,
return new ArrayElement(
elementName,
Variable.Flags.Default,
new IExpirable[] {this.Variable},
new IMutable[] {this.Variable},
delegate { return GetCorValueOfItem(indices); });
indices,
new Value(
Process,
new IExpirable[] {this.Value},
new IMutable[] {this.Value},
delegate { return GetCorValueOfItem(indices); }
)
);
}
unsafe ICorDebugValue GetCorValueOfItem(uint[] indices)

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

@ -14,11 +14,16 @@ namespace Debugger @@ -14,11 +14,16 @@ namespace Debugger
class CallFunctionEval: Eval
{
ICorDebugFunction corFunction;
Variable thisValue;
Variable[] args;
Value thisValue;
Value[] args;
public CallFunctionEval(Process process, string name, Flags flags, IExpirable[] expireDependencies, IMutable[] mutateDependencies, ICorDebugFunction corFunction, Variable thisValue, Variable[] args)
:base(process, name, flags, expireDependencies, mutateDependencies)
public CallFunctionEval(Process process,
IExpirable[] expireDependencies,
IMutable[] mutateDependencies,
ICorDebugFunction corFunction,
Value thisValue,
Value[] args)
:base(process, expireDependencies, mutateDependencies)
{
this.corFunction = corFunction;
this.thisValue = thisValue;
@ -39,7 +44,7 @@ namespace Debugger @@ -39,7 +44,7 @@ namespace Debugger
}
corArgs.Add(thisValue.SoftReference);
}
foreach(Variable arg in args) {
foreach(Value arg in args) {
corArgs.Add(arg.SoftReference);
}
} catch (CannotGetValueException e) {

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

@ -16,7 +16,7 @@ namespace Debugger @@ -16,7 +16,7 @@ namespace Debugger
/// <summary>
/// This class holds information about function evaluation.
/// </summary>
public abstract partial class Eval: Variable
public abstract partial class Eval: Value
{
protected class EvalSetupException: System.Exception
{
@ -29,6 +29,8 @@ namespace Debugger @@ -29,6 +29,8 @@ namespace Debugger
EvalState currentState = EvalState.WaitingForRequest;
string currentErrorMsg;
string description = String.Empty;
public EvalState State {
get {
return currentState;
@ -50,8 +52,15 @@ namespace Debugger @@ -50,8 +52,15 @@ namespace Debugger
}
}
protected Eval(Process process, string name, Flags flags, IExpirable[] expireDependencies, IMutable[] mutateDependencies)
:base(process, name, flags, expireDependencies, mutateDependencies, null)
public string Description {
get { return description; }
set { description = value; }
}
protected Eval(Process process,
IExpirable[] expireDependencies,
IMutable[] mutateDependencies)
:base(process, expireDependencies, mutateDependencies, null)
{
}
@ -75,46 +84,52 @@ namespace Debugger @@ -75,46 +84,52 @@ namespace Debugger
/// <summary>
/// Synchronously calls a function and returns its return value
/// </summary>
public static Variable CallFunction(Process process, Type type, string functionName, Variable thisValue, Variable[] args)
public static Value CallFunction(Process process, Type type, string functionName, Value thisValue, Value[] args)
{
string moduleName = System.IO.Path.GetFileName(type.Assembly.Location);
Module module = process.GetModule(moduleName);
string containgType = type.FullName;
ICorDebugFunction corFunction = module.GetMethod(containgType, functionName, args.Length);
return new CallFunctionEval(process,
"Function call: " + containgType + "." + functionName,
Variable.Flags.Default,
Eval eval = new CallFunctionEval(
process,
new IExpirable[] {},
new IMutable[] {},
corFunction,
thisValue,
args).EvaluateNow();
args
);
eval.Description = "Function call: " + containgType + "." + functionName;
return eval.EvaluateNow();
}
/// <summary>
/// Synchronously creates a new string
/// </summary>
public static Variable NewString(Process process, string textToCreate)
public static Value NewString(Process process, string textToCreate)
{
return new NewStringEval(process,
"New string: " + textToCreate,
Variable.Flags.Default,
Eval eval = new NewStringEval(
process,
new IExpirable[] {},
new IMutable[] {},
textToCreate).EvaluateNow();
textToCreate
);
eval.Description = "New string: " + textToCreate;
return eval.EvaluateNow();
}
/// <summary>
/// Synchronously creates a new object
/// </summary>
public static Variable NewObject(Process process, ICorDebugClass classToCreate)
public static Value NewObject(Process process, ICorDebugClass classToCreate)
{
return new NewObjectEval(process,
"New object: " + classToCreate.Token,
Variable.Flags.Default,
Eval eval = new NewObjectEval(
process,
new IExpirable[] {},
new IMutable[] {},
classToCreate).EvaluateNow();
classToCreate
);
eval.Description = "New object: " + classToCreate.Token;
return eval.EvaluateNow();
}
protected override ICorDebugValue RawCorValue {
@ -182,7 +197,7 @@ namespace Debugger @@ -182,7 +197,7 @@ namespace Debugger
protected abstract void StartEvaluation();
public Variable EvaluateNow()
public Value EvaluateNow()
{
while (State == EvalState.WaitingForRequest) {
ScheduleEvaluation();

7
src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Variables/Evals/NewObjectEval.cs

@ -14,8 +14,11 @@ namespace Debugger @@ -14,8 +14,11 @@ namespace Debugger
{
ICorDebugClass classToCreate;
public NewObjectEval(Process process, string name, Flags flags, IExpirable[] expireDependencies, IMutable[] mutateDependencies, ICorDebugClass classToCreate)
:base(process, name, flags, expireDependencies, mutateDependencies)
public NewObjectEval(Process process,
IExpirable[] expireDependencies,
IMutable[] mutateDependencies,
ICorDebugClass classToCreate)
:base(process, expireDependencies, mutateDependencies)
{
this.classToCreate = classToCreate;
}

7
src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Variables/Evals/NewStringEval.cs

@ -13,8 +13,11 @@ namespace Debugger @@ -13,8 +13,11 @@ namespace Debugger
{
string textToCreate;
public NewStringEval(Process process, string name, Flags flags, IExpirable[] expireDependencies, IMutable[] mutateDependencies, string textToCreate)
:base(process, name, flags, expireDependencies, mutateDependencies)
public NewStringEval(Process process,
IExpirable[] expireDependencies,
IMutable[] mutateDependencies,
string textToCreate)
:base(process, expireDependencies, mutateDependencies)
{
this.textToCreate = textToCreate;
}

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

@ -0,0 +1,22 @@ @@ -0,0 +1,22 @@
// <file>
// <copyright see="prj:///doc/copyright.txt"/>
// <license see="prj:///doc/license.txt"/>
// <owner name="David Srbecký" email="dsrbecky@gmail.com"/>
// <version>$Revision$</version>
// </file>
using System;
using System.Collections.Generic;
using Debugger.Wrappers.CorDebug;
namespace Debugger
{
public class LocalVariable: Variable
{
public LocalVariable(string name, Value @value)
:base (name, @value)
{
}
}
}

31
src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Variables/MethodArgument.cs

@ -0,0 +1,31 @@ @@ -0,0 +1,31 @@
// <file>
// <copyright see="prj:///doc/copyright.txt"/>
// <license see="prj:///doc/license.txt"/>
// <owner name="David Srbecký" email="dsrbecky@gmail.com"/>
// <version>$Revision$</version>
// </file>
using System;
using System.Collections.Generic;
using Debugger.Wrappers.CorDebug;
namespace Debugger
{
public class MethodArgument: Variable
{
int index;
public int Index {
get {
return index;
}
}
public MethodArgument(string name, int index, Value @value)
:base (name, @value)
{
this.index = index;
}
}
}

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

@ -33,7 +33,7 @@ namespace Debugger @@ -33,7 +33,7 @@ namespace Debugger
}
}
internal unsafe NullValue(Variable variable):base(variable)
internal unsafe NullValue(Value @value):base(@value)
{
}

50
src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Variables/ObjectMember.cs

@ -0,0 +1,50 @@ @@ -0,0 +1,50 @@
// <file>
// <copyright see="prj:///doc/copyright.txt"/>
// <license see="prj:///doc/license.txt"/>
// <owner name="David Srbecký" email="dsrbecky@gmail.com"/>
// <version>$Revision$</version>
// </file>
using System;
using System.Collections.Generic;
using Debugger.Wrappers.CorDebug;
namespace Debugger
{
/// <summary>
/// Provides information about a member of a given object.
/// In particular, it allows to access the value.
/// </summary>
public class ObjectMember: Variable
{
[Flags]
public enum Flags { Default = Public, None = 0, Public = 1, Static = 2, PublicStatic = Public | Static};
Flags memberFlags;
public Flags MemberFlags {
get {
return memberFlags;
}
}
public bool IsStatic {
get {
return (memberFlags & Flags.Static) != 0;
}
}
public bool IsPublic {
get {
return (memberFlags & Flags.Public) != 0;
}
}
public ObjectMember(string name, Flags flags, Value @value)
:base (name, @value)
{
this.memberFlags = flags;
}
}
}

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

@ -14,7 +14,7 @@ namespace Debugger @@ -14,7 +14,7 @@ namespace Debugger
public class ObjectValue: ValueProxy
{
ObjectValueClass topClass;
Variable toStringText;
Value toStringText;
public override string AsString {
get {
@ -22,7 +22,7 @@ namespace Debugger @@ -22,7 +22,7 @@ namespace Debugger
}
}
public Variable ToStringText {
public Value ToStringText {
get {
return toStringText;
}
@ -66,19 +66,17 @@ namespace Debugger @@ -66,19 +66,17 @@ namespace Debugger
return false;
}
internal ObjectValue(Variable variable):base(variable)
internal ObjectValue(Value @value):base(@value)
{
topClass = new ObjectValueClass(this, this.CorValue.As<ICorDebugObjectValue>().Class);
Module module = GetClass("System.Object").Module;
ICorDebugFunction corFunction = module.GetMethod("System.Object", "ToString", 0);
toStringText = new CallFunctionEval(this.Process,
"ToString()",
Variable.Flags.Default,
new IExpirable[] {this.Variable},
new IMutable[] {this.Variable},
new IExpirable[] {this.Value},
new IMutable[] {this.Value},
corFunction,
this.Variable,
new Variable[] {});
this.Value,
new Value[] {});
}
internal bool IsCorValueCompatible {

54
src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Variables/ObjectValueClass.cs

@ -72,7 +72,7 @@ namespace Debugger @@ -72,7 +72,7 @@ namespace Debugger
return new VariableCollection("Base class",
"{" + Type + "}",
SubCollections,
GetSubVariables(Variable.Flags.Public, Variable.Flags.PublicStatic));
GetSubVariables(ObjectMember.Flags.Public, ObjectMember.Flags.PublicStatic));
}
}
@ -82,15 +82,15 @@ namespace Debugger @@ -82,15 +82,15 @@ namespace Debugger
VariableCollection privateStatic = new VariableCollection("Private static members",
String.Empty,
new VariableCollection[0],
GetSubVariables(Variable.Flags.Static, Variable.Flags.PublicStatic));
GetSubVariables(ObjectMember.Flags.Static, ObjectMember.Flags.PublicStatic));
VariableCollection privateInstance = new VariableCollection("Private members",
String.Empty,
privateStatic.IsEmpty? new VariableCollection[0] : new VariableCollection[] {privateStatic},
GetSubVariables(Variable.Flags.None, Variable.Flags.PublicStatic));
GetSubVariables(ObjectMember.Flags.None, ObjectMember.Flags.PublicStatic));
VariableCollection publicStatic = new VariableCollection("Static members",
String.Empty,
new VariableCollection[0],
GetSubVariables(Variable.Flags.PublicStatic, Variable.Flags.PublicStatic));
GetSubVariables(ObjectMember.Flags.PublicStatic, ObjectMember.Flags.PublicStatic));
if (baseClass != null) {
yield return baseClass.SubVariables;
}
@ -103,15 +103,15 @@ namespace Debugger @@ -103,15 +103,15 @@ namespace Debugger
}
}
IEnumerable<Variable> GetSubVariables(Variable.Flags requiredFlags, Variable.Flags mask) {
foreach(Variable var in GetFieldVariables()) {
if ((var.VariableFlags & mask) == requiredFlags) {
IEnumerable<Variable> GetSubVariables(ObjectMember.Flags requiredFlags, ObjectMember.Flags mask) {
foreach(ObjectMember var in GetFieldVariables()) {
if ((var.MemberFlags & mask) == requiredFlags) {
yield return var;
}
}
foreach(Variable var in GetPropertyVariables()) {
if ((var.VariableFlags & mask) == requiredFlags) {
foreach(ObjectMember var in GetPropertyVariables()) {
if ((var.MemberFlags & mask) == requiredFlags) {
yield return var;
}
}
@ -128,18 +128,22 @@ namespace Debugger @@ -128,18 +128,22 @@ namespace Debugger
}
}
public IEnumerable<Variable> GetFieldVariables()
public IEnumerable<ObjectMember> GetFieldVariables()
{
foreach(FieldProps f in Module.MetaData.EnumFields(ClassToken)) {
FieldProps field = f; // One per scope/delegate
if (field.IsStatic && field.IsLiteral) continue; // Skip field
yield return new Variable(process,
yield return new ObjectMember(
field.Name,
(field.IsStatic ? Variable.Flags.Static : Variable.Flags.None) |
(field.IsPublic ? Variable.Flags.Public : Variable.Flags.None),
new IExpirable[] {this.objectValue.Variable},
new IMutable[] {this.objectValue.Variable},
delegate { return GetCorValueOfField(field); });
(field.IsStatic ? ObjectMember.Flags.Static : ObjectMember.Flags.None) |
(field.IsPublic ? ObjectMember.Flags.Public : ObjectMember.Flags.None),
new Value(
process,
new IExpirable[] {this.objectValue.Value},
new IMutable[] {this.objectValue.Value},
delegate { return GetCorValueOfField(field); }
)
);
}
}
@ -170,21 +174,25 @@ namespace Debugger @@ -170,21 +174,25 @@ namespace Debugger
}
}
public IEnumerable<Variable> GetPropertyVariables()
public IEnumerable<ObjectMember> GetPropertyVariables()
{
foreach(MethodProps m in Methods) {
MethodProps method = m; // One per scope/delegate
if (method.HasSpecialName && method.Name.StartsWith("get_") && method.Name != "get_Item") {
Variable.Flags flags = (method.IsStatic ? Variable.Flags.Static : Variable.Flags.None) |
(method.IsPublic ? Variable.Flags.Public : Variable.Flags.None);
yield return new CallFunctionEval(process,
ObjectMember.Flags flags = (method.IsStatic ? ObjectMember.Flags.Static : ObjectMember.Flags.None) |
(method.IsPublic ? ObjectMember.Flags.Public : ObjectMember.Flags.None);
yield return new ObjectMember(
method.Name.Remove(0, 4),
flags,
new IExpirable[] {this.objectValue.Variable},
new CallFunctionEval(
process,
new IExpirable[] {this.objectValue.Value},
new IMutable[] {process.DebugeeState},
Module.CorModule.GetFunctionFromToken(method.Token),
method.IsStatic ? null : this.objectValue.Variable, // this
new Variable[] {}); // args
method.IsStatic ? null : this.objectValue.Value, // this
new Value[] {}
)
); // args
}
}
}

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

@ -45,11 +45,11 @@ namespace Debugger @@ -45,11 +45,11 @@ namespace Debugger
} else {
(CorValue.CastTo<ICorDebugGenericValue>()).Value = newValue;
}
this.Variable.NotifyChange();
this.Value.NotifyChange();
}
}
internal PrimitiveValue(Variable variable):base(variable)
internal PrimitiveValue(Value @value):base(@value)
{
}

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

@ -25,7 +25,7 @@ namespace Debugger @@ -25,7 +25,7 @@ namespace Debugger
}
}
internal UnavailableValue(Variable variable, string message):base(variable)
internal UnavailableValue(Value @value, string message):base(@value)
{
this.message = message;
}

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

@ -12,29 +12,29 @@ namespace Debugger @@ -12,29 +12,29 @@ namespace Debugger
{
public abstract class ValueProxy: RemotingObjectBase
{
Variable variable;
Value val;
public Process Process {
get {
return variable.Process;
return val.Process;
}
}
public Variable Variable {
public Value Value {
get {
return variable;
return val;
}
}
internal ICorDebugValue CorValue {
get {
return variable.CorValue;
return val.CorValue;
}
}
protected ValueProxy FreshValue {
get {
return variable.ValueProxy;
return val.ValueProxy;
}
}
@ -78,7 +78,7 @@ namespace Debugger @@ -78,7 +78,7 @@ namespace Debugger
#if DEBUG
return new VariableCollection(subVars.Name,
subVars.Value,
Util.MergeLists(variable.GetDebugInfo(), subVars.SubCollections).ToArray(),
Util.MergeLists(val.GetDebugInfo(), subVars.SubCollections).ToArray(),
subVars.Items);
#else
return subVars;
@ -100,10 +100,10 @@ namespace Debugger @@ -100,10 +100,10 @@ namespace Debugger
}
}
protected ValueProxy(Variable variable)
protected ValueProxy(Value @value)
{
if (variable == null) throw new ArgumentNullException("variable");
this.variable = variable;
if (@value == null) throw new ArgumentNullException("value");
this.val = @value;
}
public override string ToString()

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

@ -12,15 +12,15 @@ namespace Debugger @@ -12,15 +12,15 @@ namespace Debugger
[Serializable]
public class ValueEventArgs : ProcessEventArgs
{
ValueProxy val;
Value val;
public ValueProxy ValueProxy {
public Value Value {
get {
return val;
}
}
public ValueEventArgs(ValueProxy val): base(val.Process)
public ValueEventArgs(Value val): base(val.Process)
{
this.val = val;
}

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

@ -13,7 +13,12 @@ using Debugger.Wrappers.CorDebug; @@ -13,7 +13,12 @@ using Debugger.Wrappers.CorDebug;
namespace Debugger
{
/// <summary>
/// Variable is a container which holds data necessaty to obtain
/// Delegate that is used to get value. This delegate may be called at any time and should never return null.
/// </summary>
delegate ICorDebugValue CorValueGetter();
/// <summary>
/// Value is a container which holds data necessaty to obtain
/// the value of a given object even after continue. This level of
/// abstraction is necessary because the type of a value can change
/// (eg for local variable of type object)
@ -30,21 +35,10 @@ namespace Debugger @@ -30,21 +35,10 @@ namespace Debugger
/// obteined value is still considered up to date. (If continue is
/// called and internal value is neutred new copy will be obatined)
/// </summary>
public class Variable: IExpirable, IMutable
public class Value: IExpirable, IMutable
{
/// <summary>
/// Delegate that is used to get value. This delegate may be called at any time and should never return null.
/// </summary>
public delegate ICorDebugValue CorValueGetter();
[Flags]
public enum Flags { Default = Public, None = 0, Public = 1, Static = 2, PublicStatic = Public | Static};
protected Process process;
string name;
Flags flags;
CorValueGetter corValueGetter;
IMutable[] mutateDependencies;
@ -63,15 +57,6 @@ namespace Debugger @@ -63,15 +57,6 @@ namespace Debugger
}
}
public string Name {
get {
return name;
}
set {
name = value;
}
}
public ICorDebugValue CorValue {
get {
return DereferenceUnbox(RawCorValue);
@ -108,27 +93,6 @@ namespace Debugger @@ -108,27 +93,6 @@ namespace Debugger
}
}
public Flags VariableFlags {
get {
return flags;
}
set {
flags = value;
}
}
public bool IsStatic {
get {
return (flags & Flags.Static) != 0;
}
}
public bool IsPublic {
get {
return (flags & Flags.Public) != 0;
}
}
public ICorDebugValue SoftReference {
get {
if (this.HasExpired) throw new DebuggerException("CorValue has expired");
@ -146,17 +110,12 @@ namespace Debugger @@ -146,17 +110,12 @@ namespace Debugger
}
}
public Variable(Process process, string name, Flags flags, IExpirable[] expireDependencies, IMutable[] mutateDependencies, CorValueGetter corValueGetter)
internal Value(Process process,
IExpirable[] expireDependencies,
IMutable[] mutateDependencies,
CorValueGetter corValueGetter)
{
this.process = process;
this.name = name;
if (name.StartsWith("<") && name.Contains(">") && name != "<Base class>") {
string middle = name.TrimStart('<').Split('>')[0]; // Get text between '<' and '>'
if (middle != "") {
this.name = middle;
}
}
this.flags = flags;
foreach(IExpirable exp in expireDependencies) {
AddExpireDependency(exp);
@ -191,7 +150,7 @@ namespace Debugger @@ -191,7 +150,7 @@ namespace Debugger
{
if (!isExpired) {
isExpired = true;
OnExpired(new VariableEventArgs(this));
OnExpired(new ValueEventArgs(this));
foreach(IMutable mut in mutateDependencies) {
mut.Changed -= DependencyChanged;
}
@ -214,7 +173,7 @@ namespace Debugger @@ -214,7 +173,7 @@ namespace Debugger
{
ClearCurrentValue();
if (!isExpired) {
OnChanged(new VariableEventArgs(this));
OnChanged(new ValueEventArgs(this));
}
}
@ -307,10 +266,10 @@ namespace Debugger @@ -307,10 +266,10 @@ namespace Debugger
}
}
public bool SetValue(Variable newVariable)
public bool SetValue(Value newValue)
{
ICorDebugValue corValue = this.RawCorValue;
ICorDebugValue newCorValue = newVariable.RawCorValue;
ICorDebugValue newCorValue = newValue.RawCorValue;
if (newCorValue.Type == (uint)CorElementType.BYREF) {
newCorValue = newCorValue.As<ICorDebugReferenceValue>().Dereference();
}

91
src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Variables/Variable2.cs

@ -0,0 +1,91 @@ @@ -0,0 +1,91 @@
// <file>
// <copyright see="prj:///doc/copyright.txt"/>
// <license see="prj:///doc/license.txt"/>
// <owner name="David Srbecký" email="dsrbecky@gmail.com"/>
// <version>$Revision$</version>
// </file>
using System;
using System.Collections.Generic;
using Debugger.Wrappers.CorDebug;
namespace Debugger
{
/// <summary>
///
/// </summary>
public class Variable: IExpirable, IMutable
{
string name;
Value val;
bool hasExpired;
public event EventHandler Expired;
public event EventHandler<ProcessEventArgs> Changed;
public Process Process {
get {
return val.Process;
}
}
public string Name {
get {
return name;
}
}
public Value Value {
get {
return val;
}
}
public ValueProxy ValueProxy {
get {
return val.ValueProxy;
}
}
public bool HasExpired {
get {
return hasExpired;
}
}
internal Variable(string name, Value @value)
{
if (@value == null) throw new ArgumentNullException("value");
this.name = name;
this.val = @value;
this.val.Expired += delegate(object sender, EventArgs e) { OnExpired(e); };
this.val.Changed += delegate(object sender, ProcessEventArgs e) { OnChanged(e); };
if (name.StartsWith("<") && name.Contains(">") && name != "<Base class>") {
string middle = name.TrimStart('<').Split('>')[0]; // Get text between '<' and '>'
if (middle != "") {
this.name = middle;
}
}
}
protected virtual void OnExpired(EventArgs e)
{
if (!hasExpired) {
hasExpired = true;
if (Expired != null) {
Expired(this, e);
}
}
}
protected virtual void OnChanged(ProcessEventArgs e)
{
if (Changed != null) {
Changed(this, e);
}
}
}
}

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

@ -19,7 +19,7 @@ namespace Debugger @@ -19,7 +19,7 @@ namespace Debugger
}
}
public VariableEventArgs(Variable variable): base(variable.Process)
public VariableEventArgs(Variable variable): base(variable.Value.Process)
{
this.variable = variable;
}

Loading…
Cancel
Save