Search in sources :

Example 1 with DebugProcessListener

use of com.intellij.debugger.engine.DebugProcessListener in project android by JetBrains.

the class AndroidRemoteDebugProcessHandler method startNotify.

// This is copied from com.intellij.debugger.engine.RemoteDebugProcessHandler#startNotify
// and modified to only terminate on debug detach if myDetachWhenDoneMonitoring is true.
@Override
public void startNotify() {
    final DebugProcess debugProcess = DebuggerManager.getInstance(myProject).getDebugProcess(this);
    final DebugProcessListener listener = new DebugProcessListener() {

        @Override
        public void processDetached(DebugProcess process, boolean closedByUser) {
            debugProcess.removeDebugProcessListener(this);
            if (myDetachWhenDoneMonitoring) {
                notifyProcessDetached();
            }
        }
    };
    debugProcess.addDebugProcessListener(listener);
    try {
        super.startNotify();
    } finally {
        if (debugProcess.isDetached()) {
            debugProcess.removeDebugProcessListener(listener);
            if (myDetachWhenDoneMonitoring) {
                notifyProcessDetached();
            }
        }
    }
}
Also used : DebugProcess(com.intellij.debugger.engine.DebugProcess) DebugProcessListener(com.intellij.debugger.engine.DebugProcessListener)

Example 2 with DebugProcessListener

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

the class JavaScratchConfiguration method getState.

@Override
public RunProfileState getState(@NotNull Executor executor, @NotNull ExecutionEnvironment env) throws ExecutionException {
    final JavaCommandLineState state = new JavaApplicationCommandLineState<JavaScratchConfiguration>(this, env) {

        @Override
        protected void setupJavaParameters(JavaParameters params) throws ExecutionException {
            super.setupJavaParameters(params);
            final File scrachesOutput = JavaScratchCompilationSupport.getScratchOutputDirectory(getProject());
            if (scrachesOutput != null) {
                params.getClassPath().addFirst(FileUtil.toCanonicalPath(scrachesOutput.getAbsolutePath()).replace('/', File.separatorChar));
            }
        }

        @NotNull
        @Override
        protected OSProcessHandler startProcess() throws ExecutionException {
            final OSProcessHandler handler = super.startProcess();
            if (getRunnerSettings() instanceof DebuggingRunnerData) {
                final VirtualFile vFile = getConfiguration().getScratchVirtualFile();
                if (vFile != null) {
                    DebuggerManager.getInstance(getProject()).addDebugProcessListener(handler, new DebugProcessListener() {

                        @Override
                        public void processAttached(DebugProcess process) {
                            if (vFile.isValid()) {
                                process.appendPositionManager(new JavaScratchPositionManager((DebugProcessImpl) process, vFile));
                            }
                            process.removeDebugProcessListener(this);
                        }
                    });
                }
            }
            return handler;
        }
    };
    state.setConsoleBuilder(TextConsoleBuilderFactory.getInstance().createBuilder(getProject(), getConfigurationModule().getSearchScope()));
    return state;
}
Also used : VirtualFile(com.intellij.openapi.vfs.VirtualFile) DebugProcess(com.intellij.debugger.engine.DebugProcess) DebugProcessListener(com.intellij.debugger.engine.DebugProcessListener) OSProcessHandler(com.intellij.execution.process.OSProcessHandler) VirtualFile(com.intellij.openapi.vfs.VirtualFile) File(java.io.File)

Example 3 with DebugProcessListener

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

the class JavaDebuggerLauncherImpl method startDebugSession.

@Override
public void startDebugSession(@NotNull JavaDebugConnectionData info, @NotNull ExecutionEnvironment executionEnvironment, @NotNull RemoteServer<?> server) throws ExecutionException {
    final Project project = executionEnvironment.getProject();
    final DebuggerPanelsManager manager = DebuggerPanelsManager.getInstance(project);
    final JavaDebugServerModeHandler serverModeHandler = info.getServerModeHandler();
    boolean serverMode = serverModeHandler != null;
    final RemoteConnection remoteConnection = new RemoteConnection(true, info.getHost(), String.valueOf(info.getPort()), serverMode);
    DebugEnvironment debugEnvironment = new RemoteServerDebugEnvironment(project, remoteConnection, executionEnvironment.getRunProfile());
    DebugUIEnvironment debugUIEnvironment = new RemoteServerDebugUIEnvironment(debugEnvironment, executionEnvironment);
    RunContentDescriptor debugContentDescriptor = manager.attachVirtualMachine(debugUIEnvironment);
    LOG.assertTrue(debugContentDescriptor != null);
    ProcessHandler processHandler = debugContentDescriptor.getProcessHandler();
    LOG.assertTrue(processHandler != null);
    if (serverMode) {
        serverModeHandler.attachRemote();
        DebuggerManager.getInstance(executionEnvironment.getProject()).addDebugProcessListener(processHandler, new DebugProcessListener() {

            public void processDetached(DebugProcess process, boolean closedByUser) {
                try {
                    serverModeHandler.detachRemote();
                } catch (ExecutionException e) {
                    LOG.info(e);
                }
            }
        });
    }
}
Also used : RunContentDescriptor(com.intellij.execution.ui.RunContentDescriptor) JavaDebugServerModeHandler(com.intellij.remoteServer.runtime.deployment.debug.JavaDebugServerModeHandler) Project(com.intellij.openapi.project.Project) DebugProcess(com.intellij.debugger.engine.DebugProcess) DebugProcessListener(com.intellij.debugger.engine.DebugProcessListener) DebuggerPanelsManager(com.intellij.debugger.ui.DebuggerPanelsManager) RemoteDebugProcessHandler(com.intellij.debugger.engine.RemoteDebugProcessHandler) ProcessHandler(com.intellij.execution.process.ProcessHandler) RemoteConnection(com.intellij.execution.configurations.RemoteConnection) ExecutionException(com.intellij.execution.ExecutionException) DebugEnvironment(com.intellij.debugger.DebugEnvironment) DebugUIEnvironment(com.intellij.debugger.DebugUIEnvironment)

Aggregations

DebugProcess (com.intellij.debugger.engine.DebugProcess)3 DebugProcessListener (com.intellij.debugger.engine.DebugProcessListener)3 DebugEnvironment (com.intellij.debugger.DebugEnvironment)1 DebugUIEnvironment (com.intellij.debugger.DebugUIEnvironment)1 RemoteDebugProcessHandler (com.intellij.debugger.engine.RemoteDebugProcessHandler)1 DebuggerPanelsManager (com.intellij.debugger.ui.DebuggerPanelsManager)1 ExecutionException (com.intellij.execution.ExecutionException)1 RemoteConnection (com.intellij.execution.configurations.RemoteConnection)1 OSProcessHandler (com.intellij.execution.process.OSProcessHandler)1 ProcessHandler (com.intellij.execution.process.ProcessHandler)1 RunContentDescriptor (com.intellij.execution.ui.RunContentDescriptor)1 Project (com.intellij.openapi.project.Project)1 VirtualFile (com.intellij.openapi.vfs.VirtualFile)1 JavaDebugServerModeHandler (com.intellij.remoteServer.runtime.deployment.debug.JavaDebugServerModeHandler)1 File (java.io.File)1