@NotNull
  private static XDebugProcess jvmProcessToDebug(
    @NotNull XDebugSession session,
    ExternalSystemRunnableState state,
    @NotNull ExecutionEnvironment env
  ) throws ExecutionException {
    String debugPort = String.valueOf(state.getDebugPort());
    RemoteConnection connection = state.isDebugServerProcess()
                                  ? new RemoteConnection(true, "127.0.0.1", debugPort, true)
                                  : new RemoteConnectionStub(true, "127.0.0.1", debugPort, true);
    DebugEnvironment environment = new DefaultDebugEnvironment(env, state, connection, DebugEnvironment.LOCAL_START_TIMEOUT);

    final DebuggerSession debuggerSession = DebuggerManagerEx.getInstanceEx(env.getProject()).attachVirtualMachine(environment);

    if (debuggerSession == null) {
      throw new ExecutionException(ATTACH_VM_FAILED);
    }

    final DebugProcessImpl debugProcess = debuggerSession.getProcess();


    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);
  }
@NotNull
  private static XDebugProcess jvmProcessToDebug(
    @NotNull XDebugSession session,
    ExternalSystemRunnableState state,
    @NotNull ExecutionEnvironment env
  )