public static RemoteConnection createDebugParameters(
     final JavaParameters parameters,
     GenericDebuggerRunnerSettings settings,
     boolean checkValidity)
     throws ExecutionException {
   return createDebugParameters(
       parameters,
       settings.LOCAL,
       settings.getTransport(),
       settings.getDebugPort(),
       checkValidity);
 }
  protected DebuggerSession createLocalProcess(int transport, final JavaParameters javaParameters)
      throws ExecutionException, InterruptedException, InvocationTargetException {
    createBreakpoints(javaParameters.getMainClass());
    final DebuggerSession[] debuggerSession = new DebuggerSession[] {null};

    DebuggerSettings.getInstance().DEBUGGER_TRANSPORT = transport;

    GenericDebuggerRunnerSettings debuggerRunnerSettings = new GenericDebuggerRunnerSettings();
    debuggerRunnerSettings.LOCAL = true;
    debuggerRunnerSettings.setDebugPort(String.valueOf(DEFAULT_ADDRESS));

    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());
          }
        };

    final RemoteConnection debugParameters =
        DebuggerManagerImpl.createDebugParameters(
            javaCommandLineState.getJavaParameters(), debuggerRunnerSettings, true);

    UIUtil.invokeAndWaitIfNeeded(
        new Runnable() {
          @Override
          public void run() {
            try {
              debuggerSession[0] =
                  attachVirtualMachine(
                      javaCommandLineState,
                      javaCommandLineState.getEnvironment(),
                      debugParameters,
                      false);
            } catch (ExecutionException e) {
              fail(e.getMessage());
            }
          }
        });

    final ProcessHandler processHandler = debuggerSession[0].getProcess().getProcessHandler();
    debuggerSession[0]
        .getProcess()
        .addProcessListener(
            new ProcessAdapter() {
              @Override
              public void onTextAvailable(ProcessEvent event, Key outputType) {
                print(event.getText(), outputType);
              }
            });

    DebugProcessImpl process =
        (DebugProcessImpl)
            DebuggerManagerEx.getInstanceEx(myProject).getDebugProcess(processHandler);
    assertNotNull(process);
    return debuggerSession[0];
  }
  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;
  }