Exemple #1
0
        // The following function create values only for the purpuse of evalutaion
        // They actually do not allocate memory on the managed heap
        // The advantage is that it does not continue the process
        /// <exception cref="DebuggerException">Can not create string this way</exception>
        public static Value CreateValue(Process process, object value)
        {
            if (value is string)
            {
                throw new DebuggerException("Can not create string this way");
            }
            CorElementType corElemType;
            ICorDebugClass corClass = null;

            if (value != null)
            {
                corElemType = DebugType.TypeNameToCorElementType(value.GetType().FullName);
            }
            else
            {
                corElemType = CorElementType.CLASS;
                corClass    = DebugType.Create(process, null, typeof(object).FullName).CorType.Class;
            }
            ICorDebugEval  corEval  = CreateCorEval(process);
            ICorDebugValue corValue = corEval.CreateValue((uint)corElemType, corClass);
            Value          v        = new Value(process, new Expressions.PrimitiveExpression(value), corValue);

            if (value != null)
            {
                v.PrimitiveValue = value;
            }
            return(v);
        }
Exemple #2
0
        /** get the class from metadata info. */
        public DebuggedClass GetClassFromToken(int typeDef)
        {
            ICorDebugClass c = null;

            m_mod.GetClassFromToken((uint)typeDef, out c);
            return(new DebuggedClass(c));
        }
Exemple #3
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));
        }
Exemple #4
0
 public static Value CreateValue(Thread evalThread, object value)
 {
     if (value == null)
     {
         ICorDebugClass corClass = evalThread.AppDomain.ObjectType.ToCorDebug().GetClass();
         ICorDebugEval  corEval  = evalThread.CorThread.CreateEval();
         ICorDebugValue corValue = corEval.CreateValue((uint)CorElementType.CLASS, corClass);
         return(new Value(evalThread.AppDomain, corValue));
     }
     else if (value is string)
     {
         return(Eval.NewString(evalThread, (string)value));
     }
     else
     {
         if (!value.GetType().IsPrimitive)
         {
             throw new DebuggerException("Value must be primitve type.  Seen " + value.GetType());
         }
         IType type = evalThread.AppDomain.Compilation.FindType(value.GetType());
         Value val  = Eval.NewObjectNoConstructor(evalThread, type);
         val.SetPrimitiveValue(evalThread, value);
         return(val);
     }
 }
Exemple #5
0
 public static Value CreateValue(AppDomain appDomain, object value)
 {
     if (value == null)
     {
         ICorDebugClass corClass = appDomain.ObjectType.CorType.GetClass();
         Thread         thread   = GetEvaluationThread(appDomain);
         ICorDebugEval  corEval  = thread.CorThread.CreateEval();
         ICorDebugValue corValue = corEval.CreateValue((uint)CorElementType.CLASS, corClass);
         return(new Value(appDomain, corValue));
     }
     else if (value is string)
     {
         return(Eval.NewString(appDomain, (string)value));
     }
     else
     {
         if (!value.GetType().IsPrimitive)
         {
             throw new DebuggerException("Value must be primitve type.  Seen " + value.GetType());
         }
         Value val = Eval.NewObjectNoConstructor(DebugType.CreateFromType(appDomain.Mscorlib, value.GetType()));
         val.PrimitiveValue = value;
         return(val);
     }
 }
Exemple #6
0
        /** get the class from metadata info. */
        public CorClass GetClassFromToken(int classToken)
        {
            ICorDebugClass c = null;

            m_module.GetClassFromToken((uint)classToken, out c);
            return(new CorClass(c));
        }
Exemple #7
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();
        }
        int ICorDebugEval.NewObjectNoConstructor(ICorDebugClass pClass)
        {
            this.Process.SetCurrentAppDomain(this.AppDomain);
            Engine.AllocateObject(GetScratchPadLocation(), ((CorDebugClass)pClass).TypeDef_Index);
            EndEval(EvalResult.Complete, true);

            return(Utility.COM_HResults.S_OK);
        }
Exemple #9
0
            void ICorDebugManagedCallback.UnloadClass(ICorDebugAppDomain pAppDomain, ICorDebugClass c)
            {
                var ev = new CorEventArgs(new CorAppDomain(pAppDomain, p_options));

                GetOwner(ev.Controller).DispatchEvent(ev);

                FinishEvent(ev);
            }
Exemple #10
0
            void ICorDebugManagedCallback.UnloadClass(ICorDebugAppDomain pAppDomain, ICorDebugClass c)
            {
                var ev = new CorEventArgs(GetCachedAppDomain(pAppDomain), "UnloadClass");

                GetOwner(ev.Controller).DispatchEvent(ev);

                FinishEvent(ev);
            }
Exemple #11
0
 public static Eval AsyncNewObject(Process process, ICorDebugClass classToCreate)
 {
     return(new Eval(
                process,
                "New object: " + classToCreate.Token,
                delegate(ICorDebugEval corEval) { corEval.NewObjectNoConstructor(classToCreate); }
                ));
 }
Exemple #12
0
 public void UnloadClass(
     ICorDebugAppDomain appDomain,
     ICorDebugClass c)
 {
     m_delegate.OnClassUnload(
         new DebuggedClassEventArgs(
             new DebuggedAppDomain(appDomain),
             new DebuggedClass(c)));
 }
Exemple #13
0
        int ICorDebugObjectValue.GetFieldValue(ICorDebugClass pClass, uint fieldDef, out ICorDebugValue ppValue)
        {
            //cache fields?
            RuntimeValue rtv = _rtv.GetField(0, nanoCLR_TypeSystem.ClassMemberIndexFromCLRToken(fieldDef, ((CorDebugClass)pClass).Assembly));

            ppValue = CreateValue(rtv);

            return(COM_HResults.S_OK);
        }
        public void UnloadClass(ICorDebugAppDomain pAppDomain, ICorDebugClass c)
        {
            ManagedCallback managedCallback = GetProcessCallbackInterface(pAppDomain);

            if (managedCallback != null)
            {
                managedCallback.UnloadClass(pAppDomain, c);
            }
        }
 void ICorDebugManagedCallback.UnloadClass(
     ICorDebugAppDomain appDomain,
     ICorDebugClass c)
 {
     if (DebugOutput)
     {
         Console.WriteLine("info: UnloadClass");
     }
     appDomain.Continue(0);
 }
Exemple #16
0
        public void LoadClass(ICorDebugAppDomain pAppDomain, ICorDebugClass c)
        {
            EnterCallback(PausedReason.Other, "LoadClass", pAppDomain);

            Module module = process.Modules[c.GetModule()];

            // Dynamic module has been extended - reload symbols to inlude new class
            module.LoadSymbolsDynamic();

            ExitCallback();
        }
        int ICorDebugEval.CreateValue(CorElementType elementType, ICorDebugClass pElementClass, out ICorDebugValue ppValue)
        {
            uint tdIndex = GetTypeDef_Index(elementType, pElementClass);

            Debug.Assert(Utility.FImplies(pElementClass != null, elementType == CorElementType.ELEMENT_TYPE_VALUETYPE));

            this.Process.SetCurrentAppDomain(this.AppDomain);
            Engine.AllocateObject(GetScratchPadLocation(), tdIndex);
            ppValue = GetResultValue();
            ResetScratchPadLocation();

            return(Utility.COM_HResults.S_OK);
        }
        int ICorDebugEval.NewArray(CorElementType elementType, ICorDebugClass pElementClass, uint rank, ref uint dims, ref uint lowBounds)
        {
            if (rank != 1)
            {
                return(Utility.COM_HResults.E_FAIL);
            }

            this.Process.SetCurrentAppDomain(this.AppDomain);
            uint tdIndex = GetTypeDef_Index(elementType, pElementClass);

            Engine.AllocateArray(GetScratchPadLocation(), tdIndex, 1, (int)dims);
            EndEval(EvalResult.Complete, true);

            return(Utility.COM_HResults.S_OK);
        }
        private uint GetTypeDef_Index(CorElementType elementType, ICorDebugClass pElementClass)
        {
            uint tdIndex;

            if (pElementClass != null)
            {
                tdIndex = ((CorDebugClass)pElementClass).TypeDef_Index;
            }
            else
            {
                CorDebugProcess.BuiltinType builtInType = this.Process.ResolveBuiltInType(elementType);
                tdIndex = builtInType.GetClass(this.m_appDomain).TypeDef_Index;
            }

            return(tdIndex);
        }
        static ICorDebugType ConvertTypeDefOrParameterizedType(IType type, out AppDomain appDomain)
        {
            ITypeDefinition typeDef = type.GetDefinition();

            appDomain = GetAppDomain(typeDef.Compilation);
            var                  info       = GetInfo(typeDef.ParentAssembly);
            uint                 token      = info.GetMetadataToken(typeDef.Parts[0]);
            ICorDebugClass       corClass   = info.Module.CorModule.GetClassFromToken(token);
            List <ICorDebugType> corGenArgs = new List <ICorDebugType>();
            ParameterizedType    pt         = type as ParameterizedType;

            if (pt != null)
            {
                foreach (var typeArg in pt.TypeArguments)
                {
                    corGenArgs.Add(typeArg.ToCorDebug());
                }
            }
            return(((ICorDebugClass2)corClass).GetParameterizedType((uint)(type.IsReferenceType == false ? CorElementType.VALUETYPE : CorElementType.CLASS), corGenArgs.ToArray()));
        }
 int ICorDebugType.GetClass(out ICorDebugClass ppClass)
 {
     ppClass = CorDebugValue.ClassFromRuntimeValue(m_ValueArray.RuntimeValue, m_ValueArray.AppDomain);
     return(COM_HResults.S_OK);
 }
