/// <summary>
        /// Returns the address to be used as memory context. This is used to get an address
        /// from an expression entered into Visual Studio's memory view's address text box.
        /// </summary>
        public static ulong?GetMemoryContextAddress(this RemoteValue remoteValue)
        {
            if (!IsValidValue(remoteValue))
            {
                return(null);
            }

            TypeFlags GetTypeFlags(RemoteValue value) =>
            remoteValue.GetTypeInfo().GetCanonicalType().GetTypeFlags();

            // If the value is an array, try to obtain its address.
            TypeFlags flags = GetTypeFlags(remoteValue);

            if (flags.HasFlag(TypeFlags.IS_ARRAY))
            {
                remoteValue = remoteValue.AddressOf();
                if (!IsValidValue(remoteValue))
                {
                    return(null);
                }
                flags = GetTypeFlags(remoteValue);
            }

            // Only interpret pointers, references and integers as addresses.
            if (!flags.HasFlag(TypeFlags.IS_REFERENCE) && !flags.HasFlag(TypeFlags.IS_POINTER) &&
                !flags.HasFlag(TypeFlags.IS_INTEGER))
            {
                return(null);
            }

            return(remoteValue.GetValueAsUnsigned());
        }
Esempio n. 2
0
        static IEnumerable <RemoteValue> GetPointerChildren(RemoteValue value, int offset, int count)
        {
            var    result      = new List <RemoteValue>();
            SbType pointeeType = value.GetTypeInfo()?.GetPointeeType();

            if (pointeeType == null)
            {
                // If we cannot get the pointee type, just return the empty list.
                return(result);
            }
            ulong byteSize    = pointeeType.GetByteSize();
            ulong baseAddress = value.GetValueAsUnsigned() + (ulong)offset * byteSize;

            for (int n = 0; n < count; ++n)
            {
                ulong       address    = baseAddress + (ulong)n * byteSize;
                RemoteValue childValue =
                    value.CreateValueFromAddress($"[{offset + n}]", address, pointeeType);
                if (childValue != null)
                {
                    result.Add(childValue);
                }
            }
            return(result);
        }
        public override string FormatValueAsAddress(RemoteValue remoteValue)
        {
            TypeFlags flags = remoteValue?.GetTypeInfo()?.GetTypeFlags() ?? 0;

            if (flags.HasFlag(TypeFlags.IS_REFERENCE) || flags.HasFlag(TypeFlags.IS_POINTER))
            {
                if (ValueFormat == ValueFormat.HexUppercase)
                {
                    return($"{remoteValue.GetValueAsUnsigned():X16}");
                }
                else
                {
                    return($"{remoteValue.GetValueAsUnsigned():x16}");
                }
            }
            return(string.Empty);
        }
        public virtual string FormatValueAsAddress(RemoteValue remoteValue)
        {
            TypeFlags flags = remoteValue?.GetTypeInfo()?.GetTypeFlags() ?? 0;

            if (flags.HasFlag(TypeFlags.IS_REFERENCE) || flags.HasFlag(TypeFlags.IS_POINTER))
            {
                return($"0x{remoteValue.GetValueAsUnsigned():x16}");
            }
            return(string.Empty);
        }
Esempio n. 5
0
 public ulong GetValueAsUnsigned() => remoteProxy.GetValueAsUnsigned();
 public ulong GetValueAsUnsigned() => value.GetValueAsUnsigned();