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

@@ -184,7 +184,7 @@ void RemoteGdbAdapter::handleSetTargetAsync(const GdbResponse &response)
QString fileName = fi.absoluteFilePath();
m_engine->postCommand(_("-file-exec-and-symbols \"%1\"").arg(fileName),
CB(handleFileExecAndSymbols));
} else if (response.resultClass == GdbResultError) {
} else {
QString msg = tr("Adapter too old: does not support asynchronous mode.");
setState(InferiorPreparationFailed);
emit inferiorPreparationFailed(msg);
@@ -198,7 +198,7 @@ void RemoteGdbAdapter::handleFileExecAndSymbols(const GdbResponse &response)
//m_breakHandler->clearBreakMarkers();
m_engine->setState(InferiorPrepared);
emit inferiorPrepared();
} else if (response.resultClass == GdbResultError) {
} else {
QString msg = tr("Starting remote executable failed:\n");
msg += __(response.data.findChild("msg").data());
setState(InferiorPreparationFailed);
@@ -215,7 +215,7 @@ void RemoteGdbAdapter::handleTargetRemote(const GdbResponse &record)
showStatusMessage(msgAttachedToStoppedInferior());
setState(InferiorStopped);
m_engine->continueInferior();
} else if (record.resultClass == GdbResultError) {
} else {
// 16^error,msg="hd:5555: Connection timed out."
QString msg = msgConnectRemoteServerFailed(__(record.data.findChild("msg").data()));
setState(InferiorPreparationFailed);
@@ -271,7 +271,7 @@ void RemoteGdbAdapter::handleKill(const GdbResponse &response)
setState(InferiorShutDown);
emit inferiorShutDown();
shutdown(); // re-iterate...
} else if (response.resultClass == GdbResultError) {
} else {
QString msg = msgInferiorStopFailed(__(response.data.findChild("msg").data()));
setState(InferiorShutdownFailed);
emit inferiorShutdownFailed(msg);
@@ -282,7 +282,7 @@ void RemoteGdbAdapter::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 {
QString msg = msgGdbStopFailed(__(response.data.findChild("msg").data()));
emit adapterShutdownFailed(msg);
}