forked from qt-creator/qt-creator
Valgrind: Add a ValgrindRunner member to the ValgrindToolRunner base
... instead of having one in each derived class. Change-Id: Icd121ce46b1d161bd2d59eaeaad8363528dc3c23 Reviewed-by: Christian Stenger <christian.stenger@qt.io>
This commit is contained in:
@@ -101,14 +101,9 @@ QString CallgrindToolRunner::progressTitle() const
|
|||||||
return tr("Profiling");
|
return tr("Profiling");
|
||||||
}
|
}
|
||||||
|
|
||||||
ValgrindRunner * CallgrindToolRunner::runner()
|
|
||||||
{
|
|
||||||
return &m_runner;
|
|
||||||
}
|
|
||||||
|
|
||||||
void CallgrindToolRunner::start()
|
void CallgrindToolRunner::start()
|
||||||
{
|
{
|
||||||
appendMessage(tr("Profiling %1").arg(executable()) + QLatin1Char('\n'), Utils::NormalMessageFormat);
|
appendMessage(tr("Profiling %1").arg(executable()), Utils::NormalMessageFormat);
|
||||||
return ValgrindToolRunner::start();
|
return ValgrindToolRunner::start();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -61,7 +61,6 @@ public:
|
|||||||
protected:
|
protected:
|
||||||
QStringList toolArguments() const override;
|
QStringList toolArguments() const override;
|
||||||
QString progressTitle() const override;
|
QString progressTitle() const override;
|
||||||
Valgrind::ValgrindRunner *runner() override;
|
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void parserDataReady(CallgrindToolRunner *engine);
|
void parserDataReady(CallgrindToolRunner *engine);
|
||||||
@@ -74,7 +73,6 @@ private:
|
|||||||
void localParseDataAvailable(const QString &file);
|
void localParseDataAvailable(const QString &file);
|
||||||
void controllerFinished(Callgrind::CallgrindController::Option option);
|
void controllerFinished(Callgrind::CallgrindController::Option option);
|
||||||
|
|
||||||
ValgrindRunner m_runner;
|
|
||||||
bool m_markAsPaused = false;
|
bool m_markAsPaused = false;
|
||||||
Callgrind::CallgrindController m_controller;
|
Callgrind::CallgrindController m_controller;
|
||||||
Callgrind::Parser m_parser;
|
Callgrind::Parser m_parser;
|
||||||
|
@@ -77,11 +77,6 @@ QString MemcheckToolRunner::progressTitle() const
|
|||||||
return tr("Analyzing Memory");
|
return tr("Analyzing Memory");
|
||||||
}
|
}
|
||||||
|
|
||||||
ValgrindRunner *MemcheckToolRunner::runner()
|
|
||||||
{
|
|
||||||
return &m_runner;
|
|
||||||
}
|
|
||||||
|
|
||||||
void MemcheckToolRunner::start()
|
void MemcheckToolRunner::start()
|
||||||
{
|
{
|
||||||
// MemcheckTool::engineStarting(this);
|
// MemcheckTool::engineStarting(this);
|
||||||
@@ -144,18 +139,18 @@ QStringList MemcheckToolRunner::suppressionFiles() const
|
|||||||
|
|
||||||
void MemcheckToolRunner::startDebugger()
|
void MemcheckToolRunner::startDebugger()
|
||||||
{
|
{
|
||||||
const qint64 valgrindPid = runner()->valgrindProcess()->pid();
|
const qint64 valgrindPid = m_runner.valgrindProcess()->pid();
|
||||||
|
|
||||||
Debugger::DebuggerStartParameters sp;
|
Debugger::DebuggerStartParameters sp;
|
||||||
sp.inferior = runControl()->runnable().as<StandardRunnable>();
|
sp.inferior = runnable().as<StandardRunnable>();
|
||||||
sp.startMode = Debugger::AttachToRemoteServer;
|
sp.startMode = Debugger::AttachToRemoteServer;
|
||||||
sp.displayName = QString::fromLatin1("VGdb %1").arg(valgrindPid);
|
sp.displayName = QString("VGdb %1").arg(valgrindPid);
|
||||||
sp.remoteChannel = QString::fromLatin1("| vgdb --pid=%1").arg(valgrindPid);
|
sp.remoteChannel = QString("| vgdb --pid=%1").arg(valgrindPid);
|
||||||
sp.useContinueInsteadOfRun = true;
|
sp.useContinueInsteadOfRun = true;
|
||||||
sp.expectedSignals.append("SIGTRAP");
|
sp.expectedSignals.append("SIGTRAP");
|
||||||
|
|
||||||
QString errorMessage;
|
QString errorMessage;
|
||||||
auto *gdbRunControl = new RunControl(nullptr, ProjectExplorer::Constants::DEBUG_RUN_MODE);
|
auto gdbRunControl = new RunControl(nullptr, ProjectExplorer::Constants::DEBUG_RUN_MODE);
|
||||||
(void) new Debugger::DebuggerRunTool(gdbRunControl, sp, &errorMessage);
|
(void) new Debugger::DebuggerRunTool(gdbRunControl, sp, &errorMessage);
|
||||||
connect(gdbRunControl, &RunControl::finished,
|
connect(gdbRunControl, &RunControl::finished,
|
||||||
gdbRunControl, &RunControl::deleteLater);
|
gdbRunControl, &RunControl::deleteLater);
|
||||||
|
@@ -55,12 +55,10 @@ signals:
|
|||||||
private:
|
private:
|
||||||
QString progressTitle() const override;
|
QString progressTitle() const override;
|
||||||
QStringList toolArguments() const override;
|
QStringList toolArguments() const override;
|
||||||
ValgrindRunner *runner() override;
|
|
||||||
|
|
||||||
void startDebugger();
|
void startDebugger();
|
||||||
void appendLog(const QByteArray &data);
|
void appendLog(const QByteArray &data);
|
||||||
|
|
||||||
ValgrindRunner m_runner;
|
|
||||||
const bool m_withGdb;
|
const bool m_withGdb;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@@ -40,7 +40,6 @@
|
|||||||
#include <projectexplorer/runconfiguration.h>
|
#include <projectexplorer/runconfiguration.h>
|
||||||
|
|
||||||
#include <QApplication>
|
#include <QApplication>
|
||||||
#include <QMainWindow>
|
|
||||||
|
|
||||||
#define VALGRIND_DEBUG_OUTPUT 0
|
#define VALGRIND_DEBUG_OUTPUT 0
|
||||||
|
|
||||||
@@ -82,21 +81,20 @@ void ValgrindToolRunner::start()
|
|||||||
emit outputReceived(tr("Command line arguments: %1").arg(runnable().debuggeeArgs), DebugFormat);
|
emit outputReceived(tr("Command line arguments: %1").arg(runnable().debuggeeArgs), DebugFormat);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
ValgrindRunner *run = runner();
|
m_runner.setValgrindExecutable(m_settings->valgrindExecutable());
|
||||||
run->setValgrindExecutable(m_settings->valgrindExecutable());
|
m_runner.setValgrindArguments(genericToolArguments() + toolArguments());
|
||||||
run->setValgrindArguments(genericToolArguments() + toolArguments());
|
m_runner.setDevice(device());
|
||||||
run->setDevice(device());
|
QTC_ASSERT(runnable().is<StandardRunnable>(), reportFailure());
|
||||||
if (runControl()->runnable().is<StandardRunnable>())
|
m_runner.setDebuggee(runnable().as<StandardRunnable>());
|
||||||
run->setDebuggee(runControl()->runnable().as<StandardRunnable>());
|
|
||||||
|
|
||||||
connect(run, &ValgrindRunner::processOutputReceived,
|
connect(&m_runner, &ValgrindRunner::processOutputReceived,
|
||||||
this, &ValgrindToolRunner::receiveProcessOutput);
|
this, &ValgrindToolRunner::receiveProcessOutput);
|
||||||
connect(run, &ValgrindRunner::processErrorReceived,
|
connect(&m_runner, &ValgrindRunner::processErrorReceived,
|
||||||
this, &ValgrindToolRunner::receiveProcessError);
|
this, &ValgrindToolRunner::receiveProcessError);
|
||||||
connect(run, &ValgrindRunner::finished,
|
connect(&m_runner, &ValgrindRunner::finished,
|
||||||
this, &ValgrindToolRunner::runnerFinished);
|
this, &ValgrindToolRunner::runnerFinished);
|
||||||
|
|
||||||
if (!run->start()) {
|
if (!m_runner.start()) {
|
||||||
m_progress.cancel();
|
m_progress.cancel();
|
||||||
reportFailure();
|
reportFailure();
|
||||||
return;
|
return;
|
||||||
@@ -108,14 +106,13 @@ void ValgrindToolRunner::start()
|
|||||||
void ValgrindToolRunner::stop()
|
void ValgrindToolRunner::stop()
|
||||||
{
|
{
|
||||||
m_isStopping = true;
|
m_isStopping = true;
|
||||||
runner()->stop();
|
m_runner.stop();
|
||||||
}
|
}
|
||||||
|
|
||||||
QString ValgrindToolRunner::executable() const
|
QString ValgrindToolRunner::executable() const
|
||||||
{
|
{
|
||||||
const Runnable &runnable = runControl()->runnable();
|
QTC_ASSERT(runnable().is<StandardRunnable>(), return QString());
|
||||||
return runnable.is<StandardRunnable>() ?
|
return runnable().as<StandardRunnable>().executable;
|
||||||
runnable.as<StandardRunnable>().executable : QString();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
QStringList ValgrindToolRunner::genericToolArguments() const
|
QStringList ValgrindToolRunner::genericToolArguments() const
|
||||||
@@ -137,7 +134,7 @@ QStringList ValgrindToolRunner::genericToolArguments() const
|
|||||||
smcCheckValue = QLatin1String("stack");
|
smcCheckValue = QLatin1String("stack");
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
return QStringList() << QLatin1String("--smc-check=") + smcCheckValue;
|
return {"--smc-check=" + smcCheckValue};
|
||||||
}
|
}
|
||||||
|
|
||||||
void ValgrindToolRunner::handleProgressCanceled()
|
void ValgrindToolRunner::handleProgressCanceled()
|
||||||
@@ -153,13 +150,13 @@ void ValgrindToolRunner::handleProgressFinished()
|
|||||||
|
|
||||||
void ValgrindToolRunner::runnerFinished()
|
void ValgrindToolRunner::runnerFinished()
|
||||||
{
|
{
|
||||||
appendMessage(tr("Analyzing finished.") + QLatin1Char('\n'), NormalMessageFormat);
|
appendMessage(tr("Analyzing finished."), NormalMessageFormat);
|
||||||
|
|
||||||
m_progress.reportFinished();
|
m_progress.reportFinished();
|
||||||
|
|
||||||
disconnect(runner(), &ValgrindRunner::processOutputReceived,
|
disconnect(&m_runner, &ValgrindRunner::processOutputReceived,
|
||||||
this, &ValgrindToolRunner::receiveProcessOutput);
|
this, &ValgrindToolRunner::receiveProcessOutput);
|
||||||
disconnect(runner(), &ValgrindRunner::finished,
|
disconnect(&m_runner, &ValgrindRunner::finished,
|
||||||
this, &ValgrindToolRunner::runnerFinished);
|
this, &ValgrindToolRunner::runnerFinished);
|
||||||
|
|
||||||
reportStopped();
|
reportStopped();
|
||||||
@@ -175,13 +172,13 @@ void ValgrindToolRunner::receiveProcessError(const QString &message, QProcess::P
|
|||||||
if (error == QProcess::FailedToStart) {
|
if (error == QProcess::FailedToStart) {
|
||||||
const QString valgrind = m_settings->valgrindExecutable();
|
const QString valgrind = m_settings->valgrindExecutable();
|
||||||
if (!valgrind.isEmpty())
|
if (!valgrind.isEmpty())
|
||||||
appendMessage(tr("Error: \"%1\" could not be started: %2").arg(valgrind, message) + QLatin1Char('\n'), ErrorMessageFormat);
|
appendMessage(tr("Error: \"%1\" could not be started: %2").arg(valgrind, message), ErrorMessageFormat);
|
||||||
else
|
else
|
||||||
appendMessage(tr("Error: no Valgrind executable set.") + QLatin1Char('\n'), ErrorMessageFormat);
|
appendMessage(tr("Error: no Valgrind executable set."), ErrorMessageFormat);
|
||||||
} else if (m_isStopping && error == QProcess::Crashed) { // process gets killed on stop
|
} else if (m_isStopping && error == QProcess::Crashed) { // process gets killed on stop
|
||||||
appendMessage(tr("Process terminated.") + QLatin1Char('\n'), ErrorMessageFormat);
|
appendMessage(tr("Process terminated."), ErrorMessageFormat);
|
||||||
} else {
|
} else {
|
||||||
appendMessage(QString::fromLatin1("** %1 **\n").arg(message), ErrorMessageFormat);
|
appendMessage(QString("** %1 **\n").arg(message), ErrorMessageFormat);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (m_isStopping)
|
if (m_isStopping)
|
||||||
|
@@ -55,10 +55,10 @@ signals:
|
|||||||
protected:
|
protected:
|
||||||
virtual QString progressTitle() const = 0;
|
virtual QString progressTitle() const = 0;
|
||||||
virtual QStringList toolArguments() const = 0;
|
virtual QStringList toolArguments() const = 0;
|
||||||
virtual Valgrind::ValgrindRunner *runner() = 0;
|
|
||||||
|
|
||||||
ValgrindBaseSettings *m_settings = 0;
|
ValgrindBaseSettings *m_settings = 0;
|
||||||
QFutureInterface<void> m_progress;
|
QFutureInterface<void> m_progress;
|
||||||
|
ValgrindRunner m_runner;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void handleProgressCanceled();
|
void handleProgressCanceled();
|
||||||
|
Reference in New Issue
Block a user