protected virtual void SetRawValue(ObjectPath path, object value, EvaluationOptions options) { var ctx = GetContext(options); ValueModificationUtil.ModifyValueFromRaw(ctx, value, val => SetValue(ctx, val)); }
public static ObjectValue GetChildSync(this ObjectValue val, string name, EvaluationOptions ops) { var result = val.GetChild(name, ops); return(result != null?result.Sync() : null); }
public override ObjectValue[] GetChildren(ObjectPath path, int index, int count, EvaluationOptions options) { EvaluationContext ctx = GetContext(options); try { List <ObjectValue> list = new List <ObjectValue> (); BindingFlags flattenFlag = options.FlattenHierarchy ? (BindingFlags)0 : BindingFlags.DeclaredOnly; BindingFlags flags = BindingFlags.Static | BindingFlags.Public | flattenFlag; bool groupPrivateMembers = options.GroupPrivateMembers && (options.GroupUserPrivateMembers || ctx.Adapter.IsExternalType(ctx, type)); if (!groupPrivateMembers) { flags |= BindingFlags.NonPublic; } TypeDisplayData tdata = ctx.Adapter.GetTypeDisplayData(ctx, type); object tdataType = type; foreach (ValueReference val in ctx.Adapter.GetMembersSorted(ctx, this, type, null, flags)) { object decType = val.DeclaringType; if (decType != null && decType != tdataType) { tdataType = decType; tdata = ctx.Adapter.GetTypeDisplayData(ctx, decType); } DebuggerBrowsableState state = tdata.GetMemberBrowsableState(val.Name); if (state == DebuggerBrowsableState.Never) { continue; } ObjectValue oval = val.CreateObjectValue(options); list.Add(oval); } List <ObjectValue> nestedTypes = new List <ObjectValue> (); foreach (object t in ctx.Adapter.GetNestedTypes(ctx, type)) { nestedTypes.Add(new TypeValueReference(ctx, t).CreateObjectValue(options)); } nestedTypes.Sort(delegate(ObjectValue v1, ObjectValue v2) { return(v1.Name.CompareTo(v2.Name)); }); list.AddRange(nestedTypes); if (groupPrivateMembers) { list.Add(FilteredMembersSource.CreateNonPublicsNode(ctx, this, type, null, BindingFlags.NonPublic | BindingFlags.Static | flattenFlag)); } if (!options.FlattenHierarchy) { object baseType = ctx.Adapter.GetBaseType(ctx, type, false); if (baseType != null) { TypeValueReference baseRef = new TypeValueReference(ctx, baseType); ObjectValue baseVal = baseRef.CreateObjectValue(false); baseVal.Name = "base"; list.Insert(0, baseVal); } } return(list.ToArray()); } catch (Exception ex) { Console.WriteLine(ex); ctx.WriteDebuggerOutput(ex.Message); return(new ObjectValue [0]); } }
public ObjectValue CreateObjectValue(bool withTimeout, EvaluationOptions options) { options = options.Clone(); options.EllipsizeStrings = false; options.AllowTargetInvoke = true; ctx = ctx.WithOptions(options); string type = ctx.Adapter.GetValueTypeName(ctx, Exception.ObjectValue); var excInstance = Exception.CreateObjectValue(withTimeout, options); excInstance.Name = "Instance"; ObjectValue messageValue = null; ObjectValue helpLinkValue = null; var exceptionType = ctx.Adapter.GetValueType(ctx, Exception.Value); // Get the message if (withTimeout) { messageValue = ctx.Adapter.CreateObjectValueAsync("Message", ObjectValueFlags.None, delegate { var mref = ctx.Adapter.GetMember(ctx, Exception, exceptionType, Exception.Value, "Message"); if (mref != null) { string val = (string)mref.ObjectValue; return(ObjectValue.CreatePrimitive(null, new ObjectPath("Message"), "string", new EvaluationResult(val), ObjectValueFlags.Literal)); } return(ObjectValue.CreateUnknown("Message")); }); } else { var mref = ctx.Adapter.GetMember(ctx, Exception, exceptionType, Exception.Value, "Message"); if (mref != null) { string val = (string)mref.ObjectValue; messageValue = ObjectValue.CreatePrimitive(null, new ObjectPath("Message"), "string", new EvaluationResult(val), ObjectValueFlags.Literal); } } if (messageValue == null) { messageValue = ObjectValue.CreateUnknown("Message"); } messageValue.Name = "Message"; // Get the help link if (withTimeout) { helpLinkValue = ctx.Adapter.CreateObjectValueAsync("HelpLink", ObjectValueFlags.None, delegate { var mref = ctx.Adapter.GetMember(ctx, Exception, exceptionType, Exception.Value, "HelpLink"); if (mref != null) { string val = (string)mref.ObjectValue; return(ObjectValue.CreatePrimitive(null, new ObjectPath("HelpLink"), "string", new EvaluationResult(val), ObjectValueFlags.Literal)); } return(ObjectValue.CreateUnknown("HelpLink")); }); } else { var mref = ctx.Adapter.GetMember(ctx, Exception, exceptionType, Exception.Value, "HelpLink"); if (mref != null) { string val = (string)mref.ObjectValue; helpLinkValue = ObjectValue.CreatePrimitive(null, new ObjectPath("HelpLink"), "string", new EvaluationResult(val), ObjectValueFlags.Literal); } } if (helpLinkValue == null) { helpLinkValue = ObjectValue.CreateUnknown("HelpLink"); } helpLinkValue.Name = "HelpLink"; // Inner exception ObjectValue childExceptionValue = null; if (withTimeout) { childExceptionValue = ctx.Adapter.CreateObjectValueAsync("InnerException", ObjectValueFlags.None, delegate { var inner = ctx.Adapter.GetMember(ctx, Exception, exceptionType, Exception.Value, "InnerException"); if (inner != null && !ctx.Adapter.IsNull(ctx, inner.Value)) { //Console.WriteLine ("pp got child:" + type); var innerSource = new ExceptionInfoSource(ctx, inner); var res = innerSource.CreateObjectValue(false, options); return(res); } return(ObjectValue.CreateUnknown("InnerException")); }); } else { var inner = ctx.Adapter.GetMember(ctx, Exception, exceptionType, Exception.Value, "InnerException"); if (inner != null && !ctx.Adapter.IsNull(ctx, inner.Value)) { //Console.WriteLine ("pp got child:" + type); var innerSource = new ExceptionInfoSource(ctx, inner); childExceptionValue = innerSource.CreateObjectValue(false, options); childExceptionValue.Name = "InnerException"; } } if (childExceptionValue == null) { childExceptionValue = ObjectValue.CreateUnknown("InnerException"); } // Inner exceptions in case of AgregatedException ObjectValue childExceptionsValue = null; ObjectEvaluatorDelegate getInnerExceptionsDelegate = delegate { var inner = ctx.Adapter.GetMember(ctx, Exception, exceptionType, Exception.Value, "InnerExceptions"); if (inner != null && !ctx.Adapter.IsNull(ctx, inner.Value)) { var obj = inner.GetValue(ctx); var objType = ctx.Adapter.GetValueType(ctx, obj); var count = (int)ctx.Adapter.GetMember(ctx, null, obj, "Count").ObjectValue; var childrenList = new List <ObjectValue>(); for (int i = 0; i < count; i++) { childrenList.Add(new ExceptionInfoSource(ctx, ctx.Adapter.GetIndexerReference(ctx, obj, objType, new object[] { ctx.Adapter.CreateValue(ctx, i) })).CreateObjectValue(withTimeout, ctx.Options)); } return(ObjectValue.CreateObject(null, new ObjectPath("InnerExceptions"), "", "", ObjectValueFlags.None, childrenList.ToArray())); } return(ObjectValue.CreateUnknown("InnerExceptions")); }; if (withTimeout) { childExceptionsValue = ctx.Adapter.CreateObjectValueAsync("InnerExceptions", ObjectValueFlags.None, getInnerExceptionsDelegate); } else { childExceptionsValue = getInnerExceptionsDelegate(); } if (childExceptionsValue == null) { childExceptionsValue = ObjectValue.CreateUnknown("InnerExceptions"); } // Stack trace ObjectValue stackTraceValue; if (withTimeout) { stackTraceValue = ctx.Adapter.CreateObjectValueAsync("StackTrace", ObjectValueFlags.None, delegate { var stackTrace = ctx.Adapter.GetMember(ctx, Exception, exceptionType, Exception.Value, "StackTrace"); if (stackTrace == null) { return(ObjectValue.CreateUnknown("StackTrace")); } return(GetStackTrace(stackTrace.ObjectValue as string)); }); } else { var stackTrace = ctx.Adapter.GetMember(ctx, Exception, exceptionType, Exception.Value, "StackTrace"); if (stackTrace == null) { return(ObjectValue.CreateUnknown("StackTrace")); } stackTraceValue = GetStackTrace(stackTrace.ObjectValue as string); } var children = new ObjectValue [] { excInstance, messageValue, helpLinkValue, stackTraceValue, childExceptionValue, childExceptionsValue }; return(ObjectValue.CreateObject(null, new ObjectPath("InnerException"), type, "", ObjectValueFlags.None, children)); }
public ObjectValue[] GetChildren(EvaluationOptions options) { return(GetChildren(new ObjectPath("this"), -1, -1, options)); }
ObjectValue[] IObjectValueSource.GetChildren(ObjectPath path, int index, int count, EvaluationOptions options) { return(GetChildren(path, index, count, options)); }
public ValueReference(EvaluationContext ctx) { this.ctx = ctx; originalOptions = ctx.Options; }
public ValidationResult ValidateExpression(int frameIndex, string expression, EvaluationOptions options) { return(new ValidationResult(true, null)); }
public EvaluationResult SetValue(ObjectPath path, string value, EvaluationOptions options) { session.SelectThread(threadId); return(new EvaluationResult(value)); }
public ObjectValue[] GetExpressionValues(int frameIndex, string[] expressions, EvaluationOptions options) { List <ObjectValue> values = new List <ObjectValue> (); SelectFrame(frameIndex); foreach (string exp in expressions) { values.Add(CreateVarObject(exp)); } return(values.ToArray()); }
public ExceptionInfo GetException(int frameIndex, EvaluationOptions options) { return(null); }
public ObjectValue GetThisReference(int frameIndex, EvaluationOptions options) { return(null); }
protected abstract EvaluationContext GetEvaluationContext(int frameIndex, EvaluationOptions options);
protected ValueReference(EvaluationContext ctx) { originalOptions = ctx.Options; Context = ctx; }
object IObjectValueSource.GetRawValue(ObjectPath path, EvaluationOptions options) { return(ctx.Adapter.ToRawValue(GetContext(options), this, Value)); }
public ObjectValue GetValue(ObjectPath path, EvaluationOptions options) { throw new NotSupportedException(); }
void IObjectValueSource.SetRawValue(ObjectPath path, object value, EvaluationOptions options) { Value = ctx.Adapter.FromRawValue(GetContext(options), value); }
public object GetRawValue(ObjectPath path, EvaluationOptions options) { return(null); }
public virtual ObjectValue[] GetChildren(ObjectPath path, int index, int count, EvaluationOptions options) { try { return(ctx.Adapter.GetObjectValueChildren(GetChildrenContext(options), this, Value, index, count)); } catch (Exception ex) { Console.WriteLine(ex); return(new ObjectValue [] { Mono.Debugging.Client.ObjectValue.CreateFatalError("", ex.Message, ObjectValueFlags.ReadOnly) }); } }
public void SetRawValue(ObjectPath path, object value, EvaluationOptions options) { }
public EvaluationContext GetContext(EvaluationOptions options) { return(ctx.WithOptions(options)); }
public void VirtualProperty() { EvaluationOptions ops = EvaluationOptions.DefaultOptions.Clone(); ops.FlattenHierarchy = false; ObjectValue val = Frame.GetExpressionValue("c", ops); Assert.IsNotNull(val); val.WaitHandle.WaitOne(); Assert.IsFalse(val.IsError); Assert.IsFalse(val.IsUnknown); // The C class does not have a Prop property ObjectValue prop = val.GetChild("Prop", ops); Assert.IsNull(prop); prop = val.GetChild("PropNoVirt1", ops); Assert.IsNull(prop); prop = val.GetChild("PropNoVirt2", ops); Assert.IsNull(prop); val = val.GetChild("base", ops); Assert.IsNotNull(val); val.WaitHandle.WaitOne(); Assert.IsFalse(val.IsError); Assert.IsFalse(val.IsUnknown); // The B class has a Prop property, value is 2 prop = val.GetChild("Prop", ops); Assert.IsNotNull(prop); Assert.AreEqual("2", prop.Value); prop = val.GetChild("PropNoVirt1", ops); Assert.IsNotNull(prop); Assert.AreEqual("2", prop.Value); prop = val.GetChild("PropNoVirt2", ops); Assert.IsNotNull(prop); Assert.AreEqual("2", prop.Value); val = val.GetChild("base", ops); Assert.IsNotNull(val); val.WaitHandle.WaitOne(); Assert.IsFalse(val.IsError); Assert.IsFalse(val.IsUnknown); // The A class has a Prop property, value is 1, but must return 2 becasue it is overriden prop = val.GetChild("Prop", ops); Assert.IsNotNull(prop); Assert.AreEqual("2", prop.Value); prop = val.GetChild("PropNoVirt1", ops); Assert.IsNotNull(prop); Assert.AreEqual("1", prop.Value); prop = val.GetChild("PropNoVirt2", ops); Assert.IsNotNull(prop); Assert.AreEqual("1", prop.Value); }
protected override bool CanEvaluate(EvaluationOptions options) { return(options.AllowTargetInvoke); }
public ObjectValue CreateObjectValue(bool withTimeout, EvaluationOptions options) { string type = ctx.Adapter.GetTypeName(ctx, exception.Type); ObjectValue excInstance = exception.CreateObjectValue(withTimeout, options); excInstance.Name = "Instance"; ObjectValue messageValue = null; // Get the message if (withTimeout) { messageValue = ctx.Adapter.CreateObjectValueAsync("Message", ObjectValueFlags.None, delegate { ValueReference mref = exception.GetChild("Message", options); if (mref != null) { string val = (string)mref.ObjectValue; return(ObjectValue.CreatePrimitive(null, new ObjectPath("Message"), "System.String", new EvaluationResult(val), ObjectValueFlags.Literal)); } else { return(ObjectValue.CreateUnknown("Message")); } }); } else { ValueReference mref = exception.GetChild("Message", options); if (mref != null) { string val = (string)mref.ObjectValue; messageValue = ObjectValue.CreatePrimitive(null, new ObjectPath("Message"), "System.String", new EvaluationResult(val), ObjectValueFlags.Literal); } } if (messageValue == null) { messageValue = ObjectValue.CreateUnknown("Message"); } messageValue.Name = "Message"; // Inner exception ObjectValue childExceptionValue = null; if (withTimeout) { childExceptionValue = ctx.Adapter.CreateObjectValueAsync("InnerException", ObjectValueFlags.None, delegate { ValueReference inner = exception.GetChild("InnerException", options); if (inner != null && !ctx.Adapter.IsNull(ctx, inner.Value)) { //Console.WriteLine ("pp got child:" + type); ExceptionInfoSource innerSource = new ExceptionInfoSource(ctx, inner); ObjectValue res = innerSource.CreateObjectValue(false, options); return(res); } else { return(ObjectValue.CreateUnknown("InnerException")); } }); } else { ValueReference inner = exception.GetChild("InnerException", options); if (inner != null && !ctx.Adapter.IsNull(ctx, inner.Value)) { //Console.WriteLine ("pp got child:" + type); ExceptionInfoSource innerSource = new ExceptionInfoSource(ctx, inner); childExceptionValue = innerSource.CreateObjectValue(false, options); childExceptionValue.Name = "InnerException"; } } if (childExceptionValue == null) { childExceptionValue = ObjectValue.CreateUnknown("InnerException"); } // Stack trace ObjectValue stackTraceValue; if (withTimeout) { stackTraceValue = ctx.Adapter.CreateObjectValueAsync("StackTrace", ObjectValueFlags.None, delegate { return(GetStackTrace(options)); }); } else { stackTraceValue = GetStackTrace(options); } ObjectValue[] children = new ObjectValue [] { excInstance, messageValue, stackTraceValue, childExceptionValue }; return(ObjectValue.CreateObject(null, new ObjectPath("InnerException"), type, "", ObjectValueFlags.None, children)); }
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 (dimensions.Length > 1) { int rank = baseIndices.Length; lowerBound = array.GetLowerBounds() [rank]; upperBound = lowerBound + dimensions [rank] - 1; isLastDimension = rank == dimensions.Length - 1; } else { lowerBound = array.GetLowerBounds() [0]; upperBound = lowerBound + dimensions [0] - 1; isLastDimension = true; } int len; int initalIndex; if (!IsRange) { initalIndex = lowerBound; len = upperBound + 1 - lowerBound; } 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 += ","; } curIndex [curIndex.Length - 1] = initalIndex + firstItemIndex; var elems = array.GetElements(curIndex, System.Math.Min(values.Length, upperBound + 1)); for (int n = 0; n < values.Length; n++) { int index = n + initalIndex + firstItemIndex; string sidx = curIndexStr + index; ObjectValue val; string ename = "[" + sidx.Replace(",", ", ") + "]"; if (index > upperBound) { val = ObjectValue.CreateUnknown(sidx); } else { curIndex [curIndex.Length - 1] = index; val = cctx.Adapter.CreateObjectValue(cctx, this, newPath.Append(sidx), elems.GetValue(n), ObjectValueFlags.ArrayElement); if (elems.GetValue(n) != null && !cctx.Adapter.IsNull(cctx, elems.GetValue(n))) { TypeDisplayData tdata = cctx.Adapter.GetTypeDisplayData(cctx, cctx.Adapter.GetValueType(cctx, elems.GetValue(n))); if (!string.IsNullOrEmpty(tdata.NameDisplayString)) { try { ename = cctx.Adapter.EvaluateDisplayString(cctx, elems.GetValue(n), tdata.NameDisplayString); } catch (MissingMemberException) { // missing property or otherwise malformed DebuggerDisplay string } } } } val.Name = ename; values [n] = val; } return(values); } if (!isLastDimension && div == 1) { // Return an array element group for each index var 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; var 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()); } }
protected virtual bool CanEvaluate(EvaluationOptions options) { return(true); }
protected override ObjectValue OnCreateObjectValue(EvaluationOptions options) { return(Mono.Debugging.Client.ObjectValue.CreateObject(this, new ObjectPath(Name), "<type>", fullName, Flags, null)); }
ObjectValue IObjectValueSource.GetValue(ObjectPath path, EvaluationOptions options) { return(CreateObjectValue(true, options)); }
public override void Refresh(EvaluationOptions options) { DebuggerObject.Refresh(options); }
void IObjectValueSource.SetRawValue(ObjectPath path, object value, EvaluationOptions options) { SetRawValue(path, value, options); }