summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorhjk <hjk@qt.io>2017-04-27 17:23:28 +0200
committerhjk <hjk@qt.io>2017-05-02 07:46:29 +0000
commitd8bacfe9af1082ce6a12ec418be430b5bee65efa (patch)
tree3b3f78e0f1f8e2d9816393b4f3bdb4e8c15a3c28 /src
parent6e990f96c66b40fcf73db65a857f20f8a1dc4389 (diff)
downloadqt-creator-d8bacfe9af1082ce6a12ec418be430b5bee65efa.tar.gz
Valgrind: Move to new target/tool split for local setups
Change-Id: I1167fdc147600c36149c13731d0680b858acf4fb Reviewed-by: Christian Stenger <christian.stenger@qt.io>
Diffstat (limited to 'src')
-rw-r--r--src/plugins/projectexplorer/runconfiguration.cpp29
-rw-r--r--src/plugins/valgrind/callgrindengine.cpp35
-rw-r--r--src/plugins/valgrind/callgrindengine.h8
-rw-r--r--src/plugins/valgrind/callgrindtool.cpp62
-rw-r--r--src/plugins/valgrind/memcheckengine.cpp50
-rw-r--r--src/plugins/valgrind/memcheckengine.h10
-rw-r--r--src/plugins/valgrind/memchecktool.cpp30
-rw-r--r--src/plugins/valgrind/valgrindengine.cpp60
-rw-r--r--src/plugins/valgrind/valgrindengine.h8
9 files changed, 141 insertions, 151 deletions
diff --git a/src/plugins/projectexplorer/runconfiguration.cpp b/src/plugins/projectexplorer/runconfiguration.cpp
index 1a84786615..5055c6f4ab 100644
--- a/src/plugins/projectexplorer/runconfiguration.cpp
+++ b/src/plugins/projectexplorer/runconfiguration.cpp
@@ -504,18 +504,6 @@ IRunConfigurationAspect *IRunControlFactory::createRunConfigurationAspect(RunCon
namespace Internal {
-ToolRunner *trivialToolRunner()
-{
- static ToolRunner runner(nullptr);
- return &runner;
-}
-
-TargetRunner *trivialTargetRunner()
-{
- static TargetRunner runner(nullptr);
- return &runner;
-}
-
class RunControlPrivate : public QObject
{
public:
@@ -535,10 +523,8 @@ public:
~RunControlPrivate()
{
QTC_CHECK(state == State::Stopped);
- if (targetRunner != trivialTargetRunner())
- delete targetRunner;
- if (toolRunner != trivialToolRunner())
- delete toolRunner;
+ delete targetRunner;
+ delete toolRunner;
delete outputFormatter;
}
@@ -607,6 +593,8 @@ using namespace Internal;
RunControl::RunControl(RunConfiguration *runConfiguration, Core::Id mode) :
d(new RunControlPrivate(this, runConfiguration, mode))
{
+ (void) new TargetRunner(this);
+ (void) new ToolRunner(this);
#ifdef WITH_JOURNALD
JournaldWatcher::instance()->subscribe(this, [this](const JournaldWatcher::LogEntry &entry) {
if (entry.value("_MACHINE_ID") != JournaldWatcher::instance()->machineId())
@@ -636,10 +624,6 @@ RunControl::~RunControl()
void RunControl::initiateStart()
{
- if (!d->targetRunner)
- setTargetRunner(trivialTargetRunner());
- if (!d->toolRunner)
- setToolRunner(trivialToolRunner());
emit aboutToStart();
start();
}
@@ -785,6 +769,7 @@ ToolRunner *RunControl::toolRunner() const
void RunControl::setToolRunner(ToolRunner *tool)
{
+ delete d->toolRunner;
d->toolRunner = tool;
connect(d->toolRunner, &ToolRunner::prepared, d, &RunControlPrivate::onToolPrepared);
connect(d->toolRunner, &ToolRunner::started, d, &RunControlPrivate::onToolStarted);
@@ -799,6 +784,7 @@ TargetRunner *RunControl::targetRunner() const
void RunControl::setTargetRunner(TargetRunner *runner)
{
+ delete d->targetRunner;
d->targetRunner = runner;
connect(d->targetRunner, &TargetRunner::prepared, d, &RunControlPrivate::onTargetPrepared);
connect(d->targetRunner, &TargetRunner::started, d, &RunControlPrivate::onTargetStarted);
@@ -1175,8 +1161,7 @@ void SimpleTargetRunner::onProcessFinished(int exitCode, QProcess::ExitStatus st
TargetRunner::TargetRunner(RunControl *runControl)
: m_runControl(runControl)
{
- if (runControl)
- runControl->setTargetRunner(this);
+ runControl->setTargetRunner(this);
}
RunControl *TargetRunner::runControl() const
diff --git a/src/plugins/valgrind/callgrindengine.cpp b/src/plugins/valgrind/callgrindengine.cpp
index 67b40b0d5a..9471740f86 100644
--- a/src/plugins/valgrind/callgrindengine.cpp
+++ b/src/plugins/valgrind/callgrindengine.cpp
@@ -39,19 +39,18 @@ using namespace Debugger;
using namespace Valgrind;
using namespace Valgrind::Internal;
-CallgrindRunControl::CallgrindRunControl(ProjectExplorer::RunConfiguration *runConfiguration, Core::Id runMode)
- : ValgrindRunControl(runConfiguration, runMode)
- , m_markAsPaused(false)
+CallgrindToolRunner::CallgrindToolRunner(ProjectExplorer::RunControl *runControl)
+ : ValgrindToolRunner(runControl)
{
connect(&m_runner, &Callgrind::CallgrindRunner::finished,
- this, &CallgrindRunControl::slotFinished);
+ this, &CallgrindToolRunner::slotFinished);
connect(m_runner.parser(), &Callgrind::Parser::parserDataReady,
- this, &CallgrindRunControl::slotFinished);
+ this, &CallgrindToolRunner::slotFinished);
connect(&m_runner, &Callgrind::CallgrindRunner::statusMessage,
this, &Debugger::showPermanentStatusMessage);
}
-QStringList CallgrindRunControl::toolArguments() const
+QStringList CallgrindToolRunner::toolArguments() const
{
QStringList arguments;
@@ -79,28 +78,28 @@ QStringList CallgrindRunControl::toolArguments() const
return arguments;
}
-QString CallgrindRunControl::progressTitle() const
+QString CallgrindToolRunner::progressTitle() const
{
return tr("Profiling");
}
-ValgrindRunner * CallgrindRunControl::runner()
+ValgrindRunner * CallgrindToolRunner::runner()
{
return &m_runner;
}
-void CallgrindRunControl::start()
+void CallgrindToolRunner::start()
{
appendMessage(tr("Profiling %1").arg(executable()) + QLatin1Char('\n'), Utils::NormalMessageFormat);
- return ValgrindRunControl::start();
+ return ValgrindToolRunner::start();
}
-void CallgrindRunControl::dump()
+void CallgrindToolRunner::dump()
{
m_runner.controller()->run(Callgrind::CallgrindController::Dump);
}
-void CallgrindRunControl::setPaused(bool paused)
+void CallgrindToolRunner::setPaused(bool paused)
{
if (m_markAsPaused == paused)
return;
@@ -116,7 +115,7 @@ void CallgrindRunControl::setPaused(bool paused)
}
}
-void CallgrindRunControl::setToggleCollectFunction(const QString &toggleCollectFunction)
+void CallgrindToolRunner::setToggleCollectFunction(const QString &toggleCollectFunction)
{
if (toggleCollectFunction.isEmpty())
return;
@@ -124,27 +123,27 @@ void CallgrindRunControl::setToggleCollectFunction(const QString &toggleCollectF
m_argumentForToggleCollect = QLatin1String("--toggle-collect=") + toggleCollectFunction;
}
-void CallgrindRunControl::reset()
+void CallgrindToolRunner::reset()
{
m_runner.controller()->run(Callgrind::CallgrindController::ResetEventCounters);
}
-void CallgrindRunControl::pause()
+void CallgrindToolRunner::pause()
{
m_runner.controller()->run(Callgrind::CallgrindController::Pause);
}
-void CallgrindRunControl::unpause()
+void CallgrindToolRunner::unpause()
{
m_runner.controller()->run(Callgrind::CallgrindController::UnPause);
}
-Callgrind::ParseData *CallgrindRunControl::takeParserData()
+Callgrind::ParseData *CallgrindToolRunner::takeParserData()
{
return m_runner.parser()->takeData();
}
-void CallgrindRunControl::slotFinished()
+void CallgrindToolRunner::slotFinished()
{
emit parserDataReady(this);
}
diff --git a/src/plugins/valgrind/callgrindengine.h b/src/plugins/valgrind/callgrindengine.h
index 352c7bf305..1e251f7136 100644
--- a/src/plugins/valgrind/callgrindengine.h
+++ b/src/plugins/valgrind/callgrindengine.h
@@ -33,12 +33,12 @@
namespace Valgrind {
namespace Internal {
-class CallgrindRunControl : public ValgrindRunControl
+class CallgrindToolRunner : public ValgrindToolRunner
{
Q_OBJECT
public:
- CallgrindRunControl(ProjectExplorer::RunConfiguration *runConfiguration, Core::Id runMode);
+ explicit CallgrindToolRunner(ProjectExplorer::RunControl *runControl);
void start() override;
@@ -62,13 +62,13 @@ protected:
Valgrind::ValgrindRunner *runner() override;
signals:
- void parserDataReady(CallgrindRunControl *engine);
+ void parserDataReady(CallgrindToolRunner *engine);
private:
void slotFinished();
Valgrind::Callgrind::CallgrindRunner m_runner;
- bool m_markAsPaused;
+ bool m_markAsPaused = false;
QString m_argumentForToggleCollect;
};
diff --git a/src/plugins/valgrind/callgrindtool.cpp b/src/plugins/valgrind/callgrindtool.cpp
index 30581c201f..01aac21877 100644
--- a/src/plugins/valgrind/callgrindtool.cpp
+++ b/src/plugins/valgrind/callgrindtool.cpp
@@ -122,7 +122,7 @@ public:
CallgrindTool(QObject *parent);
~CallgrindTool();
- ValgrindRunControl *createRunControl(RunConfiguration *runConfiguration, Id runMode);
+ ValgrindToolRunner *createRunTool(RunControl *runControl);
void setParseData(ParseData *data);
CostDelegate::CostFormat costFormat() const;
@@ -171,7 +171,7 @@ public:
void visualisationFunctionSelected(const Function *function);
void showParserResults(const ParseData *data);
- void takeParserDataFromRunControl(CallgrindRunControl *rc);
+ void takeParserDataFromRunControl(CallgrindToolRunner *rc);
void takeParserData(ParseData *data);
void engineStarting();
void engineFinished();
@@ -256,7 +256,9 @@ CallgrindTool::CallgrindTool(QObject *parent)
"Callgrind tool to record function calls when a program runs.");
auto rcc = [this](RunConfiguration *runConfiguration, Id mode) {
- return createRunControl(runConfiguration, mode);
+ auto runControl = new RunControl(runConfiguration, mode);
+ (void) createRunTool(runControl);
+ return runControl;
};
if (!Utils::HostOsInfo::isWindowsHost()) {
@@ -292,15 +294,15 @@ CallgrindTool::CallgrindTool(QObject *parent)
if (dlg.exec() != QDialog::Accepted)
return;
Debugger::selectPerspective(CallgrindPerspectiveId);
- ValgrindRunControl *rc = createRunControl(runConfig, CALLGRIND_RUN_MODE);
- QTC_ASSERT(rc, return);
+ auto runControl = new RunControl(runConfig, CALLGRIND_RUN_MODE);
const auto runnable = dlg.runnable();
- rc->setRunnable(runnable);
+ runControl->setRunnable(runnable);
AnalyzerConnection connection;
connection.connParams = dlg.sshParams();
- rc->setConnection(connection);
- rc->setDisplayName(runnable.executable);
- ProjectExplorerPlugin::startRunControl(rc);
+ runControl->setConnection(connection);
+ runControl->setDisplayName(runnable.executable);
+ createRunTool(runControl);
+ ProjectExplorerPlugin::startRunControl(runControl);
});
// If there is a CppEditor context menu add our own context menu actions.
@@ -760,44 +762,42 @@ void CallgrindTool::updateEventCombo()
m_eventCombo->addItem(ParseData::prettyStringForEvent(event));
}
-ValgrindRunControl *CallgrindTool::createRunControl(RunConfiguration *runConfiguration, Id runMode)
+ValgrindToolRunner *CallgrindTool::createRunTool(RunControl *runControl)
{
- auto runControl = new CallgrindRunControl(runConfiguration, runMode);
+ auto toolRunner = new CallgrindToolRunner(runControl);
- connect(runControl, &CallgrindRunControl::parserDataReady, this, &CallgrindTool::takeParserDataFromRunControl);
- connect(runControl, &RunControl::starting, this, &CallgrindTool::engineStarting);
+ connect(toolRunner, &CallgrindToolRunner::parserDataReady, this, &CallgrindTool::takeParserDataFromRunControl);
+ connect(toolRunner, &CallgrindToolRunner::starting, this, &CallgrindTool::engineStarting);
connect(runControl, &RunControl::finished, this, &CallgrindTool::engineFinished);
- connect(this, &CallgrindTool::dumpRequested, runControl, &CallgrindRunControl::dump);
- connect(this, &CallgrindTool::resetRequested, runControl, &CallgrindRunControl::reset);
- connect(this, &CallgrindTool::pauseToggled, runControl, &CallgrindRunControl::setPaused);
+ connect(this, &CallgrindTool::dumpRequested, toolRunner, &CallgrindToolRunner::dump);
+ connect(this, &CallgrindTool::resetRequested, toolRunner, &CallgrindToolRunner::reset);
+ connect(this, &CallgrindTool::pauseToggled, toolRunner, &CallgrindToolRunner::setPaused);
- connect(m_stopAction, &QAction::triggered, runControl, [runControl] { runControl->stop(); });
+ connect(m_stopAction, &QAction::triggered, toolRunner, [toolRunner] { toolRunner->stop(); });
// initialize run control
- runControl->setPaused(m_pauseAction->isChecked());
+ toolRunner->setPaused(m_pauseAction->isChecked());
// we may want to toggle collect for one function only in this run
- runControl->setToggleCollectFunction(m_toggleCollectFunction);
+ toolRunner->setToggleCollectFunction(m_toggleCollectFunction);
m_toggleCollectFunction.clear();
- QTC_ASSERT(m_visualization, return runControl);
+ QTC_ASSERT(m_visualization, return toolRunner);
// apply project settings
- if (runConfiguration) {
- if (IRunConfigurationAspect *analyzerAspect = runConfiguration->extraAspect(ANALYZER_VALGRIND_SETTINGS)) {
- if (const ValgrindBaseSettings *settings = qobject_cast<ValgrindBaseSettings *>(analyzerAspect->currentSettings())) {
- m_visualization->setMinimumInclusiveCostRatio(settings->visualisationMinimumInclusiveCostRatio() / 100.0);
- m_proxyModel.setMinimumInclusiveCostRatio(settings->minimumInclusiveCostRatio() / 100.0);
- m_dataModel.setVerboseToolTipsEnabled(settings->enableEventToolTips());
- }
+ if (IRunConfigurationAspect *analyzerAspect = runControl->runConfiguration()->extraAspect(ANALYZER_VALGRIND_SETTINGS)) {
+ if (const ValgrindBaseSettings *settings = qobject_cast<ValgrindBaseSettings *>(analyzerAspect->currentSettings())) {
+ m_visualization->setMinimumInclusiveCostRatio(settings->visualisationMinimumInclusiveCostRatio() / 100.0);
+ m_proxyModel.setMinimumInclusiveCostRatio(settings->minimumInclusiveCostRatio() / 100.0);
+ m_dataModel.setVerboseToolTipsEnabled(settings->enableEventToolTips());
}
}
m_toolBusy = true;
updateRunActions();
- return runControl;
+ return toolRunner;
}
void CallgrindTool::updateRunActions()
@@ -936,7 +936,7 @@ void CallgrindTool::loadExternalLogFile()
takeParserData(parser.takeData());
}
-void CallgrindTool::takeParserDataFromRunControl(CallgrindRunControl *rc)
+void CallgrindTool::takeParserDataFromRunControl(CallgrindToolRunner *rc)
{
takeParserData(rc->takeParserData());
}
@@ -1005,7 +1005,9 @@ public:
RunControl *create(RunConfiguration *runConfiguration, Core::Id runMode, QString *errorMessage) override
{
Q_UNUSED(errorMessage);
- return m_tool->createRunControl(runConfiguration, runMode);
+ auto runControl = new RunControl(runConfiguration, runMode);
+ m_tool->createRunTool(runControl);
+ return runControl;
}
IRunConfigurationAspect *createRunConfigurationAspect(ProjectExplorer::RunConfiguration *rc) override
diff --git a/src/plugins/valgrind/memcheckengine.cpp b/src/plugins/valgrind/memcheckengine.cpp
index 12bae14f67..0f629c51f5 100644
--- a/src/plugins/valgrind/memcheckengine.cpp
+++ b/src/plugins/valgrind/memcheckengine.cpp
@@ -51,44 +51,46 @@ using namespace Valgrind::XmlProtocol;
namespace Valgrind {
namespace Internal {
-MemcheckRunControl::MemcheckRunControl(RunConfiguration *runConfiguration, Core::Id runMode)
- : ValgrindRunControl(runConfiguration, runMode)
+MemcheckToolRunner::MemcheckToolRunner(RunControl *runControl)
+ : ValgrindToolRunner(runControl)
{
connect(&m_parser, &XmlProtocol::ThreadedParser::error,
- this, &MemcheckRunControl::parserError);
+ this, &MemcheckToolRunner::parserError);
connect(&m_parser, &XmlProtocol::ThreadedParser::suppressionCount,
- this, &MemcheckRunControl::suppressionCount);
+ this, &MemcheckToolRunner::suppressionCount);
connect(&m_parser, &XmlProtocol::ThreadedParser::internalError,
- this, &MemcheckRunControl::internalParserError);
+ this, &MemcheckToolRunner::internalParserError);
}
-QString MemcheckRunControl::progressTitle() const
+QString MemcheckToolRunner::progressTitle() const
{
return tr("Analyzing Memory");
}
-ValgrindRunner *MemcheckRunControl::runner()
+ValgrindRunner *MemcheckToolRunner::runner()
{
return &m_runner;
}
-void MemcheckRunControl::start()
+void MemcheckToolRunner::start()
{
+// MemcheckTool::engineStarting(this);
+
m_runner.setParser(&m_parser);
appendMessage(tr("Analyzing memory of %1").arg(executable()) + QLatin1Char('\n'),
Utils::NormalMessageFormat);
- ValgrindRunControl::start();
+ ValgrindToolRunner::start();
}
-void MemcheckRunControl::stop()
+void MemcheckToolRunner::stop()
{
disconnect(&m_parser, &ThreadedParser::internalError,
- this, &MemcheckRunControl::internalParserError);
- ValgrindRunControl::stop();
+ this, &MemcheckToolRunner::internalParserError);
+ ValgrindToolRunner::stop();
}
-QStringList MemcheckRunControl::toolArguments() const
+QStringList MemcheckToolRunner::toolArguments() const
{
QStringList arguments;
arguments << QLatin1String("--gen-suppressions=all");
@@ -123,35 +125,35 @@ QStringList MemcheckRunControl::toolArguments() const
return arguments;
}
-QStringList MemcheckRunControl::suppressionFiles() const
+QStringList MemcheckToolRunner::suppressionFiles() const
{
return m_settings->suppressionFiles();
}
-MemcheckWithGdbRunControl::MemcheckWithGdbRunControl(RunConfiguration *runConfiguration, Core::Id runMode)
- : MemcheckRunControl(runConfiguration, runMode)
+MemcheckWithGdbToolRunner::MemcheckWithGdbToolRunner(RunControl *runControl)
+ : MemcheckToolRunner(runControl)
{
connect(&m_runner, &Memcheck::MemcheckRunner::started,
- this, &MemcheckWithGdbRunControl::startDebugger);
+ this, &MemcheckWithGdbToolRunner::startDebugger);
connect(&m_runner, &Memcheck::MemcheckRunner::logMessageReceived,
- this, &MemcheckWithGdbRunControl::appendLog);
+ this, &MemcheckWithGdbToolRunner::appendLog);
disconnect(&m_parser, &ThreadedParser::internalError,
- this, &MemcheckRunControl::internalParserError);
+ this, &MemcheckToolRunner::internalParserError);
m_runner.disableXml();
}
-QStringList MemcheckWithGdbRunControl::toolArguments() const
+QStringList MemcheckWithGdbToolRunner::toolArguments() const
{
- return MemcheckRunControl::toolArguments()
+ return MemcheckToolRunner::toolArguments()
<< QLatin1String("--vgdb=yes") << QLatin1String("--vgdb-error=0");
}
-void MemcheckWithGdbRunControl::startDebugger()
+void MemcheckWithGdbToolRunner::startDebugger()
{
const qint64 valgrindPid = runner()->valgrindProcess()->pid();
Debugger::DebuggerStartParameters sp;
- sp.inferior = runnable().as<StandardRunnable>();
+ sp.inferior = runControl()->runnable().as<StandardRunnable>();
sp.startMode = Debugger::AttachToRemoteServer;
sp.displayName = QString::fromLatin1("VGdb %1").arg(valgrindPid);
sp.remoteChannel = QString::fromLatin1("| vgdb --pid=%1").arg(valgrindPid);
@@ -166,7 +168,7 @@ void MemcheckWithGdbRunControl::startDebugger()
gdbRunControl->initiateStart();
}
-void MemcheckWithGdbRunControl::appendLog(const QByteArray &data)
+void MemcheckWithGdbToolRunner::appendLog(const QByteArray &data)
{
appendMessage(QString::fromUtf8(data), Utils::StdOutFormat);
}
diff --git a/src/plugins/valgrind/memcheckengine.h b/src/plugins/valgrind/memcheckengine.h
index 9c011886c1..b585213282 100644
--- a/src/plugins/valgrind/memcheckengine.h
+++ b/src/plugins/valgrind/memcheckengine.h
@@ -34,13 +34,12 @@
namespace Valgrind {
namespace Internal {
-class MemcheckRunControl : public ValgrindRunControl
+class MemcheckToolRunner : public ValgrindToolRunner
{
Q_OBJECT
public:
- MemcheckRunControl(ProjectExplorer::RunConfiguration *runConfiguration,
- Core::Id runMode);
+ explicit MemcheckToolRunner(ProjectExplorer::RunControl *runControl);
void start() override;
void stop() override;
@@ -62,13 +61,12 @@ protected:
Memcheck::MemcheckRunner m_runner;
};
-class MemcheckWithGdbRunControl : public MemcheckRunControl
+class MemcheckWithGdbToolRunner : public MemcheckToolRunner
{
Q_OBJECT
public:
- MemcheckWithGdbRunControl(ProjectExplorer::RunConfiguration *runConfiguration,
- Core::Id runMode);
+ explicit MemcheckWithGdbToolRunner(ProjectExplorer::RunControl *runControl);
protected:
QStringList toolArguments() const override;
diff --git a/src/plugins/valgrind/memchecktool.cpp b/src/plugins/valgrind/memchecktool.cpp
index aab1a8c24e..4c8d421a6c 100644
--- a/src/plugins/valgrind/memchecktool.cpp
+++ b/src/plugins/valgrind/memchecktool.cpp
@@ -251,7 +251,7 @@ private:
void settingsDestroyed(QObject *settings);
void maybeActiveRunConfigurationChanged();
- void engineStarting(const MemcheckRunControl *engine);
+ void engineStarting(const MemcheckToolRunner *engine);
void engineFinished();
void loadingExternalXmlLogFileFinished();
@@ -565,18 +565,20 @@ RunControl *MemcheckTool::createRunControl(RunConfiguration *runConfiguration, C
m_errorModel.setRelevantFrameFinder(makeFrameFinder(runConfiguration
? runConfiguration->target()->project()->files(Project::AllFiles) : QStringList()));
- MemcheckRunControl *runControl = 0;
+ auto runControl = new RunControl(runConfiguration, runMode);
+ MemcheckToolRunner *runTool = 0;
if (runMode == MEMCHECK_RUN_MODE)
- runControl = new MemcheckRunControl(runConfiguration, runMode);
+ runTool = new MemcheckToolRunner(runControl);
else
- runControl = new MemcheckWithGdbRunControl(runConfiguration, runMode);
- connect(runControl, &MemcheckRunControl::starting,
- this, [this, runControl]() { engineStarting(runControl); });
- connect(runControl, &MemcheckRunControl::parserError, this, &MemcheckTool::parserError);
- connect(runControl, &MemcheckRunControl::internalParserError, this, &MemcheckTool::internalParserError);
- connect(runControl, &MemcheckRunControl::finished, this, &MemcheckTool::engineFinished);
+ runTool = new MemcheckWithGdbToolRunner(runControl);
- connect(m_stopAction, &QAction::triggered, runControl, [runControl] { runControl->stop(); });
+ connect(runTool, &MemcheckToolRunner::starting,
+ this, [this, runTool] { engineStarting(runTool); });
+ connect(runTool, &MemcheckToolRunner::parserError, this, &MemcheckTool::parserError);
+ connect(runTool, &MemcheckToolRunner::internalParserError, this, &MemcheckTool::internalParserError);
+ connect(runControl, &RunControl::finished, this, &MemcheckTool::engineFinished);
+
+ connect(m_stopAction, &QAction::triggered, runControl, &RunControl::stop);
m_toolBusy = true;
updateRunActions();
@@ -584,21 +586,21 @@ RunControl *MemcheckTool::createRunControl(RunConfiguration *runConfiguration, C
return runControl;
}
-void MemcheckTool::engineStarting(const MemcheckRunControl *runControl)
+void MemcheckTool::engineStarting(const MemcheckToolRunner *runTool)
{
setBusyCursor(true);
clearErrorView();
m_loadExternalLogFile->setDisabled(true);
QString dir;
- if (RunConfiguration *rc = runControl->runConfiguration())
+ if (RunConfiguration *rc = runTool->runControl()->runConfiguration())
dir = rc->target()->project()->projectDirectory().toString() + QLatin1Char('/');
- const QString name = Utils::FileName::fromString(runControl->executable()).fileName();
+ const QString name = Utils::FileName::fromString(runTool->executable()).fileName();
m_errorView->setDefaultSuppressionFile(dir + name + QLatin1String(".supp"));
- foreach (const QString &file, runControl->suppressionFiles()) {
+ foreach (const QString &file, runTool->suppressionFiles()) {
QAction *action = m_filterMenu->addAction(Utils::FileName::fromString(file).fileName());
action->setToolTip(file);
connect(action, &QAction::triggered, this, [this, file]() {
diff --git a/src/plugins/valgrind/valgrindengine.cpp b/src/plugins/valgrind/valgrindengine.cpp
index aab32c0f7d..090c02e6b5 100644
--- a/src/plugins/valgrind/valgrindengine.cpp
+++ b/src/plugins/valgrind/valgrindengine.cpp
@@ -53,30 +53,28 @@ using namespace ProjectExplorer;
namespace Valgrind {
namespace Internal {
-ValgrindRunControl::ValgrindRunControl(RunConfiguration *runConfiguration, Core::Id runMode)
- : RunControl(runConfiguration, runMode)
+ValgrindToolRunner::ValgrindToolRunner(RunControl *runControl)
+ : ToolRunner(runControl)
{
- setIcon(ProjectExplorer::Icons::ANALYZER_START_SMALL_TOOLBAR);
- setSupportsReRunning(false);
+ runControl->setIcon(ProjectExplorer::Icons::ANALYZER_START_SMALL_TOOLBAR);
+ runControl->setSupportsReRunning(false);
- if (runConfiguration)
- if (IRunConfigurationAspect *aspect = runConfiguration->extraAspect(ANALYZER_VALGRIND_SETTINGS))
- m_settings = qobject_cast<ValgrindBaseSettings *>(aspect->currentSettings());
+ if (IRunConfigurationAspect *aspect = runControl->runConfiguration()->extraAspect(ANALYZER_VALGRIND_SETTINGS))
+ m_settings = qobject_cast<ValgrindBaseSettings *>(aspect->currentSettings());
if (!m_settings)
m_settings = ValgrindPlugin::globalSettings();
}
-void ValgrindRunControl::start()
+void ValgrindToolRunner::start()
{
- reportApplicationStart();
emit starting();
FutureProgress *fp = ProgressManager::addTimedTask(m_progress, progressTitle(), "valgrind", 100);
fp->setKeepOnFinish(FutureProgress::HideOnFinish);
connect(fp, &FutureProgress::canceled,
- this, &ValgrindRunControl::handleProgressCanceled);
+ this, &ValgrindToolRunner::handleProgressCanceled);
connect(fp, &FutureProgress::finished,
- this, &ValgrindRunControl::handleProgressFinished);
+ this, &ValgrindToolRunner::handleProgressFinished);
m_progress.reportStarted();
#if VALGRIND_DEBUG_OUTPUT
@@ -88,36 +86,37 @@ void ValgrindRunControl::start()
ValgrindRunner *run = runner();
run->setValgrindExecutable(m_settings->valgrindExecutable());
run->setValgrindArguments(genericToolArguments() + toolArguments());
- const StandardRunnable r = runnable().as<StandardRunnable>();
- run->setDevice(r.device ? r.device : device());
- run->setDebuggee(r);
+ run->setDevice(device());
+ run->setDebuggee(runControl()->runnable().as<StandardRunnable>());
connect(run, &ValgrindRunner::processOutputReceived,
- this, &ValgrindRunControl::receiveProcessOutput);
+ this, &ValgrindToolRunner::receiveProcessOutput);
connect(run, &ValgrindRunner::processErrorReceived,
- this, &ValgrindRunControl::receiveProcessError);
+ this, &ValgrindToolRunner::receiveProcessError);
connect(run, &ValgrindRunner::finished,
- this, &ValgrindRunControl::runnerFinished);
+ this, &ValgrindToolRunner::runnerFinished);
if (!run->start()) {
m_progress.cancel();
- reportApplicationStop();
+ reportFailure();
return;
}
+
+ reportStarted();
}
-void ValgrindRunControl::stop()
+void ValgrindToolRunner::stop()
{
m_isStopping = true;
runner()->stop();
}
-QString ValgrindRunControl::executable() const
+QString ValgrindToolRunner::executable() const
{
- return runnable().as<StandardRunnable>().executable;
+ return runControl()->runnable().as<StandardRunnable>().executable;
}
-QStringList ValgrindRunControl::genericToolArguments() const
+QStringList ValgrindToolRunner::genericToolArguments() const
{
QTC_ASSERT(m_settings, return QStringList());
QString smcCheckValue;
@@ -139,36 +138,37 @@ QStringList ValgrindRunControl::genericToolArguments() const
return QStringList() << QLatin1String("--smc-check=") + smcCheckValue;
}
-void ValgrindRunControl::handleProgressCanceled()
+void ValgrindToolRunner::handleProgressCanceled()
{
m_progress.reportCanceled();
m_progress.reportFinished();
}
-void ValgrindRunControl::handleProgressFinished()
+void ValgrindToolRunner::handleProgressFinished()
{
QApplication::alert(ICore::mainWindow(), 3000);
}
-void ValgrindRunControl::runnerFinished()
+void ValgrindToolRunner::runnerFinished()
{
appendMessage(tr("Analyzing finished.") + QLatin1Char('\n'), NormalMessageFormat);
- reportApplicationStop();
m_progress.reportFinished();
disconnect(runner(), &ValgrindRunner::processOutputReceived,
- this, &ValgrindRunControl::receiveProcessOutput);
+ this, &ValgrindToolRunner::receiveProcessOutput);
disconnect(runner(), &ValgrindRunner::finished,
- this, &ValgrindRunControl::runnerFinished);
+ this, &ValgrindToolRunner::runnerFinished);
+
+ reportStopped();
}
-void ValgrindRunControl::receiveProcessOutput(const QString &output, OutputFormat format)
+void ValgrindToolRunner::receiveProcessOutput(const QString &output, OutputFormat format)
{
appendMessage(output, format);
}
-void ValgrindRunControl::receiveProcessError(const QString &message, QProcess::ProcessError error)
+void ValgrindToolRunner::receiveProcessError(const QString &message, QProcess::ProcessError error)
{
if (error == QProcess::FailedToStart) {
const QString valgrind = m_settings->valgrindExecutable();
diff --git a/src/plugins/valgrind/valgrindengine.h b/src/plugins/valgrind/valgrindengine.h
index 0ee39dcc37..874fdf284c 100644
--- a/src/plugins/valgrind/valgrindengine.h
+++ b/src/plugins/valgrind/valgrindengine.h
@@ -37,19 +37,21 @@
namespace Valgrind {
namespace Internal {
-class ValgrindRunControl : public ProjectExplorer::RunControl
+class ValgrindToolRunner : public ProjectExplorer::ToolRunner
{
Q_OBJECT
public:
- ValgrindRunControl(ProjectExplorer::RunConfiguration *runConfiguration,
- Core::Id runMode);
+ explicit ValgrindToolRunner(ProjectExplorer::RunControl *runControl);
void start() override;
void stop() override;
QString executable() const;
+signals:
+ void starting();
+
protected:
virtual QString progressTitle() const = 0;
virtual QStringList toolArguments() const = 0;