Example #1
0
        /// <summary>
        /// Gets an enumerator for all objects that are to be garbage-collected
        /// in a process.
        /// </summary>
        /// <param name="enumerateWeakReferences">
        /// A <c>Boolean</c> value that indicates whether weak references are also
        /// to be enumerated. If <c>enumerateWeakReferences</c> is <c>true</c>, the
        /// <c>ppEnum</c> enumerator includes both strong references and weak references.
        /// If <c>enumerateWeakReferences</c> is <c>false</c>, the enumerator includes
        /// only strong references.
        /// </param>
        /// <param name="ppEnum">
        /// A pointer to the address of an <c>ICorDebugGCReferenceEnum</c> that is an
        /// enumerator for the objects to be garbage-collected.
        /// </param>
        /// <remarks>
        /// This method provides a way to determine the full rooting chain
        /// for any managed object in a process and can be used to determine
        /// why an object is still alive.
        /// </remarks>
        public int EnumerateGCReferences(bool enumerateWeakReferences, out CorDebugStructEnum <COR_GC_REFERENCE> ppEnum)
        {
            void **pppEnum = default;
            int    hResult = Calli(_this, This[0]->EnumerateGCReferences, enumerateWeakReferences.ToNativeInt(), &pppEnum);

            ppEnum = ComFactory.Create <CorDebugStructEnum <COR_GC_REFERENCE> >(pppEnum, hResult);
            return(hResult);
        }
Example #2
0
        /// <summary>
        /// Gets an enumerator for the memory ranges of the managed heap.
        /// </summary>
        /// <param name="ppRegions">
        /// A pointer to the address of an <c>ICorDebugHeapSegmentEnum</c>
        /// interface object that is an enumerator for the ranges of memory
        /// in which objects reside in the managed heap.
        /// </param>
        /// <remarks>
        /// Before calling the <c>ICorDebugProcess5::EnumerateHeapRegions</c>
        /// method, you should call the <c>ICorDebugProcess5::GetGCHeapInformation</c>
        /// method and examine the value of the <c>areGCStructuresValid</c>
        /// field of the returned <c>COR_HEAPINFO</c> object to ensure that
        /// the garbage collection heap in its current state is enumerable.
        /// In addition, the <c>ICorDebugProcess5::EnumerateHeapRegions</c>
        /// method returns <c>E_FAIL</c> if you attach too early in the lifetime
        /// of the process, before memory regions are created.
        ///
        /// This method is guaranteed to enumerate all memory regions that may
        /// contain managed objects, but it does not guarantee that managed objects
        /// actually reside in those regions. The <c>ICorDebugHeapSegmentEnum</c>
        /// collection object may include empty or reserved memory regions.
        ///
        /// The <c>ICorDebugHeapSegmentEnum</c> interface object is a standard
        /// enumerator derived from the <c>ICorDebugEnum</c> interface that allows
        /// you to enumerate <c>COR_SEGMENT</c> objects. Each <c>COR_SEGMENT</c>
        /// object provides information about the memory range of a particular
        /// segment, along with the generation of the objects in that segment.
        /// </remarks>
        public int EnumerateHeapRegions(out CorDebugStructEnum <COR_SEGMENT> ppRegions)
        {
            void **ptr     = default;
            int    hResult = Calli(_this, This[0]->EnumerateHeapRegions, &ptr);

            ppRegions = ComFactory.Create <CorDebugStructEnum <COR_SEGMENT> >(ptr, hResult);
            return(hResult);
        }
