diff --git a/src/plugins/debugger/debuggerdialogs.cpp b/src/plugins/debugger/debuggerdialogs.cpp
index f30ee2c417297fb9740cac61d004f94043fbe1ae..44105961845bc286ab521beda1fb35ad3750c5d8 100644
--- a/src/plugins/debugger/debuggerdialogs.cpp
+++ b/src/plugins/debugger/debuggerdialogs.cpp
@@ -300,6 +300,58 @@ void AttachExternalDialog::pidChanged(const QString &pid)
 }
 
 
+///////////////////////////////////////////////////////////////////////
+//
+// StartExternalDialog
+//
+///////////////////////////////////////////////////////////////////////
+
+
+StartExternalDialog::StartExternalDialog(QWidget *parent)
+  : QDialog(parent), m_ui(new Ui::StartExternalDialog)
+{
+    m_ui->setupUi(this);
+    m_ui->execFile->setExpectedKind(Core::Utils::PathChooser::File);
+    m_ui->execFile->setPromptDialogTitle(tr("Select Executable"));
+    m_ui->buttonBox->button(QDialogButtonBox::Ok)->setDefault(true);
+
+    //execLabel->setHidden(false);
+    //execEdit->setHidden(false);
+    //browseButton->setHidden(false);
+
+    m_ui->execLabel->setText(tr("Executable:"));
+    m_ui->argLabel->setText(tr("Arguments:"));
+
+    connect(m_ui->buttonBox, SIGNAL(accepted()), this, SLOT(accept()));
+    connect(m_ui->buttonBox, SIGNAL(rejected()), this, SLOT(reject()));
+}
+
+StartExternalDialog::~StartExternalDialog()
+{
+    delete m_ui;
+}
+
+void StartExternalDialog::setExecutableFile(const QString &str)
+{
+    m_ui->execFile->setPath(str);
+}
+
+QString StartExternalDialog::executableFile() const
+{
+    return m_ui->execFile->path();
+}
+
+void StartExternalDialog::setExecutableArguments(const QString &str)
+{
+    m_ui->argsEdit->setText(str);
+}
+
+QString StartExternalDialog::executableArguments() const
+{
+    return m_ui->argsEdit->text();
+}
+
+
 ///////////////////////////////////////////////////////////////////////
 //
 // StartRemoteDialog
@@ -314,9 +366,14 @@ StartRemoteDialog::StartRemoteDialog(QWidget *parent)
     m_ui->buttonBox->button(QDialogButtonBox::Ok)->setDefault(true);
     m_ui->serverStartScript->setExpectedKind(Core::Utils::PathChooser::File);
     m_ui->serverStartScript->setPromptDialogTitle(tr("Select Executable"));
+
+    connect(m_ui->useServerStartScriptCheckBox, SIGNAL(toggled(bool)), 
+        this, SLOT(updateState()));
     
     connect(m_ui->buttonBox, SIGNAL(accepted()), this, SLOT(accept()));
     connect(m_ui->buttonBox, SIGNAL(rejected()), this, SLOT(reject()));
+
+    updateState();
 }
 
 StartRemoteDialog::~StartRemoteDialog()
@@ -366,55 +423,21 @@ QString StartRemoteDialog::serverStartScript() const
     return m_ui->serverStartScript->path();
 }
 
-///////////////////////////////////////////////////////////////////////
-//
-// StartExternalDialog
-//
-///////////////////////////////////////////////////////////////////////
-
-
-StartExternalDialog::StartExternalDialog(QWidget *parent)
-  : QDialog(parent), m_ui(new Ui::StartExternalDialog)
-{
-    m_ui->setupUi(this);
-    m_ui->execFile->setExpectedKind(Core::Utils::PathChooser::File);
-    m_ui->execFile->setPromptDialogTitle(tr("Select Executable"));
-    m_ui->buttonBox->button(QDialogButtonBox::Ok)->setDefault(true);
-
-    //execLabel->setHidden(false);
-    //execEdit->setHidden(false);
-    //browseButton->setHidden(false);
-
-    m_ui->execLabel->setText(tr("Executable:"));
-    m_ui->argLabel->setText(tr("Arguments:"));
-
-    connect(m_ui->buttonBox, SIGNAL(accepted()), this, SLOT(accept()));
-    connect(m_ui->buttonBox, SIGNAL(rejected()), this, SLOT(reject()));
-}
-
-StartExternalDialog::~StartExternalDialog()
-{
-    delete m_ui;
-}
-
-void StartExternalDialog::setExecutableFile(const QString &str)
-{
-    m_ui->execFile->setPath(str);
-}
-
-void StartExternalDialog::setExecutableArguments(const QString &str)
+void StartRemoteDialog::setUseServerStartScript(bool on)
 {
-    m_ui->argsEdit->setText(str);
+    m_ui->useServerStartScriptCheckBox->setChecked(on);
 }
 
-QString StartExternalDialog::executableFile() const
+bool StartRemoteDialog::useServerStartScript() const
 {
-    return m_ui->execFile->path();
+    return m_ui->useServerStartScriptCheckBox->isChecked();
 }
 
