Beispiel #1
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);
        }
        static IEnumerable <RemoteValue> GetRemoteValueChildren(RemoteValue remoteValue, int offset,
                                                                int count)
        {
            var  result      = new List <RemoteValue>();
            uint childOffset = (uint)offset;
            uint endIndex    = (uint)(offset + count);
            uint numChildren = remoteValue.GetNumChildren();

            while (childOffset < endIndex)
            {
                // Fetch children in batches for performance reasons.
                uint batchSize = System.Math.Min(endIndex - childOffset, _maxChildBatchSize);
                List <RemoteValue> currentBatch = remoteValue.GetChildren(childOffset, batchSize);

                for (int n = 0; n < batchSize; ++n)
                {
                    RemoteValue childValue = currentBatch[n];
                    if (childValue != null)
                    {
                        result.Add(childValue);
                    }
                    else if (n + childOffset < numChildren)
                    {
                        // There were times when LLDB was returning an error and thus a null child
                        // value. ex: Children[1] for a CustomType&* type.
                        Trace.WriteLine(
                            $"WARNING: No child found at index {n + childOffset} of " +
                            $"({remoteValue.GetTypeName()}){remoteValue.GetFullName()} even " +
                            $"though there are {numChildren} children.");
                    }
                }
                childOffset += batchSize;
            }
            return(result);
        }
        public virtual string FormatValue(RemoteValue remoteValue, ValueFormat fallbackValueFormat)
        {
            string displayValue = remoteValue.GetDisplayValue(GetValueFormat(fallbackValueFormat));

            // TODO: Remove trailing zeros from ST registers summary.
            if (remoteValue.GetValueType() == ValueType.Register &&
                remoteValue.GetTypeName().Contains("ext_vector_type"))
            {
                // Ensure consistency across all the registers presented as vectors.
                return(TrySwitchFromParenthesesToBrackets(displayValue));
            }
            return(displayValue);
        }
        /// <summary>
        /// Returns a casted raw address expression that can be used to build a value assign
        /// expression.
        ///
        /// Can return null.
        /// </summary>
        public static string GetMemoryAddressAssignExpression(this RemoteValue remoteValue)
        {
            if (!IsValidValue(remoteValue))
            {
                return(null);
            }
            var flags = remoteValue.GetTypeInfo().GetTypeFlags();

            if (flags.HasFlag(TypeFlags.IS_REFERENCE))
            {
                // NOTE: This works for references implemented as a pointer. It is not known how
                // this will work for other implementations.
                var typeName = remoteValue.GetTypeName();
                typeName = typeName.Replace("&", "");
                return($"(*(({typeName}*){remoteValue.GetDefaultValue()}))");
            }

            RemoteValue addressOfValue;

            if (!TryGetAddressOf(remoteValue, out addressOfValue))
            {
                return(null);
            }

            if (flags.HasFlag(TypeFlags.IS_POINTER))
            {
                return($"(({remoteValue.GetTypeName()}){remoteValue.GetDefaultValue()})");
            }

            if (flags.HasFlag(TypeFlags.IS_ARRAY))
            {
                return(null);
            }

            return($"(*(({remoteValue.GetTypeName()}*){addressOfValue.GetDefaultValue()}))");
        }
 public virtual string GetTypeName()
 {
     return(value.GetTypeName());
 }