aboutsummaryrefslogtreecommitdiffstats
path: root/src/plugins
diff options
context:
space:
mode:
authorhjk <[email protected]>2016-03-07 17:33:58 +0100
committerhjk <[email protected]>2016-05-10 10:19:09 +0000
commitd02919d85070975f6313e96e618b9adb47d6012c (patch)
treef3e02dc3ea8d745783bebdea83f1766abbdb5258 /src/plugins
parent494f4a77423d2ed88aaa14a0e791e9fef60d8216 (diff)
Valgrind: Split MemCheck and CallGrind factories
The tools are separated everywhere, lumping them into the same RunControlFactory removes modularity artificially. Change-Id: I8d9e917bb114a1898a0c293f18d3bf78a52075aa Reviewed-by: Christian Stenger <[email protected]>
Diffstat (limited to 'src/plugins')
-rw-r--r--src/plugins/valgrind/callgrindengine.cpp4
-rw-r--r--src/plugins/valgrind/callgrindengine.h2
-rw-r--r--src/plugins/valgrind/callgrindtool.cpp68
-rw-r--r--src/plugins/valgrind/callgrindtool.h14
-rw-r--r--src/plugins/valgrind/memcheckengine.cpp4
-rw-r--r--src/plugins/valgrind/memcheckengine.h3
-rw-r--r--src/plugins/valgrind/memchecktool.cpp57
-rw-r--r--src/plugins/valgrind/memchecktool.h11
-rw-r--r--src/plugins/valgrind/valgrindplugin.cpp5
-rw-r--r--src/plugins/valgrind/valgrindruncontrolfactory.cpp19
-rw-r--r--src/plugins/valgrind/valgrindruncontrolfactory.h16
11 files changed, 117 insertions, 86 deletions
diff --git a/src/plugins/valgrind/callgrindengine.cpp b/src/plugins/valgrind/callgrindengine.cpp
index cc7e41ac0db..67b40b0d5a0 100644
--- a/src/plugins/valgrind/callgrindengine.cpp
+++ b/src/plugins/valgrind/callgrindengine.cpp
@@ -39,8 +39,8 @@ using namespace Debugger;
using namespace Valgrind;
using namespace Valgrind::Internal;
-CallgrindRunControl::CallgrindRunControl(ProjectExplorer::RunConfiguration *runConfiguration)
- : ValgrindRunControl(runConfiguration, CALLGRIND_RUN_MODE)
+CallgrindRunControl::CallgrindRunControl(ProjectExplorer::RunConfiguration *runConfiguration, Core::Id runMode)
+ : ValgrindRunControl(runConfiguration, runMode)
, m_markAsPaused(false)
{
connect(&m_runner, &Callgrind::CallgrindRunner::finished,
diff --git a/src/plugins/valgrind/callgrindengine.h b/src/plugins/valgrind/callgrindengine.h
index ae5696e157e..8e30b357cbb 100644
--- a/src/plugins/valgrind/callgrindengine.h
+++ b/src/plugins/valgrind/callgrindengine.h
@@ -38,7 +38,7 @@ class CallgrindRunControl : public ValgrindRunControl
Q_OBJECT
public:
- CallgrindRunControl(ProjectExplorer::RunConfiguration *runConfiguration);
+ CallgrindRunControl(ProjectExplorer::RunConfiguration *runConfiguration, Core::Id runMode);
void start() override;
diff --git a/src/plugins/valgrind/callgrindtool.cpp b/src/plugins/valgrind/callgrindtool.cpp
index 52aecc64d6a..c00673c83de 100644
--- a/src/plugins/valgrind/callgrindtool.cpp
+++ b/src/plugins/valgrind/callgrindtool.cpp
@@ -41,6 +41,7 @@
#include <valgrind/callgrind/callgrindproxymodel.h>
#include <valgrind/callgrind/callgrindstackbrowser.h>
#include <valgrind/valgrindplugin.h>
+#include <valgrind/valgrindruncontrolfactory.h>
#include <valgrind/valgrindsettings.h>
#include <debugger/debuggerconstants.h>
@@ -64,6 +65,8 @@
#include <cppeditor/cppeditorconstants.h>
+#include <extensionsystem/pluginmanager.h>
+
#include <texteditor/texteditor.h>
#include <texteditor/textdocument.h>
@@ -73,9 +76,14 @@
#include <projectexplorer/project.h>
#include <projectexplorer/projectexplorer.h>
+#include <projectexplorer/projectexplorericons.h>
#include <projectexplorer/projecttree.h>
#include <projectexplorer/session.h>
+#include <utils/fancymainwindow.h>
+#include <utils/qtcassert.h>
+#include <utils/styledbar.h>
+
#include <QAction>
#include <QActionGroup>
#include <QComboBox>
@@ -100,6 +108,16 @@ using namespace Utils;
namespace Valgrind {
namespace Internal {
+const char CallgrindPerspectiveId[] = "Callgrind.Perspective";
+const char CallgrindLocalActionId[] = "Callgrind.Local.Action";
+const char CallgrindRemoteActionId[] = "Callgrind.Remote.Action";
+const char CallgrindCallersDockId[] = "Callgrind.Callers.Dock";
+const char CallgrindCalleesDockId[] = "Callgrind.Callees.Dock";
+const char CallgrindFlatDockId[] = "Callgrind.Flat.Dock";
+const char CallgrindVisualizationDockId[] = "Callgrind.Visualization.Dock";
+
+const char CALLGRIND_RUN_MODE[] = "CallgrindTool.CallgrindRunMode";
+
class CallgrindTool : public QObject
{
Q_OBJECT
@@ -108,7 +126,7 @@ public:
CallgrindTool(QObject *parent);
~CallgrindTool();
- ValgrindRunControl *createRunControl(RunConfiguration *runConfiguration);
+ ValgrindRunControl *createRunControl(RunConfiguration *runConfiguration, Id runMode);
void setParseData(ParseData *data);
CostDelegate::CostFormat costFormat() const;
@@ -245,7 +263,7 @@ CallgrindTool::CallgrindTool(QObject *parent)
desc.setText(tr("Valgrind Function Profiler"));
desc.setPerspectiveId(CallgrindPerspectiveId);
desc.setRunControlCreator([this](RunConfiguration *runConfiguration, Id) {
- return createRunControl(runConfiguration);
+ return createRunControl(runConfiguration, CALLGRIND_RUN_MODE);
});
desc.setToolMode(OptimizedMode);
desc.setRunMode(CALLGRIND_RUN_MODE);
@@ -259,7 +277,7 @@ CallgrindTool::CallgrindTool(QObject *parent)
StartRemoteDialog dlg;
if (dlg.exec() != QDialog::Accepted)
return;
- ValgrindRunControl *rc = createRunControl(runConfig);
+ ValgrindRunControl *rc = createRunControl(runConfig, CALLGRIND_RUN_MODE);
QTC_ASSERT(rc, return);
const auto runnable = dlg.runnable();
rc->setRunnable(runnable);
@@ -729,9 +747,9 @@ void CallgrindTool::updateEventCombo()
m_eventCombo->addItem(ParseData::prettyStringForEvent(event));
}
-ValgrindRunControl *CallgrindTool::createRunControl(RunConfiguration *runConfiguration)
+ValgrindRunControl *CallgrindTool::createRunControl(RunConfiguration *runConfiguration, Id runMode)
{
- auto runControl = new CallgrindRunControl(runConfiguration);
+ auto runControl = new CallgrindRunControl(runConfiguration, runMode);
connect(runControl, &CallgrindRunControl::parserDataReady, this, &CallgrindTool::takeParserDataFromRunControl);
connect(runControl, &AnalyzerRunControl::starting, this, &CallgrindTool::engineStarting);
@@ -958,17 +976,47 @@ void CallgrindTool::createTextMarks()
}
}
-static CallgrindTool *theCallgrindTool;
-void initCallgrindTool(QObject *parent)
+class CallgrindRunControlFactory : public IRunControlFactory
+{
+public:
+ CallgrindRunControlFactory() : m_tool(new CallgrindTool(this)) {}
+
+ bool canRun(RunConfiguration *runConfiguration, Core::Id runMode) const override
+ {
+ Q_UNUSED(runConfiguration);
+ return runMode == CALLGRIND_RUN_MODE;
+ }
+
+ RunControl *create(RunConfiguration *runConfiguration, Core::Id runMode, QString *errorMessage) override
+ {
+ Q_UNUSED(errorMessage);
+ return m_tool->createRunControl(runConfiguration, runMode);
+ }
+
+ IRunConfigurationAspect *createRunConfigurationAspect(ProjectExplorer::RunConfiguration *rc) override
+ {
+ return createValgrindRunConfigurationAspect(rc);
+ }
+
+public:
+ CallgrindTool *m_tool;
+};
+
+
+static CallgrindRunControlFactory *theCallgrindRunControlFactory;
+
+void initCallgrindTool()
{
- theCallgrindTool = new CallgrindTool(parent);
+ theCallgrindRunControlFactory = new CallgrindRunControlFactory;
+ ExtensionSystem::PluginManager::addObject(theCallgrindRunControlFactory);
}
void destroyCallgrindTool()
{
- delete theCallgrindTool;
- theCallgrindTool = 0;
+ ExtensionSystem::PluginManager::addObject(theCallgrindRunControlFactory);
+ delete theCallgrindRunControlFactory;
+ theCallgrindRunControlFactory = 0;
}
} // namespace Internal
diff --git a/src/plugins/valgrind/callgrindtool.h b/src/plugins/valgrind/callgrindtool.h
index c0618366c73..79af72ad28f 100644
--- a/src/plugins/valgrind/callgrindtool.h
+++ b/src/plugins/valgrind/callgrindtool.h
@@ -25,22 +25,10 @@
#pragma once
-#include <QObject>
-
namespace Valgrind {
namespace Internal {
-const char CallgrindPerspectiveId[] = "Callgrind.Perspective";
-const char CallgrindLocalActionId[] = "Callgrind.Local.Action";
-const char CallgrindRemoteActionId[] = "Callgrind.Remote.Action";
-const char CallgrindCallersDockId[] = "Callgrind.Callers.Dock";
-const char CallgrindCalleesDockId[] = "Callgrind.Callees.Dock";
-const char CallgrindFlatDockId[] = "Callgrind.Flat.Dock";
-const char CallgrindVisualizationDockId[] = "Callgrind.Visualization.Dock";
-
-const char CALLGRIND_RUN_MODE[] = "CallgrindTool.CallgrindRunMode";
-
-void initCallgrindTool(QObject *parent);
+void initCallgrindTool();
void destroyCallgrindTool();
} // namespace Internal
diff --git a/src/plugins/valgrind/memcheckengine.cpp b/src/plugins/valgrind/memcheckengine.cpp
index 6d4a212c891..bd4fbfcdf3a 100644
--- a/src/plugins/valgrind/memcheckengine.cpp
+++ b/src/plugins/valgrind/memcheckengine.cpp
@@ -128,8 +128,8 @@ QStringList MemcheckRunControl::suppressionFiles() const
return m_settings->suppressionFiles();
}
-MemcheckWithGdbRunControl::MemcheckWithGdbRunControl(RunConfiguration *runConfiguration)
- : MemcheckRunControl(runConfiguration, MEMCHECK_WITH_GDB_RUN_MODE)
+MemcheckWithGdbRunControl::MemcheckWithGdbRunControl(RunConfiguration *runConfiguration, Core::Id runMode)
+ : MemcheckRunControl(runConfiguration, runMode)
{
connect(&m_runner, &Memcheck::MemcheckRunner::started,
this, &MemcheckWithGdbRunControl::startDebugger);
diff --git a/src/plugins/valgrind/memcheckengine.h b/src/plugins/valgrind/memcheckengine.h
index 6455065d351..4930c5fac70 100644
--- a/src/plugins/valgrind/memcheckengine.h
+++ b/src/plugins/valgrind/memcheckengine.h
@@ -67,7 +67,8 @@ class MemcheckWithGdbRunControl : public MemcheckRunControl
Q_OBJECT
public:
- MemcheckWithGdbRunControl(ProjectExplorer::RunConfiguration *runConfiguration);
+ MemcheckWithGdbRunControl(ProjectExplorer::RunConfiguration *runConfiguration,
+ Core::Id runMode);
protected:
QStringList toolArguments() const override;
diff --git a/src/plugins/valgrind/memchecktool.cpp b/src/plugins/valgrind/memchecktool.cpp
index 7d97c948ae0..7a8dead6f26 100644
--- a/src/plugins/valgrind/memchecktool.cpp
+++ b/src/plugins/valgrind/memchecktool.cpp
@@ -37,6 +37,7 @@
#include <debugger/analyzer/startremotedialog.h>
#include <valgrind/valgrindsettings.h>
+#include <valgrind/valgrindruncontrolfactory.h>
#include <valgrind/xmlprotocol/errorlistmodel.h>
#include <valgrind/xmlprotocol/stackmodel.h>
#include <valgrind/xmlprotocol/error.h>
@@ -94,6 +95,12 @@ using namespace std::placeholders;
namespace Valgrind {
namespace Internal {
+const char MEMCHECK_RUN_MODE[] = "MemcheckTool.MemcheckRunMode";
+const char MEMCHECK_WITH_GDB_RUN_MODE[] = "MemcheckTool.MemcheckWithGdbRunMode";
+
+const char MemcheckPerspectiveId[] = "Memcheck.Perspective";
+const char MemcheckErrorDockId[] = "Memcheck.Dock.Error";
+
static ErrorListModel::RelevantFrameFinder makeFrameFinder(const QStringList &projectFiles)
{
return [projectFiles](const Error &error) {
@@ -234,8 +241,7 @@ class MemcheckTool : public QObject
public:
MemcheckTool(QObject *parent);
- MemcheckRunControl *createRunControl(ProjectExplorer::RunConfiguration *runConfiguration,
- Core::Id runMode);
+ AnalyzerRunControl *createRunControl(RunConfiguration *runConfiguration, Core::Id runMode);
private:
void updateRunActions();
@@ -414,7 +420,7 @@ MemcheckTool::MemcheckTool(QObject *parent)
StartRemoteDialog dlg;
if (dlg.exec() != QDialog::Accepted)
return;
- ValgrindRunControl *rc = createRunControl(runConfig, MEMCHECK_RUN_MODE);
+ AnalyzerRunControl *rc = createRunControl(runConfig, MEMCHECK_RUN_MODE);
QTC_ASSERT(rc, return);
const auto runnable = dlg.runnable();
rc->setRunnable(runnable);
@@ -524,8 +530,7 @@ void MemcheckTool::maybeActiveRunConfigurationChanged()
updateFromSettings();
}
-MemcheckRunControl *MemcheckTool::createRunControl(RunConfiguration *runConfiguration,
- Core::Id runMode)
+AnalyzerRunControl *MemcheckTool::createRunControl(RunConfiguration *runConfiguration, Core::Id runMode)
{
m_errorModel.setRelevantFrameFinder(makeFrameFinder(runConfiguration
? runConfiguration->target()->project()->files(Project::AllFiles) : QStringList()));
@@ -534,7 +539,7 @@ MemcheckRunControl *MemcheckTool::createRunControl(RunConfiguration *runConfigur
if (runMode == MEMCHECK_RUN_MODE)
runControl = new MemcheckRunControl(runConfiguration, runMode);
else
- runControl = new MemcheckWithGdbRunControl(runConfiguration);
+ runControl = new MemcheckWithGdbRunControl(runConfiguration, runMode);
connect(runControl, &MemcheckRunControl::starting,
this, [this, runControl]() { engineStarting(runControl); });
connect(runControl, &MemcheckRunControl::parserError, this, &MemcheckTool::parserError);
@@ -685,17 +690,47 @@ void MemcheckTool::setBusyCursor(bool busy)
m_errorView->setCursor(cursor);
}
-static MemcheckTool *theMemcheckTool;
-void initMemcheckTool(QObject *parent)
+class MemcheckRunControlFactory : public IRunControlFactory
+{
+public:
+ MemcheckRunControlFactory() : m_tool(new MemcheckTool(this)) {}
+
+ bool canRun(RunConfiguration *runConfiguration, Core::Id mode) const override
+ {
+ Q_UNUSED(runConfiguration);
+ return mode == MEMCHECK_RUN_MODE || mode == MEMCHECK_WITH_GDB_RUN_MODE;
+ }
+
+ RunControl *create(RunConfiguration *runConfiguration, Core::Id mode, QString *errorMessage) override
+ {
+ Q_UNUSED(errorMessage);
+ return m_tool->createRunControl(runConfiguration, mode);
+ }
+
+ IRunConfigurationAspect *createRunConfigurationAspect(ProjectExplorer::RunConfiguration *rc) override
+ {
+ return createValgrindRunConfigurationAspect(rc);
+ }
+
+public:
+ MemcheckTool *m_tool;
+};
+
+
+static MemcheckRunControlFactory *theMemcheckRunControlFactory;
+
+void initMemcheckTool()
{
- theMemcheckTool = new MemcheckTool(parent);
+ theMemcheckRunControlFactory = new MemcheckRunControlFactory;
+ ExtensionSystem::PluginManager::addObject(theMemcheckRunControlFactory);
}
void destroyMemcheckTool()
{
- delete theMemcheckTool;
- theMemcheckTool = 0;
+ ExtensionSystem::PluginManager::addObject(theMemcheckRunControlFactory);
+ delete theMemcheckRunControlFactory;
+ theMemcheckRunControlFactory = 0;
}
} // namespace Internal
diff --git a/src/plugins/valgrind/memchecktool.h b/src/plugins/valgrind/memchecktool.h
index 8a6bdd95f3e..7fcef04d1e1 100644
--- a/src/plugins/valgrind/memchecktool.h
+++ b/src/plugins/valgrind/memchecktool.h
@@ -26,19 +26,10 @@
#pragma once
-#include <QObject>
-
namespace Valgrind {
-
-const char MEMCHECK_RUN_MODE[] = "MemcheckTool.MemcheckRunMode";
-const char MEMCHECK_WITH_GDB_RUN_MODE[] = "MemcheckTool.MemcheckWithGdbRunMode";
-
-const char MemcheckPerspectiveId[] = "Memcheck.Perspective";
-const char MemcheckErrorDockId[] = "Memcheck.Dock.Error";
-
namespace Internal {
-void initMemcheckTool(QObject *parent);
+void initMemcheckTool();
void destroyMemcheckTool();
} // namespace Internal
diff --git a/src/plugins/valgrind/valgrindplugin.cpp b/src/plugins/valgrind/valgrindplugin.cpp
index cec95ee127f..da2d9a191ba 100644
--- a/src/plugins/valgrind/valgrindplugin.cpp
+++ b/src/plugins/valgrind/valgrindplugin.cpp
@@ -95,15 +95,14 @@ bool ValgrindPlugin::initialize(const QStringList &, QString *)
theGlobalSettings->readSettings();
addAutoReleasedObject(new ValgrindOptionsPage);
- addAutoReleasedObject(new ValgrindRunControlFactory);
return true;
}
void ValgrindPlugin::extensionsInitialized()
{
- initMemcheckTool(this);
- initCallgrindTool(this);
+ initMemcheckTool();
+ initCallgrindTool();
}
ExtensionSystem::IPlugin::ShutdownFlag ValgrindPlugin::aboutToShutdown()
diff --git a/src/plugins/valgrind/valgrindruncontrolfactory.cpp b/src/plugins/valgrind/valgrindruncontrolfactory.cpp
index 55082c39e8d..4acd1da1d98 100644
--- a/src/plugins/valgrind/valgrindruncontrolfactory.cpp
+++ b/src/plugins/valgrind/valgrindruncontrolfactory.cpp
@@ -42,23 +42,6 @@ using namespace ProjectExplorer;
namespace Valgrind {
namespace Internal {
-ValgrindRunControlFactory::ValgrindRunControlFactory(QObject *parent) :
- IRunControlFactory(parent)
-{
-}
-
-bool ValgrindRunControlFactory::canRun(RunConfiguration *runConfiguration, Core::Id mode) const
-{
- Q_UNUSED(runConfiguration);
- return mode == CALLGRIND_RUN_MODE || mode == MEMCHECK_RUN_MODE || mode == MEMCHECK_WITH_GDB_RUN_MODE;
-}
-
-RunControl *ValgrindRunControlFactory::create(RunConfiguration *runConfiguration, Core::Id mode, QString *errorMessage)
-{
- Q_UNUSED(errorMessage);
- return Debugger::createAnalyzerRunControl(runConfiguration, mode);
-}
-
class ValgrindRunConfigurationAspect : public IRunConfigurationAspect
{
public:
@@ -80,7 +63,7 @@ public:
}
};
-IRunConfigurationAspect *ValgrindRunControlFactory::createRunConfigurationAspect(RunConfiguration *rc)
+IRunConfigurationAspect *createValgrindRunConfigurationAspect(RunConfiguration *rc)
{
return new ValgrindRunConfigurationAspect(rc);
}
diff --git a/src/plugins/valgrind/valgrindruncontrolfactory.h b/src/plugins/valgrind/valgrindruncontrolfactory.h
index b3e74646d1d..01099043b3e 100644
--- a/src/plugins/valgrind/valgrindruncontrolfactory.h
+++ b/src/plugins/valgrind/valgrindruncontrolfactory.h
@@ -30,21 +30,7 @@
namespace Valgrind {
namespace Internal {
-class ValgrindRunControlFactory : public ProjectExplorer::IRunControlFactory
-{
- Q_OBJECT
-public:
- typedef ProjectExplorer::RunConfiguration RunConfiguration;
-
- explicit ValgrindRunControlFactory(QObject *parent = 0);
-
- // IRunControlFactory implementation
- bool canRun(RunConfiguration *runConfiguration, Core::Id mode) const override;
-
- ProjectExplorer::RunControl *create(RunConfiguration *runConfiguration, Core::Id mode,
- QString *errorMessage) override;
- ProjectExplorer::IRunConfigurationAspect *createRunConfigurationAspect(ProjectExplorer::RunConfiguration *rc) override;
-};
+ProjectExplorer::IRunConfigurationAspect *createValgrindRunConfigurationAspect(ProjectExplorer::RunConfiguration *rc);
} // namespace Internal
} // namespace Valgrind