centralize gdb command result class checking

each command can have only one of two legitimate responses: "error" or -
depending on the command, and thus declared via a flag - "done" or
"running".
this is way nicer than sprinkling the code with else-ifs (where elses
are sufficient) and asserts all over the place - and silently failing in
release builds.
This commit is contained in:
Oswald Buddenhagen
2009-10-12 12:00:07 +02:00
parent 2de8f49ee3
commit a1a8f6adcb
9 changed files with 60 additions and 58 deletions

View File

@@ -122,7 +122,7 @@ void PlainGdbAdapter::handleFileExecAndSymbols(const GdbResponse &response)
//m_breakHandler->clearBreakMarkers();
setState(InferiorPrepared);
emit inferiorPrepared();
} else if (response.resultClass == GdbResultError) {
} else {
QString msg = tr("Starting executable failed:\n") +
__(response.data.findChild("msg").data());
setState(InferiorPreparationFailed);
@@ -138,7 +138,6 @@ void PlainGdbAdapter::handleExecRun(const GdbResponse &response)
showStatusMessage(msgInferiorStarted());
} else {
QTC_ASSERT(state() == InferiorRunningRequested, qDebug() << state());
QTC_ASSERT(response.resultClass == GdbResultError, /**/);
const QByteArray &msg = response.data.findChild("msg").data();
//QTC_ASSERT(status() == InferiorRunning, /**/);
//interruptInferior();
@@ -151,7 +150,7 @@ void PlainGdbAdapter::startInferior()
{
QTC_ASSERT(state() == InferiorStarting, qDebug() << state());
setState(InferiorRunningRequested);
m_engine->postCommand(_("-exec-run"), CB(handleExecRun));
m_engine->postCommand(_("-exec-run"), GdbEngine::RunRequest, CB(handleExecRun));
}
void PlainGdbAdapter::interruptInferior()
@@ -218,7 +217,7 @@ void PlainGdbAdapter::handleKill(const GdbResponse &response)
setState(InferiorShutDown);
emit inferiorShutDown();
shutdown(); // re-iterate...
} else if (response.resultClass == GdbResultError) {
} else {
const QString msg = msgInferiorStopFailed(__(response.data.findChild("msg").data()));
setState(InferiorShutdownFailed);
emit inferiorShutdownFailed(msg);
@@ -229,7 +228,7 @@ void PlainGdbAdapter::handleExit(const GdbResponse &response)
{
if (response.resultClass == GdbResultDone) {
// don't set state here, this will be handled in handleGdbFinished()
} else if (response.resultClass == GdbResultError) {
} else {
const QString msg = msgGdbStopFailed(__(response.data.findChild("msg").data()));
emit adapterShutdownFailed(msg);
}