Example #1
0
        public void Callback(IntPtr token, ulong addr, ulong obj, int pinned, int interior)
        {
            string name = name = _runtime.ResolveSymbol(addr);

            if (name == null)
            {
                name = addr.ToString("X");
            }
            else
            {
                int index = name.IndexOf('!');
                if (index >= 0)
                {
                    name = name.Substring(index + 1);
                }

                name = string.Format("{0:X}: {1}", addr, name);
            }

            name = "static var " + name;
            var type = _heap.GetObjectType(obj);

            Roots.Add(new NativeStaticVar(_runtime, addr, obj, type, name, interior != 0, pinned != 0));
        }
Example #2
0
        private ClrType ConstructObjectType(ulong eeType)
        {
            IMethodTableData mtData = NativeRuntime.GetMethodTableData(eeType);

            if (mtData == null)
            {
                return(null);
            }

            ulong componentType = mtData.ElementTypeHandle;
            bool  isArray       = componentType != 0;

            // EEClass is the canonical method table.  I stuffed the pointer there instead of creating a new property.
            ulong canonType = isArray ? componentType : mtData.EEClass;

            if (!isArray && canonType != 0)
            {
                int index;
                if (!isArray && _indices.TryGetValue(canonType, out index))
                {
                    _indices[eeType] = index;  // Link the original eeType to its canonical GCHeapType.
                    return(_types[index]);
                }

                ulong tmp = eeType;
                eeType    = canonType;
                canonType = tmp;
            }

            string name = NativeRuntime.ResolveSymbol(eeType);

            if (string.IsNullOrEmpty(name))
            {
                name = NativeRuntime.ResolveSymbol(canonType);
                if (name == null)
                {
                    name = string.Format("unknown type {0:x}", eeType);
                }
            }


            int len = name.Length;

            if (name.EndsWith("::`vftable'"))
            {
                len -= 11;
            }

            int i = name.IndexOf('!') + 1;

            name = name.Substring(i, len - i);

            if (isArray)
            {
                name += "[]";
            }

            NativeModule module = FindContainingModule(eeType);

            if (module == null && canonType != 0)
            {
                module = FindContainingModule(canonType);
            }

            if (module == null)
            {
                module = _mrtModule;
            }

            NativeType type = new NativeType(this, _types.Count, module, name, eeType, mtData);

            _indices[eeType] = _types.Count;
            if (!isArray)
            {
                _indices[canonType] = _types.Count;
            }
            _types.Add(type);

            return(type);
        }