Search in sources :

Example 11 with DebuggerSession

use of com.intellij.debugger.impl.DebuggerSession in project intellij-community by JetBrains.

the class ExportThreadsAction method update.

public void update(AnActionEvent e) {
    Presentation presentation = e.getPresentation();
    Project project = e.getProject();
    if (project == null) {
        presentation.setEnabled(false);
        return;
    }
    DebuggerSession debuggerSession = (DebuggerManagerEx.getInstanceEx(project)).getContext().getDebuggerSession();
    presentation.setEnabled(debuggerSession != null && debuggerSession.isPaused());
}
Also used : Project(com.intellij.openapi.project.Project) DebuggerSession(com.intellij.debugger.impl.DebuggerSession) Presentation(com.intellij.openapi.actionSystem.Presentation)

Example 12 with DebuggerSession

use of com.intellij.debugger.impl.DebuggerSession in project android by JetBrains.

the class AndroidJavaDebugger method hasExistingDebugSession.

private static boolean hasExistingDebugSession(@NotNull Project project, @NotNull final String debugPort, @NotNull final String runConfigName) {
    Collection<RunContentDescriptor> descriptors = null;
    Project[] openProjects = ProjectManager.getInstance().getOpenProjects();
    Project targetProject = null;
    // Scan through open project to find if this port has been opened in any session.
    for (Project openProject : openProjects) {
        targetProject = openProject;
        // First check the titles of the run configurations.
        descriptors = ExecutionHelper.findRunningConsoleByTitle(targetProject, new NotNullFunction<String, Boolean>() {

            @NotNull
            @Override
            public Boolean fun(String title) {
                return runConfigName.equals(title);
            }
        });
        // If it can't find a matching title, check the debugger sessions.
        if (descriptors.isEmpty()) {
            DebuggerSession debuggerSession = findJdwpDebuggerSession(targetProject, debugPort);
            if (debuggerSession != null) {
                XDebugSession session = debuggerSession.getXDebugSession();
                if (session != null) {
                    descriptors = Collections.singletonList(session.getRunContentDescriptor());
                } else {
                    // Detach existing session.
                    debuggerSession.getProcess().stop(false);
                }
            }
        }
        if (!descriptors.isEmpty()) {
            break;
        }
    }
    if (descriptors != null && !descriptors.isEmpty()) {
        return activateDebugSessionWindow(project, descriptors.iterator().next());
    }
    return false;
}
Also used : Project(com.intellij.openapi.project.Project) XDebugSession(com.intellij.xdebugger.XDebugSession) RunContentDescriptor(com.intellij.execution.ui.RunContentDescriptor) DebuggerSession(com.intellij.debugger.impl.DebuggerSession) NotNullFunction(com.intellij.util.NotNullFunction)

Example 13 with DebuggerSession

use of com.intellij.debugger.impl.DebuggerSession in project buck by facebook.

the class TestExecutionState method attachDebugger.

private void attachDebugger(String title, String port) {
    final RemoteConnection remoteConnection = new RemoteConnection(/* useSockets */
    true, "localhost", port, /* serverMode */
    false);
    final RemoteStateState state = new RemoteStateState(mProject, remoteConnection);
    final String name = title + " debugger (" + port + ")";
    final ConfigurationFactory cfgFactory = ConfigurationTypeUtil.findConfigurationType("Remote").getConfigurationFactories()[0];
    RunnerAndConfigurationSettings runSettings = RunManager.getInstance(mProject).createRunConfiguration(name, cfgFactory);
    final Executor debugExecutor = DefaultDebugExecutor.getDebugExecutorInstance();
    final ExecutionEnvironment env = new ExecutionEnvironmentBuilder(mProject, debugExecutor).runProfile(runSettings.getConfiguration()).build();
    final int pollTimeout = 3000;
    final DebugEnvironment environment = new DefaultDebugEnvironment(env, state, remoteConnection, pollTimeout);
    ApplicationManager.getApplication().invokeLater(() -> {
        try {
            final DebuggerSession debuggerSession = DebuggerManagerEx.getInstanceEx(mProject).attachVirtualMachine(environment);
            if (debuggerSession == null) {
                return;
            }
            XDebuggerManager.getInstance(mProject).startSessionAndShowTab(name, null, new XDebugProcessStarter() {

                @Override
                @NotNull
                public XDebugProcess start(@NotNull XDebugSession session) {
                    return JavaDebugProcess.create(session, debuggerSession);
                }
            });
        } catch (ExecutionException e) {
            LOG.error("failed to attach to debugger on port " + port + " with polling timeout " + pollTimeout);
        }
    });
}
Also used : XDebugSession(com.intellij.xdebugger.XDebugSession) ExecutionEnvironment(com.intellij.execution.runners.ExecutionEnvironment) XDebugProcess(com.intellij.xdebugger.XDebugProcess) NotNull(org.jetbrains.annotations.NotNull) DefaultDebugEnvironment(com.intellij.debugger.DefaultDebugEnvironment) DefaultDebugExecutor(com.intellij.execution.executors.DefaultDebugExecutor) Executor(com.intellij.execution.Executor) DebuggerSession(com.intellij.debugger.impl.DebuggerSession) XDebugProcessStarter(com.intellij.xdebugger.XDebugProcessStarter) ConfigurationFactory(com.intellij.execution.configurations.ConfigurationFactory) RunnerAndConfigurationSettings(com.intellij.execution.RunnerAndConfigurationSettings) RemoteConnection(com.intellij.execution.configurations.RemoteConnection) RemoteStateState(com.intellij.debugger.engine.RemoteStateState) ExecutionEnvironmentBuilder(com.intellij.execution.runners.ExecutionEnvironmentBuilder) ExecutionException(com.intellij.execution.ExecutionException) DefaultDebugEnvironment(com.intellij.debugger.DefaultDebugEnvironment) DebugEnvironment(com.intellij.debugger.DebugEnvironment)

