Commit f87df9e7 authored by hjk's avatar hjk
Browse files

debugger: handle error when remote server does not respond

parent c1dc4394
......@@ -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
......
......@@ -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
......
......@@ -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;
}
}
......
......@@ -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."));
......
......@@ -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;
......
......@@ -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>
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment