Example #1
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));
        }
Example #2
0
        /// <summary>
        /// Enumerates the GC references (objects) on the stack.
        /// </summary>
        public IEnumerable <Variable> EnumerateStackObjects()
        {
            Tuple <int, Tuple <ulong, int>[]> firstBatch = Proxy.EnumerateClrThreadStackObjects(VSRuntime.Process.Id, VSRuntime.Id, SystemId, VSClrHeap.EnumerationBatchSize);

            return(VSClrHeap.EnumerateVariables(VSRuntime, firstBatch));
        }