use of com.intellij.xdebugger.XDebugProcessStarter in project intellij-community by JetBrains.
the class PydevConsoleRunnerImpl method connectToDebugger.
private XDebugSession connectToDebugger() throws ExecutionException {
final ServerSocket serverSocket = PythonCommandLineState.createServerSocket();
final XDebugSession session = XDebuggerManager.getInstance(myProject).startSessionAndShowTab("Python Console Debugger", PythonIcons.Python.Python, null, true, new XDebugProcessStarter() {
@NotNull
public XDebugProcess start(@NotNull final XDebugSession session) {
PythonDebugLanguageConsoleView debugConsoleView = new PythonDebugLanguageConsoleView(myProject, mySdk);
PyConsoleDebugProcessHandler consoleDebugProcessHandler = new PyConsoleDebugProcessHandler(myProcessHandler);
PyConsoleDebugProcess consoleDebugProcess = new PyConsoleDebugProcess(session, serverSocket, debugConsoleView, consoleDebugProcessHandler);
PythonDebugConsoleCommunication communication = PyDebugRunner.initDebugConsoleView(myProject, consoleDebugProcess, debugConsoleView, consoleDebugProcessHandler, session);
communication.addCommunicationListener(new ConsoleCommunicationListener() {
@Override
public void commandExecuted(boolean more) {
session.rebuildViews();
}
@Override
public void inputRequested() {
}
});
myPydevConsoleCommunication.setDebugCommunication(communication);
debugConsoleView.attachToProcess(consoleDebugProcessHandler);
consoleDebugProcess.waitForNextConnection();
try {
consoleDebugProcess.connect(myPydevConsoleCommunication);
} catch (Exception e) {
//TODO
LOG.error(e);
}
myProcessHandler.notifyTextAvailable("\nDebugger connected.\n", ProcessOutputTypes.STDERR);
return consoleDebugProcess;
}
});
return session;
}
use of com.intellij.xdebugger.XDebugProcessStarter 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;
}
});
}
use of com.intellij.xdebugger.XDebugProcessStarter in project intellij-community by JetBrains.
the class PyDebugRunner method createSession.
protected XDebugSession createSession(@NotNull RunProfileState state, @NotNull final ExecutionEnvironment environment) throws ExecutionException {
FileDocumentManager.getInstance().saveAllDocuments();
final PythonCommandLineState pyState = (PythonCommandLineState) state;
Sdk sdk = pyState.getSdk();
PyDebugSessionFactory sessionCreator = PyDebugSessionFactory.findExtension(sdk);
if (sessionCreator != null) {
return sessionCreator.createSession(pyState, environment);
}
final ServerSocket serverSocket = PythonCommandLineState.createServerSocket();
final int serverLocalPort = serverSocket.getLocalPort();
RunProfile profile = environment.getRunProfile();
final ExecutionResult result = pyState.execute(environment.getExecutor(), createCommandLinePatchers(environment.getProject(), pyState, profile, serverLocalPort));
return XDebuggerManager.getInstance(environment.getProject()).startSession(environment, new XDebugProcessStarter() {
@Override
@NotNull
public XDebugProcess start(@NotNull final XDebugSession session) {
PyDebugProcess pyDebugProcess = createDebugProcess(session, serverSocket, result, pyState);
createConsoleCommunicationAndSetupActions(environment.getProject(), result, pyDebugProcess, session);
return pyDebugProcess;
}
});
}
use of com.intellij.xdebugger.XDebugProcessStarter in project intellij-community by JetBrains.
the class DebuggerPanelsManager method attachVirtualMachine.
@Nullable
public RunContentDescriptor attachVirtualMachine(DebugUIEnvironment environment) throws ExecutionException {
final DebugEnvironment modelEnvironment = environment.getEnvironment();
final DebuggerSession debuggerSession = DebuggerManagerEx.getInstanceEx(myProject).attachVirtualMachine(modelEnvironment);
if (debuggerSession == null) {
return null;
}
XDebugSession debugSession = XDebuggerManager.getInstance(myProject).startSessionAndShowTab(modelEnvironment.getSessionName(), environment.getReuseContent(), new XDebugProcessStarter() {
@Override
@NotNull
public XDebugProcess start(@NotNull XDebugSession session) {
return JavaDebugProcess.create(session, debuggerSession);
}
});
return debugSession.getRunContentDescriptor();
}
use of com.intellij.xdebugger.XDebugProcessStarter in project intellij-community by JetBrains.
the class GenericDebuggerRunner method attachVirtualMachine.
@Nullable
protected RunContentDescriptor attachVirtualMachine(RunProfileState state, @NotNull ExecutionEnvironment env, RemoteConnection connection, long pollTimeout) throws ExecutionException {
DebugEnvironment environment = new DefaultDebugEnvironment(env, state, connection, pollTimeout);
final DebuggerSession debuggerSession = DebuggerManagerEx.getInstanceEx(env.getProject()).attachVirtualMachine(environment);
if (debuggerSession == null) {
return null;
}
final DebugProcessImpl debugProcess = debuggerSession.getProcess();
return XDebuggerManager.getInstance(env.getProject()).startSession(env, new XDebugProcessStarter() {
@Override
@NotNull
public XDebugProcess start(@NotNull XDebugSession session) {
XDebugSessionImpl sessionImpl = (XDebugSessionImpl) session;
ExecutionResult executionResult = debugProcess.getExecutionResult();
sessionImpl.addExtraActions(executionResult.getActions());
if (executionResult instanceof DefaultExecutionResult) {
sessionImpl.addRestartActions(((DefaultExecutionResult) executionResult).getRestartActions());
}
return JavaDebugProcess.create(session, debuggerSession);
}
}).getRunContentDescriptor();
}
Aggregations