Ejemplo n.º 1
0
        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);
        }
Ejemplo n.º 2
0
        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);
        }
Ejemplo n.º 3
0
        public static void SetUpTypeColumn(this ObjectListView listView, OLVColumn col, UIClrDumpModule dumpModule = null, string suffix = null)
        {
            listView.FormatCell += (sender, e) =>
            {
                if (e.Column == col)
                {
                    string val = e.SubItem.ModelValue as string;
                    if (val != null)
                    {
                        var colors = TypeHelpers.GetAliasColor(val);
                        if (colors.Item1 != Color.Transparent)
                        {
                            e.SubItem.BackColor = colors.Item1;
                        }
                        if (colors.Item2 != Color.Transparent)
                        {
                            e.SubItem.ForeColor = colors.Item2;
                        }
                    }
                }
            };
            col.AspectToStringConverter = o => TypeHelpers.ManageAlias((string)o);
            col.Width = 600;
            if (dumpModule != null)
            {
                listView.RegisterDataProvider(() =>
                {
                    var cellItem = listView.SelectedItem.SubItems[col.Index];
                    var subItem  = cellItem as OLVListSubItem;
                    if (subItem == null)
                    {
                        return(null);
                    }
                    string typeName = subItem.ModelValue as string;
                    ClrType type    = dumpModule.ClrDump.GetClrType(typeName);
                    if (type != null)
                    {
                        return(new TypeInstancesAddressList(dumpModule.ClrDump, type));
                    }
                    return(null);
                }, dumpModule, suffix != null ? "All" : "All - " + suffix);
                listView.RegisterDataProvider(() =>
                {
                    var cellItem = listView.SelectedItem.SubItems[col.Index];
                    var subItem  = cellItem as OLVListSubItem;
                    if (subItem == null)
                    {
                        return(null);
                    }
                    string typeName = subItem.ModelValue as string;

                    ClrType type = dumpModule.ClrDump.GetClrType(typeName);
                    if (type != null)
                    {
                        return(new ClrDumpType(dumpModule.ClrDump, type));
                    }
                    return(null);
                }, dumpModule, suffix);
                listView.AddMenuSeparator();
            }
            listView.UseCellFormatEvents = true;
        }
Ejemplo n.º 4
0
        public static void AddAddressColumn(this ObjectListView listView, AspectGetterDelegate addressGetter, UIClrDumpModule dumpModule)
        {
            var col = new OLVColumn("Address", null)
            {
                AspectGetter = addressGetter
            };

            SetUpAddressColumn(listView, col, dumpModule);
            listView.AllColumns.Add(col);
        }
Ejemplo n.º 5
0
        public static void SetUpTypeColumn(this ObjectListView listView, string colType, UIClrDumpModule dumpModule = null, string suffix = null)
        {
            OLVColumn col = listView.AllColumns.First(c => c.Name == colType);

            SetUpTypeColumn(listView, col, dumpModule, suffix);
        }
Ejemplo n.º 6
0
 public static void SetUpTypeColumn <T>(this ObjectListView listView, UIClrDumpModule dumpModule = null) where T : ITypeNameData
 {
     SetUpTypeColumn(listView, nameof(ITypeNameData.TypeName), dumpModule);
 }
