diff --git a/src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Variables/Expressions/Expression.Create.cs b/src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Variables/Expressions/Expression.Create.cs index 68699fa838..f0f4fb4c97 100644 --- a/src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Variables/Expressions/Expression.Create.cs +++ b/src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Variables/Expressions/Expression.Create.cs @@ -45,44 +45,92 @@ namespace Debugger ); } - public static ExpressionCollection StackFrameVariables(StackFrame stackFrame) + /// Get all variables for a method - this; parameters; local variables + public static ExpressionCollection MethodVariables(MethodInfo methodInfo) { - throw new NotImplementedException(); + ExpressionCollection vars = new ExpressionCollection(); + + vars.Add(MethodThis(methodInfo)); + vars.AddRange(MethodParameters(methodInfo)); + vars.AddRange(MethodLocalVariables(methodInfo)); + + return vars; } - public static Expression StackFrameThis(StackFrame stackFrame) + /// Get 'this' variable for a method + public static Expression MethodThis(MethodInfo methodInfo) { - throw new NotImplementedException(); + if (methodInfo.IsStatic) throw new DebuggerException(methodInfo.FullName + " is static method"); + + return new Ast.ThisReferenceExpression(); } - public static ExpressionCollection StackFrameParameters(StackFrame stackFrame) + /// Get parameters of a method + public static ExpressionCollection MethodParameters(MethodInfo methodInfo) { - throw new NotImplementedException(); - } - - public static ExpressionCollection StackFrameLocalVariables(StackFrame stackFrame) - { - throw new NotImplementedException(); + ExpressionCollection pars = new ExpressionCollection(); + + for(int i = 0; i < methodInfo.ParameterCount; i++) { + pars.Add(new Ast.ParameterIdentifierExpression(i, methodInfo.GetParameterName(i))); + } + + return pars; } - public ValueCollection GetArrayElements() + /// Get local variables of a method + public static ExpressionCollection MethodLocalVariables(MethodInfo methodInfo) { - throw new NotImplementedException(); + ExpressionCollection vars = new ExpressionCollection(); + + foreach(ISymUnmanagedVariable var in methodInfo.LocalVariables) { + vars.Add(new Ast.LocalVariableIdentifierExpression(var)); + } + + return vars; } - public ExpressionCollection GetObjectMembers() + /// + /// Evaluate the expression and return expressions for all array elements. + /// The expression must evaluate to array. + /// + public ExpressionCollection EvaluateAndGetArrayElements() { - throw new NotImplementedException(); + ExpressionCollection elements = new ExpressionCollection(); + foreach(uint[] indices in this.Evaluate().ArrayIndices) { + elements.Add(this.AppendIndexer(indices)); + } + return elements; } - public ExpressionCollection GetObjectMembers(BindingFlags bindingFlags) + /// + /// Evaluate the expression and return object members. + /// The expression must evaluate to object. + /// + public ExpressionCollection EvaluateAndGetObjectMembers(BindingFlags bindingFlags) { - throw new NotImplementedException(); + ExpressionCollection members = new ExpressionCollection(); + + DebugType currentType = this.Evaluate().Type; + while (currentType != null) { + members.AddRange(GetObjectMembers(currentType, bindingFlags)); + currentType = currentType.BaseType; + } + + return members; } public ExpressionCollection GetObjectMembers(DebugType type, BindingFlags bindingFlags) { - throw new NotImplementedException(); + ExpressionCollection members = new ExpressionCollection(); + + foreach(FieldInfo field in type.GetFields(bindingFlags)) { + members.Add(this.AppendFieldReference(field)); + } + foreach(PropertyInfo property in type.GetProperties(bindingFlags)) { + members.Add(this.AppendPropertyReference(property)); + } + + return members; } } } diff --git a/src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Variables/Expressions/Expression.Evaluate.cs b/src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Variables/Expressions/Expression.Evaluate.cs index c9bc01ed7c..09df721a19 100644 --- a/src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Variables/Expressions/Expression.Evaluate.cs +++ b/src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Variables/Expressions/Expression.Evaluate.cs @@ -17,12 +17,12 @@ namespace Debugger { public partial class Expression: DebuggerObject { - public Value GetValue() + public Value Evaluate() { return Evaluate(null); } - Value Evaluate(StackFrame stackFrame) + public Value Evaluate(StackFrame stackFrame) { EvaluateAstVisitor astVisitor = new EvaluateAstVisitor(stackFrame); return (Value)this.AbstractSynatxTree.AcceptVisitor(astVisitor, null); diff --git a/src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Variables/Types/MethodInfo.cs b/src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Variables/Types/MethodInfo.cs index 4988c07e77..dea991983b 100644 --- a/src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Variables/Types/MethodInfo.cs +++ b/src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Variables/Types/MethodInfo.cs @@ -21,6 +21,20 @@ namespace Debugger { MethodProps methodProps; + /// Gets the name of this method + public override string Name { + get { + return methodProps.Name; + } + } + + /// Gets name of the method including the full name of the declaring type + public string FullName { + get { + return this.DeclaringType.FullName + "." + methodProps.Name; + } + } + /// Gets a value indicating whether this method is private public override bool IsPrivate { get { @@ -59,13 +73,6 @@ namespace Debugger } } - /// Gets the name of this method - public override string Name { - get { - return methodProps.Name; - } - } - internal ICorDebugFunction CorFunction { get { return this.Module.CorModule.GetFunctionFromToken(this.MetadataToken); @@ -113,6 +120,13 @@ namespace Debugger } } + [Debugger.Tests.Ignore] + public int ParameterCount { + get { + return this.Module.MetaData.GetParamCount(this.MetadataToken); + } + } + /// Gets the name of given parameter /// Zero-based index public string GetParameterName(int index) diff --git a/src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Variables/Values/Value.Array.cs b/src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Variables/Values/Value.Array.cs index d24a6dfe6a..32a5f4783e 100644 --- a/src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Variables/Values/Value.Array.cs +++ b/src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Variables/Values/Value.Array.cs @@ -34,7 +34,7 @@ namespace Debugger } /// - /// Gets the number of elements the array can store. + /// Gets the number of elements in the array. /// eg new object[4,5] returns 20 /// public uint ArrayLenght { @@ -108,27 +108,40 @@ namespace Debugger /// Returns all elements in the array public ValueCollection GetArrayElements() { - return new ValueCollection(GetArrayElementsEnum()); + return new ValueCollection(this.ArrayElements); } - IEnumerable GetArrayElementsEnum() - { - uint[] indices = new uint[ArrayRank]; - uint rank = ArrayRank; - uint[] dimensions = ArrayDimensions; - - while(true) { // Go thought all combinations - for (uint i = rank - 1; i >= 1; i--) { - if (indices[i] >= dimensions[i]) { - indices[i] = 0; - indices[i-1]++; - } + /// Enumerate over all array elements + [Debugger.Tests.Ignore] + public IEnumerable ArrayElements { + get { + foreach(uint[] indices in ArrayIndices) { + yield return GetArrayElement(indices); } - if (indices[0] >= dimensions[0]) break; // We are done - - yield return GetArrayElement(indices); + } + } + + /// Enumerate over all array indices + [Debugger.Tests.Ignore] + public IEnumerable ArrayIndices { + get { + uint[] indices = new uint[ArrayRank]; + uint rank = ArrayRank; + uint[] dimensions = ArrayDimensions; - indices[rank - 1]++; + while(true) { // Go thought all combinations + for (uint i = rank - 1; i >= 1; i--) { + if (indices[i] >= dimensions[i]) { + indices[i] = 0; + indices[i-1]++; + } + } + if (indices[0] >= dimensions[0]) break; // We are done + + yield return (uint[])indices.Clone(); + + indices[rank - 1]++; + } } } } diff --git a/src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Variables/Values/Value.Object.cs b/src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Variables/Values/Value.Object.cs index f25949fade..bf4900e9b4 100644 --- a/src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Variables/Values/Value.Object.cs +++ b/src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Variables/Values/Value.Object.cs @@ -223,18 +223,23 @@ namespace Debugger IEnumerable GetObjectMembersEnum(DebugType type, BindingFlags bindingFlags) { - DebugType currentType = type ?? this.Type; - while (currentType != null) { - foreach(FieldInfo field in currentType.GetFields(bindingFlags)) { + if (type != null) { + foreach(FieldInfo field in type.GetFields(bindingFlags)) { yield return this.GetFieldValue(field); } - foreach(PropertyInfo property in currentType.GetProperties(bindingFlags)) { + foreach(PropertyInfo property in type.GetProperties(bindingFlags)) { yield return this.GetPropertyValue(property); } - if (type == null) { + } else { + DebugType currentType = this.Type; + while (currentType != null) { + foreach(FieldInfo field in currentType.GetFields(bindingFlags)) { + yield return this.GetFieldValue(field); + } + foreach(PropertyInfo property in currentType.GetProperties(bindingFlags)) { + yield return this.GetPropertyValue(property); + } currentType = currentType.BaseType; - } else { - yield break; } } } diff --git a/src/AddIns/Misc/Debugger/Debugger.Tests/Project/Src/TestPrograms/Callstack.xml b/src/AddIns/Misc/Debugger/Debugger.Tests/Project/Src/TestPrograms/Callstack.xml index 7ad3f432b7..c29b807f7d 100644 --- a/src/AddIns/Misc/Debugger/Debugger.Tests/Project/Src/TestPrograms/Callstack.xml +++ b/src/AddIns/Misc/Debugger/Debugger.Tests/Project/Src/TestPrograms/Callstack.xml @@ -12,11 +12,12 @@ + Sub2 + Debugger.Tests.TestPrograms.Callstack.Sub2 True False False True - Sub2 Callstack.exe Debugger.Tests.TestPrograms.Callstack @@ -48,11 +49,12 @@ + Sub1 + Debugger.Tests.TestPrograms.Callstack.Sub1 True False False True - Sub1 Callstack.exe Debugger.Tests.TestPrograms.Callstack @@ -84,11 +86,12 @@ + Main + Debugger.Tests.TestPrograms.Callstack.Main False True False True - Main Callstack.exe Debugger.Tests.TestPrograms.Callstack @@ -128,11 +131,12 @@ + Sub1 + Debugger.Tests.TestPrograms.Callstack.Sub1 True False False True - Sub1 Callstack.exe Debugger.Tests.TestPrograms.Callstack @@ -164,11 +168,12 @@ + Main + Debugger.Tests.TestPrograms.Callstack.Main False True False True - Main Callstack.exe Debugger.Tests.TestPrograms.Callstack @@ -208,11 +213,12 @@ + Main + Debugger.Tests.TestPrograms.Callstack.Main False True False True - Main Callstack.exe Debugger.Tests.TestPrograms.Callstack diff --git a/src/AddIns/Misc/Debugger/Debugger.Tests/Project/Src/TestPrograms/FunctionArgumentVariables.xml b/src/AddIns/Misc/Debugger/Debugger.Tests/Project/Src/TestPrograms/FunctionArgumentVariables.xml index 7776f8586b..9efc661797 100644 --- a/src/AddIns/Misc/Debugger/Debugger.Tests/Project/Src/TestPrograms/FunctionArgumentVariables.xml +++ b/src/AddIns/Misc/Debugger/Debugger.Tests/Project/Src/TestPrograms/FunctionArgumentVariables.xml @@ -10,11 +10,12 @@ + StaticFunction + Debugger.Tests.TestPrograms.FunctionArgumentVariables.StaticFunction True False False True - StaticFunction FunctionArgumentVariables.exe Debugger.Tests.TestPrograms.FunctionArgumentVariables @@ -95,11 +96,12 @@ + StaticFunction + Debugger.Tests.TestPrograms.FunctionArgumentVariables.StaticFunction True False False True - StaticFunction FunctionArgumentVariables.exe Debugger.Tests.TestPrograms.FunctionArgumentVariables @@ -180,11 +182,12 @@ + StaticFunction + Debugger.Tests.TestPrograms.FunctionArgumentVariables.StaticFunction True False False True - StaticFunction FunctionArgumentVariables.exe Debugger.Tests.TestPrograms.FunctionArgumentVariables @@ -265,11 +268,12 @@ + Function + Debugger.Tests.TestPrograms.FunctionArgumentVariables.Function True False False False - Function FunctionArgumentVariables.exe Debugger.Tests.TestPrograms.FunctionArgumentVariables @@ -366,11 +370,12 @@ + Function + Debugger.Tests.TestPrograms.FunctionArgumentVariables.Function True False False False - Function FunctionArgumentVariables.exe Debugger.Tests.TestPrograms.FunctionArgumentVariables @@ -467,11 +472,12 @@ + Function + Debugger.Tests.TestPrograms.FunctionArgumentVariables.Function True False False False - Function FunctionArgumentVariables.exe Debugger.Tests.TestPrograms.FunctionArgumentVariables diff --git a/src/AddIns/Misc/Debugger/Debugger.Tests/Project/Src/TestPrograms/FunctionLifetime.xml b/src/AddIns/Misc/Debugger/Debugger.Tests/Project/Src/TestPrograms/FunctionLifetime.xml index 24df51a97f..4c7b8be0e0 100644 --- a/src/AddIns/Misc/Debugger/Debugger.Tests/Project/Src/TestPrograms/FunctionLifetime.xml +++ b/src/AddIns/Misc/Debugger/Debugger.Tests/Project/Src/TestPrograms/FunctionLifetime.xml @@ -9,11 +9,12 @@ + Function + Debugger.Tests.TestPrograms.FunctionLifetime.Function True False False True - Function FunctionLifetime.exe Debugger.Tests.TestPrograms.FunctionLifetime @@ -64,11 +65,12 @@ + Function + Debugger.Tests.TestPrograms.FunctionLifetime.Function True False False True - Function FunctionLifetime.exe Debugger.Tests.TestPrograms.FunctionLifetime @@ -118,11 +120,12 @@ + SubFunction + Debugger.Tests.TestPrograms.FunctionLifetime.SubFunction True False False True - SubFunction FunctionLifetime.exe Debugger.Tests.TestPrograms.FunctionLifetime @@ -157,11 +160,12 @@ + Function + Debugger.Tests.TestPrograms.FunctionLifetime.Function True False False True - Function FunctionLifetime.exe Debugger.Tests.TestPrograms.FunctionLifetime @@ -212,11 +216,12 @@ + Main + Debugger.Tests.TestPrograms.FunctionLifetime.Main False True False True - Main FunctionLifetime.exe Debugger.Tests.TestPrograms.FunctionLifetime @@ -250,11 +255,12 @@ + Function + Debugger.Tests.TestPrograms.FunctionLifetime.Function True False False True - Function FunctionLifetime.exe Debugger.Tests.TestPrograms.FunctionLifetime diff --git a/src/AddIns/Misc/Debugger/Debugger.Tests/Project/Src/TestPrograms/FunctionLocalVariables.xml b/src/AddIns/Misc/Debugger/Debugger.Tests/Project/Src/TestPrograms/FunctionLocalVariables.xml index 9e865f5b2b..db45c162ce 100644 --- a/src/AddIns/Misc/Debugger/Debugger.Tests/Project/Src/TestPrograms/FunctionLocalVariables.xml +++ b/src/AddIns/Misc/Debugger/Debugger.Tests/Project/Src/TestPrograms/FunctionLocalVariables.xml @@ -9,11 +9,12 @@ + Main + Debugger.Tests.TestPrograms.FunctionLocalVariables.Main False True False True - Main FunctionLocalVariables.exe Debugger.Tests.TestPrograms.FunctionLocalVariables diff --git a/src/AddIns/Misc/Debugger/Debugger.Tests/Project/Src/TestPrograms/Generics.xml b/src/AddIns/Misc/Debugger/Debugger.Tests/Project/Src/TestPrograms/Generics.xml index f504b9c258..4df096a5de 100644 --- a/src/AddIns/Misc/Debugger/Debugger.Tests/Project/Src/TestPrograms/Generics.xml +++ b/src/AddIns/Misc/Debugger/Debugger.Tests/Project/Src/TestPrograms/Generics.xml @@ -9,11 +9,12 @@ + Metod + Debugger.Tests.TestPrograms.GenericClass<System.Int32,System.String>.Metod False True False False - Metod Generics.exe Debugger.Tests.TestPrograms.GenericClass<System.Int32,System.String> @@ -95,11 +96,12 @@ + GenericMethod + Debugger.Tests.TestPrograms.GenericClass<System.Int32,System.String>.GenericMethod False True False False - GenericMethod Generics.exe Debugger.Tests.TestPrograms.GenericClass<System.Int32,System.String> @@ -181,11 +183,12 @@ + StaticMetod + Debugger.Tests.TestPrograms.GenericClass<System.Int32,System.String>.StaticMetod False True False True - StaticMetod Generics.exe Debugger.Tests.TestPrograms.GenericClass<System.Int32,System.String> @@ -251,11 +254,12 @@ + StaticGenericMethod + Debugger.Tests.TestPrograms.GenericClass<System.Int32,System.String>.StaticGenericMethod False True False True - StaticGenericMethod Generics.exe Debugger.Tests.TestPrograms.GenericClass<System.Int32,System.String> @@ -321,11 +325,12 @@ + Metod + Debugger.Tests.TestPrograms.GenericStruct<System.Int32,System.String>.Metod False True False False - Metod Generics.exe Debugger.Tests.TestPrograms.GenericStruct<System.Int32,System.String> @@ -386,11 +391,12 @@ + GenericMethod + Debugger.Tests.TestPrograms.GenericStruct<System.Int32,System.String>.GenericMethod False True False False - GenericMethod Generics.exe Debugger.Tests.TestPrograms.GenericStruct<System.Int32,System.String> @@ -451,11 +457,12 @@ + StaticMetod + Debugger.Tests.TestPrograms.GenericStruct<System.Int32,System.String>.StaticMetod False True False True - StaticMetod Generics.exe Debugger.Tests.TestPrograms.GenericStruct<System.Int32,System.String> @@ -521,11 +528,12 @@ + StaticGenericMethod + Debugger.Tests.TestPrograms.GenericStruct<System.Int32,System.String>.StaticGenericMethod False True False True - StaticGenericMethod Generics.exe Debugger.Tests.TestPrograms.GenericStruct<System.Int32,System.String> diff --git a/src/AddIns/Misc/Debugger/Debugger.Tests/Project/Src/TestPrograms/Stepping.xml b/src/AddIns/Misc/Debugger/Debugger.Tests/Project/Src/TestPrograms/Stepping.xml index 55eb4c4023..fe2e514f68 100644 --- a/src/AddIns/Misc/Debugger/Debugger.Tests/Project/Src/TestPrograms/Stepping.xml +++ b/src/AddIns/Misc/Debugger/Debugger.Tests/Project/Src/TestPrograms/Stepping.xml @@ -10,11 +10,12 @@ + Main + Debugger.Tests.TestPrograms.Stepping.Main False True False True - Main Stepping.exe Debugger.Tests.TestPrograms.Stepping @@ -49,11 +50,12 @@ + Main + Debugger.Tests.TestPrograms.Stepping.Main False True False True - Main Stepping.exe Debugger.Tests.TestPrograms.Stepping @@ -91,11 +93,12 @@ + Main + Debugger.Tests.TestPrograms.Stepping.Main False True False True - Main Stepping.exe Debugger.Tests.TestPrograms.Stepping @@ -130,11 +133,12 @@ + Sub + Debugger.Tests.TestPrograms.Stepping.Sub False True False True - Sub Stepping.exe Debugger.Tests.TestPrograms.Stepping @@ -169,11 +173,12 @@ + Sub + Debugger.Tests.TestPrograms.Stepping.Sub False True False True - Sub Stepping.exe Debugger.Tests.TestPrograms.Stepping @@ -209,11 +214,12 @@ + Sub + Debugger.Tests.TestPrograms.Stepping.Sub False True False True - Sub Stepping.exe Debugger.Tests.TestPrograms.Stepping @@ -250,11 +256,12 @@ + Main + Debugger.Tests.TestPrograms.Stepping.Main False True False True - Main Stepping.exe Debugger.Tests.TestPrograms.Stepping @@ -289,11 +296,12 @@ + Main + Debugger.Tests.TestPrograms.Stepping.Main False True False True - Main Stepping.exe Debugger.Tests.TestPrograms.Stepping @@ -329,11 +337,12 @@ + Main + Debugger.Tests.TestPrograms.Stepping.Main False True False True - Main Stepping.exe Debugger.Tests.TestPrograms.Stepping