Пример #1
0
        public bool Assign(string expression, out string error)
        {
            if (IsReadOnly)
            {
                error = string.Format(
                    "Attempted to assign a value to a read only variable with name '{0}'.",
                    DisplayName);

                return(false);
            }

            string cast = "";

            if (_remoteValue.TypeIsPointerType() ||
                _remoteValue.GetTypeInfo().GetTypeFlags().HasFlag(TypeFlags.IS_ENUMERATION))
            {
                cast = $"({_remoteValue.GetTypeInfo().GetCanonicalType().GetName()})";
            }

            expression = _remoteValueFormat.FormatExpressionForAssignment(_remoteValue, expression);
            // Avoid using parentheses to enclose registers because they can prevent assignments
            // involving initialization lists from succeeding.
            if (_remoteValue.GetValueType() != DebuggerApi.ValueType.Register)
            {
                expression = $"({expression})";
            }

            RemoteValue tempValue = _remoteValue.CreateValueFromExpression(
                DisplayName, $"{_remoteValue.GetVariableAssignExpression()} = {cast}{expression}");

            SbError sbError = tempValue.GetError();

            error = sbError.Fail() ? sbError.GetCString() : null;
            return(sbError.Success());
        }
Пример #2
0
        private GrpcValueInfo CreateValueInfoAndUpdateStores(RemoteValue remoteValue)
        {
            if (remoteValue == null)
            {
                return(null);
            }

            string expressionPath;
            var    hasExpressionPath = remoteValue.GetExpressionPath(out expressionPath);
            var    valueInfo         = new GrpcValueInfo
            {
                ExpressionPath    = expressionPath ?? "",
                HasExpressionPath = hasExpressionPath,
                NumChildren       = remoteValue.GetNumChildren(),
                Summary           = remoteValue.GetSummary() ?? "",
                TypeName          = remoteValue.GetTypeName() ?? "",
                Value             = remoteValue.GetValue() ?? "",
                ValueType         = EnumUtil.ConvertTo <Debugger.Common.ValueType>(
                    remoteValue.GetValueType()),
                IsPointerType = remoteValue.TypeIsPointerType(),
                ByteSize      = remoteValue.GetByteSize(),
            };
            var typeInfo = remoteValue.GetTypeInfo();

            if (typeInfo != null)
            {
                valueInfo.Type = GrpcFactoryUtils.CreateType(
                    typeInfo, typeStore.AddObject(typeInfo));
            }
            return(valueInfo);
        }
        RemoteValue CreateMockVariable()
        {
            RemoteValue mockVariable = Substitute.For <RemoteValue>();

            mockVariable.TypeIsPointerType().Returns(false);
            mockVariable.GetValueForExpressionPath(Arg.Any <string>()).Returns((RemoteValue)null);
            return(mockVariable);
        }
Пример #4
0
        public virtual IEnumerable <RemoteValue> GetChildren(RemoteValue remoteValue, int offset,
                                                             int count)
        {
            if (_sizeSpecifier == null)
            {
                return(GetRemoteValueChildren(remoteValue, offset, count));
            }

            // If we have a size specifier, we adjust the size appropriately.
            int childCount    = (int)GetNumPointerOrArrayChildren((uint)_sizeSpecifier, remoteValue);
            int adjustedCount = Math.Max(0, Math.Min(count, childCount - offset));

            // For pointers, we obtain the children by pointer arithmetic.
            if (remoteValue.TypeIsPointerType())
            {
                return(GetPointerChildren(remoteValue, offset, adjustedCount));
            }
            return(GetRemoteValueChildren(remoteValue, offset, adjustedCount));
        }
Пример #5
0
 uint GetNumPointerOrArrayChildren(uint size, RemoteValue remoteValue) =>
 remoteValue.TypeIsPointerType() ? size : Math.Min(size, remoteValue.GetNumChildren());
Пример #6
0
 public virtual bool TypeIsPointerType()
 {
     return(value.TypeIsPointerType());
 }