Search in sources :

Example 1 with StepRequest

use of com.sun.jdi.request.StepRequest in project intellij-community by JetBrains.

the class DebugProcessImpl method doStep.

/**
   *
   * @param suspendContext
   * @param stepThread
   * @param size the step size. One of {@link StepRequest#STEP_LINE} or {@link StepRequest#STEP_MIN}
   * @param depth
   * @param hint may be null
   */
protected void doStep(final SuspendContextImpl suspendContext, final ThreadReferenceProxyImpl stepThread, int size, int depth, RequestHint hint) {
    if (stepThread == null) {
        return;
    }
    try {
        final ThreadReference stepThreadReference = stepThread.getThreadReference();
        if (LOG.isDebugEnabled()) {
            LOG.debug("DO_STEP: creating step request for " + stepThreadReference);
        }
        deleteStepRequests(stepThreadReference);
        EventRequestManager requestManager = getVirtualMachineProxy().eventRequestManager();
        StepRequest stepRequest = requestManager.createStepRequest(stepThreadReference, size, depth);
        if (!(hint != null && hint.isIgnoreFilters())) /*&& depth == StepRequest.STEP_INTO*/
        {
            checkPositionNotFiltered(stepThread, filters -> filters.forEach(f -> stepRequest.addClassExclusionFilter(f.getPattern())));
        }
        // suspend policy to match the suspend policy of the context:
        // if all threads were suspended, then during stepping all the threads must be suspended
        // if only event thread were suspended, then only this particular thread must be suspended during stepping
        stepRequest.setSuspendPolicy(suspendContext.getSuspendPolicy() == EventRequest.SUSPEND_EVENT_THREAD ? EventRequest.SUSPEND_EVENT_THREAD : EventRequest.SUSPEND_ALL);
        if (hint != null) {
            //noinspection HardCodedStringLiteral
            stepRequest.putProperty("hint", hint);
        }
        stepRequest.enable();
    } catch (ObjectCollectedException ignored) {
    }
}
Also used : UIUtil(com.intellij.util.ui.UIUtil) PrimitiveRenderer(com.intellij.debugger.ui.tree.render.PrimitiveRenderer) MessageType(com.intellij.openapi.ui.MessageType) StackCapturingLineBreakpoint(com.intellij.debugger.ui.breakpoints.StackCapturingLineBreakpoint) HashMap(com.intellij.util.containers.HashMap) com.intellij.execution.process(com.intellij.execution.process) EventRequest(com.sun.jdi.request.EventRequest) XDebugSessionImpl(com.intellij.xdebugger.impl.XDebugSessionImpl) PsiManager(com.intellij.psi.PsiManager) Semaphore(com.intellij.util.concurrency.Semaphore) Disposer(com.intellij.openapi.util.Disposer) ApplicationNamesInfo(com.intellij.openapi.application.ApplicationNamesInfo) ClassRenderer(com.intellij.debugger.ui.tree.render.ClassRenderer) ExecutionResult(com.intellij.execution.ExecutionResult) Messages(com.intellij.openapi.ui.Messages) Logger(com.intellij.openapi.diagnostic.Logger) XDebugSession(com.intellij.xdebugger.XDebugSession) MethodReturnValueWatcher(com.intellij.debugger.engine.requests.MethodReturnValueWatcher) StackFrameProxyImpl(com.intellij.debugger.jdi.StackFrameProxyImpl) Extensions(com.intellij.openapi.extensions.Extensions) RemoteConnection(com.intellij.execution.configurations.RemoteConnection) com.intellij.debugger.engine.evaluation(com.intellij.debugger.engine.evaluation) NodeRenderer(com.intellij.debugger.ui.tree.render.NodeRenderer) BreakpointManager(com.intellij.debugger.ui.breakpoints.BreakpointManager) GlobalSearchScope(com.intellij.psi.search.GlobalSearchScope) StepIntoBreakpoint(com.intellij.debugger.ui.breakpoints.StepIntoBreakpoint) com.intellij.debugger.impl(com.intellij.debugger.impl) ActionsBundle(com.intellij.idea.ActionsBundle) com.sun.jdi.connect(com.sun.jdi.connect) MagicConstant(org.intellij.lang.annotations.MagicConstant) Nullable(org.jetbrains.annotations.Nullable) ClassFilter(com.intellij.ui.classFilter.ClassFilter) JavaSdkType(com.intellij.openapi.projectRoots.JavaSdkType) ProjectJdkTable(com.intellij.openapi.projectRoots.ProjectJdkTable) XSourcePosition(com.intellij.xdebugger.XSourcePosition) ArrayRenderer(com.intellij.debugger.ui.tree.render.ArrayRenderer) StreamEx(one.util.streamex.StreamEx) com.intellij.debugger(com.intellij.debugger) VirtualMachineProxyImpl(com.intellij.debugger.jdi.VirtualMachineProxyImpl) ApplicationManager(com.intellij.openapi.application.ApplicationManager) ExecutionUtil(com.intellij.execution.runners.ExecutionUtil) com.intellij.util(com.intellij.util) NotNull(org.jetbrains.annotations.NotNull) DebuggerClassFilterProvider(com.intellij.ui.classFilter.DebuggerClassFilterProvider) EventRequestManager(com.sun.jdi.request.EventRequestManager) NodeRendererSettings(com.intellij.debugger.settings.NodeRendererSettings) java.util(java.util) DebuggerAction(com.intellij.debugger.actions.DebuggerAction) ThreadReferenceProxyImpl(com.intellij.debugger.jdi.ThreadReferenceProxyImpl) ExecutionException(com.intellij.execution.ExecutionException) XDebuggerActions(com.intellij.xdebugger.impl.actions.XDebuggerActions) NonNls(org.jetbrains.annotations.NonNls) AtomicBoolean(java.util.concurrent.atomic.AtomicBoolean) ValueDescriptor(com.intellij.debugger.ui.tree.ValueDescriptor) StepRequest(com.sun.jdi.request.StepRequest) ContainerUtil(com.intellij.util.containers.ContainerUtil) AtomicReference(java.util.concurrent.atomic.AtomicReference) DebuggerCommandImpl(com.intellij.debugger.engine.events.DebuggerCommandImpl) DebuggerContextCommandImpl(com.intellij.debugger.engine.events.DebuggerContextCommandImpl) StatusBarUtil(com.intellij.openapi.wm.impl.status.StatusBarUtil) ThreadReferenceProxy(com.intellij.debugger.engine.jdi.ThreadReferenceProxy) RequestManagerImpl(com.intellij.debugger.engine.requests.RequestManagerImpl) RunToCursorBreakpoint(com.intellij.debugger.ui.breakpoints.RunToCursorBreakpoint) ToolWindowId(com.intellij.openapi.wm.ToolWindowId) Project(com.intellij.openapi.project.Project) PsiFile(com.intellij.psi.PsiFile) SuspendContextCommandImpl(com.intellij.debugger.engine.events.SuspendContextCommandImpl) UserDataHolderBase(com.intellij.openapi.util.UserDataHolderBase) Patches(com.intellij.Patches) StringUtil(com.intellij.openapi.util.text.StringUtil) IOException(java.io.IOException) UnknownHostException(java.net.UnknownHostException) Disposable(com.intellij.openapi.Disposable) Sdk(com.intellij.openapi.projectRoots.Sdk) SystemInfo(com.intellij.openapi.util.SystemInfo) CommonClassNames(com.intellij.psi.CommonClassNames) DebuggerSettings(com.intellij.debugger.settings.DebuggerSettings) DebuggerActions(com.intellij.debugger.actions.DebuggerActions) Pair(com.intellij.openapi.util.Pair) com.sun.jdi(com.sun.jdi) CantRunException(com.intellij.execution.CantRunException) StepRequest(com.sun.jdi.request.StepRequest) EventRequestManager(com.sun.jdi.request.EventRequestManager)

Example 2 with StepRequest

use of com.sun.jdi.request.StepRequest in project intellij-community by JetBrains.

the class DebugProcessImpl method deleteStepRequests.

void deleteStepRequests(@Nullable final ThreadReference stepThread) {
    EventRequestManager requestManager = getVirtualMachineProxy().eventRequestManager();
    List<StepRequest> stepRequests = requestManager.stepRequests();
    if (!stepRequests.isEmpty()) {
        final List<StepRequest> toDelete = new ArrayList<>(stepRequests.size());
        for (final StepRequest request : stepRequests) {
            ThreadReference threadReference = request.thread();
            // [jeka] on attempt to delete a request assigned to a thread with unknown status, a JDWP error occurs
            try {
                if (threadReference.status() != ThreadReference.THREAD_STATUS_UNKNOWN && (stepThread == null || stepThread.equals(threadReference))) {
                    toDelete.add(request);
                }
            } catch (IllegalThreadStateException e) {
                // undocumented by JDI: may be thrown when querying thread status
                LOG.info(e);
            } catch (ObjectCollectedException ignored) {
            }
        }
        requestManager.deleteEventRequests(toDelete);
    }
}
Also used : StepRequest(com.sun.jdi.request.StepRequest) EventRequestManager(com.sun.jdi.request.EventRequestManager)

