Exemplo n.º 1
0
        public override TargetObject GetField(Thread thread,
                                              TargetStructObject instance,
                                              TargetFieldInfo field)
        {
            if (field.HasConstValue)
            {
                return(SymbolFile.MonoLanguage.CreateInstance(thread, field.ConstValue));
            }

            if (field.IsStatic)
            {
                return(GetStaticField(thread, field));
            }
            else
            {
                if (instance == null)
                {
                    throw new InvalidOperationException();
                }

                return((TargetObject)thread.ThreadServant.DoTargetAccess(
                           delegate(TargetMemoryAccess target)  {
                    return GetInstanceField(target, instance, field);
                }));
            }
        }
Exemplo n.º 2
0
        TargetClassObject CheckTypeProxy(TargetStructObject obj)
        {
            if (obj.Type.DebuggerTypeProxyAttribute == null)
            {
                return(null);
            }

            string proxy_name    = obj.Type.DebuggerTypeProxyAttribute.ProxyTypeName;
            string original_name = proxy_name;

            proxy_name = proxy_name.Replace('+', '/');

            Expression expression;

            try {
                expression = new TypeProxyExpression(proxy_name, obj);
                expression = expression.Resolve(this);

                if (expression == null)
                {
                    return(null);
                }

                return((TargetClassObject)expression.EvaluateObject(this));
            } catch {
                return(null);
            }
        }
Exemplo n.º 3
0
        internal TargetObject GetInstanceField(TargetMemoryAccess target,
                                               TargetStructObject instance,
                                               TargetFieldInfo field)
        {
            GetFields(target);

            int        offset = field_offsets [field.Position];
            TargetType type   = field_types [field.Position];

            if (!Type.IsByRef)
            {
                offset -= 2 * target.TargetMemoryInfo.TargetAddressSize;
            }
            TargetLocation field_loc = instance.Location.GetLocationAtOffset(offset);

            TargetAddress orig_addr = field_loc.GetAddress(target);

            if (type.IsByRef)
            {
                field_loc = field_loc.GetDereferencedLocation();
            }

            TargetAddress addr = field_loc.GetAddress(target);

            if (field_loc.HasAddress && field_loc.GetAddress(target).IsNull)
            {
                return(new TargetNullObject(type));
            }

            return(type.GetObject(target, field_loc));
        }
Exemplo n.º 4
0
        public override void SetField(Thread thread, TargetStructObject instance,
                                      TargetFieldInfo field, TargetObject value)
        {
            if (field.IsStatic)
            {
                if (instance != null)
                {
                    throw new InvalidOperationException();
                }

                SetStaticField(thread, field, value);
            }
            else
            {
                if (instance == null)
                {
                    throw new InvalidOperationException();
                }

                thread.ThreadServant.DoTargetAccess(
                    delegate(TargetMemoryAccess target)  {
                    SetInstanceField(target, instance, field, value);
                    return(null);
                });
            }
        }
Exemplo n.º 5
0
        public static EE.EvaluationResult HandleDebuggerDisplay(Interpreter interpreter,
                                                                Thread thread,
                                                                TargetStructObject instance,
                                                                DebuggerDisplayAttribute attr,
                                                                int timeout, out string name,
                                                                out string type)
        {
            ScriptingContext expr_context = new ScriptingContext(interpreter);

            expr_context.CurrentThread    = thread;
            expr_context.CurrentLanguage  = instance.Type.Language;
            expr_context.ImplicitInstance = instance;

            EE.EvaluationResult result = expr_context.HandleDebuggerDisplay(
                thread, instance, attr.Value, timeout, out name);

            if (result != EE.EvaluationResult.Ok)
            {
                type = null;
                return(result);
            }

            if (String.IsNullOrEmpty(attr.Type))
            {
                type = null;
                return(EE.EvaluationResult.Ok);
            }

            return(expr_context.HandleDebuggerDisplay(
                       thread, instance, attr.Type, timeout, out type));
        }
Exemplo n.º 6
0
        public static TargetStructObject ToStructObject(MdbEvaluationContext ctx, TargetObject obj)
        {
            TargetStructObject sobj = obj as TargetStructObject;

            if (sobj != null)
            {
                return(sobj);
            }

            TargetObjectObject oobj = obj as TargetObjectObject;

            if (oobj != null)
            {
                return(oobj.GetClassObject(ctx.Thread));
            }

            TargetArrayObject aobj = obj as TargetArrayObject;

            if ((aobj != null) && aobj.HasClassObject)
            {
                return(aobj.GetClassObject(ctx.Thread));
            }

            return(null);
        }
