Ejemplo n.º 1
0
        public void SendStepRequest(StepDepth stepDepth)
        {
            var stepEventRequest = _vm.CreateStepRequest(_mainThread);

            stepEventRequest.Depth = stepDepth;
            stepEventRequest.Size  = StepSize.Line;
            stepEventRequest.Enable();
            SafeResume();
            _requestWaitingForResponse = stepEventRequest;
        }
 public static EventRequestModifier Step(ThreadId thread, StepSize size, StepDepth depth)
 {
     return(new EventRequestModifier()
     {
         Kind = ModifierKind.Step,
         Thread = thread,
         StepSize = size,
         StepDepth = depth,
     });
 }
Ejemplo n.º 3
0
        public StepRequest(VirtualMachine virtualMachine, ThreadReference thread, StepSize size, StepDepth depth)
            : base(virtualMachine)
        {
            Contract.Requires(virtualMachine != null);

            _thread = thread;
            _size = size;
            _depth = depth;

            ThreadId threadId = default(ThreadId);
            if (thread != null)
                threadId = thread.ThreadId;

            Modifiers.Add(Types.EventRequestModifier.Step(threadId, (Types.StepSize)size, (Types.StepDepth)depth));
        }
        public IStepRequest GetStepRequest(StepSize size, StepDepth depth)
        {
            int kindIndex;

            switch (depth)
            {
            case StepDepth.Into:
                kindIndex = 0;
                break;

            case StepDepth.Out:
                kindIndex = 1;
                break;

            case StepDepth.Over:
                kindIndex = 2;
                break;

            default:
                throw new NotSupportedException();
            }

            int unitIndex;

            switch (size)
            {
            case StepSize.Instruction:
                unitIndex = 0;
                break;

            case StepSize.Line:
                unitIndex = 1;
                break;

            case StepSize.Statement:
                unitIndex = 2;
                break;

            default:
                throw new NotSupportedException();
            }

            IStepRequest request = _stepRequests[kindIndex * 3 + unitIndex];

            Contract.Assert(request.Size == size);
            Contract.Assert(request.Depth == depth);
            return(request);
        }
Ejemplo n.º 5
0
        public IStepRequest GetStepRequest(StepSize size, StepDepth depth)
        {
            int kindIndex;
            switch (depth)
            {
            case StepDepth.Into:
                kindIndex = 0;
                break;

            case StepDepth.Out:
                kindIndex = 1;
                break;

            case StepDepth.Over:
                kindIndex = 2;
                break;

            default:
                throw new NotSupportedException();
            }

            int unitIndex;
            switch (size)
            {
            case StepSize.Instruction:
                unitIndex = 0;
                break;

            case StepSize.Line:
                unitIndex = 1;
                break;

            case StepSize.Statement:
                unitIndex = 2;
                break;

            default:
                throw new NotSupportedException();
            }

            IStepRequest request = _stepRequests[kindIndex * 3 + unitIndex];
            Contract.Assert(request.Size == size);
            Contract.Assert(request.Depth == depth);
            return request;
        }
        public StepRequest(VirtualMachine virtualMachine, ThreadReference thread, StepSize size, StepDepth depth)
            : base(virtualMachine)
        {
            Contract.Requires(virtualMachine != null);

            _thread = thread;
            _size   = size;
            _depth  = depth;

            ThreadId threadId = default(ThreadId);

            if (thread != null)
            {
                threadId = thread.ThreadId;
            }

            Modifiers.Add(Types.EventRequestModifier.Step(threadId, (Types.StepSize)size, (Types.StepDepth)depth));
        }
Ejemplo n.º 7
0
		void Step (StepDepth depth, StepSize size)
		{
			ThreadPool.QueueUserWorkItem (delegate {
				try {
					Adaptor.CancelAsyncOperations (); // This call can block, so it has to run in background thread to avoid keeping the main session lock
					var req = vm.CreateStepRequest (current_thread);
					req.Depth = depth;
					req.Size = size;
					if (assemblyFilters != null && assemblyFilters.Count > 0)
						req.AssemblyFilter = assemblyFilters;
					req.Enabled = true;
					currentStepRequest = req;
					OnResumed ();
					vm.Resume ();
					DequeueEventsForFirstThread ();
				} catch (Exception ex) {
					LoggingService.LogError ("Next Line command failed", ex);
				}
			});
		}
