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 JUMPTOLINE[] = "Debugger.JumpToLine";
|
||||||
const char RETURNFROMFUNCTION[] = "Debugger.ReturnFromFunction";
|
const char RETURNFROMFUNCTION[] = "Debugger.ReturnFromFunction";
|
||||||
const char RESET[] = "Debugger.Reset";
|
const char RESET[] = "Debugger.Reset";
|
||||||
|
const char WATCH[] = "Debugger.AddToWatch";
|
||||||
const char DETACH[] = "Debugger.Detach";
|
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_SHOW_APP_ON_TOP[] = "Debugger.QmlShowAppOnTop";
|
||||||
const char QML_SELECTTOOL[] = "Debugger.QmlSelectTool";
|
const char QML_SELECTTOOL[] = "Debugger.QmlSelectTool";
|
||||||
const char QML_ZOOMTOOL[] = "Debugger.QmlZoomTool";
|
const char QML_ZOOMTOOL[] = "Debugger.QmlZoomTool";
|
||||||
|
@@ -302,6 +302,11 @@ public:
|
|||||||
ActionManager::registerAction(&m_returnFromFunctionAction, Constants::RETURNFROMFUNCTION, m_context);
|
ActionManager::registerAction(&m_returnFromFunctionAction, Constants::RETURNFROMFUNCTION, m_context);
|
||||||
ActionManager::registerAction(&m_detachAction, Constants::DETACH, m_context);
|
ActionManager::registerAction(&m_detachAction, Constants::DETACH, m_context);
|
||||||
ActionManager::registerAction(&m_resetAction, Constants::RESET, 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()
|
~DebuggerEnginePrivate()
|
||||||
@@ -319,6 +324,11 @@ public:
|
|||||||
ActionManager::unregisterAction(&m_returnFromFunctionAction, Constants::RETURNFROMFUNCTION);
|
ActionManager::unregisterAction(&m_returnFromFunctionAction, Constants::RETURNFROMFUNCTION);
|
||||||
ActionManager::unregisterAction(&m_detachAction, Constants::DETACH);
|
ActionManager::unregisterAction(&m_detachAction, Constants::DETACH);
|
||||||
ActionManager::unregisterAction(&m_resetAction, Constants::RESET);
|
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();
|
destroyPerspective();
|
||||||
|
|
||||||
delete m_logWindow;
|
delete m_logWindow;
|
||||||
@@ -518,6 +528,10 @@ public:
|
|||||||
QAction m_runToLineAction{tr("Run to Line")}; // In the debug menu
|
QAction m_runToLineAction{tr("Run to Line")}; // In the debug menu
|
||||||
QAction m_runToSelectedFunctionAction{tr("Run to Selected Function")};
|
QAction m_runToSelectedFunctionAction{tr("Run to Selected Function")};
|
||||||
QAction m_jumpToLineAction{tr("Jump to Line")};
|
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.
|
// In the Debug menu.
|
||||||
QAction m_returnFromFunctionAction{tr("Immediately Return From Inner Function")};
|
QAction m_returnFromFunctionAction{tr("Immediately Return From Inner Function")};
|
||||||
QAction m_stepOverAction{tr("Step Over")};
|
QAction m_stepOverAction{tr("Step Over")};
|
||||||
@@ -569,10 +583,22 @@ void DebuggerEnginePrivate::setupViews()
|
|||||||
"instructions and the source location view also shows the "
|
"instructions and the source location view also shows the "
|
||||||
"disassembled instructions."));
|
"disassembled instructions."));
|
||||||
m_operateByInstructionAction.setIconVisibleInMenu(false);
|
m_operateByInstructionAction.setIconVisibleInMenu(false);
|
||||||
|
|
||||||
connect(&m_operateByInstructionAction, &QAction::triggered,
|
connect(&m_operateByInstructionAction, &QAction::triggered,
|
||||||
m_engine, &DebuggerEngine::operateByInstructionTriggered);
|
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);
|
QTC_ASSERT(m_state == DebuggerNotReady || m_state == DebuggerFinished, qDebug() << m_state);
|
||||||
m_progress.setProgressValue(200);
|
m_progress.setProgressValue(200);
|
||||||
|
|
||||||
@@ -753,6 +779,9 @@ void DebuggerEnginePrivate::setupViews()
|
|||||||
connect(&m_jumpToLineAction, &QAction::triggered,
|
connect(&m_jumpToLineAction, &QAction::triggered,
|
||||||
m_engine, &DebuggerEngine::handleExecJumpToLine);
|
m_engine, &DebuggerEngine::handleExecJumpToLine);
|
||||||
|
|
||||||
|
connect(&m_watchAction, &QAction::triggered,
|
||||||
|
m_engine, &DebuggerEngine::handleAddToWatchWindow);
|
||||||
|
|
||||||
m_perspective->addToolBarAction(&m_recordForReverseOperationAction);
|
m_perspective->addToolBarAction(&m_recordForReverseOperationAction);
|
||||||
connect(&m_recordForReverseOperationAction, &QAction::triggered,
|
connect(&m_recordForReverseOperationAction, &QAction::triggered,
|
||||||
m_engine, &DebuggerEngine::handleRecordReverse);
|
m_engine, &DebuggerEngine::handleRecordReverse);
|
||||||
|
@@ -640,23 +640,6 @@ struct Callback
|
|||||||
std::function<void()> cb;
|
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
|
class DebuggerPluginPrivate : public QObject
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
@@ -760,12 +743,9 @@ public:
|
|||||||
|
|
||||||
// In the Debug menu.
|
// In the Debug menu.
|
||||||
QAction m_startAndBreakOnMain{tr("Start and Break on Main")};
|
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;
|
Command *m_watchCommand = nullptr;
|
||||||
QAction m_breakAction{tr("Toggle Breakpoint")};
|
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;
|
BreakpointManager m_breakpointManager;
|
||||||
QPointer<BaseTreeView> m_breakpointManagerView;
|
QPointer<BaseTreeView> m_breakpointManagerView;
|
||||||
@@ -1025,9 +1005,10 @@ bool DebuggerPluginPrivate::initialize(const QStringList &arguments,
|
|||||||
// Populate Windows->Views menu with standard actions.
|
// Populate Windows->Views menu with standard actions.
|
||||||
Context debugcontext(Constants::C_DEBUGMODE);
|
Context debugcontext(Constants::C_DEBUGMODE);
|
||||||
|
|
||||||
Command *cmd = ActionManager::registerAction(&m_openMemoryEditorAction,
|
act = new QAction(tr("Memory..."), this);
|
||||||
"Debugger.Views.OpenMemoryEditor", debugcontext);
|
act->setVisible(false);
|
||||||
cmd->setAttribute(Command::CA_Hide);
|
act->setEnabled(false);
|
||||||
|
Command *cmd = ActionManager::registerAction(act, Constants::OPEN_MEMORY_EDITOR);
|
||||||
|
|
||||||
TaskHub::addCategory(TASK_CATEGORY_DEBUGGER_DEBUGINFO,
|
TaskHub::addCategory(TASK_CATEGORY_DEBUGGER_DEBUGINFO,
|
||||||
tr("Debug Information"));
|
tr("Debug Information"));
|
||||||
@@ -1281,10 +1262,36 @@ bool DebuggerPluginPrivate::initialize(const QStringList &arguments,
|
|||||||
|
|
||||||
debugMenu->addSeparator();
|
debugMenu->addSeparator();
|
||||||
|
|
||||||
ActionManager::registerAction(&m_frameDownAction,
|
act = new QAction(this);
|
||||||
"Debugger.FrameDown", cppDebuggercontext);
|
act->setText(QCoreApplication::translate("Debugger::Internal::DebuggerPluginPrivate",
|
||||||
ActionManager::registerAction(&m_frameUpAction,
|
"Move to Calling Frame"));
|
||||||
"Debugger.FrameUp", cppDebuggercontext);
|
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 = ActionManager::registerAction(&m_breakAction, "Debugger.ToggleBreak");
|
||||||
cmd->setDefaultKeySequence(QKeySequence(useMacShortcuts ? tr("F8") : tr("F9")));
|
cmd->setDefaultKeySequence(QKeySequence(useMacShortcuts ? tr("F8") : tr("F9")));
|
||||||
@@ -1310,11 +1317,14 @@ bool DebuggerPluginPrivate::initialize(const QStringList &arguments,
|
|||||||
|
|
||||||
debugMenu->addSeparator();
|
debugMenu->addSeparator();
|
||||||
|
|
||||||
cmd = m_watchCommand = ActionManager::registerAction(&m_watchAction, "Debugger.AddToWatch",
|
cmd = m_watchCommand = ActionManager::registerAction(&m_watchAction, Constants::WATCH);
|
||||||
Context(CppEditor::Constants::CPPEDITOR_ID, QmlJSEditor::Constants::C_QMLJSEDITOR_ID));
|
|
||||||
//cmd->setDefaultKeySequence(QKeySequence(tr("Ctrl+D,Ctrl+W")));
|
|
||||||
debugMenu->addAction(cmd);
|
debugMenu->addAction(cmd);
|
||||||
|
|
||||||
|
// FIXME: Re-vive watcher creation before engine runs.
|
||||||
|
// connect(&m_watchAction, &QAction::triggered, this, [&] {
|
||||||
|
// QTC_CHECK(false);
|
||||||
|
// });
|
||||||
|
|
||||||
addGdbOptionPages(&m_optionPages);
|
addGdbOptionPages(&m_optionPages);
|
||||||
addCdbOptionPages(&m_optionPages);
|
addCdbOptionPages(&m_optionPages);
|
||||||
m_optionPages.append(new LocalsAndExpressionsOptionsPage);
|
m_optionPages.append(new LocalsAndExpressionsOptionsPage);
|
||||||
|
Reference in New Issue
Block a user