Debugger: Rework step{In,Out,Over} handling

Main menu action pass operation to current engine, everything else
is handled there.

Combine execute{Step,Next} and execute{Step,Next}I functions.
Implementation were mostly similar, in some cases unneeded
(the instruction-wise version e.g. for Python)

Drop GDB-isms 'step', 'next' in favor of 'step in' and 'step over'.

Change-Id: I232232bc7a67d9d297a74f1c81dc43be96787d34
Reviewed-by: David Schulz <david.schulz@qt.io>
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
This commit is contained in:
hjk
2018-10-02 12:53:07 +02:00
parent 78fbb0826b
commit fa96f73192
14 changed files with 104 additions and 187 deletions

View File

@@ -224,7 +224,7 @@ void CdbEngine::init()
m_stopMode = NoStopRequested; m_stopMode = NoStopRequested;
m_nextCommandToken = 0; m_nextCommandToken = 0;
m_currentBuiltinResponseToken = -1; m_currentBuiltinResponseToken = -1;
m_operateByInstruction = true; // Default CDB setting. m_lastOperateByInstruction = true; // Default CDB setting.
m_hasDebuggee = false; m_hasDebuggee = false;
m_sourceStepInto = false; m_sourceStepInto = false;
m_watchPointX = m_watchPointY = 0; m_watchPointX = m_watchPointY = 0;
@@ -266,14 +266,13 @@ void CdbEngine::init()
CdbEngine::~CdbEngine() = default; CdbEngine::~CdbEngine() = default;
void CdbEngine::operateByInstructionTriggered(bool operateByInstruction) void CdbEngine::adjustOperateByInstruction(bool operateByInstruction)
{ {
DebuggerEngine::operateByInstructionTriggered(operateByInstruction); if (m_lastOperateByInstruction == operateByInstruction)
if (m_operateByInstruction == operateByInstruction)
return; return;
m_operateByInstruction = operateByInstruction; m_lastOperateByInstruction = operateByInstruction;
runCommand({QLatin1String(m_operateByInstruction ? "l-t" : "l+t"), NoFlags}); runCommand({QLatin1String(m_lastOperateByInstruction ? "l-t" : "l+t"), NoFlags});
runCommand({QLatin1String(m_operateByInstruction ? "l-s" : "l+s"), NoFlags}); runCommand({QLatin1String(m_lastOperateByInstruction ? "l-s" : "l+s"), NoFlags});
} }
bool CdbEngine::canHandleToolTip(const DebuggerToolTipContext &context) const bool CdbEngine::canHandleToolTip(const DebuggerToolTipContext &context) const
@@ -521,7 +520,7 @@ void CdbEngine::handleInitialSessionIdle()
const DebuggerRunParameters &rp = runParameters(); const DebuggerRunParameters &rp = runParameters();
if (!rp.commandsAfterConnect.isEmpty()) if (!rp.commandsAfterConnect.isEmpty())
runCommand({rp.commandsAfterConnect, NoFlags}); runCommand({rp.commandsAfterConnect, NoFlags});
operateByInstructionTriggered(operatesByInstruction()); //operateByInstructionTriggered(operatesByInstruction());
// QmlCppEngine expects the QML engine to be connected before any breakpoints are hit // QmlCppEngine expects the QML engine to be connected before any breakpoints are hit
// (attemptBreakpointSynchronization() will be directly called then) // (attemptBreakpointSynchronization() will be directly called then)
if (rp.breakOnMain) { if (rp.breakOnMain) {
@@ -758,10 +757,11 @@ bool CdbEngine::hasCapability(unsigned cap) const
|AdditionalQmlStackCapability); |AdditionalQmlStackCapability);
} }
void CdbEngine::executeStep() void CdbEngine::executeStepIn(bool byInstruction)
{ {
if (!m_operateByInstruction) if (!m_lastOperateByInstruction)
m_sourceStepInto = true; // See explanation at handleStackTrace(). m_sourceStepInto = true; // See explanation at handleStackTrace().
adjustOperateByInstruction(byInstruction);
runCommand({"t", NoFlags}); // Step into-> t (trace) runCommand({"t", NoFlags}); // Step into-> t (trace)
STATE_DEBUG(state(), Q_FUNC_INFO, __LINE__, "notifyInferiorRunRequested") STATE_DEBUG(state(), Q_FUNC_INFO, __LINE__, "notifyInferiorRunRequested")
notifyInferiorRunRequested(); notifyInferiorRunRequested();
@@ -774,23 +774,14 @@ void CdbEngine::executeStepOut()
notifyInferiorRunRequested(); notifyInferiorRunRequested();
} }
void CdbEngine::executeNext() void CdbEngine::executeStepOver(bool byInstruction)
{ {
adjustOperateByInstruction(byInstruction);
runCommand({"p", NoFlags}); // Step over -> p runCommand({"p", NoFlags}); // Step over -> p
STATE_DEBUG(state(), Q_FUNC_INFO, __LINE__, "notifyInferiorRunRequested") STATE_DEBUG(state(), Q_FUNC_INFO, __LINE__, "notifyInferiorRunRequested")
notifyInferiorRunRequested(); notifyInferiorRunRequested();
} }
void CdbEngine::executeStepI()
{
executeStep();
}
void CdbEngine::executeNextI()
{
executeNext();
}
void CdbEngine::continueInferior() void CdbEngine::continueInferior()
{ {
STATE_DEBUG(state(), Q_FUNC_INFO, __LINE__, "notifyInferiorRunRequested") STATE_DEBUG(state(), Q_FUNC_INFO, __LINE__, "notifyInferiorRunRequested")
@@ -1848,7 +1839,7 @@ void CdbEngine::processStop(const GdbMi &stopReason, bool conditionalBreakPointT
if (stack.isValid()) { if (stack.isValid()) {
switch (parseStackTrace(stack, sourceStepInto)) { switch (parseStackTrace(stack, sourceStepInto)) {
case ParseStackStepInto: // Hit on a frame while step into, see parseStackTrace(). case ParseStackStepInto: // Hit on a frame while step into, see parseStackTrace().
executeStep(); executeStepIn(operatesByInstruction());
return; return;
case ParseStackStepOut: // Hit on a frame with no source while step into. case ParseStackStepOut: // Hit on a frame with no source while step into.
executeStepOut(); executeStepOut();

View File

@@ -64,11 +64,9 @@ public:
void watchPoint(const QPoint &) override; void watchPoint(const QPoint &) override;
void setRegisterValue(const QString &name, const QString &value) override; void setRegisterValue(const QString &name, const QString &value) override;
void executeStep() override; void executeStepOver(bool byInstruction) override;
void executeStepIn(bool byInstruction) override;
void executeStepOut() override; void executeStepOut() override;
void executeNext() override;
void executeStepI() override;
void executeNextI() override;
void continueInferior() override; void continueInferior() override;
void interruptInferior() override; void interruptInferior() override;
@@ -113,7 +111,7 @@ private:
void processError(); void processError();
void processFinished(); void processFinished();
void runCommand(const DebuggerCommand &cmd) override; void runCommand(const DebuggerCommand &cmd) override;
void operateByInstructionTriggered(bool) override; void adjustOperateByInstruction(bool);
void createFullBacktrace(); void createFullBacktrace();
@@ -217,7 +215,7 @@ private:
int m_currentBuiltinResponseToken = -1; int m_currentBuiltinResponseToken = -1;
QMap<QString, NormalizedSourceFileName> m_normalizedFileCache; QMap<QString, NormalizedSourceFileName> m_normalizedFileCache;
const QString m_extensionCommandPrefix; //!< Library name used as prefix const QString m_extensionCommandPrefix; //!< Library name used as prefix
bool m_operateByInstruction = true; // Default CDB setting. bool m_lastOperateByInstruction = true; // Default CDB setting.
bool m_hasDebuggee = false; bool m_hasDebuggee = false;
enum Wow64State { enum Wow64State {
wow64Uninitialized, wow64Uninitialized,

View File

@@ -691,11 +691,11 @@ void DebuggerEnginePrivate::setupViews()
m_stepOverAction.setIcon(Icons::STEP_OVER_TOOLBAR.icon()); m_stepOverAction.setIcon(Icons::STEP_OVER_TOOLBAR.icon());
connect(&m_stepOverAction, &QAction::triggered, connect(&m_stepOverAction, &QAction::triggered,
m_engine, &DebuggerEngine::handleExecNext); m_engine, &DebuggerEngine::handleExecStepOver);
m_stepIntoAction.setIcon(Icons::STEP_INTO_TOOLBAR.icon()); m_stepIntoAction.setIcon(Icons::STEP_INTO_TOOLBAR.icon());
connect(&m_stepIntoAction, &QAction::triggered, connect(&m_stepIntoAction, &QAction::triggered,
m_engine, &DebuggerEngine::handleExecStep); m_engine, &DebuggerEngine::handleExecStepIn);
m_stepOutAction.setIcon(Icons::STEP_OUT_TOOLBAR.icon()); m_stepOutAction.setIcon(Icons::STEP_OUT_TOOLBAR.icon());
connect(&m_stepOutAction, &QAction::triggered, connect(&m_stepOutAction, &QAction::triggered,
@@ -1787,16 +1787,16 @@ DebuggerToolTipManager *DebuggerEngine::toolTipManager()
return &d->m_toolTipManager; return &d->m_toolTipManager;
} }
bool DebuggerEngine::debuggerActionsEnabled() const
{
return debuggerActionsEnabledHelper(d->m_state);
}
bool DebuggerEngine::operatesByInstruction() const bool DebuggerEngine::operatesByInstruction() const
{ {
return d->m_operateByInstructionAction.isChecked(); return d->m_operateByInstructionAction.isChecked();
} }
bool DebuggerEngine::debuggerActionsEnabled() const
{
return debuggerActionsEnabledHelper(d->m_state);
}
void DebuggerEngine::operateByInstructionTriggered(bool on) void DebuggerEngine::operateByInstructionTriggered(bool on)
{ {
// Go to source only if we have the file. // Go to source only if we have the file.
@@ -2291,31 +2291,25 @@ void DebuggerEngine::handleReset()
resetInferior(); resetInferior();
} }
void DebuggerEngine::handleExecStep() void DebuggerEngine::handleExecStepIn()
{ {
if (state() == DebuggerNotReady) { if (state() == DebuggerNotReady) {
DebuggerRunTool::setBreakOnMainNextTime(); DebuggerRunTool::setBreakOnMainNextTime();
ProjectExplorerPlugin::runStartupProject(ProjectExplorer::Constants::DEBUG_RUN_MODE); ProjectExplorerPlugin::runStartupProject(ProjectExplorer::Constants::DEBUG_RUN_MODE);
} else { } else {
resetLocation(); resetLocation();
if (operatesByInstruction()) executeStepIn(operatesByInstruction());
executeStepI();
else
executeStep();
} }
} }
void DebuggerEngine::handleExecNext() void DebuggerEngine::handleExecStepOver()
{ {
if (state() == DebuggerNotReady) { if (state() == DebuggerNotReady) {
DebuggerRunTool::setBreakOnMainNextTime(); DebuggerRunTool::setBreakOnMainNextTime();
ProjectExplorerPlugin::runStartupProject(ProjectExplorer::Constants::DEBUG_RUN_MODE); ProjectExplorerPlugin::runStartupProject(ProjectExplorer::Constants::DEBUG_RUN_MODE);
} else { } else {
resetLocation(); resetLocation();
if (operatesByInstruction()) executeStepOver(operatesByInstruction());
executeNextI();
else
executeNext();
} }
} }

View File

@@ -434,8 +434,8 @@ public:
void handleUserStop(); void handleUserStop();
void handleAbort(); void handleAbort();
void handleReset(); void handleReset();
void handleExecStep(); void handleExecStepIn();
void handleExecNext(); void handleExecStepOver();
void handleExecStepOut(); void handleExecStepOut();
void handleExecReturn(); void handleExecReturn();
void handleExecJumpToLine(); void handleExecJumpToLine();
@@ -480,11 +480,9 @@ protected:
virtual void resetInferior() {} virtual void resetInferior() {}
virtual void detachDebugger() {} virtual void detachDebugger() {}
virtual void executeStep() {} virtual void executeStepOver(bool /*byInstruction*/ = false) {}
virtual void executeStepIn(bool /*byInstruction*/ = false) {}
virtual void executeStepOut() {} virtual void executeStepOut() {}
virtual void executeNext() {}
virtual void executeStepI() {}
virtual void executeNextI() {}
virtual void executeReturn() {} virtual void executeReturn() {}
virtual void continueInferior() {} virtual void continueInferior() {}

View File

@@ -768,7 +768,7 @@ public:
Action m_interruptAction{tr("Interrupt"), interruptIcon(false), &DebuggerEngine::handleExecInterrupt}; Action m_interruptAction{tr("Interrupt"), interruptIcon(false), &DebuggerEngine::handleExecInterrupt};
Action m_abortAction{tr("Abort Debugging"), {}, &DebuggerEngine::abortDebugger, Action m_abortAction{tr("Abort Debugging"), {}, &DebuggerEngine::abortDebugger,
tr("Aborts debugging and resets the debugger to the initial state.")}; tr("Aborts debugging and resets the debugger to the initial state.")};
QAction m_stepAction{tr("Step Into")}; QAction m_stepInAction{tr("Step Into")};
Action m_stepOutAction{tr("Step Out"), Icons::STEP_OUT.icon(), &DebuggerEngine::handleExecStepOut}; Action m_stepOutAction{tr("Step Out"), Icons::STEP_OUT.icon(), &DebuggerEngine::handleExecStepOut};
Action m_runToLineAction{tr("Run to Line"), {}, &DebuggerEngine::handleExecRunToLine}; Action m_runToLineAction{tr("Run to Line"), {}, &DebuggerEngine::handleExecRunToLine};
@@ -776,7 +776,7 @@ public:
Action m_jumpToLineAction{tr("Jump to Line"), {}, &DebuggerEngine::handleExecJumpToLine}; Action m_jumpToLineAction{tr("Jump to Line"), {}, &DebuggerEngine::handleExecJumpToLine};
// In the Debug menu. // In the Debug menu.
Action m_returnFromFunctionAction{tr("Immediately Return From Inner Function"), {}, &DebuggerEngine::executeReturn}; Action m_returnFromFunctionAction{tr("Immediately Return From Inner Function"), {}, &DebuggerEngine::executeReturn};
QAction m_nextAction{tr("Step Over")}; QAction m_stepOverAction{tr("Step Over")};
Action m_watchAction{tr("Add Expression Evaluator"), {}, &DebuggerEngine::handleAddToWatchWindow}; Action m_watchAction{tr("Add Expression Evaluator"), {}, &DebuggerEngine::handleAddToWatchWindow};
Command *m_watchCommand = nullptr; Command *m_watchCommand = nullptr;
QAction m_breakAction{tr("Toggle Breakpoint")}; QAction m_breakAction{tr("Toggle Breakpoint")};
@@ -1225,30 +1225,30 @@ bool DebuggerPluginPrivate::initialize(const QStringList &arguments,
debugMenu->addSeparator(); debugMenu->addSeparator();
cmd = ActionManager::registerAction(&m_nextAction, Constants::NEXT); cmd = ActionManager::registerAction(&m_stepOverAction, Constants::NEXT);
cmd->setDefaultKeySequence(QKeySequence(useMacShortcuts ? tr("Ctrl+Shift+O") : tr("F10"))); cmd->setDefaultKeySequence(QKeySequence(useMacShortcuts ? tr("Ctrl+Shift+O") : tr("F10")));
cmd->setAttribute(Command::CA_Hide); cmd->setAttribute(Command::CA_Hide);
cmd->setAttribute(Command::CA_UpdateText); cmd->setAttribute(Command::CA_UpdateText);
debugMenu->addAction(cmd); debugMenu->addAction(cmd);
m_nextAction.setIcon(Icons::STEP_OVER.icon()); m_stepOverAction.setIcon(Icons::STEP_OVER.icon());
connect(&m_nextAction, &QAction::triggered, this, [] { connect(&m_stepOverAction, &QAction::triggered, this, [] {
if (DebuggerEngine *engine = EngineManager::currentEngine()) { if (DebuggerEngine *engine = EngineManager::currentEngine()) {
engine->handleExecNext(); engine->handleExecStepOver();
} else { } else {
DebuggerRunTool::setBreakOnMainNextTime(); DebuggerRunTool::setBreakOnMainNextTime();
ProjectExplorerPlugin::runStartupProject(ProjectExplorer::Constants::DEBUG_RUN_MODE, false); ProjectExplorerPlugin::runStartupProject(ProjectExplorer::Constants::DEBUG_RUN_MODE, false);
} }
}); });
cmd = ActionManager::registerAction(&m_stepAction, Constants::STEP); cmd = ActionManager::registerAction(&m_stepInAction, Constants::STEP);
cmd->setDefaultKeySequence(QKeySequence(useMacShortcuts ? tr("Ctrl+Shift+I") : tr("F11"))); cmd->setDefaultKeySequence(QKeySequence(useMacShortcuts ? tr("Ctrl+Shift+I") : tr("F11")));
cmd->setAttribute(Command::CA_Hide); cmd->setAttribute(Command::CA_Hide);
cmd->setAttribute(Command::CA_UpdateText); cmd->setAttribute(Command::CA_UpdateText);
debugMenu->addAction(cmd); debugMenu->addAction(cmd);
m_stepAction.setIcon(Icons::STEP_INTO.icon()); m_stepInAction.setIcon(Icons::STEP_INTO.icon());
connect(&m_stepAction, &QAction::triggered, this, [] { connect(&m_stepInAction, &QAction::triggered, this, [] {
if (DebuggerEngine *engine = EngineManager::currentEngine()) { if (DebuggerEngine *engine = EngineManager::currentEngine()) {
engine->handleExecStep(); engine->handleExecStepIn();
} else { } else {
DebuggerRunTool::setBreakOnMainNextTime(); DebuggerRunTool::setBreakOnMainNextTime();
ProjectExplorerPlugin::runStartupProject(ProjectExplorer::Constants::DEBUG_RUN_MODE, false); ProjectExplorerPlugin::runStartupProject(ProjectExplorer::Constants::DEBUG_RUN_MODE, false);
@@ -1469,10 +1469,10 @@ void DebuggerPluginPrivate::updatePresetState()
// correspond to the current start up project. // correspond to the current start up project.
// Step into/next: Start and break at 'main' unless a debugger is running. // Step into/next: Start and break at 'main' unless a debugger is running.
QString stepToolTip = canRun ? tr("Start \"%1\" and break at function \"main\"").arg(startupRunConfigName) : whyNot; QString stepToolTip = canRun ? tr("Start \"%1\" and break at function \"main\"").arg(startupRunConfigName) : whyNot;
m_stepAction.setToolTip(stepToolTip); m_stepInAction.setEnabled(canRun);
m_nextAction.setToolTip(stepToolTip); m_stepInAction.setToolTip(stepToolTip);
m_stepAction.setEnabled(canRun); m_stepOverAction.setEnabled(canRun);
m_nextAction.setEnabled(canRun); m_stepOverAction.setToolTip(stepToolTip);
m_startAction.setEnabled(canRun); m_startAction.setEnabled(canRun);
m_startAction.setIcon(startIcon(false)); m_startAction.setIcon(startIcon(false));
m_startAction.setToolButtonStyle(Qt::ToolButtonTextBesideIcon); m_startAction.setToolButtonStyle(Qt::ToolButtonTextBesideIcon);
@@ -1492,8 +1492,8 @@ void DebuggerPluginPrivate::updatePresetState()
QTC_ASSERT(currentEngine, return); QTC_ASSERT(currentEngine, return);
// We have a current engine, and it belongs to the startup runconfig. // We have a current engine, and it belongs to the startup runconfig.
m_stepAction.setToolTip(QString()); m_stepInAction.setToolTip(QString());
m_nextAction.setToolTip(QString()); m_stepOverAction.setToolTip(QString());
// The 'state' bits only affect the fat debug button, not the preset start button. // The 'state' bits only affect the fat debug button, not the preset start button.
m_startAction.setIcon(startIcon(false)); m_startAction.setIcon(startIcon(false));
@@ -1522,8 +1522,8 @@ void DebuggerPluginPrivate::updatePresetState()
m_debugWithoutDeployAction.setEnabled(false); m_debugWithoutDeployAction.setEnabled(false);
m_visibleStartAction.setAction(&m_continueAction); m_visibleStartAction.setAction(&m_continueAction);
m_hiddenStopAction.setAction(&m_exitAction); m_hiddenStopAction.setAction(&m_exitAction);
m_stepAction.setEnabled(!companionPreventsAction); m_stepInAction.setEnabled(!companionPreventsAction);
m_nextAction.setEnabled(!companionPreventsAction); m_stepOverAction.setEnabled(!companionPreventsAction);
m_jumpToLineAction.setEnabled(currentEngine->hasCapability(JumpToLineCapability)); m_jumpToLineAction.setEnabled(currentEngine->hasCapability(JumpToLineCapability));
m_returnFromFunctionAction.setEnabled(currentEngine->hasCapability(ReturnFromFunctionCapability)); m_returnFromFunctionAction.setEnabled(currentEngine->hasCapability(ReturnFromFunctionCapability));
m_detachAction.setEnabled(!isCore); m_detachAction.setEnabled(!isCore);
@@ -1541,8 +1541,8 @@ void DebuggerPluginPrivate::updatePresetState()
m_debugWithoutDeployAction.setEnabled(false); m_debugWithoutDeployAction.setEnabled(false);
m_visibleStartAction.setAction(&m_interruptAction); m_visibleStartAction.setAction(&m_interruptAction);
m_hiddenStopAction.setAction(&m_interruptAction); m_hiddenStopAction.setAction(&m_interruptAction);
m_stepAction.setEnabled(false); m_stepInAction.setEnabled(false);
m_nextAction.setEnabled(false); m_stepOverAction.setEnabled(false);
m_jumpToLineAction.setEnabled(false); m_jumpToLineAction.setEnabled(false);
m_returnFromFunctionAction.setEnabled(false); m_returnFromFunctionAction.setEnabled(false);
m_detachAction.setEnabled(false); m_detachAction.setEnabled(false);
@@ -1560,8 +1560,8 @@ void DebuggerPluginPrivate::updatePresetState()
m_debugWithoutDeployAction.setEnabled(canRun); m_debugWithoutDeployAction.setEnabled(canRun);
m_visibleStartAction.setAction(&m_startAction); m_visibleStartAction.setAction(&m_startAction);
m_hiddenStopAction.setAction(&m_undisturbableAction); m_hiddenStopAction.setAction(&m_undisturbableAction);
m_stepAction.setEnabled(false); m_stepInAction.setEnabled(false);
m_nextAction.setEnabled(false); m_stepOverAction.setEnabled(false);
m_jumpToLineAction.setEnabled(false); m_jumpToLineAction.setEnabled(false);
m_returnFromFunctionAction.setEnabled(false); m_returnFromFunctionAction.setEnabled(false);
m_detachAction.setEnabled(false); m_detachAction.setEnabled(false);
@@ -1579,8 +1579,8 @@ void DebuggerPluginPrivate::updatePresetState()
m_debugWithoutDeployAction.setEnabled(false); m_debugWithoutDeployAction.setEnabled(false);
m_visibleStartAction.setAction(&m_exitAction); m_visibleStartAction.setAction(&m_exitAction);
m_hiddenStopAction.setAction(&m_exitAction); m_hiddenStopAction.setAction(&m_exitAction);
m_stepAction.setEnabled(false); m_stepInAction.setEnabled(false);
m_nextAction.setEnabled(false); m_stepOverAction.setEnabled(false);
m_jumpToLineAction.setEnabled(false); m_jumpToLineAction.setEnabled(false);
m_returnFromFunctionAction.setEnabled(false); m_returnFromFunctionAction.setEnabled(false);
m_detachAction.setEnabled(false); m_detachAction.setEnabled(false);
@@ -1601,8 +1601,8 @@ void DebuggerPluginPrivate::updatePresetState()
m_debugWithoutDeployAction.setEnabled(false); m_debugWithoutDeployAction.setEnabled(false);
m_visibleStartAction.setAction(&m_undisturbableAction); m_visibleStartAction.setAction(&m_undisturbableAction);
m_hiddenStopAction.setAction(&m_undisturbableAction); m_hiddenStopAction.setAction(&m_undisturbableAction);
m_stepAction.setEnabled(false); m_stepInAction.setEnabled(false);
m_nextAction.setEnabled(false); m_stepOverAction.setEnabled(false);
m_jumpToLineAction.setEnabled(false); m_jumpToLineAction.setEnabled(false);
m_returnFromFunctionAction.setEnabled(false); m_returnFromFunctionAction.setEnabled(false);
m_detachAction.setEnabled(false); m_detachAction.setEnabled(false);
@@ -2064,13 +2064,13 @@ void DebuggerPluginPrivate::setInitialState()
m_interruptAction.setEnabled(false); m_interruptAction.setEnabled(false);
m_continueAction.setEnabled(false); m_continueAction.setEnabled(false);
m_stepAction.setEnabled(true); m_stepInAction.setEnabled(true);
m_stepOutAction.setEnabled(false); m_stepOutAction.setEnabled(false);
m_runToLineAction.setEnabled(false); m_runToLineAction.setEnabled(false);
m_runToSelectedFunctionAction.setEnabled(true); m_runToSelectedFunctionAction.setEnabled(true);
m_returnFromFunctionAction.setEnabled(false); m_returnFromFunctionAction.setEnabled(false);
m_jumpToLineAction.setEnabled(false); m_jumpToLineAction.setEnabled(false);
m_nextAction.setEnabled(true); m_stepOverAction.setEnabled(true);
action(AutoDerefPointers)->setEnabled(true); action(AutoDerefPointers)->setEnabled(true);
action(ExpandStack)->setEnabled(false); action(ExpandStack)->setEnabled(false);

View File

@@ -400,6 +400,7 @@ void DisassemblerAgent::updateBreakpointMarker(const Breakpoint &bp)
auto marker = new DisassemblerBreakpointMarker(bp, lineNumber); auto marker = new DisassemblerBreakpointMarker(bp, lineNumber);
d->breakpointMarks.append(marker); d->breakpointMarks.append(marker);
QTC_ASSERT(d->document, return);
d->document->addMark(marker); d->document->addMark(marker);
} }

View File

@@ -901,7 +901,7 @@ void GdbEngine::handleResultRecord(DebuggerResponse *response)
// there is no debug information. Divert to "-exec-next-step" // there is no debug information. Divert to "-exec-next-step"
showMessage("APPLYING WORKAROUND #3"); showMessage("APPLYING WORKAROUND #3");
notifyInferiorStopOk(); notifyInferiorStopOk();
executeNextI(); executeStepOver(true);
} else if (msg.startsWith("Couldn't get registers: No such process.")) { } else if (msg.startsWith("Couldn't get registers: No such process.")) {
// Happens on archer-tromey-python 6.8.50.20090910-cvs // Happens on archer-tromey-python 6.8.50.20090910-cvs
// There might to be a race between a process shutting down // There might to be a race between a process shutting down
@@ -1324,7 +1324,7 @@ void GdbEngine::handleStop1(const GdbMi &data)
if (isSkippableFunction(funcName, fileName)) { if (isSkippableFunction(funcName, fileName)) {
//showMessage(_("SKIPPING ") + funcName); //showMessage(_("SKIPPING ") + funcName);
++stepCounter; ++stepCounter;
executeStep(); executeStepIn(false);
return; return;
} }
//if (stepCounter) //if (stepCounter)
@@ -1838,25 +1838,32 @@ void GdbEngine::continueInferior()
continueInferiorInternal(); continueInferiorInternal();
} }
void GdbEngine::executeStep() void GdbEngine::executeStepIn(bool byInstruction)
{ {
CHECK_STATE(InferiorStopOk); CHECK_STATE(InferiorStopOk);
setTokenBarrier(); setTokenBarrier();
notifyInferiorRunRequested(); notifyInferiorRunRequested();
showStatusMessage(tr("Step requested..."), 5000); showStatusMessage(tr("Step requested..."), 5000);
DebuggerCommand cmd;
if (isNativeMixedActiveFrame()) { if (isNativeMixedActiveFrame()) {
DebuggerCommand cmd("executeStep", RunRequest); cmd.flags = RunRequest;
cmd.function = "executeStep";
cmd.callback = CB(handleExecuteStep); cmd.callback = CB(handleExecuteStep);
runCommand(cmd); } else if (byInstruction) {
cmd.flags = RunRequest|NeedsFlush;
cmd.function = "-exec-step-instruction";
if (isReverseDebugging())
cmd.function += "--reverse";
cmd.callback = CB(handleExecuteContinue);
} else { } else {
DebuggerCommand cmd;
cmd.flags = RunRequest|NeedsFlush; cmd.flags = RunRequest|NeedsFlush;
cmd.function = "-exec-step"; cmd.function = "-exec-step";
if (isReverseDebugging()) if (isReverseDebugging())
cmd.function += " --reverse"; cmd.function += " --reverse";
cmd.callback = CB(handleExecuteStep); cmd.callback = CB(handleExecuteStep);
runCommand(cmd);
} }
runCommand(cmd);
} }
void GdbEngine::handleExecuteStep(const DebuggerResponse &response) void GdbEngine::handleExecuteStep(const DebuggerResponse &response)
@@ -1882,7 +1889,7 @@ void GdbEngine::handleExecuteStep(const DebuggerResponse &response)
notifyInferiorRunFailed(); notifyInferiorRunFailed();
if (isDying()) if (isDying())
return; return;
executeStepI(); // Fall back to instruction-wise stepping. executeStepIn(true); // Fall back to instruction-wise stepping.
} else if (msg.startsWith("Cannot execute this command while the selected thread is running.")) { } else if (msg.startsWith("Cannot execute this command while the selected thread is running.")) {
showExecutionError(msg); showExecutionError(msg);
notifyInferiorRunFailed(); notifyInferiorRunFailed();
@@ -1895,21 +1902,6 @@ void GdbEngine::handleExecuteStep(const DebuggerResponse &response)
} }
} }
void GdbEngine::executeStepI()
{
CHECK_STATE(InferiorStopOk);
setTokenBarrier();
notifyInferiorRunRequested();
showStatusMessage(tr("Step by instruction requested..."), 5000);
DebuggerCommand cmd;
cmd.flags = RunRequest|NeedsFlush;
cmd.function = "-exec-step-instruction";
if (isReverseDebugging())
cmd.function += "--reverse";
cmd.callback = CB(handleExecuteContinue);
runCommand(cmd);
}
void GdbEngine::executeStepOut() void GdbEngine::executeStepOut()
{ {
CHECK_STATE(InferiorStopOk); CHECK_STATE(InferiorStopOk);
@@ -1928,23 +1920,29 @@ void GdbEngine::executeStepOut()
} }
} }
void GdbEngine::executeNext() void GdbEngine::executeStepOver(bool byInstruction)
{ {
CHECK_STATE(InferiorStopOk); CHECK_STATE(InferiorStopOk);
setTokenBarrier(); setTokenBarrier();
notifyInferiorRunRequested(); notifyInferiorRunRequested();
showStatusMessage(tr("Step next requested..."), 5000); showStatusMessage(tr("Step next requested..."), 5000);
DebuggerCommand cmd;
cmd.flags = RunRequest;
if (isNativeMixedActiveFrame()) { if (isNativeMixedActiveFrame()) {
runCommand({"executeNext", RunRequest}); cmd.function = "executeNext";
} else if (byInstruction) {
cmd.function = "-exec-next-instruction";
if (isReverseDebugging())
cmd.function += " --reverse";
cmd.callback = CB(handleExecuteContinue);
} else { } else {
DebuggerCommand cmd;
cmd.flags = RunRequest;
cmd.function = "-exec-next"; cmd.function = "-exec-next";
if (isReverseDebugging()) if (isReverseDebugging())
cmd.function += " --reverse"; cmd.function += " --reverse";
cmd.callback = CB(handleExecuteNext); cmd.callback = CB(handleExecuteNext);
runCommand(cmd);
} }
runCommand(cmd);
} }
void GdbEngine::handleExecuteNext(const DebuggerResponse &response) void GdbEngine::handleExecuteNext(const DebuggerResponse &response)
@@ -1967,7 +1965,7 @@ void GdbEngine::handleExecuteNext(const DebuggerResponse &response)
|| msg.contains("Error accessing memory address ")) { || msg.contains("Error accessing memory address ")) {
notifyInferiorRunFailed(); notifyInferiorRunFailed();
if (!isDying()) if (!isDying())
executeNextI(); // Fall back to instruction-wise stepping. executeStepOver(true); // Fall back to instruction-wise stepping.
} else if (msg.startsWith("Cannot execute this command while the selected thread is running.")) { } else if (msg.startsWith("Cannot execute this command while the selected thread is running.")) {
showExecutionError(msg); showExecutionError(msg);
notifyInferiorRunFailed(); notifyInferiorRunFailed();
@@ -1981,21 +1979,6 @@ void GdbEngine::handleExecuteNext(const DebuggerResponse &response)
} }
} }
void GdbEngine::executeNextI()
{
CHECK_STATE(InferiorStopOk);
setTokenBarrier();
notifyInferiorRunRequested();
showStatusMessage(tr("Step next instruction requested..."), 5000);
DebuggerCommand cmd;
cmd.flags = RunRequest;
cmd.function = "-exec-next-instruction";
if (isReverseDebugging())
cmd.function += " --reverse";
cmd.callback = CB(handleExecuteContinue);
runCommand(cmd);
}
static QString addressSpec(quint64 address) static QString addressSpec(quint64 address)
{ {
return "*0x" + QString::number(address, 16); return "*0x" + QString::number(address, 16);

View File

@@ -192,11 +192,9 @@ private: ////////// General Interface //////////
void updateBreakpoint(const Breakpoint &bp) final; void updateBreakpoint(const Breakpoint &bp) final;
void enableSubBreakpoint(const SubBreakpoint &sbp, bool on) final; void enableSubBreakpoint(const SubBreakpoint &sbp, bool on) final;
void executeStep() final; void executeStepIn(bool byInstruction) final;
void executeStepOut() final; void executeStepOut() final;
void executeNext() final; void executeStepOver(bool byInstruction) final;
void executeStepI() final;
void executeNextI() final;
void continueInferiorInternal(); void continueInferiorInternal();
void continueInferior() final; void continueInferior() final;

View File

@@ -336,16 +336,10 @@ void LldbEngine::interruptInferior()
runCommand({"interruptInferior"}); runCommand({"interruptInferior"});
} }
void LldbEngine::executeStep() void LldbEngine::executeStepIn(bool byInstruction)
{ {
notifyInferiorRunRequested(); notifyInferiorRunRequested();
runCommand({"executeStep"}); runCommand({QLatin1String(byInstruction ? "executeStepI" : "executeStep")});
}
void LldbEngine::executeStepI()
{
notifyInferiorRunRequested();
runCommand({"executeStepI"});
} }
void LldbEngine::executeStepOut() void LldbEngine::executeStepOut()
@@ -354,16 +348,10 @@ void LldbEngine::executeStepOut()
runCommand({"executeStepOut"}); runCommand({"executeStepOut"});
} }
void LldbEngine::executeNext() void LldbEngine::executeStepOver(bool byInstruction)
{ {
notifyInferiorRunRequested(); notifyInferiorRunRequested();
runCommand({"executeNext"}); runCommand({QLatin1String(byInstruction ? "executeNextI" : "executeNext")});
}
void LldbEngine::executeNextI()
{
notifyInferiorRunRequested();
runCommand({"executeNextI"});
} }
void LldbEngine::continueInferior() void LldbEngine::continueInferior()

