Analyzer: Merge IAnalyzerEngine and AnalyzerRunControl

Change-Id: I74edaef59600a44924d2692c1ebc7f98d8581115
Reviewed-by: Christiaan Janssen <christiaan.janssen@digia.com>
This commit is contained in:
hjk
2013-07-30 14:08:01 +02:00
parent 1fb755bb42
commit 3de45d8c55
35 changed files with 299 additions and 476 deletions

View File

@@ -7,7 +7,6 @@ QT += network
# AnalyzerBase files
SOURCES += \
ianalyzerengine.cpp \
ianalyzertool.cpp \
analyzerplugin.cpp \
analyzerruncontrol.cpp \
@@ -19,7 +18,6 @@ SOURCES += \
startremotedialog.cpp
HEADERS += \
ianalyzerengine.h \
ianalyzertool.h \
analyzerbase_global.h \
analyzerconstants.h \

View File

@@ -31,8 +31,6 @@ QtcPlugin {
"analyzerstartparameters.h",
"analyzerutils.cpp",
"analyzerutils.h",
"ianalyzerengine.cpp",
"ianalyzerengine.h",
"ianalyzertool.cpp",
"ianalyzertool.h",
"startremotedialog.cpp",

View File

@@ -29,14 +29,10 @@
****************************************************************************/
#include "analyzerruncontrol.h"
#include "ianalyzerengine.h"
#include "ianalyzertool.h"
#include "analyzermanager.h"
#include "analyzerstartparameters.h"
#include <projectexplorer/projectexplorer.h>
#include <projectexplorer/taskhub.h>
#include <QDebug>
#include <QAction>
@@ -44,117 +40,64 @@ using namespace ProjectExplorer;
//////////////////////////////////////////////////////////////////////////
//
// AnalyzerRunControl::Private
// AnalyzerRunControl
//
//////////////////////////////////////////////////////////////////////////
namespace Analyzer {
class AnalyzerRunControl::Private
AnalyzerRunControl::AnalyzerRunControl(const AnalyzerStartParameters &sp,
ProjectExplorer::RunConfiguration *runConfiguration)
: RunControl(runConfiguration, sp.runMode)
{
public:
Private();
bool m_isRunning;
IAnalyzerEngine *m_engine;
};
AnalyzerRunControl::Private::Private()
: m_isRunning(false), m_engine(0)
{}
//////////////////////////////////////////////////////////////////////////
//
// AnalyzerRunControl
//
//////////////////////////////////////////////////////////////////////////
AnalyzerRunControl::AnalyzerRunControl(IAnalyzerTool *tool,
const AnalyzerStartParameters &sp, RunConfiguration *runConfiguration)
: RunControl(runConfiguration, tool->runMode()),
d(new Private)
{
d->m_engine = tool->createEngine(sp, runConfiguration);
if (!d->m_engine)
return;
connect(d->m_engine, SIGNAL(outputReceived(QString,Utils::OutputFormat)),
SLOT(receiveOutput(QString,Utils::OutputFormat)));
connect(d->m_engine, SIGNAL(taskToBeAdded(ProjectExplorer::Task::TaskType,QString,QString,int)),
SLOT(addTask(ProjectExplorer::Task::TaskType,QString,QString,int)));
connect(d->m_engine, SIGNAL(finished()),
SLOT(engineFinished()));
m_runConfig = runConfiguration;
m_sp = sp;
connect(this, SIGNAL(finished()), SLOT(runControlFinished()));
connect(AnalyzerManager::stopAction(), SIGNAL(triggered()), SLOT(stopIt()));
}
AnalyzerRunControl::~AnalyzerRunControl()
{
if (d->m_isRunning)
stop();
delete d->m_engine;
d->m_engine = 0;
delete d;
}
void AnalyzerRunControl::start()
{
if (!d->m_engine) {
emit finished();
return;
}
AnalyzerManager::handleToolStarted();
// Clear about-to-be-outdated tasks.
ProjectExplorerPlugin::instance()->taskHub()
->clearTasks(Core::Id(Constants::ANALYZERTASK_ID));
if (d->m_engine->start()) {
d->m_isRunning = true;
emit started();
}
}
RunControl::StopResult AnalyzerRunControl::stop()
{
if (!d->m_engine || !d->m_isRunning)
return StoppedSynchronously;
d->m_engine->stop();
d->m_isRunning = false;
return AsynchronousStop;
}
void AnalyzerRunControl::stopIt()
{
if (stop() == RunControl::StoppedSynchronously)
AnalyzerManager::handleToolFinished();
}
void AnalyzerRunControl::engineFinished()
void AnalyzerRunControl::runControlFinished()
{
d->m_isRunning = false;
m_isRunning = false;
AnalyzerManager::handleToolFinished();
emit finished();
}
void AnalyzerRunControl::start()
{
AnalyzerManager::handleToolStarted();
if (startEngine()) {
m_isRunning = true;
emit started();
}
}
RunControl::StopResult AnalyzerRunControl::stop()
{
if (!m_isRunning)
return StoppedSynchronously;
stopEngine();
m_isRunning = false;
return AsynchronousStop;
}
bool AnalyzerRunControl::isRunning() const
{
return d->m_isRunning;
return m_isRunning;
}
QString AnalyzerRunControl::displayName() const
{
if (!d->m_engine)
return QString();
if (d->m_engine->runConfiguration())
return d->m_engine->runConfiguration()->displayName();
else
return d->m_engine->startParameters().displayName;
return m_runConfig ? m_runConfig->displayName() : m_sp.displayName;
}
QIcon AnalyzerRunControl::icon() const
@@ -162,23 +105,4 @@ QIcon AnalyzerRunControl::icon() const
return QIcon(QLatin1String(":/images/analyzer_start_small.png"));
}
IAnalyzerEngine *AnalyzerRunControl::engine() const
{
return d->m_engine;
}
void AnalyzerRunControl::receiveOutput(const QString &text, Utils::OutputFormat format)
{
appendMessage(text, format);
}
void AnalyzerRunControl::addTask(Task::TaskType type, const QString &description,
const QString &file, int line)
{
TaskHub *hub = ProjectExplorerPlugin::instance()->taskHub();
hub->addTask(Task(type, description, Utils::FileName::fromUserInput(file), line,
Core::Id(Constants::ANALYZERTASK_ID)));
hub->requestPopup();
}
} // namespace Analyzer

View File

