public void Suspend()
 {
     DebugErrorHandler.ThrowOnFailure(VirtualMachine.ProtocolService.SuspendThread(this.ThreadId));
 }
 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))));
 }
예제 #3
0
 public void SetValues(int index, IValue[] values, int sourceIndex, int length)
 {
     Types.Value[] converted = values.Cast <Value>().Skip(sourceIndex).Take(length).Select(Value.ToNetworkValue).ToArray();
     Contract.Assert(converted.Length == length);
     DebugErrorHandler.ThrowOnFailure(VirtualMachine.ProtocolService.SetArrayValues(ArrayId, index, converted));
 }
 public void Resume()
 {
     DebugErrorHandler.ThrowOnFailure(VirtualMachine.ProtocolService.ResumeThread(this.ThreadId));
 }
예제 #5
0
 public IValue GetValue(int index)
 {
     Types.Value[] values;
     DebugErrorHandler.ThrowOnFailure(VirtualMachine.ProtocolService.GetArrayValues(out values, ArrayId, index, 1));
     return(VirtualMachine.GetMirrorOf(values[0]));
 }
예제 #6
0
 public ReadOnlyCollection <IValue> GetValues(int index, int length)
 {
     Types.Value[] values;
     DebugErrorHandler.ThrowOnFailure(VirtualMachine.ProtocolService.GetArrayValues(out values, ArrayId, index, length));
     return(new ReadOnlyCollection <IValue>(Array.ConvertAll(values, VirtualMachine.GetMirrorOf)));
 }
예제 #7
0
 public void SetValue(IField field, IValue value)
 {
     FieldId[]     fields = { ((Field)field).FieldId };
     Types.Value[] values = { Value.ToNetworkValue((Value)value) };
     DebugErrorHandler.ThrowOnFailure(VirtualMachine.ProtocolService.SetObjectValues(ObjectId, fields, values));
 }
예제 #8
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)));
        }
예제 #9
0
        internal IType FindType(string signature)
        {
            Contract.Requires <ArgumentNullException>(signature != null, "signature");
            Contract.Requires <ArgumentException>(!string.IsNullOrEmpty(signature));

            switch (signature[0])
            {
            case 'Z':
                return(PrimitiveTypes.Boolean);

            case 'B':
                return(PrimitiveTypes.Byte);

            case 'C':
                return(PrimitiveTypes.Char);

            case 'D':
                return(PrimitiveTypes.Double);

            case 'F':
                return(PrimitiveTypes.Float);

            case 'I':
                return(PrimitiveTypes.Integer);

            case 'J':
                return(PrimitiveTypes.Long);

            case 'S':
                return(PrimitiveTypes.Short);

            case 'V':
                return(PrimitiveTypes.Void);

            //case '[':
            //    return GetArrayType(FindType(signature.Substring(1)));
            //case 'L':
            //    return GetClassesByName(signature).Single();
            default:
                Types.ReferenceTypeData[] classes;
                DebugErrorHandler.ThrowOnFailure(ProtocolService.GetClassesBySignature(out classes, signature));
                if (classes.Length == 1)
                {
                    return(GetMirrorOf(classes[0]));
                }
                else if (classes.Length == 0)
                {
                    if (signature[0] == '[')
                    {
                        return(new UnloadedArrayType(this, signature));
                    }
                    else
                    {
                        return(new UnloadedReferenceType(this, signature));
                    }
                }
                else
                {
                    throw new ArgumentException("Could not resolve the signature to a single type.");
                }
            }
        }
예제 #10
0
 public ReadOnlyCollection <IThreadGroupReference> GetTopLevelThreadGroups()
 {
     ThreadGroupId[] groups;
     DebugErrorHandler.ThrowOnFailure(ProtocolService.GetTopLevelThreadGroups(out groups));
     return(new ReadOnlyCollection <IThreadGroupReference>(Array.ConvertAll(groups, GetMirrorOf)));
 }
예제 #11
0
 public void SetDefaultStratum(string stratum)
 {
     DebugErrorHandler.ThrowOnFailure(ProtocolService.SetDefaultStratum(stratum));
 }