Exemplo n.º 7
0
        public RuntimeInvokeResult RuntimeInvoke(Thread thread,
                                                 TargetFunctionType function,
                                                 TargetStructObject object_argument,
                                                 TargetObject[] param_objects,
                                                 RuntimeInvokeFlags flags)
        {
            IInterruptionHandler interruption = InterruptionHandler ?? Interpreter;

            if (interruption.CheckInterruption())
            {
                throw new EvaluationTimeoutException();
            }

            RuntimeInvokeResult result = thread.RuntimeInvoke(
                function, object_argument, param_objects, flags);

            WaitHandle[] handles = new WaitHandle [2];
            handles [0] = interruption.InterruptionEvent;
            handles [1] = result.CompletedEvent;

            int ret = WaitHandle.WaitAny(handles);

            if (ret == 0)
            {
                result.Abort();
                throw new EvaluationTimeoutException();
            }

            return(result);
        }
 public PropertyReference(EvaluationContext ctx, TargetPropertyInfo prop, TargetStructObject thisobj) : base(ctx)
 {
     this.prop = prop;
     if (!prop.IsStatic)
     {
         this.thisobj = thisobj;
     }
 }
Exemplo n.º 9
0
 public override void RuntimeInvoke(TargetFunctionType function,
                                    TargetStructObject object_argument,
                                    TargetObject[] param_objects,
                                    RuntimeInvokeFlags flags,
                                    RuntimeInvokeResult result)
 {
     throw new InvalidOperationException();
 }
Exemplo n.º 10
0
 public FieldReference(EvaluationContext ctx, TargetStructObject thisobj, TargetType type, TargetFieldInfo field) : base(ctx)
 {
     this.type  = type;
     this.field = field;
     if (!field.IsStatic)
     {
         this.thisobj = thisobj;
     }
 }
Exemplo n.º 11
0
        static TargetStructObject TryCurrentCast(MdbEvaluationContext ctx, TargetClassObject source, TargetClassType target_type)
        {
            TargetStructObject current = source.GetCurrentObject(ctx.Thread);

            if (current == null)
            {
                return(null);
            }

            return(TryParentCast(ctx, current, current.Type, target_type));
        }
Exemplo n.º 12
0
        public override TargetObject GetField(Thread thread,
						       TargetStructObject instance,
						       TargetFieldInfo field)
        {
            if (field.HasConstValue)
                return type.Language.CreateInstance (thread, field.ConstValue);

            return (TargetObject) thread.ThreadServant.DoTargetAccess (
                delegate (TargetMemoryAccess target)  {
                    return GetField (target, instance, field);
            });
        }
Exemplo n.º 13
0
 public RuntimeInvokeResult RuntimeInvoke(TargetFunctionType function,
                                          TargetStructObject object_argument,
                                          TargetObject[] param_objects,
                                          RuntimeInvokeFlags flags)
 {
     lock (this) {
         check_alive();
         RuntimeInvokeResult result = new RuntimeInvokeResult(this);
         servant.RuntimeInvoke(
             function, object_argument, param_objects,
             flags, result);
         return(result);
     }
 }
Exemplo n.º 14
0
        public override TargetObject GetField(Thread thread,
                                              TargetStructObject instance,
                                              TargetFieldInfo field)
        {
            if (field.HasConstValue)
            {
                return(type.Language.CreateInstance(thread, field.ConstValue));
            }

            return((TargetObject)thread.ThreadServant.DoTargetAccess(
                       delegate(TargetMemoryAccess target)  {
                return GetField(target, instance, field);
            }));
        }
        public static ValueReference CreateIndexerValueReference(MdbEvaluationContext ctx, TargetObject target, TargetObject[] index)
        {
            TargetFundamentalObject mstr = target as TargetFundamentalObject;

            if (mstr != null && mstr.TypeName == "string")
            {
                // Special case for strings
                string name = "[" + ctx.Evaluator.TargetObjectToExpression(ctx, index[0]) + "]";
                string val  = (string)mstr.GetObject(ctx.Thread);
                object oo   = ctx.Adapter.TargetObjectToObject(ctx, index[0]);
                int    idx  = (int)Convert.ChangeType(oo, typeof(int));
                return(LiteralValueReference.CreateObjectLiteral(ctx, name, val [idx]));
            }

            TargetStructObject sob = target as TargetStructObject;

            if (sob == null)
            {
                return(null);
            }

            TargetPropertyInfo indexerProp = null;

            foreach (MemberReference mem in ObjectUtil.GetTypeMembers(ctx, target.Type, false, true, true, BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance | BindingFlags.Static))
            {
                if (mem.Member.IsStatic)
                {
                    continue;
                }
                if (mem.Member is TargetPropertyInfo)
                {
                    TargetPropertyInfo prop = (TargetPropertyInfo)mem.Member;
                    if (prop.CanRead && prop.Getter.ParameterTypes.Length == 1)
                    {
                        indexerProp = prop;
                        break;
                    }
                }
            }
            if (indexerProp != null)
            {
                return(new IndexerValueReference(ctx, sob, index, indexerProp));
            }
            else
            {
                return(null);
            }
        }
