Esempio n. 1
0
        private ObjectValue CreateObjectValue(string name, ResultData data)
        {
            string vname    = data.GetValue("name");
            string typeName = data.GetValue("type");
            string value    = data.GetValue("value");
            int    nchild   = data.GetInt("numchild");

            ObjectValue      val;
            ObjectValueFlags flags = ObjectValueFlags.Variable;

            // There can be 'public' et al children for C++ structures
            if (typeName == null)
            {
                typeName = "none";
            }

            if (typeName.EndsWith("]"))
            {
                val = ObjectValue.CreateArray(this, new ObjectPath(vname), typeName, nchild, flags, null);
            }
            else if (value == "{...}" || typeName.EndsWith("*") || nchild > 0)
            {
                val = ObjectValue.CreateObject(this, new ObjectPath(vname), typeName, value, flags, null);
            }
            else
            {
                val = ObjectValue.CreatePrimitive(this, new ObjectPath(vname), typeName, new EvaluationResult(value), flags);
            }
            val.Name = name;
            return(val);
        }
        public FieldValueReference(
            EvaluationContext ctx,
            FieldInfo field,
            object obj,
            Type declaringType,
            string vname,
            ObjectValueFlags vflags,
            FieldReferenceBatch batch = null) : base(ctx)
        {
            this.field         = field;
            this.obj           = obj;
            this.declaringType = declaringType;
            this.vname         = vname;
            this.batch         = batch;

            if (field.IsStatic)
            {
                this.obj = null;
            }

            flags = GetFlags(field);

            // if `vflags` already has an origin specified, we need to unset the `Field` flag which is always returned by GetFlags().
            if ((vflags & ObjectValueFlags.OriginMask) != 0)
            {
                flags &= ~ObjectValueFlags.Field;
            }

            flags |= vflags;

            if (obj?.GetType()?.IsPrimitive == true)
            {
                flags |= ObjectValueFlags.ReadOnly;
            }
        }
Esempio n. 3
0
        public FieldValueReference(EvaluationContext ctx, FieldInfoMirror field, object obj, TypeMirror declaringType, string vname, ObjectValueFlags vflags, FieldReferenceBatch batch = null) : base(ctx)
        {
            this.field         = field;
            this.obj           = obj;
            this.declaringType = declaringType;
            this.vname         = vname;
            this.batch         = batch;
            flags = vflags;

            if (field.IsStatic)
            {
                this.obj = null;
            }

            var objectMirror = obj as ObjectMirror;

            if (objectMirror != null)
            {
                EnsureContextHasDomain(objectMirror.Domain);
            }

            flags |= GetFlags(field);

            if (obj is PrimitiveValue)
            {
                flags |= ObjectValueFlags.ReadOnly;
            }
        }
		internal static ObjectValueFlags GetFlags (PropertyInfoMirror property, MethodMirror getter)
		{
			var flags = ObjectValueFlags.Property;

			if (property.GetSetMethod (true) == null)
				flags |= ObjectValueFlags.ReadOnly;

			if (getter.IsStatic)
				flags |= ObjectValueFlags.Global;

			if (getter.IsPublic)
				flags |= ObjectValueFlags.Public;
			else if (getter.IsPrivate)
				flags |= ObjectValueFlags.Private;
			else if (getter.IsFamily)
				flags |= ObjectValueFlags.Protected;
			else if (getter.IsFamilyAndAssembly)
				flags |= ObjectValueFlags.Internal;
			else if (getter.IsFamilyOrAssembly)
				flags |= ObjectValueFlags.InternalProtected;

			if (property.DeclaringType.IsValueType)
				flags |= ObjectValueFlags.ReadOnly; // Setting property values on structs is not supported by sdb

			return flags;
		}
        internal static ObjectValueFlags GetFlags(FieldInfo field)
        {
            var flags = ObjectValueFlags.Field;

            if (field.IsStatic)
            {
                flags |= ObjectValueFlags.Global;
            }

            if (field.IsPublic)
            {
                flags |= ObjectValueFlags.Public;
            }
            else if (field.IsPrivate)
            {
                flags |= ObjectValueFlags.Private;
            }
            else if (field.IsFamily)
            {
                flags |= ObjectValueFlags.Protected;
            }
            else if (field.IsFamilyAndAssembly)
            {
                flags |= ObjectValueFlags.Internal;
            }
            else if (field.IsFamilyOrAssembly)
            {
                flags |= ObjectValueFlags.InternalProtected;
            }

            return(flags);
        }
        private ObjectValue CreateObjectValue(DebugScopedSymbol symbol)
        {
            ObjectValueFlags flags = CreateObjectValueFlags(symbol);
            ObjectValue      val   = ObjectValue.CreatePrimitive(this, new ObjectPath(symbol.FullName.Split(".".ToCharArray())), symbol.TypeName, new EvaluationResult(symbol.TextValue), flags);

            return(val);
        }
        public ObjectValue[] GetLocalVariables(int frameIndex, EvaluationOptions options)
        {
            List <ObjectValue> values = new List <ObjectValue>();

            if (frameIndex >= magoCallStackFrames.Count)
            {
                return(values.ToArray());
            }

            List <DebugScopedSymbol> tempSymbols = null;

            if (frameIndex == 0)
            {
                tempSymbols = symbols;
            }
            else
            {
                tempSymbols = session.SymbolResolver.GetLocalSymbols(threadId, magoCallStackFrames[frameIndex].InstructionPointer);
            }

            foreach (var symbol in symbols)
            {
                ObjectValueFlags flags = ObjectValueFlags.Object;
                ObjectValue      ov    = ObjectValue.CreatePrimitive(this, new ObjectPath(symbol.FullName.Split(".".ToCharArray())), symbol.TypeName, new EvaluationResult(symbol.TextValue), flags);
                values.Add(ov);
            }

            return(values.ToArray());
        }
