Exemplo n.º 1
0
        public void EnumerateGCRefs()
        {
            using DataTarget dataTarget = TestTargets.GCRoot.LoadFullDump();
            ClrRuntime runtime = dataTarget.ClrVersions.Single().CreateRuntime();
            ClrHeap    heap    = runtime.Heap;

            ulong   obj  = heap.GetObjectsOfType("DoubleRef").Single();
            ClrType type = heap.GetObjectType(obj);

            ClrObject[] refs = type.EnumerateObjectReferences(obj).ToArray();
            ValidateRefs(refs);
        }
Exemplo n.º 2
0
        private void treeViewObjects_BeforeExpand(object sender, TreeViewCancelEventArgs e)
        {
            if (e.Node.Nodes.Count == 1 && e.Node.Nodes[0].Tag == null)
            {
                e.Node.Nodes.Clear();
                ClrTypeHelper c = (ClrTypeHelper)e.Node.Tag;

                ClrType type = runtime.Heap.GetObjectType(c.Ptr);
                foreach (ClrObject o in type.EnumerateObjectReferences(c.Ptr))
                {
                    if (o.Type.Name == "System.String")
                    {
                        continue;
                    }

                    ClrType refType = runtime.Heap.GetObjectType(o.Address);

                    TreeNode refNode = new TreeNode(refType.Name);
                    refNode.Nodes.Add(new TreeNode());
                    ClrTypeHelper refHelper = new ClrTypeHelper()
                    {
                        Ptr      = o.Address,
                        Name     = refType.Name,
                        Size     = type.GetSize(o.Address),
                        TreeNode = refNode
                    };

                    System.Diagnostics.Debug.WriteLine("{0:X} {1}", o.Address, refType.Name);
                    refNode.Tag = refHelper;
                    e.Node.Nodes.Add(refNode);
                    globalSearchList.Add(refHelper);
                }

                foreach (ClrInstanceField f in type.Fields)
                {
                    System.Diagnostics.Debug.WriteLine("{0:X} {1}", f.GetAddress(c.Ptr), f.Type);
                }
            }
        }
Exemplo n.º 3
0
 /// <summary>
 ///     Enumerates all objects that the given object references.
 /// </summary>
 /// <param name="obj">The object in question.</param>
 /// <param name="carefully">
 ///     Whether to bounds check along the way (useful in cases where
 ///     the heap may be in an inconsistent state.)
 /// </param>
 /// <returns>IEnumerable&lt;IClrObject&gt;.</returns>
 public IEnumerable <IClrObject> EnumerateObjectReferences(ulong obj, bool carefully = false) =>
 ClrType.EnumerateObjectReferences(obj, carefully).Select(Converter.Convert);