Exemplo n.º 16
0
        public static TargetClassObject CheckTypeProxy(Interpreter interpreter, Thread thread,
                                                       TargetStructObject obj)
        {
            if (obj.Type.DebuggerTypeProxyAttribute == null)
            {
                return(null);
            }

            ScriptingContext expr_context = new ScriptingContext(interpreter);

            expr_context.CurrentThread    = thread;
            expr_context.CurrentLanguage  = obj.Type.Language;
            expr_context.ImplicitInstance = obj;

            return(expr_context.CheckTypeProxy(obj));
        }
Exemplo n.º 17
0
        public override void SetField(Thread thread, TargetStructObject instance,
					       TargetFieldInfo field, TargetObject value)
        {
            TargetLocation field_loc = instance.Location.GetLocationAtOffset (field.Offset);

            if (field.Type.IsByRef)
                field_loc = field_loc.GetDereferencedLocation ();

            NativeFieldInfo nfield = (NativeFieldInfo) field;
            if (!field.Type.IsByRef && nfield.IsBitfield)
                field_loc = new BitfieldTargetLocation (
                    field_loc, nfield.BitOffset, nfield.BitSize);

            // field.Type.SetObject (field_loc, value);
            throw new NotImplementedException ();
        }
Exemplo n.º 18
0
        public RuntimeInvokeResult RuntimeInvoke(TargetFunctionType function,
                                                 TargetStructObject object_argument,
                                                 TargetObject[] param_objects,
                                                 bool is_virtual, bool debug)
        {
            RuntimeInvokeFlags flags = RuntimeInvokeFlags.None;

            if (is_virtual)
            {
                flags |= RuntimeInvokeFlags.VirtualMethod;
            }
            if (debug)
            {
                flags |= RuntimeInvokeFlags.BreakOnEntry;
            }
            return(RuntimeInvoke(function, object_argument, param_objects, flags));
        }
Exemplo n.º 19
0
        internal TargetObject GetField(TargetMemoryAccess target,
                                       TargetStructObject instance,
                                       TargetFieldInfo field)
        {
            TargetLocation field_loc = instance.Location.GetLocationAtOffset(field.Offset);

            if (field.Type.IsByRef)
            {
                field_loc = field_loc.GetDereferencedLocation();
            }

            NativeFieldInfo nfield = (NativeFieldInfo)field;

            if (!field.Type.IsByRef && nfield.IsBitfield)
            {
                field_loc = new BitfieldTargetLocation(
                    field_loc, nfield.BitOffset, nfield.BitSize);
            }

            return(field.Type.GetObject(target, field_loc));
        }
Exemplo n.º 20
0
        public override void SetField(Thread thread, TargetStructObject instance,
                                      TargetFieldInfo field, TargetObject value)
        {
            TargetLocation field_loc = instance.Location.GetLocationAtOffset(field.Offset);

            if (field.Type.IsByRef)
            {
                field_loc = field_loc.GetDereferencedLocation();
            }

            NativeFieldInfo nfield = (NativeFieldInfo)field;

            if (!field.Type.IsByRef && nfield.IsBitfield)
            {
                field_loc = new BitfieldTargetLocation(
                    field_loc, nfield.BitOffset, nfield.BitSize);
            }

            // field.Type.SetObject (field_loc, value);
            throw new NotImplementedException();
        }
Exemplo n.º 21
0
        static TargetStructObject TryParentCast(MdbEvaluationContext ctx, TargetStructObject source, TargetStructType source_type, TargetStructType target_type)
        {
            if (source_type == target_type)
            {
                return(source);
            }

            if (!source_type.HasParent)
            {
                return(null);
            }

            TargetStructType parent_type = source_type.GetParentType(ctx.Thread);

            source = TryParentCast(ctx, source, parent_type, target_type);
            if (source == null)
            {
                return(null);
            }

            return(source.GetParentObject(ctx.Thread) as TargetClassObject);
        }
