Commit f0219724 authored by Tobias Nätterlund's avatar Tobias Nätterlund Committed by Tobias Nätterlund
Browse files

QNX: Show warning when slog2info is not found on QNX >6.5



Change-Id: Ifa66184c51144d461c351fcdf40233c39c9cf507
Reviewed-by: Nicolas Arnaud-Cormos's avatarNicolas Arnaud-Cormos <nicolas@kdab.com>
parent 231dd3f6
......@@ -34,14 +34,22 @@
#include "qnxdeviceprocesslist.h"
#include "qnxdeviceprocesssignaloperation.h"
#include <projectexplorer/devicesupport/sshdeviceprocess.h>
#include <ssh/sshconnection.h>
#include <utils/qtcassert.h>
#include <QApplication>
#include <QRegExp>
#include <QStringList>
#include <QThread>
using namespace Qnx;
using namespace Qnx::Internal;
namespace {
const char QnxVersionKey[] = "QnxVersion";
}
class QnxPortsGatheringMethod : public ProjectExplorer::PortsGatheringMethod
{
// TODO: The command is probably needlessly complicated because the parsing method
......@@ -82,20 +90,22 @@ class QnxPortsGatheringMethod : public ProjectExplorer::PortsGatheringMethod
QnxDeviceConfiguration::QnxDeviceConfiguration()
: RemoteLinux::LinuxDevice()
, m_versionNumber(0)
{
}
QnxDeviceConfiguration::QnxDeviceConfiguration(const QString &name, Core::Id type, MachineType machineType, Origin origin, Core::Id id)
: RemoteLinux::LinuxDevice(name, type, machineType, origin, id)
, m_versionNumber(0)
{
}
QnxDeviceConfiguration::QnxDeviceConfiguration(const QnxDeviceConfiguration &other)
: RemoteLinux::LinuxDevice(other)
, m_versionNumber(other.m_versionNumber)
{
}
QnxDeviceConfiguration::Ptr QnxDeviceConfiguration::create()
{
return Ptr(new QnxDeviceConfiguration);
......@@ -111,6 +121,58 @@ QString QnxDeviceConfiguration::displayType() const
return tr("QNX");
}
int QnxDeviceConfiguration::qnxVersion() const
{
if (m_versionNumber == 0)
updateVersionNumber();
return m_versionNumber;
}
void QnxDeviceConfiguration::updateVersionNumber() const
{
QEventLoop eventLoop;
ProjectExplorer::SshDeviceProcess versionNumberProcess(sharedFromThis());
QObject::connect(&versionNumberProcess, SIGNAL(finished()), &eventLoop, SLOT(quit()));
QObject::connect(&versionNumberProcess, SIGNAL(error(QProcess::ProcessError)), &eventLoop, SLOT(quit()));
QStringList arguments;
arguments << QLatin1String("-r");
versionNumberProcess.start(QLatin1String("uname"), arguments);
bool isGuiThread = QThread::currentThread() == QCoreApplication::instance()->thread();
if (isGuiThread)
QApplication::setOverrideCursor(Qt::WaitCursor);
eventLoop.exec(QEventLoop::ExcludeUserInputEvents);
QByteArray output = versionNumberProcess.readAllStandardOutput();
QString versionMessage = QString::fromLatin1(output);
QRegExp versionNumberRegExp = QRegExp(QLatin1String("(\\d+)\\.(\\d+)\\.(\\d+)"));
if (versionNumberRegExp.indexIn(versionMessage) > -1 && versionNumberRegExp.captureCount() == 3) {
int major = versionNumberRegExp.cap(1).toInt();
int minor = versionNumberRegExp.cap(2).toInt();
int patch = versionNumberRegExp.cap(3).toInt();
m_versionNumber = (major << 16)|(minor<<8)|(patch);
}
if (isGuiThread)
QApplication::restoreOverrideCursor();
}
void QnxDeviceConfiguration::fromMap(const QVariantMap &map)
{
m_versionNumber = map.value(QLatin1String(QnxVersionKey), 0).toInt();
RemoteLinux::LinuxDevice::fromMap(map);
}
QVariantMap QnxDeviceConfiguration::toMap() const
{
QVariantMap map(RemoteLinux::LinuxDevice::toMap());
map.insert(QLatin1String(QnxVersionKey), m_versionNumber);
return map;
}
ProjectExplorer::IDevice::Ptr QnxDeviceConfiguration::clone() const
{
return Ptr(new QnxDeviceConfiguration(*this));
......
......@@ -58,6 +58,11 @@ public:
QString displayType() const;
int qnxVersion() const;
void fromMap(const QVariantMap &map);
QVariantMap toMap() const;
protected:
QnxDeviceConfiguration();
QnxDeviceConfiguration(const QString &name, Core::Id type, MachineType machineType,
......@@ -67,6 +72,10 @@ protected:
QString interruptProcessByNameCommandLine(const QString &filePath) const;
QString killProcessByNameCommandLine(const QString &filePath) const;
private:
void updateVersionNumber() const;
mutable int m_versionNumber;
};
} // namespace Internal
......
......@@ -30,6 +30,7 @@
****************************************************************************/
#include "qnxdevicetester.h"
#include "qnxdeviceconfiguration.h"
#include <ssh/sshremoteprocessrunner.h>
#include <utils/qtcassert.h>
......@@ -44,6 +45,10 @@ QnxDeviceTester::QnxDeviceTester(QObject *parent)
, m_currentCommandIndex(-1)
{
m_genericTester = new RemoteLinux::GenericLinuxDeviceTester(this);
connect(m_genericTester, SIGNAL(progressMessage(QString)), SIGNAL(progressMessage(QString)));
connect(m_genericTester, SIGNAL(errorMessage(QString)), SIGNAL(errorMessage(QString)));
connect(m_genericTester, SIGNAL(finished(ProjectExplorer::DeviceTester::TestResult)),
SLOT(handleGenericTestFinished(ProjectExplorer::DeviceTester::TestResult)));
m_processRunner = new QSsh::SshRemoteProcessRunner(this);
connect(m_processRunner, SIGNAL(connectionError()), SLOT(handleConnectionError()));
......@@ -68,11 +73,6 @@ void QnxDeviceTester::testDevice(const ProjectExplorer::IDevice::ConstPtr &devic
m_deviceConfiguration = deviceConfiguration;
connect(m_genericTester, SIGNAL(progressMessage(QString)), SIGNAL(progressMessage(QString)));
connect(m_genericTester, SIGNAL(errorMessage(QString)), SIGNAL(errorMessage(QString)));
connect(m_genericTester, SIGNAL(finished(ProjectExplorer::DeviceTester::TestResult)),
SLOT(handleGenericTestFinished(ProjectExplorer::DeviceTester::TestResult)));
m_state = GenericTest;
m_genericTester->testDevice(deviceConfiguration);
}
......@@ -107,6 +107,10 @@ void QnxDeviceTester::handleGenericTestFinished(TestResult result)
}
m_state = CommandsTest;
QnxDeviceConfiguration::ConstPtr qnxDevice = m_deviceConfiguration.dynamicCast<const QnxDeviceConfiguration>();
m_commandsToTest.append(versionSpecificCommandsToTest(qnxDevice->qnxVersion()));
testNextCommand();
}
......@@ -161,3 +165,12 @@ void QnxDeviceTester::setFinished()
disconnect(m_processRunner, 0, this, 0);
emit finished(m_result);
}
QStringList QnxDeviceTester::versionSpecificCommandsToTest(int versionNumber) const
{
QStringList result;
if (versionNumber > 0x060500)
result << QLatin1String("slog2info");
return result;
}
......@@ -68,6 +68,8 @@ private:
void testNextCommand();
void setFinished();
QStringList versionSpecificCommandsToTest(int versionNumber) const;
RemoteLinux::GenericLinuxDeviceTester *m_genericTester;
ProjectExplorer::IDevice::ConstPtr m_deviceConfiguration;
ProjectExplorer::DeviceTester::TestResult m_result;
......
......@@ -58,6 +58,8 @@ QnxRunControl::QnxRunControl(ProjectExplorer::RunConfiguration *runConfig)
m_slog2Info = new Slog2InfoRunner(applicationId, qnxDevice, this);
connect(m_slog2Info, SIGNAL(output(QString,Utils::OutputFormat)), this, SLOT(appendMessage(QString,Utils::OutputFormat)));
connect(this, SIGNAL(started()), m_slog2Info, SLOT(start()));
if (qnxDevice->qnxVersion() > 0x060500)
connect(m_slog2Info, SIGNAL(commandMissing()), this, SLOT(printMissingWarning()));
}
ProjectExplorer::RunControl::StopResult QnxRunControl::stop()
......@@ -65,3 +67,8 @@ ProjectExplorer::RunControl::StopResult QnxRunControl::stop()
m_slog2Info->stop();
return RemoteLinuxRunControl::stop();
}
void QnxRunControl::printMissingWarning()
{
appendMessage(tr("Warning: \"slog2info\" is not found on the device, debug output not available!"), Utils::ErrorMessageFormat);
}
......@@ -47,6 +47,9 @@ public:
RemoteLinux::RemoteLinuxRunControl::StopResult stop();
private slots:
void printMissingWarning();
private:
Slog2InfoRunner *m_slog2Info;
};
......
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