Exemple #22
0
 internal CorClass(ICorDebugClass managedClass)
     : base(managedClass)
 {
     m_class = managedClass;
 }
Exemple #23
0
        public void LoadClass(ICorDebugAppDomain pAppDomain, ICorDebugClass c)
        {
            EnterCallback(PausedReason.Other, "LoadClass", pAppDomain);

            ExitCallback_Continue();
        }
 public CorClass(ICorDebugClass corClass, ICorDebugModule module)
 {
     m_corClass = corClass;
     m_module = module;
 }
		public static ICorDebugValue GetFieldValue(this ICorDebugContext instance, ICorDebugClass pClass, uint fieldDef)
		{
			ICorDebugValue ppValue;
			instance.__GetFieldValue(pClass, fieldDef, out ppValue);
			ProcessOutParameter(ppValue);
			return ppValue;
		}
		public void UnloadClass(ICorDebugAppDomain pAppDomain, ICorDebugClass c)
		{
			EnterCallback(PausedReason.Other, "UnloadClass", pAppDomain);
			
			ExitCallback();
		}
		protected ClassDebugCallbackEventArgs(ICorDebugAppDomain pAppDomain, ICorDebugClass c)
			: base(pAppDomain) {
			this.AppDomain = pAppDomain;
			this.Class = c;
		}
        int ICorDebugObjectValue.GetClass( out ICorDebugClass ppClass )
        {
            ppClass = m_class;

            return Utility.COM_HResults.S_OK;            
        }
Exemple #29
0
        int ICorDebugFunction.GetClass(out ICorDebugClass ppClass)
        {
            ppClass = m_class;

            return(COM_HResults.S_OK);
        }
 public static void NewParameterizedObjectNoConstructor(this ICorDebugEval2 instance, ICorDebugClass pClass, uint nTypeArgs, ICorDebugType[] ppTypeArgs)
 {
     instance.__NewParameterizedObjectNoConstructor(pClass, nTypeArgs, ppTypeArgs);
 }
 public static ICorDebugValue CreateValue(this ICorDebugEval instance, uint elementType, ICorDebugClass pElementClass)
 {
     ICorDebugValue ppValue;
     instance.__CreateValue(elementType, pElementClass, out ppValue);
     return ppValue;
 }
 public static void NewObjectNoConstructor(this ICorDebugEval instance, ICorDebugClass pClass)
 {
     instance.__NewObjectNoConstructor(pClass);
 }
 public static void NewArray(this ICorDebugEval instance, uint elementType, ICorDebugClass pElementClass, uint rank, ref uint dims, ref uint lowBounds)
 {
     instance.__NewArray(elementType, pElementClass, rank, ref dims, ref lowBounds);
 }
 public static ICorDebugValue GetFieldValue(this ICorDebugObjectValue instance, ICorDebugClass pClass, uint fieldDef)
 {
     ICorDebugValue ppValue;
     instance.__GetFieldValue(pClass, fieldDef, out ppValue);
     return ppValue;
 }
        int ICorDebugObjectValue.GetFieldValue( ICorDebugClass pClass, uint fieldDef, out ICorDebugValue ppValue )
        {
            //cache fields?
            RuntimeValue rtv = m_rtv.GetField( 0, TinyCLR_TypeSystem.ClassMemberIndexFromCLRToken( fieldDef, ((CorDebugClass)pClass).Assembly ) );

            ppValue = CreateValue( rtv );

            return Utility.COM_HResults.S_OK;                 
        }
Exemple #36
0
 public void UnloadClass(ICorDebugAppDomain pAppDomain, ICorDebugClass c)
 {
     pAppDomain.Continue(0);
 }
        int ICorDebugModule.GetClassFromToken( uint typeDef, out ICorDebugClass ppClass )
        {
            ppClass = GetClassFromTokenCLR( typeDef );

            return Utility.COM_HResults.S_OK;
        }
Exemple #38
0
 internal uint[] _GetFieldTokens(IMetaDataImport importer, ICorDebugClass iclass)
 {
     uint ctoken;
     iclass.GetToken(out ctoken);
     uint henum = 0;
     List<uint> fieldtoks = new List<uint>();
     try
     {
         uint[] aonefieldtok = new uint[1];
         for (; ; )
         {
             uint count;
             importer.EnumFields(ref henum, ctoken, aonefieldtok, 1, out count);
             if (1 != count)
             {
                 break;
             }
             fieldtoks.Add(aonefieldtok[0]);
         }
     }
     finally
     {
         importer.CloseEnum(henum);
     }
     return fieldtoks.ToArray();
 }
 int ICorDebugEval2.NewParameterizedObjectNoConstructor(ICorDebugClass pClass, uint nTypeArgs, ICorDebugType[] ppTypeArgs)
 {
     return(((ICorDebugEval)this).NewObjectNoConstructor(pClass));
 }
