Debugger/RemoteLinux: Make gdbserver location configurable

This helps in situation where the location of the gdbserver
installation is not under the control of the user and he
also can't tweak path settings on the device.

Change-Id: Iab5bbfef765879bf59930cc416385c692056da93
Reviewed-by: Christian Kandeler <christian.kandeler@digia.com>
This commit is contained in:
hjk
2013-06-28 13:56:42 +02:00
parent b865c6e57e
commit feef5cac4c
7 changed files with 76 additions and 8 deletions

View File

@@ -122,7 +122,10 @@ void GdbServerStarter::portListReady()
connect(&d->runner, SIGNAL(readyReadStandardError()), SLOT(handleProcessErrorOutput()));
connect(&d->runner, SIGNAL(processClosed(int)), SLOT(handleProcessClosed(int)));
QByteArray cmd = "gdbserver --attach :"
QByteArray gdbServerPath = d->device->debugServerPath().toUtf8();
if (gdbServerPath.isEmpty())
gdbServerPath = "gdbserver";
QByteArray cmd = gdbServerPath + " --attach :"
+ QByteArray::number(port) + ' ' + QByteArray::number(d->process.pid);
logMessage(tr("Running command: %1").arg(QString::fromLatin1(cmd)));
d->runner.run(cmd, d->device->sshParameters());

View File

@@ -162,6 +162,8 @@ const char KeyFileKey[] = "KeyFile";
const char PasswordKey[] = "Password";
const char TimeoutKey[] = "Timeout";
const char DebugServerKey[] = "DebugServerKey";
typedef QSsh::SshConnectionParameters::AuthenticationType AuthType;
const AuthType DefaultAuthType = QSsh::SshConnectionParameters::AuthenticationTypePublicKey;
const IDevice::MachineType DefaultMachineType = IDevice::Hardware;
@@ -189,6 +191,7 @@ public:
QSsh::SshConnectionParameters sshParameters;
Utils::PortList freePorts;
QString debugServerPath;
};
} // namespace Internal
@@ -325,6 +328,8 @@ void IDevice::fromMap(const QVariantMap &map)
QLatin1String("10000-10100")).toString());
d->machineType = static_cast<MachineType>(map.value(QLatin1String(MachineTypeKey), DefaultMachineType).toInt());
d->version = map.value(QLatin1String(VersionKey), 0).toInt();
d->debugServerPath = map.value(QLatin1String(DebugServerKey)).toString();
}
QVariantMap IDevice::toMap() const
@@ -347,6 +352,8 @@ QVariantMap IDevice::toMap() const
map.insert(QLatin1String(PortsSpecKey), d->freePorts.toString());
map.insert(QLatin1String(VersionKey), d->version);
map.insert(QLatin1String(DebugServerKey), d->debugServerPath);
return map;
}
@@ -397,6 +404,16 @@ IDevice::MachineType IDevice::machineType() const
return d->machineType;
}
QString IDevice::debugServerPath() const
{
return d->debugServerPath;
}
void IDevice::setDebugServerPath(const QString &path)
{
d->debugServerPath = path;
}
int IDevice::version() const
{
return d->version;

View File

@@ -149,6 +149,9 @@ public:
MachineType machineType() const;
QString debugServerPath() const;
void setDebugServerPath(const QString &path);
protected:
IDevice();
IDevice(Core::Id type, Origin origin, MachineType machineType, Core::Id id = Core::Id());

View File

@@ -60,6 +60,7 @@ GenericLinuxDeviceConfigurationWidget::GenericLinuxDeviceConfigurationWidget(
connect(m_ui->showPasswordCheckBox, SIGNAL(toggled(bool)), this, SLOT(showPassword(bool)));
connect(m_ui->portsLineEdit, SIGNAL(editingFinished()), this, SLOT(handleFreePortsChanged()));
connect(m_ui->createKeyButton, SIGNAL(clicked()), SLOT(createNewKey()));
connect(m_ui->gdbServerLineEdit, SIGNAL(editingFinished()), SLOT(gdbServerEditingFinished()));
initGui();
}
@@ -125,6 +126,11 @@ void GenericLinuxDeviceConfigurationWidget::keyFileEditingFinished()
device()->setSshParameters(sshParams);
}
void GenericLinuxDeviceConfigurationWidget::gdbServerEditingFinished()
{
device()->setDebugServerPath(m_ui->gdbServerLineEdit->text());
}
void GenericLinuxDeviceConfigurationWidget::handleFreePortsChanged()
{
device()->setFreePorts(PortList::fromString(m_ui->portsLineEdit->text()));
@@ -159,6 +165,7 @@ void GenericLinuxDeviceConfigurationWidget::updateDeviceFromUi()
passwordEditingFinished();
keyFileEditingFinished();
handleFreePortsChanged();
gdbServerEditingFinished();
}
void GenericLinuxDeviceConfigurationWidget::updatePortsWarningLabel()
@@ -199,5 +206,6 @@ void GenericLinuxDeviceConfigurationWidget::initGui()
m_ui->pwdLineEdit->setText(sshParams.password);
m_ui->keyFileLineEdit->setPath(sshParams.privateKeyFile);
m_ui->showPasswordCheckBox->setChecked(false);
m_ui->gdbServerLineEdit->setText(device()->debugServerPath());
updatePortsWarningLabel();
}

