示例#1
0
 public ObjectArrayInfo(DumpObjectArray org, HeapFileAnalyzer analyzer)
 {
     ClassObjectID = org.ClassObjectID;
     if (analyzer.ClassObjectInfos.ContainsKey(org.ClassObjectID))
     {
         ClassObject = analyzer.ClassObjectInfos[org.ClassObjectID];
     }
     ObjectArrayID = org.ObjectArrayID;
     ElementIDs    = org.ElementIDs;
 }
示例#2
0
        public ObjectInstanceInfo(DumpObjectInstance org, HeapFileAnalyzer analyzer)
        {
            ClassObjectID = org.ClassObjectID;
            if (analyzer.ClassObjectInfos.ContainsKey(org.ClassObjectID))
            {
                ClassObject = analyzer.ClassObjectInfos[org.ClassObjectID];
            }
            else if (analyzer.ClassNames.ContainsKey(org.ClassObjectID))
            {
                ClassObject = analyzer.ClassNames[org.ClassObjectID];
            }
            ObjectID = org.ObjectID;

            int length = org.Length;

            #region ClassObject方法 -ClassObjectInfo
            if (ClassObject is ClassObjectInfo)
            {
                int             templength = 0;
                ClassObjectInfo tempClass  = ClassObject as ClassObjectInfo;
                InstanceFields = new List <PrimitiveObjectInfo>();

                while (templength < length)
                {
                    if (tempClass.InstanceFields == null)
                    {
                        break;
                    }
                    foreach (var it in tempClass.InstanceFields)
                    {
                        var value = PrimitiveTypeHelper.GetPrimitiveValue(it.Type, org.InstanceFieldData, ref templength);
                        if (it.Type != PrimitiveType.HPROF_BASIC_OBJECT)
                        {
                            InstanceFields.Add(new PrimitiveObjectInfo()
                            {
                                Name   = it.Name,
                                NameID = it.NameID,
                                Type   = it.Type,
                                Value  = value,
                            });
                        }
                        else
                        {
                            InstanceFields.Add(new ReferenceObjectInfo()
                            {
                                Name            = it.Name,
                                NameID          = it.NameID,
                                Type            = it.Type,
                                Value           = value,
                                ReferenceTarget = null
                            });
                        }
                    }

                    if (!analyzer.ClassObjectInfos.ContainsKey(tempClass.SuperClassObjectID))
                    {
                        break;
                    }
                    tempClass = analyzer.ClassObjectInfos[tempClass.SuperClassObjectID];
                }
            }
            ;
            #endregion

            #region ClassObject方法 -string
            if (ClassObject is string)
            {
                InstanceFields = new List <PrimitiveObjectInfo>();
                if (ClassName == "java.lang.String")
                {
                    int templength = 0;

                    var value = PrimitiveTypeHelper.GetPrimitiveValue(PrimitiveType.HPROF_BASIC_OBJECT, org.InstanceFieldData, ref templength);
                    InstanceFields.Add(new ReferenceObjectInfo()
                    {
                        Name   = "data",
                        NameID = 0,
                        Type   = PrimitiveType.HPROF_BASIC_OBJECT,
                        Value  = value,
                    });
                }
            }
            ;

            if (ClassName == "android.text.SpannableString" && InstanceFields.Count == 0)
            {
                int templength = 0;

                var value = PrimitiveTypeHelper.GetPrimitiveValue(PrimitiveType.HPROF_BASIC_OBJECT, org.InstanceFieldData, ref templength);
                InstanceFields.Add(new ReferenceObjectInfo()
                {
                    Name   = "data",
                    NameID = 0,
                    Type   = PrimitiveType.HPROF_BASIC_OBJECT,
                    Value  = value,
                });
            }
            #endregion
        }