RuntimeInvoke() публичный Метод

public RuntimeInvoke ( TargetFunctionType function, TargetStructObject object_argument, TargetObject param_objects, RuntimeInvokeFlags flags ) : RuntimeInvokeResult
function Mono.Debugger.Languages.TargetFunctionType
object_argument Mono.Debugger.Languages.TargetStructObject
param_objects Mono.Debugger.Languages.TargetObject
flags RuntimeInvokeFlags
Результат RuntimeInvokeResult
Пример #1
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;
            }
        }
Пример #2
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;
        }
Пример #3
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);
            }
        }
Пример #4
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);
        }
Пример #5
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;
        }