Exemplo n.º 1
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));
        }
Exemplo n.º 2
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();
        }
        public void UpdateModuleSymbols(ICorDebugAppDomain pAppDomain, ICorDebugModule pModule, IStream pSymbolStream)
        {
            EnterCallback("UpdateModuleSymbols", pAppDomain);

            Module module = process.GetModule(pModule);

            if (module.CorModule is ICorDebugModule3 && module.IsDynamic)
            {
                // In .NET 4.0, we use the LoadClass callback to load dynamic modules
                // because it always works - UpdateModuleSymbols does not.
                //  - Simple dynamic code generation seems to trigger both callbacks.
                //  - IronPython for some reason causes just the LoadClass callback
                //    so we choose to rely on it out of the two.
            }
            else
            {
                // In .NET 2.0, this is the the only method and it works fine
                module.LoadSymbolsFromMemory(pSymbolStream);
            }

            ExitCallback();
        }
Exemplo n.º 4
0
        internal Function(Thread thread, FrameID frameID, ICorDebugILFrame corILFrame)
        {
            this.process    = thread.Process;
            this.thread     = thread;
            this.frameID    = frameID;
            this.CorILFrame = corILFrame;
            corFunction     = corILFrame.Function;
            module          = process.GetModule(corFunction.Module);

            methodProps = module.MetaData.GetMethodProps(corFunction.Token);

            // Force some callback when function steps out so that we can expire it
            stepOutStepper = new Stepper(this, "Function Tracker");
            stepOutStepper.StepOut();
            stepOutStepper.PauseWhenComplete = false;

            process.TraceMessage("Function " + this.ToString() + " created");
        }
Exemplo n.º 5
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);
		}
Exemplo n.º 6
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();
		}
Exemplo n.º 7
0
 public static List<DebugType> GetUsesTypes(Process p, DebugType dt)
 {
 	if (unit_debug_types == null)
 	{
 		unit_debug_types = new List<DebugType>();
 		foreach (Type t in unit_types)
 			unit_debug_types.Add(DebugType.Create(p.GetModule(t.Assembly.ManifestModule.ScopeName),(uint)t.MetadataToken));
 	}
 	return unit_debug_types;
 }
        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");
            }
        }
Exemplo n.º 9
0
		internal Function(Thread thread, FrameID frameID, ICorDebugILFrame corILFrame)
		{
			this.process = thread.Process;
			this.thread = thread;
			this.frameID = frameID;
			this.CorILFrame = corILFrame;
			corFunction = corILFrame.Function;
			module = process.GetModule(corFunction.Module);
			
			methodProps = module.MetaData.GetMethodProps(corFunction.Token);
			
			// Force some callback when function steps out so that we can expire it
			stepOutStepper = new Stepper(this, "Function Tracker");
			stepOutStepper.StepOut();
			stepOutStepper.PauseWhenComplete = false;
			
			process.TraceMessage("Function " + this.ToString() + " created");
		}
Exemplo n.º 10
0
		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");
			}
		}