public ObjectValue[] GetChildren(ObjectPath path, int index, int count, EvaluationOptions options)
        {
            List <ObjectValue> children = new List <ObjectValue>();

            session.SelectThread(threadId);

            string expression = path.Join(".");

            if (expression.Trim().Length == 0)
            {
                return(children.ToArray());
            }

            List <DebugScopedSymbol> childSymbols = this.session.SymbolResolver.GetChildSymbols(expression, threadId);

            if (childSymbols.Count == 0)
            {
                return(children.ToArray());
            }

            for (int i = 0; i < childSymbols.Count; i++)
            {
                DebugScopedSymbol child = childSymbols[i];

                ObjectValue ov = CreateObjectValue(child);
                children.Add(ov);
            }

            return(children.ToArray());
        }
Exemple #2
0
        public ObjectValue[] GetChildren(ObjectPath path, int index, int count, EvaluationOptions options)
        {
            List <ObjectValue> children = new List <ObjectValue>();

            session.SelectThread(threadId);
            GdbCommandResult res   = session.RunCommand("-var-list-children", "2", path.Join("."));
            ResultData       cdata = res.GetObject("children");

            // The response may not contain the "children" list at all.
            if (cdata == null)
            {
                return(children.ToArray());
            }

            if (index == -1)
            {
                index = 0;
                count = cdata.Count;
            }

            for (int n = index; n < cdata.Count && n < index + count; n++)
            {
                ResultData data  = cdata.GetObject(n);
                ResultData child = data.GetObject("child");

                string name = child.GetValue("exp");
                if (name.Length > 0 && char.IsNumber(name[0]))
                {
                    name = "[" + name + "]";
                }

                // C++ structures may contain typeless children named
                // "public", "private" and "protected".
                if (child.GetValue("type") == null)
                {
                    ObjectPath    childPath   = new ObjectPath(child.GetValue("name").Split('.'));
                    ObjectValue[] subchildren = GetChildren(childPath, -1, -1, options);
                    children.AddRange(subchildren);
                }
                else
                {
                    ObjectValue val = CreateObjectValue(name, child);
                    children.Add(val);
                }
            }
            return(children.ToArray());
        }
Exemple #3
0
        public static ObjectValue Create(object obj, ObjectPath path)
        {
            var sessionOptions = DebuggingService.GetUserOptions();
            var options        = sessionOptions.EvaluationOptions;
            var context        = new CSharpInteractiveEvaluationContext(options);

            context.Adapter   = objectValueAdapter;
            context.Evaluator = new CSharpInteractiveExpressionEvaluator();

            var source = new CSharpInteractiveObjectValueSource(path.Join("."), obj, context);

            try {
                // Cannot update top level value types from the REPL so mark the top level objects as read-only.
                var         flags = ObjectValueFlags.ReadOnly;
                ObjectValue value = objectValueAdapter.CreateObjectValue(context, source, path, obj, flags);
                AttachStackFrame(value, sessionOptions);
                return(value);
            } catch (Exception ex) {
                return(ObjectValue.CreateError(null, path, string.Empty, ex.Message, ObjectValueFlags.None));
            }
        }
Exemple #4
0
 public EvaluationResult SetValue(ObjectPath path, string value, EvaluationOptions options)
 {
     session.SelectThread(threadId);
     session.RunCommand("-var-assign", path.Join("."), value);
     return(new EvaluationResult(value));
 }