Exemplo n.º 22
0
        internal void SetInstanceField(TargetMemoryAccess target,
                                       TargetStructObject instance,
                                       TargetFieldInfo field, TargetObject obj)
        {
            GetFields(target);

            int        offset = field_offsets [field.Position];
            TargetType type   = field_types [field.Position];

            if (!Type.IsByRef)
            {
                offset -= 2 * target.TargetMemoryInfo.TargetAddressSize;
            }
            TargetLocation field_loc = instance.Location.GetLocationAtOffset(offset);

            if (type.IsByRef)
            {
                field_loc = field_loc.GetDereferencedLocation();
            }

            type.SetObject(target, field_loc, obj);
        }
Exemplo n.º 23
0
        public static TargetObject TryCast(MdbEvaluationContext ctx, TargetObject source, TargetClassType target_type)
        {
            if (source.Type == target_type)
            {
                return(source);
            }

            TargetClassObject sobj = ToClassObject(ctx, source);

            if (sobj == null)
            {
                return(null);
            }

            TargetStructObject result = TryParentCast(ctx, sobj, sobj.Type, target_type);

            if (result != null)
            {
                return(result);
            }

            return(TryCurrentCast(ctx, sobj, target_type));
        }
Exemplo n.º 24
0
 public abstract void RuntimeInvoke(TargetFunctionType function,
                                    TargetStructObject object_argument,
                                    TargetObject[] param_objects,
                                    RuntimeInvokeFlags flags,
                                    RuntimeInvokeResult result);
Exemplo n.º 25
0
        internal TargetObject GetField(TargetMemoryAccess target,
						TargetStructObject instance,
						TargetFieldInfo field)
        {
            TargetLocation field_loc = instance.Location.GetLocationAtOffset (field.Offset);

            if (field.Type.IsByRef)
                field_loc = field_loc.GetDereferencedLocation ();

            NativeFieldInfo nfield = (NativeFieldInfo) field;
            if (!field.Type.IsByRef && nfield.IsBitfield)
                field_loc = new BitfieldTargetLocation (
                    field_loc, nfield.BitOffset, nfield.BitSize);

            return field.Type.GetObject (target, field_loc);
        }
 public IndexerValueReference(EvaluationContext ctx, TargetStructObject target, TargetObject[] index, TargetPropertyInfo indexerProp) : base(ctx)
 {
     this.indexer = indexerProp;
     this.target  = target;
     this.index   = index;
 }
Exemplo n.º 27
0
        internal void SetInstanceField(TargetMemoryAccess target,
						TargetStructObject instance,
						TargetFieldInfo field, TargetObject obj)
        {
            GetFields (target);

            int offset = field_offsets [field.Position];
            TargetType type = field_types [field.Position];

            if (!Type.IsByRef)
                offset -= 2 * target.TargetMemoryInfo.TargetAddressSize;
            TargetLocation field_loc = instance.Location.GetLocationAtOffset (offset);

            if (type.IsByRef)
                field_loc = field_loc.GetDereferencedLocation ();

            type.SetObject (target, field_loc, obj);
        }
Exemplo n.º 28
0
        internal TargetObject GetInstanceField(TargetMemoryAccess target,
							TargetStructObject instance,
							TargetFieldInfo field)
        {
            GetFields (target);

            int offset = field_offsets [field.Position];
            TargetType type = field_types [field.Position];

            if (!Type.IsByRef)
                offset -= 2 * target.TargetMemoryInfo.TargetAddressSize;
            TargetLocation field_loc = instance.Location.GetLocationAtOffset (offset);

            TargetAddress orig_addr = field_loc.GetAddress (target);

            if (type.IsByRef)
                field_loc = field_loc.GetDereferencedLocation ();

            TargetAddress addr = field_loc.GetAddress (target);

            if (field_loc.HasAddress && field_loc.GetAddress (target).IsNull)
                return new TargetNullObject (type);

            return type.GetObject (target, field_loc);
        }
