Ejemplo n.º 1
0
        public CorDebugAssembly CreateAssemblyInstance(CorDebugAppDomain appDomain)
        {
            //Ensure the metadata import is created.
            IMetaDataImport iMetaDataImport = MetaDataImport;

            CorDebugAssembly assm = (CorDebugAssembly)MemberwiseClone();

            assm._appDomain       = appDomain;
            assm._primaryAssembly = this;

            return(assm);
        }
Ejemplo n.º 2
0
        public static CorDebugFunction CorDebugFunctionFromMethodIndex(uint methodIndex, CorDebugAppDomain appDomain)
        {
            CorDebugFunction function = null;
            CorDebugAssembly assembly = appDomain.AssemblyFromIdx(nanoCLR_TypeSystem.IdxAssemblyFromIndex(methodIndex));

            if (assembly != null)
            {
                uint tk = nanoCLR_TypeSystem.nanoCLRTokenFromMethodIndex(methodIndex);
                function = assembly.GetFunctionFromTokennanoCLR(tk);
            }

            return(function);
        }
Ejemplo n.º 3
0
        public static CorDebugClass CorDebugClassFromTypeIndex(uint typeIndex, CorDebugAppDomain appDomain)
        {
            CorDebugClass cls = null;

            CorDebugAssembly assembly = appDomain.AssemblyFromIdx(nanoCLR_TypeSystem.IdxAssemblyFromIndex(typeIndex));

            if (assembly != null)
            {
                uint typedef = nanoCLR_TypeSystem.CLR_TkFromType(nanoCLR_TypeSystem.CLR_TABLESENUM.TBL_TypeDef, nanoCLR_TypeSystem.IdxFromIndex(typeIndex));
                cls = assembly.GetClassFromTokennanoCLR(typedef);
            }

            return(cls);
        }
