forked from qt-creator/qt-creator
CDB: Start all CDB breakpoint IDs at 1000.
Avoid clashes with breakpoints resulting from options (break at functions from options, potentially using bm). Change-Id: I3746f5a246d7bbeea36df412460edf3f2a90e2c0 Reviewed-by: hjk <qthjk@ovi.com>
This commit is contained in:
@@ -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);
|
||||
|
||||
@@ -131,6 +131,33 @@ static BreakpointParameters fixWinMSVCBreakpoint(const BreakpointParameters &p)
|
||||
return p;
|
||||
}
|
||||
|
||||
int breakPointIdToCdbId(const BreakpointModelId &id)
|
||||
{
|
||||
return cdbBreakPointStartId + id.majorPart();
|
||||
}
|
||||
|
||||
template <class ModelId>
|
||||
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<BreakpointModelId>(id);
|
||||
}
|
||||
|
||||
BreakpointResponseId cdbIdToBreakpointResponseId(const GdbMi &id)
|
||||
{
|
||||
return cdbIdToBreakpointId<BreakpointResponseId>(id);
|
||||
}
|
||||
|
||||
QByteArray cdbAddBreakpointCommand(const BreakpointParameters &bpIn,
|
||||
const QList<QPair<QString, QString> > &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());
|
||||
|
||||
@@ -59,6 +59,13 @@ QString cdbSourcePathMapping(QString fileName,
|
||||
const QList<QPair<QString, QString> > &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<QPair<QString, QString> > &sourcePathMapping,
|
||||
|
||||
Reference in New Issue
Block a user