From 5a186ceaa47b6412ce23620665a35a8768ca90fb Mon Sep 17 00:00:00 2001 From: Pawel Polanski Date: Mon, 21 Mar 2011 16:36:49 +0100 Subject: [PATCH] CODA: Handle 'USB removed when debugging' sutiation --- src/plugins/debugger/gdb/codagdbadapter.cpp | 29 +++++++++++++++------ src/plugins/debugger/gdb/codagdbadapter.h | 10 +++++-- 2 files changed, 29 insertions(+), 10 deletions(-) diff --git a/src/plugins/debugger/gdb/codagdbadapter.cpp b/src/plugins/debugger/gdb/codagdbadapter.cpp index be67ddb0b42..427391961c7 100644 --- a/src/plugins/debugger/gdb/codagdbadapter.cpp +++ b/src/plugins/debugger/gdb/codagdbadapter.cpp @@ -72,7 +72,7 @@ enum { debug = 0 }; /* Libraries we want to be notified about (pending introduction of a 'notify all' - * setting in TCF TRK, Bug #11842 */ + * setting in Coda, Bug #11842 */ static const char *librariesC[] = { "pipelib.ldd", "rpipe.dll", "libc.dll", "libdl.dll", "libm.dll", "libpthread.dll", @@ -115,7 +115,7 @@ static inline QString startMsg(const trk::Session &session) * When continuing in sendTrkContinue(), we delete this thread, since we cannot * know whether it will exist at the next stop. * Also note that threads continue running in Symbian even if one crashes. - * TODO: - Maybe thread reporting will be improved in TCF TRK? + * TODO: - Maybe thread reporting will be improved in Coda? * - Stop all threads once one stops? * - Breakpoints do not trigger in threads other than the main thread. */ @@ -154,9 +154,11 @@ void CodaGdbAdapter::setupTrkDeviceSignals() connect(m_codaDevice.data(), SIGNAL(error(QString)), this, SLOT(codaDeviceError(QString))); connect(m_codaDevice.data(), SIGNAL(logMessage(QString)), - this, SLOT(trkLogMessage(QString))); + this, SLOT(codaLogMessage(QString))); connect(m_codaDevice.data(), SIGNAL(tcfEvent(Coda::CodaEvent)), this, SLOT(codaEvent(Coda::CodaEvent))); + connect(SymbianUtils::SymbianDeviceManager::instance(), SIGNAL(deviceRemoved(const SymbianUtils::SymbianDevice)), + this, SLOT(codaDeviceRemoved(SymbianUtils::SymbianDevice))); } CodaGdbAdapter::~CodaGdbAdapter() @@ -179,7 +181,7 @@ void CodaGdbAdapter::setVerbose(int verbose) m_codaDevice->setVerbose(m_verbose); } -void CodaGdbAdapter::trkLogMessage(const QString &msg) +void CodaGdbAdapter::codaLogMessage(const QString &msg) { logMessage(_("TRK ") + msg); } @@ -240,7 +242,7 @@ void CodaGdbAdapter::handleCodaRunControlModuleLoadContextSuspendedEvent(const C m_session.modules.removeAt(index); m_session.libraries.removeAt(index); } else { - // Might happen with preliminary version of TCF TRK. + // Might happen with preliminary version of Coda. qWarning("Received unload for module '%s' for which no load was received.", qPrintable(moduleName)); } @@ -295,6 +297,17 @@ void CodaGdbAdapter::handleTargetRemote(const GdbResponse &record) } } +void CodaGdbAdapter::codaDeviceRemoved(const SymbianUtils::SymbianDevice &dev) +{ + const DebuggerStartParameters ¶meters = startParameters(); + if (state() != DebuggerNotReady && !m_codaDevice.isNull() && parameters.remoteChannel == dev.portName()) { + const QString message = QString::fromLatin1("Device '%1' has been disconnected.").arg(dev.friendlyName()); + logMessage(message); + m_engine->handleAdapterCrashed(message); + cleanup(); + } +} + void CodaGdbAdapter::codaEvent(const CodaEvent &e) { if (debug) @@ -968,7 +981,7 @@ void CodaGdbAdapter::handleGdbServerCommand(const QByteArray &cmd) void CodaGdbAdapter::sendRunControlTerminateCommand() { // Requires id of main thread to terminate. - // Note that calling 'Settings|set|removeExecutable' crashes TCF TRK, + // Note that calling 'Settings|set|removeExecutable' crashes Coda, // so, it is apparently not required. m_codaDevice->sendRunControlTerminateCommand( CodaCallback(this, &CodaGdbAdapter::handleRunControlTerminate), @@ -1085,7 +1098,7 @@ void CodaGdbAdapter::startAdapter() if (parameters.communicationChannel == DebuggerStartParameters::CommunicationChannelTcpIp) { - logMessage(_("Connecting to TCF TRK on %1:%2") + logMessage(_("Connecting to Coda on %1:%2") .arg(codaServerAddress).arg(codaServerPort)); codaSocket->connectToHost(codaServerAddress, codaServerPort); } else { @@ -1121,7 +1134,7 @@ void CodaGdbAdapter::addThread(unsigned id) m_session.mainTid = id; } // We cannot retrieve register values unless the registers of that - // thread have been retrieved (TCF TRK oddity). + // thread have been retrieved (Coda oddity). const QByteArray contextId = RunControlContext::tcfId(m_session.pid, id); m_codaDevice->sendRegistersGetChildrenCommand( CodaCallback(this, &CodaGdbAdapter::handleRegisterChildren), diff --git a/src/plugins/debugger/gdb/codagdbadapter.h b/src/plugins/debugger/gdb/codagdbadapter.h index 1367aaac47f..2af60e7bc5d 100644 --- a/src/plugins/debugger/gdb/codagdbadapter.h +++ b/src/plugins/debugger/gdb/codagdbadapter.h @@ -58,6 +58,10 @@ namespace Coda { class CodaRunControlModuleLoadContextSuspendedEvent; } +namespace SymbianUtils { +class SymbianDevice; +} + namespace Debugger { namespace Internal { @@ -153,7 +157,9 @@ private: // Q_SLOT void handleGdbConnection(); Q_SLOT void readGdbServerCommand(); - Q_SLOT void codaDeviceError(const QString &); + Q_SLOT void codaDeviceError(const QString &); + Q_SLOT void codaDeviceRemoved(const SymbianUtils::SymbianDevice &dev); + void startGdb(); Q_SLOT void codaEvent(const Coda::CodaEvent &knownEvent); void handleCodaRunControlModuleLoadContextSuspendedEvent(const Coda::CodaRunControlModuleLoadContextSuspendedEvent &e); @@ -171,7 +177,7 @@ private: void gdbSetCurrentThread(const QByteArray &cmd, const char *why); void logMessage(const QString &msg, int channel = LogDebug); // triggers output() if m_verbose - Q_SLOT void trkLogMessage(const QString &msg); + Q_SLOT void codaLogMessage(const QString &msg); QPointer m_gdbServer; QPointer m_gdbConnection;