Example #3
0
        /// <summary>
        /// Gets an enumerator for the objects on the managed heap.
        /// </summary>
        /// <param name="ppObject">
        /// A pointer to the address of an <c>ICorDebugHeapEnum</c> interface object
        /// that is an enumerator for the objects that reside on the managed heap.
        /// </param>
        /// <remarks>
        /// Before calling the <c>ICorDebugProcess5::EnumerateHeap</c> method,
        /// you should call the <c>ICorDebugProcess5::GetGCHeapInformation</c> method and
        /// examine the value of the <c>areGCStructuresValid</c> field of the returned
        /// <c>COR_HEAPINFO</c> object to ensure that the garbage collection heap in its
        /// current state is enumerable. In addition, the <c>ICorDebugProcess5::EnumerateHeap</c>
        /// returns <c>E_FAIL</c> if you attach too early in the lifetime of the process,
        /// before memory for the managed heap is allocated.
        ///
        /// The <c>ICorDebugHeapEnum</c> interface object is a standard enumerator
        /// derived from the <c>ICorDebugEnum</c> interface that allows you to enumerate
        /// <c>COR_HEAPOBJECT</c> objects. This method populates the <c>ICorDebugHeapEnum</c>
        /// collection object with <c>COR_HEAPOBJECT</c> instances that provide information
        /// about all objects. The collection may also include <c>COR_HEAPOBJECT</c> instances
        /// that provide information about objects that are not rooted by any object but
        /// have not yet been collected by the garbage collector.
        /// </remarks>
        public int EnumerateHeap(out CorDebugStructEnum <COR_HEAPOBJECT> ppObjects)
        {
            void **pointer = default;
            int    hResult = Calli(_this, This[0]->EnumerateHeap, &pointer);

            ppObjects = ComFactory.Create <CorDebugStructEnum <COR_HEAPOBJECT> >(pointer, hResult);
            return(hResult);
        }
Example #4
0
        /// <summary>
        /// Gets an enumerator for object handles in a process.
        /// </summary>
        /// <param name="types">
        /// A bitwise combination of <c>CorGCReferenceType</c> values that
        /// specifies the type of handles to include in the collection.
        /// </param>
        /// <param name="ppENum">
        /// A pointer to the address of an <c>ICorDebugGCReferenceEnum</c> that
        /// is an enumerator for the objects to be garbage-collected.
        /// </param>
        /// <remarks>
        /// <c>EnumerateHandles</c> is a helper function that supports inspection
        /// of the handle table. It is similar to the <c>ICorDebugProcess5::EnumerateGCReferences</c>
        /// method, except that rather than populating an <c>ICorDebugGCReferenceEnum</c>
        /// collection with all objects to be garbage-collected, it includes only
        /// objects that have handles from the handle table.
        ///
        /// The <c>types</c> parameter specifies the handle types to include
        /// in the collection. <c>types</c> can be any of the following three
        /// members of the <c>CorGCReferenceType</c> enumeration:
        ///
        /// - <c>CorHandleStrongOnly</c> (handles to strong references only).
        /// - <c>CorHandleWeakOnly</c> (handles to weak references only).
        /// - <c>CorHandleAll</c> (all handles).
        /// </remarks>
        public int EnumerateHandles(CorGCReferenceType types, out CorDebugStructEnum <COR_GC_REFERENCE> ppEnum)
        {
            void **pointer = default;
            int    hResult = Calli(_this, This[0]->EnumerateHandles, (uint)types, &pointer);

            ppEnum = ComFactory.Create <CorDebugStructEnum <COR_GC_REFERENCE> >(pointer, hResult);
            return(hResult);
        }
            internal Enumerator(CorDebugStructEnum <T> parent)
            {
                int hResult = parent.Clone(out _parent);

                _ownsParent = hResult != HResult.E_NOTIMPL;

                if (_ownsParent)
                {
                    hResult.MaybeThrowHr();
                }
                else
                {
                    _parent = parent;
                }

                _obj = default;
            }
Example #6
0
 /// <summary>
 /// Gets an enumerator for all cached Windows Runtime types.
 /// </summary>
 /// <param name="guidToTypeEnum">
 /// A pointer to an <c>ICorDebugGuidToTypeEnum</c> interface object that
 /// can enumerate the managed representations of Windows Runtime types
 /// currently loaded in the application domain.
 /// </param>
 public int GetCachedWinRTTypes(out CorDebugStructEnum <CorDebugGuidToTypeMapping> guidToTypeEnum)
 => InvokeGetObject(_this, This[0]->GetCachedWinRTTypes, out guidToTypeEnum);