forked from qt-creator/qt-creator
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:
@@ -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);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user