Exemple #1
0
        public IStrongValueHandle<IObjectReference> CreateInstance(IThreadReference thread, IMethod method, InvokeOptions options, params IValue[] arguments)
        {
            TaggedObjectId returnValue;
            TaggedObjectId thrownException;
            DebugErrorHandler.ThrowOnFailure(VirtualMachine.ProtocolService.CreateClassInstance(out returnValue, out thrownException, ClassId, ((ThreadReference)thread).ThreadId, ((Method)method).MethodId, (Types.InvokeOptions)options, arguments.Cast<Value>().Select(Value.ToNetworkValue).ToArray()));
            if (thrownException != default(TaggedObjectId))
            {
                throw new NotImplementedException();
            }

            return new StrongValueHandle<ObjectReference>(VirtualMachine.GetMirrorOf(returnValue));
        }
Exemple #2
0
        public IStrongValueHandle <IValue> InvokeMethod(IThreadReference thread, IMethod method, InvokeOptions options, params IValue[] arguments)
        {
            Types.Value    returnValue;
            TaggedObjectId thrownException;
            ThreadId       threadId = (thread != null) ? ((ThreadReference)thread).ThreadId : default(ThreadId);

            DebugErrorHandler.ThrowOnFailure(VirtualMachine.ProtocolService.InvokeObjectMethod(out returnValue, out thrownException, ObjectId, threadId, (ClassId)((Method)method).DeclaringType.TaggedReferenceTypeId, ((Method)method).MethodId, (Types.InvokeOptions)options, arguments.Cast <Value>().Select(Value.ToNetworkValue).ToArray()));
            if (thrownException != default(TaggedObjectId))
            {
                throw new NotImplementedException();
            }

            Value returnValueMirror = VirtualMachine.GetMirrorOf(returnValue);

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

            return(new StrongValueHandle <Value>(VirtualMachine.GetMirrorOf(returnValue)));
        }
Exemple #3
0
        public IStrongValueHandle<IValue> InvokeMethod(IThreadReference thread, IMethod method, InvokeOptions options, params IValue[] arguments)
        {
            Types.Value returnValue;
            TaggedObjectId thrownException;
            if (thread != null || VirtualMachine.GetCanInvokeWithoutThread())
            {
                ThreadId threadId = default(ThreadId);
                if (thread != null)
                    threadId = ((ThreadReference)thread).ThreadId;

                DebugErrorHandler.ThrowOnFailure(VirtualMachine.ProtocolService.InvokeObjectMethod(out returnValue, out thrownException, ObjectId, threadId, (ClassId)((Method)method).DeclaringType.TaggedReferenceTypeId, ((Method)method).MethodId, (Types.InvokeOptions)options, arguments.Cast<Value>().Select(Value.ToNetworkValue).ToArray()));
            }
            else
            {
                returnValue = default(Types.Value);
                thrownException = default(TaggedObjectId);
                Error errorCode = Error.ThreadNotSuspended;

                foreach (var vmThread in VirtualMachine.GetAllThreads())
                {
                    ThreadReference threadReference = vmThread as ThreadReference;
                    if (threadReference == null)
                        continue;

                    ThreadStatus threadStatus;
                    SuspendStatus suspendStatus;
                    DebugErrorHandler.ThrowOnFailure(VirtualMachine.ProtocolService.GetThreadStatus(out threadStatus, out suspendStatus, threadReference.ThreadId));
                    if (threadStatus != ThreadStatus.Running)
                        continue;

                    if (suspendStatus != SuspendStatus.Suspended)
                        continue;

                    int suspendCount;
                    DebugErrorHandler.ThrowOnFailure(VirtualMachine.ProtocolService.GetThreadSuspendCount(out suspendCount, threadReference.ThreadId));

                    errorCode = VirtualMachine.ProtocolService.InvokeObjectMethod(out returnValue, out thrownException, ObjectId, threadReference.ThreadId, (ClassId)((Method)method).DeclaringType.TaggedReferenceTypeId, ((Method)method).MethodId, (Types.InvokeOptions)options, arguments.Cast<Value>().Select(Value.ToNetworkValue).ToArray());
                    if (errorCode == Error.InvalidThread)
                        continue;

                    break;
                }

                DebugErrorHandler.ThrowOnFailure(errorCode);
            }

            if (thrownException.ObjectId != default(ObjectId))
            {
                throw new InternalException((int)Error.Internal, "An exception was thrown by the invoked method.");
            }

            Value returnValueMirror = VirtualMachine.GetMirrorOf(returnValue);
            if (returnValueMirror == null)
                return null;

            return new StrongValueHandle<Value>(VirtualMachine.GetMirrorOf(returnValue));
        }
Exemple #4
0
        public IStrongValueHandle <IValue> InvokeMethod(IThreadReference thread, IMethod method, InvokeOptions options, params IValue[] arguments)
        {
            Types.Value    returnValue;
            TaggedObjectId thrownException;

            if (thread != null || VirtualMachine.GetCanInvokeWithoutThread())
            {
                ThreadId threadId = default(ThreadId);
                if (thread != null)
                {
                    threadId = ((ThreadReference)thread).ThreadId;
                }

                DebugErrorHandler.ThrowOnFailure(VirtualMachine.ProtocolService.InvokeObjectMethod(out returnValue, out thrownException, ObjectId, threadId, (ClassId)((Method)method).DeclaringType.TaggedReferenceTypeId, ((Method)method).MethodId, (Types.InvokeOptions)options, arguments.Cast <Value>().Select(Value.ToNetworkValue).ToArray()));
            }
            else
            {
                returnValue     = default(Types.Value);
                thrownException = default(TaggedObjectId);
                Error errorCode = Error.ThreadNotSuspended;

                foreach (var vmThread in VirtualMachine.GetAllThreads())
                {
                    ThreadReference threadReference = vmThread as ThreadReference;
                    if (threadReference == null)
                    {
                        continue;
                    }

                    ThreadStatus  threadStatus;
                    SuspendStatus suspendStatus;
                    DebugErrorHandler.ThrowOnFailure(VirtualMachine.ProtocolService.GetThreadStatus(out threadStatus, out suspendStatus, threadReference.ThreadId));
                    if (threadStatus != ThreadStatus.Running)
                    {
                        continue;
                    }

                    if (suspendStatus != SuspendStatus.Suspended)
                    {
                        continue;
                    }

                    int suspendCount;
                    DebugErrorHandler.ThrowOnFailure(VirtualMachine.ProtocolService.GetThreadSuspendCount(out suspendCount, threadReference.ThreadId));

                    errorCode = VirtualMachine.ProtocolService.InvokeObjectMethod(out returnValue, out thrownException, ObjectId, threadReference.ThreadId, (ClassId)((Method)method).DeclaringType.TaggedReferenceTypeId, ((Method)method).MethodId, (Types.InvokeOptions)options, arguments.Cast <Value>().Select(Value.ToNetworkValue).ToArray());
                    if (errorCode == Error.InvalidThread)
                    {
                        continue;
                    }

                    break;
                }

                DebugErrorHandler.ThrowOnFailure(errorCode);
            }

            if (thrownException.ObjectId != default(ObjectId))
            {
                throw new InternalException((int)Error.Internal, "An exception was thrown by the invoked method.");
            }

            Value returnValueMirror = VirtualMachine.GetMirrorOf(returnValue);

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

            return(new StrongValueHandle <Value>(VirtualMachine.GetMirrorOf(returnValue)));
        }
Exemple #5
0
        public IStrongValueHandle <IObjectReference> CreateInstance(IThreadReference thread, IMethod method, InvokeOptions options, params IValue[] arguments)
        {
            TaggedObjectId returnValue;
            TaggedObjectId thrownException;

            DebugErrorHandler.ThrowOnFailure(VirtualMachine.ProtocolService.CreateClassInstance(out returnValue, out thrownException, ClassId, ((ThreadReference)thread).ThreadId, ((Method)method).MethodId, (Types.InvokeOptions)options, arguments.Cast <Value>().Select(Value.ToNetworkValue).ToArray()));
            if (thrownException != default(TaggedObjectId))
            {
                throw new NotImplementedException();
            }

            return(new StrongValueHandle <ObjectReference>(VirtualMachine.GetMirrorOf(returnValue)));
        }