public void CallParameterizedFunction(CorFunction managedFunction, CorType[] argumentTypes, CorValue[] arguments) { ICorDebugType[] types = null; int typesLength = 0; ICorDebugValue[] values = null; int valuesLength = 0; var eval2 = (ICorDebugEval2) m_eval; if (argumentTypes != null) { types = new ICorDebugType[argumentTypes.Length]; for (int i = 0; i < argumentTypes.Length; i++) types[i] = argumentTypes[i].m_type; typesLength = types.Length; } if (arguments != null) { values = new ICorDebugValue[arguments.Length]; for (int i = 0; i < arguments.Length; i++) values[i] = arguments[i].m_val; valuesLength = values.Length; } eval2.CallParameterizedFunction(managedFunction.m_function, (uint) typesLength, types, (uint) valuesLength, values); }
// // IEnumerator interface // #region IEnumerator Members public bool MoveNext() { if (m_enum == null) return false; var a = new ICorDebugType[1]; uint c = 0; int r = m_enum.Next((uint) a.Length, a, out c); if (r == 0 && c == 1) // S_OK && we got 1 new element m_ty = new CorType(a[0]); else m_ty = null; return m_ty != null; }
public CorType GetParameterizedType(CorElementType elementType, CorType[] typeArguments) { ICorDebugType[] types = null; uint length = 0; if (typeArguments != null) { types = new ICorDebugType[typeArguments.Length]; for (int i = 0; i < typeArguments.Length; i++) types[i] = typeArguments[i].m_type; length = (uint) typeArguments.Length; } ICorDebugType pType; (m_class as ICorDebugClass2).GetParameterizedType(elementType, length, types, out pType); return pType == null ? null : new CorType(pType); }
public void Reset() { if (m_enum != null) m_enum.Reset(); m_ty = null; }
public void Skip(int celt) { m_enum.Skip((uint) celt); m_ty = null; }
// Print CorType to the given string builder. // Will print generic info. internal static void PrintCorType(StringBuilder sb, MDbgProcess proc, CorType ct) { switch (ct.Type) { case CorElementType.ELEMENT_TYPE_CLASS: case CorElementType.ELEMENT_TYPE_VALUETYPE: // We need to get the name from the metadata. We can get a cached metadata importer // from a MDbgModule, or we could get a new one from the CorModule directly. // Is this hash lookup to get a MDbgModule cheaper than just re-querying for the importer? CorClass cc = ct.Class; MDbgModule m = proc.Modules.Lookup(cc.Module); Type tn = m.Importer.GetType(cc.Token); sb.Append(tn.FullName); AddGenericArgs(sb, proc, ct.TypeParameters); return; // Primitives case CorElementType.ELEMENT_TYPE_BOOLEAN: sb.Append("System.Boolean"); return; case CorElementType.ELEMENT_TYPE_CHAR: sb.Append("System.Char"); return; case CorElementType.ELEMENT_TYPE_I1: sb.Append("System.SByte"); return; case CorElementType.ELEMENT_TYPE_U1: sb.Append("System.Byte"); return; case CorElementType.ELEMENT_TYPE_I2: sb.Append("System.Int16"); return; case CorElementType.ELEMENT_TYPE_U2: sb.Append("System.UInt16"); return; case CorElementType.ELEMENT_TYPE_I4: sb.Append("System.Int32"); return; case CorElementType.ELEMENT_TYPE_U4: sb.Append("System.Uint32"); return; case CorElementType.ELEMENT_TYPE_I8: sb.Append("System.Int64"); return; case CorElementType.ELEMENT_TYPE_U8: sb.Append("System.UInt64"); return; case CorElementType.ELEMENT_TYPE_I: sb.Append("System.IntPtr"); return; case CorElementType.ELEMENT_TYPE_U: sb.Append("System.UIntPtr"); return; case CorElementType.ELEMENT_TYPE_R4: sb.Append("System.Single"); return; case CorElementType.ELEMENT_TYPE_R8: sb.Append("System.Double"); return; // Well known class-types. case CorElementType.ELEMENT_TYPE_OBJECT: sb.Append("System.Object"); return; case CorElementType.ELEMENT_TYPE_STRING: sb.Append("System.String"); return; // Special compound types. Based off first type-param case CorElementType.ELEMENT_TYPE_SZARRAY: case CorElementType.ELEMENT_TYPE_ARRAY: case CorElementType.ELEMENT_TYPE_BYREF: case CorElementType.ELEMENT_TYPE_PTR: CorType t = ct.FirstTypeParameter; PrintCorType(sb, proc, t); switch (ct.Type) { case CorElementType.ELEMENT_TYPE_SZARRAY: sb.Append("[]"); return; case CorElementType.ELEMENT_TYPE_ARRAY: int rank = ct.Rank; sb.Append('['); for (int i = 0; i < rank - 1; i++) { sb.Append(','); } sb.Append(']'); return; case CorElementType.ELEMENT_TYPE_BYREF: sb.Append("&"); return; case CorElementType.ELEMENT_TYPE_PTR: sb.Append("*"); return; } Debug.Assert(false); // shouldn't have gotten here. return; case CorElementType.ELEMENT_TYPE_FNPTR: sb.Append("*(...)"); return; case CorElementType.ELEMENT_TYPE_TYPEDBYREF: sb.Append("typedbyref"); return; default: sb.Append("<unknown>"); return; } } // end PrintClass
// Return class as a string. /// <summary> /// Creates a string representation of CorType. /// </summary> /// <param name="proc">A debugged process.</param> /// <param name="ct">A CorType object representing a type in the debugged process.</param> /// <returns>String representaion of the passed in type.</returns> public static string PrintCorType(MDbgProcess proc, CorType ct) { var sb = new StringBuilder(); PrintCorType(sb, proc, ct); return sb.ToString(); }
/** Returns CorType object for a pointer to a function */ public CorType GetFunctionPointerType(CorType[] parameterTypes) { ICorDebugType[] types = null; if (parameterTypes != null) { types = new ICorDebugType[parameterTypes.Length]; for (int i = 0; i < parameterTypes.Length; i++) types[i] = parameterTypes[i].m_type; } ICorDebugType ct = null; (_ad() as ICorDebugAppDomain2).GetFunctionPointerType((uint) types.Length, types, out ct); return ct == null ? null : new CorType(ct); }
/** Returns CorType object for an array of or pointer to the given type */ public CorType GetArrayOrPointerType(CorElementType elementType, int rank, CorType parameterTypes) { ICorDebugType ct = null; var urank = (uint) rank; (_ad() as ICorDebugAppDomain2).GetArrayOrPointerType(elementType, urank, parameterTypes.m_type, out ct); return ct == null ? null : new CorType(ct); }
public void Skip(int celt) { m_enum.Skip((uint)celt); m_ty = null; }
////////////////////////////////////////////////////////////////////////////////// // // Helper functions // ////////////////////////////////////////////////////////////////////////////////// /// <summary> /// Resolves a type from a Variable Name. /// </summary> /// <param name="typeName">The name of the type to resolve.</param> /// <returns>The CorType of that Variable.</returns> public CorType ResolveType(string typeName) { CorClass cc = ResolveClass(typeName); if (cc == null) { return null; } var cta = new CorType[0]; return cc.GetParameterizedType(CorElementType.ELEMENT_TYPE_CLASS, cta); }
public CorValue CreateValueForType(CorType type) { ICorDebugValue val = null; var eval2 = (ICorDebugEval2) m_eval; eval2.CreateValueForType(type.m_type, out val); return val == null ? null : new CorValue(val); }
public void NewParameterizedArray(CorType type, int rank, int dims, int lowBounds) { var eval2 = (ICorDebugEval2) m_eval; var udims = (uint) dims; var ulowBounds = (uint) lowBounds; eval2.NewParameterizedArray(type.m_type, (uint) rank, ref udims, ref ulowBounds); }
public void NewParameterizedObjectNoConstructor(CorClass managedClass, CorType[] argumentTypes) { ICorDebugType[] types = null; int typesLength = 0; var eval2 = (ICorDebugEval2) m_eval; if (argumentTypes != null) { types = new ICorDebugType[argumentTypes.Length]; for (int i = 0; i < argumentTypes.Length; i++) types[i] = argumentTypes[i].m_type; typesLength = types.Length; } eval2.NewParameterizedObjectNoConstructor(managedClass.m_class, (uint) typesLength, types); }