Пример #1
0
        void lookForSomething_Demo()
        {
            //获取 【类名】 中含有 "LoginActivity" 的 【实例对象】
            var objectInstance = ObjectInstanceInfos.Where(c => c.ClassName.Contains("LoginActivity")).First();

            //获取 【实例对象】 中含有 名为"className" 的 【属性】
            var objectProperty = objectInstance.InstanceFields.Where(c => c.Name == "className").FirstOrDefault();

            //该属性是字符串,内存放一个指针,获取该指针指向的 【实例对象】
            var StringObject = (ObjectInstanceInfo)(objectProperty as ReferenceObjectInfo).ReferenceTarget;

            //该【实例对象】是一个String类型对象,只存放了一个指针并指向char型数组,获取该【数组实例】
            var StringRef = (StringObject.InstanceFields[0] as ReferenceObjectInfo).ReferenceTarget;

            //获取该【char数组】存储的字符串值
            var StringData = (StringRef as PrimitiveArrayInfo).StringData;
        }
Пример #2
0
        void initObjectInfo()
        {
            PrimitiveArrayInfos = DumpPrimitiveArrays.Select(c => new PrimitiveArrayInfo(c)).ToList();
            ObjectArrayInfos    = DumpObjectArrays.Select(c => new ObjectArrayInfo(c, this)).ToList();

            ObjectInstanceInfos = DumpObjectInstances
                                  .Select(c => new ObjectInstanceInfo(c, this)).ToList();
            ObjectInstanceWithDataInfos = ObjectInstanceInfos.Where(c => c.InstanceFields != null && c.InstanceFields.Count > 0).ToList();

            ObjectInfoDictionary = ObjectInstanceInfos.ToDictionary(k => k.ObjectID, v => (object)v);
            foreach (var it in PrimitiveArrayInfos)
            {
                ObjectInfoDictionary.Add(it.PrimitiveArrayID, (object)it);
            }
            foreach (var it in ObjectArrayInfos)
            {
                ObjectInfoDictionary.Add(it.ObjectArrayID, (object)it);
            }

            Parallel.ForEach(ObjectInstanceWithDataInfos, item =>
            {
                foreach (var it in item.InstanceFields)
                {
                    if (it.Type == PrimitiveType.HPROF_BASIC_OBJECT)
                    {
                        if (ObjectInfoDictionary.ContainsKey((int)it.Value))
                        {
                            (it as ReferenceObjectInfo).ReferenceTarget = ObjectInfoDictionary[(int)it.Value];
                        }
                    }
                }
            });
            Parallel.ForEach(ObjectArrayInfos, item =>
            {
                item.Elements = item.ElementIDs.Select(c => ObjectInfoDictionary.ContainsKey(c)
                ? ObjectInfoDictionary[c] : null).ToList();
            });
        }