Search in sources :

Example 1 with DebuggerCommandImpl

use of com.intellij.debugger.engine.events.DebuggerCommandImpl in project intellij-community by JetBrains.

the class BreakpointWithHighlighter method updateUI.

/**
   * updates the state of breakpoint and all the related UI widgets etc
   */
@Override
public final void updateUI() {
    if (!isVisible() || ApplicationManager.getApplication().isUnitTestMode()) {
        return;
    }
    DebuggerInvocationUtil.swingInvokeLater(myProject, () -> {
        if (!isValid()) {
            return;
        }
        DebuggerContextImpl context = DebuggerManagerEx.getInstanceEx(myProject).getContext();
        DebugProcessImpl debugProcess = context.getDebugProcess();
        if (debugProcess == null || !debugProcess.isAttached()) {
            updateCaches(null);
            updateGutter();
        } else {
            debugProcess.getManagerThread().invoke(new DebuggerCommandImpl() {

                @Override
                protected void action() throws Exception {
                    ApplicationManager.getApplication().runReadAction(() -> {
                        if (!myProject.isDisposed()) {
                            updateCaches(debugProcess);
                        }
                    });
                    DebuggerInvocationUtil.swingInvokeLater(myProject, BreakpointWithHighlighter.this::updateGutter);
                }
            });
        }
    });
}
Also used : DebuggerCommandImpl(com.intellij.debugger.engine.events.DebuggerCommandImpl) DebugProcessImpl(com.intellij.debugger.engine.DebugProcessImpl) DebuggerContextImpl(com.intellij.debugger.impl.DebuggerContextImpl) InvalidDataException(com.intellij.openapi.util.InvalidDataException)

Example 2 with DebuggerCommandImpl

use of com.intellij.debugger.engine.events.DebuggerCommandImpl in project intellij-community by JetBrains.

the class DebuggerManagerThreadImpl method terminateAndInvoke.

/**
   * waits COMMAND_TIMEOUT milliseconds
   * if worker thread is still processing the same command
   * calls terminateCommand
   */
public void terminateAndInvoke(DebuggerCommandImpl command, int terminateTimeoutMillis) {
    final DebuggerCommandImpl currentCommand = myEvents.getCurrentEvent();
    invoke(command);
    if (currentCommand != null) {
        AppExecutorUtil.getAppScheduledExecutorService().schedule(() -> {
            if (currentCommand == myEvents.getCurrentEvent()) {
                // if current command is still in progress, cancel it
                getCurrentRequest().requestStop();
                try {
                    getCurrentRequest().join();
                } catch (InterruptedException ignored) {
                } catch (Exception e) {
                    throw new RuntimeException(e);
                } finally {
                    if (!myDisposed) {
                        startNewWorkerThread();
                    }
                }
            }
        }, terminateTimeoutMillis, TimeUnit.MILLISECONDS);
    }
}
Also used : DebuggerCommandImpl(com.intellij.debugger.engine.events.DebuggerCommandImpl) VMDisconnectedException(com.sun.jdi.VMDisconnectedException)

Example 3 with DebuggerCommandImpl

use of com.intellij.debugger.engine.events.DebuggerCommandImpl 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 DebuggerCommandImpl

use of com.intellij.debugger.engine.events.DebuggerCommandImpl in project intellij-community by JetBrains.

the class DebugProcessImpl method createVirtualMachine.

