Commit 2c2a8a78 authored by hjk's avatar hjk Committed by hjk
Browse files

analyzer: merge start and startRemote partially



Change-Id: Iaa837f5bc696af7e71bbed128b9a5c8c46e512c7
Reviewed-by: default avatarhjk <qthjk@ovi.com>
parent 84cce9dc
......@@ -76,12 +76,6 @@ void CallgrindRunner::start()
m_controller->setValgrindProcess(valgrindProcess());
}
void CallgrindRunner::startRemotely(const Utils::SshConnectionParameters &sshParams)
{
ValgrindRunner::startRemotely(sshParams);
m_controller->setValgrindProcess(valgrindProcess());
}
void CallgrindRunner::processFinished(int ret, QProcess::ExitStatus status)
{
triggerParse();
......
......@@ -55,9 +55,7 @@ public:
CallgrindController *controller() const;
bool isPaused() const;
virtual void start();
virtual void startRemotely(const Utils::SshConnectionParameters &sshParams);
void start();
signals:
void statusMessage(const QString &message);
......
......@@ -98,114 +98,113 @@ void MemcheckRunner::setParser(XmlProtocol::ThreadedParser *parser)
void MemcheckRunner::start()
{
QTC_ASSERT(d->parser, return);
bool check = d->xmlServer.listen(QHostAddress(QHostAddress::LocalHost));
QTC_ASSERT(check, return);
d->xmlServer.setMaxPendingConnections(1);
const quint16 xmlPortNumber = d->xmlServer.serverPort();
connect(&d->xmlServer, SIGNAL(newConnection()), SLOT(xmlSocketConnected()));
check = d->logServer.listen(QHostAddress(QHostAddress::LocalHost));
QTC_ASSERT(check, return);
d->logServer.setMaxPendingConnections(1);
const quint16 logPortNumber = d->logServer.serverPort();
connect(&d->logServer, SIGNAL(newConnection()), SLOT(logSocketConnected()));
QStringList memcheckArguments;
memcheckArguments << QString("--xml=yes")
<< QString("--xml-socket=127.0.0.1:%1").arg(QString::number(xmlPortNumber))
<< QString("--child-silent-after-fork=yes")
<< QString("--log-socket=127.0.0.1:%1").arg(QString::number(logPortNumber))
<< valgrindArguments();
setValgrindArguments(memcheckArguments);
ValgrindRunner::start();
}
if (startMode() == Analyzer::StartLocal) {
QTC_ASSERT(d->parser, return);
bool check = d->xmlServer.listen(QHostAddress(QHostAddress::LocalHost));
QTC_ASSERT(check, return);
d->xmlServer.setMaxPendingConnections(1);
const quint16 xmlPortNumber = d->xmlServer.serverPort();
connect(&d->xmlServer, SIGNAL(newConnection()), SLOT(xmlSocketConnected()));
check = d->logServer.listen(QHostAddress(QHostAddress::LocalHost));
QTC_ASSERT(check, return);
d->logServer.setMaxPendingConnections(1);
const quint16 logPortNumber = d->logServer.serverPort();
connect(&d->logServer, SIGNAL(newConnection()), SLOT(logSocketConnected()));
QStringList memcheckArguments;
memcheckArguments << QString("--xml=yes")
<< QString("--xml-socket=127.0.0.1:%1").arg(QString::number(xmlPortNumber))
<< QString("--child-silent-after-fork=yes")
<< QString("--log-socket=127.0.0.1:%1").arg(QString::number(logPortNumber))
<< valgrindArguments();
setValgrindArguments(memcheckArguments);
}
void MemcheckRunner::startRemotely(const Utils::SshConnectionParameters &sshParams)
{
QTC_ASSERT(d->parser, return);
QList<QHostAddress> possibleHostAddresses;
//NOTE: ::allAddresses does not seem to work for usb interfaces...
foreach (const QNetworkInterface &iface, QNetworkInterface::allInterfaces()) {
foreach (const QNetworkAddressEntry &entry, iface.addressEntries()) {
const QHostAddress addr = entry.ip();
if (addr.toString() != "127.0.0.1"
&& addr.toString() != "0:0:0:0:0:0:0:1")
{
possibleHostAddresses << addr;
break;
if (startMode() == Analyzer::StartRemote) {
QTC_ASSERT(d->parser, return);
QList<QHostAddress> possibleHostAddresses;
//NOTE: ::allAddresses does not seem to work for usb interfaces...
foreach (const QNetworkInterface &iface, QNetworkInterface::allInterfaces()) {
foreach (const QNetworkAddressEntry &entry, iface.addressEntries()) {
const QHostAddress addr = entry.ip();
if (addr.toString() != "127.0.0.1"
&& addr.toString() != "0:0:0:0:0:0:0:1")
{
possibleHostAddresses << addr;
break;
}
}
}
}
QHostAddress hostAddr;
if (possibleHostAddresses.isEmpty()) {
emit processErrorReceived(tr("No network interface found for remote analysis."),
QProcess::FailedToStart);
return;
} else if (possibleHostAddresses.size() > 1) {
QDialog dlg;
dlg.setWindowTitle(tr("Select Network Interface"));
QVBoxLayout *layout = new QVBoxLayout;
QLabel *description = new QLabel;
description->setWordWrap(true);
description->setText(tr("More than one network interface was found on your machine. Please select which one you want to use for remote analysis."));
layout->addWidget(description);
QListWidget *list = new QListWidget;
foreach (const QHostAddress &address, possibleHostAddresses)
list->addItem(address.toString());
list->setSelectionMode(QAbstractItemView::SingleSelection);
list->setCurrentRow(0);
layout->addWidget(list);
QDialogButtonBox *buttons = new QDialogButtonBox;
buttons->addButton(QDialogButtonBox::Ok);
buttons->addButton(QDialogButtonBox::Cancel);
connect(buttons, SIGNAL(accepted()),
&dlg, SLOT(accept()));
connect(buttons, SIGNAL(rejected()),
&dlg, SLOT(reject()));
layout->addWidget(buttons);
dlg.setLayout(layout);
if (dlg.exec() != QDialog::Accepted)
QHostAddress hostAddr;
if (possibleHostAddresses.isEmpty()) {
emit processErrorReceived(tr("No network interface found for remote analysis."),
QProcess::FailedToStart);
return;
} else if (possibleHostAddresses.size() > 1) {
QDialog dlg;
dlg.setWindowTitle(tr("Select Network Interface"));
QVBoxLayout *layout = new QVBoxLayout;
QLabel *description = new QLabel;
description->setWordWrap(true);
description->setText(tr("More than one network interface was found on your machine. Please select which one you want to use for remote analysis."));
layout->addWidget(description);
QListWidget *list = new QListWidget;
foreach (const QHostAddress &address, possibleHostAddresses)
list->addItem(address.toString());
list->setSelectionMode(QAbstractItemView::SingleSelection);
list->setCurrentRow(0);
layout->addWidget(list);
QDialogButtonBox *buttons = new QDialogButtonBox;
buttons->addButton(QDialogButtonBox::Ok);
buttons->addButton(QDialogButtonBox::Cancel);
connect(buttons, SIGNAL(accepted()),
&dlg, SLOT(accept()));
connect(buttons, SIGNAL(rejected()),
&dlg, SLOT(reject()));
layout->addWidget(buttons);
dlg.setLayout(layout);
if (dlg.exec() != QDialog::Accepted)
return;
QTC_ASSERT(list->currentRow() >= 0, return);
QTC_ASSERT(list->currentRow() < possibleHostAddresses.size(), return);
hostAddr = possibleHostAddresses.at(list->currentRow());
} else {
hostAddr = possibleHostAddresses.first();
}
QTC_ASSERT(list->currentRow() >= 0, return);
QTC_ASSERT(list->currentRow() < possibleHostAddresses.size(), return);
hostAddr = possibleHostAddresses.at(list->currentRow());
} else {
hostAddr = possibleHostAddresses.first();
QString ip = hostAddr.toString();
QTC_ASSERT(!ip.isEmpty(), return);
bool check = d->xmlServer.listen(hostAddr);
QTC_ASSERT(check, return);
d->xmlServer.setMaxPendingConnections(1);
const quint16 xmlPortNumber = d->xmlServer.serverPort();
connect(&d->xmlServer, SIGNAL(newConnection()), SLOT(xmlSocketConnected()));
check = d->logServer.listen(hostAddr);
QTC_ASSERT(check, return);
d->logServer.setMaxPendingConnections(1);
const quint16 logPortNumber = d->logServer.serverPort();
connect(&d->logServer, SIGNAL(newConnection()), SLOT(logSocketConnected()));
QStringList memcheckArguments;
memcheckArguments << QString("--xml=yes")
<< QString("--xml-socket=%1:%2").arg(ip, QString::number(xmlPortNumber))
<< QString("--child-silent-after-fork=yes")
<< QString("--log-socket=%1:%2").arg(ip, QString::number(logPortNumber));
setValgrindArguments(memcheckArguments);
}
QString ip = hostAddr.toString();
QTC_ASSERT(!ip.isEmpty(), return);
bool check = d->xmlServer.listen(hostAddr);
QTC_ASSERT(check, return);
d->xmlServer.setMaxPendingConnections(1);
const quint16 xmlPortNumber = d->xmlServer.serverPort();
connect(&d->xmlServer, SIGNAL(newConnection()), SLOT(xmlSocketConnected()));
check = d->logServer.listen(hostAddr);
QTC_ASSERT(check, return);
d->logServer.setMaxPendingConnections(1);
const quint16 logPortNumber = d->logServer.serverPort();
connect(&d->logServer, SIGNAL(newConnection()), SLOT(logSocketConnected()));
QStringList memcheckArguments;
memcheckArguments << QString("--xml=yes")
<< QString("--xml-socket=%1:%2").arg(ip, QString::number(xmlPortNumber))
<< QString("--child-silent-after-fork=yes")
<< QString("--log-socket=%1:%2").arg(ip, QString::number(logPortNumber));
setValgrindArguments(memcheckArguments);
ValgrindRunner::startRemotely(sshParams);
ValgrindRunner::start();
}
void MemcheckRunner::xmlSocketConnected()
......
......@@ -54,9 +54,7 @@ public:
~MemcheckRunner();
void setParser(XmlProtocol::ThreadedParser *parser);
void start();
void startRemotely(const Utils::SshConnectionParameters &sshParams);
signals:
void logMessageReceived(const QByteArray &);
......
......@@ -103,6 +103,8 @@ bool ValgrindEngine::start()
runner()->setDebuggeeExecutable(sp.debuggee);
runner()->setDebuggeeArguments(sp.debuggeeArgs);
runner()->setEnvironment(sp.environment);
runner()->setConnectionParameters(sp.connParams);
runner()->setStartMode(sp.startMode);
connect(runner(), SIGNAL(processOutputReceived(QByteArray,Utils::OutputFormat)),
SLOT(receiveProcessOutput(QByteArray,Utils::OutputFormat)));
......@@ -111,10 +113,7 @@ bool ValgrindEngine::start()
connect(runner(), SIGNAL(finished()),
SLOT(runnerFinished()));
if (sp.startMode == StartRemote)
runner()->startRemotely(sp.connParams);
else
runner()->start();
runner()->start();
return true;
}
......
......@@ -52,7 +52,9 @@ public:
: q(qq),
process(0),
channelMode(QProcess::SeparateChannels),
finished(false)
finished(false),
startMode(Analyzer::StartLocal),
connParams(Utils::SshConnectionParameters::DefaultProxy)
{
}
......@@ -68,6 +70,8 @@ public:
QString debuggeeExecutable;
QString debuggeeArguments;
QString workingdir;
Analyzer::StartMode startMode;
Utils::SshConnectionParameters connParams;
};
void ValgrindRunner::Private::run(ValgrindProcess *_process)
......@@ -165,6 +169,26 @@ void ValgrindRunner::setDebuggeeArguments(const QString &arguments)
d->debuggeeArguments = arguments;
}
Analyzer::StartMode ValgrindRunner::startMode() const
{
return d->startMode;
}
void ValgrindRunner::setStartMode(Analyzer::StartMode startMode)
{
d->startMode = startMode;
}
const Utils::SshConnectionParameters &ValgrindRunner::connectionParameters() const
{
return d->connParams;
}
void ValgrindRunner::setConnectionParameters(const Utils::SshConnectionParameters &connParams)
{
d->connParams = connParams;
}
void ValgrindRunner::setWorkingDirectory(const QString &path)
{
d->workingdir = path;
......@@ -197,12 +221,10 @@ void ValgrindRunner::waitForFinished() const
void ValgrindRunner::start()
{
d->run(new LocalValgrindProcess(this));
}
void ValgrindRunner::startRemotely(const Utils::SshConnectionParameters &sshParams)
{
d->run(new RemoteValgrindProcess(sshParams, this));
if (d->startMode == Analyzer::StartLocal)
d->run(new LocalValgrindProcess(this));
else if (d->startMode == Analyzer::StartRemote)
d->run(new RemoteValgrindProcess(d->connParams, this));
}
void ValgrindRunner::processError(QProcess::ProcessError e)
......
......@@ -35,8 +35,12 @@
#ifndef VALGRIND_RUNNER_H
#define VALGRIND_RUNNER_H
#include <QtCore/QProcess>
#include "analyzerconstants.h"
#include <utils/outputformat.h>
#include <utils/ssh/sshconnection.h>
#include <QtCore/QProcess>
namespace Utils {
class Environment;
......@@ -69,13 +73,17 @@ public:
void setEnvironment(const Utils::Environment &environment);
void setProcessChannelMode(QProcess::ProcessChannelMode mode);
void setStartMode(Analyzer::StartMode startMode);
Analyzer::StartMode startMode() const;
void setConnectionParameters(const Utils::SshConnectionParameters &connParams);
const Utils::SshConnectionParameters &connectionParameters() const;
void waitForFinished() const;
QString errorString() const;
virtual void start();
virtual void startRemotely(const Utils::SshConnectionParameters &sshParams);
virtual void stop();
ValgrindProcess *valgrindProcess() const;
......
Supports Markdown
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