Beispiel #1
0
 public RhStackRootWalker(ClrHeap heap, ClrAppDomain domain, ClrThread thread)
 {
     m_heap = heap;
     m_domain = domain;
     m_thread = thread;
     Roots = new List<ClrRoot>();
 }
Beispiel #2
0
 public NativeStackRootWalker(ClrHeap heap, ClrAppDomain domain, ClrThread thread)
 {
     _heap = heap;
     _domain = domain;
     _thread = thread;
     Roots = new List<ClrRoot>();
 }
Beispiel #3
0
        public RhHandleRoot(Address addr, Address obj, Address dependentTarget, ClrType type, int hndType, ClrAppDomain domain, string name)
        {

            Init(addr, obj, dependentTarget, type, hndType, domain, name);
        }
Beispiel #4
0
 internal abstract ulong GetModuleAddress(ClrAppDomain domain);
Beispiel #5
0
 internal MemoryRegion(DesktopRuntimeBase clr, ulong addr, ulong size, ClrMemoryRegionType type, ClrAppDomain domain)
 {
     Address = addr;
     Size = size;
     _runtime = clr;
     Type = type;
     _domainModuleHeap = domain.Address;
 }
Beispiel #6
0
 public NativeStaticVar(NativeRuntime runtime, Address addr, Address obj, ClrType type, string name, bool pinned, bool interior)
 {
     Address = addr;
     Object = obj;
     _type = type;
     _name = name;
     _pinned = pinned;
     _interior = interior;
     _type = runtime.GetHeap().GetObjectType(obj);
     _appDomain = runtime.GetRhAppDomain();
 }
Beispiel #7
0
 public NativeHandleRoot(Address addr, Address obj, ClrType type, int hndType, ClrAppDomain domain, string name)
 {
     Init(addr, obj, 0, type, hndType, domain, name);
 }
Beispiel #8
0
        internal override ulong GetDomainModule(ClrAppDomain domain)
        {
            m_runtime.InitDomains();
            if (domain == null)
            {
                foreach (ulong addr in m_mapping.Values)
                    return addr;

                return 0;
            }

            ulong value;
            if (m_mapping.TryGetValue(domain, out value))
                return value;

            return 0;
        }
Beispiel #9
0
        public override object GetValue(ClrAppDomain appDomain, ClrThread thread)
        {
            if (!HasSimpleValue)
                return null;

            Address addr = GetAddress(appDomain, thread);
            if (addr == 0)
                return null;

            if (ElementType == ClrElementType.String)
            {
                object val = m_type.m_heap.GetValueAtAddress(ClrElementType.Object, addr);

                Debug.Assert(val == null || val is ulong);
                if (val == null || !(val is ulong))
                    return null;

                addr = (ulong)val;
            }

            return m_type.m_heap.GetValueAtAddress(ElementType, addr);
        }
Beispiel #10
0
        public override bool IsInitialized(ClrAppDomain appDomain)
        {
            if (m_containingType == null)
                return false;

            if (!m_containingType.Shared)
                return true;
            
            Address id = m_containingType.m_module.ModuleId;
            IDomainLocalModuleData data = m_containingType.m_heap.m_runtime.GetDomainLocalModule(appDomain.Address, id);
            if (data == null)
                return false;

            return IsInitialized(data);
        }
Beispiel #11
0
        public override object GetValue(ClrAppDomain appDomain)
        {
            if (!HasSimpleValue)
                return null;

            Address addr = GetAddress(appDomain);

            if (ElementType == ClrElementType.String)
            {
                object val = m_containingType.m_heap.GetValueAtAddress(ClrElementType.Object, addr);

                Debug.Assert(val == null || val is ulong);
                if (val == null || !(val is ulong))
                    return null;

                addr = (ulong)val;
            }

            // Structs are stored as objects.
            var elementType = ElementType;
            if (elementType == ClrElementType.Struct)
                elementType = ClrElementType.Object;

            if (elementType == ClrElementType.Object && addr == 0)
                return (ulong)0;

            return m_containingType.m_heap.GetValueAtAddress(elementType, addr);
        }
