DAP: Add run to line support

Note:
"Run to line" feature is disabled for CMake.

Change-Id: If8dc271fe51c6e5695f2544a71be544c7575bfa9
Reviewed-by: <github-actions-qt-creator@cristianadam.eu>
Reviewed-by: hjk <hjk@qt.io>
This commit is contained in:
Artem Sokolovskii
2023-08-11 13:04:41 +02:00
parent 888e7e0c6d
commit 83d2ee56b7
3 changed files with 30 additions and 3 deletions

View File

@@ -115,4 +115,12 @@ void CMakeDapEngine::setupEngine()
notifyEngineSetupOk(); notifyEngineSetupOk();
} }
bool CMakeDapEngine::hasCapability(unsigned cap) const
{
return cap & (ReloadModuleCapability
| BreakConditionCapability
| ShowModuleSymbolsCapability
/*| RunToLineCapability*/); // disable while the #25176 bug is not fixed
}
} // namespace Debugger::Internal } // namespace Debugger::Internal

View File

@@ -15,6 +15,8 @@ public:
private: private:
void handleDapStarted() override; void handleDapStarted() override;
void setupEngine() override; void setupEngine() override;
bool hasCapability(unsigned cap) const override;
}; };
} // Debugger::Internal } // Debugger::Internal

View File

@@ -305,8 +305,19 @@ void DapEngine::continueInferior()
void DapEngine::executeRunToLine(const ContextData &data) void DapEngine::executeRunToLine(const ContextData &data)
{ {
Q_UNUSED(data) // Add one-shot breakpoint
QTC_CHECK("FIXME: DapEngine::runToLineExec()" && false); BreakpointParameters bp;
bp.oneShot = true;
if (data.address) {
bp.type = BreakpointByAddress;
bp.address = data.address;
} else {
bp.type = BreakpointByFileAndLine;
bp.fileName = data.fileName;
bp.textPosition = data.textPosition;
}
BreakpointManager::createBreakpointForEngine(bp, this);
} }
void DapEngine::executeRunToFunction(const QString &functionName) void DapEngine::executeRunToFunction(const QString &functionName)
@@ -836,6 +847,8 @@ void DapEngine::handleStoppedEvent(const QJsonObject &event)
if (bp) { if (bp) {
const BreakpointParameters &params = bp->requestedParameters(); const BreakpointParameters &params = bp->requestedParameters();
gotoLocation(Location(params.fileName, params.textPosition)); gotoLocation(Location(params.fileName, params.textPosition));
if (params.oneShot)
removeBreakpoint(bp);
} }
} }
@@ -860,6 +873,9 @@ void DapEngine::handleBreakpointEvent(const QJsonObject &event)
if (body.value("reason").toString() == "new") { if (body.value("reason").toString() == "new") {
if (breakpoint.value("verified").toBool()) { if (breakpoint.value("verified").toBool()) {
notifyBreakpointInsertOk(bp); notifyBreakpointInsertOk(bp);
const BreakpointParameters &params = bp->requestedParameters();
if (params.oneShot)
continueInferior();
qCDebug(dapEngineLog) << "breakpoint inserted"; qCDebug(dapEngineLog) << "breakpoint inserted";
} else { } else {
notifyBreakpointInsertFailed(bp); notifyBreakpointInsertFailed(bp);
@@ -958,7 +974,8 @@ bool DapEngine::hasCapability(unsigned cap) const
{ {
return cap & (ReloadModuleCapability return cap & (ReloadModuleCapability
| BreakConditionCapability | BreakConditionCapability
| ShowModuleSymbolsCapability); | ShowModuleSymbolsCapability
| RunToLineCapability);
} }
void DapEngine::claimInitialBreakpoints() void DapEngine::claimInitialBreakpoints()