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()); }
internal static GrpcSbValue CreateValue(RemoteValue remoteValue, long id) => new GrpcSbValue { Id = id, Name = remoteValue.GetName() ?? "", Error = CreateError(remoteValue.GetError()) };
async Task <uint> EvaluateSizeSpecifierExpressionAsync(string expression) { RemoteValue value = await CreateValueFromExpressionAsync(expression); var err = value.GetError(); if (err.Fail()) { throw new ExpressionEvaluationFailed(err.GetCString()); } if (!uint.TryParse(value.GetValue(ValueFormat.Default), out uint size)) { throw new ExpressionEvaluationFailed("Expression isn't a uint"); } return(size); }
/// <summary> /// Returns an error string if the _remoteValue's error is in fail state and null otherwise. /// </summary> string GetErrorString() { SbError error = _remoteValue.GetError(); if (!error.Fail()) { return(null); } // TODO: Determine why we are suppressing error strings for REGISTER // ValueTypes. Add comments if needed or remove otherwise. string errorString = _remoteValue.GetValueType() == DebuggerApi.ValueType.Register ? "unavailable" : error.GetCString(); return($"<{errorString}>"); }
internal CachedValue(RemoteValue remoteProxy, RemoteValue addressOf, SbType typeInfo, string expressionPath, bool hasExpressionPath, uint numChildren, string summary, string typeName, string value, ValueType valueType, bool isPointerType, ValueFormat valueFormat, ulong byteSize) { this.remoteProxy = remoteProxy; this.addressOf = addressOf; this.typeInfo = typeInfo; this.expressionPath = expressionPath; this.hasExpressionPath = hasExpressionPath; this.numChildren = numChildren; this.summary = summary; this.typeName = typeName; this.value = value; this.valueType = valueType; this.isPointerType = isPointerType; this.valueFormat = valueFormat; this.byteSize = byteSize; // These values are prefeteched by remoteProxy. error = remoteProxy.GetError(); name = remoteProxy.GetName(); }
/// <summary> /// Determines if a RemoteValue is a valid value. i.e. has correct type information and /// isn't an error. /// </summary> /// <param name="remoteValue"></param> /// <returns></returns> private static bool IsValidValue(RemoteValue remoteValue) { return(remoteValue != null && remoteValue.GetTypeInfo() != null && !remoteValue.GetError().Fail()); }
public virtual SbError GetError() { return(value.GetError()); }