public int AddHandle(ulong addr, ulong obj, int hndType, uint refCnt, uint dependentTarget, ulong appDomain) { // If we fail to get the MT of this object, just skip it and keep going if (!GetMethodTables(obj, out ulong mt, out ulong cmt)) { return(_max-- > 0 ? 1 : 0); } ClrHandle handle = new ClrHandle() { Address = addr, Object = obj, Type = _heap.GetObjectType(obj), HandleType = (HandleType)hndType, RefCount = refCnt, AppDomain = _runtime.GetAppDomainByAddress(appDomain), DependentTarget = dependentTarget }; if (dependentTarget != 0) { handle.DependentType = _heap.GetObjectType(dependentTarget); } Handles.Add(handle); handle = handle.GetInteriorHandle(); if (handle != null) { Handles.Add(handle); } // Stop if we have too many handles (likely infinite loop in dac due to // inconsistent data). return(_max-- > 0 ? 1 : 0); }
private IEnumerable <ClrHandle> EnumerateHandleWorker() { Debug.Assert(_handles == null); List <ClrHandle> result = new List <ClrHandle>(); using (SOSHandleEnum handleEnum = _sos.EnumerateHandles()) { HandleData[] handles = new HandleData[8]; int fetched = 0; while ((fetched = handleEnum.ReadHandles(handles)) != 0) { for (int i = 0; i < fetched; i++) { ClrHandle handle = new ClrHandle(this, Heap, handles[i]); result.Add(handle); yield return(handle); handle = handle.GetInteriorHandle(); if (handle != null) { result.Add(handle); yield return(handle); } } } } _handles = result; }
public override IEnumerable<ClrHandle> EnumerateHandles() { object tmp; if (_sos.GetHandleEnum(out tmp) < 0) return null; ISOSHandleEnum handleEnum = tmp as ISOSHandleEnum; if (handleEnum == null) return null; HandleData[] handles = new HandleData[1]; List<ClrHandle> res = new List<ClrHandle>(); uint fetched = 0; do { if (handleEnum.Next(1, handles, out fetched) != 0) break; ClrHandle handle = new ClrHandle(this, GetHeap(), handles[0]); res.Add(handle); handle = handle.GetInteriorHandle(); if (handle != null) res.Add(handle); } while (fetched == 1); return res; }
public int AddHandle(ulong addr, ulong obj, int hndType, uint refCnt, uint dependentTarget, ulong appDomain) { ulong mt; ulong cmt; // If we fail to get the MT of this object, just skip it and keep going if (!GetMethodTables(obj, out mt, out cmt)) return _max-- > 0 ? 1 : 0; ClrHandle handle = new ClrHandle(); handle.Address = addr; handle.Object = obj; handle.Type = _heap.GetObjectType(obj); handle.HandleType = (HandleType)hndType; handle.RefCount = refCnt; handle.AppDomain = _runtime.GetAppDomainByAddress(appDomain); handle.DependentTarget = dependentTarget; if (dependentTarget != 0) handle.DependentType = _heap.GetObjectType(dependentTarget); Handles.Add(handle); handle = handle.GetInteriorHandle(); if (handle != null) Handles.Add(handle); // Stop if we have too many handles (likely infinite loop in dac due to // inconsistent data). return _max-- > 0 ? 1 : 0; }
/// <summary> /// Initializes a new instance of the <see cref="HandleAdapter" /> class. /// </summary> /// <param name="handle">The handle.</param> /// <exception cref="ArgumentNullException">handle</exception> /// <inheritdoc /> public HandleAdapter(IConverter converter, ClrHandle handle) : base(converter) { Handle = handle ?? throw new ArgumentNullException(nameof(handle)); Address = Handle.Address; DependentTarget = Handle.DependentTarget; IsPinned = Handle.IsPinned; IsStrong = Handle.IsStrong; Object = Handle.Object; RefCount = Handle.RefCount; }
private IEnumerable<ClrHandle> EnumerateHandleWorker() { // handles was fully populated already if (_handles != null && _handleEnum == null) yield break; // Create _handleEnum if it's not already created. object tmp; if (_handleEnum == null) { if (_sos.GetHandleEnum(out tmp) < 0) yield break; _handleEnum = tmp as ISOSHandleEnum; if (_handleEnum == null) yield break; _handles = new List<ClrHandle>(); } // We already partially enumerated handles before, start with them. foreach (var handle in _handles) yield return handle; HandleData[] handles = new HandleData[8]; uint fetched = 0; do { if (_handleEnum.Next((uint)handles.Length, handles, out fetched) < 0 || fetched <= 0) break; int curr = _handles.Count; for (int i = 0; i < fetched; i++) { ClrHandle handle = new ClrHandle(this, GetHeap(), handles[i]); _handles.Add(handle); handle = handle.GetInteriorHandle(); if (handle != null) { _handles.Add(handle); yield return handle; } } for (int i = curr; i < _handles.Count; i++) yield return _handles[i]; } while (fetched > 0); _handleEnum = null; }
public HandleInformation(ClrDump clrDump, ClrHandle clrHandle) => this.clrHandle = clrHandle;
public int AddHandle(ulong addr, ulong obj, int hndType, uint refCnt, uint dependentTarget, ulong appDomain) { ulong mt; ulong cmt; // If we fail to get the MT of this object, just skip it and keep going if (!GetMethodTables(obj, out mt, out cmt)) return m_max-- > 0 ? 1 : 0; ClrHandle handle = new ClrHandle(); handle.Address = addr; handle.Object = obj; handle.Type = m_heap.GetObjectType(obj); handle.HandleType = (HandleType)hndType; handle.RefCount = refCnt; handle.AppDomain = m_runtime.GetAppDomainByAddress(appDomain); handle.DependentTarget = dependentTarget; if (dependentTarget != 0) handle.DependentType = m_heap.GetObjectType(dependentTarget); Handles.Add(handle); handle = handle.GetInteriorHandle(); if (handle != null) Handles.Add(handle); // Stop if we have too many handles (likely infinite loop in dac due to // inconsistent data). return m_max-- > 0 ? 1 : 0; }
public MDHandle(ClrHandle handle) { m_handle = handle; }