Browse Source

Getting of function variable made lazy

git-svn-id: svn://svn.sharpdevelop.net/sharpdevelop/trunk@827 1ccf3a8d-04fe-1044-b7c0-cef0b8235c61
shortcuts
David Srbecký 20 years ago
parent
commit
4b3226aa07
  1. 4
      src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Debugger/NDebugger.cs
  2. 139
      src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Threads/Function.cs

4
src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Debugger/NDebugger.cs

@ -190,7 +190,7 @@ namespace Debugger @@ -190,7 +190,7 @@ namespace Debugger
}
}
}
public VariableCollection LocalVariables {
get {
return localVariables;
@ -202,7 +202,7 @@ namespace Debugger @@ -202,7 +202,7 @@ namespace Debugger
if (CurrentFunction == null) {
e.VariableCollection.UpdateTo(VariableCollection.Empty);
} else {
e.VariableCollection.UpdateTo(CurrentFunction.GetVariables());
e.VariableCollection.UpdateTo(CurrentFunction.Variables);
}
}
}

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

@ -395,28 +395,34 @@ namespace Debugger @@ -395,28 +395,34 @@ namespace Debugger
}
}
}
public VariableCollection GetVariables()
{
return VariableCollection.Merge(
GetContaingClassVariables(),
GetArgumentVariables(),
GetLocalVariables(),
GetPropertyVariables()
);
public IEnumerable<Variable> Variables {
get {
foreach(Variable var in ContaingClassVariables) {
yield return var;
}
foreach(Variable var in ArgumentVariables) {
yield return var;
}
foreach(Variable var in LocalVariables) {
yield return var;
}
foreach(Variable var in PropertyVariables) {
yield return var;
}
}
}
public VariableCollection GetContaingClassVariables()
{
if (IsStatic) {
return VariableCollection.Empty;
} else {
VariableCollection collection = new VariableCollection(debugger);
collection.UpdateTo(ThisValue.SubVariables);
return collection;
public IEnumerable<Variable> ContaingClassVariables {
get {
if (!IsStatic) {
foreach(Variable var in ThisValue.SubVariables) {
yield return var;
}
}
}
}
public string GetParameterName(int index)
{
// index = 0 is return parameter
@ -426,7 +432,7 @@ namespace Debugger @@ -426,7 +432,7 @@ namespace Debugger
return String.Empty;
}
}
public int ArgumentCount {
get {
ICorDebugValueEnum argumentEnum;
@ -453,70 +459,65 @@ namespace Debugger @@ -453,70 +459,65 @@ namespace Debugger
return Variable.CreateVariable(debugger, GetArgumentValue(index), GetParameterName(index));
}
public VariableCollection GetArgumentVariables()
{
VariableCollection arguments = new VariableCollection(debugger);
int argCount = ArgumentCount;
for (int i = 0; i < argCount; i++) {
arguments.Add(GetArgumentVariable(i));
public IEnumerable<Variable> ArgumentVariables {
get {
for (int i = 0; i < ArgumentCount; i++) {
yield return GetArgumentVariable(i);
}
}
return arguments;
}
public VariableCollection GetLocalVariables()
{
VariableCollection localVariables = new VariableCollection(debugger);
if (symMethod != null) {
ISymbolScope symRootScope = symMethod.RootScope;
AddScopeToVariableCollection(symRootScope, ref localVariables);
public IEnumerable<Variable> LocalVariables {
get {
if (symMethod != null) { // TODO: Is this needed?
ISymbolScope symRootScope = symMethod.RootScope;
foreach(Variable var in GetLocalVariablesInScope(symRootScope)) {
yield return var;
}
}
}
return localVariables;
}
VariableCollection GetPropertyVariables()
{
VariableCollection properties = new VariableCollection(debugger);
foreach(MethodProps method in module.MetaData.EnumMethods(methodProps.ClassToken)) {
if (method.Name.StartsWith("get_") && method.HasSpecialName) {
ICorDebugValue[] evalArgs;
ICorDebugFunction evalCorFunction;
Module.CorModule.GetFunctionFromToken(method.Token, out evalCorFunction);
if (IsStatic) {
evalArgs = new ICorDebugValue[0];
} else {
evalArgs = new ICorDebugValue[] {ThisValue.CorValue};
}
Eval eval = new Eval(debugger, evalCorFunction, evalArgs);
// Do not add evals if we just evaluated them, otherwise we get infinite loop
if (debugger.PausedReason != PausedReason.AllEvalsComplete) {
debugger.AddEval(eval);
public IEnumerable<Variable> PropertyVariables {
get {
foreach(MethodProps method in module.MetaData.EnumMethods(methodProps.ClassToken)) {
if (method.Name.StartsWith("get_") && method.HasSpecialName) {
ICorDebugValue[] evalArgs;
ICorDebugFunction evalCorFunction;
Module.CorModule.GetFunctionFromToken(method.Token, out evalCorFunction);
if (IsStatic) {
evalArgs = new ICorDebugValue[0];
} else {
evalArgs = new ICorDebugValue[] {ThisValue.CorValue};
}
Eval eval = new Eval(debugger, evalCorFunction, evalArgs);
// Do not add evals if we just evaluated them, otherwise we get infinite loop
if (debugger.PausedReason != PausedReason.AllEvalsComplete) {
debugger.AddEval(eval);
}
yield return new PropertyVariable(eval, method.Name.Remove(0, 4));
}
properties.Add(new PropertyVariable(eval, method.Name.Remove(0, 4)));
}
}
return properties;
}
void AddScopeToVariableCollection(ISymbolScope symScope, ref VariableCollection collection)
IEnumerable<Variable> GetLocalVariablesInScope(ISymbolScope symScope)
{
foreach(ISymbolScope childScope in symScope.GetChildren()) {
AddScopeToVariableCollection(childScope, ref collection);
}
foreach (ISymbolVariable symVar in symScope.GetLocals()) {
AddVariableToVariableCollection(symVar , ref collection);
yield return GetLocalVariable(symVar);
}
foreach(ISymbolScope childScope in symScope.GetChildren()) {
foreach(Variable var in GetLocalVariablesInScope(childScope)) {
yield return var;
}
}
}
void AddVariableToVariableCollection(ISymbolVariable symVar, ref VariableCollection collection)
Variable GetLocalVariable(ISymbolVariable symVar)
{
ICorDebugValue runtimeVar;
CorILFrame.GetLocalVariable((uint)symVar.AddressField1, out runtimeVar);
collection.Add(Variable.CreateVariable(debugger, runtimeVar, symVar.Name));
return Variable.CreateVariable(debugger, runtimeVar, symVar.Name);
}
}
}

Loading…
Cancel
Save