Commit 17c928f9 authored by hjk's avatar hjk

debugger: introduce a new state InferiorUnrunnable to properly describe the

state when gdb is attached to a core.
parent 573ca3ad
......@@ -72,6 +72,7 @@ enum DebuggerState
InferiorPreparing,
InferiorPrepared,
InferiorPreparationFailed,
InferiorUnrunnable, // Used in the core dump adapter
InferiorStarting,
// InferiorStarted, // Use InferiorRunningRequested or InferiorStopped
InferiorStartFailed,
......
......@@ -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);
}
......
......@@ -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;
......
......@@ -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);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment