Search in sources :

Example 1 with ThreadReferenceProxyImpl

use of com.intellij.debugger.jdi.ThreadReferenceProxyImpl in project intellij-community by JetBrains.

the class StackCapturingLineBreakpoint method processLocatableEvent.

@Override
public boolean processLocatableEvent(SuspendContextCommandImpl action, LocatableEvent event) throws EventProcessingException {
    SuspendContextImpl suspendContext = action.getSuspendContext();
    if (suspendContext != null) {
        ThreadReferenceProxyImpl thread = suspendContext.getThread();
        if (thread != null) {
            DebugProcessImpl process = suspendContext.getDebugProcess();
            try {
                StackFrameProxyImpl frameProxy = ContainerUtil.getFirstItem(thread.forceFrames());
                if (frameProxy != null) {
                    Map<Object, List<StackFrameItem>> stacks = process.getUserData(CAPTURED_STACKS);
                    if (stacks == null) {
                        stacks = new CapturedStacksMap();
                        process.putUserData(CAPTURED_STACKS, Collections.synchronizedMap(stacks));
                    }
                    Value key = myCaptureEvaluator.evaluate(new EvaluationContextImpl(suspendContext, frameProxy));
                    if (key instanceof ObjectReference) {
                        List<StackFrameItem> frames = StackFrameItem.createFrames(suspendContext, true);
                        if (frames.size() > MAX_STACK_LENGTH) {
                            frames = frames.subList(0, MAX_STACK_LENGTH);
                        }
                        stacks.put(getKey((ObjectReference) key), frames);
                    }
                }
            } catch (EvaluateException e) {
                LOG.debug(e);
                process.printToConsole(DebuggerBundle.message("error.unable.to.evaluate.capture.expression", e.getMessage()) + "\n");
            }
        }
    }
    return false;
}
Also used : StackFrameProxyImpl(com.intellij.debugger.jdi.StackFrameProxyImpl) ThreadReferenceProxyImpl(com.intellij.debugger.jdi.ThreadReferenceProxyImpl) DebugProcessImpl(com.intellij.debugger.engine.DebugProcessImpl) SuspendContextImpl(com.intellij.debugger.engine.SuspendContextImpl) List(java.util.List) CopyOnWriteArrayList(java.util.concurrent.CopyOnWriteArrayList) StackFrameItem(com.intellij.debugger.memory.utils.StackFrameItem)

Example 2 with ThreadReferenceProxyImpl

use of com.intellij.debugger.jdi.ThreadReferenceProxyImpl in project intellij-community by JetBrains.

the class SuspendContextImpl method setThread.

public void setThread(ThreadReference thread) {
    assertNotResumed();
    ThreadReferenceProxyImpl threadProxy = myDebugProcess.getVirtualMachineProxy().getThreadReferenceProxy(thread);
    LOG.assertTrue(myThread == null || myThread == threadProxy);
    myThread = threadProxy;
}
Also used : ThreadReferenceProxyImpl(com.intellij.debugger.jdi.ThreadReferenceProxyImpl)

Example 3 with ThreadReferenceProxyImpl

use of com.intellij.debugger.jdi.ThreadReferenceProxyImpl in project intellij-community by JetBrains.

the class SuspendManagerImpl method processVote.

private void processVote(final SuspendContextImpl suspendContext) {
    LOG.assertTrue(suspendContext.myVotesToVote > 0);
    suspendContext.myVotesToVote--;
    if (LOG.isDebugEnabled()) {
        LOG.debug("myVotesToVote = " + suspendContext.myVotesToVote);
    }
    if (suspendContext.myVotesToVote == 0) {
        if (suspendContext.myIsVotedForResume) {
            // resume in a separate request to allow other requests be processed (e.g. dependent bpts enable)
            myDebugProcess.getManagerThread().schedule(new DebuggerCommandImpl() {

                @Override
                protected void action() throws Exception {
                    resume(suspendContext);
                }

                @Override
                public Priority getPriority() {
                    return Priority.HIGH;
                }
            });
        } else {
            LOG.debug("vote paused");
            myDebugProcess.logThreads();
            myDebugProcess.cancelRunToCursorBreakpoint();
            final ThreadReferenceProxyImpl thread = suspendContext.getThread();
            myDebugProcess.deleteStepRequests(thread != null ? thread.getThreadReference() : null);
            notifyPaused(suspendContext);
        }
    }
}
Also used : DebuggerCommandImpl(com.intellij.debugger.engine.events.DebuggerCommandImpl) ThreadReferenceProxyImpl(com.intellij.debugger.jdi.ThreadReferenceProxyImpl) InternalException(com.sun.jdi.InternalException) ObjectCollectedException(com.sun.jdi.ObjectCollectedException)

Example 4 with ThreadReferenceProxyImpl

use of com.intellij.debugger.jdi.ThreadReferenceProxyImpl 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 5 with ThreadReferenceProxyImpl

use of com.intellij.debugger.jdi.ThreadReferenceProxyImpl in project intellij-community by JetBrains.

the class DebugProcessEvents method preprocessEvent.

private static void preprocessEvent(SuspendContextImpl suspendContext, ThreadReference thread) {
    ThreadReferenceProxyImpl oldThread = suspendContext.getThread();
    suspendContext.setThread(thread);
    if (oldThread == null) {
        //this is the first event in the eventSet that we process
        suspendContext.getDebugProcess().beforeSuspend(suspendContext);
    }
}
Also used : ThreadReferenceProxyImpl(com.intellij.debugger.jdi.ThreadReferenceProxyImpl)

Aggregations

ThreadReferenceProxyImpl (com.intellij.debugger.jdi.ThreadReferenceProxyImpl)17 DebuggerCommandImpl (com.intellij.debugger.engine.events.DebuggerCommandImpl)6 DebugProcessImpl (com.intellij.debugger.engine.DebugProcessImpl)5 DebuggerContextImpl (com.intellij.debugger.impl.DebuggerContextImpl)4 Project (com.intellij.openapi.project.Project)4 SuspendContextImpl (com.intellij.debugger.engine.SuspendContextImpl)3 StackFrameProxyImpl (com.intellij.debugger.jdi.StackFrameProxyImpl)3 DebuggerTreeNodeImpl (com.intellij.debugger.ui.impl.watch.DebuggerTreeNodeImpl)3 ThreadDescriptorImpl (com.intellij.debugger.ui.impl.watch.ThreadDescriptorImpl)3 ObjectCollectedException (com.sun.jdi.ObjectCollectedException)3 DebuggerContextCommandImpl (com.intellij.debugger.engine.events.DebuggerContextCommandImpl)2 ThreadReferenceProxy (com.intellij.debugger.engine.jdi.ThreadReferenceProxy)2 VirtualMachineProxyImpl (com.intellij.debugger.jdi.VirtualMachineProxyImpl)2 StackCapturingLineBreakpoint (com.intellij.debugger.ui.breakpoints.StackCapturingLineBreakpoint)2 ThreadReference (com.sun.jdi.ThreadReference)2 Nullable (org.jetbrains.annotations.Nullable)2 Patches (com.intellij.Patches)1 JobScheduler (com.intellij.concurrency.JobScheduler)1 com.intellij.debugger (com.intellij.debugger)1 DebuggerBundle (com.intellij.debugger.DebuggerBundle)1