forked from qt-creator/qt-creator
Debugger: Use actions in different contexts
... for F10-as-in-Start-and-break-at-main and F10-as-in-step-over. Change-Id: Ie8e9e9be389a09a1485cadeea8b2d035a130920a Reviewed-by: Eike Ziller <eike.ziller@qt.io>
This commit is contained in:
@@ -37,6 +37,8 @@ const char MODE_DEBUG[] = "Mode.Debug";
|
||||
const char C_DEBUGMODE[] = "Debugger.DebugMode";
|
||||
const char C_CPPDEBUGGER[] = "Gdb Debugger";
|
||||
const char C_QMLDEBUGGER[] = "Qml/JavaScript Debugger";
|
||||
const char C_DEBUGGER_RUNNING[] = "Debugger.Running";
|
||||
const char C_DEBUGGER_NOTRUNNING[] = "Debugger.NotRunning";
|
||||
|
||||
const char PRESET_PERSPECTIVE_ID[] = "Debugger.Perspective.Preset";
|
||||
|
||||
@@ -54,6 +56,7 @@ const char ABORT[] = "Debugger.Abort";
|
||||
const char STEP[] = "Debugger.StepLine";
|
||||
const char STEPOUT[] = "Debugger.StepOut";
|
||||
const char NEXT[] = "Debugger.NextLine";
|
||||
const char START_AND_BREAK_ON_MAIN[]= "Debugger.StartAndBreakOnMain";
|
||||
const char REVERSE[] = "Debugger.ReverseDirection";
|
||||
const char RESET[] = "Debugger.Reset";
|
||||
const char OPERATE_BY_INSTRUCTION[] = "Debugger.OperateByInstruction";
|
||||
|
||||
@@ -2293,24 +2293,14 @@ void DebuggerEngine::handleReset()
|
||||
|
||||
void DebuggerEngine::handleExecStepIn()
|
||||
{
|
||||
if (state() == DebuggerNotReady) {
|
||||
DebuggerRunTool::setBreakOnMainNextTime();
|
||||
ProjectExplorerPlugin::runStartupProject(ProjectExplorer::Constants::DEBUG_RUN_MODE);
|
||||
} else {
|
||||
resetLocation();
|
||||
executeStepIn(operatesByInstruction());
|
||||
}
|
||||
resetLocation();
|
||||
executeStepIn(operatesByInstruction());
|
||||
}
|
||||
|
||||
void DebuggerEngine::handleExecStepOver()
|
||||
{
|
||||
if (state() == DebuggerNotReady) {
|
||||
DebuggerRunTool::setBreakOnMainNextTime();
|
||||
ProjectExplorerPlugin::runStartupProject(ProjectExplorer::Constants::DEBUG_RUN_MODE);
|
||||
} else {
|
||||
resetLocation();
|
||||
executeStepOver(operatesByInstruction());
|
||||
}
|
||||
resetLocation();
|
||||
executeStepOver(operatesByInstruction());
|
||||
}
|
||||
|
||||
void DebuggerEngine::handleExecStepOut()
|
||||
|
||||
@@ -777,6 +777,7 @@ public:
|
||||
// In the Debug menu.
|
||||
Action m_returnFromFunctionAction{tr("Immediately Return From Inner Function"), {}, &DebuggerEngine::executeReturn};
|
||||
QAction m_stepOverAction{tr("Step Over")};
|
||||
QAction m_startAndBreakOnMain{tr("Start and Break on Main")};
|
||||
Action m_watchAction{tr("Add Expression Evaluator"), {}, &DebuggerEngine::handleAddToWatchWindow};
|
||||
Command *m_watchCommand = nullptr;
|
||||
QAction m_breakAction{tr("Toggle Breakpoint")};
|
||||
@@ -1012,6 +1013,11 @@ bool DebuggerPluginPrivate::initialize(const QStringList &arguments,
|
||||
QString *errorMessage)
|
||||
{
|
||||
Q_UNUSED(errorMessage);
|
||||
|
||||
const Context debuggerRunning(C_DEBUGGER_RUNNING);
|
||||
const Context debuggerNotRunning(C_DEBUGGER_NOTRUNNING);
|
||||
ICore::addAdditionalContext(debuggerNotRunning);
|
||||
|
||||
m_arguments = arguments;
|
||||
if (!m_arguments.isEmpty())
|
||||
connect(ProjectExplorerPlugin::instance(), &ProjectExplorerPlugin::finishedInitialization,
|
||||
@@ -1225,34 +1231,37 @@ bool DebuggerPluginPrivate::initialize(const QStringList &arguments,
|
||||
|
||||
debugMenu->addSeparator();
|
||||
|
||||
cmd = ActionManager::registerAction(&m_stepOverAction, Constants::NEXT);
|
||||
cmd = ActionManager::registerAction(&m_startAndBreakOnMain,
|
||||
Constants::START_AND_BREAK_ON_MAIN,
|
||||
debuggerNotRunning);
|
||||
cmd->setDefaultKeySequence(QKeySequence(useMacShortcuts ? tr("Ctrl+Shift+O") : tr("F10")));
|
||||
cmd->setAttribute(Command::CA_Hide);
|
||||
debugMenu->addAction(cmd);
|
||||
connect(&m_startAndBreakOnMain, &QAction::triggered, this, [] {
|
||||
DebuggerRunTool::setBreakOnMainNextTime();
|
||||
ProjectExplorerPlugin::runStartupProject(ProjectExplorer::Constants::DEBUG_RUN_MODE, false);
|
||||
});
|
||||
|
||||
cmd = ActionManager::registerAction(&m_stepOverAction, Constants::NEXT, debuggerRunning);
|
||||
cmd->setDefaultKeySequence(QKeySequence(useMacShortcuts ? tr("Ctrl+Shift+O") : tr("F10")));
|
||||
cmd->setAttribute(Command::CA_Hide);
|
||||
cmd->setAttribute(Command::CA_UpdateText);
|
||||
debugMenu->addAction(cmd);
|
||||
m_stepOverAction.setIcon(Icons::STEP_OVER.icon());
|
||||
connect(&m_stepOverAction, &QAction::triggered, this, [] {
|
||||
if (DebuggerEngine *engine = EngineManager::currentEngine()) {
|
||||
engine->handleExecStepOver();
|
||||
} else {
|
||||
DebuggerRunTool::setBreakOnMainNextTime();
|
||||
ProjectExplorerPlugin::runStartupProject(ProjectExplorer::Constants::DEBUG_RUN_MODE, false);
|
||||
}
|
||||
DebuggerEngine *engine = EngineManager::currentEngine();
|
||||
QTC_ASSERT(engine, return);
|
||||
engine->handleExecStepOver();
|
||||
});
|
||||
|
||||
cmd = ActionManager::registerAction(&m_stepInAction, Constants::STEP);
|
||||
cmd = ActionManager::registerAction(&m_stepInAction, Constants::STEP, debuggerRunning);
|
||||
cmd->setDefaultKeySequence(QKeySequence(useMacShortcuts ? tr("Ctrl+Shift+I") : tr("F11")));
|
||||
cmd->setAttribute(Command::CA_Hide);
|
||||
cmd->setAttribute(Command::CA_UpdateText);
|
||||
debugMenu->addAction(cmd);
|
||||
m_stepInAction.setIcon(Icons::STEP_INTO.icon());
|
||||
connect(&m_stepInAction, &QAction::triggered, this, [] {
|
||||
if (DebuggerEngine *engine = EngineManager::currentEngine()) {
|
||||
engine->handleExecStepIn();
|
||||
} else {
|
||||
DebuggerRunTool::setBreakOnMainNextTime();
|
||||
ProjectExplorerPlugin::runStartupProject(ProjectExplorer::Constants::DEBUG_RUN_MODE, false);
|
||||
}
|
||||
DebuggerEngine *engine = EngineManager::currentEngine();
|
||||
QTC_ASSERT(engine, return);
|
||||
engine->handleExecStepIn();
|
||||
});
|
||||
|
||||
|
||||
|
||||
@@ -344,8 +344,13 @@ void EngineManagerPrivate::selectUiForCurrentEngine()
|
||||
int row = 0;
|
||||
|
||||
if (m_currentItem && m_currentItem->m_engine) {
|
||||
ICore::updateAdditionalContexts(Context(Debugger::Constants::C_DEBUGGER_NOTRUNNING),
|
||||
Context(Debugger::Constants::C_DEBUGGER_RUNNING));
|
||||
perspective = m_currentItem->m_engine->perspective();
|
||||
m_currentItem->m_engine->updateState(false);
|
||||
} else {
|
||||
ICore::updateAdditionalContexts(Context(Debugger::Constants::C_DEBUGGER_RUNNING),
|
||||
Context(Debugger::Constants::C_DEBUGGER_NOTRUNNING));
|
||||
}
|
||||
|
||||
if (m_currentItem)
|
||||
|
||||
Reference in New Issue
Block a user