Example 3 with StepRequest

use of com.sun.jdi.request.StepRequest in project che by eclipse.

the class JavaDebugger method doStep.

private void doStep(int depth) throws DebuggerException {
    lock.lock();
    try {
        clearSteps();
        StepRequest request = getEventManager().createStepRequest(getCurrentThread(), StepRequest.STEP_LINE, depth);
        request.addCountFilter(1);
        request.enable();
        resume(newDto(ResumeActionDto.class));
    } finally {
        lock.unlock();
    }
}
Also used : StepRequest(com.sun.jdi.request.StepRequest) ResumeActionDto(org.eclipse.che.api.debug.shared.dto.action.ResumeActionDto)

Example 4 with StepRequest

use of com.sun.jdi.request.StepRequest in project kotlin by JetBrains.

the class DebuggerSteppingHelper method createStepRequest.

// copied from DebugProcessImpl.doStep
private static void createStepRequest(@NotNull SuspendContextImpl suspendContext, @Nullable ThreadReferenceProxyImpl stepThread, @NotNull EventRequestManager requestManager, int size, int depth) {
    if (stepThread == null) {
        return;
    }
    try {
        ThreadReference stepThreadReference = stepThread.getThreadReference();
        requestManager.deleteEventRequests(requestManager.stepRequests());
        StepRequest stepRequest = requestManager.createStepRequest(stepThreadReference, size, depth);
        List<ClassFilter> activeFilters = getActiveFilters();
        if (!activeFilters.isEmpty()) {
            String currentClassName = getCurrentClassName(stepThread);
            if (currentClassName == null || !DebuggerUtilsEx.isFiltered(currentClassName, activeFilters)) {
                // add class filters
                for (ClassFilter filter : activeFilters) {
                    stepRequest.addClassExclusionFilter(filter.getPattern());
                }
            }
        }
        // suspend policy to match the suspend policy of the context:
        // if all threads were suspended, then during stepping all the threads must be suspended
        // if only event thread were suspended, then only this particular thread must be suspended during stepping
        stepRequest.setSuspendPolicy(suspendContext.getSuspendPolicy() == EventRequest.SUSPEND_EVENT_THREAD ? EventRequest.SUSPEND_EVENT_THREAD : EventRequest.SUSPEND_ALL);
        stepRequest.enable();
    } catch (ObjectCollectedException ignored) {
    }
}
Also used : ObjectCollectedException(com.sun.jdi.ObjectCollectedException) ClassFilter(com.intellij.ui.classFilter.ClassFilter) StepRequest(com.sun.jdi.request.StepRequest) ThreadReference(com.sun.jdi.ThreadReference)

Aggregations

StepRequest (com.sun.jdi.request.StepRequest)4 EventRequestManager (com.sun.jdi.request.EventRequestManager)2 Patches (com.intellij.Patches)1 com.intellij.debugger (com.intellij.debugger)1 DebuggerAction (com.intellij.debugger.actions.DebuggerAction)1 DebuggerActions (com.intellij.debugger.actions.DebuggerActions)1 com.intellij.debugger.engine.evaluation (com.intellij.debugger.engine.evaluation)1 DebuggerCommandImpl (com.intellij.debugger.engine.events.DebuggerCommandImpl)1 DebuggerContextCommandImpl (com.intellij.debugger.engine.events.DebuggerContextCommandImpl)1 SuspendContextCommandImpl (com.intellij.debugger.engine.events.SuspendContextCommandImpl)1 ThreadReferenceProxy (com.intellij.debugger.engine.jdi.ThreadReferenceProxy)1 MethodReturnValueWatcher (com.intellij.debugger.engine.requests.MethodReturnValueWatcher)1 RequestManagerImpl (com.intellij.debugger.engine.requests.RequestManagerImpl)1 com.intellij.debugger.impl (com.intellij.debugger.impl)1 StackFrameProxyImpl (com.intellij.debugger.jdi.StackFrameProxyImpl)1 ThreadReferenceProxyImpl (com.intellij.debugger.jdi.ThreadReferenceProxyImpl)1 VirtualMachineProxyImpl (com.intellij.debugger.jdi.VirtualMachineProxyImpl)1 DebuggerSettings (com.intellij.debugger.settings.DebuggerSettings)1 NodeRendererSettings (com.intellij.debugger.settings.NodeRendererSettings)1 BreakpointManager (com.intellij.debugger.ui.breakpoints.BreakpointManager)1