Esempio n. 1
0
        public static StructValueStrings GetStructValueStrings(StructFieldsEx structFld, ClrHeap heap, ulong addr)
        {
            var cnt        = structFld._fields.Length;
            var structInfo = structFld._structFields;
            var vals       = new string[cnt];

            StructValueStrings[] structVals = null;
            for (int i = 0; i < cnt; ++i)
            {
                if (structInfo.IsAmbiguousKind(i))
                {
                    var fobj  = structFld._fields[i].GetValue(addr, true);
                    var faddr = (ulong)fobj;
                    var ftype = heap.GetObjectType(faddr);
                    if (ftype != null)
                    {
                        structFld._types[i] = ftype;
                        structInfo.SetKind(TypeExtractor.GetElementKind(ftype), i);
                    }
                }
                var fldType = structFld._types[i];
                var fld     = structFld._fields[i];
                var kind    = structFld._structFields.Kinds[i];
                Debug.Assert(fld != null);
                if (structFld._ex?[i] != null)
                {
                    if (structVals == null)
                    {
                        structVals = new StructValueStrings[cnt];
                    }

                    structVals[i] = GetStructValueStrings(structFld._ex[i], heap, fld.GetAddress(addr, true));
                }
                else if (fldType != null)
                {
                    var fobj  = fld.GetValue(addr, true);
                    var faddr = (ulong)fobj;
                    vals[i] = ValueExtractor.GetTypeValueString(heap, faddr, fldType, true, kind);
                }
                else
                {
                    if (TypeExtractor.IsKnownPrimitive(kind))
                    {
                        vals[i] = ValueExtractor.GetFieldValueString(heap, addr, true, fld, kind);
                    }
                    else
                    {
                        var fobj  = fld.GetAddress(addr, true);
                        var faddr = (ulong)fobj;
                        vals[i] = ValueExtractor.GetFieldValueString(heap, faddr, true, fld, kind);
                    }
                }
            }
            return(new StructValueStrings(vals, structVals));
        }