/**
   * This method does the necessary work to setup the input/output streams for the inferior process,
   * by either preparing the PTY to be used, or by simply leaving the PTY null, which indicates that
   * the input/output streams of the CLI should be used instead; this decision is based on the type
   * of session.
   */
  @Execute
  public void stepInitializeInputOutput(final RequestMonitor rm) {
    if (fBackend.getSessionType() == SessionType.REMOTE && !fBackend.getIsAttachSession()) {
      // Remote non-attach sessions don't support multi-process and therefore will not
      // start new processes.  Those sessions will only start the one process, which should
      // not have a console, because it's output is handled by GDB server.
      fPty = null;
      rm.done();
    } else {
      // Every other type of session that can get to this code, is starting a new process
      // and requires a pty for it.
      try {
        fPty = new PTY();

        // Tell GDB to use this PTY
        fCommandControl.queueCommand(
            fCommandFactory.createMIInferiorTTYSet(
                (IMIContainerDMContext) getContainerContext(), fPty.getSlaveName()),
            new ImmediateDataRequestMonitor<MIInfo>(rm) {
              @Override
              protected void handleFailure() {
                // We were not able to tell GDB to use the PTY
                // so we won't use it at all.
                fPty = null;
                rm.done();
              }
            });
      } catch (IOException e) {
        fPty = null;
        rm.done();
      }
    }
  }
 /**
  * This method indicates if we should use the -exec-continue command instead of the -exec-run
  * command. This method can be overridden to allow for customization.
  */
 protected boolean useContinueCommand() {
   // Note that restart does not apply to remote sessions
   IGDBBackend backend = fTracker.getService(IGDBBackend.class);
   if (backend == null) {
     return false;
   }
   // When doing remote non-attach debugging, we use -exec-continue instead of -exec-run
   // For remote attach, if we get here it is that we are starting a new process
   // (multi-process), so we want to use -exec-run
   return backend.getSessionType() == SessionType.REMOTE && !backend.getIsAttachSession();
 }
  /**
   * If we are dealing with a remote debugging session, connect to the target.
   *
   * @since 4.0
   */
  @Execute
  public void stepRemoteConnection(RequestMonitor rm) {
    // If we are dealing with a non-attach remote session, it is now time to connect
    // to the remote side.  Note that this is the 'target remote' case
    // and not the 'target extended-remote' case (remote attach session)
    // This step is actually global for GDB.  However, we have to do it after
    // we have specified the executable, so we have to do it here.
    // It is safe to do it here because a 'target remote' does not support
    // multi-process so this step will not be executed more than once.
    if (fBackend.getSessionType() == SessionType.REMOTE && !fBackend.getIsAttachSession()) {
      boolean isTcpConnection =
          CDebugUtils.getAttribute(
              fAttributes, IGDBLaunchConfigurationConstants.ATTR_REMOTE_TCP, false);

      if (isTcpConnection) {
        String remoteTcpHost =
            CDebugUtils.getAttribute(
                fAttributes, IGDBLaunchConfigurationConstants.ATTR_HOST, INVALID);
        String remoteTcpPort =
            CDebugUtils.getAttribute(
                fAttributes, IGDBLaunchConfigurationConstants.ATTR_PORT, INVALID);

        fCommandControl.queueCommand(
            fCommandFactory.createMITargetSelect(
                fCommandControl.getContext(), remoteTcpHost, remoteTcpPort, false),
            new DataRequestMonitor<MIInfo>(ImmediateExecutor.getInstance(), rm));
      } else {
        String serialDevice =
            CDebugUtils.getAttribute(
                fAttributes, IGDBLaunchConfigurationConstants.ATTR_DEV, INVALID);
        fCommandControl.queueCommand(
            fCommandFactory.createMITargetSelect(fCommandControl.getContext(), serialDevice, false),
            new DataRequestMonitor<MIInfo>(ImmediateExecutor.getInstance(), rm));
      }
    } else {
      rm.done();
    }
  }