View File

@@ -60,11 +60,9 @@ signals:
void outputReady(const QString &data); void outputReady(const QString &data);
private: private:
void executeStep() override; void executeStepIn(bool byInstruction) override;
void executeStepOut() override; void executeStepOut() override;
void executeNext() override; void executeStepOver(bool byInstruction) override;
void executeStepI() override;
void executeNextI() override;
void setupEngine() override; void setupEngine() override;
void runEngine() override; void runEngine() override;

View File

@@ -167,14 +167,7 @@ void PdbEngine::interruptInferior()
interruptProcess(m_proc.processId(), GdbEngineType, &error); interruptProcess(m_proc.processId(), GdbEngineType, &error);
} }
void PdbEngine::executeStep() void PdbEngine::executeStepIn(bool)
{
notifyInferiorRunRequested();
notifyInferiorRunOk();
postDirectCommand("step");
}
void PdbEngine::executeStepI()
{ {
notifyInferiorRunRequested(); notifyInferiorRunRequested();
notifyInferiorRunOk(); notifyInferiorRunOk();
@@ -188,14 +181,7 @@ void PdbEngine::executeStepOut()
postDirectCommand("return"); postDirectCommand("return");
} }
void PdbEngine::executeNext() void PdbEngine::executeStepOver(bool)
{
notifyInferiorRunRequested();
notifyInferiorRunOk();
postDirectCommand("next");
}
void PdbEngine::executeNextI()
{ {
notifyInferiorRunRequested(); notifyInferiorRunRequested();
notifyInferiorRunOk(); notifyInferiorRunOk();

View File

@@ -47,12 +47,9 @@ public:
PdbEngine(); PdbEngine();
private: private:
// DebuggerEngine implementation void executeStepIn(bool) override;
void executeStep() override;
void executeStepOut() override; void executeStepOut() override;
void executeNext() override; void executeStepOver(bool) override;
void executeStepI() override;
void executeNextI() override;
void setupEngine() override; void setupEngine() override;
void runEngine() override; void runEngine() override;

View File

@@ -610,15 +610,7 @@ void QmlEngine::interruptInferior()
showStatusMessage(tr("Waiting for JavaScript engine to interrupt on next statement.")); showStatusMessage(tr("Waiting for JavaScript engine to interrupt on next statement."));
} }
void QmlEngine::executeStep() void QmlEngine::executeStepIn(bool)
{
clearExceptionSelection();
d->continueDebugging(StepIn);
notifyInferiorRunRequested();
notifyInferiorRunOk();
}
void QmlEngine::executeStepI()
{ {
clearExceptionSelection(); clearExceptionSelection();
d->continueDebugging(StepIn); d->continueDebugging(StepIn);
@@ -634,7 +626,7 @@ void QmlEngine::executeStepOut()
notifyInferiorRunOk(); notifyInferiorRunOk();
} }
void QmlEngine::executeNext() void QmlEngine::executeStepOver(bool)
{ {
clearExceptionSelection(); clearExceptionSelection();
d->continueDebugging(Next); d->continueDebugging(Next);
@@ -642,11 +634,6 @@ void QmlEngine::executeNext()
notifyInferiorRunOk(); notifyInferiorRunOk();
} }
void QmlEngine::executeNextI()
{
executeNext();
}
void QmlEngine::executeRunToLine(const ContextData &data) void QmlEngine::executeRunToLine(const ContextData &data)
{ {
QTC_ASSERT(state() == InferiorStopOk, qDebug() << state()); QTC_ASSERT(state() == InferiorStopOk, qDebug() << state());

View File

@@ -72,11 +72,9 @@ private:
void resetLocation() override; void resetLocation() override;
void executeStep() override; void executeStepOver(bool) override;
void executeStepIn(bool) override;
void executeStepOut() override; void executeStepOut() override;
void executeNext() override;
void executeStepI() override;
void executeNextI() override;
void setupEngine() override; void setupEngine() override;
void runEngine() override; void runEngine() override;