Пример #1
0
        public void NewParameterizedObject(CorFunction managedFunction, CorType[] argumentTypes, CorValue[] arguments)
        {
            ICorDebugType[] types       = null;
            int             typesLength = 0;

            ICorDebugValue[] values     = null;
            int            valuesLength = 0;
            ICorDebugEval2 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.NewParameterizedObject(managedFunction.m_function, (uint)typesLength, types, (uint)valuesLength, values);
        }
Пример #2
0
        internal Value(AppDomain appDomain, ICorDebugValue corValue)
        {
            if (corValue == null)
            {
                throw new ArgumentNullException("corValue");
            }
            this.appDomain             = appDomain;
            this.corValue              = corValue;
            this.corValue_pauseSession = this.Process.PauseSession;

            this.isNull = corValue is ICorDebugReferenceValue && ((ICorDebugReferenceValue)corValue).IsNull() != 0;

            if (corValue is ICorDebugReferenceValue &&
                ((ICorDebugReferenceValue)corValue).GetValue() == 0 &&
                ((ICorDebugValue2)corValue).GetExactType() == null)
            {
                // We were passed null reference and no metadata description
                // (happens during CreateThread callback for the thread object)
                this.type = appDomain.ObjectType;
            }
            else
            {
                ICorDebugType exactType = ((ICorDebugValue2)this.CorValue).GetExactType();
                this.type = appDomain.Compilation.Import(exactType);
            }
        }
Пример #3
0
        internal Value(Process process, Expression expression, ICorDebugValue corValue)
        {
            if (corValue == null)
            {
                throw new ArgumentNullException("corValue");
            }
            this.process               = process;
            this.expression            = expression;
            this.corValue              = corValue;
            this.corValue_pauseSession = process.PauseSession;

            if (corValue.Is <ICorDebugReferenceValue>() &&
                corValue.CastTo <ICorDebugReferenceValue>().Value == 0 &&
                corValue.CastTo <ICorDebugValue2>().ExactType == null)
            {
                // We were passed null reference and no metadata description
                // (happens during CreateThread callback for the thread object)
                this.type = DebugType.Create(this.Process, null, "System.Object");
            }
            else
            {
                ICorDebugType exactType = this.CorValue.CastTo <ICorDebugValue2>().ExactType;
                this.type = DebugType.Create(this.Process, exactType);
            }
        }
Пример #4
0
        public void CallParameterizedFunction (CorFunction managedFunction, CorType[] argumentTypes, CorValue[] arguments)
        {
            ICorDebugType[] types = null;
            int typesLength = 0;
            ICorDebugValue[] values = null;
            int valuesLength = 0;
            
            ICorDebugEval2 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);
        }
Пример #5
0
        DebugType(Process process, ICorDebugType corType)
        {
            if (corType == null)
            {
                throw new ArgumentNullException("corType");
            }

            this.process        = process;
            this.corType        = corType;
            this.corElementType = (CorElementType)corType.Type;

            if (this.IsClass || this.IsValueType)
            {
                this.corClass   = corType.Class;
                this.module     = process.GetModule(corClass.Module);
                this.classProps = module.MetaData.GetTypeDefProps(corClass.Token);
            }

            if (this.IsClass || this.IsValueType || this.IsArray || this.IsPointer)
            {
                foreach (ICorDebugType t in corType.EnumerateTypeParameters().Enumerator)
                {
                    typeArguments.Add(DebugType.Create(process, t));
                }
            }

            this.fullName = GetFullName();
        }