Esempio n. 8
0
 internal void UpdateFrom(ObjectValue val, bool notify)
 {
     lock (mutex) {
         arrayCount = val.arrayCount;
         if (val.name != null)
         {
             name = val.name;
         }
         value        = val.value;
         displayValue = val.displayValue;
         typeName     = val.typeName;
         flags        = val.flags;
         source       = val.source;
         children     = val.children;
         path         = val.path;
         updater      = val.updater;
         ConnectCallbacks(parentFrame, this);
         if (evaluatedEvent != null)
         {
             evaluatedEvent.Set();
         }
         if (notify && valueChanged != null)
         {
             valueChanged(this, EventArgs.Empty);
         }
     }
 }
Esempio n. 9
0
        public ObjectValue Run(string name, ObjectValueFlags flags, ObjectEvaluatorDelegate evaluator)
        {
            string id;
            int    tid;

            lock (asyncCallbacks) {
                tid = asyncCounter++;
                id  = tid.ToString();
            }

            ObjectValue val  = null;
            bool        done = runner.Run(delegate {
                if (tid >= cancelTimestamp)
                {
                    val = evaluator();
                }
            },
                                          delegate {
                if (tid >= cancelTimestamp)
                {
                    OnEvaluationDone(id, val);
                }
            });

            if (done)
            {
                // 'val' may be null if the timed evaluator is disposed while evaluating
                return(val ?? ObjectValue.CreateUnknown(name));
            }

            return(ObjectValue.CreateEvaluating(this, new ObjectPath(id, name), flags));
        }
Esempio n. 10
0
 public VariableValueReference(EvaluationContext ctx, CorValRef var, string name, ObjectValueFlags flags)
     : base(ctx)
 {
     this.flags = flags;
     this.var   = var;
     this.name  = name;
 }
        public ObjectValue Run(string name, ObjectValueFlags flags, ObjectEvaluatorDelegate evaluator)
        {
            string id;
            int    tid;

            lock (asyncCallbacks) {
                tid = asyncCounter++;
                id  = tid.ToString();
            }

            ObjectValue val  = null;
            bool        done = runner.Run(delegate {
                if (tid >= cancelTimestamp)
                {
                    val = evaluator();
                }
            },
                                          delegate {
                if (tid >= cancelTimestamp)
                {
                    OnEvaluationDone(id, val);
                }
            });

            if (done)
            {
                return(val);
            }
            else
            {
                return(ObjectValue.CreateEvaluating(this, new ObjectPath(id, name), flags));
            }
        }
		public VariableValueReference (EvaluationContext ctx, CorValRef var, string name, ObjectValueFlags flags)
			: base (ctx)
		{
			this.flags = flags;
			this.var = var;
			this.name = name;
		}
Esempio n. 13
0
        public PropertyReference(EvaluationContext ctx, PropertyInfo prop, CorValRef thisobj, CorType declaringType, CorValRef[] index)
            : base(ctx)
        {
            this.prop          = prop;
            this.declaringType = declaringType;
            if (declaringType.Type == CorElementType.ELEMENT_TYPE_ARRAY ||
                declaringType.Type == CorElementType.ELEMENT_TYPE_SZARRAY)
            {
                this.module = ((CorType)((CorEvaluationContext)ctx).Adapter.GetType(ctx, "System.Object")).Class.Module;
            }
            else
            {
                this.module = declaringType.Class.Module;
            }
            this.index = index;
            if (!prop.GetGetMethod(true).IsStatic)
            {
                this.thisobj = thisobj;
            }

            flags = GetFlags(prop);

            loader = delegate {
                return(((CorValRef)Value).Val);
            };
        }
