diff --git a/src/plugins/debugger/cdb/cdbengine.cpp b/src/plugins/debugger/cdb/cdbengine.cpp index 6b6c3b6f536..0c0ca5da820 100644 --- a/src/plugins/debugger/cdb/cdbengine.cpp +++ b/src/plugins/debugger/cdb/cdbengine.cpp @@ -1186,7 +1186,7 @@ void CdbEngine::executeRunToLine(const ContextData &data) bp.fileName = data.fileName; bp.lineNumber = data.lineNumber; } - postCommand(cdbAddBreakpointCommand(bp, m_sourcePathMappings, BreakpointModelId(quint16(-1)), true), 0); + postCommand(cdbAddBreakpointCommand(bp, m_sourcePathMappings, BreakpointModelId(), true), 0); continueInferior(); } @@ -1196,7 +1196,7 @@ void CdbEngine::executeRunToFunction(const QString &functionName) BreakpointParameters bp(BreakpointByFunction); bp.functionName = functionName; - postCommand(cdbAddBreakpointCommand(bp, m_sourcePathMappings, BreakpointModelId(quint16(-1)), true), 0); + postCommand(cdbAddBreakpointCommand(bp, m_sourcePathMappings, BreakpointModelId(), true), 0); continueInferior(); } @@ -2043,12 +2043,10 @@ unsigned CdbEngine::examineStopReason(const GdbMi &stopReason, if (reason == "breakpoint") { // Note: Internal breakpoints (run to line) are reported with id=0. // Step out creates temporary breakpoints with id 10000. - BreakpointModelId id; int number = 0; - const GdbMi breakpointIdG = stopReason.findChild("breakpointId"); - if (breakpointIdG.isValid()) { - id = BreakpointModelId(breakpointIdG.data().toInt()); - if (id && breakHandler()->engineBreakpointIds(this).contains(id)) { + BreakpointModelId id = cdbIdToBreakpointModelId(stopReason.findChild("breakpointId")); + if (id.isValid()) { + if (breakHandler()->engineBreakpointIds(this).contains(id)) { const BreakpointResponse parameters = breakHandler()->response(id); if (!parameters.message.isEmpty()) { showMessage(parameters.message + QLatin1Char('\n'), AppOutput); @@ -2757,21 +2755,21 @@ void CdbEngine::attemptBreakpointSynchronization() if (parameters.enabled != handler->response(id).enabled) { // Change enabled/disabled breakpoints without triggering update. postCommand((parameters.enabled ? "be " : "bd ") - + QByteArray::number(id.majorPart()), 0); + + QByteArray::number(breakPointIdToCdbId(id)), 0); response.pending = false; response.enabled = parameters.enabled; handler->setResponse(id, response); } else { // Delete and re-add, triggering update addedChanged = true; - postCommand("bc " + QByteArray::number(id.majorPart()), 0); + postCommand("bc " + QByteArray::number(breakPointIdToCdbId(id)), 0); postCommand(cdbAddBreakpointCommand(parameters, m_sourcePathMappings, id, false), 0); m_pendingBreakpointMap.insert(id, response); } handler->notifyBreakpointChangeOk(id); break; case BreakpointRemoveRequested: - postCommand("bc " + QByteArray::number(id.majorPart()), 0); + postCommand("bc " + QByteArray::number(breakPointIdToCdbId(id)), 0); handler->notifyBreakpointRemoveProceeding(id); handler->notifyBreakpointRemoveOk(id); m_pendingBreakpointMap.remove(id); diff --git a/src/plugins/debugger/cdb/cdbparsehelpers.cpp b/src/plugins/debugger/cdb/cdbparsehelpers.cpp index 02afae5abe1..0173eb52e2b 100644 --- a/src/plugins/debugger/cdb/cdbparsehelpers.cpp +++ b/src/plugins/debugger/cdb/cdbparsehelpers.cpp @@ -131,6 +131,33 @@ static BreakpointParameters fixWinMSVCBreakpoint(const BreakpointParameters &p) return p; } +int breakPointIdToCdbId(const BreakpointModelId &id) +{ + return cdbBreakPointStartId + id.majorPart(); +} + +template +inline ModelId cdbIdToBreakpointId(const GdbMi &data) +{ + if (data.isValid()) { // Might not be valid if there is not id + bool ok; + const int id = data.data().toInt(&ok); + if (ok && id >= cdbBreakPointStartId) + return ModelId(id - cdbBreakPointStartId); + } + return ModelId(); +} + +BreakpointModelId cdbIdToBreakpointModelId(const GdbMi &id) +{ + return cdbIdToBreakpointId(id); +} + +BreakpointResponseId cdbIdToBreakpointResponseId(const GdbMi &id) +{ + return cdbIdToBreakpointId(id); +} + QByteArray cdbAddBreakpointCommand(const BreakpointParameters &bpIn, const QList > &sourcePathMapping, BreakpointModelId id /* = BreakpointId() */, @@ -148,7 +175,7 @@ QByteArray cdbAddBreakpointCommand(const BreakpointParameters &bpIn, // when resolving). str << (bp.type == WatchpointAtAddress ? "ba" : "bu"); if (id.isValid()) - str << id.toString(); + str << breakPointIdToCdbId(id); str << ' '; if (oneshot) str << "/1 "; @@ -304,13 +331,8 @@ void parseBreakPoint(const GdbMi &gdbmi, BreakpointResponse *r, gdbmiChildToBool(gdbmi, "enabled", &(r->enabled)); gdbmiChildToBool(gdbmi, "deferred", &(r->pending)); r->id = BreakpointResponseId(); - const GdbMi idG = gdbmi.findChild("id"); - if (idG.isValid()) { // Might not be valid if there is not id - bool ok; - const int id = idG.data().toInt(&ok); - if (ok) - r->id = BreakpointResponseId(id); - } + // Might not be valid if there is not id + r->id = cdbIdToBreakpointResponseId(gdbmi.findChild("id")); const GdbMi moduleG = gdbmi.findChild("module"); if (moduleG.isValid()) r->module = QString::fromLocal8Bit(moduleG.data()); diff --git a/src/plugins/debugger/cdb/cdbparsehelpers.h b/src/plugins/debugger/cdb/cdbparsehelpers.h index 73a506d61b3..cbf15ec7740 100644 --- a/src/plugins/debugger/cdb/cdbparsehelpers.h +++ b/src/plugins/debugger/cdb/cdbparsehelpers.h @@ -59,6 +59,13 @@ QString cdbSourcePathMapping(QString fileName, const QList > &sourcePathMapping, SourcePathMode mode); +// Ensure unique 'namespace' for breakpoints of the breakhandler. +enum { cdbBreakPointStartId = 1000 }; + +int breakPointIdToCdbId(const BreakpointModelId &id); +BreakpointModelId cdbIdToBreakpointModelId(const GdbMi &id); +BreakpointResponseId cdbIdToBreakpointResponseId(const GdbMi &id); + // Convert breakpoint in CDB syntax (applying source path mappings using native paths). QByteArray cdbAddBreakpointCommand(const BreakpointParameters &d, const QList > &sourcePathMapping,