Search in sources :

Example 1 with PyLocalPositionConverter

use of com.jetbrains.python.debugger.PyLocalPositionConverter in project intellij-community by JetBrains.

the class PyAttachToProcessDebugRunner method launchRemoteDebugServer.

private XDebugSession launchRemoteDebugServer() throws ExecutionException {
    final ServerSocket serverSocket;
    try {
        //noinspection SocketOpenedButNotSafelyClosed
        serverSocket = new ServerSocket(0);
    } catch (IOException e) {
        throw new ExecutionException("Failed to find free socket port", e);
    }
    PyAttachToProcessCommandLineState state = PyAttachToProcessCommandLineState.create(myProject, mySdkPath, serverSocket.getLocalPort(), myPid);
    final ExecutionResult result = state.execute(state.getEnvironment().getExecutor(), this);
    //start remote debug server
    return XDebuggerManager.getInstance(myProject).startSessionAndShowTab(String.valueOf(myPid), null, new XDebugProcessStarter() {

        @org.jetbrains.annotations.NotNull
        public XDebugProcess start(@NotNull final XDebugSession session) {
            PyRemoteDebugProcess pyDebugProcess = new PyRemoteDebugProcess(session, serverSocket, result.getExecutionConsole(), result.getProcessHandler(), "") {

                @Override
                protected void printConsoleInfo() {
                }

                @Override
                protected String getConnectionMessage() {
                    return "Attaching to a process with PID=" + myPid;
                }

                @Override
                protected String getConnectionTitle() {
                    return "Attaching Debugger";
                }
            };
            pyDebugProcess.setPositionConverter(new PyLocalPositionConverter());
            createConsoleCommunicationAndSetupActions(myProject, result, pyDebugProcess, session);
            return pyDebugProcess;
        }
    });
}
Also used : XDebugSession(com.intellij.xdebugger.XDebugSession) XDebugProcess(com.intellij.xdebugger.XDebugProcess) ServerSocket(java.net.ServerSocket) ExecutionResult(com.intellij.execution.ExecutionResult) IOException(java.io.IOException) XDebugProcessStarter(com.intellij.xdebugger.XDebugProcessStarter) PyLocalPositionConverter(com.jetbrains.python.debugger.PyLocalPositionConverter) ExecutionException(com.intellij.execution.ExecutionException) NotNull(org.jetbrains.annotations.NotNull) PyRemoteDebugProcess(com.jetbrains.python.debugger.PyRemoteDebugProcess)

Aggregations

ExecutionException (com.intellij.execution.ExecutionException)1 ExecutionResult (com.intellij.execution.ExecutionResult)1 XDebugProcess (com.intellij.xdebugger.XDebugProcess)1 XDebugProcessStarter (com.intellij.xdebugger.XDebugProcessStarter)1 XDebugSession (com.intellij.xdebugger.XDebugSession)1 PyLocalPositionConverter (com.jetbrains.python.debugger.PyLocalPositionConverter)1 PyRemoteDebugProcess (com.jetbrains.python.debugger.PyRemoteDebugProcess)1 IOException (java.io.IOException)1 ServerSocket (java.net.ServerSocket)1 NotNull (org.jetbrains.annotations.NotNull)1