Пример #6
0
        static public DebugType Create(Process process, ICorDebugClass corClass, params ICorDebugType[] typeArguments)
        {
            MetaData metaData = process.GetModule(corClass.Module).MetaData;

            bool isValueType     = false;
            uint superClassToken = metaData.GetTypeDefProps(corClass.Token).SuperClassToken;

            if ((superClassToken & 0xFF000000) == 0x02000000)               // TypeDef
            {
                if (metaData.GetTypeDefProps(superClassToken).Name == "System.ValueType")
                {
                    isValueType = true;
                }
            }
            if ((superClassToken & 0xFF000000) == 0x01000000)               // TypeRef
            {
                if (metaData.GetTypeRefProps(superClassToken).Name == "System.ValueType")
                {
                    isValueType = true;
                }
            }

            int getArgsCount = metaData.GetGenericParamCount(corClass.Token);

            Array.Resize(ref typeArguments, getArgsCount);
            ICorDebugType corType = corClass.CastTo <ICorDebugClass2>().GetParameterizedType(
                isValueType ? (uint)CorElementType.VALUETYPE : (uint)CorElementType.CLASS,
                typeArguments
                );

            return(Create(process, corType));
        }
Пример #7
0
 internal ICorDebugType GetDebugType()
 {
     var class2 = (ICorDebugClass2)_debugClass;
     ICorDebugType ppType;
     ICorDebugType[] typeArgs = new ICorDebugType[0];
     class2.GetParameterizedType(CorElementType.ELEMENT_TYPE_CLASS, 0, typeArgs, out ppType);
     return ppType;
 }
