protected void createLocalProcess(String className) throws ExecutionException, InterruptedException, InvocationTargetException { LOG.assertTrue(myDebugProcess == null); myDebuggerSession = createLocalProcess(DebuggerSettings.SOCKET_TRANSPORT, createJavaParameters(className)); myDebugProcess = myDebuggerSession.getProcess(); }
protected DebuggerSession createLocalSession(final JavaParameters javaParameters) throws ExecutionException, InterruptedException { createBreakpoints(javaParameters.getMainClass()); DebuggerSettings.getInstance().DEBUGGER_TRANSPORT = DebuggerSettings.SOCKET_TRANSPORT; GenericDebuggerRunnerSettings debuggerRunnerSettings = new GenericDebuggerRunnerSettings(); debuggerRunnerSettings.LOCAL = true; final RemoteConnection debugParameters = DebuggerManagerImpl.createDebugParameters(javaParameters, debuggerRunnerSettings, false); ExecutionEnvironment environment = new ExecutionEnvironmentBuilder(myProject, DefaultDebugExecutor.getDebugExecutorInstance()) .runnerSettings(debuggerRunnerSettings) .runProfile(new MockConfiguration()) .build(); final JavaCommandLineState javaCommandLineState = new JavaCommandLineState(environment) { @Override protected JavaParameters createJavaParameters() { return javaParameters; } @Override protected GeneralCommandLine createCommandLine() throws ExecutionException { return CommandLineBuilder.createFromJavaParameters(getJavaParameters()); } }; ApplicationManager.getApplication() .invokeAndWait( () -> { try { myDebuggerSession = DebuggerManagerEx.getInstanceEx(myProject) .attachVirtualMachine( new DefaultDebugEnvironment( new ExecutionEnvironmentBuilder( myProject, DefaultDebugExecutor.getDebugExecutorInstance()) .runProfile(new MockConfiguration()) .build(), javaCommandLineState, debugParameters, false)); XDebuggerManager.getInstance(myProject) .startSession( javaCommandLineState.getEnvironment(), new XDebugProcessStarter() { @Override @NotNull public XDebugProcess start(@NotNull XDebugSession session) { return JavaDebugProcess.create(session, myDebuggerSession); } }); } catch (ExecutionException e) { LOG.error(e); } }); myDebugProcess = myDebuggerSession.getProcess(); myDebugProcess.addProcessListener( new ProcessAdapter() { @Override public void onTextAvailable(ProcessEvent event, Key outputType) { print(event.getText(), outputType); } }); assertNotNull(myDebuggerSession); assertNotNull(myDebugProcess); return myDebuggerSession; }