Esempio n. 14
0
        ObjectValue CreateObjectValue(string name, DebugEngineWrapper.DebugScopedSymbol symbol)
        {
            string vname    = symbol.Name;
            string typeName = symbol.TypeName;
            string value    = symbol.TextValue;
            int    nchild   = (int)symbol.ChildrenCount;

            ObjectValue      val;
            ObjectValueFlags flags = ObjectValueFlags.Variable;

            // There can be 'public' et al children for C++ structures
            if (typeName == null)
            {
                typeName = "none";
            }

            val      = ObjectValue.CreatePrimitive(this, new ObjectPath(vname), typeName, new EvaluationResult(value), flags);
            val.Name = name;
            return(val);

            /*
             *          if (typeName.EndsWith ("]")) {
             *                  val = ObjectValue.CreateArray (this, new ObjectPath (vname), typeName, nchild, flags, null);
             *          } else if (value == "{...}" || typeName.EndsWith ("*") || nchild > 0) {
             *                  val = ObjectValue.CreateObject (this, new ObjectPath (vname), typeName, value, flags, null);
             *          } else {
             *                  val = ObjectValue.CreatePrimitive (this, new ObjectPath (vname), typeName, new EvaluationResult (value), flags);
             *          }
             *          val.Name = name;
             */

            return(val);
        }
		public ObjectValue Run (string name, ObjectValueFlags flags, ObjectEvaluatorDelegate evaluator)
		{
			string id;
			int tid;
			lock (asyncCallbacks) {
				tid = asyncCounter++;
				id = tid.ToString ();
			}
			
			ObjectValue val = null;
			bool done = runner.Run (delegate {
					if (tid >= cancelTimestamp)
						val = evaluator ();
			},
			delegate {
				if (tid >= cancelTimestamp)
					OnEvaluationDone (id, val);
			});
			
			if (done) {
				// 'val' may be null if the timed evaluator is disposed while evaluating
				return val ?? ObjectValue.CreateUnknown (name);
			}

			return ObjectValue.CreateEvaluating (this, new ObjectPath (id, name), flags);
		}
		public PropertyValueReference (EvaluationContext ctx, PropertyInfoMirror property, object obj, TypeMirror declaringType, Value[] indexerArgs): base (ctx)
		{
			this.property = property;
			this.obj = obj;
			this.declaringType = declaringType;
			this.indexerArgs = indexerArgs;
			flags = ObjectValueFlags.Property;
			if (property.GetSetMethod (true) == null)
				flags |= ObjectValueFlags.ReadOnly;
			MethodMirror getter = property.GetGetMethod (true);
			if (getter.IsStatic)
				flags |= ObjectValueFlags.Global;
			if (getter.IsPublic)
				flags |= ObjectValueFlags.Public;
			else if (getter.IsPrivate)
				flags |= ObjectValueFlags.Private;
			else if (getter.IsFamily)
				flags |= ObjectValueFlags.Protected;
			else if (getter.IsFamilyAndAssembly)
				flags |= ObjectValueFlags.Internal;
			else if (getter.IsFamilyOrAssembly)
				flags |= ObjectValueFlags.InternalProtected;
			if (property.DeclaringType.IsValueType)
				flags |= ObjectValueFlags.ReadOnly; // Setting property values on structs is not supported by sdb
		}
Esempio n. 17
0
        ObjectValue CreateObjectValue(string name, DebugEngineWrapper.DebugScopedSymbol symbol)
        {
            string vname    = symbol.Name;
            string typeName = symbol.TypeName;
            string value    = symbol.TextValue;
            int    nchild   = (int)symbol.ChildrenCount;

            ObjectValue val = symbolResolver.Resolve(symbol.Offset, vname, typeName, value, symbol.Parent);

            if (val == null)
            {
                ObjectValueFlags flags = ObjectValueFlags.Variable;

                // There can be 'public' et al children for C++ structures
                if (typeName == null)
                {
                    typeName = "none";
                }

                val      = ObjectValue.CreatePrimitive(this, new ObjectPath(vname), typeName, new EvaluationResult(value), flags);
                val.Name = name;
            }

            return(val);
        }
        bool IsPublicValueFlag(ObjectValueFlags flags)
        {
            var isField    = (flags & ObjectValueFlags.Field) != 0;
            var isProperty = (flags & ObjectValueFlags.Property) != 0;
            var isPublic   = (flags & ObjectValueFlags.Public) != 0;

            return(!(isField || isProperty) || isPublic);
        }
        public VSCodeObjectSource(VSCodeDebuggerSession vsCodeDebuggerSession, int variablesReference, int parentVariablesReference, string name, string type, string evalName, int frameId, string val)
        {
            this.vsCodeDebuggerSession    = vsCodeDebuggerSession;
            this.parentVariablesReference = parentVariablesReference;
            this.variablesReference       = variablesReference;
            this.evalName = evalName;
            this.frameId  = frameId;

            if (type == null)
            {
                if (IsCSError(118, "is a namespace but is used like a variable", val, out string ns))
                {
                    this.display = this.name = this.val = ns;
                    this.flags   = ObjectValueFlags.Namespace;
                    this.type    = "<namespace>";
                    return;
                }

                if (IsCSError(119, "is a type, which is not valid in the given context", val, out string vtype))
                {
                    if (name.StartsWith("global::", StringComparison.Ordinal))
                    {
                        vtype = name.Substring("global::".Length);
                    }

                    this.display = this.name = this.val = ObjectValueAdaptor.GetCSharpTypeName(vtype);
                    this.flags   = ObjectValueFlags.Type;
                    this.type    = "<type>";
                    return;
                }
            }

            var actualType = GetActualTypeName(type);

            this.flags = parentVariablesReference > 0 ? ObjectValueFlags.None : ObjectValueFlags.ReadOnly;
            this.type  = actualType.Replace(", ", ",");
            this.name  = GetFixedVariableName(name);

            if (actualType != "void")
            {
                this.val = GetFixedValue(val, this.type, actualType);
            }
            else
            {
                this.val = "No return value.";
            }
            this.display = val;

            if (this.name[0] == '[')
            {
                flags |= ObjectValueFlags.ArrayElement;
            }

            if (type == null || val == $"'{this.name}' threw an exception of type '{this.type}'")
            {
                flags |= ObjectValueFlags.Error;
            }
        }
		public PropertyValueReference (EvaluationContext ctx, PropertyInfoMirror property, object obj, TypeMirror declaringType, MethodMirror getter, Value[] indexerArgs): base (ctx)
		{
			this.property = property;
			this.obj = obj;
			this.declaringType = declaringType;
			this.indexerArgs = indexerArgs;
			
			flags = GetFlags (property, getter);
		}
