m_d->m_inferiorStartupComplete = false;
setState(AdapterStarted, Q_FUNC_INFO, __LINE__);
- setState(InferiorPreparing, Q_FUNC_INFO, __LINE__);
const DebuggerStartMode mode = sp->startMode;
// Figure out dumper. @TODO: same in gdb...
const QString dumperLibName = QDir::toNativeSeparators(manager()->qtDumperLibraryName());
}
m_d->m_dumper->reset(dumperLibName, dumperEnabled);
- setState(InferiorPrepared, Q_FUNC_INFO, __LINE__);
setState(InferiorStarting, Q_FUNC_INFO, __LINE__);
manager()->showStatusMessage("Starting Debugger", -1);
AdapterStarting,
AdapterStarted,
AdapterStartFailed,
- InferiorPreparing,
- InferiorPrepared,
- InferiorPreparationFailed,
InferiorUnrunnable, // Used in the core dump adapter
InferiorStarting,
// InferiorStarted, // Use InferiorRunningRequested or InferiorStopped
// |
// AdapterStarted
// |
-// InferiorPreparing --> InferiorPreparationFailed --> 0
-// |
-// InferiorPrepared
-// |
// InferiorStarting --> InferiorStartFailed --> 0
// |
// (core) | (attach) (remote)
SN(AdapterStarting)
SN(AdapterStarted)
SN(AdapterStartFailed)
- SN(InferiorPreparing)
- SN(InferiorPrepared)
- SN(InferiorPreparationFailed)
SN(InferiorStarting)
SN(InferiorStartFailed)
SN(InferiorRunningRequested)
case AdapterStarting:
return to == AdapterStarted || to == AdapterStartFailed;
case AdapterStarted:
- return to == InferiorPreparing;
- case AdapterStartFailed:
- return to == DebuggerNotReady;
-
- case InferiorPreparing:
- return to == InferiorPrepared || to == InferiorPreparationFailed;
- case InferiorPrepared:
return to == InferiorStarting;
- case InferiorPreparationFailed:
+ case AdapterStartFailed:
return to == DebuggerNotReady;
case InferiorStarting:
if (!d->m_engine)
return false;
switch (state()) {
- case InferiorPrepared:
case InferiorStarting:
case InferiorRunningRequested:
case InferiorRunning:
case AdapterStarting:
case AdapterStarted:
case AdapterStartFailed:
- case InferiorPreparing:
- case InferiorPreparationFailed:
case InferiorStartFailed:
case InferiorStopFailed:
case InferiorShuttingDown:
virtual bool isTrkAdapter() const; // isUtterlyBrokenAdapter
virtual void startAdapter() = 0;
- virtual void prepareInferior() = 0;
virtual void startInferior() = 0;
virtual void interruptInferior() = 0;
virtual void shutdown() = 0;
void adapterShutdownFailed(const QString &msg);
void adapterCrashed(const QString &msg);
- void inferiorPrepared();
- void inferiorPreparationFailed(const QString &msg);
void inferiorStartFailed(const QString &msg);
void inferiorShutDown();
void inferiorShutdownFailed(const QString &msg);
shutdown();
}
-void AttachGdbAdapter::prepareInferior()
-{
- QTC_ASSERT(state() == AdapterStarted, qDebug() << state());
- setState(InferiorPreparing);
- setState(InferiorPrepared);
- emit inferiorPrepared();
-}
-
void AttachGdbAdapter::startInferior()
{
QTC_ASSERT(state() == InferiorStarting, qDebug() << state());
bool dumpersAvailable() const { return false; }
void startAdapter();
- void prepareInferior();
void startInferior();
void interruptInferior();
void shutdown();
shutdown();
}
-void CoreGdbAdapter::prepareInferior()
-{
- QTC_ASSERT(state() == AdapterStarted, qDebug() << state());
- setState(InferiorPreparing);
- setState(InferiorPrepared);
- emit inferiorPrepared();
-}
-
void CoreGdbAdapter::startInferior()
{
QTC_ASSERT(state() == InferiorStarting, qDebug() << state());
case InferiorUnrunnable:
case InferiorShutDown:
- case InferiorPreparationFailed:
setState(AdapterShuttingDown);
m_engine->postCommand(_("-gdb-exit"), CB(handleExit));
return;
bool dumpersAvailable() const { return false; }
void startAdapter();
- void prepareInferior();
void startInferior();
void interruptInferior();
void shutdown();
{
return state == AdapterStarted
|| state == InferiorUnrunnable
- || state == InferiorPreparing
- || state == InferiorPrepared
|| state == InferiorStarting
|| state == InferiorRunningRequested
|| state == InferiorRunning
connect(m_gdbAdapter, SIGNAL(adapterShutdownFailed(QString)),
this, SLOT(handleAdapterShutdownFailed(QString)));
- connect(m_gdbAdapter, SIGNAL(inferiorPrepared()),
- this, SLOT(handleInferiorPrepared()));
- connect(m_gdbAdapter, SIGNAL(inferiorPreparationFailed(QString)),
- this, SLOT(handleInferiorPreparationFailed(QString)));
-
connect(m_gdbAdapter, SIGNAL(inferiorStartFailed(QString)),
this, SLOT(handleInferiorStartFailed(QString)));
connect(m_gdbAdapter, SIGNAL(inferiorShutDown()),
}
if (cmd.flags & NeedsStop) {
- if (state() == InferiorStopped
- || state() == EngineStarting
- || state() == InferiorPrepared) {
+ if (state() == InferiorStopped || state() == AdapterStarted) {
// Can be safely sent now.
flushCommand(cmd);
} else {
void GdbEngine::handleAdapterStarted()
{
- debugMessage(_("ADAPTER SUCCESSFULLY STARTED, PREPARING INFERIOR"));
- m_gdbAdapter->prepareInferior();
-}
-
-void GdbEngine::handleInferiorPreparationFailed(const QString &msg)
-{
- debugMessage(_("INFERIOR PREPARATION FAILED"));
- showMessageBox(QMessageBox::Critical,
- tr("Inferior start preparation failed"), msg);
- shutdown();
-}
-
-void GdbEngine::handleInferiorPrepared()
-{
- QTC_ASSERT(state() == InferiorPrepared, qDebug() << state());
- debugMessage(_("INFERIOR PREPARED"));
- // FIXME: Check that inferior is in "stopped" state
- showStatusMessage(tr("Inferior prepared for startup."));
+ debugMessage(_("ADAPTER SUCCESSFULLY STARTED, INITIALIZING GDB"));
postCommand(_("show version"), CB(handleShowVersion));
//postCommand(_("-enable-timings");
void GdbEngine::startInferior()
{
- QTC_ASSERT(state() == InferiorPrepared, qDebug() << state());
+ QTC_ASSERT(state() == AdapterStarted, qDebug() << state());
showStatusMessage(tr("Starting inferior..."));
setState(InferiorStarting);
m_gdbAdapter->startInferior();
void handleAdapterStarted();
void handleAdapterStartFailed(const QString &msg, const QString &settingsIdHint = QString());
- void handleInferiorPrepared();
- void handleInferiorPreparationFailed(const QString &msg);
void handleInferiorStartFailed(const QString &msg);
void handleInferiorShutDown();
void handleInferiorShutdownFailed(const QString &msg);
emit adapterCrashed(m_engine->errorMessage(error));
}
-void PlainGdbAdapter::prepareInferior()
+void PlainGdbAdapter::startInferior()
{
- QTC_ASSERT(state() == AdapterStarted, qDebug() << state());
- setState(InferiorPreparing);
+ QTC_ASSERT(state() == InferiorStarting, qDebug() << state());
if (!startParameters().processArgs.isEmpty())
m_engine->postCommand(_("-exec-arguments ")
+ startParameters().processArgs.join(_(" ")));
void PlainGdbAdapter::handleFileExecAndSymbols(const GdbResponse &response)
{
- QTC_ASSERT(state() == InferiorPreparing, qDebug() << state());
+ QTC_ASSERT(state() == InferiorStarting, qDebug() << state());
if (response.resultClass == GdbResultDone) {
//m_breakHandler->clearBreakMarkers();
- setState(InferiorPrepared);
- emit inferiorPrepared();
+ setState(InferiorRunningRequested);
+ m_engine->postCommand(_("-exec-run"), GdbEngine::RunRequest, CB(handleExecRun));
} else {
QString msg = tr("Starting executable failed:\n") +
__(response.data.findChild("msg").data());
- setState(InferiorPreparationFailed);
- emit inferiorPreparationFailed(msg);
+ emit inferiorStartFailed(msg);
}
}
}
}
-void PlainGdbAdapter::startInferior()
-{
- QTC_ASSERT(state() == InferiorStarting, qDebug() << state());
- setState(InferiorRunningRequested);
- m_engine->postCommand(_("-exec-run"), GdbEngine::RunRequest, CB(handleExecRun));
-}
-
void PlainGdbAdapter::interruptInferior()
{
debugMessage(_("TRYING TO INTERUPT INFERIOR"));
bool dumpersAvailable() const { return true; }
void startAdapter();
- void prepareInferior();
void startInferior();
void interruptInferior();
void shutdown();
m_engine->gdbOutputAvailable(LogError, QString::fromLocal8Bit(ba, ba.length()));
}
-void RemoteGdbAdapter::prepareInferior()
+void RemoteGdbAdapter::startInferior()
{
- QTC_ASSERT(state() == AdapterStarted, qDebug() << state());
- setState(InferiorPreparing);
+ QTC_ASSERT(state() == InferiorStarting, qDebug() << state());
m_engine->postCommand(_("set architecture %1")
.arg(startParameters().remoteArchitecture));
#if 0
void RemoteGdbAdapter::handleSetTargetAsync(const GdbResponse &response)
{
- QTC_ASSERT(state() == InferiorPreparing, qDebug() << state());
+ QTC_ASSERT(state() == InferiorStarting, qDebug() << state());
if (response.resultClass == GdbResultDone) {
//qq->breakHandler()->setAllPending();
QFileInfo fi(startParameters().executable);
CB(handleFileExecAndSymbols));
} else {
QString msg = tr("Adapter too old: does not support asynchronous mode.");
- setState(InferiorPreparationFailed);
- emit inferiorPreparationFailed(msg);
+ emit inferiorStartFailed(msg);
}
}
#endif
void RemoteGdbAdapter::handleFileExecAndSymbols(const GdbResponse &response)
{
- QTC_ASSERT(state() == InferiorPreparing, qDebug() << state());
+ QTC_ASSERT(state() == InferiorStarting, qDebug() << state());
if (response.resultClass == GdbResultDone) {
//m_breakHandler->clearBreakMarkers();
- m_engine->setState(InferiorPrepared);
- emit inferiorPrepared();
+
+ // "target remote" does three things:
+ // (1) connects to the gdb server
+ // (2) starts the remote application
+ // (3) stops the remote application (early, e.g. in the dynamic linker)
+ QString channel = startParameters().remoteChannel;
+ m_engine->postCommand(_("target remote %1").arg(channel),
+ CB(handleTargetRemote));
} else {
QString msg = tr("Starting remote executable failed:\n");
msg += __(response.data.findChild("msg").data());
- setState(InferiorPreparationFailed);
- emit inferiorPreparationFailed(msg);
+ emit inferiorStartFailed(msg);
}
}
} else {
// 16^error,msg="hd:5555: Connection timed out."
QString msg = msgConnectRemoteServerFailed(__(record.data.findChild("msg").data()));
- setState(InferiorPreparationFailed);
emit inferiorStartFailed(msg);
}
}
-void RemoteGdbAdapter::startInferior()
-{
- QTC_ASSERT(state() == InferiorStarting, qDebug() << state());
- QString channel = startParameters().remoteChannel;
-
- // "target remote" does three things:
- // (1) connects to the gdb server
- // (2) starts the remote application
- // (3) stops the remote application (early, e.g. in the dynamic linker)
- m_engine->postCommand(_("target remote %1").arg(channel),
- CB(handleTargetRemote));
-}
-
void RemoteGdbAdapter::interruptInferior()
{
m_engine->postCommand(_("-exec-interrupt"));
QTC_ASSERT(false, qDebug() << state());
// fall through
- case InferiorPreparationFailed:
+ case InferiorStartFailed:
case InferiorShutDown:
setState(AdapterShuttingDown);
m_engine->postCommand(_("-gdb-exit"), CB(handleExit));
bool dumpersAvailable() const { return true; }
void startAdapter();
- void prepareInferior();
void startInferior();
void interruptInferior();
void shutdown();
emit adapterStartFailed(m_adapterFailMessage, TrkOptionsPage::settingsId());
}
+void TrkGdbAdapter::emitDelayedInferiorStartFailed(const QString &msg)
+{
+ m_adapterFailMessage = msg;
+ QTimer::singleShot(0, this, SLOT(slotEmitDelayedInferiorStartFailed()));
+}
+
+void TrkGdbAdapter::slotEmitDelayedInferiorStartFailed()
+{
+ emit inferiorStartFailed(m_adapterFailMessage);
+}
+
void TrkGdbAdapter::waitForTrkConnect()
{
QTC_ASSERT(state() == AdapterStarting, qDebug() << state());
waitForTrkConnect();
}
-void TrkGdbAdapter::prepareInferior()
+void TrkGdbAdapter::startInferior()
{
- QTC_ASSERT(state() == AdapterStarted, qDebug() << state());
- setState(InferiorPreparing);
+ QTC_ASSERT(state() == InferiorStarting, qDebug() << state());
QByteArray ba;
appendByte(&ba, 0); // ?
void TrkGdbAdapter::handleCreateProcess(const TrkResult &result)
{
- QTC_ASSERT(state() == InferiorPreparing, qDebug() << state());
+ QTC_ASSERT(state() == InferiorStarting, qDebug() << state());
// 40 00 00]
//logMessage(" RESULT: " + result.toString());
// [80 08 00 00 00 01 B5 00 00 01 B6 78 67 40 00 00 40 00 00]
.arg(m_remoteExecutable).arg(result.errorString());
// Delay cleanup as not to close a trk device from its read handler,
// which blocks.
- emitDelayedAdapterStartFailed(msg);
+ emitDelayedInferiorStartFailed(msg);
return;
}
const char *data = result.data.data();
void TrkGdbAdapter::handleTargetRemote(const GdbResponse &record)
{
- QTC_ASSERT(state() == InferiorPreparing, qDebug() << state());
+ QTC_ASSERT(state() == InferiorStarting, qDebug() << state());
if (record.resultClass == GdbResultDone) {
- setState(InferiorPrepared);
- emit inferiorPrepared();
+ setState(InferiorRunningRequested);
+ m_engine->postCommand(_("-exec-continue"), CB(handleFirstContinue));
} else {
QString msg = tr("Connecting to trk server adapter failed:\n")
+ _(record.data.findChild("msg").data());
- emit inferiorPreparationFailed(msg);
+ emit inferiorStartFailed(msg);
}
}
-void TrkGdbAdapter::startInferior()
-{
- QTC_ASSERT(state() == InferiorStarting, qDebug() << state());
- setState(InferiorRunningRequested);
- m_engine->postCommand(_("-exec-continue"), CB(handleFirstContinue));
-}
-
void TrkGdbAdapter::handleFirstContinue(const GdbResponse &record)
{
QTC_ASSERT(state() == InferiorRunning, qDebug() << state());
private:
void startAdapter();
- void prepareInferior();
void startInferior();
void interruptInferior();
void shutdown();
void cleanup();
void emitDelayedAdapterStartFailed(const QString &msg);
Q_SLOT void slotEmitDelayedAdapterStartFailed();
+ void emitDelayedInferiorStartFailed(const QString &msg);
+ Q_SLOT void slotEmitDelayedInferiorStartFailed();
Q_SLOT void waitForTrkConnect();
void handleKill(const GdbResponse &response);