View File

@@ -58,6 +58,7 @@ private slots:
void userNameEditingFinished();
void passwordEditingFinished();
void keyFileEditingFinished();
void gdbServerEditingFinished();
void showPassword(bool showClearText);
void handleFreePortsChanged();
void setPrivateKey(const QString &path);

View File

@@ -7,7 +7,7 @@
<x>0</x>
<y>0</y>
<width>393</width>
<height>206</height>
<height>321</height>
</rect>
</property>
<property name="windowTitle">
@@ -17,7 +17,16 @@
<property name="fieldGrowthPolicy">
<enum>QFormLayout::FieldsStayAtSizeHint</enum>
</property>
<property name="margin">
<property name="leftMargin">
<number>0</number>
</property>
<property name="topMargin">
<number>0</number>
</property>
<property name="rightMargin">
<number>0</number>
</property>
<property name="bottomMargin">
<number>0</number>
</property>
<item row="1" column="0">
@@ -30,7 +39,16 @@
<item row="1" column="1">
<widget class="QWidget" name="authTypeButtonsWidget" native="true">
<layout class="QHBoxLayout" name="horizontalLayout_3">
<property name="margin">
<property name="leftMargin">
<number>0</number>
</property>
<property name="topMargin">
<number>0</number>
</property>
<property name="rightMargin">
<number>0</number>
</property>
<property name="bottomMargin">
<number>0</number>
</property>
<item>
@@ -233,6 +251,20 @@
<item row="0" column="1">
<widget class="QLabel" name="machineTypeValueLabel"/>
</item>
<item row="7" column="0">
<widget class="QLabel" name="gdbServerLabel">
<property name="text">
<string>GDB server executable:</string>
</property>
</widget>
</item>
<item row="7" column="1">
<widget class="QLineEdit" name="gdbServerLineEdit">
<property name="placeholderText">
<string>Leave empty to look up executable in $PATH</string>
</property>
</widget>
</item>
</layout>
<zorder>passwordLabel</zorder>
<zorder>authTypeButtonsWidget</zorder>
@@ -244,6 +276,8 @@
<zorder>keyLabel</zorder>
<zorder>machineTypeLabel</zorder>
<zorder>machineTypeValueLabel</zorder>
<zorder>gdbServerLabel</zorder>
<zorder>gdbServerLineEdit</zorder>
</widget>
<customwidgets>
<customwidget>

View File

@@ -162,17 +162,19 @@ void LinuxDeviceDebugSupport::startExecution()
connect(runner, SIGNAL(remoteStdout(QByteArray)), SLOT(handleRemoteOutput(QByteArray)));
if (d->qmlDebugging && !d->cppDebugging)
connect(runner, SIGNAL(remoteProcessStarted()), SLOT(handleRemoteProcessStarted()));
QString command;
QStringList args = arguments();
if (d->qmlDebugging)
args += QString::fromLocal8Bit("-qmljsdebugger=port:%1,block").arg(d->qmlPort);
QString command;
if (d->qmlDebugging && !d->cppDebugging) {
command = remoteFilePath();
} else {
command = QLatin1String("gdbserver");
command = device()->debugServerPath();
if (command.isEmpty())
command = QLatin1String("gdbserver");
args.prepend(remoteFilePath());
args.prepend(QString::fromLatin1(":%1").arg(d->gdbServerPort));
}
connect(runner, SIGNAL(finished(bool)), SLOT(handleAppRunnerFinished(bool)));
connect(runner, SIGNAL(reportProgress(QString)), SLOT(handleProgressReport(QString)));
connect(runner, SIGNAL(reportError(QString)), SLOT(handleAppRunnerError(QString)));