Esempio n. 1
0
 public IObjectReference GetThisObject()
 {
     Types.TaggedObjectId thisObject;
     DebugErrorHandler.ThrowOnFailure(VirtualMachine.ProtocolService.GetThisObject(out thisObject, _thread.ThreadId, FrameId));
     return(VirtualMachine.GetMirrorOf(thisObject));
 }
Esempio n. 2
0
 public IValue GetValue(int index)
 {
     Types.Value[] values;
     DebugErrorHandler.ThrowOnFailure(VirtualMachine.ProtocolService.GetArrayValues(out values, ArrayId, index, 1));
     return(VirtualMachine.GetMirrorOf(values[0]));
 }
 public ReadOnlyCollection <IStackFrame> GetFrames(int startFrame, int length)
 {
     FrameLocationData[] framesData;
     DebugErrorHandler.ThrowOnFailure(VirtualMachine.ProtocolService.GetThreadFrames(out framesData, ThreadId, startFrame, length));
     return(new ReadOnlyCollection <IStackFrame>(Array.ConvertAll(framesData, frameData => VirtualMachine.GetMirrorOf(this, frameData))));
 }
Esempio n. 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)));
        }