Ejemplo n.º 7
0
        public static void SetUpAddressColumn(this ObjectListView listView, OLVColumn col, UIClrDumpModule dumpModule, string suffix = null)
        {
            col.AspectToStringFormat = "{0:X}";
            col.TextAlign            = HorizontalAlignment.Right;
            col.Width = 150;

            listView.CellClick += (o, e) =>
            {
                if (e.ClickCount == 2 && e.Column == col)
                {
                    if (e.Model == null)
                    {
                        return;
                    }
                    var cellItem = listView.SelectedItem?.GetSubItem(col.Index);
                    if (cellItem == null)
                    {
                        return;
                    }
                    var addressObj = cellItem.ModelValue;
                    if (addressObj is ulong)
                    {
                        var address = (ulong)addressObj;
                        if (address == 0)
                        {
                            return;
                        }
                        var type = dumpModule.ClrDump.GetObjectType(address);
                        if (type == null)
                        {
                            dumpModule.Log($"Can't find type for instance: {address:X}", LogLevelType.Error);
                            return;
                        }
                        var clrDumpObject = new ClrDumpObject(dumpModule.ClrDump, type, address);
                        InstanceDetailsCommand.Display(dumpModule, clrDumpObject);
                    }
                }
            };
            listView.RegisterDataProvider(() =>
            {
                var cellItem = listView.SelectedItem?.GetSubItem(col.Index);
                if (cellItem == null)
                {
                    return(null);
                }
                var addressObj = cellItem.ModelValue;
                if (addressObj is ulong)
                {
                    var address       = (ulong)addressObj;
                    var type          = dumpModule.ClrDump.GetObjectType(address);
                    var clrDumpObject = new ClrDumpObject(dumpModule.ClrDump, type, address);
                    return(clrDumpObject);
                }
                return(null);
            }, dumpModule, suffix
                                          );
            listView.FormatCell += (o, e) =>
            {
                if (e.Column != col || e.SubItem.ModelValue == null)
                {
                    return;
                }
                var addressObj = e.SubItem.ModelValue;
                if (addressObj is ulong)
                {
                    var address  = (ulong)addressObj;
                    var bookmark = dumpModule.ClrDump.ClrDumpInfo.GetBookmark(address);
                    if (bookmark != null)
                    {
                        e.SubItem.BackColor = bookmark.Color;
                    }
                }
            };
            var tooltipGetter = listView.CellToolTipGetter;

            listView.CellToolTipGetter = (column, modelObject) =>
            {
                if (column == col)
                {
                    if (modelObject == null || !(modelObject is ulong))
                    {
                        return(null);
                    }
                    if (modelObject is ulong)
                    {
                        var address  = (ulong)modelObject;
                        var bookmark = dumpModule.ClrDump.ClrDumpInfo.GetBookmark(address);
                        if (bookmark != null)
                        {
                            return(bookmark.Comment);
                        }
                    }
                }
                if (tooltipGetter != null)
                {
                    return(tooltipGetter(column, modelObject));
                }
                return(null);
            };
            listView.UseCellFormatEvents = true;
            listView.AddMenuSeparator();
            listView.SelectedIndexChanged += (sender, evt) =>
            {
                var cellItem = listView.SelectedItem?.GetSubItem(col.Index);
                if (cellItem == null)
                {
                    return;
                }
                var addressObj = cellItem.ModelValue;
                if (addressObj is ulong)
                {
                    var address       = (ulong)addressObj;
                    var type          = dumpModule.ClrDump.GetObjectType(address);
                    var clrDumpObject = new ClrDumpObject(dumpModule.ClrDump, type, address);
                    dumpModule.MessageBus.SendMessage(new SelectedClrDumpObjectMessage(clrDumpObject));
                }
            };
            var menuItem = new ToolStripMenuItem("Copy Address");

            //            menuItem.Image = command.Icon;
            listView.ContextMenuStrip.Items.Add(menuItem);
            menuItem.Click += (o, e) =>
            {
                var cellItem = listView.SelectedItem?.GetSubItem(col.Index);
                if (cellItem == null)
                {
                    return;
                }
                var addressObj = cellItem.ModelValue;
                if (addressObj is ulong)
                {
                    var address = (ulong)addressObj;
                    Clipboard.SetText(address.ToString("X"));
                }
            };
        }
Ejemplo n.º 8
0
        public static void SetUpAddressColumn(this ObjectListView listView, string colName, UIClrDumpModule dumpModule, string suffix = null)
        {
            var col = listView.AllColumns.First(c => c.Name == colName);

            SetUpAddressColumn(listView, col, dumpModule, suffix);
        }
Ejemplo n.º 9
0
 public static void SetUpAddressColumn <T>(this ObjectListView listView, UIClrDumpModule dumpModule, string suffix = null) where T : IAddressData
 {
     SetUpAddressColumn(listView, nameof(IAddressData.Address), dumpModule, suffix);
 }