public VariableReference (EvaluationContext ctx, CorValRef var, string name, DC.ObjectValueFlags flags) : base (ctx) { this.flags = flags; this.var = var; this.name = name; }
static string Resolve (this ComposedType type, EvaluationContext ctx, List<object> args) { string name; if (type.HasNullableSpecifier) { args.Insert (0, type.BaseType.Resolve (ctx)); name = "System.Nullable`1"; } else { name = type.BaseType.Resolve (ctx, args); } if (type.PointerRank > 0) name += new string ('*', type.PointerRank); if (type.ArraySpecifiers.Count > 0) { foreach (var spec in type.ArraySpecifiers) { if (spec.Dimensions > 1) name += "[" + new string (',', spec.Dimensions - 1) + "]"; else name += "[]"; } } return name; }
public VariableReference (EvaluationContext ctx, TargetVariable var, DC.ObjectValueFlags flags): base (ctx) { this.flags = flags; this.var = var; if (!var.CanWrite) flags |= DC.ObjectValueFlags.ReadOnly; }
public TypeValueReference (EvaluationContext ctx, object type) : base (ctx) { this.type = type; fullName = ctx.Adapter.GetDisplayTypeName (ctx, type); name = GetTypeName (fullName); }
public FieldReference (EvaluationContext ctx, TargetStructObject thisobj, TargetType type, TargetFieldInfo field): base (ctx) { this.type = type; this.field = field; if (!field.IsStatic) this.thisobj = thisobj; }
public BaseTypeViewSource (EvaluationContext ctx, IObjectSource objectSource, object type, object obj) { this.ctx = ctx; this.type = type; this.obj = obj; this.objectSource = objectSource; }
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 }
public override void CopyFrom(Mono.Debugging.Evaluation.EvaluationContext gctx) { base.CopyFrom(gctx); MdbEvaluationContext ctx = (MdbEvaluationContext)gctx; thread = ctx.thread; frame = ctx.frame; }
public static LiteralValueReference CreateObjectLiteral (EvaluationContext ctx, string name, object value) { LiteralValueReference val = new LiteralValueReference (ctx); val.name = name; val.objValue = value; val.objLiteral = true; return val; }
public static ObjectValue CreateRawView (EvaluationContext ctx, IObjectSource objectSource, object obj) { RawViewSource src = new RawViewSource (ctx, objectSource, obj); src.Connect (); ObjectValue val = ObjectValue.CreateObject (src, new ObjectPath ("Raw View"), "", "", ObjectValueFlags.Group|ObjectValueFlags.ReadOnly|ObjectValueFlags.NoRefresh, null); val.ChildSelector = ""; return val; }
public FilteredMembersSource (EvaluationContext ctx, IObjectSource objectSource, object type, object obj, BindingFlags bindingFlags) { this.ctx = ctx; this.obj = obj; this.type = type; this.bindingFlags = bindingFlags; this.objectSource = objectSource; }
public string TargetObjectToString (EvaluationContext ctx, object obj) { object res = ctx.Adapter.TargetObjectToObject (ctx, obj); if (res == null) return null; else return res.ToString (); }
static ObjectValue CreateNode (EvaluationContext ctx, IObjectSource objectSource, object type, object obj, BindingFlags bindingFlags, string label) { FilteredMembersSource src = new FilteredMembersSource (ctx, objectSource, type, obj, bindingFlags); src.Connect (); ObjectValue val = ObjectValue.CreateObject (src, new ObjectPath (label), "", "", ObjectValueFlags.Group|ObjectValueFlags.ReadOnly|ObjectValueFlags.NoRefresh, null); val.ChildSelector = ""; return val; }
public virtual EvaluationResult ToExpression (EvaluationContext ctx, object obj) { if (obj == null) return new EvaluationResult ("null"); else if (obj is IntPtr) { IntPtr p = (IntPtr) obj; return new EvaluationResult ("0x" + p.ToInt64 ().ToString ("x")); } else if (obj is char) { char c = (char) obj; string str; if (c == '\'') str = @"'\''"; else if (c == '"') str = "'\"'"; else str = EscapeString ("'" + c + "'"); return new EvaluationResult (str, ((int) c) + " " + str); } else if (obj is string) { string val = "\"" + EscapeString ((string) obj) + "\""; string display = val; if (val.Length > EllipsizeLength + 2) display = "\"" + EscapeString ((string) obj, EllipsizeLength) + "\""; return new EvaluationResult (val, display); } else if (obj is bool) return new EvaluationResult (((bool)obj) ? "true" : "false"); else if (obj is decimal) return new EvaluationResult (((decimal)obj).ToString (System.Globalization.CultureInfo.InvariantCulture)); else if (obj is EvaluationResult) return (EvaluationResult) obj; if (ctx.Options.IntegerDisplayFormat == IntegerDisplayFormat.Hexadecimal) { string fval = null; if (obj is sbyte) fval = ((sbyte)obj).ToString ("x2"); else if (obj is int) fval = ((int)obj).ToString ("x4"); else if (obj is short) fval = ((short)obj).ToString ("x8"); else if (obj is long) fval = ((long)obj).ToString ("x16"); else if (obj is byte) fval = ((byte)obj).ToString ("x2"); else if (obj is uint) fval = ((uint)obj).ToString ("x4"); else if (obj is ushort) fval = ((ushort)obj).ToString ("x8"); else if (obj is ulong) fval = ((ulong)obj).ToString ("x16"); if (fval != null) return new EvaluationResult ("0x" + fval); } return new EvaluationResult (obj.ToString ()); }
public static ObjectValue CreateBaseTypeView (EvaluationContext ctx, IObjectSource objectSource, object type, object obj) { BaseTypeViewSource src = new BaseTypeViewSource (ctx, objectSource, type, obj); src.Connect (); string tname = ctx.Adapter.GetDisplayTypeName (ctx, type); ObjectValue val = ObjectValue.CreateObject (src, new ObjectPath ("base"), tname, "{" + tname + "}", ObjectValueFlags.Type|ObjectValueFlags.ReadOnly|ObjectValueFlags.NoRefresh, null); val.ChildSelector = ""; return val; }
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); }
public override void CopyFrom (EvaluationContext ctx) { base.CopyFrom (ctx); SoftEvaluationContext other = (SoftEvaluationContext) ctx; frame = other.frame; stackVersion = other.stackVersion; Thread = other.Thread; session = other.session; }
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); } }
public override void CopyFrom (EvaluationContext ctx) { base.CopyFrom (ctx); frame = ((CorEvaluationContext) ctx).frame; frameIndex = ((CorEvaluationContext) ctx).frameIndex; evalTimestamp = ((CorEvaluationContext) ctx).evalTimestamp; Thread = ((CorEvaluationContext) ctx).Thread; Session = ((CorEvaluationContext) ctx).Session; }
public RemoteRawValue(EvaluationContext gctx, IObjectSource source, object targetObject) { this.ctx = gctx.Clone (); ctx.Options.AllowTargetInvoke = true; ctx.Options.AllowMethodEvaluation = true; this.targetObject = targetObject; this.source = source; Connect (); }
public ArrayElementGroup (EvaluationContext ctx, ICollectionAdaptor array, int[] baseIndices, int firstIndex, int lastIndex) { this.array = array; this.ctx = ctx; this.bounds = array.GetDimensions (); this.baseIndices = baseIndices; this.firstIndex = firstIndex; this.lastIndex = lastIndex; }
public static LiteralValueReference CreateTargetObjectLiteral (EvaluationContext ctx, string name, object value) { LiteralValueReference val = new LiteralValueReference (ctx); val.name = name; val.value = value; val.type = ctx.Adapter.GetValueType (ctx, value); val.objCreated = true; return val; }
Value NormalizeValue (EvaluationContext ctx, Value value) { if (variable.Type.IsPointer) { long addr = (long) ((PrimitiveValue) value).Value; return new PointerValue (value.VirtualMachine, variable.Type, addr); } return ctx.Adapter.IsNull (ctx, value) ? null : value; }
public static LiteralValueReference CreateVoidReturnLiteral (EvaluationContext ctx, string name) { LiteralValueReference val = new LiteralValueReference (ctx); val.name = name; val.value = val.objValue = new EvaluationResult ("No return value."); val.type = typeof (EvaluationResult); val.objLiteral = true; val.objCreated = true; return val; }
public NamespaceValueReference (EvaluationContext ctx, string name) : base (ctx) { namspace = name; int i = namspace.LastIndexOf ('.'); if (i != -1) this.name = namspace.Substring (i+1); else this.name = namspace; }
public string TargetObjectToString (EvaluationContext ctx, object obj) { object res = ctx.Adapter.TargetObjectToObject (ctx, obj); if (res == null) return null; if (res is EvaluationResult) return ((EvaluationResult) res).DisplayValue; else return res.ToString (); }
static string Resolve (this AstType type, EvaluationContext ctx, List<object> args) { if (type is PrimitiveType) return Resolve ((PrimitiveType) type, ctx, args); else if (type is ComposedType) return Resolve ((ComposedType) type, ctx, args); else if (type is MemberType) return Resolve ((MemberType) type, ctx, args); else if (type is SimpleType) return Resolve ((SimpleType) type, ctx, args); return null; }
public FieldReference (EvaluationContext ctx, CorValRef thisobj, CorType type, FieldInfo field) : base (ctx) { this.thisobj = thisobj; this.type = type; this.field = field; if (!field.IsStatic) this.thisobj = thisobj; loader = delegate { return ((CorValRef)Value).Val; }; }
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; loader = delegate { return ((CorValRef)Value).Val; }; }
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 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; }; }
public virtual ValidationResult ValidateExpression(EvaluationContext ctx, string expression) { return(new ValidationResult(true, null)); }
public ArrayValueReference(EvaluationContext ctx, object arr, int[] indices) : base(ctx) { this.indices = indices; adaptor = ctx.Adapter.CreateArrayAdaptor(ctx, arr); }
public virtual EvaluationResult ToExpression(EvaluationContext ctx, object obj) { if (obj == null) { return(new EvaluationResult("null")); } else if (obj is IntPtr) { IntPtr p = (IntPtr)obj; return(new EvaluationResult("0x" + p.ToInt64().ToString("x"))); } else if (obj is char) { char c = (char)obj; string str; if (c == '\'') { str = @"'\''"; } else if (c == '"') { str = "'\"'"; } else { str = EscapeString("'" + c + "'"); } return(new EvaluationResult(str, ((int)c) + " " + str)); } else if (obj is string) { return(new EvaluationResult("\"" + EscapeString((string)obj) + "\"")); } else if (obj is bool) { return(new EvaluationResult(((bool)obj) ? "true" : "false")); } else if (obj is decimal) { return(new EvaluationResult(((decimal)obj).ToString(System.Globalization.CultureInfo.InvariantCulture))); } else if (obj is EvaluationResult) { return((EvaluationResult)obj); } if (ctx.Options.IntegerDisplayFormat == IntegerDisplayFormat.Hexadecimal) { string fval = null; if (obj is sbyte) { fval = ((sbyte)obj).ToString("x2"); } else if (obj is int) { fval = ((int)obj).ToString("x4"); } else if (obj is short) { fval = ((short)obj).ToString("x8"); } else if (obj is long) { fval = ((long)obj).ToString("x16"); } else if (obj is byte) { fval = ((byte)obj).ToString("x2"); } else if (obj is uint) { fval = ((uint)obj).ToString("x4"); } else if (obj is ushort) { fval = ((ushort)obj).ToString("x8"); } else if (obj is ulong) { fval = ((ulong)obj).ToString("x16"); } if (fval != null) { return(new EvaluationResult("0x" + fval)); } } return(new EvaluationResult(obj.ToString())); }
public virtual IEnumerable <ValueReference> GetParameters(EvaluationContext ctx) { return(ctx.Adapter.GetParameters(ctx)); }
LiteralValueReference(EvaluationContext ctx) : base(ctx) { }
public virtual void CopyFrom(EvaluationContext ctx) { options = ctx.options.Clone(); Evaluator = ctx.Evaluator; Adapter = ctx.Adapter; }
public ExpressionValueSource(EvaluationContext ctx) { this.ctx = ctx; Connect(); }
public ObjectValue[] GetChildren(ObjectPath path, int firstItemIndex, int count, EvaluationOptions options) { EvaluationContext cctx = ctx.WithOptions(options); if (path.Length > 1) { // Looking for children of an array element int[] idx = StringToIndices(path [1]); object obj = array.GetElement(idx); return(cctx.Adapter.GetObjectValueChildren(cctx, new ArrayObjectSource(array, path[1]), obj, firstItemIndex, count)); } int lowerBound; int upperBound; bool isLastDimension; if (bounds.Length > 1) { int rank = baseIndices.Length; lowerBound = 0; upperBound = bounds [rank] - 1; isLastDimension = rank == bounds.Length - 1; } else { lowerBound = 0; upperBound = bounds [0] - 1; isLastDimension = true; } int len; int initalIndex; if (!IsRange) { initalIndex = lowerBound; len = upperBound + 1; } else { initalIndex = firstIndex; len = lastIndex - firstIndex + 1; } if (firstItemIndex == -1) { firstItemIndex = 0; count = len; } // Make sure the group doesn't have too many elements. If so, divide int div = 1; while (len / div > MaxChildCount) { div *= 10; } if (div == 1 && isLastDimension) { // Return array elements ObjectValue[] values = new ObjectValue [count]; ObjectPath newPath = new ObjectPath("this"); int[] curIndex = new int [baseIndices.Length + 1]; Array.Copy(baseIndices, curIndex, baseIndices.Length); string curIndexStr = IndicesToString(baseIndices); if (baseIndices.Length > 0) { curIndexStr += ","; } for (int n = 0; n < values.Length; n++) { int index = n + initalIndex + firstItemIndex; string sidx = curIndexStr + index.ToString(); ObjectValue val; string ename = "[" + sidx.Replace(",", ", ") + "]"; if (index > upperBound) { val = ObjectValue.CreateUnknown(sidx); } else { curIndex [curIndex.Length - 1] = index; object elem = array.GetElement(curIndex); val = cctx.Adapter.CreateObjectValue(cctx, this, newPath.Append(sidx), elem, ObjectValueFlags.ArrayElement); if (elem != null && !cctx.Adapter.IsNull(cctx, elem)) { TypeDisplayData tdata = cctx.Adapter.GetTypeDisplayData(cctx, cctx.Adapter.GetValueType(cctx, elem)); if (!string.IsNullOrEmpty(tdata.NameDisplayString)) { ename = cctx.Adapter.EvaluateDisplayString(cctx, elem, tdata.NameDisplayString); } } } val.Name = ename; values [n] = val; } return(values); } else if (!isLastDimension && div == 1) { // Return an array element group for each index List <ObjectValue> list = new List <ObjectValue> (); for (int i = 0; i < count; i++) { int index = i + initalIndex + firstItemIndex; ObjectValue val; // This array must be created at every call to avoid sharing // changes with all array groups int[] curIndex = new int [baseIndices.Length + 1]; Array.Copy(baseIndices, curIndex, baseIndices.Length); curIndex [curIndex.Length - 1] = index; if (index > upperBound) { val = ObjectValue.CreateUnknown(""); } else { ArrayElementGroup grp = new ArrayElementGroup(cctx, array, curIndex); val = grp.CreateObjectValue(); } list.Add(val); } return(list.ToArray()); } else { // Too many elements. Split the array. // Don't make divisions of 10 elements, min is 100 if (div == 10) { div = 100; } // Create the child groups int i = initalIndex + firstItemIndex; len += i; List <ObjectValue> list = new List <ObjectValue> (); while (i < len) { int end = i + div - 1; if (end > len) { end = len - 1; } ArrayElementGroup grp = new ArrayElementGroup(cctx, array, baseIndices, i, end); list.Add(grp.CreateObjectValue()); i += div; } return(list.ToArray()); } }
public ArrayElementGroup(EvaluationContext ctx, ICollectionAdaptor array) : this(ctx, array, new int [0]) { }
public ArrayElementGroup(EvaluationContext ctx, ICollectionAdaptor array, int[] baseIndices) : this(ctx, array, baseIndices, 0, -1) { }
public ValueReference(EvaluationContext ctx) { this.ctx = ctx; originalOptions = ctx.Options; }
public ValueReference Evaluate(EvaluationContext ctx, string exp) { return(Evaluate(ctx, exp, null)); }
public virtual ValueReference GetCurrentException(EvaluationContext ctx) { return(ctx.Adapter.GetCurrentException(ctx)); }
protected ValueReference(EvaluationContext ctx) { originalOptions = ctx.Options; Context = ctx; }
public virtual ValueReference GetThisReference(EvaluationContext ctx) { return(ctx.Adapter.GetThisReference(ctx)); }
public virtual void SetValue(EvaluationContext ctx, object value) { Value = value; }
public virtual IEnumerable <ValueReference> GetLocalVariables(EvaluationContext ctx) { return(ctx.Adapter.GetLocalVariables(ctx)); }
public virtual object GetValue(EvaluationContext ctx) { return(Value); }
public NullValueReference(EvaluationContext ctx, object type) : base(ctx) { this.type = type; }
public EvaluationResult TargetObjectToExpression(EvaluationContext ctx, object obj) { return(ToExpression(ctx, ctx.Adapter.TargetObjectToObject(ctx, obj))); }