Beispiel #1
0
 IDebuggerValue Create(DBG.CorValue v)
 {
     if (v == null)
     {
         throw new InvalidOperationException("Could not create a new value");
     }
     return(new DebuggerValue(debugger, v));
 }
Beispiel #2
0
        DBG.CorValue[] CreateArgs(object[] args)
        {
            var res = new DBG.CorValue[args.Length];

            for (int i = 0; i < args.Length; i++)
            {
                var v = (DebuggerValue)Create(args[i]);
                res[i] = v.CorValue;
            }
            return(res);
        }
Beispiel #3
0
 void Keep(DBG.CorValue v)
 {
     debugger.Dispatcher.VerifyAccess();
     if (v == null)
     {
         return;
     }
     if (valuesToKeep == null)
     {
         valuesToKeep = new List <DBG.CorValue>();
     }
     valuesToKeep.Add(v);
 }
Beispiel #4
0
        public static DBG.CorValue[] ToCorValues(this IDebuggerValue[] values)
        {
            if (values == null)
            {
                return(null);
            }
            var cvalues = new DBG.CorValue[values.Length];

            for (int i = 0; i < values.Length; i++)
            {
                var v = (DebuggerValue)values[i];
                cvalues[i] = v.CorValue;
            }
            return(cvalues);
        }
Beispiel #5
0
 public bool Equals(CorValue other)
 {
     return(!ReferenceEquals(other, null) &&
            RawObject == other.RawObject);
 }
Beispiel #6
0
 public bool Equals(CorValue other) => !ReferenceEquals(other, null) && RawObject == other.RawObject;
Beispiel #7
0
 public string ToString(CorValue value, TypeFormatterFlags flags) => Write(new StringBuilderTypeOutput(), value, flags).ToString();
Beispiel #8
0
		DBG.CorValue[] CreateArgs(object[] args) {
			var res = new DBG.CorValue[args.Length];
			for (int i = 0; i < args.Length; i++) {
				var v = (DebuggerValue)Create(args[i]);
				res[i] = v.CorValue;
			}
			return res;
		}
Beispiel #9
0
        static CorValueResult?GetSimpleResult(CorValue value, CorElementType etype)
        {
            byte[] data;
            switch (etype)
            {
            case CorElementType.Boolean:
                if (value.Size != 1)
                {
                    break;
                }
                data = value.ReadGenericValue();
                if (data == null)
                {
                    break;
                }
                return(new CorValueResult(data[0] != 0));

            case CorElementType.Char:
                if (value.Size != 2)
                {
                    break;
                }
                data = value.ReadGenericValue();
                if (data == null)
                {
                    break;
                }
                return(new CorValueResult(BitConverter.ToChar(data, 0)));

            case CorElementType.I1:
                if (value.Size != 1)
                {
                    break;
                }
                data = value.ReadGenericValue();
                if (data == null)
                {
                    break;
                }
                return(new CorValueResult((sbyte)data[0]));

            case CorElementType.U1:
                if (value.Size != 1)
                {
                    break;
                }
                data = value.ReadGenericValue();
                if (data == null)
                {
                    break;
                }
                return(new CorValueResult(data[0]));

            case CorElementType.I2:
                if (value.Size != 2)
                {
                    break;
                }
                data = value.ReadGenericValue();
                if (data == null)
                {
                    break;
                }
                return(new CorValueResult(BitConverter.ToInt16(data, 0)));

            case CorElementType.U2:
                if (value.Size != 2)
                {
                    break;
                }
                data = value.ReadGenericValue();
                if (data == null)
                {
                    break;
                }
                return(new CorValueResult(BitConverter.ToUInt16(data, 0)));

            case CorElementType.I4:
                if (value.Size != 4)
                {
                    break;
                }
                data = value.ReadGenericValue();
                if (data == null)
                {
                    break;
                }
                return(new CorValueResult(BitConverter.ToInt32(data, 0)));

            case CorElementType.U4:
                if (value.Size != 4)
                {
                    break;
                }
                data = value.ReadGenericValue();
                if (data == null)
                {
                    break;
                }
                return(new CorValueResult(BitConverter.ToUInt32(data, 0)));

            case CorElementType.I8:
                if (value.Size != 8)
                {
                    break;
                }
                data = value.ReadGenericValue();
                if (data == null)
                {
                    break;
                }
                return(new CorValueResult(BitConverter.ToInt64(data, 0)));

            case CorElementType.U8:
                if (value.Size != 8)
                {
                    break;
                }
                data = value.ReadGenericValue();
                if (data == null)
                {
                    break;
                }
                return(new CorValueResult(BitConverter.ToUInt64(data, 0)));

            case CorElementType.R4:
                if (value.Size != 4)
                {
                    break;
                }
                data = value.ReadGenericValue();
                if (data == null)
                {
                    break;
                }
                return(new CorValueResult(BitConverter.ToSingle(data, 0)));

            case CorElementType.R8:
                if (value.Size != 8)
                {
                    break;
                }
                data = value.ReadGenericValue();
                if (data == null)
                {
                    break;
                }
                return(new CorValueResult(BitConverter.ToDouble(data, 0)));

            case CorElementType.TypedByRef:
                break;                //TODO:

            case CorElementType.I:
                if (value.Size != (uint)Utils.DebuggeeIntPtrSize)
                {
                    break;
                }
                data = value.ReadGenericValue();
                if (data == null)
                {
                    break;
                }
                Debug.Assert(Utils.DebuggeeIntPtrSize == IntPtr.Size, "Invalid IntPtr size");
                if (Utils.DebuggeeIntPtrSize == 4)
                {
                    return(new CorValueResult(new IntPtr(BitConverter.ToInt32(data, 0))));
                }
                return(new CorValueResult(new IntPtr(BitConverter.ToInt64(data, 0))));

            case CorElementType.U:
            case CorElementType.Ptr:
            case CorElementType.FnPtr:
                if (value.Size != (uint)Utils.DebuggeeIntPtrSize)
                {
                    break;
                }
                data = value.ReadGenericValue();
                if (data == null)
                {
                    break;
                }
                Debug.Assert(Utils.DebuggeeIntPtrSize == UIntPtr.Size, "Invalid UIntPtr size");
                if (Utils.DebuggeeIntPtrSize == 4)
                {
                    return(new CorValueResult(new UIntPtr(BitConverter.ToUInt32(data, 0))));
                }
                return(new CorValueResult(new UIntPtr(BitConverter.ToUInt64(data, 0))));

            case CorElementType.Class:
            case CorElementType.ValueType:
                var res = GetDecimalResult(value);
                if (res != null)
                {
                    return(res);
                }
                res = GetDateTimeResult(value);
                if (res != null)
                {
                    return(res);
                }
                res = GetNullableResult(value);
                if (res != null)
                {
                    return(res);
                }
                break;
            }

            return(null);
        }