Beispiel #12
0
 public RhFinalizerRoot(Address obj, ClrType type, ClrAppDomain domain, string name)
 {
     Object = obj;
     m_name = name;
     m_type = type;
     m_appDomain = domain;
 }
Beispiel #13
0
 public NativeFinalizerRoot(Address obj, ClrType type, ClrAppDomain domain, string name)
 {
     Object = obj;
     _name = name;
     _type = type;
     _appDomain = domain;
 }
Beispiel #14
0
 public RhHandleRootWalker(RhRuntime runtime, bool dependentHandleSupport)
 {
     m_heap = runtime.GetHeap();
     m_domain = runtime.GetRhAppDomain();
     m_dependentSupport = dependentHandleSupport;
 }
Beispiel #15
0
 public RhStaticVar(RhRuntime runtime, Address addr, Address obj, ClrType type, string name, bool pinned, bool interior)
 {
     Address = addr;
     Object = obj;
     m_type = type;
     m_name = name;
     m_pinned = pinned;
     m_interior = interior;
     m_type = runtime.GetHeap().GetObjectType(obj);
     m_appDomain = runtime.GetRhAppDomain();
 }
Beispiel #16
0
 internal abstract Address GetDomainModule(ClrAppDomain appDomain);
Beispiel #17
0
 internal void AddMapping(ClrAppDomain domain, ulong domainModule)
 {
     DesktopAppDomain appDomain = (DesktopAppDomain)domain;
     m_mapping[domain] = domainModule;
 }
Beispiel #18
0
 public LocalVarRoot(ulong addr, ulong obj, ClrType type, ClrAppDomain domain, ClrThread thread, bool pinned, bool falsePos, bool interior)
 {
     Address = addr;
     Object = obj;
     _pinned = pinned;
     _falsePos = falsePos;
     _interior = interior;
     _domain = domain;
     _thread = thread;
     _type = type;
 }
Beispiel #19
0
 internal override Address GetDomainModule(ClrAppDomain appDomain)
 {
     return 0;
 }
Beispiel #20
0
        public override object GetValue(ClrAppDomain appDomain, bool convertStrings = true)
        {
            if (!HasSimpleValue)
                return null;

            Address addr = GetAddress(appDomain);

            if (ElementType == ClrElementType.String)
            {
                object val = _containingType.DesktopHeap.GetValueAtAddress(ClrElementType.Object, addr);

                Debug.Assert(val == null || val is ulong);
                if (val == null || !(val is ulong))
                    return convertStrings ? null : (object)(ulong)0;

                addr = (ulong)val;
                if (!convertStrings)
                    return addr;
            }

            // Structs are stored as objects.
            var elementType = ElementType;
            if (elementType == ClrElementType.Struct)
                elementType = ClrElementType.Object;

            if (elementType == ClrElementType.Object && addr == 0)
                return (ulong)0;

            return _containingType.DesktopHeap.GetValueAtAddress(elementType, addr);
        }
Beispiel #21
0
 public NativeStackRoot(ClrThread thread, ulong addr, ulong obj, string name, ClrType type, ClrAppDomain domain, bool pinned, bool interior)
 {
     Address = addr;
     Object = obj;
     _name = name;
     _type = type;
     _appDomain = domain;
     _pinned = pinned;
     _interior = interior;
     _thread = thread;
 }
Beispiel #22
0
        public override Address GetAddress(ClrAppDomain appDomain)
        {
            if (_containingType == null)
                return 0;

            bool shared = _containingType.Shared;

            IDomainLocalModuleData data = null;
            if (shared)
            {
                Address id = _containingType.DesktopModule.ModuleId;
                data = _containingType.DesktopHeap.DesktopRuntime.GetDomainLocalModule(appDomain.Address, id);
                if (!IsInitialized(data))
                    return 0;
            }
            else
            {
                Address modAddr = _containingType.GetModuleAddress(appDomain);
                if (modAddr != 0)
                    data = _containingType.DesktopHeap.DesktopRuntime.GetDomainLocalModule(modAddr);
            }

            if (data == null)
                return 0;

            Address addr;
            if (DesktopRuntimeBase.IsPrimitive(ElementType))
                addr = data.NonGCStaticDataStart + _field.Offset;
            else
                addr = data.GCStaticDataStart + _field.Offset;

            return addr;
        }
