forked from qt-creator/qt-creator
Valgrind: Use the majority way to register run workers
Change-Id: I6423620a9a1917ab09b93038b020c36e9208b728 Reviewed-by: Christian Stenger <christian.stenger@qt.io>
This commit is contained in:
@@ -42,6 +42,8 @@ using namespace Valgrind::Callgrind;
|
|||||||
namespace Valgrind {
|
namespace Valgrind {
|
||||||
namespace Internal {
|
namespace Internal {
|
||||||
|
|
||||||
|
void setupCallgrindRunner(CallgrindToolRunner *);
|
||||||
|
|
||||||
CallgrindToolRunner::CallgrindToolRunner(RunControl *runControl)
|
CallgrindToolRunner::CallgrindToolRunner(RunControl *runControl)
|
||||||
: ValgrindToolRunner(runControl)
|
: ValgrindToolRunner(runControl)
|
||||||
{
|
{
|
||||||
@@ -67,6 +69,8 @@ CallgrindToolRunner::CallgrindToolRunner(RunControl *runControl)
|
|||||||
});
|
});
|
||||||
|
|
||||||
m_controller.setValgrindRunnable(runnable());
|
m_controller.setValgrindRunnable(runnable());
|
||||||
|
|
||||||
|
setupCallgrindRunner(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
QStringList CallgrindToolRunner::toolArguments() const
|
QStringList CallgrindToolRunner::toolArguments() const
|
||||||
|
|||||||
@@ -98,7 +98,6 @@ using namespace Valgrind::Callgrind;
|
|||||||
using namespace TextEditor;
|
using namespace TextEditor;
|
||||||
using namespace ProjectExplorer;
|
using namespace ProjectExplorer;
|
||||||
using namespace Utils;
|
using namespace Utils;
|
||||||
using namespace std::placeholders;
|
|
||||||
|
|
||||||
namespace Valgrind {
|
namespace Valgrind {
|
||||||
namespace Internal {
|
namespace Internal {
|
||||||
@@ -121,7 +120,7 @@ public:
|
|||||||
CallgrindTool();
|
CallgrindTool();
|
||||||
~CallgrindTool();
|
~CallgrindTool();
|
||||||
|
|
||||||
ValgrindToolRunner *createRunTool(RunControl *runControl);
|
void setupRunner(CallgrindToolRunner *runner);
|
||||||
|
|
||||||
void setParseData(ParseData *data);
|
void setParseData(ParseData *data);
|
||||||
CostDelegate::CostFormat costFormat() const;
|
CostDelegate::CostFormat costFormat() const;
|
||||||
@@ -272,7 +271,7 @@ CallgrindTool::CallgrindTool()
|
|||||||
action->setToolTip(toolTip);
|
action->setToolTip(toolTip);
|
||||||
menu->addAction(ActionManager::registerAction(action, CallgrindRemoteActionId),
|
menu->addAction(ActionManager::registerAction(action, CallgrindRemoteActionId),
|
||||||
Debugger::Constants::G_ANALYZER_REMOTE_TOOLS);
|
Debugger::Constants::G_ANALYZER_REMOTE_TOOLS);
|
||||||
QObject::connect(action, &QAction::triggered, this, [this, action] {
|
QObject::connect(action, &QAction::triggered, this, [action] {
|
||||||
auto runConfig = RunConfiguration::startupRunConfiguration();
|
auto runConfig = RunConfiguration::startupRunConfiguration();
|
||||||
if (!runConfig) {
|
if (!runConfig) {
|
||||||
showCannotStartDialog(action->text());
|
showCannotStartDialog(action->text());
|
||||||
@@ -283,10 +282,11 @@ CallgrindTool::CallgrindTool()
|
|||||||
return;
|
return;
|
||||||
Debugger::selectPerspective(CallgrindPerspectiveId);
|
Debugger::selectPerspective(CallgrindPerspectiveId);
|
||||||
auto runControl = new RunControl(runConfig, CALLGRIND_RUN_MODE);
|
auto runControl = new RunControl(runConfig, CALLGRIND_RUN_MODE);
|
||||||
|
if (auto creator = RunControl::producer(runConfig, CALLGRIND_RUN_MODE))
|
||||||
|
creator(runControl);
|
||||||
const auto runnable = dlg.runnable();
|
const auto runnable = dlg.runnable();
|
||||||
runControl->setRunnable(runnable);
|
runControl->setRunnable(runnable);
|
||||||
runControl->setDisplayName(runnable.executable);
|
runControl->setDisplayName(runnable.executable);
|
||||||
createRunTool(runControl);
|
|
||||||
ProjectExplorerPlugin::startRunControl(runControl);
|
ProjectExplorerPlugin::startRunControl(runControl);
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -747,9 +747,9 @@ void CallgrindTool::updateEventCombo()
|
|||||||
m_eventCombo->addItem(ParseData::prettyStringForEvent(event));
|
m_eventCombo->addItem(ParseData::prettyStringForEvent(event));
|
||||||
}
|
}
|
||||||
|
|
||||||
ValgrindToolRunner *CallgrindTool::createRunTool(RunControl *runControl)
|
void CallgrindTool::setupRunner(CallgrindToolRunner *toolRunner)
|
||||||
{
|
{
|
||||||
auto toolRunner = new CallgrindToolRunner(runControl);
|
RunControl *runControl = toolRunner->runControl();
|
||||||
|
|
||||||
connect(toolRunner, &CallgrindToolRunner::parserDataReady, this, &CallgrindTool::takeParserDataFromRunControl);
|
connect(toolRunner, &CallgrindToolRunner::parserDataReady, this, &CallgrindTool::takeParserDataFromRunControl);
|
||||||
connect(runControl, &RunControl::stopped, this, &CallgrindTool::engineFinished);
|
connect(runControl, &RunControl::stopped, this, &CallgrindTool::engineFinished);
|
||||||
@@ -767,7 +767,7 @@ ValgrindToolRunner *CallgrindTool::createRunTool(RunControl *runControl)
|
|||||||
toolRunner->setToggleCollectFunction(m_toggleCollectFunction);
|
toolRunner->setToggleCollectFunction(m_toggleCollectFunction);
|
||||||
m_toggleCollectFunction.clear();
|
m_toggleCollectFunction.clear();
|
||||||
|
|
||||||
QTC_ASSERT(m_visualization, return toolRunner);
|
QTC_ASSERT(m_visualization, return);
|
||||||
|
|
||||||
// apply project settings
|
// apply project settings
|
||||||
if (IRunConfigurationAspect *analyzerAspect = runControl->runConfiguration()->extraAspect(ANALYZER_VALGRIND_SETTINGS)) {
|
if (IRunConfigurationAspect *analyzerAspect = runControl->runConfiguration()->extraAspect(ANALYZER_VALGRIND_SETTINGS)) {
|
||||||
@@ -787,8 +787,6 @@ ValgrindToolRunner *CallgrindTool::createRunTool(RunControl *runControl)
|
|||||||
m_loadExternalLogFile->setEnabled(false);
|
m_loadExternalLogFile->setEnabled(false);
|
||||||
clearTextMarks();
|
clearTextMarks();
|
||||||
doClear(true);
|
doClear(true);
|
||||||
|
|
||||||
return toolRunner;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void CallgrindTool::updateRunActions()
|
void CallgrindTool::updateRunActions()
|
||||||
@@ -974,12 +972,16 @@ void CallgrindTool::createTextMarks()
|
|||||||
|
|
||||||
static CallgrindTool *theCallgrindTool;
|
static CallgrindTool *theCallgrindTool;
|
||||||
|
|
||||||
|
void setupCallgrindRunner(CallgrindToolRunner *toolRunner)
|
||||||
|
{
|
||||||
|
theCallgrindTool->setupRunner(toolRunner);
|
||||||
|
}
|
||||||
|
|
||||||
void initCallgrindTool()
|
void initCallgrindTool()
|
||||||
{
|
{
|
||||||
theCallgrindTool = new CallgrindTool;
|
theCallgrindTool = new CallgrindTool;
|
||||||
|
|
||||||
auto producer = std::bind(&CallgrindTool::createRunTool, theCallgrindTool, _1);
|
RunControl::registerWorker<CallgrindToolRunner>(CALLGRIND_RUN_MODE, {});
|
||||||
RunControl::registerWorker(CALLGRIND_RUN_MODE, producer);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void destroyCallgrindTool()
|
void destroyCallgrindTool()
|
||||||
|
|||||||
@@ -111,8 +111,6 @@ using namespace ProjectExplorer;
|
|||||||
using namespace Utils;
|
using namespace Utils;
|
||||||
using namespace Valgrind::XmlProtocol;
|
using namespace Valgrind::XmlProtocol;
|
||||||
|
|
||||||
using namespace std::placeholders;
|
|
||||||
|
|
||||||
namespace Valgrind {
|
namespace Valgrind {
|
||||||
namespace Internal {
|
namespace Internal {
|
||||||
|
|
||||||
@@ -128,8 +126,7 @@ class MemcheckToolRunner : public ValgrindToolRunner
|
|||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
public:
|
public:
|
||||||
explicit MemcheckToolRunner(ProjectExplorer::RunControl *runControl,
|
explicit MemcheckToolRunner(ProjectExplorer::RunControl *runControl);
|
||||||
bool withGdb = false);
|
|
||||||
|
|
||||||
void start() override;
|
void start() override;
|
||||||
void stop() override;
|
void stop() override;
|
||||||
@@ -175,33 +172,6 @@ public:
|
|||||||
QSsh::SshConnection connection;
|
QSsh::SshConnection connection;
|
||||||
};
|
};
|
||||||
|
|
||||||
MemcheckToolRunner::MemcheckToolRunner(RunControl *runControl, bool withGdb)
|
|
||||||
: ValgrindToolRunner(runControl),
|
|
||||||
m_withGdb(withGdb),
|
|
||||||
m_localServerAddress(QHostAddress::LocalHost)
|
|
||||||
{
|
|
||||||
setDisplayName("MemcheckToolRunner");
|
|
||||||
connect(m_runner.parser(), &XmlProtocol::ThreadedParser::error,
|
|
||||||
this, &MemcheckToolRunner::parserError);
|
|
||||||
connect(m_runner.parser(), &XmlProtocol::ThreadedParser::suppressionCount,
|
|
||||||
this, &MemcheckToolRunner::suppressionCount);
|
|
||||||
|
|
||||||
if (withGdb) {
|
|
||||||
connect(&m_runner, &ValgrindRunner::valgrindStarted,
|
|
||||||
this, &MemcheckToolRunner::startDebugger);
|
|
||||||
connect(&m_runner, &ValgrindRunner::logMessageReceived,
|
|
||||||
this, &MemcheckToolRunner::appendLog);
|
|
||||||
// m_runner.disableXml();
|
|
||||||
} else {
|
|
||||||
connect(m_runner.parser(), &XmlProtocol::ThreadedParser::internalError,
|
|
||||||
this, &MemcheckToolRunner::internalParserError);
|
|
||||||
}
|
|
||||||
|
|
||||||
// We need a real address to connect to from the outside.
|
|
||||||
if (device()->type() != ProjectExplorer::Constants::DESKTOP_DEVICE_TYPE)
|
|
||||||
addStartDependency(new LocalAddressFinder(runControl, &m_localServerAddress));
|
|
||||||
}
|
|
||||||
|
|
||||||
QString MemcheckToolRunner::progressTitle() const
|
QString MemcheckToolRunner::progressTitle() const
|
||||||
{
|
{
|
||||||
return tr("Analyzing Memory");
|
return tr("Analyzing Memory");
|
||||||
@@ -423,8 +393,7 @@ class MemcheckTool : public QObject
|
|||||||
public:
|
public:
|
||||||
MemcheckTool();
|
MemcheckTool();
|
||||||
|
|
||||||
RunWorker *createRunWorker(RunControl *runControl);
|
void setupRunner(MemcheckToolRunner *runTool);
|
||||||
|
|
||||||
void loadShowXmlLogFile(const QString &filePath, const QString &exitMsg);
|
void loadShowXmlLogFile(const QString &filePath, const QString &exitMsg);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
@@ -703,7 +672,8 @@ MemcheckTool::MemcheckTool()
|
|||||||
TaskHub::clearTasks(Debugger::Constants::ANALYZERTASK_ID);
|
TaskHub::clearTasks(Debugger::Constants::ANALYZERTASK_ID);
|
||||||
Debugger::selectPerspective(MemcheckPerspectiveId);
|
Debugger::selectPerspective(MemcheckPerspectiveId);
|
||||||
RunControl *rc = new RunControl(runConfig, MEMCHECK_RUN_MODE);
|
RunControl *rc = new RunControl(runConfig, MEMCHECK_RUN_MODE);
|
||||||
rc->createWorker(MEMCHECK_RUN_MODE);
|
if (auto creator = RunControl::producer(runConfig, MEMCHECK_RUN_MODE))
|
||||||
|
creator(rc);
|
||||||
const auto runnable = dlg.runnable();
|
const auto runnable = dlg.runnable();
|
||||||
rc->setRunnable(runnable);
|
rc->setRunnable(runnable);
|
||||||
rc->setDisplayName(runnable.executable);
|
rc->setDisplayName(runnable.executable);
|
||||||
@@ -963,13 +933,12 @@ void MemcheckTool::maybeActiveRunConfigurationChanged()
|
|||||||
updateFromSettings();
|
updateFromSettings();
|
||||||
}
|
}
|
||||||
|
|
||||||
RunWorker *MemcheckTool::createRunWorker(RunControl *runControl)
|
void MemcheckTool::setupRunner(MemcheckToolRunner *runTool)
|
||||||
{
|
{
|
||||||
|
RunControl *runControl = runTool->runControl();
|
||||||
m_errorModel.setRelevantFrameFinder(makeFrameFinder(transform(runControl->project()->files(Project::AllFiles),
|
m_errorModel.setRelevantFrameFinder(makeFrameFinder(transform(runControl->project()->files(Project::AllFiles),
|
||||||
&FileName::toString)));
|
&FileName::toString)));
|
||||||
|
|
||||||
auto runTool = new MemcheckToolRunner(runControl, runControl->runMode() == MEMCHECK_WITH_GDB_RUN_MODE);
|
|
||||||
|
|
||||||
connect(runTool, &MemcheckToolRunner::parserError, this, &MemcheckTool::parserError);
|
connect(runTool, &MemcheckToolRunner::parserError, this, &MemcheckTool::parserError);
|
||||||
connect(runTool, &MemcheckToolRunner::internalParserError, this, &MemcheckTool::internalParserError);
|
connect(runTool, &MemcheckToolRunner::internalParserError, this, &MemcheckTool::internalParserError);
|
||||||
connect(runTool, &MemcheckToolRunner::stopped, this, &MemcheckTool::engineFinished);
|
connect(runTool, &MemcheckToolRunner::stopped, this, &MemcheckTool::engineFinished);
|
||||||
@@ -997,8 +966,6 @@ RunWorker *MemcheckTool::createRunWorker(RunControl *runControl)
|
|||||||
});
|
});
|
||||||
m_suppressionActions.append(action);
|
m_suppressionActions.append(action);
|
||||||
}
|
}
|
||||||
|
|
||||||
return runTool;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void MemcheckTool::loadShowXmlLogFile(const QString &filePath, const QString &exitMsg)
|
void MemcheckTool::loadShowXmlLogFile(const QString &filePath, const QString &exitMsg)
|
||||||
@@ -1140,13 +1107,41 @@ void MemcheckTool::setBusyCursor(bool busy)
|
|||||||
|
|
||||||
static MemcheckTool *theMemcheckTool;
|
static MemcheckTool *theMemcheckTool;
|
||||||
|
|
||||||
|
MemcheckToolRunner::MemcheckToolRunner(RunControl *runControl)
|
||||||
|
: ValgrindToolRunner(runControl),
|
||||||
|
m_withGdb(runControl->runMode() == MEMCHECK_WITH_GDB_RUN_MODE),
|
||||||
|
m_localServerAddress(QHostAddress::LocalHost)
|
||||||
|
{
|
||||||
|
setDisplayName("MemcheckToolRunner");
|
||||||
|
connect(m_runner.parser(), &XmlProtocol::ThreadedParser::error,
|
||||||
|
this, &MemcheckToolRunner::parserError);
|
||||||
|
connect(m_runner.parser(), &XmlProtocol::ThreadedParser::suppressionCount,
|
||||||
|
this, &MemcheckToolRunner::suppressionCount);
|
||||||
|
|
||||||
|
if (m_withGdb) {
|
||||||
|
connect(&m_runner, &ValgrindRunner::valgrindStarted,
|
||||||
|
this, &MemcheckToolRunner::startDebugger);
|
||||||
|
connect(&m_runner, &ValgrindRunner::logMessageReceived,
|
||||||
|
this, &MemcheckToolRunner::appendLog);
|
||||||
|
// m_runner.disableXml();
|
||||||
|
} else {
|
||||||
|
connect(m_runner.parser(), &XmlProtocol::ThreadedParser::internalError,
|
||||||
|
this, &MemcheckToolRunner::internalParserError);
|
||||||
|
}
|
||||||
|
|
||||||
|
// We need a real address to connect to from the outside.
|
||||||
|
if (device()->type() != ProjectExplorer::Constants::DESKTOP_DEVICE_TYPE)
|
||||||
|
addStartDependency(new LocalAddressFinder(runControl, &m_localServerAddress));
|
||||||
|
|
||||||
|
theMemcheckTool->setupRunner(this);
|
||||||
|
}
|
||||||
|
|
||||||
void initMemcheckTool()
|
void initMemcheckTool()
|
||||||
{
|
{
|
||||||
theMemcheckTool = new MemcheckTool;
|
theMemcheckTool = new MemcheckTool;
|
||||||
|
|
||||||
auto producer = std::bind(&MemcheckTool::createRunWorker, theMemcheckTool, _1);
|
RunControl::registerWorker<MemcheckToolRunner>(MEMCHECK_RUN_MODE, {});
|
||||||
RunControl::registerWorker(MEMCHECK_RUN_MODE, producer);
|
RunControl::registerWorker<MemcheckToolRunner>(MEMCHECK_WITH_GDB_RUN_MODE, {});
|
||||||
RunControl::registerWorker(MEMCHECK_WITH_GDB_RUN_MODE, producer);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void destroyMemcheckTool()
|
void destroyMemcheckTool()
|
||||||
|
|||||||
Reference in New Issue
Block a user