コード例 #1
0
        public static StructValues GetStructValues(StructFieldsEx structFld, ClrHeap heap, ulong addr)
        {
            var cnt        = structFld._fields.Length;
            var structInfo = structFld._structFields;
            var vals       = new object[cnt];

            StructValues[] 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 StructValues[cnt];
                    }

                    structVals[i] = GetStructValues(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.GetTypeValue(heap, faddr, fldType, kind);
                }
                else
                {
                    vals[i] = ValueExtractor.GetFieldValue(heap, addr, true, fld, kind);
                }
            }
            return(new StructValues(vals, structVals));
        }
コード例 #2
-1
        public void GetValue(ClrHeap heap, ulong address, Queue <ValueTuple <TypeValue, ulong> > que)
        {
            que.Clear();
            que.Enqueue((this, address));
            while (que.Count > 0)
            {
                (TypeValue val, ulong addr) = que.Dequeue();
                if (val._type == null)
                {
                    ClrType clrType = heap.GetObjectType(addr);
                    if (clrType == null)
                    {
                        continue;
                    }
                    val._type = clrType;
                    val._kind = TypeExtractor.GetElementKind(clrType);
                    val.SetValue(addr);
                }
                if (val._children != null)
                {
                    for (int i = 0, icnt = val._children.Length; i < icnt; ++i)
                    {
                        TypeValue fldVal = val._children[i];

                        if (fldVal._fieldName != null && fldVal._field == null)
                        {
                            ClrInstanceField f = val._type.GetFieldByName(fldVal._fieldName);
                            if (f == null)
                            {
                                continue;
                            }
                            fldVal._field = f;
                            fldVal._type  = f.Type;
                            fldVal._kind  = TypeExtractor.GetElementKind(f.Type);
                        }
                        object v = ValueExtractor.GetFieldValue(heap, addr, fldVal._type.IsValueClass, fldVal._field, fldVal._kind);
                        ulong  a = (v is ulong) ? (ulong)v : Constants.InvalidAddress;
                        fldVal.SetValue(v);
                        que.Enqueue((val._children[i], (ulong)val._value));
                    }
                }
                else
                {
                    if (val._fieldName != null && val._field == null)
                    {
                        ClrInstanceField f = val._type.GetFieldByName(val._fieldName);
                        val._field = f;
                        val._type  = f.Type;
                        val._kind  = TypeExtractor.GetElementKind(f.Type);
                    }
                    object v = ValueExtractor.GetFieldValue(heap, addr, val._type.IsValueClass, val._field, val._kind);
                    val.SetValue(v);
                }
            }
        }