forked from qt-creator/qt-creator
Debugger: Switch attach and setting of breakpoints
This avoids a race on Windows, where attaching is non-atomic. Task-number: QTCREATORBUG-8663 Change-Id: I119cae7129882fabaa97fa3f236379e5efe62df9 Reviewed-by: David Schulz <david.schulz@digia.com> Reviewed-by: Christian Stenger <christian.stenger@digia.com>
This commit is contained in:
@@ -2841,14 +2841,14 @@ void GdbEngine::changeBreakpoint(BreakpointModelId id)
|
|||||||
QTC_ASSERT(state2 == BreakpointChangeProceeding, qDebug() << state2);
|
QTC_ASSERT(state2 == BreakpointChangeProceeding, qDebug() << state2);
|
||||||
QVariant vid = QVariant::fromValue(id);
|
QVariant vid = QVariant::fromValue(id);
|
||||||
|
|
||||||
if (data.threadSpec != response.threadSpec) {
|
if (!response.pending && data.threadSpec != response.threadSpec) {
|
||||||
// The only way to change this seems to be to re-set the bp completely.
|
// The only way to change this seems to be to re-set the bp completely.
|
||||||
postCommand("-break-delete " + bpnr,
|
postCommand("-break-delete " + bpnr,
|
||||||
NeedsStop | RebuildBreakpointModel,
|
NeedsStop | RebuildBreakpointModel,
|
||||||
CB(handleBreakThreadSpec), vid);
|
CB(handleBreakThreadSpec), vid);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (data.lineNumber != response.lineNumber) {
|
if (!response.pending && data.lineNumber != response.lineNumber) {
|
||||||
// The only way to change this seems to be to re-set the bp completely.
|
// The only way to change this seems to be to re-set the bp completely.
|
||||||
postCommand("-break-delete " + bpnr,
|
postCommand("-break-delete " + bpnr,
|
||||||
NeedsStop | RebuildBreakpointModel,
|
NeedsStop | RebuildBreakpointModel,
|
||||||
|
|||||||
@@ -123,11 +123,18 @@ void GdbTermEngine::setupInferior()
|
|||||||
QTC_ASSERT(state() == InferiorSetupRequested, qDebug() << state());
|
QTC_ASSERT(state() == InferiorSetupRequested, qDebug() << state());
|
||||||
const qint64 attachedPID = m_stubProc.applicationPID();
|
const qint64 attachedPID = m_stubProc.applicationPID();
|
||||||
const qint64 attachedMainThreadID = m_stubProc.applicationMainThreadID();
|
const qint64 attachedMainThreadID = m_stubProc.applicationMainThreadID();
|
||||||
const QString msg = (attachedMainThreadID != -1)
|
|
||||||
? QString::fromLatin1("Attaching to %1 (%2)").arg(attachedPID).arg(attachedMainThreadID)
|
|
||||||
: QString::fromLatin1("Attaching to %1").arg(attachedPID);
|
|
||||||
showMessage(msg, LogMisc);
|
|
||||||
notifyInferiorPid(attachedPID);
|
notifyInferiorPid(attachedPID);
|
||||||
|
const QString msg = (attachedMainThreadID != -1)
|
||||||
|
? QString::fromLatin1("Going to attach to %1 (%2)").arg(attachedPID).arg(attachedMainThreadID)
|
||||||
|
: QString::fromLatin1("Going to attach to %1").arg(attachedPID);
|
||||||
|
showMessage(msg, LogMisc);
|
||||||
|
handleInferiorPrepared();
|
||||||
|
}
|
||||||
|
|
||||||
|
void GdbTermEngine::runEngine()
|
||||||
|
{
|
||||||
|
QTC_ASSERT(state() == EngineRunRequested, qDebug() << state());
|
||||||
|
const qint64 attachedPID = m_stubProc.applicationPID();
|
||||||
postCommand("attach " + QByteArray::number(attachedPID),
|
postCommand("attach " + QByteArray::number(attachedPID),
|
||||||
CB(handleStubAttached));
|
CB(handleStubAttached));
|
||||||
}
|
}
|
||||||
@@ -154,28 +161,25 @@ void GdbTermEngine::handleStubAttached(const GdbResponse &response)
|
|||||||
LogWarning);
|
LogWarning);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
handleInferiorPrepared();
|
notifyEngineRunAndInferiorStopOk();
|
||||||
|
continueInferiorInternal();
|
||||||
break;
|
break;
|
||||||
case GdbResultError:
|
case GdbResultError:
|
||||||
if (response.data["msg"].data() == "ptrace: Operation not permitted.") {
|
if (response.data["msg"].data() == "ptrace: Operation not permitted.") {
|
||||||
notifyInferiorSetupFailed(msgPtraceError(startParameters().startMode));
|
showMessage(msgPtraceError(startParameters().startMode));
|
||||||
|
notifyEngineRunFailed();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
notifyInferiorSetupFailed(QString::fromLocal8Bit(response.data["msg"].data()));
|
showMessage(QString::fromLocal8Bit(response.data["msg"].data()));
|
||||||
|
notifyEngineRunFailed();
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
notifyInferiorSetupFailed(QString::fromLatin1("Invalid response %1").arg(response.resultClass));
|
showMessage(QString::fromLatin1("Invalid response %1").arg(response.resultClass));
|
||||||
|
notifyEngineRunFailed();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void GdbTermEngine::runEngine()
|
|
||||||
{
|
|
||||||
QTC_ASSERT(state() == EngineRunRequested, qDebug() << state());
|
|
||||||
notifyEngineRunAndInferiorStopOk();
|
|
||||||
continueInferiorInternal();
|
|
||||||
}
|
|
||||||
|
|
||||||
void GdbTermEngine::interruptInferior2()
|
void GdbTermEngine::interruptInferior2()
|
||||||
{
|
{
|
||||||
interruptLocalInferior(inferiorPid());
|
interruptLocalInferior(inferiorPid());
|
||||||
|
|||||||
Reference in New Issue
Block a user