Search in sources :

Example 21 with XDebugSession

use of com.intellij.xdebugger.XDebugSession in project intellij-community by JetBrains.

the class SortValuesToggleAction method update.

@Override
public void update(@NotNull AnActionEvent e) {
    super.update(e);
    XDebugSession session = XDebugSession.DATA_KEY.getData(e.getDataContext());
    e.getPresentation().setEnabledAndVisible(session != null && !session.getDebugProcess().isValuesCustomSorted());
}
Also used : XDebugSession(com.intellij.xdebugger.XDebugSession)

Example 22 with XDebugSession

use of com.intellij.xdebugger.XDebugSession in project android by JetBrains.

the class InstantRunPositionManager method getPsiFileByLocation.

/**
   * Returns the PSI file corresponding to the given JDI location.
   * This method is overridden so that we may provide an API specific version of the sources for platform (android.jar) classes.
   *
   * TODO: This method is implemented as part of InstantRunPositionManager, although it has nothing to do with instant run.
   * The issue is that the position manager extension API is a little odd: the position manager that was added last is the one that gets
   * used, and luckily for us, the instant run position manager is being added last. Ideally, we should move just the code that identifies
   * the Psi File given a location to a separate extension mechanism. See b.android.com/208140
   */
@Nullable
@Override
protected PsiFile getPsiFileByLocation(Project project, Location location) {
    PsiFile file = super.getPsiFileByLocation(project, location);
    if (file == null) {
        return null;
    }
    if (!DebuggerSettings.getInstance().SHOW_ALTERNATIVE_SOURCE) {
        return file;
    }
    // we only care about providing an alternate source for files inside the platform.
    if (!AndroidFacet.isInAndroidSdk(file)) {
        return file;
    }
    XDebugSession session = XDebuggerManager.getInstance(project).getCurrentSession();
    if (session == null) {
        return file;
    }
    String relPath = getRelPathFromSourceRoot(project, file);
    if (relPath == null) {
        return file;
    }
    AndroidVersion version = session.getDebugProcess().getProcessHandler().getUserData(AndroidSessionInfo.ANDROID_DEVICE_API_LEVEL);
    if (version == null) {
        return file;
    }
    PsiFile source = getSourceForApiLevel(project, version, relPath);
    return source == null ? file : source;
}
Also used : XDebugSession(com.intellij.xdebugger.XDebugSession) PsiFile(com.intellij.psi.PsiFile) AndroidVersion(com.android.sdklib.AndroidVersion) Nullable(org.jetbrains.annotations.Nullable)

Example 23 with XDebugSession

use of com.intellij.xdebugger.XDebugSession 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 24 with XDebugSession

use of com.intellij.xdebugger.XDebugSession in project intellij-plugins by JetBrains.

the class DartRunner method doExecuteDartDebug.