Example 14 with DebuggerSession

use of com.intellij.debugger.impl.DebuggerSession in project intellij-community by JetBrains.

the class JavaAwareTestConsoleProperties method getDebugSession.

@Nullable
public DebuggerSession getDebugSession() {
    final DebuggerManagerEx debuggerManager = DebuggerManagerEx.getInstanceEx(getProject());
    if (debuggerManager == null)
        return null;
    final Collection<DebuggerSession> sessions = debuggerManager.getSessions();
    for (final DebuggerSession debuggerSession : sessions) {
        if (getConsole() == debuggerSession.getProcess().getExecutionResult().getExecutionConsole())
            return debuggerSession;
    }
    return null;
}
Also used : DebuggerManagerEx(com.intellij.debugger.DebuggerManagerEx) DebuggerSession(com.intellij.debugger.impl.DebuggerSession) Nullable(org.jetbrains.annotations.Nullable)

Example 15 with DebuggerSession

use of com.intellij.debugger.impl.DebuggerSession in project intellij-community by JetBrains.

the class JvmSmartStepIntoActionHandler method perform.

public void perform(@NotNull final Project project, final AnActionEvent event) {
    final DebuggerContextImpl debuggerContext = (DebuggerManagerEx.getInstanceEx(project)).getContext();
    final DebuggerSession session = debuggerContext.getDebuggerSession();
    if (session != null) {
        doStep(project, debuggerContext.getSourcePosition(), session);
    }
}
Also used : DebuggerSession(com.intellij.debugger.impl.DebuggerSession) DebuggerContextImpl(com.intellij.debugger.impl.DebuggerContextImpl)

Aggregations

DebuggerSession (com.intellij.debugger.impl.DebuggerSession)25 DebuggerContextImpl (com.intellij.debugger.impl.DebuggerContextImpl)11 Project (com.intellij.openapi.project.Project)9 XDebugSession (com.intellij.xdebugger.XDebugSession)6 DebuggerManagerEx (com.intellij.debugger.DebuggerManagerEx)4 DebugProcessImpl (com.intellij.debugger.engine.DebugProcessImpl)4 Nullable (org.jetbrains.annotations.Nullable)4 SourcePosition (com.intellij.debugger.SourcePosition)3 DebuggerCommandImpl (com.intellij.debugger.engine.events.DebuggerCommandImpl)3 DebuggerContextCommandImpl (com.intellij.debugger.engine.events.DebuggerContextCommandImpl)3 DebugEnvironment (com.intellij.debugger.DebugEnvironment)2 SuspendContextImpl (com.intellij.debugger.engine.SuspendContextImpl)2 DebuggerTree (com.intellij.debugger.ui.impl.watch.DebuggerTree)2 DebuggerTreeNodeImpl (com.intellij.debugger.ui.impl.watch.DebuggerTreeNodeImpl)2 NodeDescriptorImpl (com.intellij.debugger.ui.impl.watch.NodeDescriptorImpl)2 WatchItemDescriptor (com.intellij.debugger.ui.impl.watch.WatchItemDescriptor)2 Presentation (com.intellij.openapi.actionSystem.Presentation)2 Ref (com.intellij.openapi.util.Ref)2 XDebugProcess (com.intellij.xdebugger.XDebugProcess)2 XDebugProcessStarter (com.intellij.xdebugger.XDebugProcessStarter)2