Exemple #40
0
            public void UnloadClass(ICorDebugAppDomain pAppDomain, ICorDebugClass c)
            {
                try
                {
                    _EnterCallback();

                    _CallbackNotImplemented();

                    _CallbackEvent("UnloadClass");
                }
                catch (Exception e)
                {
                    _CallbackException(e);
                }
            }
		public UnloadClassDebugCallbackEventArgs(ICorDebugAppDomain pAppDomain, ICorDebugClass c)
			: base(pAppDomain, c) {
		}
 public CorClass(ICorDebugClass corClass)
 {
     m_corClass = corClass;
     m_corClass.GetModule(out m_module);
 }
		public void LoadClass(ICorDebugAppDomain pAppDomain, ICorDebugClass c)
		{
			EnterCallback(PausedReason.Other, "LoadClass", pAppDomain);
			
			ExitCallback_Continue();
		}
 internal RuntimeClass(NetDebuggerSession session, ICorDebugClass comClass)
 {
     _session = session;
     _comClass = comClass;
 }
 public virtual void UnloadClass(ICorDebugAppDomain appDomain, ICorDebugClass @class)
 {
     this.DefaultHandler(appDomain);
 }
 int ICorDebugType.GetClass (out ICorDebugClass ppClass)
 {
     ppClass = CorDebugValue.ClassFromRuntimeValue(m_ValueArray.RuntimeValue, m_ValueArray.AppDomain);
     return Utility.COM_HResults.S_OK;
 }
Exemple #47
0
 internal uint _FindFieldTokenByName(IMetaDataImport importer, ICorDebugClass iclass, uint[] fieldtoks, string name)
 {
     uint classtok;
     iclass.GetToken(out classtok);
     return _FindFieldTokenByName(importer, classtok, fieldtoks, name);
 }
Exemple #48
0
        public void UnloadClass(ICorDebugAppDomain pAppDomain, ICorDebugClass c)
        {
            EnterCallback(PausedReason.Other, "UnloadClass", pAppDomain);

            ExitCallback();
        }
Exemple #49
0
        int ICorDebugObjectValue.GetClass(out ICorDebugClass ppClass)
        {
            ppClass = m_class;

            return(COM_HResults.S_OK);
        }
		public void UnloadClass(ICorDebugAppDomain pAppDomain, ICorDebugClass c)
		{
			EnterCallback("UnloadClass", pAppDomain);
			
			ExitCallback();
		}
Exemple #51
0
 internal CorClass(ICorDebugClass managedClass)
     : base(managedClass)
 {
     m_class = managedClass;
 }
 protected ClassDebugCallbackEventArgs(ICorDebugAppDomain pAppDomain, ICorDebugClass c)
     : base(pAppDomain)
 {
     AppDomain = pAppDomain;
     Class     = c;
 }
		public void LoadClass(ICorDebugAppDomain pAppDomain, ICorDebugClass c)
		{
			EnterCallback("LoadClass", pAppDomain);
			
			Module module = process.GetModule(c.GetModule());
			
			// Dynamic module has been extended - reload symbols to inlude new class
			module.LoadSymbolsDynamic();
			
			ExitCallback();
		}
 public UnloadClassDebugCallbackEventArgs(ICorDebugAppDomain pAppDomain, ICorDebugClass c)
     : base(pAppDomain, c)
 {
 }
		public void UnloadClass(ICorDebugAppDomain pAppDomain, ICorDebugClass c)
		{
			ManagedCallback managedCallback = GetProcessCallbackInterface("UnloadClass", pAppDomain);
			if (managedCallback != null) {
				managedCallback.UnloadClass(pAppDomain, c);
			}
		}
        public void UnloadClass(ICorDebugAppDomain pAppDomain, ICorDebugClass c)
        {
            EnterCallback("UnloadClass", pAppDomain);

            ExitCallback();
        }
        int ICorDebugFunction.GetClass( out ICorDebugClass ppClass )
        {
            ppClass = m_class;

            return Utility.COM_HResults.S_OK;
        }
Exemple #58
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();
		}
Exemple #59
0
 void ICorDebugManagedCallback.UnloadClass(
                          ICorDebugAppDomain appDomain,
                          ICorDebugClass c)
 {
     HandleEvent(ManagedCallbackType.OnClassUnload,
                       new CorClassEventArgs( appDomain == null ? null : new CorAppDomain(appDomain),
                                              c == null ? null : new CorClass(c),
                                              ManagedCallbackType.OnClassUnload));
 }
Exemple #60
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);
		}