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