private void createVirtualMachine(final DebugEnvironment environment) {
    final String sessionName = environment.getSessionName();
    final long pollTimeout = environment.getPollTimeout();
    final Semaphore semaphore = new Semaphore();
    semaphore.down();
    final AtomicBoolean connectorIsReady = new AtomicBoolean(false);
    myDebugProcessDispatcher.addListener(new DebugProcessListener() {

        @Override
        public void connectorIsReady() {
            connectorIsReady.set(true);
            semaphore.up();
            myDebugProcessDispatcher.removeListener(this);
        }
    });
    // reload to make sure that source positions are initialized
    DebuggerManagerEx.getInstanceEx(myProject).getBreakpointManager().reloadBreakpoints();
    getManagerThread().schedule(new DebuggerCommandImpl() {

        @Override
        protected void action() {
            VirtualMachine vm = null;
            try {
                final long time = System.currentTimeMillis();
                do {
                    try {
                        vm = createVirtualMachineInt();
                        break;
                    } catch (final ExecutionException e) {
                        if (pollTimeout > 0 && !myConnection.isServerMode() && e.getCause() instanceof IOException) {
                            synchronized (this) {
                                try {
                                    wait(500);
                                } catch (InterruptedException ignored) {
                                    break;
                                }
                            }
                        } else {
                            ProcessHandler processHandler = getProcessHandler();
                            boolean terminated = processHandler != null && (processHandler.isProcessTerminating() || processHandler.isProcessTerminated());
                            fail();
                            DebuggerInvocationUtil.swingInvokeLater(myProject, () -> {
                                // this problem to the user
                                if ((myExecutionResult != null && !terminated) || !connectorIsReady.get()) {
                                    ExecutionUtil.handleExecutionError(myProject, ToolWindowId.DEBUG, sessionName, e);
                                }
                            });
                            break;
                        }
                    }
                } while (System.currentTimeMillis() - time < pollTimeout);
            } finally {
                semaphore.up();
            }
            if (vm != null) {
                final VirtualMachine vm1 = vm;
                afterProcessStarted(() -> getManagerThread().schedule(new DebuggerCommandImpl() {

                    @Override
                    protected void action() throws Exception {
                        commitVM(vm1);
                    }
                }));
            }
        }

        @Override
        protected void commandCancelled() {
            try {
                super.commandCancelled();
            } finally {
                semaphore.up();
            }
        }
    });
    semaphore.waitFor();
}
Also used : Semaphore(com.intellij.util.concurrency.Semaphore) IOException(java.io.IOException) ExecutionException(com.intellij.execution.ExecutionException) IOException(java.io.IOException) UnknownHostException(java.net.UnknownHostException) CantRunException(com.intellij.execution.CantRunException) AtomicBoolean(java.util.concurrent.atomic.AtomicBoolean) DebuggerCommandImpl(com.intellij.debugger.engine.events.DebuggerCommandImpl) ExecutionException(com.intellij.execution.ExecutionException)

Example 5 with DebuggerCommandImpl

use of com.intellij.debugger.engine.events.DebuggerCommandImpl in project intellij-community by JetBrains.

the class ExportThreadsAction method actionPerformed.

public void actionPerformed(AnActionEvent e) {
    final Project project = e.getProject();
    if (project == null) {
        return;
    }
    DebuggerContextImpl context = (DebuggerManagerEx.getInstanceEx(project)).getContext();
    final DebuggerSession session = context.getDebuggerSession();
    if (session != null && session.isAttached()) {
        final DebugProcessImpl process = context.getDebugProcess();
        if (process != null) {
            process.getManagerThread().invoke(new DebuggerCommandImpl() {

                protected void action() throws Exception {
                    final List<ThreadState> threads = ThreadDumpAction.buildThreadStates(process.getVirtualMachineProxy());
                    ApplicationManager.getApplication().invokeLater(() -> ExportToTextFileAction.export(project, ThreadDumpPanel.createToFileExporter(project, threads)), ModalityState.NON_MODAL);
                }
            });
        }
    }
}
Also used : Project(com.intellij.openapi.project.Project) DebuggerSession(com.intellij.debugger.impl.DebuggerSession) DebuggerCommandImpl(com.intellij.debugger.engine.events.DebuggerCommandImpl) DebugProcessImpl(com.intellij.debugger.engine.DebugProcessImpl) List(java.util.List) DebuggerContextImpl(com.intellij.debugger.impl.DebuggerContextImpl)

Aggregations

DebuggerCommandImpl (com.intellij.debugger.engine.events.DebuggerCommandImpl)24 DebugProcessImpl (com.intellij.debugger.engine.DebugProcessImpl)9 DebuggerContextImpl (com.intellij.debugger.impl.DebuggerContextImpl)8 ThreadReferenceProxyImpl (com.intellij.debugger.jdi.ThreadReferenceProxyImpl)5 EvaluateException (com.intellij.debugger.engine.evaluation.EvaluateException)4 Project (com.intellij.openapi.project.Project)4 SuspendContextImpl (com.intellij.debugger.engine.SuspendContextImpl)3 DebuggerSession (com.intellij.debugger.impl.DebuggerSession)3 DebuggerTreeNodeImpl (com.intellij.debugger.ui.impl.watch.DebuggerTreeNodeImpl)3 ThreadDescriptorImpl (com.intellij.debugger.ui.impl.watch.ThreadDescriptorImpl)3 ExecutionException (com.intellij.execution.ExecutionException)3 VMDisconnectedException (com.sun.jdi.VMDisconnectedException)3 List (java.util.List)3 SuspendContextCommandImpl (com.intellij.debugger.engine.events.SuspendContextCommandImpl)2 VirtualMachineProxyImpl (com.intellij.debugger.jdi.VirtualMachineProxyImpl)2 InvalidDataException (com.intellij.openapi.util.InvalidDataException)2 XDebugSession (com.intellij.xdebugger.XDebugSession)2 ArrayList (java.util.ArrayList)2 Client (com.android.ddmlib.Client)1 InstantRunClient (com.android.tools.fd.client.InstantRunClient)1