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

@@ -1679,7 +1679,7 @@ void TrkGdbAdapter::handleTargetRemote(const GdbResponse &record)
if (record.resultClass == GdbResultDone) {
setState(InferiorPrepared);
emit inferiorPrepared();
} else if (record.resultClass == GdbResultError) {
} else {
QString msg = tr("Connecting to trk server adapter failed:\n")
+ _(record.data.findChild("msg").data());
emit inferiorPreparationFailed(msg);
@@ -1699,7 +1699,7 @@ void TrkGdbAdapter::handleFirstContinue(const GdbResponse &record)
if (record.resultClass == GdbResultDone) {
debugMessage(_("INFERIOR STARTED"));
showStatusMessage(msgInferiorRunning());
} else if (record.resultClass == GdbResultError) {
} else {
emit inferiorStartFailed(msgConnectRemoteServerFailed(record.toString()));
}
}
@@ -2076,7 +2076,7 @@ void TrkGdbAdapter::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);
@@ -2088,7 +2088,7 @@ void TrkGdbAdapter::handleExit(const GdbResponse &response)
if (response.resultClass == GdbResultDone) {
qDebug() << "EXITED, NO MESSAGE...";
// 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);
}