Debugger: Dissolve Debugger::ActionDescription

ActionDescription was a horizontal layer of convenience functionality
covering (only) ex-AnalyzerBase based RunControl start scenarios
and gets in the way of target/tool orthogonalization.

So continue the path chosen with the removal of AnalyzerRunControl:
Remove ActionDescription by inlining into user code, then orthogonalize
tool-by-tool, then generalize again.

Change-Id: Ib597df3f4ad7b06bef06644458fa13ddca53afdb
Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
This commit is contained in:
hjk
2017-04-12 10:06:41 +02:00
parent e821b98c11
commit e063ca68d0
10 changed files with 192 additions and 214 deletions

View File

@@ -251,28 +251,47 @@ CallgrindTool::CallgrindTool(QObject *parent)
m_startAction = Debugger::createStartAction();
m_stopAction = Debugger::createStopAction();
ActionDescription desc;
desc.setToolTip(tr("Valgrind Function Profiler uses the "
"Callgrind tool to record function calls when a program runs."));
ActionContainer *menu = ActionManager::actionContainer(Debugger::Constants::M_DEBUG_ANALYZER);
QString toolTip = tr("Valgrind Function Profiler uses the "
"Callgrind tool to record function calls when a program runs.");
auto rcc = [this](RunConfiguration *runConfiguration, Id mode) {
return createRunControl(runConfiguration, mode);
};
if (!Utils::HostOsInfo::isWindowsHost()) {
desc.setText(tr("Valgrind Function Profiler"));
desc.setPerspectiveId(CallgrindPerspectiveId);
desc.setRunControlCreator([this](RunConfiguration *runConfiguration, Id) {
return createRunControl(runConfiguration, CALLGRIND_RUN_MODE);
Debugger::registerAction(CALLGRIND_RUN_MODE, rcc);
auto action = new QAction(tr("Valgrind Function Profiler"), this);
action->setToolTip(toolTip);
menu->addAction(ActionManager::registerAction(action, CallgrindLocalActionId),
Debugger::Constants::G_ANALYZER_TOOLS);
QObject::connect(action, &QAction::triggered, this, [action] {
if (!Debugger::wantRunTool(OptimizedMode, action->text()))
return;
Debugger::selectPerspective(CallgrindPerspectiveId);
ProjectExplorerPlugin::runStartupProject(CALLGRIND_RUN_MODE);
});
QObject::connect(m_startAction, &QAction::triggered, action, &QAction::triggered);
QObject::connect(m_startAction, &QAction::changed, action, [action, this] {
action->setEnabled(m_startAction->isEnabled());
});
desc.setToolMode(OptimizedMode);
desc.setRunMode(CALLGRIND_RUN_MODE);
desc.setMenuGroup(Debugger::Constants::G_ANALYZER_TOOLS);
Debugger::registerAction(CallgrindLocalActionId, desc, m_startAction);
}
desc.setText(tr("Valgrind Function Profiler (External Application)"));
desc.setPerspectiveId(CallgrindPerspectiveId);
desc.setCustomToolStarter([this](RunConfiguration *runConfig) {
Debugger::registerAction(CALLGRIND_RUN_MODE, rcc);
auto action = new QAction(tr("Valgrind Function Profiler (External Application)"), this);
action->setToolTip(toolTip);
menu->addAction(ActionManager::registerAction(action, CallgrindRemoteActionId),
Debugger::Constants::G_ANALYZER_REMOTE_TOOLS);
QObject::connect(action, &QAction::triggered, this, [this, action] {
RunConfiguration *runConfig = startupRunConfiguration();
if (!runConfig) {
showCannotStartDialog(action->text());
return;
}
StartRemoteDialog dlg;
if (dlg.exec() != QDialog::Accepted)
return;
Debugger::selectPerspective(CallgrindPerspectiveId);
ValgrindRunControl *rc = createRunControl(runConfig, CALLGRIND_RUN_MODE);
QTC_ASSERT(rc, return);
const auto runnable = dlg.runnable();
@@ -283,8 +302,6 @@ CallgrindTool::CallgrindTool(QObject *parent)
rc->setDisplayName(runnable.executable);
ProjectExplorerPlugin::startRunControl(rc);
});
desc.setMenuGroup(Debugger::Constants::G_ANALYZER_REMOTE_TOOLS);
Debugger::registerAction(CallgrindRemoteActionId, desc);
// If there is a CppEditor context menu add our own context menu actions.
if (ActionContainer *editorContextMenu =
@@ -360,7 +377,7 @@ CallgrindTool::CallgrindTool(QObject *parent)
//
// load external log file
auto action = m_loadExternalLogFile = new QAction(this);
action = m_loadExternalLogFile = new QAction(this);
action->setIcon(Utils::Icons::OPENFILE.icon());
action->setToolTip(tr("Load External Log File"));
connect(action, &QAction::triggered, this, &CallgrindTool::loadExternalLogFile);

View File

@@ -57,6 +57,7 @@
#include <projectexplorer/session.h>
#include <projectexplorer/buildconfiguration.h>
#include <coreplugin/actionmanager/actioncontainer.h>
#include <coreplugin/actionmanager/actioncontainer.h>
#include <coreplugin/actionmanager/actionmanager.h>
#include <coreplugin/actionmanager/command.h>
@@ -87,6 +88,7 @@
#include <QString>
#include <QToolButton>
using namespace Core;
using namespace Debugger;
using namespace ProjectExplorer;
using namespace Utils;
@@ -390,37 +392,66 @@ MemcheckTool::MemcheckTool(QObject *parent)
connect(m_filterMenu, &QMenu::triggered, this, &MemcheckTool::updateErrorFilter);
filterButton->setMenu(m_filterMenu);
ActionDescription desc;
desc.setToolTip(tr("Valgrind Analyze Memory uses the "
"Memcheck tool to find memory leaks."));
ActionContainer *menu = ActionManager::actionContainer(Debugger::Constants::M_DEBUG_ANALYZER);
QString toolTip = tr("Valgrind Analyze Memory uses the Memcheck tool to find memory leaks.");
if (!Utils::HostOsInfo::isWindowsHost()) {
desc.setText(tr("Valgrind Memory Analyzer"));
desc.setPerspectiveId(MemcheckPerspectiveId);
desc.setRunControlCreator(std::bind(&MemcheckTool::createRunControl, this, _1, _2));
desc.setToolMode(DebugMode);
desc.setRunMode(MEMCHECK_RUN_MODE);
desc.setMenuGroup(Debugger::Constants::G_ANALYZER_TOOLS);
Debugger::registerAction("Memcheck.Local", desc, m_startAction);
Debugger::registerAction(MEMCHECK_RUN_MODE, std::bind(&MemcheckTool::createRunControl, this, _1, _2));
action = new QAction(this);
action->setText(tr("Valgrind Memory Analyzer"));
action->setToolTip(toolTip);
menu->addAction(ActionManager::registerAction(action, "Memcheck.Local"),
Debugger::Constants::G_ANALYZER_TOOLS);
QObject::connect(action, &QAction::triggered, this, [action] {
if (!Debugger::wantRunTool(DebugMode, action->text()))
return;
TaskHub::clearTasks(Debugger::Constants::ANALYZERTASK_ID);
Debugger::selectPerspective(MemcheckPerspectiveId);
ProjectExplorerPlugin::runStartupProject(MEMCHECK_RUN_MODE);
});
QObject::connect(m_startAction, &QAction::triggered, action, &QAction::triggered);
QObject::connect(m_startAction, &QAction::changed, action, [action, this] {
action->setEnabled(m_startAction->isEnabled());
});
desc.setText(tr("Valgrind Memory Analyzer with GDB"));
desc.setToolTip(tr("Valgrind Analyze Memory with GDB uses the "
Debugger::registerAction(MEMCHECK_WITH_GDB_RUN_MODE, std::bind(&MemcheckTool::createRunControl, this, _1, _2));
action = new QAction(this);
action->setText(tr("Valgrind Memory Analyzer with GDB"));
action->setToolTip(tr("Valgrind Analyze Memory with GDB uses the "
"Memcheck tool to find memory leaks.\nWhen a problem is detected, "
"the application is interrupted and can be debugged."));
desc.setPerspectiveId(MemcheckPerspectiveId);
desc.setRunControlCreator(std::bind(&MemcheckTool::createRunControl, this, _1, _2));
desc.setToolMode(DebugMode);
desc.setRunMode(MEMCHECK_WITH_GDB_RUN_MODE);
desc.setMenuGroup(Debugger::Constants::G_ANALYZER_TOOLS);
Debugger::registerAction("MemcheckWithGdb.Local", desc, m_startWithGdbAction);
menu->addAction(ActionManager::registerAction(action, "MemcheckWithGdb.Local"),
Debugger::Constants::G_ANALYZER_TOOLS);
QObject::connect(action, &QAction::triggered, this, [action] {
if (!Debugger::wantRunTool(DebugMode, action->text()))
return;
TaskHub::clearTasks(Debugger::Constants::ANALYZERTASK_ID);
Debugger::selectPerspective(MemcheckPerspectiveId);
ProjectExplorerPlugin::runStartupProject(MEMCHECK_WITH_GDB_RUN_MODE);
});
QObject::connect(m_startWithGdbAction, &QAction::triggered, action, &QAction::triggered);
QObject::connect(m_startWithGdbAction, &QAction::changed, action, [action, this] {
action->setEnabled(m_startWithGdbAction->isEnabled());
});
}
desc.setText(tr("Valgrind Memory Analyzer (External Application)"));
desc.setPerspectiveId(MemcheckPerspectiveId);
desc.setCustomToolStarter([this](ProjectExplorer::RunConfiguration *runConfig) {
Debugger::registerAction(MEMCHECK_RUN_MODE, std::bind(&MemcheckTool::createRunControl, this, _1, _2));
action = new QAction(this);
action->setText(tr("Valgrind Memory Analyzer (External Application)"));
action->setToolTip(toolTip);
menu->addAction(ActionManager::registerAction(action, "Memcheck.Remote"),
Debugger::Constants::G_ANALYZER_REMOTE_TOOLS);
QObject::connect(action, &QAction::triggered, this, [this, action] {
RunConfiguration *runConfig = startupRunConfiguration();
if (!runConfig) {
showCannotStartDialog(action->text());
return;
}
StartRemoteDialog dlg;
if (dlg.exec() != QDialog::Accepted)
return;
TaskHub::clearTasks(Debugger::Constants::ANALYZERTASK_ID);
Debugger::selectPerspective(MemcheckPerspectiveId);
RunControl *rc = createRunControl(runConfig, MEMCHECK_RUN_MODE);
QTC_ASSERT(rc, return);
const auto runnable = dlg.runnable();
@@ -431,8 +462,6 @@ MemcheckTool::MemcheckTool(QObject *parent)
rc->setDisplayName(runnable.executable);
ProjectExplorerPlugin::startRunControl(rc);
});
desc.setMenuGroup(Debugger::Constants::G_ANALYZER_REMOTE_TOOLS);
Debugger::registerAction("Memcheck.Remote", desc);
ToolbarDescription toolbar;
toolbar.addAction(m_startAction);