From 92ec05c9bd083c13d6972ccc729c8a8a755b01f4 Mon Sep 17 00:00:00 2001 From: hjk Date: Fri, 19 Jun 2015 08:34:46 +0200 Subject: [PATCH] Valgrind: Start custom actions more directly This does not need to go through the PE machinery. Change-Id: If0b2fde5309d7e119e8ac27245a22939b68d847d Reviewed-by: Christian Stenger --- src/plugins/valgrind/callgrindtool.cpp | 6 ++-- src/plugins/valgrind/callgrindtool.h | 3 +- src/plugins/valgrind/memchecktool.cpp | 2 +- src/plugins/valgrind/memchecktool.h | 4 +-- src/plugins/valgrind/valgrindengine.cpp | 5 +-- src/plugins/valgrind/valgrindengine.h | 2 ++ src/plugins/valgrind/valgrindplugin.cpp | 48 +++++++++++++++---------- 7 files changed, 42 insertions(+), 28 deletions(-) diff --git a/src/plugins/valgrind/callgrindtool.cpp b/src/plugins/valgrind/callgrindtool.cpp index 0aefec59b87..b792cd2dd1e 100644 --- a/src/plugins/valgrind/callgrindtool.cpp +++ b/src/plugins/valgrind/callgrindtool.cpp @@ -120,7 +120,7 @@ public: void doClear(bool clearParseData); void updateEventCombo(); - AnalyzerRunControl *createRunControl(const AnalyzerStartParameters &sp, + ValgrindRunControl *createRunControl(const AnalyzerStartParameters &sp, RunConfiguration *runConfiguration = 0); signals: @@ -514,13 +514,13 @@ CallgrindTool::~CallgrindTool() delete d; } -AnalyzerRunControl *CallgrindTool::createRunControl(const AnalyzerStartParameters &sp, +ValgrindRunControl *CallgrindTool::createRunControl(const AnalyzerStartParameters &sp, RunConfiguration *runConfiguration) { return d->createRunControl(sp, runConfiguration); } -AnalyzerRunControl *CallgrindToolPrivate::createRunControl(const AnalyzerStartParameters &sp, +ValgrindRunControl *CallgrindToolPrivate::createRunControl(const AnalyzerStartParameters &sp, RunConfiguration *runConfiguration) { CallgrindRunControl *rc = new CallgrindRunControl(sp, runConfiguration); diff --git a/src/plugins/valgrind/callgrindtool.h b/src/plugins/valgrind/callgrindtool.h index 930eff7e324..0018ecab2aa 100644 --- a/src/plugins/valgrind/callgrindtool.h +++ b/src/plugins/valgrind/callgrindtool.h @@ -40,6 +40,7 @@ const char CallgrindToolId[] = "Callgrind"; const char CallgrindLocalActionId[] = "Callgrind.Local"; const char CallgrindRemoteActionId[] = "Callgrind.Remote"; +class ValgrindRunControl; class CallgrindToolPrivate; class CallgrindTool : public QObject @@ -50,7 +51,7 @@ public: CallgrindTool(QObject *parent); ~CallgrindTool(); - Analyzer::AnalyzerRunControl *createRunControl(const Analyzer::AnalyzerStartParameters &sp, + ValgrindRunControl *createRunControl(const Analyzer::AnalyzerStartParameters &sp, ProjectExplorer::RunConfiguration *runConfiguration = 0); QWidget *createWidgets(); diff --git a/src/plugins/valgrind/memchecktool.cpp b/src/plugins/valgrind/memchecktool.cpp index b409a0d170b..04d4085e2e6 100644 --- a/src/plugins/valgrind/memchecktool.cpp +++ b/src/plugins/valgrind/memchecktool.cpp @@ -427,7 +427,7 @@ QWidget *MemcheckTool::createWidgets() return widget; } -AnalyzerRunControl *MemcheckTool::createRunControl(const AnalyzerStartParameters &sp, +MemcheckRunControl *MemcheckTool::createRunControl(const AnalyzerStartParameters &sp, RunConfiguration *runConfiguration) { m_frameFinder->setFiles(runConfiguration ? runConfiguration->target() diff --git a/src/plugins/valgrind/memchecktool.h b/src/plugins/valgrind/memchecktool.h index 40e4ecea09a..6e9cdaae1c8 100644 --- a/src/plugins/valgrind/memchecktool.h +++ b/src/plugins/valgrind/memchecktool.h @@ -85,8 +85,8 @@ public: QWidget *createWidgets(); - Analyzer::AnalyzerRunControl *createRunControl(const Analyzer::AnalyzerStartParameters &sp, - ProjectExplorer::RunConfiguration *runConfiguration); + MemcheckRunControl *createRunControl(const Analyzer::AnalyzerStartParameters &sp, + ProjectExplorer::RunConfiguration *runConfiguration); private slots: void settingsDestroyed(QObject *settings); diff --git a/src/plugins/valgrind/valgrindengine.cpp b/src/plugins/valgrind/valgrindengine.cpp index cac9fb67e42..0de0d0b7280 100644 --- a/src/plugins/valgrind/valgrindengine.cpp +++ b/src/plugins/valgrind/valgrindengine.cpp @@ -60,13 +60,14 @@ ValgrindRunControl::ValgrindRunControl(const AnalyzerStartParameters &sp, m_settings(0), m_isStopping(false) { + m_isCustomStart = false; + if (runConfiguration) if (IRunConfigurationAspect *aspect = runConfiguration->extraAspect(ANALYZER_VALGRIND_SETTINGS)) m_settings = qobject_cast(aspect->currentSettings()); if (!m_settings) m_settings = ValgrindPlugin::globalSettings(); - } ValgrindRunControl::~ValgrindRunControl() @@ -100,7 +101,7 @@ bool ValgrindRunControl::startEngine() run->setDebuggeeArguments(sp.debuggeeArgs); run->setEnvironment(sp.environment); run->setConnectionParameters(sp.connParams); - run->setUseStartupProject(sp.useStartupProject); + run->setUseStartupProject(!m_isCustomStart); run->setLocalRunMode(sp.localRunMode); connect(run, &ValgrindRunner::processOutputReceived, diff --git a/src/plugins/valgrind/valgrindengine.h b/src/plugins/valgrind/valgrindengine.h index d40380ae614..c952fe8b3b8 100644 --- a/src/plugins/valgrind/valgrindengine.h +++ b/src/plugins/valgrind/valgrindengine.h @@ -56,6 +56,7 @@ public: void stopEngine(); QString executable() const; + void setCustomStart() { m_isCustomStart = true; } protected: virtual QString progressTitle() const = 0; @@ -64,6 +65,7 @@ protected: ValgrindBaseSettings *m_settings; QFutureInterface m_progress; + bool m_isCustomStart; private slots: void handleProgressCanceled(); diff --git a/src/plugins/valgrind/valgrindplugin.cpp b/src/plugins/valgrind/valgrindplugin.cpp index cb773871368..f8efdf33527 100644 --- a/src/plugins/valgrind/valgrindplugin.cpp +++ b/src/plugins/valgrind/valgrindplugin.cpp @@ -33,6 +33,7 @@ #include "callgrindtool.h" #include "memchecktool.h" +#include "memcheckengine.h" #include "valgrindruncontrolfactory.h" #include "valgrindsettings.h" #include "valgrindconfigwidget.h" @@ -109,22 +110,18 @@ ValgrindPlugin::~ValgrindPlugin() theGlobalSettings = 0; } -static void customStart(ProjectExplorer::RunMode runMode) +static bool fillParameters(AnalyzerStartParameters *sp) { StartRemoteDialog dlg; if (dlg.exec() != QDialog::Accepted) - return; + return false; - AnalyzerStartParameters sp; - sp.useStartupProject = false; - sp.connParams = dlg.sshParams(); - sp.debuggee = dlg.executable(); - sp.debuggeeArgs = dlg.arguments(); - sp.displayName = dlg.executable(); - sp.workingDirectory = dlg.workingDirectory(); - - AnalyzerRunControl *rc = AnalyzerManager::createRunControl(sp, 0); - ProjectExplorerPlugin::startRunControl(rc, runMode); + sp->connParams = dlg.sshParams(); + sp->debuggee = dlg.executable(); + sp->debuggeeArgs = dlg.arguments(); + sp->displayName = dlg.executable(); + sp->workingDirectory = dlg.workingDirectory(); + return false; } bool ValgrindPlugin::initialize(const QStringList &, QString *) @@ -151,7 +148,7 @@ void ValgrindPlugin::extensionsInitialized() auto mcTool = new MemcheckTool(this); auto mcWidgetCreator = [mcTool] { return mcTool->createWidgets(); }; auto mcRunControlCreator = [mcTool](const AnalyzerStartParameters &sp, - ProjectExplorer::RunConfiguration *runConfiguration) { + ProjectExplorer::RunConfiguration *runConfiguration) -> AnalyzerRunControl * { return mcTool->createRunControl(sp, runConfiguration); }; @@ -212,9 +209,15 @@ void ValgrindPlugin::extensionsInitialized() action->setActionId("Memcheck.Remote"); action->setToolId("Memcheck"); action->setWidgetCreator(mcWidgetCreator); - action->setRunControlCreator(mcRunControlCreator); - action->setCustomToolStarter([] { customStart(MemcheckRunMode); }); - action->setRunMode(MemcheckRunMode); + action->setCustomToolStarter([mcTool] { + AnalyzerStartParameters sp; + if (!fillParameters(&sp)) + return; + ValgrindRunControl *rc = mcTool->createRunControl(sp, 0); + QTC_ASSERT(rc, return); + rc->setCustomStart(); + ProjectExplorerPlugin::startRunControl(rc, MemcheckRunMode); + }); action->setText(tr("Valgrind Memory Analyzer (External Remote Application)")); action->setToolTip(memcheckToolTip); action->setMenuGroup(Analyzer::Constants::G_ANALYZER_REMOTE_TOOLS); @@ -224,9 +227,16 @@ void ValgrindPlugin::extensionsInitialized() action->setActionId(CallgrindRemoteActionId); action->setToolId(CallgrindToolId); action->setWidgetCreator(cgWidgetCreator); - action->setRunControlCreator(cgRunControlCreator); - action->setCustomToolStarter([] { customStart(CallgrindRunMode); }); - action->setRunMode(CallgrindRunMode); + action->setCustomToolStarter([cgTool] { + AnalyzerStartParameters sp; + if (!fillParameters(&sp)) + return; + ValgrindRunControl *rc = cgTool->createRunControl(sp, 0); + QTC_ASSERT(rc, return); + rc->setCustomStart(); + ProjectExplorerPlugin::startRunControl(rc, CallgrindRunMode); + }); + action->setText(tr("Valgrind Function Profiler (External Remote Application)")); action->setToolTip(callgrindToolTip); action->setMenuGroup(Analyzer::Constants::G_ANALYZER_REMOTE_TOOLS);