Beispiel #23
0
        private void Init(Address addr, Address obj, Address dependentTarget, ClrType type, int hndType, ClrAppDomain domain, string name)
        {
            HandleType htype = (HandleType)hndType;
            switch (htype)
            {
                case HandleType.AsyncPinned:
                    _kind = GCRootKind.AsyncPinning;
                    break;

                case HandleType.Pinned:
                    _kind = GCRootKind.Pinning;
                    break;

                case HandleType.WeakShort:
                case HandleType.WeakLong:
                    _kind = GCRootKind.Weak;
                    break;

                default:
                    _kind = GCRootKind.Strong;
                    break;
            }

            Address = addr;
            _name = name;
            _type = type;
            _appDomain = domain;

            if (htype == HandleType.Dependent && dependentTarget != 0)
                Object = dependentTarget;
            else
                Object = obj;
        }
Beispiel #24
0
        public override bool IsInitialized(ClrAppDomain appDomain)
        {
            if (_containingType == null)
                return false;

            if (!_containingType.Shared)
                return true;

            Address id = _containingType.DesktopModule.ModuleId;
            IDomainLocalModuleData data = _containingType.DesktopHeap.DesktopRuntime.GetDomainLocalModule(appDomain.Address, id);
            if (data == null)
                return false;

            return IsInitialized(data);
        }
Beispiel #25
0
 public NativeHandleRootWalker(NativeRuntime runtime, bool dependentHandleSupport)
 {
     _heap = runtime.GetHeap();
     _domain = runtime.GetRhAppDomain();
     _dependentSupport = dependentHandleSupport;
 }
Beispiel #26
0
        public override object GetValue(ClrAppDomain appDomain, ClrThread thread, bool convertStrings = true)
        {
            if (!HasSimpleValue)
                return null;

            Address addr = GetAddress(appDomain, thread);
            if (addr == 0)
                return null;

            if (ElementType == ClrElementType.String)
            {
                object val = _type.DesktopHeap.GetValueAtAddress(ClrElementType.Object, addr);

                Debug.Assert(val == null || val is ulong);
                if (val == null || !(val is ulong))
                    return convertStrings ? null : (object)(ulong)0;

                addr = (ulong)val;
                if (!convertStrings)
                    return addr;
            }

            return _type.DesktopHeap.GetValueAtAddress(ElementType, addr);
        }
Beispiel #27
0
 internal override Address GetModuleAddress(ClrAppDomain appDomain)
 {
     if (DesktopModule == null)
         return 0;
     return DesktopModule.GetDomainModule(appDomain);
 }
Beispiel #28
0
        public override Address GetAddress(ClrAppDomain appDomain, ClrThread thread)
        {
            if (_type == null)
                return 0;

            DesktopRuntimeBase runtime = _type.DesktopHeap.DesktopRuntime;
            IModuleData moduleData = runtime.GetModuleData(_field.Module);

            return runtime.GetThreadStaticPointer(thread.Address, (ClrElementType)_field.CorElementType, (uint)Offset, (uint)moduleData.ModuleId, _type.Shared);
        }
Beispiel #29
0
 internal override Address GetModuleAddress(ClrAppDomain domain)
 {
     return 0;
 }
Beispiel #30
0
        internal ulong GetMTForDomain(ClrAppDomain domain, DesktopHeapType type)
        {
            DesktopGCHeap heap = null;
            var mtList = _runtime.GetMethodTableList(_mapping[domain]);

            bool hasToken = type.MetadataToken != 0 && type.MetadataToken != uint.MaxValue;

            uint token = ~0xff000000 & type.MetadataToken;

            foreach (MethodTableTokenPair pair in mtList)
            {
                if (hasToken)
                {
                    if (pair.Token == token)
                        return pair.MethodTable;
                }
                else
                {
                    if (heap == null)
                        heap = (DesktopGCHeap)_runtime.GetHeap();

                    if (heap.GetTypeByMethodTable(pair.MethodTable, 0) == type)
                        return pair.MethodTable;
                }
            }

            return 0;
        }