forked from qt-creator/qt-creator
Device support: Rename DeviceProcess to DeviceProcessItem.
We want to introduce a new class that has more right to that name. Change-Id: I9535632e10872a97a8555e885a80c383bc5dcd2b Reviewed-by: hjk <hjk121@nokiamail.com>
This commit is contained in:
@@ -527,7 +527,7 @@ public:
|
|||||||
|
|
||||||
static QString executableForPid(qint64 pid)
|
static QString executableForPid(qint64 pid)
|
||||||
{
|
{
|
||||||
foreach (const DeviceProcess &p, DeviceProcessList::localProcesses())
|
foreach (const DeviceProcessItem &p, DeviceProcessList::localProcesses())
|
||||||
if (p.pid == pid)
|
if (p.pid == pid)
|
||||||
return p.exe;
|
return p.exe;
|
||||||
return QString();
|
return QString();
|
||||||
@@ -1688,7 +1688,7 @@ void DebuggerPluginPrivate::attachToProcess(bool startServerOnly)
|
|||||||
QTC_ASSERT(kit, return);
|
QTC_ASSERT(kit, return);
|
||||||
IDevice::ConstPtr device = DeviceKitInformation::device(kit);
|
IDevice::ConstPtr device = DeviceKitInformation::device(kit);
|
||||||
QTC_ASSERT(device, return);
|
QTC_ASSERT(device, return);
|
||||||
DeviceProcess process = dlg->currentProcess();
|
DeviceProcessItem process = dlg->currentProcess();
|
||||||
if (process.pid == 0) {
|
if (process.pid == 0) {
|
||||||
QMessageBox::warning(mainWindow(), tr("Warning"),
|
QMessageBox::warning(mainWindow(), tr("Warning"),
|
||||||
tr("Cannot attach to process with PID 0"));
|
tr("Cannot attach to process with PID 0"));
|
||||||
|
@@ -62,7 +62,7 @@ public:
|
|||||||
|
|
||||||
DeviceProcessesDialog *dialog;
|
DeviceProcessesDialog *dialog;
|
||||||
bool startServerOnly;
|
bool startServerOnly;
|
||||||
DeviceProcess process;
|
DeviceProcessItem process;
|
||||||
Kit *kit;
|
Kit *kit;
|
||||||
IDevice::ConstPtr device;
|
IDevice::ConstPtr device;
|
||||||
|
|
||||||
|
@@ -104,7 +104,7 @@ public slots:
|
|||||||
void handleProcessListUpdated();
|
void handleProcessListUpdated();
|
||||||
void handleProcessKilled();
|
void handleProcessKilled();
|
||||||
void updateButtons();
|
void updateButtons();
|
||||||
DeviceProcess selectedProcess() const;
|
DeviceProcessItem selectedProcess() const;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
QWidget *q;
|
QWidget *q;
|
||||||
@@ -277,11 +277,11 @@ void DeviceProcessesDialogPrivate::updateButtons()
|
|||||||
errorText->setVisible(!errorText->document()->isEmpty());
|
errorText->setVisible(!errorText->document()->isEmpty());
|
||||||
}
|
}
|
||||||
|
|
||||||
DeviceProcess DeviceProcessesDialogPrivate::selectedProcess() const
|
DeviceProcessItem DeviceProcessesDialogPrivate::selectedProcess() const
|
||||||
{
|
{
|
||||||
const QModelIndexList indexes = procView->selectionModel()->selectedIndexes();
|
const QModelIndexList indexes = procView->selectionModel()->selectedIndexes();
|
||||||
if (indexes.empty() || !processList)
|
if (indexes.empty() || !processList)
|
||||||
return DeviceProcess();
|
return DeviceProcessItem();
|
||||||
return processList->at(proxyModel.mapToSource(indexes.first()).row());
|
return processList->at(proxyModel.mapToSource(indexes.first()).row());
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -355,7 +355,7 @@ void DeviceProcessesDialog::showAllDevices()
|
|||||||
d->updateDevice();
|
d->updateDevice();
|
||||||
}
|
}
|
||||||
|
|
||||||
DeviceProcess DeviceProcessesDialog::currentProcess() const
|
DeviceProcessItem DeviceProcessesDialog::currentProcess() const
|
||||||
{
|
{
|
||||||
return d->selectedProcess();
|
return d->selectedProcess();
|
||||||
}
|
}
|
||||||
|
@@ -38,7 +38,7 @@
|
|||||||
|
|
||||||
namespace ProjectExplorer {
|
namespace ProjectExplorer {
|
||||||
|
|
||||||
class DeviceProcess;
|
class DeviceProcessItem;
|
||||||
class KitChooser;
|
class KitChooser;
|
||||||
|
|
||||||
namespace Internal { class DeviceProcessesDialogPrivate; }
|
namespace Internal { class DeviceProcessesDialogPrivate; }
|
||||||
@@ -55,7 +55,7 @@ public:
|
|||||||
|
|
||||||
void setDevice(const IDevice::ConstPtr &device);
|
void setDevice(const IDevice::ConstPtr &device);
|
||||||
void showAllDevices();
|
void showAllDevices();
|
||||||
DeviceProcess currentProcess() const;
|
DeviceProcessItem currentProcess() const;
|
||||||
KitChooser *kitChooser() const;
|
KitChooser *kitChooser() const;
|
||||||
void logMessage(const QString &line);
|
void logMessage(const QString &line);
|
||||||
DeviceProcessesDialog(KitChooser *chooser, QWidget *parent);
|
DeviceProcessesDialog(KitChooser *chooser, QWidget *parent);
|
||||||
|
@@ -46,7 +46,7 @@ public:
|
|||||||
{ }
|
{ }
|
||||||
|
|
||||||
const IDevice::ConstPtr device;
|
const IDevice::ConstPtr device;
|
||||||
QList<DeviceProcess> remoteProcesses;
|
QList<DeviceProcessItem> remoteProcesses;
|
||||||
State state;
|
State state;
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -96,7 +96,7 @@ void DeviceProcessList::update()
|
|||||||
doUpdate();
|
doUpdate();
|
||||||
}
|
}
|
||||||
|
|
||||||
void DeviceProcessList::reportProcessListUpdated(const QList<DeviceProcess> &processes)
|
void DeviceProcessList::reportProcessListUpdated(const QList<DeviceProcessItem> &processes)
|
||||||
{
|
{
|
||||||
QTC_ASSERT(d->state == Listing, return);
|
QTC_ASSERT(d->state == Listing, return);
|
||||||
setFinished();
|
setFinished();
|
||||||
@@ -125,7 +125,7 @@ void DeviceProcessList::reportProcessKilled()
|
|||||||
emit processKilled();
|
emit processKilled();
|
||||||
}
|
}
|
||||||
|
|
||||||
DeviceProcess DeviceProcessList::at(int row) const
|
DeviceProcessItem DeviceProcessList::at(int row) const
|
||||||
{
|
{
|
||||||
return d->remoteProcesses.at(row);
|
return d->remoteProcesses.at(row);
|
||||||
}
|
}
|
||||||
@@ -156,7 +156,7 @@ QVariant DeviceProcessList::data(const QModelIndex &index, int role) const
|
|||||||
return QVariant();
|
return QVariant();
|
||||||
|
|
||||||
if (role == Qt::DisplayRole || role == Qt::ToolTipRole) {
|
if (role == Qt::DisplayRole || role == Qt::ToolTipRole) {
|
||||||
const DeviceProcess &proc = d->remoteProcesses.at(index.row());
|
const DeviceProcessItem &proc = d->remoteProcesses.at(index.row());
|
||||||
if (index.column() == 0)
|
if (index.column() == 0)
|
||||||
return proc.pid;
|
return proc.pid;
|
||||||
else
|
else
|
||||||
@@ -182,12 +182,12 @@ void DeviceProcessList::reportError(const QString &message)
|
|||||||
emit error(message);
|
emit error(message);
|
||||||
}
|
}
|
||||||
|
|
||||||
QList<DeviceProcess> DeviceProcessList::localProcesses()
|
QList<DeviceProcessItem> DeviceProcessList::localProcesses()
|
||||||
{
|
{
|
||||||
return LocalProcessList::getLocalProcesses();
|
return LocalProcessList::getLocalProcesses();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool DeviceProcess::operator <(const DeviceProcess &other) const
|
bool DeviceProcessItem::operator <(const DeviceProcessItem &other) const
|
||||||
{
|
{
|
||||||
if (pid != other.pid)
|
if (pid != other.pid)
|
||||||
return pid < other.pid;
|
return pid < other.pid;
|
||||||
|
@@ -39,11 +39,11 @@ namespace ProjectExplorer {
|
|||||||
|
|
||||||
namespace Internal { class DeviceProcessListPrivate; }
|
namespace Internal { class DeviceProcessListPrivate; }
|
||||||
|
|
||||||
class PROJECTEXPLORER_EXPORT DeviceProcess
|
class PROJECTEXPLORER_EXPORT DeviceProcessItem
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
DeviceProcess() : pid(0) {}
|
DeviceProcessItem() : pid(0) {}
|
||||||
bool operator<(const DeviceProcess &other) const;
|
bool operator<(const DeviceProcessItem &other) const;
|
||||||
|
|
||||||
int pid;
|
int pid;
|
||||||
QString cmdLine;
|
QString cmdLine;
|
||||||
@@ -60,9 +60,9 @@ public:
|
|||||||
|
|
||||||
void update();
|
void update();
|
||||||
void killProcess(int row);
|
void killProcess(int row);
|
||||||
DeviceProcess at(int row) const;
|
DeviceProcessItem at(int row) const;
|
||||||
|
|
||||||
static QList<DeviceProcess> localProcesses();
|
static QList<DeviceProcessItem> localProcesses();
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void processListUpdated();
|
void processListUpdated();
|
||||||
@@ -72,7 +72,7 @@ signals:
|
|||||||
protected:
|
protected:
|
||||||
void reportError(const QString &message);
|
void reportError(const QString &message);
|
||||||
void reportProcessKilled();
|
void reportProcessKilled();
|
||||||
void reportProcessListUpdated(const QList<DeviceProcess> &processes);
|
void reportProcessListUpdated(const QList<DeviceProcessItem> &processes);
|
||||||
|
|
||||||
IDevice::ConstPtr device() const;
|
IDevice::ConstPtr device() const;
|
||||||
|
|
||||||
@@ -87,7 +87,7 @@ private:
|
|||||||
bool hasChildren(const QModelIndex &parent) const;
|
bool hasChildren(const QModelIndex &parent) const;
|
||||||
|
|
||||||
virtual void doUpdate() = 0;
|
virtual void doUpdate() = 0;
|
||||||
virtual void doKillProcess(const DeviceProcess &process) = 0;
|
virtual void doKillProcess(const DeviceProcessItem &process) = 0;
|
||||||
|
|
||||||
void setFinished();
|
void setFinished();
|
||||||
|
|
||||||
|
@@ -166,15 +166,15 @@ static bool isUnixProcessId(const QString &procname)
|
|||||||
|
|
||||||
static const char procDirC[] = "/proc/";
|
static const char procDirC[] = "/proc/";
|
||||||
|
|
||||||
static QList<DeviceProcess> getLocalProcessesUsingProc(const QDir &procDir)
|
static QList<DeviceProcessItem> getLocalProcessesUsingProc(const QDir &procDir)
|
||||||
{
|
{
|
||||||
QList<DeviceProcess> processes;
|
QList<DeviceProcessItem> processes;
|
||||||
const QString procDirPath = QLatin1String(procDirC);
|
const QString procDirPath = QLatin1String(procDirC);
|
||||||
const QStringList procIds = procDir.entryList();
|
const QStringList procIds = procDir.entryList();
|
||||||
foreach (const QString &procId, procIds) {
|
foreach (const QString &procId, procIds) {
|
||||||
if (!isUnixProcessId(procId))
|
if (!isUnixProcessId(procId))
|
||||||
continue;
|
continue;
|
||||||
DeviceProcess proc;
|
DeviceProcessItem proc;
|
||||||
proc.pid = procId.toInt();
|
proc.pid = procId.toInt();
|
||||||
const QString root = procDirPath + procId;
|
const QString root = procDirPath + procId;
|
||||||
|
|
||||||
@@ -216,14 +216,14 @@ static QList<DeviceProcess> getLocalProcessesUsingProc(const QDir &procDir)
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Determine UNIX processes by running ps
|
// Determine UNIX processes by running ps
|
||||||
static QList<DeviceProcess> getLocalProcessesUsingPs()
|
static QList<DeviceProcessItem> getLocalProcessesUsingPs()
|
||||||
{
|
{
|
||||||
#ifdef Q_OS_MAC
|
#ifdef Q_OS_MAC
|
||||||
static const char formatC[] = "pid state command";
|
static const char formatC[] = "pid state command";
|
||||||
#else
|
#else
|
||||||
static const char formatC[] = "pid,state,cmd";
|
static const char formatC[] = "pid,state,cmd";
|
||||||
#endif
|
#endif
|
||||||
QList<DeviceProcess> processes;
|
QList<DeviceProcessItem> processes;
|
||||||
QProcess psProcess;
|
QProcess psProcess;
|
||||||
QStringList args;
|
QStringList args;
|
||||||
args << QLatin1String("-e") << QLatin1String("-o") << QLatin1String(formatC);
|
args << QLatin1String("-e") << QLatin1String("-o") << QLatin1String(formatC);
|
||||||
@@ -240,7 +240,7 @@ static QList<DeviceProcess> getLocalProcessesUsingPs()
|
|||||||
const int pidSep = line.indexOf(blank);
|
const int pidSep = line.indexOf(blank);
|
||||||
const int cmdSep = pidSep != -1 ? line.indexOf(blank, pidSep + 1) : -1;
|
const int cmdSep = pidSep != -1 ? line.indexOf(blank, pidSep + 1) : -1;
|
||||||
if (cmdSep > 0) {
|
if (cmdSep > 0) {
|
||||||
DeviceProcess procData;
|
DeviceProcessItem procData;
|
||||||
procData.pid = line.left(pidSep).toInt();
|
procData.pid = line.left(pidSep).toInt();
|
||||||
procData.exe = line.mid(cmdSep + 1);
|
procData.exe = line.mid(cmdSep + 1);
|
||||||
procData.cmdLine = line.mid(cmdSep + 1);
|
procData.cmdLine = line.mid(cmdSep + 1);
|
||||||
@@ -252,13 +252,13 @@ static QList<DeviceProcess> getLocalProcessesUsingPs()
|
|||||||
return processes;
|
return processes;
|
||||||
}
|
}
|
||||||
|
|
||||||
QList<DeviceProcess> LocalProcessList::getLocalProcesses()
|
QList<DeviceProcessItem> LocalProcessList::getLocalProcesses()
|
||||||
{
|
{
|
||||||
const QDir procDir = QDir(QLatin1String(procDirC));
|
const QDir procDir = QDir(QLatin1String(procDirC));
|
||||||
return procDir.exists() ? getLocalProcessesUsingProc(procDir) : getLocalProcessesUsingPs();
|
return procDir.exists() ? getLocalProcessesUsingProc(procDir) : getLocalProcessesUsingPs();
|
||||||
}
|
}
|
||||||
|
|
||||||
void LocalProcessList::doKillProcess(const DeviceProcess &process)
|
void LocalProcessList::doKillProcess(const DeviceProcessItem &process)
|
||||||
{
|
{
|
||||||
if (kill(process.pid, SIGKILL) == -1)
|
if (kill(process.pid, SIGKILL) == -1)
|
||||||
m_error = QString::fromLocal8Bit(strerror(errno));
|
m_error = QString::fromLocal8Bit(strerror(errno));
|
||||||
|
@@ -49,11 +49,11 @@ public:
|
|||||||
LocalProcessList(const IDevice::ConstPtr &device, QObject *parent = 0);
|
LocalProcessList(const IDevice::ConstPtr &device, QObject *parent = 0);
|
||||||
virtual Qt::ItemFlags flags(const QModelIndex &index) const;
|
virtual Qt::ItemFlags flags(const QModelIndex &index) const;
|
||||||
|
|
||||||
static QList<DeviceProcess> getLocalProcesses();
|
static QList<DeviceProcessItem> getLocalProcesses();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void doUpdate();
|
void doUpdate();
|
||||||
void doKillProcess(const DeviceProcess &process);
|
void doKillProcess(const DeviceProcessItem &process);
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
void handleUpdate();
|
void handleUpdate();
|
||||||
|
@@ -59,7 +59,7 @@ void SshDeviceProcessList::doUpdate()
|
|||||||
d->process.run(listProcessesCommandLine().toUtf8(), device()->sshParameters());
|
d->process.run(listProcessesCommandLine().toUtf8(), device()->sshParameters());
|
||||||
}
|
}
|
||||||
|
|
||||||
void SshDeviceProcessList::doKillProcess(const DeviceProcess &process)
|
void SshDeviceProcessList::doKillProcess(const DeviceProcessItem &process)
|
||||||
{
|
{
|
||||||
QTC_ASSERT(device()->processSupport(), return);
|
QTC_ASSERT(device()->processSupport(), return);
|
||||||
connect(&d->process, SIGNAL(connectionError()), SLOT(handleConnectionError()));
|
connect(&d->process, SIGNAL(connectionError()), SLOT(handleConnectionError()));
|
||||||
|
@@ -47,10 +47,10 @@ private slots:
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
virtual QString listProcessesCommandLine() const = 0;
|
virtual QString listProcessesCommandLine() const = 0;
|
||||||
virtual QList<DeviceProcess> buildProcessList(const QString &listProcessesReply) const = 0;
|
virtual QList<DeviceProcessItem> buildProcessList(const QString &listProcessesReply) const = 0;
|
||||||
|
|
||||||
void doUpdate();
|
void doUpdate();
|
||||||
void doKillProcess(const DeviceProcess &process);
|
void doKillProcess(const DeviceProcessItem &process);
|
||||||
|
|
||||||
void handleProcessError(const QString &errorMessage);
|
void handleProcessError(const QString &errorMessage);
|
||||||
void setFinished();
|
void setFinished();
|
||||||
|
@@ -105,9 +105,9 @@ private:
|
|||||||
return QLatin1String("pidin -F \"%a %A '/%n'\"");
|
return QLatin1String("pidin -F \"%a %A '/%n'\"");
|
||||||
}
|
}
|
||||||
|
|
||||||
QList<ProjectExplorer::DeviceProcess> buildProcessList(const QString &listProcessesReply) const
|
QList<ProjectExplorer::DeviceProcessItem> buildProcessList(const QString &listProcessesReply) const
|
||||||
{
|
{
|
||||||
QList<ProjectExplorer::DeviceProcess> processes;
|
QList<ProjectExplorer::DeviceProcessItem> processes;
|
||||||
QStringList lines = listProcessesReply.split(QLatin1Char('\n'));
|
QStringList lines = listProcessesReply.split(QLatin1Char('\n'));
|
||||||
if (lines.isEmpty())
|
if (lines.isEmpty())
|
||||||
return processes;
|
return processes;
|
||||||
@@ -122,7 +122,7 @@ private:
|
|||||||
const int pid = captures[1].toInt();
|
const int pid = captures[1].toInt();
|
||||||
const QString args = captures[2];
|
const QString args = captures[2];
|
||||||
const QString exe = captures[3];
|
const QString exe = captures[3];
|
||||||
ProjectExplorer::DeviceProcess deviceProcess;
|
ProjectExplorer::DeviceProcessItem deviceProcess;
|
||||||
deviceProcess.pid = pid;
|
deviceProcess.pid = pid;
|
||||||
deviceProcess.exe = exe.trimmed();
|
deviceProcess.exe = exe.trimmed();
|
||||||
deviceProcess.cmdLine = args.trimmed();
|
deviceProcess.cmdLine = args.trimmed();
|
||||||
|
@@ -72,9 +72,9 @@ private:
|
|||||||
"done").arg(QLatin1String(Delimiter0)).arg(QLatin1String(Delimiter1));
|
"done").arg(QLatin1String(Delimiter0)).arg(QLatin1String(Delimiter1));
|
||||||
}
|
}
|
||||||
|
|
||||||
QList<DeviceProcess> buildProcessList(const QString &listProcessesReply) const
|
QList<DeviceProcessItem> buildProcessList(const QString &listProcessesReply) const
|
||||||
{
|
{
|
||||||
QList<DeviceProcess> processes;
|
QList<DeviceProcessItem> processes;
|
||||||
const QStringList lines = listProcessesReply.split(QString::fromLatin1(Delimiter0)
|
const QStringList lines = listProcessesReply.split(QString::fromLatin1(Delimiter0)
|
||||||
+ QString::fromLatin1(Delimiter1), QString::SkipEmptyParts);
|
+ QString::fromLatin1(Delimiter1), QString::SkipEmptyParts);
|
||||||
foreach (const QString &line, lines) {
|
foreach (const QString &line, lines) {
|
||||||
@@ -104,7 +104,7 @@ private:
|
|||||||
+ QLatin1Char(']');
|
+ QLatin1Char(']');
|
||||||
}
|
}
|
||||||
|
|
||||||
DeviceProcess process;
|
DeviceProcessItem process;
|
||||||
process.pid = pid;
|
process.pid = pid;
|
||||||
process.cmdLine = command;
|
process.cmdLine = command;
|
||||||
process.exe = elements.at(3);
|
process.exe = elements.at(3);
|
||||||
|
Reference in New Issue
Block a user