-QString StartExternalDialog::executableArguments() const
+void StartRemoteDialog::updateState()
 {
-    return m_ui->argsEdit->text();
+    bool enabled = m_ui->useServerStartScriptCheckBox->isChecked();
+    m_ui->serverStartScriptLabel->setEnabled(enabled);
+    m_ui->serverStartScript->setEnabled(enabled);
 }
 
 } // namespace Internal
diff --git a/src/plugins/debugger/debuggerdialogs.h b/src/plugins/debugger/debuggerdialogs.h
index 403e094d4cc6c80236fca844cc772a3145ce0aa0..3f6deba9442d0ed976f1ab6e6f3a45d7d1e5e22a 100644
--- a/src/plugins/debugger/debuggerdialogs.h
+++ b/src/plugins/debugger/debuggerdialogs.h
@@ -101,6 +101,24 @@ private:
     ProcessListFilterModel *m_model;
 };
 
+class StartExternalDialog : public QDialog
+{
+    Q_OBJECT
+
+public:
+    explicit StartExternalDialog(QWidget *parent);
+    ~StartExternalDialog();
+
+    void setExecutableFile(const QString &executable);
+    void setExecutableArguments(const QString &args);
+
+    QString executableFile() const;
+    QString executableArguments() const;
+
+private:
+    Ui::StartExternalDialog *m_ui;
+};
+
 class StartRemoteDialog : public QDialog
 {
     Q_OBJECT
@@ -116,27 +134,14 @@ public:
     QString remoteArchitecture() const;
     void setServerStartScript(const QString &scriptName);
     QString serverStartScript() const;
+    void setUseServerStartScript(bool on);
+    bool useServerStartScript() const;
 
-private:
-    Ui::StartRemoteDialog *m_ui;
-};
-
-class StartExternalDialog : public QDialog
-{
-    Q_OBJECT
-
-public:
-    explicit StartExternalDialog(QWidget *parent);
-    ~StartExternalDialog();
-
-    void setExecutableFile(const QString &executable);
-    void setExecutableArguments(const QString &args);
-
-    QString executableFile() const;
-    QString executableArguments() const;
+private slots:
+    void updateState();
 
 private:
-    Ui::StartExternalDialog *m_ui;
+    Ui::StartRemoteDialog *m_ui;
 };
 
 } // namespace Debugger
diff --git a/src/plugins/debugger/debuggermanager.cpp b/src/plugins/debugger/debuggermanager.cpp
index cbcd0f76f3e954eb318d82a0eb5b47c59cbf6dfe..2d1e5e18325082ca339d3e8a8a8f7995a37777d2 100644
--- a/src/plugins/debugger/debuggermanager.cpp
+++ b/src/plugins/debugger/debuggermanager.cpp
@@ -937,6 +937,7 @@ void DebuggerManager::startNewDebugger(DebuggerRunControl *runControl)
         dlg.setRemoteChannel(configValue(_("LastRemoteChannel")).toString());
         dlg.setRemoteArchitecture(configValue(_("LastRemoteArchtecture")).toString());
         dlg.setServerStartScript(configValue(_("LastServerStartScript")).toString());
+        dlg.setUseServerStartScript(configValue(_("LastUseServerStartScript")).toBool());
         if (dlg.exec() != QDialog::Accepted) {  
             runControl->debuggingFinished();
             return;
@@ -944,9 +945,12 @@ void DebuggerManager::startNewDebugger(DebuggerRunControl *runControl)
         setConfigValue(_("LastRemoteChannel"), dlg.remoteChannel());
         setConfigValue(_("LastRemoteArchitecture"), dlg.remoteArchitecture());
         setConfigValue(_("LastServerStartScript"), dlg.serverStartScript());
+        setConfigValue(_("LastUseServerStartScript"), dlg.useServerStartScript());
         m_remoteChannel = dlg.remoteChannel();
         m_remoteArchitecture = dlg.remoteArchitecture();
         m_serverStartScript = dlg.serverStartScript();
+        if (!dlg.useServerStartScript())
+            m_serverStartScript.clear();
         break;
     }
     }
diff --git a/src/plugins/debugger/gdbengine.cpp b/src/plugins/debugger/gdbengine.cpp
index e2239c878e02bb761e5df576a376303f62989cc0..928f7428c5927944680c44c68d9f177c8f5d63ad 100644
--- a/src/plugins/debugger/gdbengine.cpp
+++ b/src/plugins/debugger/gdbengine.cpp
@@ -1558,7 +1558,7 @@ bool GdbEngine::startDebugger()
         QString fileName = q->m_executable;
         execCommand(_("-file-exec-and-symbols \"%1\"").arg(fileName));
         // works only for > 6.8
-        execCommand(_("set target-async on"), CB(handleTargetAsync));
+        execCommand(_("set target-async on"), CB(handleSetTargetAsync));
     } else if (q->m_useTerminal) {
         qq->breakHandler()->setAllPending();
     } else if (q->startMode() == StartInternal || q->startMode() == StartExternal) {
@@ -1653,15 +1653,13 @@ void GdbEngine::handleAttach(const GdbResultRecord &, const QVariant &)
     qq->reloadRegisters();
 }
 