private RunContentDescriptor doExecuteDartDebug(@NotNull final RunProfileState state, @NotNull final ExecutionEnvironment env, @Nullable final String dasExecutionContextId) throws RuntimeConfigurationError, ExecutionException {
    final DartSdk sdk = DartSdk.getDartSdk(env.getProject());
    // already checked
    assert (sdk != null);
    final RunProfile runConfiguration = env.getRunProfile();
    final VirtualFile contextFileOrDir;
    VirtualFile currentWorkingDirectory;
    final ExecutionResult executionResult;
    final String debuggingHost;
    final int observatoryPort;
    if (runConfiguration instanceof DartRunConfigurationBase) {
        contextFileOrDir = ((DartRunConfigurationBase) runConfiguration).getRunnerParameters().getDartFileOrDirectory();
        final String cwd = ((DartRunConfigurationBase) runConfiguration).getRunnerParameters().computeProcessWorkingDirectory(env.getProject());
        currentWorkingDirectory = LocalFileSystem.getInstance().findFileByPath((cwd));
        executionResult = state.execute(env.getExecutor(), this);
        if (executionResult == null) {
            return null;
        }
        debuggingHost = null;
        observatoryPort = ((DartCommandLineRunningState) state).getObservatoryPort();
    } else if (runConfiguration instanceof DartRemoteDebugConfiguration) {
        final String path = ((DartRemoteDebugConfiguration) runConfiguration).getParameters().getDartProjectPath();
        contextFileOrDir = LocalFileSystem.getInstance().findFileByPath(path);
        if (contextFileOrDir == null) {
            throw new RuntimeConfigurationError("Folder not found: " + FileUtil.toSystemDependentName(path));
        }
        currentWorkingDirectory = contextFileOrDir;
        executionResult = null;
        debuggingHost = ((DartRemoteDebugConfiguration) runConfiguration).getParameters().getHost();
        observatoryPort = ((DartRemoteDebugConfiguration) runConfiguration).getParameters().getPort();
    } else {
        LOG.error("Unexpected run configuration: " + runConfiguration.getClass().getName());
        return null;
    }
    FileDocumentManager.getInstance().saveAllDocuments();
    final XDebuggerManager debuggerManager = XDebuggerManager.getInstance(env.getProject());
    final XDebugSession debugSession = debuggerManager.startSession(env, new XDebugProcessStarter() {

        @Override
        @NotNull
        public XDebugProcess start(@NotNull final XDebugSession session) {
            final DartUrlResolver dartUrlResolver = getDartUrlResolver(env.getProject(), contextFileOrDir);
            return new DartVmServiceDebugProcess(session, StringUtil.notNullize(debuggingHost, "localhost"), observatoryPort, executionResult, dartUrlResolver, dasExecutionContextId, runConfiguration instanceof DartRemoteDebugConfiguration, getTimeout(), currentWorkingDirectory);
        }
    });
    return debugSession.getRunContentDescriptor();
}
Also used : VirtualFile(com.intellij.openapi.vfs.VirtualFile) XDebugSession(com.intellij.xdebugger.XDebugSession) XDebugProcess(com.intellij.xdebugger.XDebugProcess) DartRunConfigurationBase(com.jetbrains.lang.dart.ide.runner.base.DartRunConfigurationBase) XDebuggerManager(com.intellij.xdebugger.XDebuggerManager) ExecutionResult(com.intellij.execution.ExecutionResult) RunProfile(com.intellij.execution.configurations.RunProfile) NotNull(org.jetbrains.annotations.NotNull) DartVmServiceDebugProcess(com.jetbrains.lang.dart.ide.runner.server.vmService.DartVmServiceDebugProcess) DartSdk(com.jetbrains.lang.dart.sdk.DartSdk) DartRemoteDebugConfiguration(com.jetbrains.lang.dart.ide.runner.server.DartRemoteDebugConfiguration) XDebugProcessStarter(com.intellij.xdebugger.XDebugProcessStarter) DartUrlResolver(com.jetbrains.lang.dart.util.DartUrlResolver) RuntimeConfigurationError(com.intellij.execution.configurations.RuntimeConfigurationError)

Example 25 with XDebugSession

use of com.intellij.xdebugger.XDebugSession in project intellij-plugins by JetBrains.

the class DartPopFrameAction method getStackFrame.

@Nullable
private static DartVmServiceStackFrame getStackFrame(@NotNull final AnActionEvent e) {
    final Project project = e.getProject();
    if (project == null)
        return null;
    XDebugSession session = e.getData(XDebugSession.DATA_KEY);
    if (session == null) {
        session = XDebuggerManager.getInstance(project).getCurrentSession();
    }
    if (session != null) {
        XStackFrame frame = session.getCurrentStackFrame();
        if (frame instanceof DartVmServiceStackFrame) {
            return ((DartVmServiceStackFrame) frame);
        }
    }
    return null;
}
Also used : Project(com.intellij.openapi.project.Project) XDebugSession(com.intellij.xdebugger.XDebugSession) DartVmServiceStackFrame(com.jetbrains.lang.dart.ide.runner.server.vmService.frame.DartVmServiceStackFrame) XStackFrame(com.intellij.xdebugger.frame.XStackFrame) Nullable(org.jetbrains.annotations.Nullable)

Aggregations

XDebugSession (com.intellij.xdebugger.XDebugSession)50 Project (com.intellij.openapi.project.Project)15 NotNull (org.jetbrains.annotations.NotNull)13 XDebugProcessStarter (com.intellij.xdebugger.XDebugProcessStarter)9 XDebugSessionImpl (com.intellij.xdebugger.impl.XDebugSessionImpl)9 XDebugProcess (com.intellij.xdebugger.XDebugProcess)8 Nullable (org.jetbrains.annotations.Nullable)7 DebuggerSession (com.intellij.debugger.impl.DebuggerSession)6 IOException (java.io.IOException)5 DebugProcessImpl (com.intellij.debugger.engine.DebugProcessImpl)4 ExecutionException (com.intellij.execution.ExecutionException)4 XValueNodeImpl (com.intellij.xdebugger.impl.ui.tree.nodes.XValueNodeImpl)4 DebugEnvironment (com.intellij.debugger.DebugEnvironment)3 VirtualMachineProxyImpl (com.intellij.debugger.jdi.VirtualMachineProxyImpl)3 ExecutionResult (com.intellij.execution.ExecutionResult)3 RunContentDescriptor (com.intellij.execution.ui.RunContentDescriptor)3 XSourcePosition (com.intellij.xdebugger.XSourcePosition)3 ServerSocket (java.net.ServerSocket)3 List (java.util.List)3 DefaultDebugEnvironment (com.intellij.debugger.DefaultDebugEnvironment)2