forked from qt-creator/qt-creator
Debugger: Fix handling of some actions after multiinferior split
The pattern used is some inactive/invible global action with a command to put in the menus, and per-engine action "overloads" to reflect the active engine's state once there is an engine. Task-number: QTCREATORBUG-21454 Change-Id: I861a42994849ef9f0b51fb7b1608f14fa7fa9d7c Reviewed-by: Orgad Shaneh <orgads@gmail.com> Reviewed-by: Eike Ziller <eike.ziller@qt.io>
This commit is contained in:
@@ -59,7 +59,12 @@ const char RUNTOSELECTEDFUNCTION[] = "Debugger.RunToSelectedFunction";
|
||||
const char JUMPTOLINE[] = "Debugger.JumpToLine";
|
||||
const char RETURNFROMFUNCTION[] = "Debugger.ReturnFromFunction";
|
||||
const char RESET[] = "Debugger.Reset";
|
||||
const char WATCH[] = "Debugger.AddToWatch";
|
||||
const char DETACH[] = "Debugger.Detach";
|
||||
const char OPERATE_BY_INSTRUCTION[] = "Debugger.OperateByInstruction";
|
||||
const char OPEN_MEMORY_EDITOR[] = "Debugger.Views.OpenMemoryEditor";
|
||||
const char FRAME_UP[] = "Debugger.FrameUp";
|
||||
const char FRAME_DOWN[] = "Debugger.FrameDown";
|
||||
const char QML_SHOW_APP_ON_TOP[] = "Debugger.QmlShowAppOnTop";
|
||||
const char QML_SELECTTOOL[] = "Debugger.QmlSelectTool";
|
||||
const char QML_ZOOMTOOL[] = "Debugger.QmlZoomTool";
|
||||
|
@@ -302,6 +302,11 @@ public:
|
||||
ActionManager::registerAction(&m_returnFromFunctionAction, Constants::RETURNFROMFUNCTION, m_context);
|
||||
ActionManager::registerAction(&m_detachAction, Constants::DETACH, m_context);
|
||||
ActionManager::registerAction(&m_resetAction, Constants::RESET, m_context);
|
||||
ActionManager::registerAction(&m_watchAction, Constants::WATCH, m_context);
|
||||
ActionManager::registerAction(&m_operateByInstructionAction, Constants::OPERATE_BY_INSTRUCTION, m_context);
|
||||
ActionManager::registerAction(&m_openMemoryEditorAction, Constants::OPEN_MEMORY_EDITOR, m_context);
|
||||
ActionManager::registerAction(&m_frameUpAction, Constants::FRAME_UP, m_context);
|
||||
ActionManager::registerAction(&m_frameDownAction, Constants::FRAME_DOWN, m_context);
|
||||
}
|
||||
|
||||
~DebuggerEnginePrivate()
|
||||
@@ -319,6 +324,11 @@ public:
|
||||
ActionManager::unregisterAction(&m_returnFromFunctionAction, Constants::RETURNFROMFUNCTION);
|
||||
ActionManager::unregisterAction(&m_detachAction, Constants::DETACH);
|
||||
ActionManager::unregisterAction(&m_resetAction, Constants::RESET);
|
||||
ActionManager::unregisterAction(&m_watchAction, Constants::WATCH);
|
||||
ActionManager::unregisterAction(&m_operateByInstructionAction, Constants::OPERATE_BY_INSTRUCTION);
|
||||
ActionManager::unregisterAction(&m_openMemoryEditorAction, Constants::OPEN_MEMORY_EDITOR);
|
||||
ActionManager::unregisterAction(&m_frameUpAction, Constants::FRAME_UP);
|
||||
ActionManager::unregisterAction(&m_frameDownAction, Constants::FRAME_DOWN);
|
||||
destroyPerspective();
|
||||
|
||||
delete m_logWindow;
|
||||
@@ -518,6 +528,10 @@ public:
|
||||
QAction m_runToLineAction{tr("Run to Line")}; // In the debug menu
|
||||
QAction m_runToSelectedFunctionAction{tr("Run to Selected Function")};
|
||||
QAction m_jumpToLineAction{tr("Jump to Line")};
|
||||
QAction m_frameUpAction{tr("Move to Calling Frame")};
|
||||
QAction m_frameDownAction{tr("Move to Called Frame")};
|
||||
QAction m_openMemoryEditorAction{tr("Memory...")};
|
||||
|
||||
// In the Debug menu.
|
||||
QAction m_returnFromFunctionAction{tr("Immediately Return From Inner Function")};
|
||||
QAction m_stepOverAction{tr("Step Over")};
|
||||
@@ -569,10 +583,22 @@ void DebuggerEnginePrivate::setupViews()
|
||||
"instructions and the source location view also shows the "
|
||||
"disassembled instructions."));
|
||||
m_operateByInstructionAction.setIconVisibleInMenu(false);
|
||||
|
||||
connect(&m_operateByInstructionAction, &QAction::triggered,
|
||||
m_engine, &DebuggerEngine::operateByInstructionTriggered);
|
||||
|
||||
m_frameDownAction.setEnabled(true);
|
||||
connect(&m_frameDownAction, &QAction::triggered,
|
||||
m_engine, &DebuggerEngine::handleFrameDown);
|
||||
|
||||
m_frameUpAction.setEnabled(true);
|
||||
connect(&m_frameUpAction, &QAction::triggered,
|
||||
m_engine, &DebuggerEngine::handleFrameUp);
|
||||
|
||||
m_openMemoryEditorAction.setEnabled(true);
|
||||
m_openMemoryEditorAction.setVisible(m_engine->hasCapability(ShowMemoryCapability));
|
||||
connect(&m_openMemoryEditorAction, &QAction::triggered,
|
||||
m_engine, &DebuggerEngine::openMemoryEditor);
|
||||
|
||||
QTC_ASSERT(m_state == DebuggerNotReady || m_state == DebuggerFinished, qDebug() << m_state);
|
||||
m_progress.setProgressValue(200);
|
||||
|
||||
@@ -753,6 +779,9 @@ void DebuggerEnginePrivate::setupViews()
|
||||
connect(&m_jumpToLineAction, &QAction::triggered,
|
||||
m_engine, &DebuggerEngine::handleExecJumpToLine);
|
||||
|
||||
connect(&m_watchAction, &QAction::triggered,
|
||||
m_engine, &DebuggerEngine::handleAddToWatchWindow);
|
||||
|
||||
m_perspective->addToolBarAction(&m_recordForReverseOperationAction);
|
||||
connect(&m_recordForReverseOperationAction, &QAction::triggered,
|
||||
m_engine, &DebuggerEngine::handleRecordReverse);
|
||||
|
@@ -640,23 +640,6 @@ struct Callback
|
||||
std::function<void()> cb;
|
||||
};
|
||||
|
||||
struct Action : public QAction
|
||||
{
|
||||
Action(const QString &name, const QIcon &icon = {}) : QAction(name) { setIcon(icon); }
|
||||
Action(const QString &name, const QIcon &icon, Callback cb, const QString &toolTip = {})
|
||||
: Action(name, icon)
|
||||
{
|
||||
m_cb = cb;
|
||||
setToolTip(toolTip);
|
||||
connect(this, &QAction::triggered, this, &Action::onTriggered);
|
||||
}
|
||||
void onTriggered()
|
||||
{
|
||||
m_cb.cb();
|
||||
}
|
||||
Callback m_cb;
|
||||
};
|
||||
|
||||
class DebuggerPluginPrivate : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
@@ -760,12 +743,9 @@ public:
|
||||
|
||||
// In the Debug menu.
|
||||
QAction m_startAndBreakOnMain{tr("Start and Break on Main")};
|
||||
Action m_watchAction{tr("Add Expression Evaluator"), {}, &DebuggerEngine::handleAddToWatchWindow};
|
||||
QAction m_watchAction{tr("Add Expression Evaluator")};
|
||||
Command *m_watchCommand = nullptr;
|
||||
QAction m_breakAction{tr("Toggle Breakpoint")};
|
||||
Action m_frameUpAction{tr("Move to Calling Frame"), {}, &DebuggerEngine::handleFrameDown};
|
||||
Action m_frameDownAction{tr("Move to Called Frame"), {}, &DebuggerEngine::handleFrameUp};
|
||||
Action m_openMemoryEditorAction{tr("Memory..."), {}, &DebuggerEngine::openMemoryEditor};
|
||||
|
||||
BreakpointManager m_breakpointManager;
|
||||
QPointer<BaseTreeView> m_breakpointManagerView;
|
||||
@@ -1025,9 +1005,10 @@ bool DebuggerPluginPrivate::initialize(const QStringList &arguments,
|
||||
// Populate Windows->Views menu with standard actions.
|
||||
Context debugcontext(Constants::C_DEBUGMODE);
|
||||
|
||||
Command *cmd = ActionManager::registerAction(&m_openMemoryEditorAction,
|
||||
"Debugger.Views.OpenMemoryEditor", debugcontext);
|
||||
cmd->setAttribute(Command::CA_Hide);
|
||||
act = new QAction(tr("Memory..."), this);
|
||||
act->setVisible(false);
|
||||
act->setEnabled(false);
|
||||
Command *cmd = ActionManager::registerAction(act, Constants::OPEN_MEMORY_EDITOR);
|
||||
|
||||
TaskHub::addCategory(TASK_CATEGORY_DEBUGGER_DEBUGINFO,
|
||||
tr("Debug Information"));
|
||||
@@ -1281,10 +1262,36 @@ bool DebuggerPluginPrivate::initialize(const QStringList &arguments,
|
||||
|
||||
debugMenu->addSeparator();
|
||||
|
||||
ActionManager::registerAction(&m_frameDownAction,
|
||||
"Debugger.FrameDown", cppDebuggercontext);
|
||||
ActionManager::registerAction(&m_frameUpAction,
|
||||
"Debugger.FrameUp", cppDebuggercontext);
|
||||
act = new QAction(this);
|
||||
act->setText(QCoreApplication::translate("Debugger::Internal::DebuggerPluginPrivate",
|
||||
"Move to Calling Frame"));
|
||||
act->setEnabled(false);
|
||||
act->setVisible(false);
|
||||
ActionManager::registerAction(act, Constants::FRAME_UP);
|
||||
|
||||
act = new QAction(this);
|
||||
act->setText(QCoreApplication::translate("Debugger::Internal::DebuggerPluginPrivate",
|
||||
"Move to Called Frame"));
|
||||
act->setEnabled(false);
|
||||
act->setVisible(false);
|
||||
ActionManager::registerAction(act, Constants::FRAME_DOWN);
|
||||
|
||||
act = new QAction(this);
|
||||
act->setText(QCoreApplication::translate("Debugger::Internal::DebuggerPluginPrivate",
|
||||
"Memory..."));
|
||||
act->setEnabled(false);
|
||||
act->setVisible(true);
|
||||
ActionManager::registerAction(act, Constants::FRAME_UP);
|
||||
|
||||
act = new QAction(this);
|
||||
act->setText(QCoreApplication::translate("Debugger::Internal::DebuggerPluginPrivate",
|
||||
"Operate by Instruction"));
|
||||
act->setEnabled(false);
|
||||
act->setVisible(false);
|
||||
act->setCheckable(true);
|
||||
act->setChecked(false);
|
||||
cmd = ActionManager::registerAction(act, Constants::OPERATE_BY_INSTRUCTION);
|
||||
debugMenu->addAction(cmd);
|
||||
|
||||
cmd = ActionManager::registerAction(&m_breakAction, "Debugger.ToggleBreak");
|
||||
cmd->setDefaultKeySequence(QKeySequence(useMacShortcuts ? tr("F8") : tr("F9")));
|
||||
@@ -1310,11 +1317,14 @@ bool DebuggerPluginPrivate::initialize(const QStringList &arguments,
|
||||
|
||||
debugMenu->addSeparator();
|
||||
|
||||
cmd = m_watchCommand = ActionManager::registerAction(&m_watchAction, "Debugger.AddToWatch",
|
||||
Context(CppEditor::Constants::CPPEDITOR_ID, QmlJSEditor::Constants::C_QMLJSEDITOR_ID));
|
||||
//cmd->setDefaultKeySequence(QKeySequence(tr("Ctrl+D,Ctrl+W")));
|
||||
cmd = m_watchCommand = ActionManager::registerAction(&m_watchAction, Constants::WATCH);
|
||||
debugMenu->addAction(cmd);
|
||||
|
||||
// FIXME: Re-vive watcher creation before engine runs.
|
||||
// connect(&m_watchAction, &QAction::triggered, this, [&] {
|
||||
// QTC_CHECK(false);
|
||||
// });
|
||||
|
||||
addGdbOptionPages(&m_optionPages);
|
||||
addCdbOptionPages(&m_optionPages);
|
||||
m_optionPages.append(new LocalsAndExpressionsOptionsPage);
|
||||
|
Reference in New Issue
Block a user