Commit 92ec05c9 authored by hjk's avatar hjk

Valgrind: Start custom actions more directly

This does not need to go through the PE machinery.

Change-Id: If0b2fde5309d7e119e8ac27245a22939b68d847d
Reviewed-by: default avatarChristian Stenger <christian.stenger@theqtcompany.com>
parent 8a1c603c
......@@ -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);
......
......@@ -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();
......
......@@ -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()
......
......@@ -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);
......
......@@ -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<ValgrindBaseSettings *>(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,
......
......@@ -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<void> m_progress;
bool m_isCustomStart;
private slots:
void handleProgressCanceled();
......
......@@ -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;
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);
return false;
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);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment