forked from qt-creator/qt-creator
make attaching adapters more robust
to make the behavior consistent across gdb versions, ignore the initial *stopped which gdb7 delivers while attaching. Reviewed-By: hjk
This commit is contained in:
@@ -77,17 +77,9 @@ void AttachGdbAdapter::startInferior()
|
||||
|
||||
void AttachGdbAdapter::handleAttach(const GdbResponse &response)
|
||||
{
|
||||
if (response.resultClass == GdbResultDone) {
|
||||
// We don't know the exact 6.8.50 build where gdb started emitting
|
||||
// *stopped here, so allow for some slack.
|
||||
if (m_engine->m_gdbVersion < 60850) {
|
||||
QTC_ASSERT(state() == InferiorStarting, qDebug() << state());
|
||||
if (response.resultClass == GdbResultDone) {
|
||||
setState(InferiorStopped);
|
||||
} else if (m_engine->m_gdbVersion < 70000 && state() == InferiorStarting) {
|
||||
setState(InferiorStopped);
|
||||
} else {
|
||||
QTC_ASSERT(state() == InferiorStopped, qDebug() << state());
|
||||
}
|
||||
debugMessage(_("INFERIOR ATTACHED"));
|
||||
showStatusMessage(msgAttachedToStoppedInferior());
|
||||
emit inferiorPrepared();
|
||||
|
||||
@@ -889,6 +889,7 @@ void GdbEngine::updateAll()
|
||||
{
|
||||
QTC_ASSERT(state() == InferiorUnrunnable || state() == InferiorStopped, /**/);
|
||||
tryLoadDebuggingHelpers();
|
||||
reloadModulesInternal();
|
||||
postCommand(_("-stack-list-frames"), WatchUpdate, CB(handleStackListFrames),
|
||||
QVariant::fromValue<StackCookie>(StackCookie(false, true)));
|
||||
manager()->stackHandler()->setCurrentIndex(0);
|
||||
@@ -1009,6 +1010,11 @@ void GdbEngine::handleAqcuiredInferior()
|
||||
|
||||
void GdbEngine::handleStopResponse(const GdbMi &data)
|
||||
{
|
||||
// This is gdb 7+'s initial *stopped in response to attach.
|
||||
// For consistency, we just discard it.
|
||||
if (state() == InferiorStarting)
|
||||
return;
|
||||
|
||||
const QByteArray reason = data.findChild("reason").data();
|
||||
|
||||
if (isExitedReason(reason)) {
|
||||
@@ -1051,15 +1057,11 @@ void GdbEngine::handleStopResponse(const GdbMi &data)
|
||||
return;
|
||||
}
|
||||
|
||||
bool initHelpers = true;
|
||||
if (state() == InferiorRunning) {
|
||||
// Stop triggered by a breakpoint or otherwise not directly
|
||||
// initiated by the user.
|
||||
setState(InferiorStopping);
|
||||
} else {
|
||||
if (state() == InferiorStarting)
|
||||
initHelpers = false;
|
||||
else
|
||||
QTC_ASSERT(state() == InferiorStopping, qDebug() << state());
|
||||
}
|
||||
setState(InferiorStopped);
|
||||
@@ -1138,8 +1140,7 @@ void GdbEngine::handleStopResponse(const GdbMi &data)
|
||||
}
|
||||
}
|
||||
|
||||
if (initHelpers && m_debuggingHelperState != DebuggingHelperUninitialized)
|
||||
initHelpers = false;
|
||||
bool initHelpers = (m_debuggingHelperState == DebuggingHelperUninitialized);
|
||||
// Don't load helpers on stops triggered by signals unless it's
|
||||
// an intentional trap.
|
||||
if (initHelpers && reason == "signal-received"
|
||||
|
||||
@@ -191,8 +191,9 @@ void RemoteGdbAdapter::handleFileExecAndSymbols(const GdbResponse &response)
|
||||
|
||||
void RemoteGdbAdapter::handleTargetRemote(const GdbResponse &record)
|
||||
{
|
||||
QTC_ASSERT(state() == InferiorStarting, qDebug() << state());
|
||||
if (record.resultClass == GdbResultDone) {
|
||||
QTC_ASSERT(state() == InferiorStopped, qDebug() << state());
|
||||
setState(InferiorStopped);
|
||||
// gdb server will stop the remote application itself.
|
||||
debugMessage(_("INFERIOR STARTED"));
|
||||
showStatusMessage(msgAttachedToStoppedInferior());
|
||||
|
||||
@@ -114,8 +114,9 @@ void TermGdbAdapter::startInferior()
|
||||
|
||||
void TermGdbAdapter::handleStubAttached(const GdbResponse &response)
|
||||
{
|
||||
QTC_ASSERT(state() == InferiorStarting, qDebug() << state());
|
||||
if (response.resultClass == GdbResultDone) {
|
||||
QTC_ASSERT(state() == InferiorStopped, qDebug() << state());
|
||||
setState(InferiorStopped);
|
||||
debugMessage(_("INFERIOR ATTACHED"));
|
||||
emit inferiorPrepared();
|
||||
} else if (response.resultClass == GdbResultError) {
|
||||
|
||||
@@ -1616,6 +1616,7 @@ void TrkGdbAdapter::handleTargetRemote(const GdbResponse &record)
|
||||
{
|
||||
QTC_ASSERT(state() == InferiorStarting, qDebug() << state());
|
||||
if (record.resultClass == GdbResultDone) {
|
||||
setState(InferiorStopped);
|
||||
emit inferiorPrepared();
|
||||
} else {
|
||||
QString msg = tr("Connecting to TRK server adapter failed:\n")
|
||||
|
||||
Reference in New Issue
Block a user