forked from qt-creator/qt-creator
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 <christian.stenger@qt.io>
This commit is contained in:
@@ -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,
|
||||
|
@@ -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;
|
||||
|
||||
|
@@ -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
|
||||
{
|
||||
theCallgrindTool = new CallgrindTool(parent);
|
||||
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()
|
||||
{
|
||||
theCallgrindRunControlFactory = new CallgrindRunControlFactory;
|
||||
ExtensionSystem::PluginManager::addObject(theCallgrindRunControlFactory);
|
||||
}
|
||||
|
||||
void destroyCallgrindTool()
|
||||
{
|
||||
delete theCallgrindTool;
|
||||
theCallgrindTool = 0;
|
||||
ExtensionSystem::PluginManager::addObject(theCallgrindRunControlFactory);
|
||||
delete theCallgrindRunControlFactory;
|
||||
theCallgrindRunControlFactory = 0;
|
||||
}
|
||||
|
||||
} // namespace Internal
|
||||
|
@@ -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
|
||||
|
@@ -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);
|
||||
|
@@ -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;
|
||||
|
@@ -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
|
||||
{
|
||||
theMemcheckTool = new MemcheckTool(parent);
|
||||
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()
|
||||
{
|
||||
theMemcheckRunControlFactory = new MemcheckRunControlFactory;
|
||||
ExtensionSystem::PluginManager::addObject(theMemcheckRunControlFactory);
|
||||
}
|
||||
|
||||
void destroyMemcheckTool()
|
||||
{
|
||||
delete theMemcheckTool;
|
||||
theMemcheckTool = 0;
|
||||
ExtensionSystem::PluginManager::addObject(theMemcheckRunControlFactory);
|
||||
delete theMemcheckRunControlFactory;
|
||||
theMemcheckRunControlFactory = 0;
|
||||
}
|
||||
|
||||
} // namespace Internal
|
||||
|
@@ -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
|
||||
|
@@ -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()
|
||||
|
@@ -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);
|
||||
}
|
||||
|
@@ -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
|
||||
|
Reference in New Issue
Block a user