Пример #8
0
        /** 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;
            uint          urank = (uint)rank;

            (_ad() as ICorDebugAppDomain2).GetArrayOrPointerType(elementType, urank, parameterTypes.m_type, out ct);
            return(ct == null?null:new CorType(ct));
        }
Пример #9
0
        int ICorDebugEval2.CreateValueForType(ICorDebugType pType, out ICorDebugValue ppValue)
        {
            CorElementType type;
            ICorDebugClass cls;

            pType.GetType(out type);
            pType.GetClass(out cls);

            return(((ICorDebugEval)this).CreateValue(type, cls, out ppValue));
        }
Пример #10
0
        int ICorDebugEval2.NewParameterizedArray(ICorDebugType pElementType, uint rank, ref uint dims, ref uint lowBounds)
        {
            CorElementType type;
            ICorDebugClass cls;

            pElementType.GetType(out type);
            pElementType.GetClass(out cls);

            return(((ICorDebugEval)this).NewArray(type, cls, rank, dims, lowBounds));
        }
		public ICorDebugType Next()
		{
			ICorDebugType[] corTypes = new ICorDebugType[1];
			uint typesFetched = this.Next(1, corTypes);
			if (typesFetched == 0) {
				return null;
			} else {
				return corTypes[0];
			}
		}
Пример #12
0
        /// <summary> Obtains instance of DebugType. Same types will return identical instance. </summary>
        static public DebugType Create(Process process, ICorDebugType corType)
        {
            DateTime startTime = Util.HighPrecisionTimer.Now;

            DebugType type = new DebugType(process, corType);

            // Get types with matching names from cache
            List <DebugType> typesWithMatchingName;

            if (!loadedTypes.TryGetValue(type.FullName, out typesWithMatchingName))
            {
                // No types with such name - create a new list
                typesWithMatchingName = new List <DebugType>(1);
                loadedTypes.Add(type.FullName, typesWithMatchingName);
            }

            // Try to find the type
            foreach (DebugType loadedType in typesWithMatchingName)
            {
                if (loadedType.Equals(type))
                {
                    TimeSpan totalTime = Util.HighPrecisionTimer.Now - startTime;
                    if (process.Options.Verbose)
                    {
                        process.TraceMessage("Type " + type.FullName + " was loaded already (" + totalTime.TotalMilliseconds + " ms)");
                    }
                    return(loadedType);                    // Type was loaded before
                }
            }

            // The type is not in the cache, finish loading it and add it to the cache
            if (type.IsClass || type.IsValueType)
            {
                type.LoadMemberInfo();
            }
            typesWithMatchingName.Add(type);
            type.Process.Exited += delegate { typesWithMatchingName.Remove(type); };

            TimeSpan totalTime2 = Util.HighPrecisionTimer.Now - startTime;
            string   prefix     = type.IsInterface ? "interface" : "type";

            if (process.Options.Verbose)
            {
                process.TraceMessage("Loaded {0} {1} ({2} ms)", prefix, type.FullName, totalTime2.TotalMilliseconds);
                foreach (DebugType inter in type.Interfaces)
                {
                    process.TraceMessage(" - Implements {0}", inter.FullName);
                }
            }

            return(type);
        }
Пример #13
0
        public static Value NewObject(Process process, DebugType debugType)
        {
            ICorDebugType  ppTypeArgs = null;
            ICorDebugValue ppArgs     = null;
            Eval           e          = new Eval(
                process,
                "New object: " + debugType.Token,
                delegate(ICorDebugEval corEval) { corEval.CastTo <ICorDebugEval2>().NewParameterizedObject
                                                      (debugType.GetDefaultConstructor(), (uint)debugType.GenericArguments.Count, ref ppTypeArgs, 0, ref ppArgs); }
                );

            return(e.EvaluateNow());
        }
        //
        // 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;
        }
Пример #15
0
 //
 // IEnumerator interface
 //
 public bool MoveNext ()
 {
     if( m_enum==null )
         return false;
     
     ICorDebugType[] 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;
 }
Пример #16
0
        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);
        }
Пример #17
0
        public CorType GetVirtualMethodAndType(int memberToken, out CorFunction managedFunction)
        {
            ICorDebugType     dt    = null;
            ICorDebugFunction pfunc = null;

            (m_objVal as ICorDebugObjectValue2).GetVirtualMethodAndType((uint)memberToken, out pfunc, out dt);
            if (pfunc == null)
            {
                managedFunction = null;
            }
            else
            {
                managedFunction = new CorFunction(pfunc);
            }
            return(dt == null ? null : new CorType(dt));
        }
Пример #18
0
        /** 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));
        }
Пример #19
0
        public void NewParameterizedObjectNoConstructor(CorClass managedClass, CorType[] argumentTypes)
        {
            ICorDebugType[] types       = null;
            int             typesLength = 0;
            ICorDebugEval2  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);
        }
Пример #20
0
        public static Eval AsyncNewObjectNoConstructor(Thread evalThread, IType type)
        {
            ICorDebugType[] typeArgs = new ICorDebugType[0];
            var             genType  = type as ParameterizedType;

            if (genType != null)
            {
                typeArgs = genType.TypeArguments.Select(t => t.ToCorDebug()).ToArray();
            }
            return(new Eval(
                       evalThread,
                       "New object: " + type.FullName,
                       delegate(Eval eval) {
                eval.CorEval2.NewParameterizedObjectNoConstructor(type.ToCorDebug().GetClass(), (uint)typeArgs.Length, typeArgs);
            }
                       ));
        }
Пример #21
0
        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));
        }
Пример #22
0
        /// <summary>
        /// Get a method from a managed type, method name and argument count
        /// </summary>
        public static MethodInfo GetFromName(Process process, System.Type type, string name, int paramCount)
        {
            if (type.IsNested)
            {
                throw new DebuggerException("Not implemented for nested types");
            }
            if (type.IsGenericType)
            {
                throw new DebuggerException("Not implemented for generic types");
            }
            if (type.IsGenericParameter)
            {
                throw new DebuggerException("Type can not be generic parameter");
            }

            foreach (Module module in process.Modules)
            {
                TypeDefProps typeDefProps;
                try
                {
                    typeDefProps = module.MetaData.FindTypeDefByName(type.FullName, 0 /* enclosing class for nested */);
                }
                catch
                {
                    continue;
                }
                foreach (MethodProps methodProps in module.MetaData.EnumMethodsWithName(typeDefProps.Token, name))
                {
                    if (module.MetaData.GetParamCount(methodProps.Token) == paramCount)
                    {
                        ICorDebugFunction corFunction = module.CorModule.GetFunctionFromToken(methodProps.Token);
                        ICorDebugClass2   corClass    = corFunction.Class.As <ICorDebugClass2>();
                        ICorDebugType     corType     = corClass.GetParameterizedType(type.IsValueType ? (uint)CorElementType.VALUETYPE : (uint)CorElementType.CLASS,
                                                                                      0,
                                                                                      new ICorDebugType[] {});
                        return(new MethodInfo(DebugType.Create(process, corType), methodProps));
                    }
                }
            }
            throw new DebuggerException("Not found");
        }
