forked from qt-creator/qt-creator
debugger: replace BreakpointPending state with a flag in BreakpointResponse
To keep the breakpoint state machinery simple
This commit is contained in:
@@ -569,17 +569,12 @@ static bool isAllowedTransition(BreakpointState from, BreakpointState to)
|
|||||||
return to == BreakpointInsertProceeding;
|
return to == BreakpointInsertProceeding;
|
||||||
case BreakpointInsertProceeding:
|
case BreakpointInsertProceeding:
|
||||||
return to == BreakpointInserted
|
return to == BreakpointInserted
|
||||||
|| to == BreakpointPending
|
|
||||||
|| to == BreakpointDead;
|
|| to == BreakpointDead;
|
||||||
case BreakpointChangeRequested:
|
case BreakpointChangeRequested:
|
||||||
return to == BreakpointChangeProceeding;
|
return to == BreakpointChangeProceeding;
|
||||||
case BreakpointChangeProceeding:
|
case BreakpointChangeProceeding:
|
||||||
return to == BreakpointInserted
|
return to == BreakpointInserted
|
||||||
|| to == BreakpointPending
|
|
||||||
|| to == BreakpointDead;
|
|| to == BreakpointDead;
|
||||||
case BreakpointPending:
|
|
||||||
return to == BreakpointChangeRequested
|
|
||||||
|| to == BreakpointRemoveRequested;
|
|
||||||
case BreakpointInserted:
|
case BreakpointInserted:
|
||||||
return to == BreakpointChangeRequested
|
return to == BreakpointChangeRequested
|
||||||
|| to == BreakpointRemoveRequested;
|
|| to == BreakpointRemoveRequested;
|
||||||
@@ -610,6 +605,18 @@ void BreakHandler::setState(BreakpointId id, BreakpointState state)
|
|||||||
it->state = state;
|
it->state = state;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static bool needsChange(const BreakpointParameters &data,
|
||||||
|
const BreakpointResponse &response)
|
||||||
|
{
|
||||||
|
if (!data.conditionsMatch(response.condition))
|
||||||
|
return true;
|
||||||
|
if (data.ignoreCount != response.ignoreCount)
|
||||||
|
return true;
|
||||||
|
if (data.enabled != response.enabled)
|
||||||
|
return true;
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
void BreakHandler::notifyBreakpointInsertProceeding(BreakpointId id)
|
void BreakHandler::notifyBreakpointInsertProceeding(BreakpointId id)
|
||||||
{
|
{
|
||||||
QTC_ASSERT(state(id)== BreakpointInsertRequested, /**/);
|
QTC_ASSERT(state(id)== BreakpointInsertRequested, /**/);
|
||||||
@@ -620,6 +627,12 @@ void BreakHandler::notifyBreakpointInsertOk(BreakpointId id)
|
|||||||
{
|
{
|
||||||
QTC_ASSERT(state(id)== BreakpointInsertProceeding, /**/);
|
QTC_ASSERT(state(id)== BreakpointInsertProceeding, /**/);
|
||||||
setState(id, BreakpointInserted);
|
setState(id, BreakpointInserted);
|
||||||
|
ConstIterator it = m_storage.find(id);
|
||||||
|
QTC_ASSERT(it != m_storage.end(), return);
|
||||||
|
if (needsChange(it->data, it->response)) {
|
||||||
|
setState(id, BreakpointChangeRequested);
|
||||||
|
scheduleSynchronization();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void BreakHandler::notifyBreakpointInsertFailed(BreakpointId id)
|
void BreakHandler::notifyBreakpointInsertFailed(BreakpointId id)
|
||||||
@@ -660,12 +673,6 @@ void BreakHandler::notifyBreakpointChangeFailed(BreakpointId id)
|
|||||||
setState(id, BreakpointDead);
|
setState(id, BreakpointDead);
|
||||||
}
|
}
|
||||||
|
|
||||||
void BreakHandler::notifyBreakpointPending(BreakpointId id)
|
|
||||||
{
|
|
||||||
//QTC_ASSERT(state(id)== BreakpointInsertProceeding, /**/);
|
|
||||||
setState(id, BreakpointPending);
|
|
||||||
}
|
|
||||||
|
|
||||||
void BreakHandler::notifyBreakpointReleased(BreakpointId id)
|
void BreakHandler::notifyBreakpointReleased(BreakpointId id)
|
||||||
{
|
{
|
||||||
//QTC_ASSERT(state(id) == BreakpointChangeProceeding, /**/);
|
//QTC_ASSERT(state(id) == BreakpointChangeProceeding, /**/);
|
||||||
@@ -902,7 +909,7 @@ void BreakHandler::setResponse(BreakpointId id, const BreakpointResponse &data)
|
|||||||
{
|
{
|
||||||
Iterator it = m_storage.find(id);
|
Iterator it = m_storage.find(id);
|
||||||
QTC_ASSERT(it != m_storage.end(), return);
|
QTC_ASSERT(it != m_storage.end(), return);
|
||||||
it->response = BreakpointResponse(data);
|
it->response = data;
|
||||||
updateMarker(id);
|
updateMarker(id);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -952,7 +959,6 @@ static QString stateToString(BreakpointState state)
|
|||||||
case BreakpointInsertProceeding: return "insertion proceeding";
|
case BreakpointInsertProceeding: return "insertion proceeding";
|
||||||
case BreakpointChangeRequested: return "change requested";
|
case BreakpointChangeRequested: return "change requested";
|
||||||
case BreakpointChangeProceeding: return "change proceeding";
|
case BreakpointChangeProceeding: return "change proceeding";
|
||||||
case BreakpointPending: return "breakpoint pending";
|
|
||||||
case BreakpointInserted: return "breakpoint inserted";
|
case BreakpointInserted: return "breakpoint inserted";
|
||||||
case BreakpointRemoveRequested: return "removal requested";
|
case BreakpointRemoveRequested: return "removal requested";
|
||||||
case BreakpointRemoveProceeding: return "removal is proceeding";
|
case BreakpointRemoveProceeding: return "removal is proceeding";
|
||||||
|
@@ -176,8 +176,7 @@ private:
|
|||||||
BreakpointItem();
|
BreakpointItem();
|
||||||
|
|
||||||
void destroyMarker();
|
void destroyMarker();
|
||||||
bool isPending() const { return state == BreakpointPending
|
bool isPending() const { return response.pending; }
|
||||||
|| state == BreakpointNew; }
|
|
||||||
bool isLocatedAt(const QString &fileName, int lineNumber,
|
bool isLocatedAt(const QString &fileName, int lineNumber,
|
||||||
bool useMarkerPosition) const;
|
bool useMarkerPosition) const;
|
||||||
QString toToolTip() const;
|
QString toToolTip() const;
|
||||||
|
@@ -92,7 +92,7 @@ QString BreakpointParameters::toString() const
|
|||||||
//////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
BreakpointResponse::BreakpointResponse()
|
BreakpointResponse::BreakpointResponse()
|
||||||
: number(0), multiple(false)
|
: number(0), pending(true), multiple(false)
|
||||||
{}
|
{}
|
||||||
|
|
||||||
QString BreakpointResponse::toString() const
|
QString BreakpointResponse::toString() const
|
||||||
@@ -100,15 +100,11 @@ QString BreakpointResponse::toString() const
|
|||||||
QString result;
|
QString result;
|
||||||
QTextStream ts(&result);
|
QTextStream ts(&result);
|
||||||
ts << number;
|
ts << number;
|
||||||
ts << condition;
|
ts << pending;
|
||||||
ts << ignoreCount;
|
|
||||||
ts << fileName;
|
|
||||||
ts << fullName;
|
ts << fullName;
|
||||||
ts << lineNumber;
|
ts << multiple;
|
||||||
ts << threadSpec;
|
ts << extra;
|
||||||
ts << functionName;
|
return result + BreakpointParameters::toString();
|
||||||
ts << address;
|
|
||||||
return result;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void BreakpointResponse::fromParameters(const BreakpointParameters &p)
|
void BreakpointResponse::fromParameters(const BreakpointParameters &p)
|
||||||
|
@@ -65,7 +65,6 @@ enum BreakpointState
|
|||||||
BreakpointInsertProceeding,
|
BreakpointInsertProceeding,
|
||||||
BreakpointChangeRequested,
|
BreakpointChangeRequested,
|
||||||
BreakpointChangeProceeding,
|
BreakpointChangeProceeding,
|
||||||
BreakpointPending,
|
|
||||||
BreakpointInserted,
|
BreakpointInserted,
|
||||||
BreakpointRemoveRequested,
|
BreakpointRemoveRequested,
|
||||||
BreakpointRemoveProceeding,
|
BreakpointRemoveProceeding,
|
||||||
@@ -110,6 +109,7 @@ public:
|
|||||||
void fromParameters(const BreakpointParameters &p);
|
void fromParameters(const BreakpointParameters &p);
|
||||||
|
|
||||||
int number; // Breakpoint number assigned by the debugger engine.
|
int number; // Breakpoint number assigned by the debugger engine.
|
||||||
|
bool pending; // Breakpoint not fully resolved.
|
||||||
QString fullName; // Full file name acknowledged by the debugger engine.
|
QString fullName; // Full file name acknowledged by the debugger engine.
|
||||||
bool multiple; // Happens in constructors/gdb.
|
bool multiple; // Happens in constructors/gdb.
|
||||||
QByteArray extra; // gdb: <PENDING>, <MULTIPLE>
|
QByteArray extra; // gdb: <PENDING>, <MULTIPLE>
|
||||||
|
@@ -1257,11 +1257,8 @@ void DebuggerEngine::attemptBreakpointSynchronization()
|
|||||||
//qDebug() << "BREAKPOINT " << id << " STILL IN PROGRESS, STATE"
|
//qDebug() << "BREAKPOINT " << id << " STILL IN PROGRESS, STATE"
|
||||||
// << handler->state(id);
|
// << handler->state(id);
|
||||||
continue;
|
continue;
|
||||||
case BreakpointPending:
|
|
||||||
//qDebug() << "BREAKPOINT " << id << " IS GOOD: PENDING";
|
|
||||||
continue;
|
|
||||||
case BreakpointInserted:
|
case BreakpointInserted:
|
||||||
//qDebug() << "BREAKPOINT " << id << " IS GOOD: INSERTED";
|
//qDebug() << "BREAKPOINT " << id << " IS GOOD";
|
||||||
continue;
|
continue;
|
||||||
case BreakpointDead:
|
case BreakpointDead:
|
||||||
// Should not only be visible inside BreakpointHandler.
|
// Should not only be visible inside BreakpointHandler.
|
||||||
|
@@ -2026,7 +2026,6 @@ void GdbEngine::updateBreakpointDataFromOutput(BreakpointId id, const GdbMi &bkp
|
|||||||
QTC_ASSERT(bkpt.isValid(), return);
|
QTC_ASSERT(bkpt.isValid(), return);
|
||||||
BreakpointResponse response = breakHandler()->response(id);
|
BreakpointResponse response = breakHandler()->response(id);
|
||||||
|
|
||||||
bool pending = false;
|
|
||||||
response.multiple = false;
|
response.multiple = false;
|
||||||
response.enabled = true;
|
response.enabled = true;
|
||||||
response.condition.clear();
|
response.condition.clear();
|
||||||
@@ -2065,8 +2064,7 @@ void GdbEngine::updateBreakpointDataFromOutput(BreakpointId id, const GdbMi &bkp
|
|||||||
} else if (child.hasName("enabled")) {
|
} else if (child.hasName("enabled")) {
|
||||||
response.enabled = (child.data() == "y");
|
response.enabled = (child.data() == "y");
|
||||||
} else if (child.hasName("pending")) {
|
} else if (child.hasName("pending")) {
|
||||||
//data->setState(BreakpointPending);
|
response.pending = true;
|
||||||
pending = true;
|
|
||||||
// Any content here would be interesting only if we did accept
|
// Any content here would be interesting only if we did accept
|
||||||
// spontaneously appearing breakpoints (user using gdb commands).
|
// spontaneously appearing breakpoints (user using gdb commands).
|
||||||
} else if (child.hasName("at")) {
|
} else if (child.hasName("at")) {
|
||||||
@@ -2104,12 +2102,8 @@ void GdbEngine::updateBreakpointDataFromOutput(BreakpointId id, const GdbMi &bkp
|
|||||||
if (!name.isEmpty())
|
if (!name.isEmpty())
|
||||||
response.fileName = name;
|
response.fileName = name;
|
||||||
|
|
||||||
// FIXME: Should this honour current state?
|
|
||||||
if (pending)
|
|
||||||
breakHandler()->notifyBreakpointPending(id);
|
|
||||||
else
|
|
||||||
breakHandler()->notifyBreakpointInsertOk(id);
|
|
||||||
breakHandler()->setResponse(id, response);
|
breakHandler()->setResponse(id, response);
|
||||||
|
breakHandler()->notifyBreakpointInsertOk(id);
|
||||||
}
|
}
|
||||||
|
|
||||||
QString GdbEngine::breakLocation(const QString &file) const
|
QString GdbEngine::breakLocation(const QString &file) const
|
||||||
|
Reference in New Issue
Block a user