Ejemplo n.º 4
0
        public CorDebugAssembly(CorDebugProcess process, string name, Pdbx.PdbxFile pdbxFile, uint idx)
        {
            _process              = process;
            _appDomain            = null;
            _name                 = name;
            _pdbxFile             = pdbxFile;
            _pdbxAssembly         = (pdbxFile != null) ? pdbxFile.Assembly : null;
            _htTokenCLRToPdbx     = new Hashtable();
            _htTokennanoCLRToPdbx = new Hashtable();
            _idx                 = idx;
            _primaryAssembly     = null;
            _isFrameworkAssembly = false;

            if (_pdbxAssembly != null)
            {
                if (!string.IsNullOrEmpty(pdbxFile.PdbxPath))
                {
                    string pdbxPath = pdbxFile.PdbxPath.ToLower();

                    // pdbx files are supposed to be in the 'packages' folder
                    if (pdbxPath.Contains(@"\packages\"))
                    {
                        _isFrameworkAssembly = (frameworkAssemblies_v1_0.Contains(name.ToLower()));
                    }
                }

                _pdbxAssembly.CorDebugAssembly = this;

                foreach (Pdbx.Class c in _pdbxAssembly.Classes)
                {
                    AddTokenToHashtables(c.Token, c);
                    foreach (Pdbx.Field field in c.Fields)
                    {
                        AddTokenToHashtables(field.Token, field);
                    }

                    foreach (Pdbx.Method method in c.Methods)
                    {
                        AddTokenToHashtables(method.Token, method);
                    }
                }
            }
        }
Ejemplo n.º 5
0
 public CorDebugClass(CorDebugAssembly assembly, uint tkSymbolless) : this(assembly, null)
 {
     m_tkSymbolless = tkSymbolless;
 }
Ejemplo n.º 6
0
 public CorDebugClass(CorDebugAssembly assembly, Pdbx.Class cls)
 {
     m_assembly  = assembly;
     m_pdbxClass = cls;
 }
 // This constructor is used exclusively for resolving potentially (but never really) generic classes into fully specified types.
 // Generics are not supported (yet) but we still need to be able to convert classes into fully specified types.
 public CorDebugGenericType(CorElementType elemType, RuntimeValue rtv, CorDebugAssembly assembly)
 {
     m_elemType = elemType;
     m_rtv      = rtv;
     Assembly   = assembly;
 }
 public ManagedCallbackAssembly(CorDebugAssembly assembly, EventType eventType)
 {
     m_assembly  = assembly;
     m_eventType = eventType;
 }
        public bool UpdateAssemblies()
        {
            uint[] assemblies = null;
            List <ManagedCallbacks.ManagedCallback> callbacks = new System.Collections.Generic.List <ManagedCallbacks.ManagedCallback>();

            if (Process.Engine.Capabilities.AppDomains)
            {
                WireProtocol.Commands.Debugging_Resolve_AppDomain.Reply reply = Process.Engine.ResolveAppDomain(m_id);

                if (reply != null)
                {
                    m_name     = reply.Name;
                    assemblies = reply.m_data;
                }

                if (assemblies == null)
                {
                    //assembly is already unloaded
                    assemblies = new uint[0];
                }
            }
            else
            {
                List <WireProtocol.Commands.DebuggingResolveAssembly> reply = Process.Engine.ResolveAllAssemblies();
                assemblies = new uint[reply.Count];

                for (int iAssembly = 0; iAssembly < assemblies.Length; iAssembly++)
                {
                    assemblies[iAssembly] = reply[iAssembly].Idx;
                }
            }

            //Convert Assembly Index to Idx.
            for (uint iAssembly = 0; iAssembly < assemblies.Length; iAssembly++)
            {
                assemblies[iAssembly] = nanoCLR_TypeSystem.IdxAssemblyFromIndex(assemblies[iAssembly]);
            }

            //Unload dead assemblies
            for (int iAssembly = m_assemblies.Count - 1; iAssembly >= 0; iAssembly--)
            {
                CorDebugAssembly assembly = (CorDebugAssembly)m_assemblies[iAssembly];

                if (Array.IndexOf(assemblies, assembly.Idx) < 0)
                {
                    callbacks.Add(new ManagedCallbacks.ManagedCallbackAssembly(assembly, ManagedCallbacks.ManagedCallbackAssembly.EventType.UnloadModule));
                    callbacks.Add(new ManagedCallbacks.ManagedCallbackAssembly(assembly, ManagedCallbacks.ManagedCallbackAssembly.EventType.UnloadAssembly));

                    m_assemblies.RemoveAt(iAssembly);
                }
            }

            //Load new assemblies
            for (int i = 0; i < assemblies.Length; i++)
            {
                uint idx = assemblies[i];

                CorDebugAssembly assembly = AssemblyFromIdx(idx);

                if (assembly == null)
                {
                    //Get the primary assembly from CorDebugProcess
                    assembly = Process.AssemblyFromIdx(idx);

                    Debug.Assert(assembly != null);

                    //create a new CorDebugAssemblyInstance
                    assembly = assembly.CreateAssemblyInstance(this);

                    Debug.Assert(assembly != null);

                    m_assemblies.Add(assembly);

                    //cpde expects mscorlib to be the first assembly it hears about
                    int index = (assembly.Name == "mscorlib") ? 0 : callbacks.Count;

                    callbacks.Insert(index, new ManagedCallbacks.ManagedCallbackAssembly(assembly, ManagedCallbacks.ManagedCallbackAssembly.EventType.LoadAssembly));
                    callbacks.Insert(index + 1, new ManagedCallbacks.ManagedCallbackAssembly(assembly, ManagedCallbacks.ManagedCallbackAssembly.EventType.LoadModule));
                }
            }

            Process.EnqueueEvents(callbacks);

            return(callbacks.Count > 0);
        }
 public CorDebugAssembly AssemblyFromIndex(uint index)
 {
     return(CorDebugAssembly.AssemblyFromIndex(index, m_assemblies));
 }
 public CorDebugAssembly AssemblyFromIdx(uint idx)
 {
     return(CorDebugAssembly.AssemblyFromIdx(idx, m_assemblies));
 }
Ejemplo n.º 12
0
        public static uint ClassMemberIndexFromnanoCLRToken(uint token, CorDebugAssembly assembly)
        {
            uint idx = nanoCLR_TypeSystem.CLR_DataFromTk(token);

            return(nanoCLR_TypeSystem.IndexFromIdxAssemblyIdx(assembly.Idx, idx));
        }
Ejemplo n.º 13
0
        public static uint ClassMemberIndexFromCLRToken(uint token, CorDebugAssembly assembly)
        {
            Pdbx.ClassMember cm = assembly.GetPdbxClassMemberFromTokenCLR(token);

            return(ClassMemberIndexFromnanoCLRToken(cm.Token.nanoCLR, assembly));
        }