analyzer: refactoring of analyzer manager

Change-Id: I60268b8bc86e439beb3fca8f4b6a87ea03925bad
Reviewed-on: http://codereview.qt.nokia.com/1049
Reviewed-by: hjk <qthjk@ovi.com>
This commit is contained in:
hjk
2011-06-30 13:44:22 +02:00
committed by hjk
parent 343ac57943
commit 99d9f065b3
31 changed files with 461 additions and 512 deletions

View File

@@ -45,22 +45,24 @@ using namespace Analyzer;
using namespace Valgrind;
using namespace Valgrind::Internal;
CallgrindEngine::CallgrindEngine(const AnalyzerStartParameters &sp,
ProjectExplorer::RunConfiguration *runConfiguration)
: ValgrindEngine(sp, runConfiguration)
CallgrindEngine::CallgrindEngine(IAnalyzerTool *tool, const AnalyzerStartParameters &sp,
ProjectExplorer::RunConfiguration *runConfiguration)
: ValgrindEngine(tool, sp, runConfiguration)
, m_markAsPaused(false)
{
connect(&m_runner, SIGNAL(finished()), this, SLOT(slotFinished()));
connect(&m_runner, SIGNAL(started()), this, SLOT(slotStarted()));
connect(m_runner.parser(), SIGNAL(parserDataReady()), this, SLOT(slotFinished()));
connect(&m_runner, SIGNAL(statusMessage(QString)),
Analyzer::AnalyzerManager::instance(), SLOT(showStatusMessage(QString)));
connect(&m_runner, SIGNAL(statusMessage(QString)), SLOT(showStatusMessage(QString)));
m_progress->setProgressRange(0, 2);
}
void CallgrindEngine::showStatusMessage(const QString &msg)
{
AnalyzerManager::showStatusMessage(msg);
}
QStringList CallgrindEngine::toolArguments() const
{
QStringList arguments;

View File

@@ -46,8 +46,8 @@ class CallgrindEngine : public Valgrind::Internal::ValgrindEngine
Q_OBJECT
public:
explicit CallgrindEngine(const Analyzer::AnalyzerStartParameters &sp,
ProjectExplorer::RunConfiguration *runConfiguration);
CallgrindEngine(Analyzer::IAnalyzerTool *tool, const Analyzer::AnalyzerStartParameters &sp,
ProjectExplorer::RunConfiguration *runConfiguration);
void start();
@@ -79,15 +79,16 @@ protected:
signals:
void parserDataReady(CallgrindEngine *engine);
private slots:
void slotFinished();
void slotStarted();
void showStatusMessage(const QString &msg);
private:
Valgrind::Callgrind::CallgrindRunner m_runner;
bool m_markAsPaused;
QStringList m_extraArguments;
private slots:
void slotFinished();
void slotStarted();
};
} // namespace Internal

View File