Пример #23
0
        /// <summary> Obtains instance of DebugType. Same types will return identical instance. </summary>
        static internal DebugType Create(Process process, ICorDebugType corType)
        {
            DateTime startTime = Util.HighPrecisionTimer.Now;

            DebugType type = new DebugType(process, corType);

            // Get types with matching names from cache
            List <DebugType> typesWithMatchingName;

            if (!loadedTypes.TryGetValue(type.FullName, out typesWithMatchingName))
            {
                // No types with such name - create a new list
                typesWithMatchingName = new List <DebugType>(1);
                loadedTypes.Add(type.FullName, typesWithMatchingName);
            }

            // Try to find the type
            foreach (DebugType loadedType in typesWithMatchingName)
            {
                if (loadedType.Equals(type))
                {
                    TimeSpan totalTime = Util.HighPrecisionTimer.Now - startTime;
                    //process.TraceMessage("Type " + type.FullName + " was loaded already (" + totalTime.TotalMilliseconds + " ms)");
                    return(loadedType);                    // Type was loaded before
                }
            }

            // The type is not in the cache, finish loading it and add it to the cache
            if (type.IsClass || type.IsValueType || type.ManagedType == typeof(string))
            {
                type.LoadMemberInfo();
            }
            typesWithMatchingName.Add(type);
            type.Process.Expired += delegate { typesWithMatchingName.Remove(type); };

            TimeSpan totalTime2 = Util.HighPrecisionTimer.Now - startTime;

            process.TraceMessage("Loaded type " + type.FullName + " (" + totalTime2.TotalMilliseconds + " ms)");

            return(type);
        }
Пример #24
0
        //
        // 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 static void GetVirtualMethodAndType(this ICorDebugObjectValue2 instance, uint memberRef, out ICorDebugFunction ppFunction, out ICorDebugType ppType)
 {
     instance.__GetVirtualMethodAndType(memberRef, out ppFunction, out ppType);
 }
Пример #26
0
 int ICorDebugType.GetBase (out ICorDebugType pBase)
 {
     pBase = null;
     return Utility.COM_HResults.E_NOTIMPL;
 }
 public static ICorDebugType GetParameterizedType(this ICorDebugClass2 instance, uint elementType, uint nTypeArgs, ICorDebugType[] ppTypeArgs)
 {
     ICorDebugType ppType;
     instance.__GetParameterizedType(elementType, nTypeArgs, ppTypeArgs, out ppType);
     return ppType;
 }
Пример #28
0
        int ICorDebugValue2.GetExactType(out ICorDebugType ppType)

        {
            ppType = new CorDebugTypeArray(this);
            return(COM_HResults.S_OK);
        }
 public static ICorDebugValue CreateValueForType(this ICorDebugEval2 instance, ICorDebugType pType)
 {
     ICorDebugValue ppValue;
     instance.__CreateValueForType(pType, out ppValue);
     return ppValue;
 }
Пример #30
0
 public void NewParameterizedObjectNoConstructor(CorClass managedClass, CorType[] argumentTypes)
 {
     ICorDebugType[] types = null;
     int typesLength=0;
     ICorDebugEval2 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);
 }
Пример #31
0
 int ICorDebugValue2.GetExactType(out ICorDebugType ppType)
 {
     ppType = new CorDebugGenericType(RuntimeValue.CorElementType, m_rtv, m_appDomain);
     return(COM_HResults.S_OK);
 }
