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

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

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

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

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

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

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

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

@ -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
} }
internal unsafe ArrayValue(Variable variable):base(variable) internal unsafe ArrayValue(Value @value):base(@value)
{ {
corElementType = (CorElementType)CorArrayValue.ElementType; corElementType = (CorElementType)CorArrayValue.ElementType;
@ -115,12 +115,16 @@ namespace Debugger
elementName += indices[i].ToString() + ","; elementName += indices[i].ToString() + ",";
elementName = elementName.TrimEnd(new char[] {','}) + "]"; elementName = elementName.TrimEnd(new char[] {','}) + "]";
return new Variable(Process, return new ArrayElement(
elementName, elementName,
Variable.Flags.Default, indices,
new IExpirable[] {this.Variable}, new Value(
new IMutable[] {this.Variable}, Process,
delegate { return GetCorValueOfItem(indices); }); new IExpirable[] {this.Value},
new IMutable[] {this.Value},
delegate { return GetCorValueOfItem(indices); }
)
);
} }
unsafe ICorDebugValue GetCorValueOfItem(uint[] 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
class CallFunctionEval: Eval class CallFunctionEval: Eval
{ {
ICorDebugFunction corFunction; ICorDebugFunction corFunction;
Variable thisValue; Value thisValue;
Variable[] args; Value[] args;
public CallFunctionEval(Process process, string name, Flags flags, IExpirable[] expireDependencies, IMutable[] mutateDependencies, ICorDebugFunction corFunction, Variable thisValue, Variable[] args) public CallFunctionEval(Process process,
:base(process, name, flags, expireDependencies, mutateDependencies) IExpirable[] expireDependencies,
IMutable[] mutateDependencies,
ICorDebugFunction corFunction,
Value thisValue,
Value[] args)
:base(process, expireDependencies, mutateDependencies)
{ {
this.corFunction = corFunction; this.corFunction = corFunction;
this.thisValue = thisValue; this.thisValue = thisValue;
@ -39,7 +44,7 @@ namespace Debugger
} }
corArgs.Add(thisValue.SoftReference); corArgs.Add(thisValue.SoftReference);
} }
foreach(Variable arg in args) { foreach(Value arg in args) {
corArgs.Add(arg.SoftReference); corArgs.Add(arg.SoftReference);
} }
} catch (CannotGetValueException e) { } catch (CannotGetValueException e) {

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

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

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

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

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

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

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

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

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

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

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

@ -45,11 +45,11 @@ namespace Debugger
} else { } else {
(CorValue.CastTo<ICorDebugGenericValue>()).Value = newValue; (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
} }
} }
internal UnavailableValue(Variable variable, string message):base(variable) internal UnavailableValue(Value @value, string message):base(@value)
{ {
this.message = message; this.message = message;
} }

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

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

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

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

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

@ -13,7 +13,12 @@ using Debugger.Wrappers.CorDebug;
namespace Debugger namespace Debugger
{ {
/// <summary> /// <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 /// the value of a given object even after continue. This level of
/// abstraction is necessary because the type of a value can change /// abstraction is necessary because the type of a value can change
/// (eg for local variable of type object) /// (eg for local variable of type object)
@ -30,21 +35,10 @@ namespace Debugger
/// obteined value is still considered up to date. (If continue is /// obteined value is still considered up to date. (If continue is
/// called and internal value is neutred new copy will be obatined) /// called and internal value is neutred new copy will be obatined)
/// </summary> /// </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; protected Process process;
string name;
Flags flags;
CorValueGetter corValueGetter; CorValueGetter corValueGetter;
IMutable[] mutateDependencies; IMutable[] mutateDependencies;
@ -63,15 +57,6 @@ namespace Debugger
} }
} }
public string Name {
get {
return name;
}
set {
name = value;
}
}
public ICorDebugValue CorValue { public ICorDebugValue CorValue {
get { get {
return DereferenceUnbox(RawCorValue); return DereferenceUnbox(RawCorValue);
@ -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 { public ICorDebugValue SoftReference {
get { get {
if (this.HasExpired) throw new DebuggerException("CorValue has expired"); if (this.HasExpired) throw new DebuggerException("CorValue has expired");
@ -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.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) { foreach(IExpirable exp in expireDependencies) {
AddExpireDependency(exp); AddExpireDependency(exp);
@ -191,7 +150,7 @@ namespace Debugger
{ {
if (!isExpired) { if (!isExpired) {
isExpired = true; isExpired = true;
OnExpired(new VariableEventArgs(this)); OnExpired(new ValueEventArgs(this));
foreach(IMutable mut in mutateDependencies) { foreach(IMutable mut in mutateDependencies) {
mut.Changed -= DependencyChanged; mut.Changed -= DependencyChanged;
} }
@ -214,7 +173,7 @@ namespace Debugger
{ {
ClearCurrentValue(); ClearCurrentValue();
if (!isExpired) { if (!isExpired) {
OnChanged(new VariableEventArgs(this)); OnChanged(new ValueEventArgs(this));
} }
} }
@ -307,10 +266,10 @@ namespace Debugger
} }
} }
public bool SetValue(Variable newVariable) public bool SetValue(Value newValue)
{ {
ICorDebugValue corValue = this.RawCorValue; ICorDebugValue corValue = this.RawCorValue;
ICorDebugValue newCorValue = newVariable.RawCorValue; ICorDebugValue newCorValue = newValue.RawCorValue;
if (newCorValue.Type == (uint)CorElementType.BYREF) { if (newCorValue.Type == (uint)CorElementType.BYREF) {
newCorValue = newCorValue.As<ICorDebugReferenceValue>().Dereference(); newCorValue = newCorValue.As<ICorDebugReferenceValue>().Dereference();
} }

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

@ -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
} }
} }
public VariableEventArgs(Variable variable): base(variable.Process) public VariableEventArgs(Variable variable): base(variable.Value.Process)
{ {
this.variable = variable; this.variable = variable;
} }

Loading…
Cancel
Save