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