Esempio n. 21
0
        public static ObjectValue CreateFatalError(string name, string message, ObjectValueFlags flags)
        {
            var val = new ObjectValue();

            val.flags = flags | ObjectValueFlags.Error;
            val.value = message;
            val.name  = name;
            return(val);
        }
		public ObjectValue CreateObjectValue (EvaluationContext ctx, IObjectValueSource source, ObjectPath path, object obj, ObjectValueFlags flags)
		{
			try {
				return CreateObjectValueImpl (ctx, source, path, obj, flags);
			} catch (Exception ex) {
				ctx.WriteDebuggerError (ex);
				return ObjectValue.CreateFatalError (path.LastName, ex.Message, flags);
			}
		}
Esempio n. 23
0
        public static ObjectValue CreateFatalError(string name, string message, ObjectValueFlags flags)
        {
            ObjectValue ob = new ObjectValue();

            ob.flags = flags | ObjectValueFlags.Error;
            ob.value = message;
            ob.name  = name;
            return(ob);
        }
Esempio n. 24
0
        public static ObjectValue CreateEvaluationException(EvaluationContext ctx, IObjectValueSource source, ObjectPath path, EvaluatorExceptionThrownException exception,
                                                            ObjectValueFlags flags = ObjectValueFlags.None)
        {
            var error = CreateError(source, path, exception.ExceptionTypeName, "Exception was thrown", flags);
            var exceptionReference = LiteralValueReference.CreateTargetObjectLiteral(ctx, "Exception", exception.Exception);
            var exceptionValue     = exceptionReference.CreateObjectValue(ctx.Options);

            error.children = new List <ObjectValue> {
                exceptionValue
            };
            return(error);
        }
Esempio n. 25
0
        public ObjectValue[] GetChildren(ObjectPath path, int index, int count, EvaluationOptions options)
        {
            List <ObjectValue> children = new List <ObjectValue>();

            session.SelectThread(threadId);

            if (Engine.Symbols.ScopeLocalSymbols == null)
            {
                return(children.ToArray());
            }

            DEW.DebugScopedSymbol parent = null;

            for (uint i = 0; i < Engine.Symbols.ScopeLocalSymbols.Symbols.Length; i++)
            {
                DEW.DebugScopedSymbol symbol = Engine.Symbols.ScopeLocalSymbols.Symbols[i];
                if (symbol.Name == path.LastName)
                {
                    parent = symbol;
                    break;
                }
            }

            if (parent == null || parent.ChildrenCount == 0)
            {
                return(children.ToArray());
            }

            for (uint i = 0; i < parent.ChildrenCount; i++)
            {
                DEW.DebugScopedSymbol child = parent.Children[i];

                string name     = child.Name;
                string typename = child.TypeName;
                string val      = child.TextValue;
                ulong  offset   = child.Offset;

                ObjectValue ov = symbolResolver.Resolve(offset, name, typename, val, child.Parent);
                if (ov == null)
                {
                    ObjectValueFlags flags = ObjectValueFlags.Variable;
                    ov = ObjectValue.CreatePrimitive(this, new ObjectPath(name), typename, new EvaluationResult(val), flags);
                }

                if (ov != null)
                {
                    children.Add(ov);
                }
            }

            return(children.ToArray());
        }
		public static ObjectValue CreateObject (IObjectValueSource source, ObjectPath path, string typeName, EvaluationResult value, ObjectValueFlags flags, ObjectValue[] children)
		{
			ObjectValue ob = Create (source, path, typeName);
			ob.path = path;
			ob.flags = flags | ObjectValueFlags.Object;
			ob.value = value.Value;
			ob.displayValue = value.DisplayValue;
			if (children != null) {
				ob.children = new List<ObjectValue> ();
				ob.children.AddRange (children);
			}
			return ob;
		}
		public PropertyValueReference (EvaluationContext ctx, PropertyInfoMirror property, object obj, TypeMirror declaringType, MethodMirror getter, Value[] indexerArgs): base (ctx)
		{
			this.declaringType = declaringType;
			this.indexerArgs = indexerArgs;
			this.property = property;
			this.getter = getter;
			this.obj = obj;

			var objectMirror = obj as ObjectMirror;
			if (objectMirror != null)
				EnsureContextHasDomain (objectMirror.Domain);

			flags = GetFlags (property, getter);
		}
Esempio n. 28
0
		public FieldReference (EvaluationContext ctx, CorValRef thisobj, CorType type, FieldInfo field, string vname, ObjectValueFlags vflags) : base (ctx)
		{
			this.thisobj = thisobj;
			this.type = type;
			this.field = field;
			this.vname = vname;
			if (field.IsStatic)
				this.thisobj = null;

			flags = vflags | GetFlags (field);

			loader = delegate {
				return ((CorValRef)Value).Val;
			};
		}