-void GdbEngine::handleTargetAsync(const GdbResultRecord &record, const QVariant &)
+void GdbEngine::handleSetTargetAsync(const GdbResultRecord &record, const QVariant &)
 {
     if (record.resultClass == GdbResultDone) {
         //execCommand(_("info target"), handleStart);
         qq->notifyInferiorRunningRequested();
         execCommand(_("target remote %1").arg(q->m_remoteChannel),
-            CB(handleAttach));
-        //execCommand(_("-exec-continue"), CB(handleExecRun));
-        handleAqcuiredInferior();
+            CB(handleTargetRemote));
     } else if (record.resultClass == GdbResultError) {
         // a typical response on "old" gdb is:
         // &"set target-async on\n"
@@ -1671,6 +1669,22 @@ void GdbEngine::handleTargetAsync(const GdbResultRecord &record, const QVariant
         execCommand(_("-gdb-exit"), CB(handleExit));
     }
 }
+
+void GdbEngine::handleTargetRemote(const GdbResultRecord &record, const QVariant &)
+{
+    if (record.resultClass == GdbResultDone) {
+        //execCommand(_("-exec-continue"), CB(handleExecRun));
+        handleAqcuiredInferior();
+    } else if (record.resultClass == GdbResultError) {
+        // 16^error,msg="hd:5555: Connection timed out."
+        QString msg = __(record.data.findChild("msg").data());
+        QString msg1 = tr("Connecting to remote server failed:");
+        q->showStatusMessage(msg1 + _c(' ') + msg);
+        QMessageBox::critical(q->mainWindow(), tr("Error"), msg1 + _c('\n') + msg);
+        execCommand(_("-gdb-exit"), CB(handleExit));
+    }
+}
+
 void GdbEngine::handleExit(const GdbResultRecord &, const QVariant &)
 {
     q->showStatusMessage(tr("Debugger exited."));
diff --git a/src/plugins/debugger/gdbengine.h b/src/plugins/debugger/gdbengine.h
index d749e75190ab0056c963ef3a6f94d8f686ff1e7f..e309f1b1a0415eadd919a8b93a56a39fd21b4734 100644
--- a/src/plugins/debugger/gdbengine.h
+++ b/src/plugins/debugger/gdbengine.h
@@ -218,7 +218,8 @@ private:
     void handleQuerySources(const GdbResultRecord &response, const QVariant &);
     void handleTargetCore(const GdbResultRecord &, const QVariant &);
     void handleExit(const GdbResultRecord &, const QVariant &);
-    void handleTargetAsync(const GdbResultRecord &, const QVariant &);
+    void handleSetTargetAsync(const GdbResultRecord &, const QVariant &);
+    void handleTargetRemote(const GdbResultRecord &, const QVariant &);
     void debugMessage(const QString &msg);
 
     OutputCollector m_outputCollector;
diff --git a/src/plugins/debugger/startremotedialog.ui b/src/plugins/debugger/startremotedialog.ui
index af0bc703237904f7cc6f1ba2793e766cc2572dea..da017b20576700cdd1140310747c019e488926b9 100644
--- a/src/plugins/debugger/startremotedialog.ui
+++ b/src/plugins/debugger/startremotedialog.ui
@@ -28,7 +28,7 @@
      <item row="0" column="0">
       <widget class="QLabel" name="channelLabel">
        <property name="text">
-        <string>Host and Port:</string>
+        <string>Host and port:</string>
        </property>
       </widget>
      </item>
@@ -49,15 +49,25 @@
      <item row="1" column="1">
       <widget class="QComboBox" name="architectureComboBox"/>
      </item>
+     <item row="2" column="1">
+      <widget class="QCheckBox" name="useServerStartScriptCheckBox"/>
+     </item>
      <item row="2" column="0">
-      <widget class="QLabel" name="serverStartScriptLabel">
+      <widget class="QLabel" name="useServerStartScriptLabel">
        <property name="text">
-        <string>Server start script</string>
+        <string>Use server start script:</string>
        </property>
       </widget>
      </item>
-     <item row="2" column="1">
-       <widget class="Core::Utils::PathChooser" name="serverStartScript" native="true"/>
+     <item row="3" column="1">
+      <widget class="Core::Utils::PathChooser" name="serverStartScript" native="true"/>
+     </item>
+     <item row="3" column="0">
+      <widget class="QLabel" name="serverStartScriptLabel">
+       <property name="text">
+        <string>Server start script:</string>
+       </property>
+      </widget>
      </item>
     </layout>
    </item>
@@ -73,6 +83,13 @@
    </item>
   </layout>
  </widget>
+ <customwidgets>
+  <customwidget>
+   <class>Core::Utils::PathChooser</class>
+   <extends>QWidget</extends>
+   <header location="global">utils/pathchooser.h</header>
+  </customwidget>
+ </customwidgets>
  <resources/>
  <connections/>
 </ui>