Пример #32
0
		/// <summary> Obtains instance of DebugType. Same types will return identical instance. </summary>
		static internal DebugType Create(Process process, ICorDebugType corType)
		{
			DateTime startTime = Util.HighPrecisionTimer.Now;
			
			DebugType type = new DebugType(process, corType);
			
			// Get types with matching names from cache
			List<DebugType> typesWithMatchingName;
			if (!loadedTypes.TryGetValue(type.FullName, out typesWithMatchingName)) {
				// No types with such name - create a new list
				typesWithMatchingName = new List<DebugType>(1);
				loadedTypes.Add(type.FullName, typesWithMatchingName);
			}
			
			// Try to find the type
			foreach(DebugType loadedType in typesWithMatchingName) {
				if (loadedType.Equals(type)) {
					TimeSpan totalTime = Util.HighPrecisionTimer.Now - startTime;
					//process.TraceMessage("Type " + type.FullName + " was loaded already (" + totalTime.TotalMilliseconds + " ms)");
					return loadedType; // Type was loaded before
				}
			}
			
			// The type is not in the cache, finish loading it and add it to the cache
			if (type.IsClass || type.IsValueType || type.ManagedType == typeof(string)) {
				type.LoadMemberInfo();
			}
			typesWithMatchingName.Add(type);
			type.Process.Expired += delegate { typesWithMatchingName.Remove(type); };
			
			TimeSpan totalTime2 = Util.HighPrecisionTimer.Now - startTime;
			process.TraceMessage("Loaded type " + type.FullName + " (" + totalTime2.TotalMilliseconds + " ms)");
			
			return type;
		}
 int ICorDebugType.GetFirstTypeParameter(out ICorDebugType value)
 {
     // For non-arrays there is not first parameter.
     value = null;
     return(COM_HResults.E_NOTIMPL);
 }
 /*
  *  The function ICorDebugType.GetFirstTypeParameter returns the type
  *  of element in the array.
  *  It control viewing of arrays elements in the watch window of debugger.
  */
 int ICorDebugType.GetFirstTypeParameter(out ICorDebugType value)
 {
     value = new CorDebugGenericType(CorElementType.ELEMENT_TYPE_CLASS, m_ValueArray.RuntimeValue, m_ValueArray.AppDomain);
     return(COM_HResults.S_OK);
 }
 public static void NewParameterizedObjectNoConstructor(this ICorDebugEval2 instance, ICorDebugClass pClass, uint nTypeArgs, ICorDebugType[] ppTypeArgs)
 {
     instance.__NewParameterizedObjectNoConstructor(pClass, nTypeArgs, ppTypeArgs);
 }
 int ICorDebugType.GetBase(out ICorDebugType pBase)
 {
     pBase = null;
     return(COM_HResults.E_NOTIMPL);
 }
 public static ICorDebugType GetArrayOrPointerType(this ICorDebugAppDomain2 instance, uint elementType, uint nRank, ICorDebugType pTypeArg)
 {
     ICorDebugType ppType;
     instance.__GetArrayOrPointerType(elementType, nRank, pTypeArg, out ppType);
     return ppType;
 }
 public static void CallParameterizedFunction(this ICorDebugEval2 instance, ICorDebugFunction pFunction, uint nTypeArgs, ICorDebugType[] ppTypeArgs, uint nArgs, ICorDebugValue[] ppArgs)
 {
     instance.__CallParameterizedFunction(pFunction, nTypeArgs, ppTypeArgs, nArgs, ppArgs);
 }