@@ -175,6 +175,7 @@ public slots:
public:
CallgrindTool *q;
bool m_local;
DataModel *m_dataModel;
DataProxyModel *m_proxyModel;
StackBrowser *m_stackBrowser;
@@ -217,6 +218,7 @@ public:
CallgrindToolPrivate::CallgrindToolPrivate(CallgrindTool *parent)
: q(parent)
, m_local(true)
, m_dataModel(new DataModel(this))
, m_proxyModel(new DataProxyModel(this))
, m_stackBrowser(new StackBrowser(this))
@@ -497,10 +499,11 @@ static QToolButton *createToolButton(QAction *action)
return button;
}
CallgrindTool::CallgrindTool(QObject *parent)
CallgrindTool::CallgrindTool(bool local, QObject *parent)
: Analyzer::IAnalyzerTool(parent)
{
d = new CallgrindToolPrivate(this);
d->m_local = local;
Core::ICore *core = Core::ICore::instance();
// EditorManager
@@ -514,14 +517,21 @@ CallgrindTool::~CallgrindTool()
delete d;
}
QString CallgrindTool::id() const
QByteArray CallgrindTool::id() const
{
return "Callgrind";
return d->m_local ? "CallgrindLocal" : "CallgrindRemote";
}
QString CallgrindTool::displayName() const
{
return tr("Valgrind Function Profile");
return d->m_local ? tr("Valgrind Function Profile")
: tr("Valgrind Function Profile (Remote)");
}
QByteArray CallgrindTool::menuGroup() const
{
return d->m_local ? Analyzer::Constants::G_ANALYZER_TOOLS
: Analyzer::Constants::G_ANALYZER_REMOTE_TOOLS;
}
QString CallgrindTool::description() const
@@ -530,15 +540,19 @@ QString CallgrindTool::description() const
"record function calls when a program runs.");
}
void CallgrindTool::startTool()
{
if (d->m_local)
AnalyzerManager::startLocalTool(this);
else
AnalyzerManager::startRemoteTool(this);
}
IAnalyzerTool::ToolMode CallgrindTool::mode() const
{
return ReleaseMode;
}
void CallgrindTool::initialize()
{
}
void CallgrindTool::extensionsInitialized()
{
Core::ICore *core = Core::ICore::instance();
@@ -577,8 +591,7 @@ void CallgrindTool::initializeDockWidgets()
void CallgrindToolPrivate::initializeDockWidgets()
{
AnalyzerManager *am = AnalyzerManager::instance();
Utils::FancyMainWindow *mw = am->mainWindow();
Utils::FancyMainWindow *mw = AnalyzerManager::mainWindow();
m_visualisation = new Visualisation(mw);
m_visualisation->setFrameStyle(QFrame::NoFrame);
m_visualisation->setObjectName("Valgrind.CallgrindToolPrivate.Visualisation");
@@ -621,21 +634,17 @@ void CallgrindToolPrivate::initializeDockWidgets()
updateCostFormat();
QDockWidget *callersDock =
am->createDockWidget(q, tr("Callers"), m_callersView,
Qt::BottomDockWidgetArea);
QDockWidget *callersDock = AnalyzerManager::createDockWidget
(q, tr("Callers"), m_callersView, Qt::BottomDockWidgetArea);
QDockWidget *flatDock =
am->createDockWidget(q, tr("Functions"), m_flatView,
Qt::BottomDockWidgetArea);
QDockWidget *flatDock = AnalyzerManager::createDockWidget
(q, tr("Functions"), m_flatView, Qt::BottomDockWidgetArea);
QDockWidget *calleesDock =
am->createDockWidget(q, tr("Callees"), m_calleesView,
Qt::BottomDockWidgetArea);
QDockWidget *calleesDock = AnalyzerManager::createDockWidget
(q, tr("Callees"), m_calleesView, Qt::BottomDockWidgetArea);
QDockWidget *visualizationDock =
am->createDockWidget(q, tr("Visualization"), m_visualisation,
Qt::RightDockWidgetArea);
QDockWidget *visualizationDock = AnalyzerManager::createDockWidget
(q, tr("Visualization"), m_visualisation, Qt::RightDockWidgetArea);
visualizationDock->hide();
mw->splitDockWidget(mw->toolBarDockWidget(), calleesDock, Qt::Vertical);
@@ -653,7 +662,7 @@ IAnalyzerEngine *CallgrindTool::createEngine(const AnalyzerStartParameters &sp,
IAnalyzerEngine *CallgrindToolPrivate::createEngine(const AnalyzerStartParameters &sp,
ProjectExplorer::RunConfiguration *runConfiguration)
{
CallgrindEngine *engine = new CallgrindEngine(sp, runConfiguration);
CallgrindEngine *engine = new CallgrindEngine(q, sp, runConfiguration);
connect(engine, SIGNAL(parserDataReady(CallgrindEngine *)),
SLOT(takeParserData(CallgrindEngine *)));
@@ -673,7 +682,7 @@ IAnalyzerEngine *CallgrindToolPrivate::createEngine(const AnalyzerStartParameter
engine->setToggleCollectFunction(m_toggleCollectFunction);
m_toggleCollectFunction.clear();
AnalyzerManager::instance()->showStatusMessage(AnalyzerManager::msgToolStarted(q->displayName()));
AnalyzerManager::showStatusMessage(AnalyzerManager::msgToolStarted(q->displayName()));
// apply project settings
AnalyzerProjectSettings *analyzerSettings = runConfiguration->extraAspect<AnalyzerProjectSettings>();
@@ -862,7 +871,7 @@ void CallgrindToolPrivate::engineFinished()
if (data)
showParserResults(data);
else
AnalyzerManager::instance()->showStatusMessage(tr("Profiling aborted."));
AnalyzerManager::showStatusMessage(tr("Profiling aborted."));
}
void CallgrindToolPrivate::showParserResults(const ParseData *data)
@@ -879,7 +888,7 @@ void CallgrindToolPrivate::showParserResults(const ParseData *data)
} else {
msg = tr("Parsing failed.");
}
AnalyzerManager::instance()->showStatusMessage(msg);
AnalyzerManager::showStatusMessage(msg);
}
void CallgrindToolPrivate::editorOpened(Core::IEditor *editor)
@@ -938,8 +947,8 @@ void CallgrindToolPrivate::handleShowCostsOfFunction()
m_toggleCollectFunction = QString("%1()").arg(qualifiedFunctionName);
AnalyzerManager::instance()->selectTool(q);
AnalyzerManager::instance()->startTool(q);
AnalyzerManager::selectTool(q);
AnalyzerManager::startTool(q);
}
void CallgrindToolPrivate::slotRequestDump()
@@ -999,15 +1008,6 @@ void CallgrindToolPrivate::createTextMarks()
}
}
bool CallgrindTool::canRunLocally() const
{
#ifdef Q_OS_WINDOWS
return false;
#else
return true;
#endif
}
} // namespace Internal
} // namespace Valgrind

