Ejemplo n.º 1
0
 public JvmRemoteLocation(JvmMethodRemoteHandle method, jlocation location)
 {
     Method   = method;
     Location = location;
 }
Ejemplo n.º 2
0
 internal JvmLocation(JvmEnvironment environment, jmethodID method, jlocation location)
 {
     throw new NotImplementedException();
 }
            public override bool ProcessEvent(JvmtiEnvironment environment, JniEnvironment nativeEnvironment, EventProcessor processor, ThreadId thread, TaggedReferenceTypeId @class, Location?location)
            {
                if (!base.ProcessEvent(environment, nativeEnvironment, processor, thread, @class, location))
                {
                    return(false);
                }

                // Step Out is implemented with Frame Pop events set at the correct depth
                if (_depth == StepDepth.Out)
                {
                    if (location.HasValue && !location.Value.Method.Equals(_lastMethod))
                    {
                        _lastLocation = new jlocation((long)location.Value.Index);
                        _lastMethod   = location.Value.Method;
                        UpdateLastLine(environment);
                    }

                    return(true);
                }

                using (var threadHandle = environment.VirtualMachine.GetLocalReferenceForThread(nativeEnvironment, thread))
                {
                    int stackDepth;
                    JvmtiErrorHandler.ThrowOnFailure(environment.GetFrameCount(threadHandle.Value, out stackDepth));

                    if (_hasMethodInfo && stackDepth > _stackDepth)
                    {
                        bool convertToFramePop;
                        if (location.HasValue && (!_convertedToFramePop || !_framePopMethod.Equals(location.Value.Method)) && ShouldSkipCurrentMethod(processor.VirtualMachine, environment, nativeEnvironment, threadHandle.Value, stackDepth, location.Value, out convertToFramePop))
                        {
                            if (convertToFramePop)
                            {
                                // remove the single step event
                                JvmtiErrorHandler.ThrowOnFailure((jvmtiError)processor.ClearEventInternal(EventKind.FramePop, this.RequestId));
                                JvmtiErrorHandler.ThrowOnFailure((jvmtiError)processor.ClearEventInternal(EventKind.SingleStep, this.RequestId));
                                // set an actual step filter to respond when the thread arrives back in this frame
                                JvmtiErrorHandler.ThrowOnFailure((jvmtiError)processor.SetEventInternal(environment, nativeEnvironment, EventKind.FramePop, this));
                                _convertedToFramePop = true;
                                _framePopMethod      = location.Value.Method;
                            }

                            return(false);
                        }
                        else
                        {
                            _convertedToFramePop = false;
                            return(true);
                        }
                    }
                    else if (stackDepth == _stackDepth)
                    {
                        if (_size == StepSize.Statement && _disassembledMethod != null)
                        {
                            int instructionIndex = _disassembledMethod.Instructions.FindIndex(i => (uint)i.Offset == location.Value.Index);
                            if (instructionIndex >= 0 && _evaluationStackDepths != null && (_evaluationStackDepths[instructionIndex] ?? 0) != 0)
                            {
                                return(false);
                            }
                            else if (instructionIndex >= 0 && _disassembledMethod.Instructions[instructionIndex].OpCode.FlowControl == JavaFlowControl.Branch)
                            {
                                // follow branch instructions before stopping
                                return(false);
                            }
                        }
                        else if (_lastLine != null)
                        {
                            // see if we're on the same line
                            LineNumberData[] lines;
                            jvmtiError       error = environment.GetLineNumberTable(location.Value.Method, out lines);
                            if (error == jvmtiError.None)
                            {
                                LineNumberData entry = lines.LastOrDefault(i => i.LineCodeIndex <= (long)location.Value.Index);
                                if (entry.LineNumber == _lastLine)
                                {
                                    return(false);
                                }
                            }
                        }
                    }

                    if (location.HasValue)
                    {
                        _lastLocation = new jlocation((long)location.Value.Index);
                        _lastMethod   = location.Value.Method;
                        UpdateLastLine(environment);
                    }

                    _stackDepth = stackDepth;
                    return(true);
                }
            }
Ejemplo n.º 4
0
        private void HandleFieldModification(jvmtiEnvHandle env, JNIEnvHandle jniEnv, jthread threadHandle, jmethodID method, jlocation jlocation, jclass fieldClassHandle, jobject @objectHandle, jfieldID fieldId, byte signatureType, jvalue newValue)
        {
            JvmEnvironment     environment = JvmEnvironment.GetEnvironment(env);
            JvmThreadReference thread      = JvmThreadReference.FromHandle(environment, jniEnv, threadHandle, true);
            JvmLocation        location    = new JvmLocation(environment, method, jlocation);
            JvmClassReference  fieldClass  = JvmClassReference.FromHandle(environment, jniEnv, fieldClassHandle, true);
            JvmObjectReference @object     = JvmObjectReference.FromHandle(environment, jniEnv, objectHandle, true);
            JvmField           field       = new JvmField(environment, fieldId);

            foreach (var processor in _processors)
            {
                processor.HandleFieldModification(environment, thread, location, fieldClass, @object, field, signatureType, newValue);
            }
        }
Ejemplo n.º 5
0
        private void HandleBreakpoint(jvmtiEnvHandle env, JNIEnvHandle jniEnv, jthread threadHandle, jmethodID method, jlocation jlocation)
        {
            JvmEnvironment     environment = JvmEnvironment.GetEnvironment(env);
            JvmThreadReference thread      = JvmThreadReference.FromHandle(environment, jniEnv, threadHandle, true);
            JvmLocation        location    = new JvmLocation(environment, method, jlocation);

            foreach (var processor in _processors)
            {
                processor.HandleBreakpoint(environment, thread, location);
            }
        }
Ejemplo n.º 6
0
        private void HandleExceptionCatch(jvmtiEnvHandle env, JNIEnvHandle jniEnv, jthread threadHandle, jmethodID method, jlocation jlocation, jobject exceptionHandle)
        {
            JvmEnvironment     environment = JvmEnvironment.GetEnvironment(env);
            JvmThreadReference thread      = JvmThreadReference.FromHandle(environment, jniEnv, threadHandle, true);
            JvmLocation        location    = new JvmLocation(environment, method, jlocation);
            JvmObjectReference exception   = JvmObjectReference.FromHandle(environment, jniEnv, exceptionHandle, true);

            foreach (var processor in _processors)
            {
                processor.HandleExceptionCatch(environment, thread, location, exception);
            }
        }