Exemplo n.º 29
0
        public static EvaluationResult MonoObjectToString(Thread thread, TargetStructObject obj,
                                                          EvaluationFlags flags, int timeout,
                                                          out string result)
        {
            result = null;

            if (!obj.Type.Language.IsManaged)
            {
                return(EvaluationResult.MethodNotFound);
            }

again:
            TargetStructType ctype = obj.Type;

            if ((ctype.Name == "System.Object") || (ctype.Name == "System.ValueType"))
            {
                return(EvaluationResult.MethodNotFound);
            }

            TargetClass klass = ctype.GetClass(thread);

            if (klass == null)
            {
                return(EvaluationResult.NotInitialized);
            }

            TargetMethodInfo[] methods = klass.GetMethods(thread);
            if (methods == null)
            {
                return(EvaluationResult.MethodNotFound);
            }

            foreach (TargetMethodInfo minfo in methods)
            {
                if (minfo.Name != "ToString")
                {
                    continue;
                }

                TargetFunctionType ftype = minfo.Type;
                if (ftype.ParameterTypes.Length != 0)
                {
                    continue;
                }
                if (ftype.ReturnType != ftype.Language.StringType)
                {
                    continue;
                }

                RuntimeInvokeResult rti;
                try {
                    RuntimeInvokeFlags rti_flags = RuntimeInvokeFlags.VirtualMethod;

                    if ((flags & EvaluationFlags.NestedBreakStates) != 0)
                    {
                        rti_flags |= RuntimeInvokeFlags.NestedBreakStates;
                    }

                    rti = thread.RuntimeInvoke(
                        ftype, obj, new TargetObject [0], rti_flags);

                    if (!rti.CompletedEvent.WaitOne(timeout, false))
                    {
                        rti.Abort();
                        return(EvaluationResult.Timeout);
                    }

                    if ((rti.TargetException != null) &&
                        (rti.TargetException.Type == TargetError.ClassNotInitialized))
                    {
                        result = null;
                        return(EvaluationResult.NotInitialized);
                    }

                    if (rti.Result is Exception)
                    {
                        result = ((Exception)rti.Result).Message;
                        return(EvaluationResult.UnknownError);
                    }

                    if (rti.ExceptionMessage != null)
                    {
                        result = rti.ExceptionMessage;
                        return(EvaluationResult.Exception);
                    }
                    else if (rti.ReturnObject == null)
                    {
                        rti.Abort();
                        return(EvaluationResult.UnknownError);
                    }
                } catch (TargetException ex) {
                    result = ex.ToString();
                    return(EvaluationResult.UnknownError);
                }

                TargetObject retval = (TargetObject)rti.ReturnObject;
                result = (string)((TargetFundamentalObject)retval).GetObject(thread);
                return(EvaluationResult.Ok);
            }

            if (obj.Type.HasParent)
            {
                obj = obj.GetParentObject(thread) as TargetClassObject;
                if (obj != null)
                {
                    goto again;
                }
            }

            return(EvaluationResult.MethodNotFound);
        }
Exemplo n.º 30
0
 public EE.EvaluationResult GetProperty(Thread thread, TargetPropertyInfo property,
                                        TargetStructObject instance, EE.EvaluationFlags flags,
                                        int timeout, out string error, out TargetObject value)
 {
     return(EE.GetProperty(thread, property, instance, flags, timeout, out error, out value));
 }
Exemplo n.º 31
0
 public EE.EvaluationResult MonoObjectToString(Thread thread, TargetStructObject obj,
                                               EE.EvaluationFlags flags, int timeout,
                                               out string text)
 {
     return(EE.MonoObjectToString(thread, obj, flags, timeout, out text));
 }
Exemplo n.º 32
0
        public override void SetField(Thread thread, TargetStructObject instance,
					       TargetFieldInfo field, TargetObject value)
        {
            if (field.IsStatic) {
                if (instance != null)
                    throw new InvalidOperationException ();

                SetStaticField (thread, field, value);
            } else {
                if (instance == null)
                    throw new InvalidOperationException ();

                thread.ThreadServant.DoTargetAccess (
                    delegate (TargetMemoryAccess target)  {
                        SetInstanceField (target, instance, field, value);
                        return null;
                });
            }
        }