Пример #39
0
        /** 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);
        }
Пример #40
0
 int ICorDebugValue2.GetExactType(out ICorDebugType ppType)
 {
     return ((ICorDebugValue2)m_value).GetExactType( out ppType);
 }
Пример #41
0
		public static Eval AsyncNewObjectNoConstructor(Thread evalThread, IType type)
		{
			ICorDebugType[] typeArgs = new ICorDebugType[0];
			var genType = type as ParameterizedType;
			if (genType != null) {
				typeArgs = genType.TypeArguments.Select(t => t.ToCorDebug()).ToArray();
			}
			return new Eval(
				evalThread,
				"New object: " + type.FullName,
				delegate(Eval eval) {
					eval.CorEval2.NewParameterizedObjectNoConstructor(type.ToCorDebug().GetClass(), (uint)typeArgs.Length, typeArgs);
				}
			);
		}
        public static ITypeReference ToTypeReference(this ICorDebugType corType, Process process)
        {
            switch ((CorElementType)corType.GetTheType())
            {
            case CorElementType.VOID:
                return(KnownTypeReference.Void);

            case CorElementType.BOOLEAN:
                return(KnownTypeReference.Boolean);

            case CorElementType.CHAR:
                return(KnownTypeReference.Char);

            case CorElementType.I1:
                return(KnownTypeReference.SByte);

            case CorElementType.U1:
                return(KnownTypeReference.Byte);

            case CorElementType.I2:
                return(KnownTypeReference.Int16);

            case CorElementType.U2:
                return(KnownTypeReference.UInt16);

            case CorElementType.I4:
                return(KnownTypeReference.Int32);

            case CorElementType.U4:
                return(KnownTypeReference.UInt32);

            case CorElementType.I8:
                return(KnownTypeReference.Int64);

            case CorElementType.U8:
                return(KnownTypeReference.UInt64);

            case CorElementType.R4:
                return(KnownTypeReference.Single);

            case CorElementType.R8:
                return(KnownTypeReference.Double);

            case CorElementType.STRING:
                return(KnownTypeReference.String);

            case CorElementType.PTR:
                return(new PointerTypeReference(corType.GetFirstTypeParameter().ToTypeReference(process)));

            case CorElementType.BYREF:
                return(new ByReferenceTypeReference(corType.GetFirstTypeParameter().ToTypeReference(process)));

            case CorElementType.VALUETYPE:
            case CorElementType.CLASS:
                // Get generic arguments
                List <ITypeReference> genericArguments = new List <ITypeReference>();
                foreach (ICorDebugType t in corType.EnumerateTypeParameters().GetEnumerator())
                {
                    genericArguments.Add(t.ToTypeReference(process));
                }
                var            module = process.GetModule(corType.GetClass().GetModule());
                ITypeReference typeDefinitionReference = ToTypeDefinitionReference(module, corType.GetClass().GetToken());
                if (genericArguments.Count > 0)
                {
                    return(new ParameterizedTypeReference(typeDefinitionReference, genericArguments));
                }
                else
                {
                    return(typeDefinitionReference);
                }

            case CorElementType.ARRAY:
                return(new ArrayTypeReference(corType.GetFirstTypeParameter().ToTypeReference(process),
                                              (int)corType.GetRank()));

            case CorElementType.GENERICINST:
                throw new NotSupportedException();

            case CorElementType.I:
                return(KnownTypeReference.IntPtr);

            case CorElementType.U:
                return(KnownTypeReference.UIntPtr);

            case CorElementType.OBJECT:
                return(KnownTypeReference.Object);

            case CorElementType.SZARRAY:
                return(new ArrayTypeReference(corType.GetFirstTypeParameter().ToTypeReference(process)));

            case CorElementType.CMOD_REQD:
            case CorElementType.CMOD_OPT:
                return(corType.GetFirstTypeParameter().ToTypeReference(process));

            default:
                throw new InvalidOperationException("Invalid value for CorElementType");
            }
        }
Пример #43
0
        int ICorDebugValue2.GetExactType(out ICorDebugType ppType)

        {
            ppType = new CorDebugTypeArray( this );
            return Utility.COM_HResults.S_OK;
        }
 public static void NewParameterizedObject(this ICorDebugEval2 instance, ICorDebugFunction pConstructor, uint nTypeArgs, ICorDebugType[] ppTypeArgs, uint nArgs, ICorDebugValue[] ppArgs)
 {
     instance.__NewParameterizedObject(pConstructor, nTypeArgs, ppTypeArgs, nArgs, ppArgs);
 }
Пример #45
0
 int ICorDebugValue2.GetExactType(out ICorDebugType ppType)
 {
     return(((ICorDebugValue2)m_value).GetExactType(out ppType));
 }
 public static void NewParameterizedArray(this ICorDebugEval2 instance, ICorDebugType pElementType, uint rank, uint[] dims, uint[] lowBounds)
 {
     instance.__NewParameterizedArray(pElementType, rank, dims, lowBounds);
 }
Пример #47
0
        int ICorDebugClass2.GetParameterizedType(CorElementType elementType, uint nTypeArgs, ICorDebugType [] ppTypeArgs, out ICorDebugType ppType)
        {
            // CorDebugClass.GetParameterizedType is not implemented
            ppType = null;

            return(COM_HResults.S_OK);
        }
 public static uint Next(this ICorDebugTypeEnum instance, uint celt, ICorDebugType[] values)
 {
     uint pceltFetched;
     instance.__Next(celt, values, out pceltFetched);
     return pceltFetched;
 }
Пример #49
0
 int ICorDebugValue2.GetExactType(out ICorDebugType ppType)
 {
     ppType = new CorDebugGenericType(RuntimeValue.CorElementType, m_rtv, m_appDomain);
     return Utility.COM_HResults.S_OK;
 }
Пример #50
0
        int ICorDebugClass2.GetParameterizedType( CorElementType elementType, uint nTypeArgs, ICorDebugType []ppTypeArgs, out ICorDebugType ppType )
        {
            // CorDebugClass.GetParameterizedType is not implemented
            ppType = null;

            return Utility.COM_HResults.S_OK;
        }
Пример #51
0
        private void SetNameModuleAndFields(CorElementType typeKind, COR_TYPEID typeID, int numFields)
        {
            // THere is recursion in the definition of primitive types (they have a value field of the primtitive type.
            // Cut this off here.
            if (GCRootNames.IsPrimitiveType(typeKind))
            {
                numFields = 0;
            }

            var             buffer   = new StringBuilder(1024);
            IMetadataImport metaData = null;
            int             bufferSizeRet;

            // This is getting names.   If we fail, we can still plow on ....
            try
            {
                ICorDebugType corType = null;
                // Console.WriteLine("Calling GetTypeForTypeID {0:x} {1:x}", typeID.token1, typeID.token2);
                m_heap.m_process5.GetTypeForTypeID(typeID, out corType);

                string moduleFilePath;
                m_name           = GCRootNames.GetTypeName(corType, out moduleFilePath, out metaData, buffer);
                m_moduleFilePath = moduleFilePath;
            }
            catch (Exception e)
            {
                Console.WriteLine("Error: Caught exception for type ID {0:x} {1:x}: {2}", typeID.token1, typeID.token2, e.Message);
                m_name           = string.Format("!ERROR TYPE ID {0:x} {1:x}", typeID.token1, typeID.token2);
                m_moduleFilePath = Name;
            }

            if (numFields > 0)
            {
                m_fields = new ICorDebugGCHeapField[numFields];
                var corFields = new COR_FIELD[numFields];

                int fieldsFetched;
                m_heap.m_process5.GetTypeFields(typeID, corFields.Length, corFields, out fieldsFetched);
                Debug.Assert(fieldsFetched == m_fields.Length);

                for (int i = 0; i < corFields.Length; i++)
                {
                    int    fieldTypeToken, fieldAttr, sigBlobSize, cplusTypeFlab, fieldValSize;
                    IntPtr sigBlob, fieldVal;
                    buffer.Length = 0;
                    if (metaData != null)
                    {
                        metaData.GetFieldProps(corFields[i].token, out fieldTypeToken, buffer, buffer.Capacity, out bufferSizeRet,
                                               out fieldAttr, out sigBlob, out sigBlobSize, out cplusTypeFlab, out fieldVal, out fieldValSize);
                    }

                    var fieldName = buffer.ToString();
                    ICorDebugGCHeapType fieldType = null;
                    // If the type has never been loaded, then you can get a null field type.
                    // TODO FIX NOW, think about this.
                    if (corFields[i].id.token1 != 0 || corFields[i].id.token2 != 0)
                    {
                        // Console.WriteLine("Looking up field {0}.{1} typeId {2:x} {3:x}", Name, fieldName, corFields[i].id.token1, corFields[i].id.token2);
                        Debug.Assert(corFields[i].fieldType != CorElementType.ELEMENT_TYPE_END);

                        // TODO FIX NOW remove the condition
                        if (!GCRootNames.IsReferenceType(corFields[i].fieldType))
                        {
                            fieldType = m_heap.GetObjectTypeFromID(corFields[i].id);
                        }
                    }
                    else
                    {
                        // Console.WriteLine("Warning, NULL type token for {0}.{1} assuming it is an objectRef", Name, fieldName);
                        // Zero means the type is not loaded.   This can only happen if it is a reference type
                        corFields[i].fieldType = CorElementType.ELEMENT_TYPE_CLASS;
                    }
                    // The element types match. (string matches class)
#if DEBUG
                    if (fieldType != null)
                    {
                        var fieldTypeKind = fieldType.TypeKind;
                        if (fieldTypeKind == CorElementType.ELEMENT_TYPE_STRING)
                        {
                            fieldTypeKind = CorElementType.ELEMENT_TYPE_CLASS;
                        }
                        if (fieldTypeKind == CorElementType.ELEMENT_TYPE_OBJECT)
                        {
                            fieldTypeKind = CorElementType.ELEMENT_TYPE_CLASS;
                        }
                        Debug.Assert(fieldTypeKind == corFields[i].fieldType);
                    }
#endif
                    m_fields[i] = new ICorDebugGCHeapField(fieldName, corFields[i].offset, fieldType, corFields[i].fieldType);
                }
            }
        }
        int ICorDebugAppDomain2.GetArrayOrPointerType( CorElementType elementType, uint nRank, ICorDebugType pTypeArg, out ICorDebugType ppType )
        {
            ppType = null;

            return Utility.COM_HResults.S_OK;
        }
Пример #53
0
 internal CorType (ICorDebugType type)
     : base(type)
 {
     m_type = type;
 }
        int ICorDebugAppDomain2.GetFunctionPointerType( uint nTypeArgs, ICorDebugType[] ppTypeArgs, out ICorDebugType ppType )
        {
            ppType = null;

            return Utility.COM_HResults.S_OK;
        }
 public static IType Import(this ICompilation compilation, ICorDebugType corType)
 {
     return(ToTypeReference(corType, GetAppDomain(compilation).Process).Resolve(compilation.TypeResolveContext));
 }
Пример #56
0
 internal CorType(ICorDebugType type)
     : base(type)
 {
     m_type = type;
 }
Пример #57
0
		public ICorDebugType GetParameterizedType(uint elementType, ICorDebugType[] ppTypeArgs)
		{
			return this.GetParameterizedType(elementType, (uint)ppTypeArgs.Length, ppTypeArgs);
		}
 public static ICorDebugType GetFunctionPointerType(this ICorDebugAppDomain2 instance, uint nTypeArgs, ref ICorDebugType ppTypeArgs)
 {
     ICorDebugType ppType;
     instance.__GetFunctionPointerType(nTypeArgs, ref ppTypeArgs, out ppType);
     return ppType;
 }
 internal RuntimeTypeDescriptor(NetDebuggerSession session, ICorDebugType comType)
 {
     _session = session;
     _comType = comType;
 }
Пример #60
0
		DebugType(Process process, ICorDebugType corType)
		{
			if (corType == null) throw new ArgumentNullException("corType");
			
			this.process = process;
			this.corType = corType;
			this.corElementType = (CorElementType)corType.Type;
			
			if (this.IsClass || this.IsValueType) {
				this.corClass = corType.Class;
				this.module = process.GetModule(corClass.Module);
				this.classProps = module.MetaData.GetTypeDefProps(corClass.Token);
			}
			
			if (this.IsClass || this.IsValueType || this.IsArray || this.IsPointer) {
				foreach(ICorDebugType t in corType.EnumerateTypeParameters().Enumerator) {
					typeArguments.Add(DebugType.Create(process, t));
				}
			}
			
			this.fullName = GetFullName();
		}