public static List<ClrType> GetDelegateTypes(ClrDump clrDump) { CancellationTokenSource token = new CancellationTokenSource(); clrDump.MessageBus.BeginTask("Analyzing delegate types...", token); List<ClrType> delegates = new List<ClrType>(); var delegateType = clrDump.GetClrType(typeof(MulticastDelegate).FullName); foreach(var type in clrDump.AllTypes) { clrDump.MessageBus.Status($"Analyzing delegate type: {type.Name}"); if (token.IsCancellationRequested) { break; } if ( type.BaseType != null && type.BaseType == delegateType ) { clrDump.MessageBus.Status($"Analyzing delegate type: counting instances for {type.Name}"); int nb = clrDump.CountInstances(type); if (nb > 0) { delegates.Add(type); } } } clrDump.MessageBus.EndTask("Delegate types analyzed."); return delegates.GroupBy(t => t.Name).Select(g => g.First()).ToList(); }
public DelegateTypeInformation(ClrDump clrDump, ClrType clrType, int count, long targetCount) { ClrDump = clrDump; ClrType = clrType; Count = count; Targets = targetCount; }
public ClrExceptionInformation(ClrDump clrDump, ClrException exception) { this.exception = exception; Message = clrDump.Eval(() => exception.Message); StackFrames = clrDump.Eval(() => exception.StackTrace.Select(frame => new StackFrameInformation(clrDump, frame))).ToList(); TypeName = exception.Type.Name; }
public ArrayInstanceInformation(ClrDump clrDump, ClrType clrType, ulong address, int length, float? nullRatio, float? uniqueRatio) { Address = address; Length = length; NullRatio = nullRatio; UniqueRatio = uniqueRatio; }
public void Setup(ClrDump clrDump, ClrThread clrThread) { ClrDump = clrDump; ClrThread = clrThread; Icon = Properties.Resources.exclamation_small; Name = $"#{clrDump.Id} - Exception"; }
public LoneTargetInformation(ClrDump clrDump, ClrObject target, ClrMethod methInfo, ClrObject owner) { this.clrDump = clrDump; this.target = target; this.methInfo = methInfo; this.owner = owner; }
internal static List<DisposableTypeInformation> GetDisposableTypeInformations(ClrDump clrDump) { CancellationTokenSource token = new CancellationTokenSource(); clrDump.MessageBus.BeginTask("Analyzing IDisposable types...", token); List<DisposableTypeInformation> result = new List<DisposableTypeInformation>(); foreach (var type in clrDump.AllTypes) { clrDump.MessageBus.Status($"Analyzing type: {type.Name}"); if (token.IsCancellationRequested) { clrDump.MessageBus.EndTask("Analyzing IDisposable types: cancelled."); return result; } foreach (var interf in type.Interfaces) { if( interf.Name == typeof(System.IDisposable).FullName) { clrDump.MessageBus.Status($"Analyzing IDisposable type: counting instances for {type.Name}"); int nb = clrDump.CountInstances(type); result.Add(new DisposableTypeInformation(type, nb)); } } } clrDump.MessageBus.EndTask("IDisposable types analyzed."); return result; }
public void Setup(ClrDump clrDump) { ClrDump = clrDump; Icon = Properties.Resources.outline_wight_gallery_small; Name = $"#{clrDump.Id} - Segments"; dlvSegments.InitColumns <SegmentInformation>(); }
public void Setup(ClrDump clrDump) { ClrDump = clrDump; Icon = Properties.Resources.plugin_link_small; Name = $"#{clrDump.Id} - Handles"; dlvHandles.InitColumns <HandleInformation>(); }
public void Setup(ClrDump clrDump) { ClrDump = clrDump; Icon = Properties.Resources.borders_accent_small; Name = $"#{clrDump.Id} - Regions"; dlvRegions.InitColumns <RegionInformation>(); }
public ReferersInformation(ClrDump clrDump, ClrType clrType, MessageBus messageBus, IAddressContainer addresses) : this(clrDump, clrType, null, messageBus, 0) { for (int i = 0; i < addresses.Count; i++) { Instances.Add(addresses[i]); } Init(); }
public void Setup(ClrDump clrDump) { ClrDump = clrDump; Icon = Properties.Resources.plugin_link_small; Name = $"#{clrDump.Id} - Handles"; dlvHandles.InitColumns<HandleInformation>(); }
public void Setup(ClrDump clrDump) { ClrDump = clrDump; Icon = Properties.Resources.outline_wight_gallery_small; Name = $"#{clrDump.Id} - Segments"; dlvSegments.InitColumns<SegmentInformation>(); }
public void Setup(ClrDump clrDump) { ClrDump = clrDump; Icon = Properties.Resources.borders_accent_small; Name = $"#{clrDump.Id} - Regions"; dlvRegions.InitColumns<RegionInformation>(); }
public void Setup(ClrDump clrDump) { ClrDump = clrDump; Icon = Properties.Resources.module_small; Name = $"#{clrDump.Id} - Modules"; dlvModules.InitColumns<ModuleInformation>(); }
public void Setup(ClrDump clrDump) { ClrDump = clrDump; Icon = Properties.Resources.text_rotate_small; Name = $"#{clrDump.Id:###,###,###,##0} - Strings"; dlvStrings.InitColumns <StringInformation>(); dlvStrings.RegisterDataProvider(() => Data, this); }
public void Setup(ClrDump clrDump, ClrThread thread) { ClrDump = clrDump; Thread = thread; Icon = Properties.Resources.red_line_small; Name = $"#{clrDump.Id} - StackTrace - Id: {Thread?.ManagedThreadId}"; dlvStackFrames.InitColumns<StackFrameInformation>(); }
private static ClrMethod GetDelegateMethod(ClrDump clrDump, ClrObject handler, ClrObject target) { var targetType = target.Type; var methPtrObj = handler[MethodPtrFieldName]; var methPtrLong = (long)methPtrObj.SimpleValue; var methPtr = (ulong)methPtrLong; return(GetDelegateMethod(methPtr, clrDump)); }
public void Setup(ClrDump clrDump, ClrThread thread) { ClrDump = clrDump; Thread = thread; Icon = Properties.Resources.red_line_small; Name = $"#{clrDump.Id} - StackTrace - Id: {Thread?.ManagedThreadId}"; dlvStackFrames.InitColumns <StackFrameInformation>(); }
public void Setup(ClrDump clrDump) { ClrDump = clrDump; Icon = Properties.Resources._lock_small; Name = $"#{clrDump.Id} - BlockingObjects"; dlvBlockingObjects.InitColumns<BlockingObjectInformation>(); dlvBlockingObjects.SetUpAddressColumn<BlockingObjectInformation>(this); dlvBlockingObjects.SetUpTypeColumn<BlockingObjectInformation>(this); dlvBlockingObjects.SetTypeNameFilter<BlockingObjectInformation>(regexFilterControl); }
public InstanceInformation(ClrDump clrDump, ulong address) { ClrDump = clrDump; Address = address; ClrType = ClrDump.GetObjectType(Address); if (ClrType != null) { TypeName = ClrType.Name; } }
public static bool HasReferers(MessageBus msgBus, ClrDump clrDump, IEnumerable<ulong> addresses) { foreach(ulong address in addresses) { if (clrDump.HasReferers(address)) { return true; } } return false; }
public ReferersInformation(ClrDump clrDump, ClrType clrType, string fieldName, MessageBus messageBus, int parentCount) { ClrDump = clrDump; ClrType = clrType; FieldName = fieldName; MessageBus = messageBus; Instances = new HashSet <ulong>(); References = new HashSet <ulong>(); this.parentCount = parentCount; }
public void Setup(ClrDump clrDump) { ClrDump = clrDump; Icon = Properties.Resources.macro_show_all_actions_small; Name = $"#{clrDump.Id} - Delegate Types"; dlvDelegateTypes.InitColumns <DelegateTypeInformation>(); dlvDelegateTypes.SetUpTypeColumn <DelegateTypeInformation>(this); dlvDelegateTypes.SetTypeNameFilter <DelegateTypeInformation>(regexFilterControl); }
public void Setup(ClrDump clrDump) { ClrDump = clrDump; Icon = Properties.Resources.broom_small; Name = $"#{clrDump.Id} - Finalizer"; dlvFinalizer.InitColumns <FinalizerInformation>(); dlvFinalizer.SetUpTypeColumn <FinalizerInformation>(this); dlvFinalizer.RegisterDataProvider(() => ((UIDataProvider <AddressList>) this).Data, this, "Finalizer"); }
public void Setup(ClrDump clrDump) { ClrDump = clrDump; Icon = Properties.Resources._lock_small; Name = $"#{clrDump.Id} - BlockingObjects"; dlvBlockingObjects.InitColumns <BlockingObjectInformation>(); dlvBlockingObjects.SetUpAddressColumn <BlockingObjectInformation>(this); dlvBlockingObjects.SetUpTypeColumn <BlockingObjectInformation>(this); dlvBlockingObjects.SetTypeNameFilter <BlockingObjectInformation>(regexFilterControl); }
public void Setup(ClrDump clrDump) { ClrDump = clrDump; Icon = Properties.Resources.candlestickchart_small; Name = $"#{clrDump.Id} - ThreadPool"; dlvNativeWorkItem.InitColumns <NativeWorkItemInformation>(); dlvNativeWorkItem.SetUpAddressColumn(nameof(NativeWorkItemInformation.Data), this); dlvManagedWorkItem.InitColumns <ManagedWorkItemInformation>(); dlvManagedWorkItem.SetUpAddressColumn(nameof(ManagedWorkItemInformation.Object), this); dlvManagedWorkItem.SetUpTypeColumn <ManagedWorkItemInformation>(this); }
public static bool HasReferers(MessageBus msgBus, ClrDump clrDump, IEnumerable <ulong> addresses) { foreach (ulong address in addresses) { if (clrDump.HasReferers(address)) { return(true); } } return(false); }
public void Setup(ClrDump clrDump) { ClrDump = clrDump; Icon = Properties.Resources.candlestickchart_small; Name = $"#{clrDump.Id} - ThreadPool"; dlvNativeWorkItem.InitColumns<NativeWorkItemInformation>(); dlvNativeWorkItem.SetUpAddressColumn(nameof(NativeWorkItemInformation.Data), this); dlvManagedWorkItem.InitColumns<ManagedWorkItemInformation>(); dlvManagedWorkItem.SetUpAddressColumn(nameof(ManagedWorkItemInformation.Object), this); dlvManagedWorkItem.SetUpTypeColumn<ManagedWorkItemInformation>(this); }
public void Setup(ClrDump clrDump) { ClrDump = clrDump; Icon = Properties.Resources.broom_small; Name = $"#{clrDump.Id} - ClrRoots"; dlvClrRoots.InitColumns <ClrRootsInformation>(); dlvClrRoots.SetUpAddressColumn <ClrRootsInformation>(this); dlvClrRoots.SetUpAddressColumn(nameof(ClrRootsInformation.ObjectAddress), this); dlvClrRoots.SetUpTypeColumn <ClrRootsInformation>(this); }
public void SetUp(ClrDump clrDump) { ClrDump = clrDump; dlvBookmarks.InitColumns <Bookmark>(); dlvBookmarks.SetUpAddressColumn <Bookmark>(this); dlvBookmarks.SetUpTypeColumn <Bookmark>(this); var col = dlvBookmarks[nameof(Bookmark.Comment)]; col.CellEditUseWholeCell = true; dlvBookmarks.CellEditActivation = ObjectListView.CellEditActivateMode.DoubleClick; dlvBookmarks.CellEditFinished += (o, e) => { ClrDump.ClrDumpInfo.Save(); }; var colColor = dlvBookmarks[nameof(Bookmark.Color)]; dlvBookmarks.FormatCell += (o, e) => { if (e.Column != colColor) { return; } var rowObj = e.Model; var bookmark = rowObj as Bookmark; if (bookmark != null) { e.SubItem.BackColor = bookmark.Color; e.SubItem.Text = bookmark.Color != Color.Empty ? null : "Select Color..."; } }; var colPick = dlvBookmarks[nameof(Bookmark.ColorPick)]; colPick.IsButton = true; colPick.ButtonSizing = OLVColumn.ButtonSizingMode.CellBounds; dlvBookmarks.ButtonClick += (o, e) => { var rowObj = e.Model; var bookmark = rowObj as Bookmark; if (bookmark != null) { ColorDialog colDiag = new ColorDialog(); colDiag.Color = bookmark.Color; if (colDiag.ShowDialog() == DialogResult.OK) { bookmark.Color = colDiag.Color; ClrDump.ClrDumpInfo.Save(); } } }; dlvBookmarks.UseCellFormatEvents = true; LoadBookmarks(); }
public override void Init() { if (Thread == null) { StackInstances = null; } else { StackInstances = ClrDump.Eval(() => Thread.EnumerateStackObjects().GroupBy(clrRoot => clrRoot.Object).Select(clrRootGroup => new StackInstanceInformation(ClrDump, clrRootGroup.First())).ToList()); } dlvStack.Objects = StackInstances; }
public static long CountTargets(ClrDump clrDump, ClrType clrType) { long count = 0; var targetField = clrType.GetFieldByName(TargetFieldName); var invocCountField = clrType.GetFieldByName(InvocationCountFieldName); foreach (ulong address in clrDump.EnumerateInstances(clrType)) { count += CountTargets(address, clrType, targetField, invocCountField); } return(count); }
public void Setup(ClrDump clrDump) { ClrDump = clrDump; Icon = Properties.Resources.recommended_summart_table_small; Name = $"#{clrDump.Id} - Arrays"; dlvArrays.InitColumns <ArraysInformation>(); dlvArrays.SetUpTypeColumn <ArraysInformation>(); dlvArrays.RegisterDataProvider(() => Data, this); dlvArrays.CellClick += OnCellClick; dlvArrays.SetTypeNameFilter <ArraysInformation>(regexFilterControl); }
public void Setup(ClrDump clrDump) { ClrDump = clrDump; Icon = Properties.Resources.table_lightning_small; Name = $"#{ClrDump.Id} - Lone Targets"; dlvLoneHandlers.InitColumns <LoneTargetInformation>(); dlvLoneHandlers.SetUpAddressColumn <LoneTargetInformation>(this); dlvLoneHandlers.SetUpTypeColumn <LoneTargetInformation>(this); dlvLoneHandlers.SetUpAddressColumn(nameof(LoneTargetInformation.OwnerAddress), this, "Owner"); dlvLoneHandlers.SetUpTypeColumn(nameof(LoneTargetInformation.OwnerType), this, "Owner"); }
public override void Init() { Exceptions = new List <ClrExceptionInformation>(); ClrException exception = ClrDump.Eval(() => ClrThread.CurrentException); while (exception != null) { Exceptions.Add(new ClrExceptionInformation(ClrDump, exception)); exception = ClrDump.Eval(() => exception.Inner); } dlvExceptions.Objects = Exceptions; }
public ModuleInformation(ClrDump clrDump, ClrModule module) { this.module = module; DebuggingMode = module.DebuggingMode; Pdb = clrDump.Eval(() => { if (module.IsFile && module.Pdb != null) { return module.Pdb.FileName; } return null; }); }
public void Setup(ClrDump clrDump) { ClrDump = clrDump; Icon = Properties.Resources.table_lightning_small; Name = $"#{ClrDump.Id} - Lone Targets"; dlvLoneHandlers.InitColumns<LoneTargetInformation>(); dlvLoneHandlers.SetUpAddressColumn<LoneTargetInformation>(this); dlvLoneHandlers.SetUpTypeColumn<LoneTargetInformation>(this); dlvLoneHandlers.SetUpAddressColumn(nameof(LoneTargetInformation.OwnerAddress), this, "Owner"); dlvLoneHandlers.SetUpTypeColumn(nameof(LoneTargetInformation.OwnerType), this, "Owner"); }
public ModuleInformation(ClrDump clrDump, ClrModule module) { this.module = module; DebuggingMode = module.DebuggingMode; Pdb = clrDump.Eval(() => { if (module.IsFile && module.Pdb != null) { return(module.Pdb.FileName); } return(null); }); }
public override void Init() { Log("Computing type statistics...", WinFwk.UITools.Log.LogLevelType.Info); if (ClrDump.Runtime != null) { typeStats = ClrDump.GetTypeStats(); Summary = $"{typeStats.Count:###,###,###,##0} types"; } else { Summary = $"Error. Dump file not loaded !"; } Log("Type statistics computed.", WinFwk.UITools.Log.LogLevelType.Info); }
public void Setup(ClrDump clrDump, ClrThread thread, UIClrDumpModule parentModule = null) { ClrDump = clrDump; Thread = thread; Icon = Properties.Resources.formatting_dublicate_value_small; Name = $"#{clrDump.Id} - Stack - Id: {Thread?.ManagedThreadId}"; dlvStack.InitColumns <StackInstanceInformation>(); dlvStack.SetUpAddressColumn <StackInstanceInformation>(parentModule ?? this); dlvStack.SetUpTypeColumn <StackInstanceInformation>(parentModule ?? this); dlvStack.AddSimpleValueColumn(o => ((StackInstanceInformation)o).Address, ClrDump, o => ((StackInstanceInformation)o).Type); dlvStack.RebuildColumns(); dlvStack.SetTypeNameFilter <StackInstanceInformation>(regexFilterControl); }
// Thanks to Lee Culver and Jeff Cyr // for the code: // https://github.com/Microsoft/clrmd/issues/35 public static ClrMethod GetDelegateMethod(ulong methodPtr, ClrDump clrDump) { ulong magicPtr = methodPtr + 5; ulong magicValue1 = clrDump.ReadHeapPointer(magicPtr + 1); ulong magicValue2 = clrDump.ReadHeapPointer(magicPtr + 2); ulong mysticPtr = magicPtr + 8 * (magicValue2 & 0xFF) + 3; ulong mysticOffset = 8 * (magicValue1 & 0xFF); ulong mysticValue = clrDump.ReadRuntimePointer(mysticPtr); ulong methodDescriptorPtr = mysticValue + mysticOffset; return(clrDump.GetMethodByHandle(methodDescriptorPtr)); }
public static List <RootPathInformation> AnalyzeRootPath(MessageBus msgBus, ClrDumpObject clrDumpObject) { ClrDump clrDump = clrDumpObject.ClrDump; ulong address = clrDumpObject.Address; CancellationTokenSource token = new CancellationTokenSource(); msgBus.BeginTask("Analysing Root Path...", token); if (token.IsCancellationRequested) { msgBus.EndTask("Root Path analysis: cancelled."); return(null); } msgBus.Status("Analysing Root Path: collecting root instances..."); var roots = new HashSet <ulong>(clrDump.EnumerateClrRoots.Select(clrRoot => clrRoot.Object)); if (logger.IsDebugEnabled) { logger.Debug("Roots: " + Str(roots)); } List <ulong> bestPath = null; var currentPath = new List <ulong>(); bool result = FindShortestPath(address, currentPath, ref bestPath, clrDump.GetReferers, roots.Contains, new Dictionary <ulong, List <ulong> >()); if (!result) { currentPath = new List <ulong>(); FindShortestPath(address, currentPath, ref bestPath, clrDump.GetReferers, (addr) => !clrDump.HasReferers(addr), new Dictionary <ulong, List <ulong> >()); } List <RootPathInformation> path = new List <RootPathInformation>(); ulong prevAddress = address; if (bestPath != null) { foreach (var refAddress in bestPath) { var refClrDumpObject = new ClrDumpObject(clrDump, clrDump.GetObjectType(refAddress), refAddress); var fieldName = refAddress == address ? " - " : clrDump.GetFieldNameReference(prevAddress, refAddress); fieldName = TypeHelpers.RealName(fieldName); path.Add(new RootPathInformation(refClrDumpObject, fieldName)); prevAddress = refAddress; } msgBus.EndTask("Root Path found."); } else { msgBus.EndTask("Root Path NOT found."); } return(path); }
public void Setup(ClrDump clrDump, ClrThread thread, UIClrDumpModule parentModule=null) { ClrDump = clrDump; Thread = thread; Icon = Properties.Resources.formatting_dublicate_value_small; Name = $"#{clrDump.Id} - Stack - Id: {Thread?.ManagedThreadId}"; dlvStack.InitColumns<StackInstanceInformation>(); dlvStack.SetUpAddressColumn<StackInstanceInformation>(parentModule ?? this); dlvStack.SetUpTypeColumn<StackInstanceInformation>(parentModule ?? this); dlvStack.AddSimpleValueColumn(o => ((StackInstanceInformation)o).Address, ClrDump, o => ((StackInstanceInformation)o).Type); dlvStack.RebuildColumns(); dlvStack.SetTypeNameFilter<StackInstanceInformation>(regexFilterControl); }
public void Setup(ClrDump clrDump, IAddressContainer instances, UIClrDumpModule parentModule=null) { ClrDump = clrDump; Instances = instances; Icon = Properties.Resources.formatting_dublicate_value_small; Name = $"#{ClrDump.Id}"; dlvInstances.InitColumns<InstanceInformation>(); dlvInstances.SetUpAddressColumn<InstanceInformation>(parentModule ?? this); dlvInstances.SetUpTypeColumn<InstanceInformation>(parentModule ?? this); dlvInstances.AddSizeColumn(o => ((InstanceInformation)o).Address, ClrDump, o => ((InstanceInformation)o).ClrType); dlvInstances.AddSimpleValueColumn(o => ((InstanceInformation)o).Address, ClrDump, o => ((InstanceInformation)o).ClrType); dlvInstances.RebuildColumns(); dlvInstances.SetTypeNameFilter<InstanceInformation>(regexFilterControl); }
public BlockingObjectInformation(ClrDump clrDump, BlockingObject blockingObject) { ClrDump = clrDump; BlockingObject = blockingObject; OwnersId = blockingObject.HasSingleOwner && blockingObject.Owner != null ? new HashSet <int> { blockingObject.Owner.ManagedThreadId } : new HashSet <int>(blockingObject.Owners.Where(thread => thread != null).Select(thread => thread.ManagedThreadId)); WaitersId = blockingObject.Waiters != null ? new HashSet <int>(blockingObject.Waiters.Where(thread => thread != null).Select(thread => thread.ManagedThreadId)) : new HashSet <int>(); }
public StackFrameInformation(ClrDump clrDump, ClrStackFrame frame) { this.clrDump = clrDump; this.frame = frame; DisplayString = frame.DisplayString; Kind = frame.Kind; Method = frame.Method; #if LINE_AND_FILE if (frame.Kind != ClrStackFrameType.Runtime) { fileAndLineNumber = clrDump.Eval(() => frame.FileAndLineNumber()); } #endif }
public override void Init() { if (ClrDumpObject == null) { return; } mainFieldValues = FieldValueInformation.GetChildren(ClrDumpObject); SimpleValue = ClrDump.Eval(() => { return(SimpleValueHelper.IsSimpleValue(ClrDumpObject.ClrType) ? SimpleValueHelper.GetSimpleValue(ClrDumpObject.Address, ClrDumpObject.ClrType) : null); }); }
internal static List <DelegateTypeInformation> GetDelegateTypeInformations(ClrDump clrDump) { var types = GetDelegateTypes(clrDump); var typeInformations = new List <DelegateTypeInformation>(); foreach (var type in types) { var count = clrDump.CountInstances(type); var targets = CountTargets(clrDump, type); var delegateInformation = new DelegateTypeInformation(clrDump, type, count, targets); typeInformations.Add(delegateInformation); } return(typeInformations); }
public void Setup(ClrDump clrDump, IAddressContainer instances, UIClrDumpModule parentModule = null) { ClrDump = clrDump; Instances = instances; Icon = Properties.Resources.formatting_dublicate_value_small; Name = $"#{ClrDump.Id}"; dlvInstances.InitColumns <InstanceInformation>(); dlvInstances.SetUpAddressColumn <InstanceInformation>(parentModule ?? this); dlvInstances.SetUpTypeColumn <InstanceInformation>(parentModule ?? this); dlvInstances.AddSizeColumn(o => ((InstanceInformation)o).Address, ClrDump, o => ((InstanceInformation)o).ClrType); dlvInstances.AddSimpleValueColumn(o => ((InstanceInformation)o).Address, ClrDump, o => ((InstanceInformation)o).ClrType); dlvInstances.RebuildColumns(); dlvInstances.SetTypeNameFilter <InstanceInformation>(regexFilterControl); }
internal static List<ArraysInformation> Analyse(ClrDump clrDump, MessageBus msgBus) { CancellationTokenSource token = new CancellationTokenSource(); var arrays = new List<ArraysInformation>(); msgBus.BeginTask("Analyzing arrays...", token); int n = 0; clrDump.Run(() => { var arrayTypes = clrDump.AllTypes.Where(t => t.IsArray); int nbArrayType = arrayTypes.Count(); foreach (var type in arrayTypes) { string typeName = type.Name; msgBus.Status($"Analyzing array type: {typeName} ({n:###,###,###,##0}/{nbArrayType:###,###,###,##0})"); if ( token.IsCancellationRequested ) { return; } n++; ulong nbInstances = 0; ulong totalSize = 0; ulong totalLength = 0; ulong maxLength = 0; foreach (var address in clrDump.EnumerateInstances(type)) { nbInstances++; var length = (ulong)(type.GetArrayLength(address)); maxLength = Math.Max(maxLength, length); totalSize += type.GetSize(address); totalLength += length; if (nbInstances % 512 == 0) { msgBus.Status($"Analyzing array: #{nbInstances:###,###,###,##0} for type: {typeName}"); if (token.IsCancellationRequested) { return; } } } arrays.Add(new ArraysInformation(new ClrDumpType(clrDump, type), nbInstances, totalLength, maxLength, totalSize)); } }); msgBus.EndTask($"Arrays analyzed. Types: {n:###,###,###,##0}"); return arrays; }
public static void Create(ClrDump clrDump, IAddressContainer addresses, UIModule parent, Action<InstancesMixedModule> postInit, string name = null) { if (addresses == null) { MessageBox.Show("No instances selected !", "Error", MessageBoxButtons.OK); return; } UIModuleFactory.CreateModule<InstancesMixedModule>( mod => { mod.UIModuleParent = parent; mod.Setup(clrDump, addresses); if (name != null) { mod.Name = name; } }, mod => postInit(mod) ); }
internal static List<StringInformation> Analyse(ClrDump clrDump, MessageBus msgBus) { var stringType = clrDump.GetClrType(typeof(string).FullName); var stringInstances = clrDump.EnumerateInstances(stringType); int nbStrings = clrDump.CountInstances(stringType); Dictionary <string, List<ulong>> result = new Dictionary<string, List<ulong>>(); CancellationTokenSource token = new CancellationTokenSource(); msgBus.BeginTask("Analyzing strings...", token); int n = 0; clrDump.Run(() => { foreach (var address in stringInstances) { if( token.IsCancellationRequested) { return; } n++; var value = SimpleValueHelper.GetSimpleValue(address, stringType, false) as string; if (value == null) { continue; } List<ulong> addresses; if( ! result.TryGetValue(value, out addresses)) { addresses = new List<ulong>(); result[value] = addresses; } addresses.Add(address); if( n % 1024 == 0) { float pct = (float)n / nbStrings; msgBus.Status($"Analyzing strings: {pct:p2}, n= {n:###,###,###,##0} / {nbStrings:###,###,###,##0}"); } } }); msgBus.EndTask($"Strings analyzed. Instances: {n:###,###,###,##0}, unique values: {result.Count:###,###,###,##0}"); var strings = result.Select(kvp => new StringInformation(kvp.Key, kvp.Value)).ToList(); return strings; }
public DiffColumn(ClrDump clrDump, List<ClrTypeStats> stats, List<ClrTypeStats> prevStats) { ClrDump = clrDump; this.stats = stats; Text = "#" + clrDump.Id; TextAlign = System.Windows.Forms.HorizontalAlignment.Right; Width = 150; ToolTipText = Text + " / " + clrDump.DumpPath; dicoStats = BuildDicoStat(stats); if (prevStats != null) { AspectToStringFormat = "{0:+###,###,###,##0;-###,###,###,##0;0}"; dicoPrevStats = BuildDicoStat(prevStats); } else { AspectToStringFormat = "{0:###,###,###,##0}"; } AspectGetter = GetCountForType; }
public ThreadInformation(ClrDump clrDump, ClrThread thread) { ClrDump = clrDump; Thread = thread; clrDump.Run(() => { OSThreadId = thread.OSThreadId; ManagedThreadId = thread.ManagedThreadId; CurrentException = thread.CurrentException?.Type?.Name; GcMode = thread.GcMode; IsAborted = thread.IsAborted; IsAbortRequested = thread.IsAbortRequested; IsAlive = thread.IsAlive; IsBackground = thread.IsBackground; IsCoInitialized = thread.IsCoInitialized; IsDebuggerHelper = thread.IsDebuggerHelper; IsDebugSuspended = thread.IsDebugSuspended; IsFinalizer = thread.IsFinalizer; IsGC = thread.IsGC; IsGCSuspendPending = thread.IsGCSuspendPending; IsMTA = thread.IsMTA; IsShutdownHelper = thread.IsShutdownHelper; IsSTA = thread.IsSTA; IsSuspendingEE = thread.IsSuspendingEE; IsThreadpoolCompletionPort = thread.IsThreadpoolCompletionPort; IsThreadpoolGate = thread.IsThreadpoolGate; IsThreadpoolTimer = thread.IsThreadpoolTimer; IsThreadpoolWait = thread.IsThreadpoolWait; IsThreadpoolWorker = thread.IsThreadpoolWorker; IsUnstarted = thread.IsUnstarted; IsUserSuspended = thread.IsUserSuspended; LockCount = thread.LockCount; var gcThreads = clrDump.Runtime.EnumerateGCThreads().ToList(); IsGCThread = gcThreads.Any(gcThreadId => gcThreadId == OSThreadId); }); }
public BlockingObjectInformation(ClrDump clrDump, BlockingObject blockingObject) { ClrDump = clrDump; BlockingObject = blockingObject; if (blockingObject.HasSingleOwner && blockingObject.Owner != null) { OwnersId = new HashSet<int>(); OwnersId.Add(blockingObject.Owner.ManagedThreadId); } else { OwnersId = new HashSet<int>(blockingObject.Owners.Where(thread => thread != null).Select(thread => thread.ManagedThreadId)); } if (blockingObject.Waiters != null) { WaitersId = new HashSet<int>(blockingObject.Waiters.Where(thread => thread != null).Select(thread => thread.ManagedThreadId)); } else { WaitersId = new HashSet<int>(); } }
private static ClrMethod GetDelegateMethod(ClrDump clrDump, ClrObject handler, ClrObject target) { var targetType = target.Type; var methPtrObj = handler[MethodPtrFieldName]; var methPtrLong = (long)methPtrObj.SimpleValue; var methPtr = (ulong)methPtrLong; var methInfo = GetDelegateMethod(methPtr, clrDump); return methInfo; }
public static ulong FindOwner(ulong address, ClrDump clrDump, ClrType delegateType, ClrType arrayObjType, HashSet<ulong> visited) { if( visited.Contains(address)) { return 0; } var type = clrDump.GetObjectType(address); if (type == null) { return 0; } if( type != arrayObjType && (type.BaseType == null || type.BaseType != delegateType ) ) { return address; } visited.Add(address); var refs = clrDump.GetReferers(address); foreach(var newAddress in refs) { var owner = FindOwner(newAddress, clrDump, delegateType, arrayObjType, visited); if( owner != 0) { return owner; } } return 0; }
public static List<LoneTargetInformation> GetLoneTargetInformations(ClrDump clrDump) { CancellationTokenSource token = new CancellationTokenSource(); clrDump.MessageBus.BeginTask("Analyzing lone targets...", token); Dictionary<ClrObject, ClrObject> loneTargetAddresses = new Dictionary<ClrObject, ClrObject>(); // For each instance of every delegate types // let's find all the target objects // and select those with only referenced once var types = GetDelegateTypes(clrDump); foreach(var type in types) { clrDump.MessageBus.Status($"Analyzing delegate type: {type.Name}"); if (token.IsCancellationRequested) { break; } int n = 0; foreach (var address in clrDump.EnumerateInstances(type)) { if (n++ % 128 == 0) { clrDump.MessageBus.Status($"Analyzing delegate type: {type.Name}, instance #{n:###,###,###,##0}"); } var handlerObject = new ClrObject(address, type); foreach(var subHandlerObject in EnumerateHandlers(handlerObject)) { if (token.IsCancellationRequested) { break; } var target = subHandlerObject[TargetFieldName]; int count = clrDump.CountReferers(target.Address); if( count == 1) { loneTargetAddresses[target] = subHandlerObject; } } } } List<LoneTargetInformation> loneTargets = new List<LoneTargetInformation>(); // foreach lone target, in its reference tree, we try to find the first // object that is not a delegate type or an array of object (ie invocationList) var delegateType = clrDump.GetClrType(typeof(MulticastDelegate).FullName); var arrayObjType = clrDump.GetClrType(typeof(object[]).FullName); HashSet<ulong> visited = new HashSet<ulong>(); foreach (var kvp in loneTargetAddresses) { var loneTarget = kvp.Key; var handler = kvp.Value; var methInfo = GetDelegateMethod(clrDump, handler, loneTarget); visited.Clear(); ulong ownerAddress = FindOwner(handler.Address, clrDump, delegateType, arrayObjType, visited); ClrObject owner = new ClrObject(ownerAddress, clrDump.GetObjectType(ownerAddress)); var loneTargetInformation = new LoneTargetInformation(clrDump, loneTarget, methInfo, owner); loneTargets.Add(loneTargetInformation); } string status = token.IsCancellationRequested ? "cancelled" : "done"; clrDump.MessageBus.EndTask($"Analyzing lone targets: {status}. Found: {loneTargets.Count}"); return loneTargets; }