/// <summary>
        /// Get the variable assignment expression as a string. Returns null if the value is
        /// constant or invalid.
        /// </summary>
        public static string GetVariableAssignExpression(this RemoteValue remoteValue)
        {
            var valueType = remoteValue.GetValueType();

            if (valueType == ValueType.Invalid)
            {
                return(null);
            }

            if (valueType == ValueType.Register)
            {
                return($"${remoteValue.GetName()}");
            }

            TypeFlags?typeFlags = remoteValue.GetTypeInfo()?.GetTypeFlags();

            if (typeFlags.HasValue && typeFlags.Value.HasFlag(TypeFlags.IS_ARRAY))
            {
                return(null);
            }

            string variableExpression = remoteValue.GetFullName();

            if (variableExpression == null)
            {
                variableExpression = remoteValue.GetMemoryAddressAssignExpression();
            }
            return(variableExpression);
        }
        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);
        }
Example #3
0
 public string Fullname() => _remoteValue.GetValueType() == DebuggerApi.ValueType.Register
     ? $"{ExpressionConstants.RegisterPrefix}{_remoteValue.GetName()}"
     : _remoteValue.GetFullName();