Beispiel #10
0
        public static CorValueResult ReadSimpleTypeValue(CorValue value)
        {
            if (value == null)
            {
                return(new CorValueResult());
            }

            if (value.IsReference && value.ElementType == CorElementType.ByRef)
            {
                if (value.IsNull)
                {
                    return(new CorValueResult(null));
                }
                value = value.DereferencedValue;
                if (value == null)
                {
                    return(new CorValueResult());
                }
            }
            if (value.IsReference)
            {
                if (value.IsNull)
                {
                    return(new CorValueResult(null));
                }
                if (value.ElementType == CorElementType.Ptr || value.ElementType == CorElementType.FnPtr)
                {
                    if (Utils.DebuggeeIntPtrSize == 4)
                    {
                        return(new CorValueResult((uint)value.ReferenceAddress));
                    }
                    return(new CorValueResult(value.ReferenceAddress));
                }
                value = value.DereferencedValue;
                if (value == null)
                {
                    return(new CorValueResult());
                }
            }
            if (value.IsBox)
            {
                value = value.BoxedValue;
                if (value == null)
                {
                    return(new CorValueResult());
                }
            }
            if (value.IsReference)
            {
                return(new CorValueResult());
            }
            if (value.IsBox)
            {
                return(new CorValueResult());
            }
            if (value.IsArray)
            {
                return(new CorValueResult());
            }
            if (value.IsString)
            {
                return(new CorValueResult(value.String));
            }

            var type = value.ExactType;

            if (type == null)
            {
                return(new CorValueResult());
            }
            var vres = GetSimpleResult(value, type.TryGetPrimitiveType(), type);

            return(vres ?? new CorValueResult());
        }
Beispiel #11
0
 public DummyCorValueHolder(CorValue value)
 {
     this.value = value;
 }
Beispiel #12
0
 public EvalResult(bool wasException, CorValue resultOrException)
 {
     this.WasException      = wasException;
     this.ResultOrException = resultOrException;
 }
Beispiel #13
0
		public static DBG.CorValue[] ToCorValues(this IDebuggerValue[] values) {
			if (values == null)
				return null;
			var cvalues = new DBG.CorValue[values.Length];
			for (int i = 0; i < values.Length; i++) {
				var v = (DebuggerValue)values[i];
				cvalues[i] = v.CorValue;
			}
			return cvalues;
		}
Beispiel #14
0
 public string ToString(CorValue value, TypePrinterFlags flags)
 {
     return(Write(new StringBuilderTypeOutput(), value, flags).ToString());
 }
Beispiel #15
0
 public void InvalidateCorValue()
 {
     value?.DisposeHandle();
     value = null;
 }
Beispiel #16
0
 public EvalResult(bool wasException, bool wasCustomNotification, bool wasCancelled, CorValue resultOrException)
 {
     WasException          = wasException;
     WasCustomNotification = wasCustomNotification;
     WasCancelled          = wasCancelled;
     ResultOrException     = resultOrException;
 }
Beispiel #17
0
 public T Write <T>(T output, CorValue value, TypeFormatterFlags flags, Func <DnEval> getEval = null) where T : ITypeOutput
 {
     new TypeFormatter(output, flags, getEval).Write(value, this);
     return(output);
 }
Beispiel #18
0
 public EvalResult(bool wasException, CorValue resultOrException)
 {
     WasException      = wasException;
     ResultOrException = resultOrException;
 }