Beispiel #1
0
        /// <summary>
        /// Initializes a new instance of the <see cref="VSClrAppDomain" /> class.
        /// </summary>
        /// <param name="runtime">The runtime.</param>
        /// <param name="id">The application domain identifier.</param>
        /// <param name="address">The application domain address.</param>
        /// <param name="applicationBase">The application domain base directory.</param>
        /// <param name="configurationFile">The configuration file used for application domain.</param>
        public VSClrAppDomain(VSClrRuntime runtime, int id, string name, ulong address, string applicationBase, string configurationFile)
        {
            VSRuntime         = runtime;
            Id                = id;
            Name              = name;
            Address           = address;
            ApplicationBase   = applicationBase;
            ConfigurationFile = configurationFile;
            modulesCache      = SimpleCache.Create(() =>
            {
                ulong[] moduleAddresses = VSRuntime.Proxy.GetClrAppDomainModules(VSRuntime.Process.Id, VSRuntime.Id, Id);
                VSClrModule[] modules   = new VSClrModule[moduleAddresses.Length];

                for (int i = 0; i < modules.Length; i++)
                {
                    modules[i] = VSRuntime.GetModule(moduleAddresses[i]);
                }
                return(modules);
            });
        }
Beispiel #2
0
        /// <summary>
        /// Initializes a new instance of the <see cref="VSClrRuntime" /> class.
        /// </summary>
        /// <param name="debugger">The Visual Studio debugger.</param>
        /// <param name="process">The process.</param>
        /// <param name="id">The runtime identifier.</param>
        /// <param name="version">The runtime version.</param>
        public VSClrRuntime(VSDebugger debugger, Process process, int id, ModuleVersion version)
        {
            Debugger            = debugger;
            Id                  = id;
            Process             = process;
            Version             = version;
            VSHeap              = new VSClrHeap(this);
            clrTypesCache       = new DictionaryCache <int, VSClrType>((clrTypeId) => new VSClrType(this, clrTypeId));
            threadsAndGcThreads = SimpleCache.Create(() =>
            {
                Tuple <bool, uint, bool, ulong>[] threadTuples = Proxy.GetClrRuntimeThreads(Process.Id, Id);
                List <VSClrThread> threads   = new List <VSClrThread>();
                List <VSClrThread> gcThreads = new List <VSClrThread>();

                for (int i = 0; i < threadTuples.Length; i++)
                {
                    VSClrThread thread = new VSClrThread(this, threadTuples[i].Item2, threadTuples[i].Item3, threadTuples[i].Item4);

                    if (!threadTuples[i].Item1)
                    {
                        gcThreads.Add(thread);
                    }
                    threads.Add(thread);
                }
                return(Tuple.Create(threads.ToArray(), gcThreads.ToArray()));
            });
            modulesCache = SimpleCache.Create(() =>
            {
                ulong[] moduleAddresses = Proxy.GetClrRuntimeModules(Process.Id, Id);
                VSClrModule[] modules   = new VSClrModule[moduleAddresses.Length];

                for (int i = 0; i < modules.Length; i++)
                {
                    modules[i] = new VSClrModule(this, moduleAddresses[i]);
                }
                return(modules);
            });
            appDomainsCache = SimpleCache.Create(() =>
            {
                Tuple <int, string, ulong, string, string>[] tuples = Proxy.GetClrRuntimeAppDomains(Process.Id, Id);
                VSClrAppDomain[] appDomains = new VSClrAppDomain[tuples.Length];

                for (int i = 0; i < tuples.Length; i++)
                {
                    appDomains[i] = new VSClrAppDomain(this, tuples[i].Item1, tuples[i].Item2, tuples[i].Item3, tuples[i].Item4, tuples[i].Item5);
                }
                return(appDomains);
            });
            sharedAppDomainCache = SimpleCache.Create(() =>
            {
                Tuple <int, string, ulong, string, string> tuple = Proxy.GetClrRuntimeSharedAppDomain(Process.Id, Id);

                if (tuple.Item1 == int.MinValue)
                {
                    return(null);
                }
                return(new VSClrAppDomain(this, tuple.Item1, tuple.Item2, tuple.Item3, tuple.Item4, tuple.Item5));
            });
            systemAppDomainCache = SimpleCache.Create(() =>
            {
                Tuple <int, string, ulong, string, string> tuple = Proxy.GetClrRuntimeSystemAppDomain(Process.Id, Id);

                if (tuple.Item1 == int.MinValue)
                {
                    return(null);
                }
                return(new VSClrAppDomain(this, tuple.Item1, tuple.Item2, tuple.Item3, tuple.Item4, tuple.Item5));
            });
            heapCountCache = SimpleCache.Create(() => Proxy.GetClrRuntimeHeapCount(Process.Id, Id));
            serverGCCache  = SimpleCache.Create(() => Proxy.GetClrRuntimeServerGC(Process.Id, Id));
        }