public void AddThreadFilter(IThreadReference thread)
        {
            Contract.Requires<ArgumentNullException>(thread != null, "thread");
            Contract.Requires<VirtualMachineMismatchException>(this.GetVirtualMachine().Equals(thread.GetVirtualMachine()));

            throw new NotImplementedException();
        }
        public void AddThreadFilter(IThreadReference thread)
        {
            Contract.Requires <ArgumentNullException>(thread != null, "thread");
            Contract.Requires <VirtualMachineMismatchException>(this.GetVirtualMachine().Equals(thread.GetVirtualMachine()));

            throw new NotImplementedException();
        }
Пример #3
0
 public static void AbortAll(this IThreadReference reference, System.TimeSpan timeout)
 {
     foreach (var tp in reference.GetReferencedThreads())
     {
         System.Threading.Thread t = tp;
         Media.Common.Extensions.Thread.ThreadExtensions.TryAbort(ref t, timeout, System.Threading.ThreadState.Running);
     }
 }
Пример #4
0
        public void AddThreadFilter(IThreadReference thread)
        {
            ThreadReference threadReference = thread as ThreadReference;
            if (threadReference == null)
                throw new VirtualMachineMismatchException();

            Modifiers.Add(Types.EventRequestModifier.ThreadFilter(threadReference.ThreadId));
        }
Пример #5
0
        public IStepRequest CreateStepRequest(IThreadReference thread, StepSize size, StepDepth depth)
        {
            Contract.Requires <VirtualMachineMismatchException>(thread == null || this.GetVirtualMachine().Equals(thread.GetVirtualMachine()));
            Contract.Ensures(Contract.Result <IStepRequest>() != null);
            Contract.Ensures(this.GetVirtualMachine().Equals(Contract.Result <IStepRequest>().GetVirtualMachine()));

            throw new NotImplementedException();
        }
Пример #6
0
 public static void AbortAll(this IThreadReference reference, int timeoutmSec = (int)Common.Extensions.TimeSpan.TimeSpanExtensions.MicrosecondsPerMillisecond)
 {
     foreach (var tp in reference.GetReferencedThreads())
     {
         System.Threading.Thread t = tp;
         Media.Common.Extensions.Thread.ThreadExtensions.TryAbort(ref t, System.Threading.ThreadState.Running, timeoutmSec);
     }
 }
        public JavaDebugThread(JavaDebugProgram program, IThreadReference thread, ThreadCategory category)
        {
            Contract.Requires <ArgumentNullException>(program != null, "program");
            Contract.Requires <ArgumentNullException>(thread != null, "thread");

            _program  = program;
            _thread   = thread;
            _category = category;
            CreateStepRequests();
        }
Пример #8
0
        public JavaDebugThread(JavaDebugProgram program, IThreadReference thread, ThreadCategory category)
        {
            Contract.Requires<ArgumentNullException>(program != null, "program");
            Contract.Requires<ArgumentNullException>(thread != null, "thread");

            _program = program;
            _thread = thread;
            _category = category;
            CreateStepRequests();
        }
Пример #9
0
        public void AddThreadFilter(IThreadReference thread)
        {
            ThreadReference threadReference = thread as ThreadReference;

            if (threadReference == null || !threadReference.VirtualMachine.Equals(this.VirtualMachine))
            {
                throw new VirtualMachineMismatchException();
            }

            Modifiers.Add(Types.EventRequestModifier.ThreadFilter(threadReference.ThreadId));
        }
Пример #10
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));
        }
Пример #11
0
        public IStrongValueHandle<IValue> InvokeMethod(IThreadReference thread, IMethod method, InvokeOptions options, params IValue[] arguments)
        {
            Contract.Requires<ArgumentNullException>(method != null, "method");
            Contract.Requires<VirtualMachineMismatchException>(thread == null || this.GetVirtualMachine().Equals(thread.GetVirtualMachine()));
            Contract.Requires<VirtualMachineMismatchException>(method.GetVirtualMachine().Equals(this.GetVirtualMachine()));
#if CONTRACTS_FORALL
            Contract.Requires<VirtualMachineMismatchException>(arguments == null || Contract.ForAll(arguments, argument => argument == null || this.GetVirtualMachine().Equals(argument.GetVirtualMachine())));
#endif
            Contract.Ensures(Contract.Result<IStrongValueHandle<IValue>>() == null || this.GetVirtualMachine().Equals(Contract.Result<IStrongValueHandle<IValue>>().GetVirtualMachine()));

            throw new NotImplementedException();
        }
        public IStrongValueHandle <IValue> InvokeMethod(IThreadReference thread, IMethod method, InvokeOptions options, params IValue[] arguments)
        {
            Contract.Requires <ArgumentNullException>(method != null, "method");
            Contract.Requires <VirtualMachineMismatchException>(thread == null || this.GetVirtualMachine().Equals(thread.GetVirtualMachine()));
            Contract.Requires <VirtualMachineMismatchException>(method.GetVirtualMachine().Equals(this.GetVirtualMachine()));
#if CONTRACTS_FORALL
            Contract.Requires <VirtualMachineMismatchException>(arguments == null || Contract.ForAll(arguments, argument => argument == null || this.GetVirtualMachine().Equals(argument.GetVirtualMachine())));
#endif
            Contract.Ensures(Contract.Result <IStrongValueHandle <IValue> >() == null || this.GetVirtualMachine().Equals(Contract.Result <IStrongValueHandle <IValue> >().GetVirtualMachine()));

            throw new NotImplementedException();
        }