Esempio n. 29
0
        internal void UpdateFromTrace(string trace)
        {
            EvaluationResult res   = new EvaluationResult(trace);
            ObjectValueFlags flags = ObjectValueFlags.Primitive | ObjectValueFlags.Field;
            string           type  = "";

            if (value != null)
            {
                flags = value.Flags;
                type  = value.TypeName;
            }
            value     = ObjectValue.CreatePrimitive(null, new ObjectPath(Expression), type, res, flags);
            evaluated = true;
            NotifyChanged();
        }
Esempio n. 30
0
		public PropertyReference (EvaluationContext ctx, PropertyInfo prop, CorValRef thisobj, CorType declaringType, CorValRef[] index)
			: base (ctx)
		{
			this.prop = prop;
			this.declaringType = declaringType;
			this.module = declaringType.Class.Module;
			this.index = index;
			if (!prop.GetGetMethod (true).IsStatic)
				this.thisobj = thisobj;

			flags = GetFlags (prop);

			loader = delegate {
				return ((CorValRef)Value).Val;
			};
		}
		public FieldValueReference (EvaluationContext ctx, FieldInfoMirror field, object obj, TypeMirror declaringType, string vname, ObjectValueFlags vflags): base (ctx)
		{
			this.field = field;
			this.obj = obj;
			this.declaringType = declaringType;
			this.vname = vname;
			flags = vflags;

			if (field.IsStatic)
				this.obj = null;

			flags |= GetFlags (field);

			if (obj is PrimitiveValue)
				flags |= ObjectValueFlags.ReadOnly;
		}
Esempio n. 32
0
        public FieldReference(EvaluationContext ctx, CorValRef thisobj, CorType type, FieldInfo field, string vname, ObjectValueFlags vflags) : base(ctx)
        {
            this.thisobj = thisobj;
            this.type    = type;
            this.field   = field;
            this.vname   = vname;
            if (field.IsStatic)
            {
                this.thisobj = null;
            }

            flags = vflags | GetFlags(field);

            loader = delegate {
                return(((CorValRef)Value).Val);
            };
        }
Esempio n. 33
0
        public PropertyValueReference(EvaluationContext ctx, PropertyInfoMirror property, object obj, TypeMirror declaringType, MethodMirror getter, Value[] indexerArgs) : base(ctx)
        {
            this.declaringType = declaringType;
            this.indexerArgs   = indexerArgs;
            this.property      = property;
            this.getter        = getter;
            this.obj           = obj;

            var objectMirror = obj as ObjectMirror;

            if (objectMirror != null)
            {
                EnsureContextHasDomain(objectMirror.Domain);
            }

            flags = GetFlags(property, getter);
        }
        public ObjectValue Run(string name, ObjectValueFlags flags, ObjectEvaluatorDelegate evaluator)
        {
            string id;
            int    tid;

            lock (asyncCallbacks) {
                tid = asyncCounter++;
                id  = tid.ToString();
            }

            ObjectValue val  = null;
            bool        done = runner.Run(delegate {
                if (tid >= cancelTimestamp)
                {
                    var session = Session;
                    if (session == null || (flags == ObjectValueFlags.EvaluatingGroup))
                    {
                        // Cannot report timing if session is null. If a group is being
                        // evaluated then individual timings are not possible and must
                        // be done elsewhere.
                        val = evaluator();
                    }
                    else
                    {
                        using (var timer = session.EvaluationStats.StartTimer(name)) {
                            val = evaluator();
                            timer.Stop(val);
                        }
                    }
                }
            },
                                          delegate {
                if (tid >= cancelTimestamp)
                {
                    OnEvaluationDone(id, val);
                }
            });

            if (done)
            {
                // 'val' may be null if the timed evaluator is disposed while evaluating
                return(val ?? ObjectValue.CreateUnknown(name));
            }

            return(ObjectValue.CreateEvaluating(this, new ObjectPath(id, name), flags));
        }
Esempio n. 35
0
        public PropertyValueReference(EvaluationContext ctx, PropertyDefinition prop, CorValRef thisobj, CorDebugType declaringType, CorValRef[] index)
            : base(ctx)
        {
            this.prop          = prop;
            this.declaringType = declaringType;
            this.module        = declaringType.Class.Assembly;
            this.index         = index;
            if (!prop.GetMethod.IsStatic)
            {
                this.thisobj = thisobj;
            }

            flags = GetFlags(prop);

            loader = delegate {
                return(((CorValRef)Value).Val);
            };
        }
