forked from qt-creator/qt-creator
Valgrind: Dismantle LocalAddressFinder
Change-Id: I00ba9b82a6805d9f649247e79ca44795e799818b Reviewed-by: hjk <hjk@qt.io>
This commit is contained in:
@@ -111,50 +111,7 @@ private:
|
||||
void appendLog(const QByteArray &data);
|
||||
|
||||
const bool m_withGdb;
|
||||
QHostAddress m_localServerAddress;
|
||||
};
|
||||
|
||||
class LocalAddressFinder : public RunWorker
|
||||
{
|
||||
public:
|
||||
LocalAddressFinder(RunControl *runControl, QHostAddress *localServerAddress)
|
||||
: RunWorker(runControl), m_localServerAddress(localServerAddress) {}
|
||||
|
||||
void start() final
|
||||
{
|
||||
QTC_ASSERT(!m_process, return);
|
||||
m_process.reset(new Process);
|
||||
m_process->setCommand({device()->filePath("echo"), "-n $SSH_CLIENT", CommandLine::Raw});
|
||||
connect(m_process.get(), &Process::done, this, [this] {
|
||||
if (m_process->error() != QProcess::UnknownError) {
|
||||
reportFailure();
|
||||
return;
|
||||
}
|
||||
const QByteArrayList data = m_process->rawStdOut().split(' ');
|
||||
if (data.size() != 3) {
|
||||
reportFailure();
|
||||
return;
|
||||
}
|
||||
QHostAddress hostAddress;
|
||||
if (!hostAddress.setAddress(QString::fromLatin1(data.first()))) {
|
||||
reportFailure();
|
||||
return;
|
||||
}
|
||||
*m_localServerAddress = hostAddress;
|
||||
reportStarted();
|
||||
m_process.release()->deleteLater();
|
||||
});
|
||||
m_process->start();
|
||||
}
|
||||
|
||||
void stop() final
|
||||
{
|
||||
reportStopped();
|
||||
}
|
||||
|
||||
private:
|
||||
std::unique_ptr<Process> m_process = nullptr;
|
||||
QHostAddress *m_localServerAddress = nullptr;
|
||||
std::unique_ptr<Process> m_process;
|
||||
};
|
||||
|
||||
QString MemcheckToolRunner::progressTitle() const
|
||||
@@ -164,12 +121,35 @@ QString MemcheckToolRunner::progressTitle() const
|
||||
|
||||
void MemcheckToolRunner::start()
|
||||
{
|
||||
m_runner.setLocalServerAddress(m_localServerAddress);
|
||||
if (device()->type() != ProjectExplorer::Constants::DESKTOP_DEVICE_TYPE) {
|
||||
m_process.reset(new Process);
|
||||
m_process->setCommand({device()->filePath("echo"), "-n $SSH_CLIENT", CommandLine::Raw});
|
||||
connect(m_process.get(), &Process::done, this, [this] {
|
||||
const ProcessResult result = m_process->result();
|
||||
const QByteArrayList data = m_process->rawStdOut().split(' ');
|
||||
m_process.release()->deleteLater();
|
||||
if (result != ProcessResult::FinishedWithSuccess || data.size() != 3) {
|
||||
reportFailure();
|
||||
return;
|
||||
}
|
||||
QHostAddress hostAddress;
|
||||
if (!hostAddress.setAddress(QString::fromLatin1(data.first()))) {
|
||||
reportFailure();
|
||||
return;
|
||||
}
|
||||
m_runner.setLocalServerAddress(hostAddress);
|
||||
ValgrindToolRunner::start();
|
||||
});
|
||||
m_process->start();
|
||||
return;
|
||||
}
|
||||
m_runner.setLocalServerAddress(QHostAddress::LocalHost);
|
||||
ValgrindToolRunner::start();
|
||||
}
|
||||
|
||||
void MemcheckToolRunner::stop()
|
||||
{
|
||||
m_process.reset();
|
||||
disconnect(&m_runner, &ValgrindProcess::internalError,
|
||||
this, &MemcheckToolRunner::internalParserError);
|
||||
ValgrindToolRunner::stop();
|
||||
@@ -1135,9 +1115,8 @@ void MemcheckTool::setBusyCursor(bool busy)
|
||||
}
|
||||
|
||||
MemcheckToolRunner::MemcheckToolRunner(RunControl *runControl)
|
||||
: ValgrindToolRunner(runControl),
|
||||
m_withGdb(runControl->runMode() == MEMCHECK_WITH_GDB_RUN_MODE),
|
||||
m_localServerAddress(QHostAddress::LocalHost)
|
||||
: ValgrindToolRunner(runControl)
|
||||
, m_withGdb(runControl->runMode() == MEMCHECK_WITH_GDB_RUN_MODE)
|
||||
{
|
||||
setId("MemcheckToolRunner");
|
||||
connect(&m_runner, &ValgrindProcess::error, this, &MemcheckToolRunner::parserError);
|
||||
@@ -1152,13 +1131,6 @@ MemcheckToolRunner::MemcheckToolRunner(RunControl *runControl)
|
||||
this, &MemcheckToolRunner::internalParserError);
|
||||
}
|
||||
|
||||
// We need a real address to connect to from the outside.
|
||||
if (device()->type() != ProjectExplorer::Constants::DESKTOP_DEVICE_TYPE) {
|
||||
auto *dependentWorker = new LocalAddressFinder(runControl, &m_localServerAddress);
|
||||
addStartDependency(dependentWorker);
|
||||
addStopDependency(dependentWorker);
|
||||
}
|
||||
|
||||
dd->setupRunner(this);
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user