diff --git a/src/plugins/debugger/breakhandler.cpp b/src/plugins/debugger/breakhandler.cpp index 827cbaa1e14..35b1c30449d 100644 --- a/src/plugins/debugger/breakhandler.cpp +++ b/src/plugins/debugger/breakhandler.cpp @@ -2490,7 +2490,7 @@ void BreakpointManager::createBreakpointForEngine(const BreakpointParameters &pa engine->breakHandler()->tryClaimBreakpoint(gbp); } -void BreakpointManager::toggleBreakpoint(const ContextData &location, const QString &tracePointMessage) +void BreakpointManager::setOrRemoveBreakpoint(const ContextData &location, const QString &tracePointMessage) { QTC_ASSERT(location.isValid(), return); GlobalBreakpoint gbp = findBreakpointFromContext(location); @@ -2517,6 +2517,15 @@ void BreakpointManager::toggleBreakpoint(const ContextData &location, const QStr } } +void BreakpointManager::enableOrDisableBreakpoint(const ContextData &location) +{ + QTC_ASSERT(location.isValid(), return); + if (GlobalBreakpoint gbp = findBreakpointFromContext(location)) + gbp->setEnabled(!gbp->isEnabled()); + else + setOrRemoveBreakpoint(location); +} + GlobalBreakpoint BreakpointManager::findBreakpointFromContext(const ContextData &location) { int matchLevel = 0; diff --git a/src/plugins/debugger/breakhandler.h b/src/plugins/debugger/breakhandler.h index b20555cae45..3354b382ddc 100644 --- a/src/plugins/debugger/breakhandler.h +++ b/src/plugins/debugger/breakhandler.h @@ -304,7 +304,8 @@ public: static GlobalBreakpoint findBreakpointFromContext(const ContextData &location); static void claimBreakpointsForEngine(DebuggerEngine *engine); - static void toggleBreakpoint(const ContextData &location, const QString &tracePointMessage = QString()); + static void setOrRemoveBreakpoint(const ContextData &location, const QString &tracePointMessage = {}); + static void enableOrDisableBreakpoint(const ContextData &location); static void createBreakpointForEngine(const BreakpointParameters &data, DebuggerEngine *engine); static void editBreakpoint(const GlobalBreakpoint &gbp, QWidget *parent); diff --git a/src/plugins/debugger/debuggerengine.cpp b/src/plugins/debugger/debuggerengine.cpp index cc1c6d6396b..058c0a3f7ce 100644 --- a/src/plugins/debugger/debuggerengine.cpp +++ b/src/plugins/debugger/debuggerengine.cpp @@ -545,7 +545,8 @@ public: QAction m_returnFromFunctionAction{tr("Immediately Return From Inner Function")}; QAction m_stepOverAction{tr("Step Over")}; QAction m_watchAction{tr("Add Expression Evaluator")}; - QAction m_breakAction{tr("Toggle Breakpoint")}; + QAction m_setOrRemoveBreakpointAction{tr("Set or Remove Breakpoint")}; + QAction m_enableOrDisableBreakpointAction{tr("Enable or Disable Breakpoint")}; QAction m_resetAction{tr("Restart Debugging")}; OptionalAction m_operateByInstructionAction{tr("Operate by Instruction")}; QAction m_recordForReverseOperationAction{tr("Record Information to Allow Reversal of Direction")}; @@ -1412,7 +1413,8 @@ void DebuggerEnginePrivate::setInitialActionStates() m_detachAction.setEnabled(false); m_watchAction.setEnabled(true); - m_breakAction.setEnabled(false); + m_setOrRemoveBreakpointAction.setEnabled(false); + m_enableOrDisableBreakpointAction.setEnabled(false); m_snapshotAction.setEnabled(false); m_operateByInstructionAction.setEnabled(false); @@ -1537,7 +1539,8 @@ void DebuggerEnginePrivate::updateState() m_snapshotAction.setEnabled(stopped && !isCore); m_watchAction.setEnabled(true); - m_breakAction.setEnabled(true); + m_setOrRemoveBreakpointAction.setEnabled(true); + m_enableOrDisableBreakpointAction.setEnabled(true); const bool canOperateByInstruction = m_engine->hasCapability(OperateByInstructionCapability); m_operateByInstructionAction.setVisible(canOperateByInstruction); diff --git a/src/plugins/debugger/debuggerplugin.cpp b/src/plugins/debugger/debuggerplugin.cpp index aa471d96b77..b15fb07569e 100644 --- a/src/plugins/debugger/debuggerplugin.cpp +++ b/src/plugins/debugger/debuggerplugin.cpp @@ -623,7 +623,7 @@ public: return; message = dialog.textValue(); } - BreakpointManager::toggleBreakpoint(data, message); + BreakpointManager::setOrRemoveBreakpoint(data, message); } void editorOpened(IEditor *editor); @@ -633,7 +633,8 @@ public: void requestContextMenu(TextEditorWidget *widget, int lineNumber, QMenu *menu); - void toggleBreakpointHelper(); + void setOrRemoveBreakpoint(); + void enableOrDisableBreakpoint(); void updateDebugWithoutDeployMenu(); void startRemoteCdbSession(); @@ -683,7 +684,8 @@ public: QAction m_startAndBreakOnMain{tr("Start and Break on Main")}; QAction m_watchAction{tr("Add Expression Evaluator")}; Command *m_watchCommand = nullptr; - QAction m_breakAction{tr("Toggle Breakpoint")}; + QAction m_setOrRemoveBreakpointAction{tr("Set or Remove Breakpoint")}; + QAction m_enableOrDisableBreakpointAction{tr("Enable or Disable Breakpoint")}; QAction m_reloadDebuggingHelpersAction{tr("Reload Debugging Helpers")}; BreakpointManager m_breakpointManager; @@ -1094,11 +1096,18 @@ DebuggerPluginPrivate::DebuggerPluginPrivate(const QStringList &arguments) cmd = ActionManager::registerAction(act, Constants::OPERATE_BY_INSTRUCTION); debugMenu->addAction(cmd); - cmd = ActionManager::registerAction(&m_breakAction, "Debugger.ToggleBreak"); + cmd = ActionManager::registerAction(&m_setOrRemoveBreakpointAction, "Debugger.ToggleBreak"); cmd->setDefaultKeySequence(QKeySequence(useMacShortcuts ? tr("F8") : tr("F9"))); debugMenu->addAction(cmd); - connect(&m_breakAction, &QAction::triggered, - this, &DebuggerPluginPrivate::toggleBreakpointHelper); + connect(&m_setOrRemoveBreakpointAction, &QAction::triggered, + this, &DebuggerPluginPrivate::setOrRemoveBreakpoint); + + cmd = ActionManager::registerAction(&m_enableOrDisableBreakpointAction, + "Debugger.EnableOrDisableBreakpoint"); + cmd->setDefaultKeySequence(QKeySequence(useMacShortcuts ? tr("Ctrl+F8") : tr("Ctrl+F9"))); + debugMenu->addAction(cmd); + connect(&m_enableOrDisableBreakpointAction, &QAction::triggered, + this, &DebuggerPluginPrivate::enableOrDisableBreakpoint); debugMenu->addSeparator(); @@ -1493,7 +1502,8 @@ void DebuggerPluginPrivate::updatePresetState() m_attachToUnstartedApplication.setEnabled(true); m_watchAction.setEnabled(state != DebuggerFinished && state != DebuggerNotReady); - m_breakAction.setEnabled(true); + m_setOrRemoveBreakpointAction.setEnabled(true); + m_enableOrDisableBreakpointAction.setEnabled(true); } void DebuggerPluginPrivate::onStartupProjectChanged(Project *project) @@ -1825,7 +1835,8 @@ void DebuggerPluginPrivate::editorOpened(IEditor *editor) void DebuggerPluginPrivate::updateBreakMenuItem(IEditor *editor) { BaseTextEditor *textEditor = qobject_cast(editor); - m_breakAction.setEnabled(textEditor != nullptr); + m_setOrRemoveBreakpointAction.setEnabled(textEditor != nullptr); + m_enableOrDisableBreakpointAction.setEnabled(textEditor != nullptr); } void DebuggerPluginPrivate::requestContextMenu(TextEditorWidget *widget, @@ -1921,14 +1932,24 @@ void DebuggerPluginPrivate::requestContextMenu(TextEditorWidget *widget, } } -void DebuggerPluginPrivate::toggleBreakpointHelper() +void DebuggerPluginPrivate::setOrRemoveBreakpoint() { - BaseTextEditor *textEditor = BaseTextEditor::currentTextEditor(); + const BaseTextEditor *textEditor = BaseTextEditor::currentTextEditor(); QTC_ASSERT(textEditor, return); const int lineNumber = textEditor->currentLine(); ContextData location = getLocationContext(textEditor->textDocument(), lineNumber); if (location.isValid()) - BreakpointManager::toggleBreakpoint(location); + BreakpointManager::setOrRemoveBreakpoint(location); +} + +void DebuggerPluginPrivate::enableOrDisableBreakpoint() +{ + const BaseTextEditor *textEditor = BaseTextEditor::currentTextEditor(); + QTC_ASSERT(textEditor, return); + const int lineNumber = textEditor->currentLine(); + ContextData location = getLocationContext(textEditor->textDocument(), lineNumber); + if (location.isValid()) + BreakpointManager::enableOrDisableBreakpoint(location); } void DebuggerPluginPrivate::requestMark(TextEditorWidget *widget, int lineNumber, @@ -1937,7 +1958,7 @@ void DebuggerPluginPrivate::requestMark(TextEditorWidget *widget, int lineNumber if (kind == BreakpointRequest) { ContextData location = getLocationContext(widget->textDocument(), lineNumber); if (location.isValid()) - BreakpointManager::toggleBreakpoint(location); + BreakpointManager::setOrRemoveBreakpoint(location); } } @@ -1951,7 +1972,8 @@ void DebuggerPluginPrivate::setInitialState() m_attachToUnstartedApplication.setEnabled(true); m_watchAction.setEnabled(false); - m_breakAction.setEnabled(false); + m_setOrRemoveBreakpointAction.setEnabled(false); + m_enableOrDisableBreakpointAction.setEnabled(false); //m_snapshotAction.setEnabled(false); debuggerSettings()->autoDerefPointers.setEnabled(true);