Beispiel #1
0
        /// <summary>
        /// Initializes a new instance of the <see cref="Runtime" /> class.
        /// </summary>
        /// <param name="process">The process.</param>
        /// <param name="clrRuntime">The CLR runtime.</param>
        internal Runtime(Process process, Microsoft.Diagnostics.Runtime.ClrRuntime clrRuntime)
        {
            Process      = process;
            ClrRuntime   = clrRuntime;
            appDomains   = SimpleCache.Create(() => ClrRuntime.AppDomains.Select(ad => new AppDomain(this, ad)).ToArray());
            modules      = SimpleCache.Create(() => ClrRuntime.Modules.Select(mm => Process.Modules.Where(m => m.Address == mm.ImageBase).FirstOrDefault()).Where(m => m != null).ToArray());
            sharedDomain = SimpleCache.Create(() => ClrRuntime.SharedDomain != null ? new AppDomain(this, ClrRuntime.SharedDomain) : null);
            systemDomain = SimpleCache.Create(() => ClrRuntime.SystemDomain != null ? new AppDomain(this, ClrRuntime.SystemDomain) : null);
            threads      = SimpleCache.Create(() => ClrRuntime.Threads.Select(tt => Process.Threads.Where(t => t.SystemId == tt.OSThreadId).FirstOrDefault()).Where(t => t != null).ToArray());
            gcThreads    = SimpleCache.Create(() => ClrRuntime.EnumerateGCThreads().Select(tt => Process.Threads.Where(t => t.SystemId == tt).FirstOrDefault()).Where(t => t != null).ToArray());

            var version = ClrRuntime.ClrInfo.Version;

            Version = new ModuleVersion()
            {
                Major    = version.Major,
                Minor    = version.Minor,
                Patch    = version.Patch,
                Revision = version.Revision,
            };
        }
Beispiel #2
0
        /// <summary>
        /// Initializes a new instance of the <see cref="ClrMdRuntime" /> class.
        /// </summary>
        /// <param name="provider">The ClrMD provider.</param>
        /// <param name="process">The process.</param>
        /// <param name="clrRuntime">The CLR runtime.</param>
        internal ClrMdRuntime(CLR.ClrMdProvider provider, Process process, Microsoft.Diagnostics.Runtime.ClrRuntime clrRuntime)
        {
            Provider     = provider;
            Process      = process;
            ClrRuntime   = clrRuntime;
            appDomains   = SimpleCache.Create(() => ClrRuntime.AppDomains.Select(ad => new ClrMdAppDomain(this, ad)).ToArray());
            modules      = SimpleCache.Create(() => ClrRuntime.Modules.Select(mm => Provider.FromClrModule(mm)).ToArray());
            sharedDomain = SimpleCache.Create(() => ClrRuntime.SharedDomain != null ? new ClrMdAppDomain(this, ClrRuntime.SharedDomain) : null);
            systemDomain = SimpleCache.Create(() => ClrRuntime.SystemDomain != null ? new ClrMdAppDomain(this, ClrRuntime.SystemDomain) : null);
            threads      = SimpleCache.Create(() => ClrRuntime.Threads.Select(tt => new ClrMdThread(Process.Threads.Where(t => t.SystemId == tt.OSThreadId).FirstOrDefault(), tt, Process)).ToArray());
            gcThreads    = SimpleCache.Create(() => ClrRuntime.EnumerateGCThreads().Select(tt => new ClrMdThread(Process.Threads.Where(t => t.SystemId == tt).FirstOrDefault(), ClrRuntime.Threads.First(ct => ct.OSThreadId == tt), Process)).ToArray());
            heap         = SimpleCache.Create(() => new ClrMdHeap(this, ClrRuntime.GetHeap()));

            var version = ClrRuntime.ClrInfo.Version;

            Version = new ModuleVersion()
            {
                Major    = version.Major,
                Minor    = version.Minor,
                Patch    = version.Patch,
                Revision = version.Revision,
            };
        }
Beispiel #3
0
 /// <summary>
 /// Gets the process for the specified CLR runtime.
 /// </summary>
 /// <param name="runtime">The CLR runtime.</param>
 internal Process GetProcess(Microsoft.Diagnostics.Runtime.ClrRuntime runtime)
 {
     return(Process.All.FirstOrDefault(p => p.ClrRuntimes.Cast <ClrMdRuntime>().Any(r => r.ClrRuntime == runtime)));
 }