Esempio n. 36
0
        public ObjectValue[] GetAllLocals(int frameIndex, EvaluationOptions options)
        {
            session.RunCommand(true, "vars");
            List <ObjectValue> locals = new List <ObjectValue> ();

            lock (syncLock) {
                foreach (string varName in session.lastResult.vars)
                {
                    ObjectValue      val;
                    ObjectValueFlags flags = ObjectValueFlags.Variable;
                    val      = ObjectValue.CreatePrimitive(this, new ObjectPath(varName), "dummyInt", new EvaluationResult("test_val"), flags);
                    val.Name = varName;
                    locals.Add(val);
                }
            }

            return(locals.ToArray());
        }
        public PropertyValueReference(EvaluationContext ctx, PropertyInfoMirror property, object obj, TypeMirror declaringType, MethodMirror getter, Value[] indexerArgs) : base(ctx)
        {
            this.property      = property;
            this.obj           = obj;
            this.declaringType = declaringType;
            this.indexerArgs   = indexerArgs;

            flags = ObjectValueFlags.Property;
            if (property.GetSetMethod(true) == null)
            {
                flags |= ObjectValueFlags.ReadOnly;
            }

            if (getter.IsStatic)
            {
                flags |= ObjectValueFlags.Global;
            }
            if (getter.IsPublic)
            {
                flags |= ObjectValueFlags.Public;
            }
            else if (getter.IsPrivate)
            {
                flags |= ObjectValueFlags.Private;
            }
            else if (getter.IsFamily)
            {
                flags |= ObjectValueFlags.Protected;
            }
            else if (getter.IsFamilyAndAssembly)
            {
                flags |= ObjectValueFlags.Internal;
            }
            else if (getter.IsFamilyOrAssembly)
            {
                flags |= ObjectValueFlags.InternalProtected;
            }

            if (property.DeclaringType.IsValueType)
            {
                flags |= ObjectValueFlags.ReadOnly;                 // Setting property values on structs is not supported by sdb
            }
        }
Esempio n. 38
0
        internal static ObjectValueFlags GetFlags(PropertyInfo prop)
        {
            ObjectValueFlags flags = ObjectValueFlags.Property;
            MethodInfo       mi    = prop.GetGetMethod(true) ?? prop.GetSetMethod(true);

            if (prop.GetSetMethod(true) == null)
            {
                flags |= ObjectValueFlags.ReadOnly;
            }

            if (mi.IsStatic)
            {
                flags |= ObjectValueFlags.Global;
            }

            if (mi.IsFamilyAndAssembly)
            {
                flags |= ObjectValueFlags.Internal;
            }
            else if (mi.IsFamilyOrAssembly)
            {
                flags |= ObjectValueFlags.InternalProtected;
            }
            else if (mi.IsFamily)
            {
                flags |= ObjectValueFlags.Protected;
            }
            else if (mi.IsPublic)
            {
                flags |= ObjectValueFlags.Public;
            }
            else
            {
                flags |= ObjectValueFlags.Private;
            }

            if (!prop.CanWrite)
            {
                flags |= ObjectValueFlags.ReadOnly;
            }

            return(flags);
        }
		internal static ObjectValueFlags GetFlags (FieldInfoMirror field)
		{
			var flags = ObjectValueFlags.Field;

			if (field.IsStatic)
				flags |= ObjectValueFlags.Global;

			if (field.IsPublic)
				flags |= ObjectValueFlags.Public;
			else if (field.IsPrivate)
				flags |= ObjectValueFlags.Private;
			else if (field.IsFamily)
				flags |= ObjectValueFlags.Protected;
			else if (field.IsFamilyAndAssembly)
				flags |= ObjectValueFlags.Internal;
			else if (field.IsFamilyOrAssembly)
				flags |= ObjectValueFlags.InternalProtected;

			return flags;
		}
Esempio n. 40
0
        internal static ObjectValueFlags GetFlags(PropertyInfo property, MethodInfo getter)
        {
            var flags = ObjectValueFlags.Property;

            if (property.GetSetMethod(true) == null)
            {
                flags |= ObjectValueFlags.ReadOnly;
            }

            if (getter.IsStatic)
            {
                flags |= ObjectValueFlags.Global;
            }

            if (getter.IsPublic)
            {
                flags |= ObjectValueFlags.Public;
            }
            else if (getter.IsPrivate)
            {
                flags |= ObjectValueFlags.Private;
            }
            else if (getter.IsFamily)
            {
                flags |= ObjectValueFlags.Protected;
            }
            else if (getter.IsFamilyAndAssembly)
            {
                flags |= ObjectValueFlags.Internal;
            }
            else if (getter.IsFamilyOrAssembly)
            {
                flags |= ObjectValueFlags.InternalProtected;
            }

            if (property.DeclaringType.IsValueType)
            {
                flags |= ObjectValueFlags.ReadOnly;                 // Setting property values on structs is not supported by sdb
            }
            return(flags);
        }
Esempio n. 41
0
        internal static ObjectValueFlags GetFlags(PropertyDefinition prop)
        {
            ObjectValueFlags flags = ObjectValueFlags.Property;
            var mi = prop.GetMethod ?? prop.SetMethod;

            if (prop.SetMethod == null)
            {
                flags |= ObjectValueFlags.ReadOnly;
            }

            if (mi.IsStatic)
            {
                flags |= ObjectValueFlags.Global;
            }

            if (mi.IsFamilyAndAssembly)
            {
                flags |= ObjectValueFlags.Internal;
            }
            else if (mi.IsFamilyOrAssembly)
            {
                flags |= ObjectValueFlags.InternalProtected;
            }
            else if (mi.IsFamily)
            {
                flags |= ObjectValueFlags.Protected;
            }
            else if (mi.IsPublic)
            {
                flags |= ObjectValueFlags.Public;
            }
            else
            {
                flags |= ObjectValueFlags.Private;
            }

//			if (!prop.can)
//				flags |= ObjectValueFlags.ReadOnly;

            return(flags);
        }
		public FieldValueReference (EvaluationContext ctx, FieldInfoMirror field, object obj, TypeMirror declaringType, string vname, ObjectValueFlags vflags, FieldReferenceBatch batch = null): base (ctx)
		{
			this.field = field;
			this.obj = obj;
			this.declaringType = declaringType;
			this.vname = vname;
			this.batch = batch;
			flags = vflags;

			if (field.IsStatic)
				this.obj = null;

			var objectMirror = obj as ObjectMirror;
			if (objectMirror != null)
				EnsureContextHasDomain (objectMirror.Domain);

			flags |= GetFlags (field);

			if (obj is PrimitiveValue)
				flags |= ObjectValueFlags.ReadOnly;
		}
