Commit 5a186cea authored by Pawel Polanski's avatar Pawel Polanski
Browse files

CODA: Handle 'USB removed when debugging' sutiation

parent a2ec23c0
...@@ -72,7 +72,7 @@ ...@@ -72,7 +72,7 @@
enum { debug = 0 }; enum { debug = 0 };
/* Libraries we want to be notified about (pending introduction of a 'notify all' /* 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[] = { static const char *librariesC[] = {
"pipelib.ldd", "rpipe.dll", "libc.dll", "pipelib.ldd", "rpipe.dll", "libc.dll",
"libdl.dll", "libm.dll", "libpthread.dll", "libdl.dll", "libm.dll", "libpthread.dll",
...@@ -115,7 +115,7 @@ static inline QString startMsg(const trk::Session &session) ...@@ -115,7 +115,7 @@ static inline QString startMsg(const trk::Session &session)
* When continuing in sendTrkContinue(), we delete this thread, since we cannot * When continuing in sendTrkContinue(), we delete this thread, since we cannot
* know whether it will exist at the next stop. * know whether it will exist at the next stop.
* Also note that threads continue running in Symbian even if one crashes. * 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? * - Stop all threads once one stops?
* - Breakpoints do not trigger in threads other than the main thread. */ * - Breakpoints do not trigger in threads other than the main thread. */
...@@ -154,9 +154,11 @@ void CodaGdbAdapter::setupTrkDeviceSignals() ...@@ -154,9 +154,11 @@ void CodaGdbAdapter::setupTrkDeviceSignals()
connect(m_codaDevice.data(), SIGNAL(error(QString)), connect(m_codaDevice.data(), SIGNAL(error(QString)),
this, SLOT(codaDeviceError(QString))); this, SLOT(codaDeviceError(QString)));
connect(m_codaDevice.data(), SIGNAL(logMessage(QString)), connect(m_codaDevice.data(), SIGNAL(logMessage(QString)),
this, SLOT(trkLogMessage(QString))); this, SLOT(codaLogMessage(QString)));
connect(m_codaDevice.data(), SIGNAL(tcfEvent(Coda::CodaEvent)), connect(m_codaDevice.data(), SIGNAL(tcfEvent(Coda::CodaEvent)),
this, SLOT(codaEvent(Coda::CodaEvent))); this, SLOT(codaEvent(Coda::CodaEvent)));
connect(SymbianUtils::SymbianDeviceManager::instance(), SIGNAL(deviceRemoved(const SymbianUtils::SymbianDevice)),
this, SLOT(codaDeviceRemoved(SymbianUtils::SymbianDevice)));
} }
CodaGdbAdapter::~CodaGdbAdapter() CodaGdbAdapter::~CodaGdbAdapter()
...@@ -179,7 +181,7 @@ void CodaGdbAdapter::setVerbose(int verbose) ...@@ -179,7 +181,7 @@ void CodaGdbAdapter::setVerbose(int verbose)
m_codaDevice->setVerbose(m_verbose); m_codaDevice->setVerbose(m_verbose);
} }
void CodaGdbAdapter::trkLogMessage(const QString &msg) void CodaGdbAdapter::codaLogMessage(const QString &msg)
{ {
logMessage(_("TRK ") + msg); logMessage(_("TRK ") + msg);
} }
...@@ -240,7 +242,7 @@ void CodaGdbAdapter::handleCodaRunControlModuleLoadContextSuspendedEvent(const C ...@@ -240,7 +242,7 @@ void CodaGdbAdapter::handleCodaRunControlModuleLoadContextSuspendedEvent(const C
m_session.modules.removeAt(index); m_session.modules.removeAt(index);
m_session.libraries.removeAt(index); m_session.libraries.removeAt(index);
} else { } 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.", qWarning("Received unload for module '%s' for which no load was received.",
qPrintable(moduleName)); qPrintable(moduleName));
} }
...@@ -295,6 +297,17 @@ void CodaGdbAdapter::handleTargetRemote(const GdbResponse &record) ...@@ -295,6 +297,17 @@ void CodaGdbAdapter::handleTargetRemote(const GdbResponse &record)
} }
} }
void CodaGdbAdapter::codaDeviceRemoved(const SymbianUtils::SymbianDevice &dev)
{
const DebuggerStartParameters &parameters = 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) void CodaGdbAdapter::codaEvent(const CodaEvent &e)
{ {
if (debug) if (debug)
...@@ -968,7 +981,7 @@ void CodaGdbAdapter::handleGdbServerCommand(const QByteArray &cmd) ...@@ -968,7 +981,7 @@ void CodaGdbAdapter::handleGdbServerCommand(const QByteArray &cmd)
void CodaGdbAdapter::sendRunControlTerminateCommand() void CodaGdbAdapter::sendRunControlTerminateCommand()
{ {
// Requires id of main thread to terminate. // 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. // so, it is apparently not required.
m_codaDevice->sendRunControlTerminateCommand( m_codaDevice->sendRunControlTerminateCommand(
CodaCallback(this, &CodaGdbAdapter::handleRunControlTerminate), CodaCallback(this, &CodaGdbAdapter::handleRunControlTerminate),
...@@ -1085,7 +1098,7 @@ void CodaGdbAdapter::startAdapter() ...@@ -1085,7 +1098,7 @@ void CodaGdbAdapter::startAdapter()
if (parameters.communicationChannel == if (parameters.communicationChannel ==
DebuggerStartParameters::CommunicationChannelTcpIp) { DebuggerStartParameters::CommunicationChannelTcpIp) {
logMessage(_("Connecting to TCF TRK on %1:%2") logMessage(_("Connecting to Coda on %1:%2")
.arg(codaServerAddress).arg(codaServerPort)); .arg(codaServerAddress).arg(codaServerPort));
codaSocket->connectToHost(codaServerAddress, codaServerPort); codaSocket->connectToHost(codaServerAddress, codaServerPort);
} else { } else {
...@@ -1121,7 +1134,7 @@ void CodaGdbAdapter::addThread(unsigned id) ...@@ -1121,7 +1134,7 @@ void CodaGdbAdapter::addThread(unsigned id)
m_session.mainTid = id; m_session.mainTid = id;
} }
// We cannot retrieve register values unless the registers of that // 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); const QByteArray contextId = RunControlContext::tcfId(m_session.pid, id);
m_codaDevice->sendRegistersGetChildrenCommand( m_codaDevice->sendRegistersGetChildrenCommand(
CodaCallback(this, &CodaGdbAdapter::handleRegisterChildren), CodaCallback(this, &CodaGdbAdapter::handleRegisterChildren),
......
...@@ -58,6 +58,10 @@ namespace Coda { ...@@ -58,6 +58,10 @@ namespace Coda {
class CodaRunControlModuleLoadContextSuspendedEvent; class CodaRunControlModuleLoadContextSuspendedEvent;
} }
namespace SymbianUtils {
class SymbianDevice;
}
namespace Debugger { namespace Debugger {
namespace Internal { namespace Internal {
...@@ -153,7 +157,9 @@ private: ...@@ -153,7 +157,9 @@ private:
// //
Q_SLOT void handleGdbConnection(); Q_SLOT void handleGdbConnection();
Q_SLOT void readGdbServerCommand(); 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(); void startGdb();
Q_SLOT void codaEvent(const Coda::CodaEvent &knownEvent); Q_SLOT void codaEvent(const Coda::CodaEvent &knownEvent);
void handleCodaRunControlModuleLoadContextSuspendedEvent(const Coda::CodaRunControlModuleLoadContextSuspendedEvent &e); void handleCodaRunControlModuleLoadContextSuspendedEvent(const Coda::CodaRunControlModuleLoadContextSuspendedEvent &e);
...@@ -171,7 +177,7 @@ private: ...@@ -171,7 +177,7 @@ private:
void gdbSetCurrentThread(const QByteArray &cmd, const char *why); void gdbSetCurrentThread(const QByteArray &cmd, const char *why);
void logMessage(const QString &msg, int channel = LogDebug); // triggers output() if m_verbose 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<QTcpServer> m_gdbServer; QPointer<QTcpServer> m_gdbServer;
QPointer<QTcpSocket> m_gdbConnection; QPointer<QTcpSocket> m_gdbConnection;
......
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