View File

@@ -45,15 +45,16 @@ class CallgrindTool : public Analyzer::IAnalyzerTool
Q_OBJECT
public:
explicit CallgrindTool(QObject *parent = 0);
CallgrindTool(bool local, QObject *parent);
~CallgrindTool();
QString id() const;
QByteArray id() const;
QString displayName() const;
QByteArray menuGroup() const;
QString description() const;
ToolMode mode() const;
void initialize();
void startTool();
void extensionsInitialized();
void initializeDockWidgets();
@@ -61,9 +62,6 @@ public:
ProjectExplorer::RunConfiguration *runConfiguration = 0);
QWidget *createControlWidget();
bool canRunRemotely() const { return true; }
bool canRunLocally() const;
private:
CallgrindToolPrivate *d;
};

View File

@@ -49,9 +49,9 @@ using namespace Valgrind::XmlProtocol;
namespace Valgrind {
namespace Internal {
MemcheckEngine::MemcheckEngine(const Analyzer::AnalyzerStartParameters &sp,
ProjectExplorer::RunConfiguration *runConfiguration)
: ValgrindEngine(sp, runConfiguration)
MemcheckEngine::MemcheckEngine(IAnalyzerTool *tool, const AnalyzerStartParameters &sp,
ProjectExplorer::RunConfiguration *runConfiguration)
: ValgrindEngine(tool, sp, runConfiguration)
{
connect(&m_parser, SIGNAL(error(Valgrind::XmlProtocol::Error)),
SIGNAL(parserError(Valgrind::XmlProtocol::Error)));

View File

@@ -46,9 +46,10 @@ namespace Internal {
class MemcheckEngine : public ValgrindEngine
{
Q_OBJECT
public:
explicit MemcheckEngine(const Analyzer::AnalyzerStartParameters &sp,
ProjectExplorer::RunConfiguration *runConfiguration);
MemcheckEngine(Analyzer::IAnalyzerTool *tool, const Analyzer::AnalyzerStartParameters &sp,
ProjectExplorer::RunConfiguration *runConfiguration);
void start();
void stop();

View File

@@ -184,9 +184,10 @@ static void initKindFilterAction(QAction *action, const QList<int> &kinds)
action->setData(data);
}
MemcheckTool::MemcheckTool(QObject *parent)
MemcheckTool::MemcheckTool(bool local, QObject *parent)
: Analyzer::IAnalyzerTool(parent)
{
m_local = local;
m_settings = 0;
m_errorModel = 0;
m_errorProxyModel = 0;
@@ -292,9 +293,15 @@ void MemcheckTool::maybeActiveRunConfigurationChanged()
m_errorProxyModel->setFilterExternalIssues(memcheckSettings->filterExternalIssues());
}
QString MemcheckTool::id() const
QByteArray MemcheckTool::id() const
{
return "Memcheck";
return m_local ? "MemcheckLocal" : "MemcheckGlobal";
}
QByteArray MemcheckTool::menuGroup() const
{
return m_local ? Analyzer::Constants::G_ANALYZER_TOOLS
: Analyzer::Constants::G_ANALYZER_REMOTE_TOOLS;
}
QString MemcheckTool::displayName() const
@@ -313,6 +320,14 @@ IAnalyzerTool::ToolMode MemcheckTool::mode() const
return DebugMode;
}
void MemcheckTool::startTool()
{
if (m_local)
AnalyzerManager::startLocalTool(this);
else
AnalyzerManager::startRemoteTool(this);
}
class FrameFinder : public ErrorListModel::RelevantFrameFinder
{
public:
@@ -369,8 +384,7 @@ void MemcheckTool::ensureWidgets()
if (m_errorView)
return;
AnalyzerManager *am = AnalyzerManager::instance();
Utils::FancyMainWindow *mw = am->mainWindow();
Utils::FancyMainWindow *mw = AnalyzerManager::mainWindow();
m_errorView = new MemcheckErrorView;
m_errorView->setObjectName(QLatin1String("MemcheckErrorView"));
@@ -390,9 +404,8 @@ void MemcheckTool::ensureWidgets()
m_errorView->setAutoScroll(false);
m_errorView->setObjectName("Valgrind.MemcheckTool.ErrorView");
QDockWidget *errorDock =
am->createDockWidget(this, tr("Memory Issues"), m_errorView,
Qt::BottomDockWidgetArea);
QDockWidget *errorDock = AnalyzerManager::createDockWidget
(this, tr("Memory Issues"), m_errorView, Qt::BottomDockWidgetArea);
mw->splitDockWidget(mw->toolBarDockWidget(), errorDock, Qt::Vertical);
connect(ProjectExplorer::ProjectExplorerPlugin::instance(),
@@ -457,9 +470,10 @@ QWidget *MemcheckTool::createControlWidget()
IAnalyzerEngine *MemcheckTool::createEngine(const AnalyzerStartParameters &sp,
ProjectExplorer::RunConfiguration *runConfiguration)
{
m_frameFinder->setFiles(runConfiguration ? runConfiguration->target()->project()->files(ProjectExplorer::Project::AllFiles) : QStringList());
m_frameFinder->setFiles(runConfiguration ? runConfiguration->target()
->project()->files(ProjectExplorer::Project::AllFiles) : QStringList());
MemcheckEngine *engine = new MemcheckEngine(sp, runConfiguration);
MemcheckEngine *engine = new MemcheckEngine(this, sp, runConfiguration);
connect(engine, SIGNAL(starting(const Analyzer::IAnalyzerEngine*)),
this, SLOT(engineStarting(const Analyzer::IAnalyzerEngine*)));
@@ -468,7 +482,7 @@ IAnalyzerEngine *MemcheckTool::createEngine(const AnalyzerStartParameters &sp,
connect(engine, SIGNAL(internalParserError(QString)),
this, SLOT(internalParserError(QString)));
connect(engine, SIGNAL(finished()), this, SLOT(finished()));
AnalyzerManager::instance()->showStatusMessage(AnalyzerManager::msgToolStarted(displayName()));
AnalyzerManager::showStatusMessage(AnalyzerManager::msgToolStarted(displayName()));
return engine;
}
@@ -556,21 +570,7 @@ void MemcheckTool::finished()
m_goBack->setEnabled(n > 0);
m_goNext->setEnabled(n > 0);
const QString msg = AnalyzerManager::msgToolFinished(displayName(), n);
AnalyzerManager::instance()->showStatusMessage(msg);
}
bool MemcheckTool::canRunRemotely() const
{
return true;
}
bool MemcheckTool::canRunLocally() const
{
#ifdef Q_OS_WINDOWS
return false;
#else
return true;
#endif
AnalyzerManager::showStatusMessage(msg);
}
} // namespace Internal

View File

@@ -91,12 +91,13 @@ class MemcheckTool : public Analyzer::IAnalyzerTool
Q_OBJECT
public:
explicit MemcheckTool(QObject *parent = 0);
MemcheckTool(bool local, QObject *parent);
QString id() const;
QByteArray id() const;
QString displayName() const;
QString description() const;
ToolMode mode() const;
QByteArray menuGroup() const;
void startTool();
private slots:
void settingsDestroyed(QObject *settings);
@@ -111,11 +112,9 @@ private slots:
void suppressionActionTriggered();
private:
ToolMode mode() const;
void ensureWidgets();
bool canRunRemotely() const;
bool canRunLocally() const;
void initializeDockWidgets();
void initialize() {}
void extensionsInitialized();
QWidget *createControlWidget();
@@ -124,6 +123,8 @@ private:
void clearErrorView();
private:
bool m_local;
Analyzer::AnalyzerSettings *m_settings;
QMenu *m_filterMenu;

View File

@@ -52,9 +52,9 @@ using namespace Analyzer;
using namespace Valgrind::Internal;
using namespace Utils;
ValgrindEngine::ValgrindEngine(const AnalyzerStartParameters &sp,
ProjectExplorer::RunConfiguration *runConfiguration)
: IAnalyzerEngine(sp, runConfiguration),
ValgrindEngine::ValgrindEngine(IAnalyzerTool *tool, const AnalyzerStartParameters &sp,
ProjectExplorer::RunConfiguration *runConfiguration)
: IAnalyzerEngine(tool, sp, runConfiguration),
m_settings(0),
m_progress(new QFutureInterface<void>()),
m_progressWatcher(new QFutureWatcher<void>()),
@@ -130,7 +130,7 @@ QString ValgrindEngine::executable() const
void ValgrindEngine::handleProgressCanceled()
{
AnalyzerManager::instance()->stopTool();
AnalyzerManager::stopTool(tool());
}
void ValgrindEngine::handleProgressFinished()

View File

@@ -37,7 +37,6 @@
#include "valgrind_global.h"
#include <analyzerbase/ianalyzerengine.h>
#include <analyzerbase/ianalyzerengine.h>
#include <utils/environment.h>
@@ -59,10 +58,12 @@ namespace Internal {
class VALGRINDTOOLBASE_EXPORT ValgrindEngine : public Analyzer::IAnalyzerEngine
{
Q_OBJECT
public:
explicit ValgrindEngine(const Analyzer::AnalyzerStartParameters &sp,
ProjectExplorer::RunConfiguration *runConfiguration);
virtual ~ValgrindEngine();
ValgrindEngine(Analyzer::IAnalyzerTool *tool,
const Analyzer::AnalyzerStartParameters &sp,
ProjectExplorer::RunConfiguration *runConfiguration);
~ValgrindEngine();
void start();
void stop();

View File

@@ -80,14 +80,16 @@ bool ValgrindPlugin::initialize(const QStringList &, QString *)
AnalyzerGlobalSettings::instance()->registerSubConfigs(&globalCallgrindFactory, &projectCallgrindFactory);
AnalyzerGlobalSettings::instance()->registerSubConfigs(&globalMemcheckFactory, &projectMemcheckFactory);
AnalyzerManager::instance()->addTool(new MemcheckTool(this));
AnalyzerManager::instance()->addTool(new CallgrindTool(this));
#ifndef Q_OS_WIN
AnalyzerManager::addTool(new MemcheckTool(true, this));
#endif
AnalyzerManager::addTool(new MemcheckTool(false, this));
#ifndef Q_OS_WIN
AnalyzerManager::addTool(new CallgrindTool(true, this));
#endif
AnalyzerManager::addTool(new CallgrindTool(false, this));
return true;
}
void ValgrindPlugin::extensionsInitialized()
{
}
Q_EXPORT_PLUGIN(Valgrind::Internal::ValgrindPlugin)

View File

@@ -48,7 +48,7 @@ public:
ValgrindPlugin() {}
virtual bool initialize(const QStringList &arguments, QString *errorString);
virtual void extensionsInitialized();
virtual void extensionsInitialized() {}
};
} // namespace Internal