Esempio n. 43
0
		public PropertyReference (EvaluationContext ctx, PropertyInfo prop, CorValRef thisobj, CorType declaringType, CorValRef[] index)
			: base (ctx)
		{
			this.prop = prop;
			this.declaringType = declaringType;
			if (declaringType.Type == CorElementType.ELEMENT_TYPE_ARRAY ||
			    declaringType.Type == CorElementType.ELEMENT_TYPE_SZARRAY) {
				this.module = ((CorType)((CorEvaluationContext)ctx).Adapter.GetType (ctx, "System.Object")).Class.Module;
			} else {
				this.module = declaringType.Class.Module;
			}
			this.index = index;
			if (!prop.GetGetMethod (true).IsStatic)
				this.thisobj = thisobj;

			flags = GetFlags (prop);

			loader = delegate {
				return ((CorValRef)Value).Val;
			};
		}
        public static string GetIcon(ObjectValueFlags flags)
        {
            if ((flags & ObjectValueFlags.Field) != 0 && (flags & ObjectValueFlags.ReadOnly) != 0)
            {
                return("md-literal");
            }

            string source;
            string stic = (flags & ObjectValueFlags.Global) != 0 ? "static-" : string.Empty;

            switch (flags & ObjectValueFlags.OriginMask)
            {
            case ObjectValueFlags.Property: source = "property"; break;

            case ObjectValueFlags.Type: source = "class"; stic = string.Empty; break;

            case ObjectValueFlags.Literal: return("md-literal");

            case ObjectValueFlags.Namespace: return("md-name-space");

            case ObjectValueFlags.Group: return("md-open-resource-folder");

            default: source = "field"; break;
            }
            string access;

            switch (flags & ObjectValueFlags.AccessMask)
            {
            case ObjectValueFlags.Private: access = "private-"; break;

            case ObjectValueFlags.Internal: access = "internal-"; break;

            case ObjectValueFlags.InternalProtected:
            case ObjectValueFlags.Protected: access = "protected-"; break;

            default: access = string.Empty; break;
            }

            return("md-" + access + stic + source);
        }
		public ObjectValue Run (string name, ObjectValueFlags flags, ObjectEvaluatorDelegate evaluator)
		{
			string id;
			int tid;
			lock (asyncCallbacks) {
				tid = asyncCounter++;
				id = tid.ToString ();
			}
			
			ObjectValue val = null;
			bool done = runner.Run (delegate {
					if (tid >= cancelTimestamp)
						val = evaluator ();
			},
			delegate {
				if (tid >= cancelTimestamp)
					OnEvaluationDone (id, val);
			});
			
			if (done)
				return val;
			else
				return ObjectValue.CreateEvaluating (this, new ObjectPath (id, name), flags);
		}
Esempio n. 46
0
		public FieldValueReference (EvaluationContext ctx, FieldInfoMirror field, object obj, TypeMirror declaringType, string vname, ObjectValueFlags vflags): base (ctx)
		{
			this.field = field;
			this.obj = obj;
			this.declaringType = declaringType;
			this.vname = vname;
			flags = vflags;
			if (field.IsStatic) {
				flags |= ObjectValueFlags.Global;
				this.obj = null;
			}
			if (field.IsPublic)
				flags |= ObjectValueFlags.Public;
			else if (field.IsPrivate)
				flags |= ObjectValueFlags.Private;
			else if (field.IsFamily)
				flags |= ObjectValueFlags.Protected;
			else if (field.IsFamilyAndAssembly)
				flags |= ObjectValueFlags.Internal;
			else if (field.IsFamilyOrAssembly)
				flags |= ObjectValueFlags.InternalProtected;
			if (obj is PrimitiveValue)
				flags |= ObjectValueFlags.ReadOnly;
		}