Exemplo n.º 33
0
        EE.EvaluationResult HandleDebuggerDisplay(Thread thread, TargetStructObject instance,
                                                  string attr_value, int timeout,
                                                  out string result)
        {
            result = null;

            StringBuilder sb = new StringBuilder();

            int pos = 0;

            while (pos < attr_value.Length)
            {
                if (attr_value [pos] == '\\')
                {
                    if (pos == attr_value.Length)
                    {
                        break;
                    }
                    else
                    {
                        sb.Append(attr_value [++pos]);
                        pos++;
                        continue;
                    }
                }

                if (attr_value [pos] == '}')
                {
                    result = null;
                    return(EE.EvaluationResult.InvalidExpression);
                }

                if (attr_value [pos] != '{')
                {
                    sb.Append(attr_value [pos++]);
                    continue;
                }

                pos++;
                StringBuilder expr_text = new StringBuilder();

                while (pos < attr_value.Length)
                {
                    if (attr_value [pos] == '\\')
                    {
                        if (pos == attr_value.Length)
                        {
                            break;
                        }
                        else
                        {
                            expr_text.Append(attr_value [++pos]);
                            pos++;
                            continue;
                        }
                    }
                    else if (attr_value [pos] == '{')
                    {
                        result = null;
                        return(EE.EvaluationResult.InvalidExpression);
                    }
                    else if (attr_value [pos] == '}')
                    {
                        pos++;
                        break;
                    }

                    expr_text.Append(attr_value [pos++]);
                }

                Expression expr;

                try {
                    expr = Interpreter.ExpressionParser.ParseInternal(expr_text.ToString());
                } catch (ExpressionParsingException ex) {
                    result = ex.Message;
                    return(EE.EvaluationResult.InvalidExpression);
                } catch {
                    return(EE.EvaluationResult.InvalidExpression);
                }

                try {
                    expr = expr.Resolve(this);
                } catch (ScriptingException ex) {
                    result = ex.Message;
                    return(EE.EvaluationResult.InvalidExpression);
                } catch {
                    return(EE.EvaluationResult.InvalidExpression);
                }

                string text;

                try {
                    object retval = expr.Evaluate(this);
                    if (retval is TargetObject)
                    {
                        text = DoFormatObject(
                            (TargetObject)retval, DisplayFormat.Object);
                    }
                    else
                    {
                        text = interpreter.Style.FormatObject(
                            CurrentThread, retval, DisplayFormat.Object);
                    }
                } catch (ScriptingException ex) {
                    result = ex.Message;
                    return(EE.EvaluationResult.InvalidExpression);
                } catch {
                    return(EE.EvaluationResult.InvalidExpression);
                }

                sb.Append(text);
            }

            result = sb.ToString();
            return(EE.EvaluationResult.Ok);
        }
Exemplo n.º 34
0
        public static EvaluationResult GetProperty(Thread thread, TargetPropertyInfo property,
                                                   TargetStructObject instance, EvaluationFlags flags,
                                                   int timeout, out string error, out TargetObject result)
        {
            error = null;

            RuntimeInvokeResult rti;

            try {
                RuntimeInvokeFlags rti_flags = RuntimeInvokeFlags.VirtualMethod;

                if ((flags & EvaluationFlags.NestedBreakStates) != 0)
                {
                    rti_flags |= RuntimeInvokeFlags.NestedBreakStates;
                }

                rti = thread.RuntimeInvoke(
                    property.Getter, instance, new TargetObject [0], rti_flags);

                if (!rti.CompletedEvent.WaitOne(timeout, false))
                {
                    rti.Abort();
                    result = null;
                    return(EvaluationResult.Timeout);
                }

                if ((rti.TargetException != null) &&
                    (rti.TargetException.Type == TargetError.ClassNotInitialized))
                {
                    result = null;
                    error  = rti.ExceptionMessage;
                    return(EvaluationResult.NotInitialized);
                }

                if (rti.Result is Exception)
                {
                    result = null;
                    error  = ((Exception)rti.Result).Message;
                    return(EvaluationResult.UnknownError);
                }

                result = (TargetObject)rti.ReturnObject;

                if (rti.ExceptionMessage != null)
                {
                    error = rti.ExceptionMessage;
                    return(EvaluationResult.Exception);
                }
                else if (rti.ReturnObject == null)
                {
                    rti.Abort();
                    return(EvaluationResult.UnknownError);
                }

                return(EvaluationResult.Ok);
            } catch (TargetException ex) {
                result = null;
                error  = ex.ToString();
                return(EvaluationResult.UnknownError);
            }
        }
Exemplo n.º 35
0
        public override TargetObject GetField(Thread thread,
						       TargetStructObject instance,
						       TargetFieldInfo field)
        {
            if (field.HasConstValue)
                return SymbolFile.MonoLanguage.CreateInstance (thread, field.ConstValue);

            if (field.IsStatic) {
                return GetStaticField (thread, field);
            } else {
                if (instance == null)
                    throw new InvalidOperationException ();

                return (TargetObject) thread.ThreadServant.DoTargetAccess (
                    delegate (TargetMemoryAccess target)  {
                        return GetInstanceField (target, instance, field);
                });
            }
        }