Commit b585cbda authored by ck's avatar ck
Browse files

Maemo: Make gdbserver port user-configurable.

parent 834a47b1
......@@ -64,7 +64,8 @@ namespace {
const QLatin1String NameKey("Name");
const QLatin1String TypeKey("Type");
const QLatin1String HostKey("Host");
const QLatin1String PortKey("Port");
const QLatin1String SshPortKey("SshPort");
const QLatin1String GdbServerPortKey("GdbServerPort");
const QLatin1String UserNameKey("Uname");
const QLatin1String AuthKey("Authentication");
const QLatin1String KeyFileKey("KeyFile");
......@@ -92,7 +93,8 @@ private:
MaemoDeviceConfig::MaemoDeviceConfig(const QString &name)
: name(name),
type(Physical),
port(22),
sshPort(22),
gdbServerPort(10000),
authentication(Key),
keyFile(DefaultKeyFile),
timeout(30),
......@@ -105,7 +107,8 @@ MaemoDeviceConfig::MaemoDeviceConfig(const QSettings &settings,
: name(settings.value(NameKey).toString()),
type(static_cast<DeviceType>(settings.value(TypeKey, Physical).toInt())),
host(settings.value(HostKey).toString()),
port(settings.value(PortKey, 22).toInt()),
sshPort(settings.value(SshPortKey, 22).toInt()),
gdbServerPort(settings.value(GdbServerPortKey, 10000).toInt()),
uname(settings.value(UserNameKey).toString()),
authentication(static_cast<AuthType>(settings.value(AuthKey).toInt())),
pwd(settings.value(PasswordKey).toString()),
......@@ -132,7 +135,8 @@ void MaemoDeviceConfig::save(QSettings &settings) const
settings.setValue(NameKey, name);
settings.setValue(TypeKey, type);
settings.setValue(HostKey, host);
settings.setValue(PortKey, port);
settings.setValue(SshPortKey, sshPort);
settings.setValue(GdbServerPortKey, gdbServerPort);
settings.setValue(UserNameKey, uname);
settings.setValue(AuthKey, authentication);
settings.setValue(PasswordKey, pwd);
......
......@@ -62,7 +62,8 @@ public:
QString name;
DeviceType type;
QString host;
int port;
int sshPort;
int gdbServerPort;
QString uname;
AuthType authentication;
QString pwd;
......
......@@ -151,7 +151,7 @@ void AbstractMaemoRunControl::deploy()
emit addToOutputWindow(this, tr("File to deploy: %1.").arg(deployable.fileName));
QStringList cmdArgs;
cmdArgs << "-P" << port() << options() << deployable.fileName
cmdArgs << "-P" << sshPort() << options() << deployable.fileName
<< (devConfig.uname + "@" + devConfig.host + ":" + remoteDir());
deployProcess.setWorkingDirectory(deployable.dir);
......@@ -239,9 +239,9 @@ const QString AbstractMaemoRunControl::executableOnHost() const
return runConfig->executable();
}
const QString AbstractMaemoRunControl::port() const
const QString AbstractMaemoRunControl::sshPort() const
{
return QString::number(devConfig.port);
return QString::number(devConfig.sshPort);
}
const QString AbstractMaemoRunControl::executableFileName() const
......@@ -376,7 +376,7 @@ void MaemoRunControl::startExecution()
.arg(runConfig->arguments().join(" "));
QStringList cmdArgs;
cmdArgs << "-n" << "-p" << port() << "-l" << devConfig.uname
cmdArgs << "-n" << "-p" << sshPort() << "-l" << devConfig.uname
<< options() << devConfig.host << remoteCall;
sshProcess.start(runConfig->sshCmd(), cmdArgs);
......@@ -428,7 +428,7 @@ void MaemoRunControl::stop()
QStringList cmdArgs;
const QString remoteCall = QString::fromLocal8Bit("pkill -x %1; "
"sleep 1; pkill -x -9 %1").arg(executableFileName());
cmdArgs << "-n" << "-p" << port() << "-l" << devConfig.uname
cmdArgs << "-n" << "-p" << sshPort() << "-l" << devConfig.uname
<< options() << devConfig.host << remoteCall;
stopProcess.start(runConfig->sshCmd(), cmdArgs);
#endif // USE_SSH_LIB
......@@ -458,7 +458,7 @@ void MaemoRunControl::handleRemoteOutput(const QString &output)
MaemoDebugRunControl::MaemoDebugRunControl(RunConfiguration *runConfiguration)
: AbstractMaemoRunControl(runConfiguration)
, gdbServerPort("10000"), debuggerManager(0)
, debuggerManager(0)
, startParams(new Debugger::DebuggerStartParameters)
{
#ifndef USE_SSH_LIB
......@@ -472,7 +472,8 @@ MaemoDebugRunControl::MaemoDebugRunControl(RunConfiguration *runConfiguration)
QTC_ASSERT(debuggerManager != 0, return);
startParams->startMode = Debugger::StartRemote;
startParams->executable = executableOnHost();
startParams->remoteChannel = devConfig.host + ":" + gdbServerPort;
startParams->remoteChannel
= devConfig.host + ":" + QString::number(devConfig.gdbServerPort);
startParams->remoteArchitecture = "arm";
startParams->sysRoot = runConfig->sysRoot();
startParams->toolChainType = ToolChain::GCC_MAEMO;
......@@ -513,8 +514,8 @@ void MaemoDebugRunControl::handleDeploymentFinished(bool success)
void MaemoDebugRunControl::startGdbServer()
{
const QString remoteCall(QString::fromLocal8Bit("%1 gdbserver :%2 %3 %4").
arg(targetCmdLinePrefix()).arg(gdbServerPort). arg(executableOnTarget())
.arg(runConfig->arguments().join(" ")));
arg(targetCmdLinePrefix()).arg(devConfig.gdbServerPort)
.arg(executableOnTarget()).arg(runConfig->arguments().join(" ")));
inferiorPid = -1;
#ifdef USE_SSH_LIB
sshRunner.reset(new MaemoSshRunner(devConfig, remoteCall));
......@@ -524,7 +525,7 @@ void MaemoDebugRunControl::startGdbServer()
#else
QStringList sshArgs;
sshArgs << "-t" << "-n" << "-l" << devConfig.uname << "-p"
<< port() << options() << devConfig.host << remoteCall;
<< sshPort() << options() << devConfig.host << remoteCall;
disconnect(&gdbServer, SIGNAL(readyReadStandardError()), 0, 0);
connect(&gdbServer, SIGNAL(readyReadStandardError()), this,
SLOT(gdbServerStarted()));
......@@ -651,7 +652,7 @@ void MaemoDebugRunControl::debuggingFinished()
const QString remoteCall = QString::fromLocal8Bit("kill %1; sleep 1; "
"kill -9 %1; pkill -x -9 gdbserver").arg(inferiorPid);
QStringList sshArgs;
sshArgs << "-n" << "-l" << devConfig.uname << "-p" << port()
sshArgs << "-n" << "-l" << devConfig.uname << "-p" << sshPort()
<< options() << devConfig.host << remoteCall;
stopProcess.start(runConfig->sshCmd(), sshArgs);
}
......
......@@ -73,7 +73,7 @@ protected:
const QString executableOnHost() const;
const QString executableOnTarget() const;
const QString executableFileName() const;
const QString port() const;
const QString sshPort() const;
const QString targetCmdLinePrefix() const;
const QString remoteDir() const;
const QStringList options() const;
......@@ -183,7 +183,6 @@ private:
QProcess gdbServer;
QProcess stopProcess;
#endif // USE_SSH_LIB
const QString gdbServerPort;
Debugger::DebuggerManager *debuggerManager;
QSharedPointer<Debugger::DebuggerStartParameters> startParams;
int inferiorPid;
......
......@@ -133,7 +133,8 @@ private slots:
void deviceTypeChanged();
void authenticationTypeChanged();
void hostNameEditingFinished();
void portEditingFinished();
void sshPortEditingFinished();
void gdbServerPortEditingFinished();
void timeoutEditingFinished();
void userNameEditingFinished();
void passwordEditingFinished();
......@@ -161,7 +162,8 @@ private:
Ui_maemoSettingsWidget *m_ui;
QList<MaemoDeviceConfig> m_devConfs;
PortAndTimeoutValidator m_portValidator;
PortAndTimeoutValidator m_sshPortValidator;
PortAndTimeoutValidator m_gdbServerPortValidator;
PortAndTimeoutValidator m_timeoutValidator;
NameValidator m_nameValidator;
#ifdef USE_SSH_LIB
......@@ -239,7 +241,8 @@ void MaemoSettingsWidget::initGui()
{
m_ui->setupUi(this);
m_ui->nameLineEdit->setValidator(&m_nameValidator);
m_ui->portLineEdit->setValidator(&m_portValidator);
m_ui->sshPortLineEdit->setValidator(&m_sshPortValidator);
m_ui->gdbServerPortLineEdit->setValidator(&m_gdbServerPortValidator);
m_ui->timeoutLineEdit->setValidator(&m_timeoutValidator);
m_ui->keyFileLineEdit->setExpectedKind(Utils::PathChooser::File);
foreach(const MaemoDeviceConfig &devConf, m_devConfs)
......@@ -305,14 +308,17 @@ void MaemoSettingsWidget::display(const MaemoDeviceConfig &devConfig)
else
m_ui->keyButton->setChecked(true);
m_ui->hostLineEdit->setText(devConfig.host);
m_ui->portLineEdit->setText(QString::number(devConfig.port));
m_ui->sshPortLineEdit->setText(QString::number(devConfig.sshPort));
m_ui->gdbServerPortLineEdit
->setText(QString::number(devConfig.gdbServerPort));
m_ui->timeoutLineEdit->setText(QString::number(devConfig.timeout));
m_ui->userLineEdit->setText(devConfig.uname);
m_ui->pwdLineEdit->setText(devConfig.pwd);
m_ui->keyFileLineEdit->setPath(devConfig.keyFile);
m_ui->detailsWidget->setEnabled(true);
m_nameValidator.setDisplayName(devConfig.name);
m_portValidator.setValue(devConfig.port);
m_sshPortValidator.setValue(devConfig.sshPort);
m_gdbServerPortValidator.setValue(devConfig.gdbServerPort);
m_timeoutValidator.setValue(devConfig.timeout);
m_ui->detailsWidget->setEnabled(true);
}
......@@ -367,9 +373,16 @@ void MaemoSettingsWidget::hostNameEditingFinished()
currentConfig().host = m_ui->hostLineEdit->text();
}
void MaemoSettingsWidget::portEditingFinished()
void MaemoSettingsWidget::sshPortEditingFinished()
{
setPortOrTimeout(m_ui->portLineEdit, currentConfig().port, m_portValidator);
setPortOrTimeout(m_ui->sshPortLineEdit, currentConfig().sshPort,
m_sshPortValidator);
}
void MaemoSettingsWidget::gdbServerPortEditingFinished()
{
setPortOrTimeout(m_ui->gdbServerPortLineEdit, currentConfig().gdbServerPort,
m_gdbServerPortValidator);
}
void MaemoSettingsWidget::timeoutEditingFinished()
......@@ -594,7 +607,8 @@ void MaemoSettingsWidget::clearDetails()
{
m_ui->nameLineEdit->clear();
m_ui->hostLineEdit->clear();
m_ui->portLineEdit->clear();
m_ui->sshPortLineEdit->clear();
m_ui->gdbServerPortLineEdit->clear();
m_ui->timeoutLineEdit->clear();
m_ui->userLineEdit->clear();
m_ui->pwdLineEdit->clear();
......
......@@ -124,57 +124,67 @@
<item row="4" column="0">
<widget class="QLabel" name="label_4">
<property name="text">
<string>Port:</string>
<string>SSH Port:</string>
</property>
</widget>
</item>
<item row="4" column="1">
<widget class="QLineEdit" name="portLineEdit"/>
<widget class="QLineEdit" name="sshPortLineEdit"/>
</item>
<item row="5" column="0">
<item row="6" column="0">
<widget class="QLabel" name="label_5">
<property name="text">
<string>Connection Timeout:</string>
</property>
</widget>
</item>
<item row="5" column="1">
<item row="6" column="1">
<widget class="QLineEdit" name="timeoutLineEdit"/>
</item>
<item row="6" column="0">
<item row="7" column="0">
<widget class="QLabel" name="label_6">
<property name="text">
<string>User Name:</string>
</property>
</widget>
</item>
<item row="6" column="1">
<item row="7" column="1">
<widget class="QLineEdit" name="userLineEdit"/>
</item>
<item row="7" column="0">
<item row="8" column="0">
<widget class="QLabel" name="passwordLabel">
<property name="text">
<string>Password:</string>
</property>
</widget>
</item>
<item row="7" column="1">
<item row="8" column="1">
<widget class="QLineEdit" name="pwdLineEdit">
<property name="echoMode">
<enum>QLineEdit::Password</enum>
</property>
</widget>
</item>
<item row="8" column="0">
<item row="9" column="0">
<widget class="QLabel" name="keyLabel">
<property name="text">
<string>Private key file:</string>
</property>
</widget>
</item>
<item row="8" column="1">
<item row="9" column="1">
<widget class="Utils::PathChooser" name="keyFileLineEdit" native="true"/>
</item>
<item row="5" column="0">
<widget class="QLabel" name="gdbServerPortLabel">
<property name="text">
<string>Gdbserver Port:</string>
</property>
</widget>
</item>
<item row="5" column="1">
<widget class="QLineEdit" name="gdbServerPortLineEdit"/>
</item>
</layout>
</widget>
</item>
......@@ -272,8 +282,8 @@ p, li { white-space: pre-wrap; }
<slot>configNameEditingFinished()</slot>
<hints>
<hint type="sourcelabel">
<x>372</x>
<y>146</y>
<x>396</x>
<y>145</y>
</hint>
<hint type="destinationlabel">
<x>514</x>
......@@ -288,8 +298,8 @@ p, li { white-space: pre-wrap; }
<slot>deviceTypeChanged()</slot>
<hints>
<hint type="sourcelabel">
<x>264</x>
<y>175</y>
<x>267</x>
<y>169</y>
</hint>
<hint type="destinationlabel">
<x>511</x>
......@@ -304,8 +314,8 @@ p, li { white-space: pre-wrap; }
<slot>hostNameEditingFinished()</slot>
<hints>
<hint type="sourcelabel">
<x>385</x>
<y>228</y>
<x>396</x>
<y>216</y>
</hint>
<hint type="destinationlabel">
<x>424</x>
......@@ -314,14 +324,14 @@ p, li { white-space: pre-wrap; }
</hints>
</connection>
<connection>
<sender>portLineEdit</sender>
<sender>sshPortLineEdit</sender>
<signal>editingFinished()</signal>
<receiver>maemoSettingsWidget</receiver>
<slot>portEditingFinished()</slot>
<slot>sshPortEditingFinished()</slot>
<hints>
<hint type="sourcelabel">
<x>385</x>
<y>255</y>
<x>396</x>
<y>240</y>
</hint>
<hint type="destinationlabel">
<x>514</x>
......@@ -384,8 +394,8 @@ p, li { white-space: pre-wrap; }
<slot>deviceTypeChanged()</slot>
<hints>
<hint type="sourcelabel">
<x>376</x>
<y>175</y>
<x>387</x>
<y>169</y>
</hint>
<hint type="destinationlabel">
<x>426</x>
......@@ -521,12 +531,28 @@ p, li { white-space: pre-wrap; }
</hint>
</hints>
</connection>
<connection>
<sender>gdbServerPortLineEdit</sender>
<signal>editingFinished()</signal>
<receiver>maemoSettingsWidget</receiver>
<slot>gdbServerPortEditingFinished()</slot>
<hints>
<hint type="sourcelabel">
<x>218</x>
<y>255</y>
</hint>
<hint type="destinationlabel">
<x>427</x>
<y>467</y>
</hint>
</hints>
</connection>
</connections>
<slots>
<slot>configNameEditingFinished()</slot>
<slot>deviceTypeChanged()</slot>
<slot>hostNameEditingFinished()</slot>
<slot>portEditingFinished()</slot>
<slot>sshPortEditingFinished()</slot>
<slot>timeoutEditingFinished()</slot>
<slot>userNameEditingFinished()</slot>
<slot>passwordEditingFinished()</slot>
......@@ -537,5 +563,6 @@ p, li { white-space: pre-wrap; }
<slot>keyFileEditingFinished()</slot>
<slot>testConfig()</slot>
<slot>deployKey()</slot>
<slot>gdbServerPortEditingFinished()</slot>
</slots>
</ui>
......@@ -74,8 +74,8 @@ MaemoSshConnection::MaemoSshConnection(const MaemoDeviceConfig &devConf,
authString = &devConf.keyFile;
connFunc = &ne7ssh::connectWithKey;
}
m_channel = (ssh.*connFunc)(devConf.host.toAscii(), devConf.port,
devConf.uname.toAscii(), authString->toAscii(), shell, devConf.timeout);
m_channel = (ssh.*connFunc)(devConf.host.toLatin1(), devConf.sshPort,
devConf.uname.toAscii(), authString->toLatin1(), shell, devConf.timeout);
if (m_channel == -1)
throw MaemoSshException(tr("Could not connect to host"));
}
......@@ -130,7 +130,7 @@ void MaemoInteractiveSshConnection::runCommand(const QString &command)
ssh.lock();
const char * output = ssh.read(channel(), false);
if (output) {
emit remoteOutput(QLatin1String(output));
emit remoteOutput(QString::fromUtf8(output));
ssh.resetInput(channel(), false);
}
ssh.unlock();
......
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