Esempio n. 47
0
		protected virtual ObjectValue CreateObjectValueImpl (EvaluationContext ctx, Mono.Debugging.Backend.IObjectValueSource source, ObjectPath path, object obj, ObjectValueFlags flags)
		{
			string typeName = obj != null ? GetValueTypeName (ctx, obj) : "";

			if (obj == null || IsNull (ctx, obj)) {
				return ObjectValue.CreateNullObject (source, path, GetDisplayTypeName (typeName), flags);
			}
			else if (IsPrimitive (ctx, obj) || IsEnum (ctx,obj)) {
				return ObjectValue.CreatePrimitive (source, path, GetDisplayTypeName (typeName), ctx.Evaluator.TargetObjectToExpression (ctx, obj), flags);
			}
			else if (IsArray (ctx, obj)) {
				return ObjectValue.CreateObject (source, path, GetDisplayTypeName (typeName), ctx.Evaluator.TargetObjectToExpression (ctx, obj), flags, null);
			}
			else {
				TypeDisplayData tdata = GetTypeDisplayData (ctx, GetValueType (ctx, obj));
				
				EvaluationResult tvalue;
				if (!string.IsNullOrEmpty (tdata.ValueDisplayString) && ctx.Options.AllowDisplayStringEvaluation)
					tvalue = new EvaluationResult (EvaluateDisplayString (ctx, obj, tdata.ValueDisplayString));
				else
					tvalue = ctx.Evaluator.TargetObjectToExpression (ctx, obj);
				
				string tname;
				if (!string.IsNullOrEmpty (tdata.TypeDisplayString) && ctx.Options.AllowDisplayStringEvaluation)
					tname = EvaluateDisplayString (ctx, obj, tdata.TypeDisplayString);
				else
					tname = GetDisplayTypeName (typeName);
				
				ObjectValue oval = ObjectValue.CreateObject (source, path, tname, tvalue, flags, null);
				if (!string.IsNullOrEmpty (tdata.NameDisplayString) && ctx.Options.AllowDisplayStringEvaluation)
					oval.Name = EvaluateDisplayString (ctx, obj, tdata.NameDisplayString);
				return oval;
			}
		}
Esempio n. 48
0
		public ObjectValue CreateObjectValueAsync (string name, ObjectValueFlags flags, ObjectEvaluatorDelegate evaluator)
		{
			return asyncEvaluationTracker.Run (name, flags, evaluator);
		}
		public static ObjectValue CreatePrimitive (IObjectValueSource source, ObjectPath path, string typeName, EvaluationResult value, ObjectValueFlags flags)
		{
			ObjectValue ob = Create (source, path, typeName);
			ob.flags = flags | ObjectValueFlags.Primitive;
			ob.value = value.Value;
			ob.displayValue = value.DisplayValue;
			return ob;
		}
		public static ObjectValue CreateArray (IObjectValueSource source, ObjectPath path, string typeName, int arrayCount, ObjectValueFlags flags, ObjectValue[] children)
		{
			ObjectValue ob = Create (source, path, typeName);
			ob.arrayCount = arrayCount;
			ob.flags = flags | ObjectValueFlags.Array;
			ob.value = "[" + arrayCount + "]";
			if (children != null && children.Length > 0) {
				ob.children = new List<ObjectValue> ();
				ob.children.AddRange (children);
			}
			return ob;
		}
		public static ObjectValue CreateError (IObjectValueSource source, ObjectPath path, string typeName, string value, ObjectValueFlags flags)
		{
			ObjectValue ob = Create (source, path, typeName);
			ob.flags = flags | ObjectValueFlags.Error;
			ob.value = value;
			return ob;
		}
		public static ObjectValue CreateImplicitNotSupported (IObjectValueSource source, ObjectPath path, string typeName, ObjectValueFlags flags)
		{
			return CreateNotSupported (source, path, typeName, "Implicit evaluation is disabled", flags);
		}
		public static ObjectValue CreateNotSupported (IObjectValueSource source, ObjectPath path, string typeName, string message, ObjectValueFlags flags)
		{
			ObjectValue ob = Create (source, path, typeName);
			ob.flags = flags | ObjectValueFlags.NotSupported;
			ob.value = message;
			return ob;
		}
		public static ObjectValue CreateNullObject (IObjectValueSource source, ObjectPath path, string typeName, ObjectValueFlags flags)
		{
			ObjectValue ob = Create (source, path, typeName);
			ob.flags = flags | ObjectValueFlags.Object;
			ob.value = "(null)";
			ob.isNull = true;
			return ob;
		}
		public static ObjectValue CreateFatalError (string name, string message, ObjectValueFlags flags)
		{
			ObjectValue ob = new ObjectValue ();
			ob.flags = flags | ObjectValueFlags.Error;
			ob.value = message;
			ob.name = name;
			return ob;
		}
		public static ObjectValue CreateNullObject (IObjectValueSource source, string name, string typeName, ObjectValueFlags flags)
		{
			return CreateNullObject (source, new ObjectPath (name), typeName, flags);
		}
		public static ObjectValue CreateEvaluating (IObjectValueUpdater updater, ObjectPath path, ObjectValueFlags flags)
		{
			ObjectValue ob = Create (null, path, null);
			ob.updater = updater;
			ob.path = path;
			ob.flags = flags | ObjectValueFlags.Evaluating;
			return ob;
		}
		public static ObjectValue CreateObject (IObjectValueSource source, ObjectPath path, string typeName, string value, ObjectValueFlags flags, ObjectValue[] children)
		{
			return CreateObject (source, path, typeName, new EvaluationResult (value), flags, children);
		}
		internal void UpdateFrom (ObjectValue val, bool notify)
		{
			lock (this) {
				arrayCount = val.arrayCount;
				if (val.name != null)
					name = val.name;
				value = val.value;
				displayValue = val.displayValue;
				typeName = val.typeName;
				flags = val.flags;
				source = val.source;
				children = val.children;
				path = val.path;
				updater = val.updater;
				ConnectCallbacks (parentFrame, this);
				if (evaluatedEvent != null)
					evaluatedEvent.Set ();
				if (notify && valueChanged != null)
					valueChanged (this, EventArgs.Empty);
			}
		}
		public bool HasFlag (ObjectValueFlags flag)
		{
			return (flags & flag) != 0;
		}