Exemplo n.º 1
0
        private void FilterNodes()
        {
            Cursor.Current = Cursors.WaitCursor;
            TreeNode foundNode = null;

            richTextBoxInfo.Clear();
            foreach (ClrTypeHelper c in globalSearchList)
            {
                if (c.ObjectInfo == null)
                {
                    c.ObjectInfo = ClrMdHelper.GetInfoOfObject(runtime, c.Ptr, null);
                }

                if (c.ObjectInfo.Contains(textBoxFilter.Text))
                {
                    if (foundNode == null)
                    {
                        foundNode = c.TreeNode;
                    }
                    c.TreeNode.BackColor = Color.LightGreen;
                    richTextBoxInfo.AppendText(c.ObjectInfo + System.Environment.NewLine);
                }
                else
                {
                    c.TreeNode.BackColor = Color.White;
                }
            }
            if (foundNode != null)
            {
                foundNode.EnsureVisible();
            }
            Cursor.Current = Cursors.Default;
        }
Exemplo n.º 2
0
        //https://github.com/Microsoft/dotnet-samples/tree/master/Microsoft.Diagnostics.Runtime/CLRMD
        private void objectOverviewToolStripMenuItem_Click(object sender, EventArgs e)
        {
            if (Process == null)
            {
                return;
            }

            saveFileDialogObjects.FileName = String.Format("clrmd_{0:yyyyMMdd_HHmmss}_FieldInfo", DateTime.Now);
            if (saveFileDialogObjects.ShowDialog() != DialogResult.OK)
            {
                return;
            }

            if (File.Exists(saveFileDialogObjects.FileName))
            {
                File.Delete(saveFileDialogObjects.FileName);
            }

            Cursor.Current = Cursors.WaitCursor;

            using (DataTarget dataTarget = DataTarget.AttachToProcess(Process.Id, dataTargetTimeOut, dataTargetAttachFlag))
            {
                ClrInfo    clrVersion = dataTarget.ClrVersions.First();
                ClrRuntime runtime    = clrVersion.CreateRuntime();
                if (runtime.Heap.CanWalkHeap)
                {
                    using (StreamWriter writer = new StreamWriter(saveFileDialogObjects.FileName, true, Encoding.UTF8))
                    {
                        foreach (DataGridViewRow row in dataGridViewMain.SelectedRows)
                        {
                            int           cnt = 0;
                            ManagedObject m   = row.DataBoundItem as ManagedObject;

                            writer.WriteLine("*********************** {0} ************************", m.ObjectName);
                            writer.WriteLine();

                            foreach (ulong ptr in runtime.Heap.EnumerateObjectAddresses())
                            {
                                ClrType type = runtime.Heap.GetObjectType(ptr);

                                if (type == null || type.Name != m.ObjectName)
                                {
                                    continue;
                                }

                                writer.WriteLine(ClrMdHelper.GetInfoOfObject(runtime, ptr, type));
                                writer.WriteLine();
                                cnt++;
                            }
                            writer.WriteLine("{0}x found in Heap {1}", cnt, m.ObjectName);
                            writer.WriteLine();
                            writer.WriteLine();
                        }
                    }
                }
            }
            Cursor.Current = Cursors.Default;
        }
Exemplo n.º 3
0
        private void treeViewObjects_AfterSelect(object sender, TreeViewEventArgs e)
        {
            ClrTypeHelper c = e.Node.Tag as ClrTypeHelper;

            if (c.ObjectInfo == null)
            {
                c.ObjectInfo = ClrMdHelper.GetInfoOfObject(runtime, c.Ptr, null);
            }

            richTextBoxInfo.Text = c.ObjectInfo;
        }