/// <summary> /// Gets an array of MDbgValues that are the Arguments to the Function in the given Frame. /// </summary> /// <param name="managedFrame">The Frame to use.</param> /// <returns>The MDbgValue[] Arguments.</returns> public MDbgValue[] GetArguments(MDbgFrame managedFrame) { Debug.Assert(managedFrame != null); if (managedFrame == null) { throw new ArgumentException(); } CorFrame f = managedFrame.CorFrame; // we only support this, when the frame is our function Debug.Assert(f.FunctionToken == m_function.Token); if (!(f.FunctionToken == m_function.Token)) { throw new ArgumentException(); } EnsureIsUpToDate(); ArrayList al = new ArrayList(); int c = f.GetArgumentCount(); if (c == -1) { throw new MDbgException("Could not get metainformation. (Jit tracking information not turned on)"); } int i; for (i = 0; i < c; i++) { CorValue arg = null; try { arg = f.GetArgument(i); } catch (System.Runtime.InteropServices.COMException e) { if (e.ErrorCode != (int)Microsoft.Samples.Debugging.CorDebug.HResult.CORDBG_E_IL_VAR_NOT_AVAILABLE) { throw; } } al.Add(new MDbgValue(m_module.Process, arg)); } MDbgValue[] argArray = (MDbgValue[])al.ToArray(typeof(MDbgValue)); MethodInfo mi = managedFrame.Function.MethodInfo; foreach (ParameterInfo pi in mi.GetParameters()) { int pos = pi.Position; // ParameterInfo at Position 0 refers to the return type (eg. when it has an attribute applied) if (pos == 0) { continue; } if (mi.IsStatic) { pos--; } Debug.Assert(pos < c); argArray[pos].InternalSetName(pi.Name); } i = 0; foreach (MDbgValue v in argArray) { if (v.Name == null) { if (i == 0 && !mi.IsStatic) { v.InternalSetName("this"); } else { v.InternalSetName("unnamed_param_" + i); } i++; } } return(argArray); }