@@ -36,20 +36,55 @@
#include <projectexplorer/runconfiguration.h>
#include <projectexplorer/task.h>
#include "analyzerbase_global.h"
#include "analyzerstartparameters.h"
#include <projectexplorer/task.h>
#include <projectexplorer/runconfiguration.h>
#include <utils/outputformat.h>
#include <QObject>
#include <QString>
namespace ProjectExplorer { class RunConfiguration; }
namespace Analyzer {
class AnalyzerStartParameters;
class IAnalyzerTool;
class IAnalyzerEngine;
/**
* An AnalyzerRunControl instance handles the launch of an analyzation tool.
*
* It gets created for each launch and deleted when the launch is stopped or ended.
*/
class ANALYZER_EXPORT AnalyzerRunControl : public ProjectExplorer::RunControl
{
Q_OBJECT
public:
AnalyzerRunControl(IAnalyzerTool *tool, const AnalyzerStartParameters &sp,
AnalyzerRunControl(const AnalyzerStartParameters &sp,
ProjectExplorer::RunConfiguration *runConfiguration);
~AnalyzerRunControl();
/// Start analyzation process.
virtual bool startEngine() = 0;
/// Trigger async stop of the analyzation process.
virtual void stopEngine() = 0;
/// Controller actions.
virtual bool canPause() const { return false; }
virtual void pause() {}
virtual void unpause() {}
/// The active run configuration for this engine, might be zero.
ProjectExplorer::RunConfiguration *runConfiguration() const { return m_runConfig; }
/// The start parameters for this engine.
const AnalyzerStartParameters &startParameters() const { return m_sp; }
StartMode mode() const { return m_sp.startMode; }
virtual void notifyRemoteSetupDone(quint16) {}
virtual void notifyRemoteFinished(bool) {}
bool m_isRunning;
// ProjectExplorer::RunControl
void start();
@@ -58,22 +93,21 @@ public:
QString displayName() const;
QIcon icon() const;
IAnalyzerEngine *engine() const;
public slots:
virtual void logApplicationMessage(const QString &, Utils::OutputFormat) {}
private slots:
void stopIt();
void receiveOutput(const QString &, Utils::OutputFormat format);
void runControlFinished();
void addTask(ProjectExplorer::Task::TaskType type, const QString &description,
const QString &file, int line);
void engineFinished();
signals:
/// Must be emitted when the engine is starting.
void starting(const Analyzer::AnalyzerRunControl *);
private:
class Private;
Private *d;
ProjectExplorer::RunConfiguration *m_runConfig;
AnalyzerStartParameters m_sp;
};
} // namespace Analyzer
#endif // ANALYZERRUNCONTROL_H

View File

@@ -38,6 +38,7 @@
#include <coreplugin/id.h>
#include <ssh/sshconnection.h>
#include <utils/environment.h>
#include <projectexplorer/projectexplorerconstants.h>
namespace Analyzer {
@@ -51,6 +52,7 @@ public:
{}
StartMode startMode;
ProjectExplorer::RunMode runMode;
QSsh::SshConnectionParameters connParams;
Core::Id toolId;

View File

@@ -1,42 +0,0 @@
/****************************************************************************
**
** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/legal
** Author: Nicolas Arnaud-Cormos, KDAB (nicolas.arnaud-cormos@kdab.com)
**
** This file is part of Qt Creator.
**
** Commercial License Usage
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
** a written agreement between you and Digia. For licensing terms and
** conditions see http://qt.digia.com/licensing. For further information
** use the contact form at http://qt.digia.com/contact-us.
**
** GNU Lesser General Public License Usage
** Alternatively, this file may be used under the terms of the GNU Lesser
** General Public License version 2.1 as published by the Free Software
** Foundation and appearing in the file LICENSE.LGPL included in the
** packaging of this file. Please review the following information to
** ensure the GNU Lesser General Public License version 2.1 requirements
** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
** In addition, as a special exception, Digia gives you certain additional
** rights. These rights are described in the Digia Qt LGPL Exception
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
****************************************************************************/
#include "ianalyzerengine.h"
namespace Analyzer {
IAnalyzerEngine::IAnalyzerEngine(const AnalyzerStartParameters &sp,
ProjectExplorer::RunConfiguration *runConfiguration)
{
m_runConfig = runConfiguration;
m_sp = sp;
}
} // namespace Analyzer

View File

@@ -1,105 +0,0 @@
/****************************************************************************
**
** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/legal
** Author: Nicolas Arnaud-Cormos, KDAB (nicolas.arnaud-cormos@kdab.com)
**
** This file is part of Qt Creator.
**
** Commercial License Usage
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
** a written agreement between you and Digia. For licensing terms and
** conditions see http://qt.digia.com/licensing. For further information
** use the contact form at http://qt.digia.com/contact-us.
**
** GNU Lesser General Public License Usage
** Alternatively, this file may be used under the terms of the GNU Lesser
** General Public License version 2.1 as published by the Free Software
** Foundation and appearing in the file LICENSE.LGPL included in the
** packaging of this file. Please review the following information to
** ensure the GNU Lesser General Public License version 2.1 requirements
** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
** In addition, as a special exception, Digia gives you certain additional
** rights. These rights are described in the Digia Qt LGPL Exception
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
****************************************************************************/
#ifndef IANALYZERENGINE_H
#define IANALYZERENGINE_H
#include "analyzerbase_global.h"
#include "analyzerstartparameters.h"
#include <projectexplorer/task.h>
#include <utils/outputformat.h>
#include <QObject>
#include <QString>
namespace ProjectExplorer {
class RunConfiguration;
}
namespace Analyzer {
/**
* An IAnalyzerEngine instance handles the launch of an analyzation tool.
*
* It gets created for each launch and deleted when the launch is stopped or ended.
*/
class ANALYZER_EXPORT IAnalyzerEngine : public QObject
{
Q_OBJECT
public:
IAnalyzerEngine(const AnalyzerStartParameters &sp,
ProjectExplorer::RunConfiguration *runConfiguration);
/// Start analyzation process.
virtual bool start() = 0;
/// Trigger async stop of the analyzation process.
virtual void stop() = 0;
/// Controller actions.
virtual bool canPause() const { return false; }
virtual void pause() {}
virtual void unpause() {}
/// The active run configuration for this engine, might be zero.
ProjectExplorer::RunConfiguration *runConfiguration() const { return m_runConfig; }
/// The start parameters for this engine.
const AnalyzerStartParameters &startParameters() const { return m_sp; }
StartMode mode() const { return m_sp.startMode; }
virtual void notifyRemoteSetupDone(quint16) {}
virtual void notifyRemoteFinished(bool) {}
public slots:
virtual void logApplicationMessage(const QString &, Utils::OutputFormat) {}
signals:
/// Should be emitted when the debuggee outputted something.
void outputReceived(const QString &, Utils::OutputFormat format);
/// Can be emitted when you want to show a task, e.g. to display an error.
void taskToBeAdded(ProjectExplorer::Task::TaskType type, const QString &description,
const QString &file, int line);
/// Must be emitted when the engine finished.
void finished();
/// Must be emitted when the engine is starting.
void starting(const Analyzer::IAnalyzerEngine *);
private:
ProjectExplorer::RunConfiguration *m_runConfig;
AnalyzerStartParameters m_sp;
};
} // namespace Analyzer
#endif // IANALYZERENGINE_H

View File

@@ -45,7 +45,7 @@ class RunConfiguration;
namespace Analyzer {
class IAnalyzerOutputPaneAdapter;
class IAnalyzerEngine;
class AnalyzerRunControl;
class AbstractAnalyzerSubConfig;
@@ -116,7 +116,7 @@ public:
/// Returns a new engine for the given start parameters.
/// Called each time the tool is launched.
virtual IAnalyzerEngine *createEngine(const AnalyzerStartParameters &sp,
virtual AnalyzerRunControl *createRunControl(const AnalyzerStartParameters &sp,
ProjectExplorer::RunConfiguration *runConfiguration = 0) = 0;
/// Returns true if the tool can be run

View File

@@ -33,7 +33,6 @@
#include "androidmanager.h"
#include <analyzerbase/ianalyzertool.h>
#include <analyzerbase/ianalyzerengine.h>
#include <analyzerbase/analyzermanager.h>
#include <analyzerbase/analyzerruncontrol.h>
#include <analyzerbase/analyzerstartparameters.h>
@@ -63,6 +62,7 @@ RunControl *AndroidAnalyzeSupport::createAnalyzeRunControl(AndroidRunConfigurati
AnalyzerStartParameters params;
params.toolId = tool->id();
params.runMode = runMode;
Target *target = runConfig->target();
params.displayName = AndroidManager::packageName(target);
params.sysroot = SysRootKitInformation::sysRoot(target->kit()).toString();
@@ -76,23 +76,21 @@ RunControl *AndroidAnalyzeSupport::createAnalyzeRunControl(AndroidRunConfigurati
params.startMode = StartQmlRemote;
}
AnalyzerRunControl * const analyzerRunControl = new AnalyzerRunControl(tool, params, runConfig);
new AndroidAnalyzeSupport(runConfig, analyzerRunControl);
AnalyzerRunControl *analyzerRunControl = tool->createRunControl(params, runConfig);
(void) new AndroidAnalyzeSupport(runConfig, analyzerRunControl);
return analyzerRunControl;
}
AndroidAnalyzeSupport::AndroidAnalyzeSupport(AndroidRunConfiguration *runConfig,
AnalyzerRunControl *runControl)
: AndroidRunSupport(runConfig, runControl),
m_engine(0),
m_runControl(0),
m_qmlPort(0)
{
if (runControl) {
m_engine = runControl->engine();
if (m_engine) {
connect(m_engine, SIGNAL(starting(const Analyzer::IAnalyzerEngine*)),
m_runner, SLOT(start()));
}
m_runControl = runControl;
connect(m_runControl, SIGNAL(starting(const Analyzer::AnalyzerRunControl*)),
m_runner, SLOT(start()));
}
connect(&m_outputParser, SIGNAL(waitingForConnectionOnPort(quint16)),
SLOT(remoteIsRunning()));
@@ -115,8 +113,8 @@ void AndroidAnalyzeSupport::handleRemoteProcessStarted(int qmlPort)
void AndroidAnalyzeSupport::handleRemoteOutput(const QByteArray &output)
{
const QString msg = QString::fromUtf8(output);
if (m_engine)
m_engine->logApplicationMessage(msg, Utils::StdOutFormatSameLine);
if (m_runControl)
m_runControl->logApplicationMessage(msg, Utils::StdOutFormatSameLine);
else
AndroidRunSupport::handleRemoteOutput(output);
m_outputParser.processOutput(msg);
@@ -124,16 +122,16 @@ void AndroidAnalyzeSupport::handleRemoteOutput(const QByteArray &output)
void AndroidAnalyzeSupport::handleRemoteErrorOutput(const QByteArray &output)
{
if (m_engine)
m_engine->logApplicationMessage(QString::fromUtf8(output), Utils::StdErrFormatSameLine);
if (m_runControl)
m_runControl->logApplicationMessage(QString::fromUtf8(output), Utils::StdErrFormatSameLine);
else
AndroidRunSupport::handleRemoteErrorOutput(output);
}
void AndroidAnalyzeSupport::remoteIsRunning()
{
if (m_engine)
m_engine->notifyRemoteSetupDone(m_qmlPort);
if (m_runControl)
m_runControl->notifyRemoteSetupDone(m_qmlPort);
}
} // namespace Internal

View File

@@ -33,10 +33,7 @@
#include "androidrunsupport.h"
#include <qmldebug/qmloutputparser.h>
namespace Analyzer {
class IAnalyzerEngine;
class AnalyzerRunControl;
}
namespace Analyzer { class AnalyzerRunControl; }
namespace ProjectExplorer { class RunControl; }
namespace Android {
@@ -66,7 +63,7 @@ private slots:
void remoteIsRunning();
private:
Analyzer::IAnalyzerEngine *m_engine;
Analyzer::AnalyzerRunControl *m_runControl;
QmlDebug::QmlOutputParser m_outputParser;
int m_qmlPort;
};

View File

@@ -45,7 +45,7 @@ LocalQmlProfilerRunner *LocalQmlProfilerRunner::createLocalRunner(
RunConfiguration *runConfiguration,
const Analyzer::AnalyzerStartParameters &sp,
QString *errorMessage,
QmlProfilerEngine *engine)
QmlProfilerRunControl *engine)
{
QmlProjectManager::QmlProjectRunConfiguration *rc1 =
qobject_cast<QmlProjectManager::QmlProjectRunConfiguration *>(runConfiguration);
@@ -81,7 +81,7 @@ LocalQmlProfilerRunner *LocalQmlProfilerRunner::createLocalRunner(
}
LocalQmlProfilerRunner::LocalQmlProfilerRunner(const Configuration &configuration,
QmlProfilerEngine *engine) :
QmlProfilerRunControl *engine) :
AbstractQmlProfilerRunner(engine),
m_configuration(configuration),
m_engine(engine)

View File

@@ -41,7 +41,7 @@ namespace Analyzer { class AnalyzerStartParameters; }
namespace QmlProfiler {
namespace Internal {
class QmlProfilerEngine;
class QmlProfilerRunControl;
class LocalQmlProfilerRunner : public AbstractQmlProfilerRunner
{
Q_OBJECT
@@ -58,7 +58,7 @@ public:
static LocalQmlProfilerRunner *createLocalRunner(ProjectExplorer::RunConfiguration *runConfiguration,
const Analyzer::AnalyzerStartParameters &sp,
QString *errorMessage,
QmlProfilerEngine *engine);
QmlProfilerRunControl *engine);
~LocalQmlProfilerRunner();
@@ -71,12 +71,12 @@ private slots:
void spontaneousStop(int exitCode);
private:
LocalQmlProfilerRunner(const Configuration &configuration, QmlProfilerEngine *engine);
LocalQmlProfilerRunner(const Configuration &configuration, QmlProfilerRunControl *engine);
private:
Configuration m_configuration;
ProjectExplorer::ApplicationLauncher m_launcher;
QmlProfilerEngine *m_engine;
QmlProfilerRunControl *m_engine;
};
} // namespace Internal

View File

@@ -61,15 +61,14 @@ namespace Internal {
// QmlProfilerEnginePrivate
//
class QmlProfilerEngine::QmlProfilerEnginePrivate
class QmlProfilerRunControl::QmlProfilerEnginePrivate
{
public:
QmlProfilerEnginePrivate(const AnalyzerStartParameters &sp) : sp(sp), m_running(false) {}
QmlProfilerEnginePrivate() : m_running(false) {}
QmlProfilerStateManager *m_profilerState;
QTimer m_noDebugOutputTimer;
QmlDebug::QmlOutputParser m_outputParser;
const AnalyzerStartParameters sp;
bool m_running;
};
@@ -77,10 +76,10 @@ public:
// QmlProfilerEngine
//
QmlProfilerEngine::QmlProfilerEngine(const Analyzer::AnalyzerStartParameters &sp,
QmlProfilerRunControl::QmlProfilerRunControl(const Analyzer::AnalyzerStartParameters &sp,
ProjectExplorer::RunConfiguration *runConfiguration)
: IAnalyzerEngine(sp, runConfiguration)
, d(new QmlProfilerEnginePrivate(sp))
: AnalyzerRunControl(sp, runConfiguration)
, d(new QmlProfilerEnginePrivate)
{
d->m_profilerState = 0;
@@ -99,14 +98,14 @@ QmlProfilerEngine::QmlProfilerEngine(const Analyzer::AnalyzerStartParameters &sp
this, SLOT(wrongSetupMessageBox(QString)));
}
QmlProfilerEngine::~QmlProfilerEngine()
QmlProfilerRunControl::~QmlProfilerRunControl()
{
if (d->m_profilerState && d->m_profilerState->currentState() == QmlProfilerStateManager::AppRunning)
stop();
stopEngine();
delete d;
}
bool QmlProfilerEngine::start()
bool QmlProfilerRunControl::startEngine()
{
QTC_ASSERT(d->m_profilerState, return false);
@@ -122,7 +121,7 @@ bool QmlProfilerEngine::start()
}
}
if (d->sp.startMode == StartQmlRemote || d->sp.startMode == StartLocal) {
if (startParameters().startMode == StartQmlRemote || startParameters().startMode == StartLocal) {
d->m_noDebugOutputTimer.start();
} else {
emit processRunning(startParameters().analyzerPort);
@@ -133,7 +132,7 @@ bool QmlProfilerEngine::start()
return true;
}
void QmlProfilerEngine::stop()
void QmlProfilerRunControl::stopEngine()
{
QTC_ASSERT(d->m_profilerState, return);
@@ -158,7 +157,7 @@ void QmlProfilerEngine::stop()
}
}
void QmlProfilerEngine::notifyRemoteFinished(bool success)
void QmlProfilerRunControl::notifyRemoteFinished(bool success)
{
QTC_ASSERT(d->m_profilerState, return);
@@ -170,7 +169,7 @@ void QmlProfilerEngine::notifyRemoteFinished(bool success)
d->m_profilerState->setCurrentState(QmlProfilerStateManager::AppKilled);
AnalyzerManager::stopTool();
engineFinished();
runControlFinished();
break;
}
case QmlProfilerStateManager::AppStopped :
@@ -186,7 +185,7 @@ void QmlProfilerEngine::notifyRemoteFinished(bool success)
}
}
void QmlProfilerEngine::cancelProcess()
void QmlProfilerRunControl::cancelProcess()
{
QTC_ASSERT(d->m_profilerState, return);
@@ -206,16 +205,16 @@ void QmlProfilerEngine::cancelProcess()
return;
}
}
engineFinished();
runControlFinished();
}
void QmlProfilerEngine::logApplicationMessage(const QString &msg, Utils::OutputFormat format)
void QmlProfilerRunControl::logApplicationMessage(const QString &msg, Utils::OutputFormat format)
{
emit outputReceived(msg, format);
appendMessage(msg, format);
d->m_outputParser.processOutput(msg);
}
void QmlProfilerEngine::wrongSetupMessageBox(const QString &errorMessage)
void QmlProfilerRunControl::wrongSetupMessageBox(const QString &errorMessage)
{
QMessageBox *infoBox = new QMessageBox(Core::ICore::mainWindow());
infoBox->setIcon(QMessageBox::Critical);
@@ -235,10 +234,10 @@ void QmlProfilerEngine::wrongSetupMessageBox(const QString &errorMessage)
// KILL
d->m_profilerState->setCurrentState(QmlProfilerStateManager::AppDying);
AnalyzerManager::stopTool();
engineFinished();
runControlFinished();
}
void QmlProfilerEngine::wrongSetupMessageBoxFinished(int button)
void QmlProfilerRunControl::wrongSetupMessageBoxFinished(int button)
{
if (button == QMessageBox::Help) {
Core::HelpManager *helpManager = Core::HelpManager::instance();
@@ -247,7 +246,7 @@ void QmlProfilerEngine::wrongSetupMessageBoxFinished(int button)
}
}
void QmlProfilerEngine::showNonmodalWarning(const QString &warningMsg)
void QmlProfilerRunControl::showNonmodalWarning(const QString &warningMsg)
{
QMessageBox *noExecWarning = new QMessageBox(Core::ICore::mainWindow());
noExecWarning->setIcon(QMessageBox::Warning);
@@ -259,13 +258,13 @@ void QmlProfilerEngine::showNonmodalWarning(const QString &warningMsg)
noExecWarning->show();
}
void QmlProfilerEngine::notifyRemoteSetupDone(quint16 port)
void QmlProfilerRunControl::notifyRemoteSetupDone(quint16 port)
{
d->m_noDebugOutputTimer.stop();
emit processRunning(port);
}
void QmlProfilerEngine::processIsRunning(quint16 port)
void QmlProfilerRunControl::processIsRunning(quint16 port)
{
d->m_noDebugOutputTimer.stop();
@@ -273,13 +272,13 @@ void QmlProfilerEngine::processIsRunning(quint16 port)
emit processRunning(port);
}
void QmlProfilerEngine::engineStarted()
void QmlProfilerRunControl::engineStarted()
{
d->m_running = true;
emit starting(this);
}
void QmlProfilerEngine::engineFinished()
void QmlProfilerRunControl::runControlFinished()
{
d->m_running = false;
emit finished();
@@ -287,7 +286,7 @@ void QmlProfilerEngine::engineFinished()
////////////////////////////////////////////////////////////////
// Profiler State
void QmlProfilerEngine::registerProfilerStateManager( QmlProfilerStateManager *profilerState )
void QmlProfilerRunControl::registerProfilerStateManager( QmlProfilerStateManager *profilerState )
{
// disconnect old
if (d->m_profilerState)
@@ -300,7 +299,7 @@ void QmlProfilerEngine::registerProfilerStateManager( QmlProfilerStateManager *p
connect(d->m_profilerState, SIGNAL(stateChanged()), this, SLOT(profilerStateChanged()));
}
void QmlProfilerEngine::profilerStateChanged()
void QmlProfilerRunControl::profilerStateChanged()
{
switch (d->m_profilerState->currentState()) {
case QmlProfilerStateManager::AppReadyToStop : {

View File

@@ -32,20 +32,20 @@
#include "qmlprofilerstatemanager.h"
#include <analyzerbase/ianalyzerengine.h>
#include <analyzerbase/analyzerruncontrol.h>
#include <utils/outputformat.h>
namespace QmlProfiler {
namespace Internal {
class QmlProfilerEngine : public Analyzer::IAnalyzerEngine
class QmlProfilerRunControl : public Analyzer::AnalyzerRunControl
{
Q_OBJECT
public:
QmlProfilerEngine(const Analyzer::AnalyzerStartParameters &sp,
QmlProfilerRunControl(const Analyzer::AnalyzerStartParameters &sp,
ProjectExplorer::RunConfiguration *runConfiguration);
~QmlProfilerEngine();
~QmlProfilerRunControl();
void registerProfilerStateManager( QmlProfilerStateManager *profilerState );
@@ -58,8 +58,8 @@ signals:
void timeUpdate();
public slots:
bool start();
void stop();
bool startEngine();
void stopEngine();
private slots:
void notifyRemoteFinished(bool success = true);
@@ -70,7 +70,7 @@ private slots:
void wrongSetupMessageBoxFinished(int);
void processIsRunning(quint16 port = 0);
void engineStarted();
void engineFinished();
void runControlFinished();
private slots:
void profilerStateChanged();

View File

@@ -131,13 +131,14 @@ RunControl *QmlProfilerRunControlFactory::create(RunConfiguration *runConfigurat
QTC_ASSERT(canRun(runConfiguration, mode), return 0);
AnalyzerStartParameters sp = createQmlProfilerStartParameters(runConfiguration);
sp.runMode = mode;
// only desktop device is supported
const IDevice::ConstPtr device = DeviceKitInformation::device(runConfiguration->target()->kit());
QTC_ASSERT(device->type() == ProjectExplorer::Constants::DESKTOP_DEVICE_TYPE, return 0);
AnalyzerRunControl *rc = new AnalyzerRunControl(tool, sp, runConfiguration);
QmlProfilerEngine *engine = qobject_cast<QmlProfilerEngine *>(rc->engine());
AnalyzerRunControl *rc = tool->createRunControl(sp, runConfiguration);
QmlProfilerRunControl *engine = qobject_cast<QmlProfilerRunControl *>(rc);
if (!engine) {
delete rc;
return 0;
@@ -148,7 +149,7 @@ RunControl *QmlProfilerRunControlFactory::create(RunConfiguration *runConfigurat
connect(runner, SIGNAL(stopped()), engine, SLOT(notifyRemoteFinished()));
connect(runner, SIGNAL(appendMessage(QString,Utils::OutputFormat)),
engine, SLOT(logApplicationMessage(QString,Utils::OutputFormat)));
connect(engine, SIGNAL(starting(const Analyzer::IAnalyzerEngine*)), runner,
connect(engine, SIGNAL(starting(const Analyzer::AnalyzerRunControl*)), runner,
SLOT(start()));
connect(rc, SIGNAL(finished()), runner, SLOT(stop()));
return rc;

View File

@@ -218,10 +218,10 @@ IAnalyzerTool::ToolMode QmlProfilerTool::toolMode() const
return AnyMode;
}
IAnalyzerEngine *QmlProfilerTool::createEngine(const AnalyzerStartParameters &sp,
AnalyzerRunControl *QmlProfilerTool::createRunControl(const AnalyzerStartParameters &sp,
RunConfiguration *runConfiguration)
{
QmlProfilerEngine *engine = new QmlProfilerEngine(sp, runConfiguration);
QmlProfilerRunControl *engine = new QmlProfilerRunControl(sp, runConfiguration);
engine->registerProfilerStateManager(d->m_profilerState);
@@ -489,7 +489,8 @@ static void startRemoteTool(IAnalyzerTool *tool, StartMode mode)
sp.sysroot = SysRootKitInformation::sysRoot(kit).toString();
sp.analyzerPort = port;
AnalyzerRunControl *rc = new AnalyzerRunControl(tool, sp, 0);
//AnalyzerRunControl *rc = new AnalyzerRunControl(tool, sp, 0);
AnalyzerRunControl *rc = tool->createRunControl(sp, 0);
QObject::connect(AnalyzerManager::stopAction(), SIGNAL(triggered()), rc, SLOT(stopIt()));
ProjectExplorerPlugin::instance()->startRunControl(rc, tool->runMode());

View File

@@ -31,7 +31,7 @@
#define QMLPROFILERTOOL_H
#include <analyzerbase/ianalyzertool.h>
#include <analyzerbase/ianalyzerengine.h>
#include <analyzerbase/analyzerruncontrol.h>
QT_BEGIN_NAMESPACE
class QMessageBox;
@@ -56,7 +56,7 @@ public:
void extensionsInitialized() {}
Analyzer::IAnalyzerEngine *createEngine(const Analyzer::AnalyzerStartParameters &sp,
Analyzer::AnalyzerRunControl *createRunControl(const Analyzer::AnalyzerStartParameters &sp,
ProjectExplorer::RunConfiguration *runConfiguration = 0);
bool canRun(ProjectExplorer::RunConfiguration *runConfiguration,

View File

@@ -29,7 +29,7 @@
#include "qnxanalyzesupport.h"
#include <analyzerbase/ianalyzerengine.h>
#include <analyzerbase/analyzerruncontrol.h>
#include <analyzerbase/analyzerstartparameters.h>
#include <projectexplorer/devicesupport/deviceapplicationrunner.h>
@@ -41,9 +41,9 @@ using namespace Qnx;
using namespace Qnx::Internal;
QnxAnalyzeSupport::QnxAnalyzeSupport(QnxRunConfiguration *runConfig,
Analyzer::IAnalyzerEngine *engine)
: QnxAbstractRunSupport(runConfig, engine)
, m_engine(engine)
Analyzer::AnalyzerRunControl *runControl)
: QnxAbstractRunSupport(runConfig, runControl)
, m_runControl(runControl)
, m_qmlPort(-1)
{
const DeviceApplicationRunner *runner = appRunner();
@@ -54,7 +54,7 @@ QnxAnalyzeSupport::QnxAnalyzeSupport(QnxRunConfiguration *runConfig,
connect(runner, SIGNAL(remoteStdout(QByteArray)), SLOT(handleRemoteOutput(QByteArray)));
connect(runner, SIGNAL(remoteStderr(QByteArray)), SLOT(handleRemoteOutput(QByteArray)));
connect(m_engine, SIGNAL(starting(const Analyzer::IAnalyzerEngine*)),
connect(m_runControl, SIGNAL(starting(const Analyzer::AnalyzerRunControl*)),
SLOT(handleAdapterSetupRequested()));
connect(&m_outputParser, SIGNAL(waitingForConnectionOnPort(quint16)),
SLOT(remoteIsRunning()));
@@ -78,7 +78,7 @@ void QnxAnalyzeSupport::startExecution()
setState(StartingRemoteProcess);
const QString args = m_engine->startParameters().debuggeeArgs +
const QString args = m_runControl->startParameters().debuggeeArgs +
QString::fromLatin1(" -qmljsdebugger=port:%1,block").arg(m_qmlPort);
const QString command = QString::fromLatin1("%1 %2 %3").arg(commandPrefix(), executable(), args);
appRunner()->start(device(), command.toUtf8());
@@ -86,13 +86,13 @@ void QnxAnalyzeSupport::startExecution()
void QnxAnalyzeSupport::handleRemoteProcessFinished(bool success)
{
if (m_engine || state() == Inactive)
if (m_runControl || state() == Inactive)
return;
if (!success)
showMessage(tr("The %1 process closed unexpectedly.").arg(executable()),
Utils::NormalMessageFormat);
m_engine->notifyRemoteFinished(success);
m_runControl->notifyRemoteFinished(success);
}
void QnxAnalyzeSupport::handleProfilingFinished()
@@ -124,13 +124,13 @@ void QnxAnalyzeSupport::handleError(const QString &error)
void QnxAnalyzeSupport::remoteIsRunning()
{
if (m_engine)
m_engine->notifyRemoteSetupDone(m_qmlPort);
if (m_runControl)
m_runControl->notifyRemoteSetupDone(m_qmlPort);
}
void QnxAnalyzeSupport::showMessage(const QString &msg, Utils::OutputFormat format)
{
if (state() != Inactive && m_engine)
m_engine->logApplicationMessage(msg, format);
if (state() != Inactive && m_runControl)
m_runControl->logApplicationMessage(msg, format);
m_outputParser.processOutput(msg);
}

View File

@@ -36,7 +36,7 @@
#include <utils/outputformat.h>
#include <qmldebug/qmloutputparser.h>
namespace Analyzer { class IAnalyzerEngine; }
namespace Analyzer { class AnalyzerRunControl; }
namespace Qnx {
namespace Internal {
@@ -47,7 +47,7 @@ class QnxAnalyzeSupport : public QnxAbstractRunSupport
{
Q_OBJECT
public:
QnxAnalyzeSupport(QnxRunConfiguration *runConfig, Analyzer::IAnalyzerEngine *engine);
QnxAnalyzeSupport(QnxRunConfiguration *runConfig, Analyzer::AnalyzerRunControl *engine);
public slots:
void handleProfilingFinished();
@@ -66,7 +66,7 @@ private:
void startExecution();
void showMessage(const QString &, Utils::OutputFormat);
Analyzer::IAnalyzerEngine *m_engine;
Analyzer::AnalyzerRunControl *m_runControl;
QmlDebug::QmlOutputParser m_outputParser;
int m_qmlPort;
};

View File

@@ -48,6 +48,7 @@
#include <analyzerbase/analyzerstartparameters.h>
#include <analyzerbase/analyzermanager.h>
#include <analyzerbase/analyzerruncontrol.h>
#include <analyzerbase/ianalyzertool.h>
#include <projectexplorer/environmentaspect.h>
#include <projectexplorer/buildconfiguration.h>
#include <projectexplorer/project.h>
@@ -195,8 +196,9 @@ RunControl *QnxRunControlFactory::create(RunConfiguration *runConfig, RunMode mo
return 0;
}
const AnalyzerStartParameters params = createAnalyzerStartParameters(rc, mode);
AnalyzerRunControl * const runControl = new AnalyzerRunControl(tool, params, runConfig);
QnxAnalyzeSupport * const analyzeSupport = new QnxAnalyzeSupport(rc, runControl->engine());
AnalyzerRunControl *runControl = tool->createRunControl(params, runConfig);
//AnalyzerRunControl * const runControl = new AnalyzerRunControl(tool, params, runConfig);
QnxAnalyzeSupport * const analyzeSupport = new QnxAnalyzeSupport(rc, runControl);
connect(runControl, SIGNAL(finished()), analyzeSupport, SLOT(handleProfilingFinished()));
return runControl;
}

View File

@@ -31,7 +31,7 @@
#include "remotelinuxrunconfiguration.h"
#include <analyzerbase/ianalyzerengine.h>
#include <analyzerbase/analyzerruncontrol.h>
#include <projectexplorer/buildconfiguration.h>
#include <projectexplorer/project.h>
@@ -55,14 +55,14 @@ namespace Internal {
class RemoteLinuxAnalyzeSupportPrivate
{
public:
RemoteLinuxAnalyzeSupportPrivate(IAnalyzerEngine *engine, RunMode runMode)
: engine(engine),
RemoteLinuxAnalyzeSupportPrivate(AnalyzerRunControl *rc, RunMode runMode)
: runControl(rc),
qmlProfiling(runMode == QmlProfilerRunMode),
qmlPort(-1)
{
}
const QPointer<IAnalyzerEngine> engine;
const QPointer<AnalyzerRunControl> runControl;
bool qmlProfiling;
int qmlPort;
@@ -79,6 +79,7 @@ AnalyzerStartParameters RemoteLinuxAnalyzeSupport::startParameters(const RemoteL
AnalyzerStartParameters params;
if (runMode == QmlProfilerRunMode)
params.startMode = StartQmlRemote;
params.runMode = runMode;
params.connParams = DeviceKitInformation::device(runConfig->target()->kit())->sshParameters();
params.analyzerCmdPrefix = runConfig->commandPrefix();
params.displayName = runConfig->displayName();
@@ -89,11 +90,11 @@ AnalyzerStartParameters RemoteLinuxAnalyzeSupport::startParameters(const RemoteL
}
RemoteLinuxAnalyzeSupport::RemoteLinuxAnalyzeSupport(RemoteLinuxRunConfiguration *runConfig,
IAnalyzerEngine *engine, RunMode runMode)
AnalyzerRunControl *engine, RunMode runMode)
: AbstractRemoteLinuxRunSupport(runConfig, engine),
d(new RemoteLinuxAnalyzeSupportPrivate(engine, runMode))
{
connect(d->engine, SIGNAL(starting(const Analyzer::IAnalyzerEngine*)),
connect(d->runControl, SIGNAL(starting(const Analyzer::AnalyzerRunControl*)),
SLOT(handleRemoteSetupRequested()));
connect(&d->outputParser, SIGNAL(waitingForConnectionOnPort(quint16)),
SLOT(remoteIsRunning()));
@@ -106,14 +107,14 @@ RemoteLinuxAnalyzeSupport::~RemoteLinuxAnalyzeSupport()
void RemoteLinuxAnalyzeSupport::showMessage(const QString &msg, Utils::OutputFormat format)
{
if (state() != Inactive && d->engine)
d->engine->logApplicationMessage(msg, format);
if (state() != Inactive && d->runControl)
d->runControl->logApplicationMessage(msg, format);
d->outputParser.processOutput(msg);
}
void RemoteLinuxAnalyzeSupport::handleRemoteSetupRequested()
{
if (d->engine->mode() != Analyzer::StartQmlRemote)
if (d->runControl->mode() != Analyzer::StartQmlRemote)
return;
QTC_ASSERT(state() == Inactive, return);
@@ -163,19 +164,19 @@ void RemoteLinuxAnalyzeSupport::handleAppRunnerFinished(bool success)
reset();
if (!success)
showMessage(tr("Failure running remote process."), Utils::NormalMessageFormat);
d->engine->notifyRemoteFinished(success);
d->runControl->notifyRemoteFinished(success);
}
void RemoteLinuxAnalyzeSupport::handleProfilingFinished()
{
if (d->engine->mode() != Analyzer::StartQmlRemote)
if (d->runControl->mode() != Analyzer::StartQmlRemote)
return;
setFinished();
}
void RemoteLinuxAnalyzeSupport::remoteIsRunning()
{
d->engine->notifyRemoteSetupDone(d->qmlPort);
d->runControl->notifyRemoteSetupDone(d->qmlPort);
}
void RemoteLinuxAnalyzeSupport::handleRemoteOutput(const QByteArray &output)
@@ -189,7 +190,7 @@ void RemoteLinuxAnalyzeSupport::handleRemoteErrorOutput(const QByteArray &output
{
QTC_ASSERT(state() != GatheringPorts, return);
if (!d->engine)
if (!d->runControl)
return;
showMessage(QString::fromUtf8(output), Utils::StdErrFormat);

View File

@@ -37,7 +37,7 @@
namespace Analyzer {
class AnalyzerStartParameters;
class IAnalyzerEngine;
class AnalyzerRunControl;
}
namespace RemoteLinux {
@@ -53,7 +53,7 @@ public:
ProjectExplorer::RunMode runMode);
RemoteLinuxAnalyzeSupport(RemoteLinuxRunConfiguration *runConfig,
Analyzer::IAnalyzerEngine *engine, ProjectExplorer::RunMode runMode);
Analyzer::AnalyzerRunControl *engine, ProjectExplorer::RunMode runMode);
~RemoteLinuxAnalyzeSupport();
protected:

View File

@@ -40,6 +40,7 @@
#include <analyzerbase/analyzerstartparameters.h>
#include <analyzerbase/analyzermanager.h>
#include <analyzerbase/analyzerruncontrol.h>
#include <analyzerbase/ianalyzertool.h>
#include <projectexplorer/kitinformation.h>
#include <projectexplorer/target.h>
#include <utils/portlist.h>
@@ -113,9 +114,13 @@ RunControl *RemoteLinuxRunControlFactory::create(RunConfiguration *runConfig, Ru
return 0;
}
AnalyzerStartParameters params = RemoteLinuxAnalyzeSupport::startParameters(rc, mode);
AnalyzerRunControl * const runControl = new AnalyzerRunControl(tool, params, runConfig);
//AnalyzerRunControl * const runControl = new AnalyzerRunControl(tool, params, runConfig);
AnalyzerRunControl *runControl = tool->createRunControl(params, runConfig);
//m_engine->setRunControl(this);
RemoteLinuxAnalyzeSupport * const analyzeSupport =
new RemoteLinuxAnalyzeSupport(rc, runControl->engine(), mode);
new RemoteLinuxAnalyzeSupport(rc, runControl, mode);
connect(runControl, SIGNAL(finished()), analyzeSupport, SLOT(handleProfilingFinished()));
return runControl;
}

View File

@@ -42,9 +42,9 @@ using namespace Analyzer;
using namespace Valgrind;
using namespace Valgrind::Internal;
CallgrindEngine::CallgrindEngine(const AnalyzerStartParameters &sp,
CallgrindRunControl::CallgrindRunControl(const AnalyzerStartParameters &sp,
ProjectExplorer::RunConfiguration *runConfiguration)
: ValgrindEngine(sp, runConfiguration)
: ValgrindRunControl(sp, runConfiguration)
, m_markAsPaused(false)
{
connect(&m_runner, SIGNAL(finished()), this, SLOT(slotFinished()));
@@ -55,12 +55,12 @@ CallgrindEngine::CallgrindEngine(const AnalyzerStartParameters &sp,
m_progress->setProgressRange(0, 2);
}
void CallgrindEngine::showStatusMessage(const QString &msg)
void CallgrindRunControl::showStatusMessage(const QString &msg)
{
AnalyzerManager::showStatusMessage(msg);
}
QStringList CallgrindEngine::toolArguments() const
QStringList CallgrindRunControl::toolArguments() const
{
QStringList arguments;
@@ -89,28 +89,28 @@ QStringList CallgrindEngine::toolArguments() const
return arguments;
}
QString CallgrindEngine::progressTitle() const
QString CallgrindRunControl::progressTitle() const
{
return tr("Profiling");
}
Valgrind::ValgrindRunner * CallgrindEngine::runner()
Valgrind::ValgrindRunner * CallgrindRunControl::runner()
{
return &m_runner;
}
bool CallgrindEngine::start()
bool CallgrindRunControl::startEngine()
{
emit outputReceived(tr("Profiling %1\n").arg(executable()), Utils::NormalMessageFormat);
return ValgrindEngine::start();
appendMessage(tr("Profiling %1\n").arg(executable()), Utils::NormalMessageFormat);
return ValgrindRunControl::startEngine();
}
void CallgrindEngine::dump()
void CallgrindRunControl::dump()
{
m_runner.controller()->run(Valgrind::Callgrind::CallgrindController::Dump);
}
void CallgrindEngine::setPaused(bool paused)
void CallgrindRunControl::setPaused(bool paused)
{
if (m_markAsPaused == paused)
return;
@@ -126,7 +126,7 @@ void CallgrindEngine::setPaused(bool paused)
}
}
void CallgrindEngine::setToggleCollectFunction(const QString &toggleCollectFunction)
void CallgrindRunControl::setToggleCollectFunction(const QString &toggleCollectFunction)
{
if (toggleCollectFunction.isEmpty())
return;
@@ -134,32 +134,32 @@ void CallgrindEngine::setToggleCollectFunction(const QString &toggleCollectFunct
m_argumentForToggleCollect = QLatin1String("--toggle-collect=") + toggleCollectFunction;
}
void CallgrindEngine::reset()
void CallgrindRunControl::reset()
{
m_runner.controller()->run(Valgrind::Callgrind::CallgrindController::ResetEventCounters);
}
void CallgrindEngine::pause()
void CallgrindRunControl::pause()
{
m_runner.controller()->run(Valgrind::Callgrind::CallgrindController::Pause);
}
void CallgrindEngine::unpause()
void CallgrindRunControl::unpause()
{
m_runner.controller()->run(Valgrind::Callgrind::CallgrindController::UnPause);
}
Valgrind::Callgrind::ParseData *CallgrindEngine::takeParserData()
Valgrind::Callgrind::ParseData *CallgrindRunControl::takeParserData()
{
return m_runner.parser()->takeData();
}
void CallgrindEngine::slotFinished()
void CallgrindRunControl::slotFinished()
{
emit parserDataReady(this);
}
void CallgrindEngine::slotStarted()
void CallgrindRunControl::slotStarted()
{
m_progress->setProgressValue(1);;
}

View File

@@ -38,15 +38,15 @@
namespace Valgrind {
namespace Internal {
class CallgrindEngine : public Valgrind::Internal::ValgrindEngine
class CallgrindRunControl : public ValgrindRunControl
{
Q_OBJECT
public:
CallgrindEngine(const Analyzer::AnalyzerStartParameters &sp,
CallgrindRunControl(const Analyzer::AnalyzerStartParameters &sp,
ProjectExplorer::RunConfiguration *runConfiguration);
bool start();
bool startEngine();
Valgrind::Callgrind::ParseData *takeParserData();
@@ -71,7 +71,7 @@ protected:
virtual Valgrind::ValgrindRunner *runner();
signals:
void parserDataReady(CallgrindEngine *engine);
void parserDataReady(CallgrindRunControl *engine);
private slots:
void slotFinished();

View File

@@ -118,7 +118,7 @@ public:
void doClear(bool clearParseData);
void updateEventCombo();
IAnalyzerEngine *createEngine(const AnalyzerStartParameters &sp,
AnalyzerRunControl *createRunControl(const AnalyzerStartParameters &sp,
ProjectExplorer::RunConfiguration *runConfiguration = 0);
signals:
@@ -163,8 +163,8 @@ public slots:
void visualisationFunctionSelected(const Valgrind::Callgrind::Function *function);
void showParserResults(const Valgrind::Callgrind::ParseData *data);
void takeParserData(CallgrindEngine *engine);
void engineStarting(const Analyzer::IAnalyzerEngine *);
void takeParserData(CallgrindRunControl *rc);
void engineStarting(const Analyzer::AnalyzerRunControl *);
void engineFinished();
void editorOpened(Core::IEditor *);
@@ -569,38 +569,38 @@ void CallgrindTool::extensionsInitialized()
}
}
IAnalyzerEngine *CallgrindTool::createEngine(const AnalyzerStartParameters &sp,
AnalyzerRunControl *CallgrindTool::createRunControl(const AnalyzerStartParameters &sp,
RunConfiguration *runConfiguration)
{
return d->createEngine(sp, runConfiguration);
return d->createRunControl(sp, runConfiguration);
}
IAnalyzerEngine *CallgrindToolPrivate::createEngine(const AnalyzerStartParameters &sp,
AnalyzerRunControl *CallgrindToolPrivate::createRunControl(const AnalyzerStartParameters &sp,
RunConfiguration *runConfiguration)
{
CallgrindEngine *engine = new CallgrindEngine(sp, runConfiguration);
CallgrindRunControl *rc = new CallgrindRunControl(sp, runConfiguration);
connect(engine, SIGNAL(parserDataReady(CallgrindEngine*)),
SLOT(takeParserData(CallgrindEngine*)));
connect(engine, SIGNAL(starting(const Analyzer::IAnalyzerEngine*)),
SLOT(engineStarting(const Analyzer::IAnalyzerEngine*)));
connect(engine, SIGNAL(finished()),
connect(rc, SIGNAL(parserDataReady(CallgrindRunControl*)),
SLOT(takeParserData(CallgrindRunControl*)));
connect(rc, SIGNAL(starting(const Analyzer::AnalyzerRunControl*)),
SLOT(engineStarting(const Analyzer::AnalyzerRunControl*)));
connect(rc, SIGNAL(finished()),
SLOT(engineFinished()));
connect(this, SIGNAL(dumpRequested()), engine, SLOT(dump()));
connect(this, SIGNAL(resetRequested()), engine, SLOT(reset()));
connect(this, SIGNAL(pauseToggled(bool)), engine, SLOT(setPaused(bool)));
connect(this, SIGNAL(dumpRequested()), rc, SLOT(dump()));
connect(this, SIGNAL(resetRequested()), rc, SLOT(reset()));
connect(this, SIGNAL(pauseToggled(bool)), rc, SLOT(setPaused(bool)));
// initialize engine
engine->setPaused(m_pauseAction->isChecked());
// initialize run control
rc->setPaused(m_pauseAction->isChecked());
// we may want to toggle collect for one function only in this run
engine->setToggleCollectFunction(m_toggleCollectFunction);
rc->setToggleCollectFunction(m_toggleCollectFunction);
m_toggleCollectFunction.clear();
AnalyzerManager::showStatusMessage(AnalyzerManager::msgToolStarted(q->displayName()));
QTC_ASSERT(m_visualisation, return engine);
QTC_ASSERT(m_visualisation, return rc);
// apply project settings
if (runConfiguration) {
@@ -612,7 +612,7 @@ IAnalyzerEngine *CallgrindToolPrivate::createEngine(const AnalyzerStartParameter
}
}
}
return engine;
return rc;
}
void CallgrindTool::startTool(StartMode mode)
@@ -856,7 +856,7 @@ void CallgrindToolPrivate::clearTextMarks()
m_textMarks.clear();
}
void CallgrindToolPrivate::engineStarting(const Analyzer::IAnalyzerEngine *)
void CallgrindToolPrivate::engineStarting(const Analyzer::AnalyzerRunControl *)
{
// enable/disable actions
m_resetAction->setEnabled(true);
@@ -964,9 +964,9 @@ void CallgrindToolPrivate::slotRequestDump()
dumpRequested();
}
void CallgrindToolPrivate::takeParserData(CallgrindEngine *engine)
void CallgrindToolPrivate::takeParserData(CallgrindRunControl *rc)
{
ParseData *data = engine->takeParserData();
ParseData *data = rc->takeParserData();
showParserResults(data);
if (!data)

View File

@@ -54,7 +54,7 @@ public:
void extensionsInitialized();
Analyzer::IAnalyzerEngine *createEngine(const Analyzer::AnalyzerStartParameters &sp,
Analyzer::AnalyzerRunControl *createRunControl(const Analyzer::AnalyzerStartParameters &sp,
ProjectExplorer::RunConfiguration *runConfiguration = 0);
QWidget *createWidgets();

View File

@@ -34,20 +34,24 @@
#include <analyzerbase/analyzersettings.h>
#include <projectexplorer/projectexplorer.h>
#include <projectexplorer/taskhub.h>
#include <valgrind/xmlprotocol/error.h>
#include <valgrind/xmlprotocol/status.h>
#include <utils/qtcassert.h>
using namespace Analyzer;
using namespace ProjectExplorer;
using namespace Valgrind::XmlProtocol;
namespace Valgrind {
namespace Internal {
MemcheckEngine::MemcheckEngine(const AnalyzerStartParameters &sp,
MemcheckRunControl::MemcheckRunControl(const AnalyzerStartParameters &sp,
ProjectExplorer::RunConfiguration *runConfiguration)
: ValgrindEngine(sp, runConfiguration)
: ValgrindRunControl(sp, runConfiguration)
{
connect(&m_parser, SIGNAL(error(Valgrind::XmlProtocol::Error)),
SIGNAL(parserError(Valgrind::XmlProtocol::Error)));
@@ -61,33 +65,36 @@ MemcheckEngine::MemcheckEngine(const AnalyzerStartParameters &sp,
m_progress->setProgressRange(0, XmlProtocol::Status::Finished + 1);
}
QString MemcheckEngine::progressTitle() const
QString MemcheckRunControl::progressTitle() const
{
return tr("Analyzing Memory");
}
Valgrind::ValgrindRunner *MemcheckEngine::runner()
Valgrind::ValgrindRunner *MemcheckRunControl::runner()
{
return &m_runner;
}
bool MemcheckEngine::start()
bool MemcheckRunControl::startEngine()
{
m_runner.setParser(&m_parser);
emit outputReceived(tr("Analyzing memory of %1\n").arg(executable()),
// Clear about-to-be-outdated tasks.
ProjectExplorerPlugin::instance()->taskHub()->clearTasks(Analyzer::Constants::ANALYZERTASK_ID);
appendMessage(tr("Analyzing memory of %1\n").arg(executable()),
Utils::NormalMessageFormat);
return ValgrindEngine::start();
return ValgrindRunControl::startEngine();
}
void MemcheckEngine::stop()
void MemcheckRunControl::stopEngine()
{
disconnect(&m_parser, SIGNAL(internalError(QString)),
this, SIGNAL(internalParserError(QString)));
ValgrindEngine::stop();
ValgrindRunControl::stopEngine();
}
QStringList MemcheckEngine::toolArguments() const
QStringList MemcheckRunControl::toolArguments() const
{
QStringList arguments;
arguments << QLatin1String("--gen-suppressions=all");
@@ -105,17 +112,17 @@ QStringList MemcheckEngine::toolArguments() const
return arguments;
}
QStringList MemcheckEngine::suppressionFiles() const
QStringList MemcheckRunControl::suppressionFiles() const
{
return m_settings->subConfig<ValgrindBaseSettings>()->suppressionFiles();
}
void MemcheckEngine::status(const Status &status)
void MemcheckRunControl::status(const Status &status)
{
m_progress->setProgressValue(status.state() + 1);
}
void MemcheckEngine::receiveLogMessage(const QByteArray &b)
void MemcheckRunControl::receiveLogMessage(const QByteArray &b)
{
QString error = QString::fromLocal8Bit(b);
// workaround https://bugs.kde.org/show_bug.cgi?id=255888
@@ -126,7 +133,7 @@ void MemcheckEngine::receiveLogMessage(const QByteArray &b)
if (error.isEmpty())
return;
stop();
stopEngine();
QString file;
int line = -1;
@@ -138,7 +145,10 @@ void MemcheckEngine::receiveLogMessage(const QByteArray &b)
line = suppressionError.cap(2).toInt();
}
emit taskToBeAdded(ProjectExplorer::Task::Error, error, file, line);
TaskHub *hub = ProjectExplorerPlugin::instance()->taskHub();
hub->addTask(Task(Task::Error, error, Utils::FileName::fromUserInput(file), line,
Analyzer::Constants::ANALYZERTASK_ID));
hub->requestPopup();
}
} // namespace Internal

View File

@@ -39,16 +39,16 @@
namespace Valgrind {
namespace Internal {
class MemcheckEngine : public ValgrindEngine
class MemcheckRunControl : public ValgrindRunControl
{
Q_OBJECT
public:
MemcheckEngine(const Analyzer::AnalyzerStartParameters &sp,
MemcheckRunControl(const Analyzer::AnalyzerStartParameters &sp,
ProjectExplorer::RunConfiguration *runConfiguration);
bool start();
void stop();
bool startEngine();
void stopEngine();
QStringList suppressionFiles() const;

View File

@@ -450,16 +450,16 @@ QWidget *MemcheckTool::createWidgets()
return widget;
}
IAnalyzerEngine *MemcheckTool::createEngine(const AnalyzerStartParameters &sp,
AnalyzerRunControl *MemcheckTool::createRunControl(const AnalyzerStartParameters &sp,
RunConfiguration *runConfiguration)
{
m_frameFinder->setFiles(runConfiguration ? runConfiguration->target()
->project()->files(Project::AllFiles) : QStringList());
MemcheckEngine *engine = new MemcheckEngine(sp, runConfiguration);
MemcheckRunControl *engine = new MemcheckRunControl(sp, runConfiguration);
connect(engine, SIGNAL(starting(const Analyzer::IAnalyzerEngine*)),
this, SLOT(engineStarting(const Analyzer::IAnalyzerEngine*)));
connect(engine, SIGNAL(starting(const Analyzer::AnalyzerRunControl*)),
this, SLOT(engineStarting(const Analyzer::AnalyzerRunControl*)));
connect(engine, SIGNAL(parserError(Valgrind::XmlProtocol::Error)),
this, SLOT(parserError(Valgrind::XmlProtocol::Error)));
connect(engine, SIGNAL(internalParserError(QString)),
@@ -474,7 +474,7 @@ void MemcheckTool::startTool(StartMode mode)
ValgrindPlugin::startValgrindTool(this, mode);
}
void MemcheckTool::engineStarting(const IAnalyzerEngine *engine)
void MemcheckTool::engineStarting(const AnalyzerRunControl *engine)
{
setBusyCursor(true);
clearErrorView();
@@ -483,7 +483,7 @@ void MemcheckTool::engineStarting(const IAnalyzerEngine *engine)
if (RunConfiguration *rc = engine->runConfiguration())
dir = rc->target()->project()->projectDirectory() + QDir::separator();
const MemcheckEngine *mEngine = dynamic_cast<const MemcheckEngine *>(engine);
const MemcheckRunControl *mEngine = dynamic_cast<const MemcheckRunControl *>(engine);
QTC_ASSERT(mEngine, return);
const QString name = QFileInfo(mEngine->executable()).fileName();

View File

@@ -98,7 +98,7 @@ private slots:
void settingsDestroyed(QObject *settings);
void maybeActiveRunConfigurationChanged();
void engineStarting(const Analyzer::IAnalyzerEngine *engine);
void engineStarting(const Analyzer::AnalyzerRunControl *engine);
void finished();
void parserError(const Valgrind::XmlProtocol::Error &error);
@@ -112,7 +112,7 @@ private:
QWidget *createWidgets();
void setBusyCursor(bool busy);
Analyzer::IAnalyzerEngine *createEngine(const Analyzer::AnalyzerStartParameters &sp,
Analyzer::AnalyzerRunControl *createRunControl(const Analyzer::AnalyzerStartParameters &sp,
ProjectExplorer::RunConfiguration *runConfiguration = 0);
void startTool(Analyzer::StartMode mode);

View File

@@ -53,9 +53,9 @@ namespace Internal {
const int progressMaximum = 1000000;
ValgrindEngine::ValgrindEngine(const AnalyzerStartParameters &sp,
ValgrindRunControl::ValgrindRunControl(const AnalyzerStartParameters &sp,
ProjectExplorer::RunConfiguration *runConfiguration)
: IAnalyzerEngine(sp, runConfiguration),
: AnalyzerRunControl(sp, runConfiguration),
m_settings(0),
m_progress(new QFutureInterface<void>()),
m_progressWatcher(new QFutureWatcher<void>()),
@@ -73,12 +73,12 @@ ValgrindEngine::ValgrindEngine(const AnalyzerStartParameters &sp,
this, SLOT(handleProgressFinished()));
}
ValgrindEngine::~ValgrindEngine()
ValgrindRunControl::~ValgrindRunControl()
{
delete m_progress;
}
bool ValgrindEngine::start()
bool ValgrindRunControl::startEngine()
{
emit starting(this);
@@ -123,32 +123,32 @@ bool ValgrindEngine::start()
return true;
}
void ValgrindEngine::stop()
void ValgrindRunControl::stopEngine()
{
m_isStopping = true;
runner()->stop();
}
QString ValgrindEngine::executable() const
QString ValgrindRunControl::executable() const
{
return startParameters().debuggee;
}
void ValgrindEngine::handleProgressCanceled()
void ValgrindRunControl::handleProgressCanceled()
{
AnalyzerManager::stopTool();
m_progress->reportCanceled();
m_progress->reportFinished();
}
void ValgrindEngine::handleProgressFinished()
void ValgrindRunControl::handleProgressFinished()
{
QApplication::alert(ICore::mainWindow(), 3000);
}
void ValgrindEngine::runnerFinished()
void ValgrindRunControl::runnerFinished()
{
emit outputReceived(tr("** Analyzing finished **\n"), NormalMessageFormat);
appendMessage(tr("** Analyzing finished **\n"), NormalMessageFormat);
emit finished();
m_progress->reportFinished();
@@ -159,7 +159,7 @@ void ValgrindEngine::runnerFinished()
this, SLOT(runnerFinished()));
}
void ValgrindEngine::receiveProcessOutput(const QByteArray &output, OutputFormat format)
void ValgrindRunControl::receiveProcessOutput(const QByteArray &output, OutputFormat format)
{
int progress = m_progress->progressValue();
if (progress < 5 * progressMaximum / 10)
@@ -167,21 +167,21 @@ void ValgrindEngine::receiveProcessOutput(const QByteArray &output, OutputFormat
else if (progress < 9 * progressMaximum / 10)
progress += progress / 1000;
m_progress->setProgressValue(progress);
emit outputReceived(QString::fromLocal8Bit(output), format);
appendMessage(QString::fromLocal8Bit(output), format);
}
void ValgrindEngine::receiveProcessError(const QString &message, QProcess::ProcessError error)
void ValgrindRunControl::receiveProcessError(const QString &message, QProcess::ProcessError error)
{
if (error == QProcess::FailedToStart) {
const QString &valgrind = m_settings->subConfig<ValgrindBaseSettings>()->valgrindExecutable();
if (!valgrind.isEmpty())
emit outputReceived(tr("** Error: \"%1\" could not be started: %2 **\n").arg(valgrind).arg(message), ErrorMessageFormat);
appendMessage(tr("** Error: \"%1\" could not be started: %2 **\n").arg(valgrind).arg(message), ErrorMessageFormat);
else
emit outputReceived(tr("** Error: no valgrind executable set **\n"), ErrorMessageFormat);
appendMessage(tr("** Error: no valgrind executable set **\n"), ErrorMessageFormat);
} else if (m_isStopping && error == QProcess::Crashed) { // process gets killed on stop
emit outputReceived(tr("** Process Terminated **\n"), ErrorMessageFormat);
appendMessage(tr("** Process Terminated **\n"), ErrorMessageFormat);
} else {
emit outputReceived(QString::fromLatin1("** %1 **\n").arg(message), ErrorMessageFormat);
appendMessage(QString::fromLatin1("** %1 **\n").arg(message), ErrorMessageFormat);
}
if (m_isStopping)

View File

@@ -31,7 +31,7 @@
#ifndef VALGRINDENGINE_H
#define VALGRINDENGINE_H
#include <analyzerbase/ianalyzerengine.h>
#include <analyzerbase/analyzerruncontrol.h>
#include <utils/environment.h>
#include <valgrind/valgrindrunner.h>
@@ -43,17 +43,17 @@ namespace Analyzer { class AnalyzerSettings; }
namespace Valgrind {
namespace Internal {
class ValgrindEngine : public Analyzer::IAnalyzerEngine
class ValgrindRunControl : public Analyzer::AnalyzerRunControl
{
Q_OBJECT
public:
ValgrindEngine(const Analyzer::AnalyzerStartParameters &sp,
ValgrindRunControl(const Analyzer::AnalyzerStartParameters &sp,
ProjectExplorer::RunConfiguration *runConfiguration);
~ValgrindEngine();
~ValgrindRunControl();
bool start();
void stop();
bool startEngine();
void stopEngine();
QString executable() const;

View File

@@ -75,7 +75,8 @@ static void startRemoteTool(IAnalyzerTool *tool)
sp.displayName = dlg.executable();
sp.workingDirectory = dlg.workingDirectory();
AnalyzerRunControl *rc = new AnalyzerRunControl(tool, sp, 0);
//AnalyzerRunControl *rc = new AnalyzerRunControl(tool, sp, 0);
AnalyzerRunControl *rc = tool->createRunControl(sp, 0);
//m_currentRunControl = rc;
QObject::connect(AnalyzerManager::stopAction(), SIGNAL(triggered()), rc, SLOT(stopIt()));

View File

@@ -122,8 +122,7 @@ RunControl *ValgrindRunControlFactory::create(RunConfiguration *runConfiguration
AnalyzerStartParameters sp = createValgrindStartParameters(runConfiguration);
sp.toolId = tool->id();
AnalyzerRunControl *rc = new AnalyzerRunControl(tool, sp, runConfiguration);
return rc;
return tool->createRunControl(sp, runConfiguration);
}
IRunConfigurationAspect *ValgrindRunControlFactory::createRunConfigurationAspect(RunConfiguration *rc)