diff --git a/src/plugins/debugger/debuggerconstants.h b/src/plugins/debugger/debuggerconstants.h index 87882b8ce3543e281187f882ead20e8e00d6749d..b1f5b270227ca87121a7d610d976d580abea4c88 100644 --- a/src/plugins/debugger/debuggerconstants.h +++ b/src/plugins/debugger/debuggerconstants.h @@ -72,6 +72,7 @@ enum DebuggerState InferiorPreparing, InferiorPrepared, InferiorPreparationFailed, + InferiorUnrunnable, // Used in the core dump adapter InferiorStarting, // InferiorStarted, // Use InferiorRunningRequested or InferiorStopped InferiorStartFailed, diff --git a/src/plugins/debugger/debuggermanager.cpp b/src/plugins/debugger/debuggermanager.cpp index 24e6322a63fe9a01158bdb61eb22b5b4ce25fc15..02494d42d332c7e989103970cfe7949d4d26d075 100644 --- a/src/plugins/debugger/debuggermanager.cpp +++ b/src/plugins/debugger/debuggermanager.cpp @@ -195,6 +195,7 @@ static const char *stateName(int s) SN(InferiorStartFailed) SN(InferiorRunningRequested) SN(InferiorRunning) + SN(InferiorUnrunnable) SN(InferiorStopping) SN(InferiorStopped) SN(InferiorStopFailed) @@ -1571,7 +1572,7 @@ static bool isAllowedTransition(int from, int to) case InferiorStarting: return to == InferiorRunningRequested || to == InferiorStopped - || to == InferiorStartFailed; + || to == InferiorStartFailed || to == InferiorUnrunnable; case InferiorStartFailed: return to == DebuggerNotReady; @@ -1587,6 +1588,8 @@ static bool isAllowedTransition(int from, int to) case InferiorStopFailed: return to == DebuggerNotReady; + case InferiorUnrunnable: + return to == AdapterShuttingDown; case InferiorShuttingDown: return to == InferiorShutDown || to == InferiorShutdownFailed; case InferiorShutDown: @@ -1630,44 +1633,45 @@ void DebuggerManager::setState(DebuggerState state) emit debuggingFinished(); } - const bool started = state == InferiorRunning + const bool stoppable = state == InferiorRunning || state == InferiorRunningRequested || state == InferiorStopping - || state == InferiorStopped; + || state == InferiorStopped + || state == InferiorUnrunnable; const bool running = state == InferiorRunning; + const bool stopped = state == InferiorStopped; - const bool ready = state == InferiorStopped - && d->m_startParameters->startMode != AttachCore; - - if (ready) + if (stopped) QApplication::alert(mainWindow(), 3000); - d->m_actions.watchAction->setEnabled(ready); + d->m_actions.watchAction->setEnabled(stopped); d->m_actions.breakAction->setEnabled(true); bool interruptIsExit = !running; if (interruptIsExit) { - d->m_actions.stopAction->setIcon(QIcon(":/debugger/images/debugger_stop_small.png")); + static QIcon icon(":/debugger/images/debugger_stop_small.png"); + d->m_actions.stopAction->setIcon(icon); d->m_actions.stopAction->setText(tr("Stop Debugger")); } else { - d->m_actions.stopAction->setIcon(QIcon(":/debugger/images/debugger_interrupt_small.png")); + static QIcon icon(":/debugger/images/debugger_interrupt_small.png"); + d->m_actions.stopAction->setIcon(icon); d->m_actions.stopAction->setText(tr("Interrupt")); } - d->m_actions.stopAction->setEnabled(started); + d->m_actions.stopAction->setEnabled(stoppable); d->m_actions.resetAction->setEnabled(true); - d->m_actions.stepAction->setEnabled(ready); - d->m_actions.stepOutAction->setEnabled(ready); - d->m_actions.runToLineAction->setEnabled(ready); - d->m_actions.runToFunctionAction->setEnabled(ready); - d->m_actions.jumpToLineAction->setEnabled(ready); - d->m_actions.nextAction->setEnabled(ready); - //showStatusMessage(QString("started: %1, running: %2") - // .arg(started).arg(running)); + d->m_actions.stepAction->setEnabled(stopped); + d->m_actions.stepOutAction->setEnabled(stopped); + d->m_actions.runToLineAction->setEnabled(stopped); + d->m_actions.runToFunctionAction->setEnabled(stopped); + d->m_actions.jumpToLineAction->setEnabled(stopped); + d->m_actions.nextAction->setEnabled(stopped); + //showStatusMessage(QString("stoppable: %1, running: %2") + // .arg(stoppable).arg(running)); emit stateChanged(d->m_state); - const bool notbusy = ready || state == DebuggerNotReady; + const bool notbusy = stopped || state == DebuggerNotReady; setBusyCursor(!notbusy); } diff --git a/src/plugins/debugger/gdb/coregdbadapter.cpp b/src/plugins/debugger/gdb/coregdbadapter.cpp index a9f48b3fc82c53a888cd99e7838aacf9cf72177d..106b1b097aeb855b896bf104f961c5039fd05d8b 100644 --- a/src/plugins/debugger/gdb/coregdbadapter.cpp +++ b/src/plugins/debugger/gdb/coregdbadapter.cpp @@ -150,8 +150,7 @@ void CoreGdbAdapter::handleTargetCore(const GdbResponse &response) { QTC_ASSERT(state() == InferiorStarting, qDebug() << state()); if (response.resultClass == GdbResultDone) { - setState(InferiorStopped); - debugMessage(_("INFERIOR STARTED")); + setState(InferiorUnrunnable); showStatusMessage(tr("Attached to core.")); m_engine->updateAll(); } else { @@ -170,7 +169,7 @@ void CoreGdbAdapter::interruptInferior() void CoreGdbAdapter::shutdown() { - if (state() == InferiorStopped || state() == InferiorShutDown) { + if (state() == InferiorUnrunnable || state() == InferiorShutDown) { setState(AdapterShuttingDown); m_engine->postCommand(_("-gdb-exit"), CB(handleExit)); return; diff --git a/src/plugins/debugger/gdb/gdbengine.cpp b/src/plugins/debugger/gdb/gdbengine.cpp index e8196d9584491f116252d479704b02524db2d0fe..8ad7a964feb2407b8686419c30f21fc5e3917350 100644 --- a/src/plugins/debugger/gdb/gdbengine.cpp +++ b/src/plugins/debugger/gdb/gdbengine.cpp @@ -112,6 +112,7 @@ namespace Internal { static bool stateAcceptsGdbCommands(DebuggerState state) { return state == AdapterStarted + || state == InferiorUnrunnable || state == InferiorPreparing || state == InferiorPrepared || state == InferiorStarting @@ -822,18 +823,10 @@ void GdbEngine::handleResultRecord(const GdbResponse &response) } if (response.token < m_oldestAcceptableToken && (cmd.flags & Discardable)) { - //qDebug() << "### SKIPPING OLD RESULT" << response.toString(); - //showMessageBox(QMessageBox::Information(tr("Skipped"), "xxx")); + //debugMessage(_("### SKIPPING OLD RESULT") + response.toString()); return; } -#if 0 - qDebug() << "# handleOutput," - << "cmd name:" << cmd.callbackName - << " cmd synchronized:" << cmd.synchronized - << "\n response: " << response.toString(); -#endif - GdbResponse responseWithCookie = response; responseWithCookie.cookie = cmd.cookie; @@ -865,7 +858,7 @@ void GdbEngine::handleResultRecord(const GdbResponse &response) Continuation cont = m_continuationAfterDone; m_continuationAfterDone = 0; (this->*cont)(); - //showStatusMessage(tr("Continuing after temporary stop.")); + showStatusMessage(tr("Continuing after temporary stop."), 1000); } else { PENDING_DEBUG("MISSING TOKENS: " << m_cookieForToken.keys()); } @@ -881,10 +874,10 @@ void GdbEngine::executeDebuggerCommand(const QString &command) m_gdbAdapter->write(command.toLatin1() + "\r\n"); } -// called from CoreAdapter and AttachAdapter +// Called from CoreAdapter and AttachAdapter void GdbEngine::updateAll() { - QTC_ASSERT(state() == InferiorStopped, /**/); + QTC_ASSERT(state() == InferiorUnrunnable || state() == InferiorStopped, /**/); manager()->resetLocation(); tryLoadDebuggingHelpers(); manager()->stackHandler()->setCurrentIndex(0);