diff --git a/src/AddIns/Misc/Debugger/Debugger.AddIn/Project/Src/TreeModel/StackFrameNode.cs b/src/AddIns/Misc/Debugger/Debugger.AddIn/Project/Src/TreeModel/StackFrameNode.cs index a9f1a0c780..af5ca5fcf8 100644 --- a/src/AddIns/Misc/Debugger/Debugger.AddIn/Project/Src/TreeModel/StackFrameNode.cs +++ b/src/AddIns/Misc/Debugger/Debugger.AddIn/Project/Src/TreeModel/StackFrameNode.cs @@ -31,7 +31,7 @@ namespace Debugger.AddIn.TreeModel IEnumerable GetChildNodes() { - foreach(Expression expr in Expression.MethodVariables(stackFrame.MethodInfo)) { + foreach(Expression expr in stackFrame.MethodInfo.GetExpressionsForAllVariables()) { yield return ValueNode.Create(expr); } if (stackFrame.Thread.CurrentException != null) { diff --git a/src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Control/StackFrame.cs b/src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Control/StackFrame.cs index aee357adb1..1367c9afa1 100644 --- a/src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Control/StackFrame.cs +++ b/src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Control/StackFrame.cs @@ -306,17 +306,18 @@ namespace Debugger } /// Gets all arguments of the stack frame. - public Value[] GetArgumentValues() + public List GetArgumentValues() { List values = new List(); for (int i = 0; i < ArgumentCount; i++) { values.Add(GetArgumentValue(i)); } - return values.ToArray(); + return values; } #endregion + /// Returns value of give local variable public Value GetLocalVariableValue(ISymUnmanagedVariable symVar) { return new Value(this.Process, new LocalVariableIdentifierExpression(MethodInfo, symVar), GetLocalVariableCorValue(symVar)); @@ -346,14 +347,14 @@ namespace Debugger return null; } - /// Gets all local variables of the stack frame. - public Value[] GetLocalVariableValues() + /// Returns all local variables of the stack frame. + public List GetLocalVariableValues() { List values = new List(); foreach(ISymUnmanagedVariable symVar in this.MethodInfo.LocalVariables) { values.Add(GetLocalVariableValue(symVar)); } - return values.ToArray(); + return values; } #endregion diff --git a/src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Expressions/Expression.Create.cs b/src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Expressions/Expression.Create.cs index c9179075dd..ca79132ac3 100644 --- a/src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Expressions/Expression.Create.cs +++ b/src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Expressions/Expression.Create.cs @@ -58,51 +58,5 @@ namespace Debugger.Expressions members.Sort(); return members.ToArray(); } - - /// Get all variables for a method - this; parameters; local variables - public static Expression[] MethodVariables(MethodInfo methodInfo) - { - List vars = new List(); - - if (!methodInfo.IsStatic) { - vars.Add(MethodThis()); - } - vars.AddRange(MethodParameters(methodInfo)); - vars.AddRange(MethodLocalVariables(methodInfo)); - - return vars.ToArray(); - } - - /// Get 'this' variable for a method - public static Expression MethodThis() - { - return new ThisReferenceExpression(); - } - - /// Get parameters of a method - public static Expression[] MethodParameters(MethodInfo methodInfo) - { - List pars = new List(); - - for(int i = 0; i < methodInfo.ParameterCount; i++) { - pars.Add(new ParameterIdentifierExpression(methodInfo, i)); - } - - pars.Sort(); - return pars.ToArray(); - } - - /// Get local variables of a method - public static Expression[] MethodLocalVariables(MethodInfo methodInfo) - { - List vars = new List(); - - foreach(ISymUnmanagedVariable var in methodInfo.LocalVariables) { - vars.Add(new LocalVariableIdentifierExpression(methodInfo, var)); - } - - vars.Sort(); - return vars.ToArray(); - } } } diff --git a/src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Metadata/MethodInfo.cs b/src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Metadata/MethodInfo.cs index 080486c507..977e894935 100644 --- a/src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Metadata/MethodInfo.cs +++ b/src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Metadata/MethodInfo.cs @@ -5,9 +5,9 @@ // $Revision$ // +using Debugger.Expressions; using System; using System.Collections.Generic; - using Debugger.Wrappers.CorDebug; using Debugger.Wrappers.CorSym; using Debugger.Wrappers.MetaData; @@ -253,5 +253,86 @@ namespace Debugger.MetaData } return vars; } + + #region Convenience methods + + /// Returns expression for 'this' value of the stack frame + public Expression GetExpressionForThis() + { + return new ThisReferenceExpression(); + } + + /// Returns expression for argument with the given index + public Expression GetExpressionForParameter(int index) + { + return new ParameterIdentifierExpression(this, index); + } + + /// Returns expression for argument with the given name + public Expression GetExpressionForParameter(string name) + { + for(int i = 0; i < this.ParameterCount; i++) { + if (this.GetParameterName(i) == name) { + return GetExpressionForParameter(i); + } + } + return null; + } + + /// Returns expressions for all arguments of this stack frame + public List GetExpressionsForParameters() + { + List ret = new List(); + for (int i = 0; i < this.ParameterCount; i++) { + ret.Add(GetExpressionForParameter(i)); + } + ret.Sort(); + return ret; + } + + /// Returns expression for the given local variable + public Expression GetExpressionForLocalVariable(ISymUnmanagedVariable symVar) + { + return new LocalVariableIdentifierExpression(this, symVar); + } + + /// Returns expression for local variable with the given name + /// Null if not found + public Expression GetExpressionForLocalVariable(string name) + { + foreach(ISymUnmanagedVariable symVar in this.LocalVariables) { + if (symVar.Name == name) { + return GetExpressionForLocalVariable(symVar); + } + } + return null; + } + + /// Returns expressions for all local variables + public List GetExpressionsForLocalVariables() + { + List ret = new List(); + foreach(ISymUnmanagedVariable symVar in this.LocalVariables) { + ret.Add(GetExpressionForLocalVariable(symVar)); + } + ret.Sort(); + return ret; + } + + /// Returns a combined collection of all variables in this stack frame + public List GetExpressionsForAllVariables() + { + List vars = new List(); + + if (!this.IsStatic) { + vars.Add(GetExpressionForThis()); + } + vars.AddRange(GetExpressionsForParameters()); + vars.AddRange(GetExpressionsForLocalVariables()); + + return vars; + } + + #endregion } } diff --git a/src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Wrappers/MetaData/MetaDataImport.cs b/src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Wrappers/MetaData/MetaDataImport.cs index ad1e4a67ae..8d39b766af 100644 --- a/src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Wrappers/MetaData/MetaDataImport.cs +++ b/src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Wrappers/MetaData/MetaDataImport.cs @@ -19,7 +19,7 @@ using Debugger.Wrappers.CorSym; namespace Debugger.Wrappers.MetaData { /// Wrapper for the unmanaged metadata API. - /// http://msdn.microsoft.com/en-us/library/ms233124.aspx + /// http://msdn.microsoft.com/en-us/library/ms230172.aspx public class MetaDataImport: IDisposable { IMetaDataImport metaData;