debugger: retrieve InferiorRunning state from gdb output, not from business logic

This commit is contained in:
hjk
2009-09-28 15:06:17 +02:00
parent 214d998b63
commit bc15777ee1
2 changed files with 18 additions and 14 deletions

View File

@@ -555,18 +555,21 @@ void GdbEngine::handleResponse(const QByteArray &buff)
break; break;
QByteArray resultClass = QByteArray::fromRawData(from, inner - from); QByteArray resultClass = QByteArray::fromRawData(from, inner - from);
if (resultClass == "done") if (resultClass == "done") {
response.resultClass = GdbResultDone; response.resultClass = GdbResultDone;
else if (resultClass == "running") } else if (resultClass == "running") {
setState(InferiorRunning);
showStatusMessage(tr("Running..."));
response.resultClass = GdbResultRunning; response.resultClass = GdbResultRunning;
else if (resultClass == "connected") } else if (resultClass == "connected") {
response.resultClass = GdbResultConnected; response.resultClass = GdbResultConnected;
else if (resultClass == "error") } else if (resultClass == "error") {
response.resultClass = GdbResultError; response.resultClass = GdbResultError;
else if (resultClass == "exit") } else if (resultClass == "exit") {
response.resultClass = GdbResultExit; response.resultClass = GdbResultExit;
else } else {
response.resultClass = GdbResultUnknown; response.resultClass = GdbResultUnknown;
}
from = inner; from = inner;
if (from != to) { if (from != to) {
@@ -1422,12 +1425,11 @@ void GdbEngine::handleFileExecAndSymbols(const GdbResponse &response)
void GdbEngine::handleExecContinue(const GdbResponse &response) void GdbEngine::handleExecContinue(const GdbResponse &response)
{ {
QTC_ASSERT(state() == InferiorRunningRequested, /**/);
if (response.resultClass == GdbResultRunning) { if (response.resultClass == GdbResultRunning) {
setState(InferiorRunning); // The "running" state is picked up in handleResponse()
showStatusMessage(tr("Running..."), 5000); QTC_ASSERT(state() == InferiorRunning, /**/);
} else { } else if (response.resultClass == GdbResultError) {
QTC_ASSERT(response.resultClass == GdbResultError, /**/); QTC_ASSERT(state() == InferiorRunningRequested, /**/);
const QByteArray &msg = response.data.findChild("msg").data(); const QByteArray &msg = response.data.findChild("msg").data();
if (msg == "Cannot find bounds of current function") { if (msg == "Cannot find bounds of current function") {
setState(InferiorStopped); setState(InferiorStopped);
@@ -1441,6 +1443,8 @@ void GdbEngine::handleExecContinue(const GdbResponse &response)
QTC_ASSERT(state() == InferiorRunning, /**/); QTC_ASSERT(state() == InferiorRunning, /**/);
shutdown(); shutdown();
} }
} else {
QTC_ASSERT(false, /**/);
} }
} }
@@ -4150,7 +4154,7 @@ void GdbEngine::handleInferiorStartFailed(const QString &msg)
void GdbEngine::handleInferiorStarted() void GdbEngine::handleInferiorStarted()
{ {
QTC_ASSERT(state() == InferiorRunningRequested QTC_ASSERT(state() == InferiorRunning
|| state() == InferiorStopped, qDebug() << state()); || state() == InferiorStopped, qDebug() << state());
debugMessage(_("INFERIOR STARTED")); debugMessage(_("INFERIOR STARTED"));
if (state() == InferiorStopped) if (state() == InferiorStopped)

View File

@@ -209,11 +209,11 @@ void PlainGdbAdapter::handleInfoTarget(const GdbResponse &response)
void PlainGdbAdapter::handleExecRun(const GdbResponse &response) void PlainGdbAdapter::handleExecRun(const GdbResponse &response)
{ {
QTC_ASSERT(state() == InferiorRunningRequested, qDebug() << state());
if (response.resultClass == GdbResultRunning) { if (response.resultClass == GdbResultRunning) {
QTC_ASSERT(state() == InferiorRunning, qDebug() << state());
emit inferiorStarted(); emit inferiorStarted();
setState(InferiorRunning);
} else { } else {
QTC_ASSERT(state() == InferiorRunningRequested, qDebug() << state());
QTC_ASSERT(response.resultClass == GdbResultError, /**/); QTC_ASSERT(response.resultClass == GdbResultError, /**/);
const QByteArray &msg = response.data.findChild("msg").data(); const QByteArray &msg = response.data.findChild("msg").data();
//QTC_ASSERT(status() == InferiorRunning, /**/); //QTC_ASSERT(status() == InferiorRunning, /**/);