Пример #13
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)));
        }
        public JavaDebugExceptionEvent(enum_EVENTATTRIBUTES attributes, JavaDebugProgram program, IThreadReference thread, IObjectReference exceptionObject, ILocation location, ILocation catchLocation)
            : base(attributes)
        {
            Contract.Requires <ArgumentNullException>(program != null, "program");
            Contract.Requires <ArgumentNullException>(thread != null, "thread");
            Contract.Requires <ArgumentNullException>(exceptionObject != null, "exceptionObject");

            _program         = program;
            _thread          = thread;
            _exceptionObject = exceptionObject;
            _location        = location;
            _catchLocation   = catchLocation;
        }
Пример #15
0
        public JavaDebugExceptionEvent(enum_EVENTATTRIBUTES attributes, JavaDebugProgram program, IThreadReference thread, IObjectReference exceptionObject, ILocation location, ILocation catchLocation)
            : base(attributes)
        {
            Contract.Requires<ArgumentNullException>(program != null, "program");
            Contract.Requires<ArgumentNullException>(thread != null, "thread");
            Contract.Requires<ArgumentNullException>(exceptionObject != null, "exceptionObject");

            _program = program;
            _thread = thread;
            _exceptionObject = exceptionObject;
            _location = location;
            _catchLocation = catchLocation;
        }
Пример #16
0
        public static void AbortAndFreeAll(this IThreadReference reference, int timeoutmSec = (int)Common.Extensions.TimeSpan.TimeSpanExtensions.MicrosecondsPerMillisecond)
        {
            foreach (var tp in reference.GetReferencedThreads())
            {
                //Take a reference to that thread
                System.Threading.Thread t = tp;

                //Call AbortAndFree                                                    //Should be Stopped to check for stop?
                if (false == Media.Common.Extensions.Thread.ThreadExtensions.TryAbortAndFree(ref t, System.Threading.ThreadState.Running, timeoutmSec))
                {
                    t = null;                                                                                                                                     //Remove the reference if required
                }
            }
        }
Пример #17
0
        public static void AbortAndFreeAll(this IThreadReference reference, System.TimeSpan timeout)
        {
            foreach (var tp in reference.GetReferencedThreads())
            {
                //Take a reference to that thread
                System.Threading.Thread t = tp;

                //Call AbortAndFree                                                    //Should be Stopped to check for stop?
                if (false == ThreadExtensions.TryAbortAndFree(ref t, timeout, System.Threading.ThreadState.Running))
                {
                    t = null;                                                                                                  //Remove the reference if required
                }
            }
        }
Пример #18
0
        public IStepRequest CreateStepRequest(IThreadReference thread, StepSize size, StepDepth depth)
        {
            ThreadReference threadReference = thread as ThreadReference;

            if ((threadReference == null || !threadReference.VirtualMachine.Equals(this.VirtualMachine)) && thread != null)
            {
                throw new VirtualMachineMismatchException();
            }

            var request = new StepRequest(VirtualMachine, threadReference, size, depth);

            _stepRequests.Add(request);
            return(request);
        }
