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

@@ -133,7 +133,6 @@ void CoreGdbAdapter::handleTargetCore1(const GdbResponse &response)
m_engine->postCommand(_("detach"), CB(handleDetach1));
}
} else {
QTC_ASSERT(response.resultClass == GdbResultError, /**/);
const QByteArray msg = response.data.findChild("msg").data();
setState(InferiorStartFailed);
emit inferiorStartFailed(msg);
@@ -149,7 +148,6 @@ void CoreGdbAdapter::handleDetach1(const GdbResponse &response)
m_engine->postCommand(_("-file-exec-and-symbols \"%1\"")
.arg(fi.absoluteFilePath()), CB(handleFileExecAndSymbols));
} else {
QTC_ASSERT(response.resultClass == GdbResultError, /**/);
const QByteArray msg = response.data.findChild("msg").data();
setState(InferiorStartFailed);
emit inferiorStartFailed(msg);
@@ -165,7 +163,7 @@ void CoreGdbAdapter::handleFileExecAndSymbols(const GdbResponse &response)
QFileInfo fi(startParameters().coreFile);
QString coreName = fi.absoluteFilePath();
m_engine->postCommand(_("target core ") + coreName, CB(handleTargetCore2));
} else if (response.resultClass == GdbResultError) {
} else {
QString msg = tr("Symbols not found in \"%1\" failed:\n%2")
.arg(__(response.data.findChild("msg").data()));
setState(InferiorUnrunnable);
@@ -182,7 +180,7 @@ void CoreGdbAdapter::handleTargetCore2(const GdbResponse &response)
showStatusMessage(tr("Attached to core."));
setState(InferiorUnrunnable);
m_engine->updateAll();
} else if (response.resultClass == GdbResultError) {
} else {
QString msg = tr("Attach to core \"%1\" failed:\n%2")
.arg(__(response.data.findChild("msg").data()));
setState(InferiorUnrunnable);
@@ -220,7 +218,7 @@ void CoreGdbAdapter::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);
}