Ejemplo n.º 8
0
 public void SendStepRequest(StepDepth stepDepth)
 {
     var stepEventRequest = _vm.CreateStepRequest(_mainThread);
     stepEventRequest.Depth = stepDepth;
     stepEventRequest.Size = StepSize.Line;
     stepEventRequest.Enable();
     SafeResume();
     _requestWaitingForResponse = stepEventRequest;
 }
Ejemplo n.º 9
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();
        }
            public StepEventFilter(EventKind internalEventKind, RequestId requestId, SuspendPolicy suspendPolicy, IEnumerable <EventRequestModifier> modifiers, ThreadId thread, JvmtiEnvironment environment, JniEnvironment nativeEnvironment, StepSize size, StepDepth depth)
                : base(internalEventKind, requestId, suspendPolicy, modifiers, thread)
            {
                if (size == StepSize.Statement && JavaVM.DisableStatementStepping)
                {
                    size = StepSize.Line;
                }

                _size  = size;
                _depth = depth;

                // gather reference information for the thread
                using (var threadHandle = environment.VirtualMachine.GetLocalReferenceForThread(nativeEnvironment, thread))
                {
                    if (threadHandle.IsAlive)
                    {
                        jvmtiError error = environment.GetFrameLocation(threadHandle.Value, 0, out _lastMethod, out _lastLocation);
                        if (error == jvmtiError.None)
                        {
                            error = environment.GetFrameCount(threadHandle.Value, out _stackDepth);
                        }

                        if (error == jvmtiError.None)
                        {
                            _hasMethodInfo = true;
                        }

                        UpdateLastLine(environment);

                        if (error == jvmtiError.None && size == StepSize.Statement && (depth == StepDepth.Over || depth == StepDepth.Into))
                        {
                            byte[] bytecode;
                            JvmtiErrorHandler.ThrowOnFailure(environment.GetBytecodes(_lastMethod, out bytecode));
                            _disassembledMethod = BytecodeDisassembler.Disassemble(bytecode);

                            TaggedReferenceTypeId declaringClass;
                            JvmtiErrorHandler.ThrowOnFailure(environment.GetMethodDeclaringClass(nativeEnvironment, _lastMethod, out declaringClass));
                            using (var classHandle = environment.VirtualMachine.GetLocalReferenceForClass(nativeEnvironment, declaringClass.TypeId))
                            {
                                int    constantPoolCount;
                                byte[] data;
                                JvmtiErrorHandler.ThrowOnFailure(environment.GetConstantPool(classHandle.Value, out constantPoolCount, out data));

                                List <ConstantPoolEntry> entryList = new List <ConstantPoolEntry>();
                                int currentPosition = 0;
                                for (int i = 0; i < constantPoolCount - 1; i++)
                                {
                                    entryList.Add(ConstantPoolEntry.FromBytes(data, ref currentPosition));
                                    switch (entryList.Last().Type)
                                    {
                                    case ConstantType.Double:
                                    case ConstantType.Long:
                                        // these entries take 2 slots
                                        entryList.Add(ConstantPoolEntry.Reserved);
                                        i++;
                                        break;

                                    default:
                                        break;
                                    }
                                }

                                _constantPool = entryList.AsReadOnly();

                                string classSignature;
                                string classGenericSignature;
                                JvmtiErrorHandler.ThrowOnFailure(environment.GetClassSignature(classHandle.Value, out classSignature, out classGenericSignature));
                                string methodName;
                                string methodSignature;
                                string methodGenericSignature;
                                JvmtiErrorHandler.ThrowOnFailure(environment.GetMethodName(_lastMethod, out methodName, out methodSignature, out methodGenericSignature));

                                jobject classLoader;
                                JvmtiErrorHandler.ThrowOnFailure(environment.GetClassLoader(classHandle.Value, out classLoader));
                                long classLoaderTag;
                                JvmtiErrorHandler.ThrowOnFailure(environment.TagClassLoader(classLoader, out classLoaderTag));

                                ReadOnlyCollection <ExceptionTableEntry> exceptionTable;
                                JvmtiErrorHandler.ThrowOnFailure(environment.VirtualMachine.GetExceptionTable(classLoaderTag, classSignature, methodName, methodSignature, out exceptionTable));

                                _evaluationStackDepths = BytecodeDisassembler.GetEvaluationStackDepths(_disassembledMethod, _constantPool, exceptionTable);
                            }
                        }
                    }
                }
            }
Ejemplo n.º 11
0
        private void DoStep(StepDepth depth)
        {
            Contract.Requires(m_stepRequest == null, "m_stepRequest is not null");

            Log.WriteLine(TraceLevel.Verbose, "Debugger", "Stepping {0}", depth);
            m_stepRequest = m_vm.CreateStepRequest(m_currentThread);
            m_stepRequest.Depth = depth;
            m_stepRequest.Size = StepBy;
            m_stepRequest.Enabled = true;

            m_thread.Resume();
        }