Пример #19
0
        public int ContinueFromSynchronousEvent(IDebugEvent2 pEvent)
        {
            if (pEvent == null)
            {
                throw new ArgumentNullException("pEvent");
            }
            if (!(pEvent is DebugEvent))
            {
                return(VSConstants.E_INVALIDARG);
            }

            if (pEvent is IDebugEngineCreateEvent2)
            {
                return(VSConstants.S_OK);
            }

            IPropertyOwner propertyOwner = pEvent as IPropertyOwner;

            if (propertyOwner != null)
            {
                bool manualResume;
                propertyOwner.Properties.TryGetProperty("ManualResume", out manualResume);

                SuspendPolicy suspendPolicy;
                if (!manualResume && propertyOwner.Properties.TryGetProperty(typeof(SuspendPolicy), out suspendPolicy))
                {
                    IThreadReference thread = propertyOwner.Properties.GetProperty <IThreadReference>(typeof(IThreadReference));

                    switch (suspendPolicy)
                    {
                    case SuspendPolicy.All:
                        JavaDebugProgram program = propertyOwner.Properties.GetProperty <JavaDebugProgram>(typeof(JavaDebugProgram));
                        JavaDebugThread  debugThread;
                        program.Threads.TryGetValue(thread.GetUniqueId(), out debugThread);
                        program.Continue(debugThread);
                        break;

                    case SuspendPolicy.EventThread:
                        Task.Factory.StartNew(thread.Resume).HandleNonCriticalExceptions();
                        break;

                    case SuspendPolicy.None:
                        break;
                    }
                }
            }

            return(VSConstants.S_OK);
        }
        private void ManualContinueFromEvent(ThreadEventArgs e)
        {
            switch (e.SuspendPolicy)
            {
            case SuspendPolicy.All:
                JavaDebugThread thread;
                _threads.TryGetValue(e.Thread.GetUniqueId(), out thread);
                Continue(thread);
                break;

            case SuspendPolicy.EventThread:
                IThreadReference threadReference = e.Thread;
                Task.Factory.StartNew(threadReference.Resume).HandleNonCriticalExceptions();
                break;

            case SuspendPolicy.None:
                break;
            }
        }
Пример #21
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)));
        }
 private static void SetEventProperties(DebugEvent debugEvent, IEventRequest request, SuspendPolicy suspendPolicy, IVirtualMachine virtualMachine, IThreadReference thread, bool manualResume)
 {
     Contract.Requires <ArgumentNullException>(debugEvent != null, "debugEvent");
     debugEvent.Properties.AddProperty(typeof(IEventRequest), request);
     debugEvent.Properties.AddProperty(typeof(SuspendPolicy), suspendPolicy);
     debugEvent.Properties.AddProperty(typeof(IVirtualMachine), virtualMachine);
     debugEvent.Properties.AddProperty(typeof(IThreadReference), thread);
     debugEvent.Properties.AddProperty("ManualResume", manualResume);
 }
 public void AddThreadFilter(IThreadReference thread)
 {
     throw new NotImplementedException();
 }
Пример #24
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));
        }
        public IStepRequest CreateStepRequest(IThreadReference thread, StepSize size, StepDepth depth)
        {
            Contract.Requires<VirtualMachineMismatchException>(thread == null || this.GetVirtualMachine().Equals(thread.GetVirtualMachine()));
            Contract.Ensures(Contract.Result<IStepRequest>() != null);
            Contract.Ensures(this.GetVirtualMachine().Equals(Contract.Result<IStepRequest>().GetVirtualMachine()));

            throw new NotImplementedException();
        }
 public IStrongValueHandle<IValue> InvokeMethod(IThreadReference thread, IMethod method, InvokeOptions options, params IValue[] arguments)
 {
     throw new NotImplementedException();
 }
 public IStrongValueHandle <IValue> InvokeMethod(IThreadReference thread, IMethod method, InvokeOptions options, params IValue[] arguments)
 {
     throw new NotImplementedException();
 }
Пример #28
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)));
        }
Пример #29
0
 private static void SetEventProperties(DebugEvent debugEvent, IEventRequest request, SuspendPolicy suspendPolicy, IVirtualMachine virtualMachine, IThreadReference thread, bool manualResume)
 {
     Contract.Requires<ArgumentNullException>(debugEvent != null, "debugEvent");
     debugEvent.Properties.AddProperty(typeof(IEventRequest), request);
     debugEvent.Properties.AddProperty(typeof(SuspendPolicy), suspendPolicy);
     debugEvent.Properties.AddProperty(typeof(IVirtualMachine), virtualMachine);
     debugEvent.Properties.AddProperty(typeof(IThreadReference), thread);
     debugEvent.Properties.AddProperty("ManualResume", manualResume);
 }
Пример #30
0
        public IStepRequest CreateStepRequest(IThreadReference thread, StepSize size, StepDepth depth)
        {
            ThreadReference threadReference = thread as ThreadReference;
            if ((threadReference == null || !threadReference.VirtualMachine.Equals(this.VirtualMachine)) && thread != null)
                throw new VirtualMachineMismatchException();

            var request = new StepRequest(VirtualMachine, threadReference, size, depth);
            _stepRequests.Add(request);
            return request;
        }