Commit 1d792a9a authored by Tobias Nätterlund's avatar Tobias Nätterlund Committed by Tobias Nätterlund

QNX: Add support for listing processes for pure QNX devices

Change-Id: Id2d9bd6b7f5ce56ff0d7ece30bb93a69969beecf
Reviewed-by: default avatarAndreas Holzammer <andreas.holzammer@kdab.com>
Reviewed-by: Nicolas Arnaud-Cormos's avatarNicolas Arnaud-Cormos <nicolas@kdab.com>
Reviewed-by: default avatarTobias Hunger <tobias.hunger@digia.com>
parent 3c1b5213
......@@ -31,6 +31,11 @@
#include "qnxdeviceconfiguration.h"
#include <projectexplorer/devicesupport/sshdeviceprocesslist.h>
#include <QRegExp>
#include <QStringList>
using namespace Qnx;
using namespace Qnx::Internal;
......@@ -85,6 +90,51 @@ class QnxPortsGatheringMethod : public ProjectExplorer::PortsGatheringMethod
}
};
class QnxDeviceProcessList : public ProjectExplorer::SshDeviceProcessList
{
public:
QnxDeviceProcessList(const ProjectExplorer::IDevice::ConstPtr &device, QObject *parent)
: SshDeviceProcessList(device, parent)
{
}
private:
QString listProcessesCommandLine() const
{
return QLatin1String("pidin -F \"%a %A '/%n'\"");
}
QList<ProjectExplorer::DeviceProcess> buildProcessList(const QString &listProcessesReply) const
{
QList<ProjectExplorer::DeviceProcess> processes;
QStringList lines = listProcessesReply.split(QLatin1Char('\n'));
if (lines.isEmpty())
return processes;
lines.pop_front(); // drop headers
QRegExp re(QLatin1String("\\s*(\\d+)\\s+(.*)'(.*)'"));
foreach (const QString& line, lines) {
if (re.exactMatch(line)) {
const QStringList captures = re.capturedTexts();
if (captures.size() == 4) {
const int pid = captures[1].toInt();
const QString args = captures[2];
const QString exe = captures[3];
ProjectExplorer::DeviceProcess deviceProcess;
deviceProcess.pid = pid;
deviceProcess.exe = exe.trimmed();
deviceProcess.cmdLine = args.trimmed();
processes.append(deviceProcess);
}
}
}
qSort(processes);
return processes;
}
};
QnxDeviceConfiguration::QnxDeviceConfiguration()
: RemoteLinux::LinuxDevice()
{
......@@ -130,3 +180,8 @@ ProjectExplorer::PortsGatheringMethod::Ptr QnxDeviceConfiguration::portsGatherin
{
return ProjectExplorer::PortsGatheringMethod::Ptr(new QnxPortsGatheringMethod);
}
ProjectExplorer::DeviceProcessList *QnxDeviceConfiguration::createProcessListModel(QObject *parent) const
{
return new QnxDeviceProcessList(sharedFromThis(), parent);
}
......@@ -52,7 +52,7 @@ public:
ProjectExplorer::DeviceProcessSupport::Ptr processSupport() const;
ProjectExplorer::PortsGatheringMethod::Ptr portsGatheringMethod() const;
bool canCreateProcessModel() const { return false; } // Override LinuxDevice implementation.
ProjectExplorer::DeviceProcessList *createProcessListModel(QObject *parent) const;
QString displayType() const;
......
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