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