Ejemplo n.º 12
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);
        }
            public StepEventFilter(EventKind internalEventKind, RequestId requestId, SuspendPolicy suspendPolicy, IEnumerable<EventRequestModifier> modifiers, ThreadId thread, JvmtiEnvironment environment, JniEnvironment nativeEnvironment, StepSize size, StepDepth depth)
                : base(internalEventKind, requestId, suspendPolicy, modifiers, thread)
            {
                if (size == StepSize.Statement && JavaVM.DisableStatementStepping)
                    size = StepSize.Line;

                _size = size;
                _depth = depth;

                // gather reference information for the thread
                using (var threadHandle = environment.VirtualMachine.GetLocalReferenceForThread(nativeEnvironment, thread))
                {
                    if (threadHandle.IsAlive)
                    {
                        jvmtiError error = environment.GetFrameLocation(threadHandle.Value, 0, out _lastMethod, out _lastLocation);
                        if (error == jvmtiError.None)
                            error = environment.GetFrameCount(threadHandle.Value, out _stackDepth);

                        if (error == jvmtiError.None)
                            _hasMethodInfo = true;

                        UpdateLastLine(environment);

                        if (error == jvmtiError.None && size == StepSize.Statement && (depth == StepDepth.Over || depth == StepDepth.Into))
                        {
                            byte[] bytecode;
                            JvmtiErrorHandler.ThrowOnFailure(environment.GetBytecodes(_lastMethod, out bytecode));
                            _disassembledMethod = BytecodeDisassembler.Disassemble(bytecode);

                            TaggedReferenceTypeId declaringClass;
                            JvmtiErrorHandler.ThrowOnFailure(environment.GetMethodDeclaringClass(nativeEnvironment, _lastMethod, out declaringClass));
                            using (var classHandle = environment.VirtualMachine.GetLocalReferenceForClass(nativeEnvironment, declaringClass.TypeId))
                            {
                                int constantPoolCount;
                                byte[] data;
                                JvmtiErrorHandler.ThrowOnFailure(environment.GetConstantPool(classHandle.Value, out constantPoolCount, out data));

                                List<ConstantPoolEntry> entryList = new List<ConstantPoolEntry>();
                                int currentPosition = 0;
                                for (int i = 0; i < constantPoolCount - 1; i++)
                                {
                                    entryList.Add(ConstantPoolEntry.FromBytes(data, ref currentPosition));
                                    switch (entryList.Last().Type)
                                    {
                                    case ConstantType.Double:
                                    case ConstantType.Long:
                                        // these entries take 2 slots
                                        entryList.Add(ConstantPoolEntry.Reserved);
                                        i++;
                                        break;

                                    default:
                                        break;
                                    }
                                }

                                _constantPool = entryList.AsReadOnly();

                                string classSignature;
                                string classGenericSignature;
                                JvmtiErrorHandler.ThrowOnFailure(environment.GetClassSignature(classHandle.Value, out classSignature, out classGenericSignature));
                                string methodName;
                                string methodSignature;
                                string methodGenericSignature;
                                JvmtiErrorHandler.ThrowOnFailure(environment.GetMethodName(_lastMethod, out methodName, out methodSignature, out methodGenericSignature));

                                jobject classLoader;
                                JvmtiErrorHandler.ThrowOnFailure(environment.GetClassLoader(classHandle.Value, out classLoader));
                                long classLoaderTag;
                                JvmtiErrorHandler.ThrowOnFailure(environment.TagClassLoader(classLoader, out classLoaderTag));

                                ReadOnlyCollection<ExceptionTableEntry> exceptionTable;
                                JvmtiErrorHandler.ThrowOnFailure(environment.VirtualMachine.GetExceptionTable(classLoaderTag, classSignature, methodName, methodSignature, out exceptionTable));

                                _evaluationStackDepths = BytecodeDisassembler.GetEvaluationStackDepths(_disassembledMethod, _constantPool, exceptionTable);
                            }
                        }
                    }
                }
            }
        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();
        }
Ejemplo n.º 15
0
 public static EventRequestModifier Step(ThreadId thread, StepSize size, StepDepth depth)
 {
     return new EventRequestModifier()
     {
         Kind = ModifierKind.Step,
         Thread = thread,
         StepSize = size,
         StepDepth = depth,
     };
 }
Ejemplo n.º 16
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;
        }