public void AppDomainPropertyTest() { IClrRuntime runtime = Process.Current.ClrRuntimes.Single(); IClrAppDomain systemDomain = runtime.SystemDomain; Assert.Equal("System Domain", systemDomain.Name); IClrAppDomain sharedDomain = runtime.SharedDomain; Assert.Equal("Shared Domain", sharedDomain.Name); Assert.Null(systemDomain.ApplicationBase); Assert.True(string.IsNullOrEmpty(systemDomain.ConfigurationFile)); Assert.Equal("0: System Domain", systemDomain.ToString()); Assert.Equal(2, runtime.AppDomains.Length); IClrAppDomain AppDomainsExe = runtime.AppDomains[0]; Assert.Equal("AppDomains.exe", AppDomainsExe.Name); Assert.Equal(1, AppDomainsExe.Id); IClrAppDomain NestedExceptionExe = runtime.AppDomains[1]; Assert.Equal("Second AppDomain", NestedExceptionExe.Name); Assert.Equal(2, NestedExceptionExe.Id); }
/// <summary> /// Extracts data from the provided object /// </summary> /// <param name="clrObject">The object.</param> /// <param name="clrRuntime">The runtime.</param> /// <returns>Extracted dump object</returns> /// <inheritdoc /> public DumpObject Extract(IClrObject clrObject, IClrRuntime clrRuntime) { var text = clrObject.GetStringField("text"); return(new ButtonDumpObject(clrObject.Address, clrObject.Type.Name, clrObject.Size, clrRuntime.Heap.GetGeneration(clrObject.Address), text)); }
/// <summary> /// Extracts data from the provided object /// </summary> /// <param name="clrObject">The object.</param> /// <param name="clrRuntime">The runtime.</param> /// <returns>Extracted dump object</returns> /// <inheritdoc /> public DumpObject Extract(IClrObject clrObject, IClrRuntime clrRuntime) { var value = (string)clrObject.Type.GetValue(clrObject.Address); var heapObject = new StringDumpObject(clrObject.Address, "System.String", clrObject.Size, value, clrRuntime.Heap.GetGeneration(clrObject.Address)); return(heapObject); }
/// <summary> /// Extracts the specified address. /// </summary> /// <param name="address">The address.</param> /// <param name="clrRuntime">The color runtime.</param> /// <returns>DumpObject.</returns> /// <inheritdoc /> public DumpObject Extract(ulong address, IClrRuntime clrRuntime) { var type = clrRuntime.Heap.GetObjectType(address); var textField = type.GetFieldByName("text"); var text = (string)textField.GetValue(address); return(new ButtonDumpObject(address, type.Name, type.GetSize(address), clrRuntime.Heap.GetGeneration(address), text)); }
/// <summary> /// Extracts data from the provided object /// </summary> /// <param name="clrObject">The object.</param> /// <param name="clrRuntime">The runtime.</param> /// <returns>Extracted dump object</returns> public DumpObject Extract(IClrObject clrObject, IClrRuntime clrRuntime) { var address = clrObject.Address; var gen = clrRuntime.Heap.GetGeneration(address); var size = clrObject.Size; var name = clrObject.Type.Name; var dumpObject = new DumpObject(address, name, size, gen); return(dumpObject); }
/// <summary> /// Initializes a new instance of the <see cref="ClrMdProvider"/> class. /// </summary> public ClrMdProvider() { dataTargetsPerProcess = new DictionaryCache <uint, Microsoft.Diagnostics.Runtime.DataTarget>(GetDataTarget); clrTypes = new DictionaryCache <Microsoft.Diagnostics.Runtime.ClrType, ClrMdType>(type => new ClrMdType(this, type)); clrModules = new DictionaryCache <Microsoft.Diagnostics.Runtime.ClrModule, ClrMdModule>(module => new ClrMdModule(this, module)); clrHeaps = new DictionaryCache <Microsoft.Diagnostics.Runtime.ClrHeap, ClrMdHeap>(clrHeap => { IClrRuntime runtime = Process.All.SelectMany(p => p.ClrRuntimes).Where(r => ((ClrMdRuntime)r).ClrRuntime == clrHeap.Runtime).FirstOrDefault(); return((ClrMdHeap)(runtime?.Heap)); }); }
public void HeapSize() { IClrRuntime runtime = Process.Current.ClrRuntimes.Single(); IClrHeap heap = runtime.Heap; Assert.True(heap.TotalHeapSize > 0); ulong generationSizes = 0; for (int generation = 0; generation <= 3; generation++) { generationSizes += heap.GetSizeByGeneration(generation); } Assert.Equal(heap.TotalHeapSize, generationSizes); }
public void SystemAndSharedLibraryModulesTest() { IClrRuntime runtime = Process.Current.ClrRuntimes.Single(); IClrAppDomain systemDomain = runtime.SystemDomain; Assert.Empty(systemDomain.Modules); IClrAppDomain sharedDomain = runtime.SharedDomain; Assert.Single(sharedDomain.Modules); IClrModule mscorlib = sharedDomain.Modules.Single(); Assert.Equal("mscorlib.dll", Path.GetFileName(mscorlib.Module.ImageName), ignoreCase: true); }
public void HeapEnumeration() { IClrRuntime runtime = Process.Current.ClrRuntimes.Single(); IClrHeap heap = runtime.Heap; Assert.NotNull(heap); Assert.NotNull(runtime.GCThreads); Assert.True(runtime.HeapCount > 0); Assert.NotNull(runtime.ToString()); Assert.True(heap.CanWalkHeap); int count = 0; foreach (Variable variable in heap.EnumerateObjects()) { Assert.NotNull(variable); count++; } Assert.True(count > 0); }
public void ModuleDomainTest() { IClrRuntime runtime = Process.Current.ClrRuntimes.Single(); IClrAppDomain appDomainExe = runtime.GetAppDomainByName("AppDomains.exe"); IClrAppDomain nestedDomain = runtime.GetAppDomainByName("Second AppDomain"); IClrModule mscorlib = runtime.GetModuleByFileName("mscorlib.dll"); AssertModuleContainsDomains(mscorlib, runtime.SharedDomain, appDomainExe, nestedDomain); AssertModuleDoesntContainDomains(mscorlib, runtime.SystemDomain); IClrModule appDomainsExeModule = runtime.GetModuleByFileName("AppDomains.exe"); AssertModuleContainsDomains(appDomainsExeModule, appDomainExe); AssertModuleDoesntContainDomains(appDomainsExeModule, runtime.SystemDomain, runtime.SharedDomain, nestedDomain); IClrModule nestedExeModule = runtime.GetModuleByFileName("NestedException.exe"); AssertModuleContainsDomains(nestedExeModule, nestedDomain); AssertModuleDoesntContainDomains(nestedExeModule, runtime.SystemDomain, runtime.SharedDomain, appDomainExe); }
/// <summary> /// Initializes a new instance of the <see cref="DumpInformationRepository" /> class. /// </summary> /// <param name="dataTarget">The data target.</param> /// <param name="runtime">The runtime.</param> /// <param name="dumpFile">The dump file.</param> /// <exception cref="ArgumentNullException">dataTarget</exception> /// <exception cref="System.ArgumentNullException">dataTarget</exception> public DumpInformationRepository(IDataTarget dataTarget, IClrRuntime runtime, FileInfo dumpFile) { CpuUtilization = runtime.ThreadPool.CpuUtilization; DumpFile = dumpFile; HeapCount = runtime.HeapCount; IsMiniDump = dataTarget?.IsMinidump ?? throw new ArgumentNullException(nameof(dataTarget)); IsServerGc = runtime.IsServerGc; MaxNumberFreeIoCompletionPorts = runtime.ThreadPool.MaxFreeCompletionPorts; MaxNumberIoCompletionPorts = runtime.ThreadPool.MaxCompletionPorts; MaxThreads = runtime.ThreadPool.MaxThreads; MinNumberIoCompletionPorts = runtime.ThreadPool.MinCompletionPorts; MinThreads = runtime.ThreadPool.MinThreads; NumberFreeIoCompletionPorts = runtime.ThreadPool.FreeCompletionPortCount; NumberIdleThreads = runtime.ThreadPool.IdleThreads; NumRunningThreads = runtime.ThreadPool.RunningThreads; ModuleInfosInternal = dataTarget?.EnumerateModules().ToList(); SymbolCache = dataTarget.SymbolLocator.SymbolCache; SymbolPath = dataTarget.SymbolLocator.SymbolPath; TotalHeapSize = runtime.Heap.TotalHeapSize; TotalThreads = runtime.ThreadPool.TotalThreads; StartTimeUtc = DateTime.UtcNow; }
/// <summary> /// Gets the CLR runtimes running in the specified process. /// </summary> /// <param name="process">The process.</param> public IClrRuntime[] GetClrRuntimes(Process process) { Tuple <int, int, int, int, int>[] runtimeTuples = Proxy.GetClrRuntimes(process.Id); if (runtimeTuples == null) { return(new IClrRuntime[0]); } IClrRuntime[] runtimes = new IClrRuntime[runtimeTuples.Length]; for (int i = 0; i < runtimeTuples.Length; i++) { runtimes[i] = new VSClrRuntime(this, process, runtimeTuples[i].Item1, new ModuleVersion { Major = runtimeTuples[i].Item2, Minor = runtimeTuples[i].Item3, Revision = runtimeTuples[i].Item4, Patch = runtimeTuples[i].Item5, }); } return(runtimes); }
public void ModuleAppDomainEqualityTest() { IClrRuntime runtime = Process.Current.ClrRuntimes.Single(); IClrAppDomain appDomainsExe = runtime.GetAppDomainByName("AppDomains.exe"); IClrAppDomain nestedExceptionExe = runtime.GetAppDomainByName("Second AppDomain"); Dictionary <string, Module> appDomainsModules = GetAppDomainModuleDictionary(appDomainsExe); Assert.True(appDomainsModules.ContainsKey("appdomains.exe")); Assert.True(appDomainsModules.ContainsKey("mscorlib.dll")); Assert.False(appDomainsModules.ContainsKey("nestedexception.exe")); Dictionary <string, Module> nestedExceptionModules = GetAppDomainModuleDictionary(nestedExceptionExe); Assert.True(nestedExceptionModules.ContainsKey("nestedexception.exe")); Assert.True(nestedExceptionModules.ContainsKey("mscorlib.dll")); Assert.False(nestedExceptionModules.ContainsKey("appdomains.exe")); // Ensure that we use the same Module in each AppDomain. Assert.Equal(appDomainsModules["mscorlib.dll"], nestedExceptionModules["mscorlib.dll"]); }
/// <summary> /// Determines whether this instance can extract from the provided object /// </summary> /// <param name="clrObject">The object to try to get values from</param> /// <param name="clrRuntime">The clr runtime being used</param> /// <returns><c>true</c> if this instance can extract from the object; otherwise, <c>false</c>.</returns> public bool CanExtract(IClrObject clrObject, IClrRuntime clrRuntime) => true;
/// <summary> /// Extracts the specified address. /// </summary> /// <param name="address">The address.</param> /// <param name="clrRuntime">The color runtime.</param> /// <returns>DumpObject.</returns> /// <inheritdoc /> public DumpObject Extract(ulong address, IClrRuntime clrRuntime) { var type = clrRuntime.Heap.GetObjectType(address); return(new DumpObject(address, type.Name, type.GetSize(address), clrRuntime.Heap.GetGeneration(address))); }
/// <summary> /// Determines whether this instance can extract from the provided object /// </summary> /// <param name="clrObject">The object to try to get values from</param> /// <param name="clrRuntime">The clr runtime being used</param> /// <returns><c>true</c> if this instance can extract from the object; otherwise, <c>false</c>.</returns> /// <inheritdoc /> public bool CanExtract(IClrObject clrObject, IClrRuntime clrRuntime) => clrObject.Type.Name == "System.Windows.Forms.Button";
/// <summary> /// Determines whether this instance can extract from the provided object /// </summary> /// <param name="clrObject">The object to try to get values from</param> /// <param name="clrRuntime">The clr runtime being used</param> /// <returns><c>true</c> if this instance can extract from the object; otherwise, <c>false</c>.</returns> /// <inheritdoc /> public bool CanExtract(IClrObject clrObject, IClrRuntime clrRuntime) => clrObject.Type?.Name == "System.String";
public void WorkstationSegmentTests() { IClrRuntime runtime = Process.Current.ClrRuntimes.Single(); Assert.False(runtime.ServerGC); }
/// <summary> /// Determines whether this instance can extract the specified address. /// </summary> /// <param name="address">The address.</param> /// <param name="clrRuntime">The color runtime.</param> /// <returns><c>true</c> if this instance can extract the specified address; otherwise, <c>false</c>.</returns> /// <inheritdoc /> public bool CanExtract(ulong address, IClrRuntime clrRuntime) { var type = clrRuntime.Heap.GetObjectType(address); return(type.Name == "System.Windows.Forms.Button"); }
public void ServerSegmentTests() { IClrRuntime runtime = Process.Current.ClrRuntimes.Single(); Assert.True(runtime.ServerGC); }
/// <summary> /// Determines whether this instance can extract the specified address. /// </summary> /// <param name="address">The address.</param> /// <param name="clrRuntime">The color runtime.</param> /// <returns><c>true</c> if this instance can extract the specified address; otherwise, <c>false</c>.</returns> /// <inheritdoc /> public bool CanExtract(ulong address, IClrRuntime clrRuntime) => true;