aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPawel Polanski <pawel.3.polanski@nokia.com>2011-06-09 14:45:08 +0200
committerPaweł Polański <jaggernod@gmail.com>2011-06-10 16:45:38 +0200
commit3f750695b42bbc8452764263b3e0ab6d00012815 (patch)
tree5c7546a539cb69b9cdd2b3627d97c856b290c32b
parenteed4d1e149056c723bab48e81c8bce30eb682209 (diff)
Symbian: TRK is no more!
TKR-related code has been removed. From now on CODA is the default On-Device Agent Change-Id: I52236a33aff9b31ca48d507da97430df7d871239 Reviewed-on: http://codereview.qt.nokia.com/450 Reviewed-by: Qt Sanity Bot <qt_sanity_bot@ovi.com> Reviewed-by: Paweł Polański <jaggernod@gmail.com>
-rw-r--r--src/plugins/debugger/debuggerplugin.cpp2
-rw-r--r--src/plugins/debugger/debuggerstartparameters.h3
-rw-r--r--src/plugins/debugger/gdb/abstractgdbadapter.cpp2
-rw-r--r--src/plugins/debugger/gdb/abstractgdbadapter.h12
-rw-r--r--src/plugins/debugger/gdb/codagdbadapter.cpp54
-rw-r--r--src/plugins/debugger/gdb/codagdbadapter.h22
-rw-r--r--src/plugins/debugger/gdb/gdb.pri4
-rw-r--r--src/plugins/debugger/gdb/gdbengine.cpp30
-rw-r--r--src/plugins/debugger/gdb/gdbengine.h2
-rw-r--r--src/plugins/debugger/gdb/pythongdbengine.cpp4
-rw-r--r--src/plugins/debugger/gdb/s60debuggerbluetoothstarter.cpp73
-rw-r--r--src/plugins/debugger/gdb/s60debuggerbluetoothstarter.h66
-rw-r--r--src/plugins/debugger/gdb/symbian.cpp38
-rw-r--r--src/plugins/debugger/gdb/symbian.h2
-rw-r--r--src/plugins/debugger/gdb/trkgdbadapter.cpp1996
-rw-r--r--src/plugins/debugger/gdb/trkgdbadapter.h242
-rw-r--r--src/plugins/debugger/qml/qmladapter.cpp6
-rw-r--r--src/plugins/qt4projectmanager/qt-s60/codaruncontrol.cpp6
-rw-r--r--src/plugins/qt4projectmanager/qt-s60/codaruncontrol.h2
-rw-r--r--src/plugins/qt4projectmanager/qt-s60/qt-s60.pri4
-rw-r--r--src/plugins/qt4projectmanager/qt-s60/qt4symbiantarget.cpp1
-rw-r--r--src/plugins/qt4projectmanager/qt-s60/s60deployconfiguration.cpp4
-rw-r--r--src/plugins/qt4projectmanager/qt-s60/s60deployconfiguration.h1
-rw-r--r--src/plugins/qt4projectmanager/qt-s60/s60deployconfigurationwidget.cpp165
-rw-r--r--src/plugins/qt4projectmanager/qt-s60/s60deployconfigurationwidget.h10
-rw-r--r--src/plugins/qt4projectmanager/qt-s60/s60deploystep.cpp290
-rw-r--r--src/plugins/qt4projectmanager/qt-s60/s60deploystep.h27
-rw-r--r--src/plugins/qt4projectmanager/qt-s60/s60devicedebugruncontrol.cpp4
-rw-r--r--src/plugins/qt4projectmanager/qt-s60/s60runconfigbluetoothstarter.cpp73
-rw-r--r--src/plugins/qt4projectmanager/qt-s60/s60runconfigbluetoothstarter.h68
-rw-r--r--src/plugins/qt4projectmanager/qt-s60/s60runcontrolfactory.cpp4
-rw-r--r--src/plugins/qt4projectmanager/qt-s60/trkruncontrol.cpp246
-rw-r--r--src/plugins/qt4projectmanager/qt-s60/trkruncontrol.h99
-rw-r--r--src/shared/symbianutils/bluetoothlistener.cpp215
-rw-r--r--src/shared/symbianutils/bluetoothlistener.h94
-rw-r--r--src/shared/symbianutils/bluetoothlistener_gui.cpp102
-rw-r--r--src/shared/symbianutils/bluetoothlistener_gui.h80
-rw-r--r--src/shared/symbianutils/callback.h4
-rw-r--r--src/shared/symbianutils/codadevice.cpp14
-rw-r--r--src/shared/symbianutils/codadevice.h4
-rw-r--r--src/shared/symbianutils/codamessage.h16
-rw-r--r--src/shared/symbianutils/codautils.cpp (renamed from src/shared/symbianutils/trkutils.cpp)78
-rw-r--r--src/shared/symbianutils/codautils.h (renamed from src/shared/symbianutils/trkutils.h)124
-rw-r--r--src/shared/symbianutils/codautils_p.h (renamed from src/shared/symbianutils/trkutils_p.h)14
-rw-r--r--src/shared/symbianutils/communicationstarter.cpp242
-rw-r--r--src/shared/symbianutils/communicationstarter.h151
-rw-r--r--src/shared/symbianutils/launcher.cpp1117
-rw-r--r--src/shared/symbianutils/launcher.h218
-rw-r--r--src/shared/symbianutils/symbiandevicemanager.cpp87
-rw-r--r--src/shared/symbianutils/symbiandevicemanager.h22
-rw-r--r--src/shared/symbianutils/symbianutils.pri22
-rw-r--r--src/shared/symbianutils/trkdevice.cpp1196
-rw-r--r--src/shared/symbianutils/trkdevice.h134
53 files changed, 249 insertions, 7247 deletions
diff --git a/src/plugins/debugger/debuggerplugin.cpp b/src/plugins/debugger/debuggerplugin.cpp
index ec1f91c78a..6347c1939a 100644
--- a/src/plugins/debugger/debuggerplugin.cpp
+++ b/src/plugins/debugger/debuggerplugin.cpp
@@ -153,7 +153,7 @@
\brief Base class of a debugger engine.
Note: the Debugger process itself and any helper processes like
- gdbserver, the trk client etc are referred to as 'Engine',
+ gdbserver, the CODA client etc are referred to as 'Engine',
whereas the debugged process is referred to as 'Inferior'.
Transitions marked by '---' are done in the individual engines.
diff --git a/src/plugins/debugger/debuggerstartparameters.h b/src/plugins/debugger/debuggerstartparameters.h
index 53b797529a..883901f72c 100644
--- a/src/plugins/debugger/debuggerstartparameters.h
+++ b/src/plugins/debugger/debuggerstartparameters.h
@@ -56,7 +56,6 @@ public:
};
enum SymbianDebugClient {
- SymbianDebugClientTrk,
SymbianDebugClientCoda
};
@@ -73,7 +72,7 @@ public:
executableUid(0),
communicationChannel(CommunicationChannelTcpIp),
serverPort(0),
- debugClient(SymbianDebugClientTrk)
+ debugClient(SymbianDebugClientCoda)
{}
QString executable;
diff --git a/src/plugins/debugger/gdb/abstractgdbadapter.cpp b/src/plugins/debugger/gdb/abstractgdbadapter.cpp
index 5a75252cd3..aa7fc7e02d 100644
--- a/src/plugins/debugger/gdb/abstractgdbadapter.cpp
+++ b/src/plugins/debugger/gdb/abstractgdbadapter.cpp
@@ -74,7 +74,7 @@ void AbstractGdbAdapter::write(const QByteArray &data)
gdbProc()->write(data);
}
-bool AbstractGdbAdapter::isTrkAdapter() const
+bool AbstractGdbAdapter::isCodaAdapter() const
{
return false;
}
diff --git a/src/plugins/debugger/gdb/abstractgdbadapter.h b/src/plugins/debugger/gdb/abstractgdbadapter.h
index 32770e1eae..db5022c2f5 100644
--- a/src/plugins/debugger/gdb/abstractgdbadapter.h
+++ b/src/plugins/debugger/gdb/abstractgdbadapter.h
@@ -49,9 +49,9 @@ class AbstractGdbProcess;
class GdbResponse;
// AbstractGdbAdapter is inherited by PlainGdbAdapter used for local
-// debugging and TrkGdbAdapter used for on-device debugging.
+// debugging and CodaGdbAdapter used for on-device debugging.
// In the PlainGdbAdapter case it's just a wrapper around a QProcess running
-// gdb, in the TrkGdbAdapter case it's the interface to the gdb process in
+// gdb, in the CodaGdbAdapter case it's the interface to the gdb process in
// the whole rfcomm/gdb/gdbserver combo.
class AbstractGdbAdapter : public QObject
{
@@ -88,10 +88,10 @@ public:
static QString msgInferiorRunOk();
static QString msgConnectRemoteServerFailed(const QString &why);
- // Trk specific stuff
- virtual bool isTrkAdapter() const;
- virtual void trkReloadRegisters() {}
- virtual void trkReloadThreads() {}
+ // CODA specific stuff
+ virtual bool isCodaAdapter() const;
+ virtual void codaReloadRegisters() {}
+ virtual void codaReloadThreads() {}
virtual void handleRemoteSetupDone(int gdbServerPort, int qmlPort);
virtual void handleRemoteSetupFailed(const QString &reason);
diff --git a/src/plugins/debugger/gdb/codagdbadapter.cpp b/src/plugins/debugger/gdb/codagdbadapter.cpp
index 663d2dcfa7..7ac0c704cd 100644
--- a/src/plugins/debugger/gdb/codagdbadapter.cpp
+++ b/src/plugins/debugger/gdb/codagdbadapter.cpp
@@ -34,7 +34,7 @@
#include "debuggerstartparameters.h"
#include "codadevice.h"
-#include "trkutils.h"
+#include "codautils.h"
#include "gdbmi.h"
#include "symbiandevicemanager.h"
@@ -89,7 +89,7 @@ namespace Internal {
using namespace Symbian;
using namespace Coda;
-static inline QString startMsg(const trk::Session &session)
+static inline QString startMsg(const Coda::Session &session)
{
return CodaGdbAdapter::tr("Process started, PID: 0x%1, thread id: 0x%2, "
"code segment: 0x%3, data segment: 0x%4.")
@@ -109,9 +109,9 @@ static inline QString startMsg(const trk::Session &session)
* - Engine sets up breakpoints,etc and calls inferiorStartPhase2(), which
* resumes the suspended CODA process via gdb 'continue'.
* Thread handling (30.06.2010):
- * TRK does not report thread creation/termination. So, if we receive
+ * CODA does not report thread creation/termination. So, if we receive
* a stop in a different thread, we store an additional thread in snapshot.
- * When continuing in sendTrkContinue(), we delete this thread, since we cannot
+ * When continuing in sendContinue(), 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 CODA?
@@ -149,7 +149,7 @@ CodaGdbAdapter::CodaGdbAdapter(GdbEngine *engine) :
this, SLOT(setVerbose(QVariant)));
}
-void CodaGdbAdapter::setupTrkDeviceSignals()
+void CodaGdbAdapter::setupDeviceSignals()
{
connect(m_codaDevice.data(), SIGNAL(error(QString)),
this, SLOT(codaDeviceError(QString)));
@@ -186,7 +186,7 @@ void CodaGdbAdapter::setVerbose(int verbose)
void CodaGdbAdapter::codaLogMessage(const QString &msg)
{
- logMessage(_("TRK ") + msg);
+ logMessage(_("CODA ") + msg);
}
void CodaGdbAdapter::setGdbServerName(const QString &name)
@@ -221,7 +221,7 @@ void CodaGdbAdapter::handleCodaRunControlModuleLoadContextSuspendedEvent(const C
if (!isExe) {
if (minfo.loaded) {
m_session.modules.push_back(moduleName);
- trk::Library library;
+ Coda::Library library;
library.name = minfo.name;
library.codeseg = minfo.codeAddress;
library.dataseg = minfo.dataAddress;
@@ -268,7 +268,7 @@ void CodaGdbAdapter::handleCodaRunControlModuleLoadContextSuspendedEvent(const C
} else {
// Does not seem to be necessary anymore.
// FIXME: Startup sequence can be streamlined now as we do not
- // have to wait for the TRK startup to learn the load address.
+ // have to wait for the CODA startup to learn the load address.
//m_engine->postCommand("add-symbol-file \"" + symbolFile + "\" "
// + QByteArray::number(m_session.codeseg));
m_engine->postCommand("symbol-file \"" + symbolFile + "\"");
@@ -466,7 +466,7 @@ void CodaGdbAdapter::readGdbServerCommand()
if (code != '$') {
logMessage("Broken package (2) " + quoteUnprintableLatin1(ba)
- + trk::hexNumber(code), LogError);
+ + Coda::hexNumber(code), LogError);
continue;
}
@@ -486,7 +486,7 @@ void CodaGdbAdapter::readGdbServerCommand()
}
//logMessage(QString("Packet checksum: %1").arg(checkSum));
- trk::byte sum = 0;
+ Coda::byte sum = 0;
for (int i = 0; i < pos; ++i)
sum += ba.at(i);
@@ -533,7 +533,7 @@ void CodaGdbAdapter::sendGdbServerAck()
void CodaGdbAdapter::sendGdbServerMessage(const QByteArray &msg, const QByteArray &logNote)
{
- trk::byte sum = 0;
+ Coda::byte sum = 0;
for (int i = 0; i != msg.size(); ++i)
sum += msg.at(i);
@@ -593,7 +593,7 @@ void CodaGdbAdapter::handleGdbServerCommand(const QByteArray &cmd)
else if (cmd == "c") {
logMessage(msgGdbPacket(_("Continue")));
sendGdbServerAck();
- sendTrkContinue();
+ sendContinue();
}
else if (cmd.startsWith('C')) {
@@ -608,7 +608,7 @@ void CodaGdbAdapter::handleGdbServerCommand(const QByteArray &cmd)
LogWarning);
sendGdbServerMessage('O' + QByteArray("Console output").toHex());
sendGdbServerMessage("W81"); // "Process exited with result 1
- sendTrkContinue();
+ sendContinue();
}
else if (cmd.startsWith('D')) {
@@ -746,12 +746,12 @@ void CodaGdbAdapter::handleGdbServerCommand(const QByteArray &cmd)
logMessage(_("Setting register #%1 to 0x%2").arg(regnumValue.first)
.arg(regnumValue.second, 0, 16));
QByteArray registerValue;
- trk::appendInt(&registerValue, trk::BigEndian); // Registers are big endian
+ Coda::appendInt(&registerValue, Coda::BigEndian); // Registers are big endian
m_codaDevice->sendRegistersSetCommand(
CodaCallback(this, &CodaGdbAdapter::handleWriteRegister),
currentThreadContextId(), regnumValue.first, registerValue,
QVariant(regnumValue.first));
- // Note that App TRK refuses to write registers 13 and 14
+ // Note that App CODA refuses to write registers 13 and 14
}
else if (cmd == "qAttached") {
@@ -890,7 +890,7 @@ void CodaGdbAdapter::handleGdbServerCommand(const QByteArray &cmd)
arg(pc, 0, 16)));
sendGdbServerAck();
m_running = true;
- sendTrkStepRange();
+ sendStepRange();
}
else if (cmd.startsWith('T')) {
@@ -909,7 +909,7 @@ void CodaGdbAdapter::handleGdbServerCommand(const QByteArray &cmd)
// vCont[;action[:thread-id]]...'
sendGdbServerAck();
m_running = true;
- sendTrkContinue();
+ sendContinue();
}
else if (cmd.startsWith("Z0,") || cmd.startsWith("Z1,")) {
@@ -1047,7 +1047,7 @@ void CodaGdbAdapter::startAdapter()
if (parameters.communicationChannel ==
DebuggerStartParameters::CommunicationChannelTcpIp) {
m_codaDevice = QSharedPointer<CodaDevice>(new CodaDevice, &CodaDevice::deleteLater);
- setupTrkDeviceSignals();
+ setupDeviceSignals();
codaSocket = QSharedPointer<QTcpSocket>(new QTcpSocket);
m_codaDevice->setDevice(codaSocket);
} else {
@@ -1065,7 +1065,7 @@ void CodaGdbAdapter::startAdapter()
m_engine->handleAdapterStartFailed(msg, QString());
return;
}
- setupTrkDeviceSignals();
+ setupDeviceSignals();
m_codaDevice->setVerbose(m_verbose);
}
@@ -1209,7 +1209,7 @@ void CodaGdbAdapter::write(const QByteArray &data)
QByteArray ba = QByteArray::fromHex(data.mid(2));
qDebug() << "Writing: " << quoteUnprintableLatin1(ba);
// if (ba.size() >= 1)
- // sendTrkMessage(ba.at(0), TrkCB(handleDirectTrk), ba.mid(1));
+ // sendMessage(ba.at(0), TrkCB(handleDirectTrk), ba.mid(1));
return;
}
if (data.startsWith("@@")) {
@@ -1252,13 +1252,13 @@ void CodaGdbAdapter::shutdownAdapter()
}
}
-void CodaGdbAdapter::trkReloadRegisters()
+void CodaGdbAdapter::codaReloadRegisters()
{
// Take advantage of direct access to cached register values.
m_snapshot.syncRegisters(m_session.tid, m_engine->registerHandler());
}
-void CodaGdbAdapter::trkReloadThreads()
+void CodaGdbAdapter::codaReloadThreads()
{
m_snapshot.syncThreads(m_engine->threadsHandler());
}
@@ -1557,7 +1557,7 @@ void CodaGdbAdapter::tryAnswerGdbMemoryRequest(bool buffered)
it = m_snapshot.memory.begin();
et = m_snapshot.memory.end();
for ( ; it != et; ++it)
- qDebug() << trk::hexNumber(it.key().from) << trk::hexNumber(it.key().to);
+ qDebug() << Coda::hexNumber(it.key().from) << Coda::hexNumber(it.key().to);
qDebug() << "WANTED" << wanted.from << wanted.to;
# endif
sendGdbServerMessage("E22", "");
@@ -1601,7 +1601,7 @@ QByteArray CodaGdbAdapter::currentThreadContextId() const
return RunControlContext::codaId(m_session.pid, m_session.tid);
}
-void CodaGdbAdapter::sendTrkContinue()
+void CodaGdbAdapter::sendContinue()
{
// Remove all but main thread as we do not know whether they will exist
// at the next stop.
@@ -1610,7 +1610,7 @@ void CodaGdbAdapter::sendTrkContinue()
m_codaDevice->sendRunControlResumeCommand(CodaCallback(), m_codaProcessId);
}
-void CodaGdbAdapter::sendTrkStepRange()
+void CodaGdbAdapter::sendStepRange()
{
uint from = m_snapshot.lineFromAddress;
uint to = m_snapshot.lineToAddress;
@@ -1641,10 +1641,10 @@ void CodaGdbAdapter::handleStep(const CodaCommandResult &result)
if (!result) { // Try fallback with Continue.
logMessage(_("Error while stepping: %1 (fallback to 'continue')").
arg(result.errorString()), LogWarning);
- sendTrkContinue();
+ sendContinue();
// Doing nothing as below does not work as gdb seems to insist on
// making some progress through a 'step'.
- //sendTrkMessage(0x12,
+ //sendMessage(0x12,
// TrkCB(handleAndReportReadRegistersAfterStop),
// trkReadRegistersMessage());
return;
diff --git a/src/plugins/debugger/gdb/codagdbadapter.h b/src/plugins/debugger/gdb/codagdbadapter.h
index f1d928d9a1..460165897f 100644
--- a/src/plugins/debugger/gdb/codagdbadapter.h
+++ b/src/plugins/debugger/gdb/codagdbadapter.h
@@ -36,7 +36,7 @@
#include "abstractgdbadapter.h"
#include "localgdbprocess.h"
#include "callback.h"
-#include "trkutils.h"
+#include "codautils.h"
#include "symbian.h"
#include <QtCore/QPointer>
@@ -78,9 +78,9 @@ class CodaGdbAdapter : public AbstractGdbAdapter
Q_OBJECT
public:
- typedef trk::Callback<const GdbResult &> GdbResultCallback;
- typedef trk::Callback<const Coda::CodaCommandResult &> CodaCallback;
- typedef trk::Callback<const GdbResponse &> GdbCallback;
+ typedef Coda::Callback<const GdbResult &> GdbResultCallback;
+ typedef Coda::Callback<const Coda::CodaCommandResult &> CodaCallback;
+ typedef Coda::Callback<const GdbResponse &> GdbCallback;
explicit CodaGdbAdapter(GdbEngine *engine);
virtual ~CodaGdbAdapter();
@@ -91,8 +91,8 @@ public:
void setVerbose(int verbose);
void setBufferedMemoryRead(bool b) { m_bufferedMemoryRead = b; }
- void trkReloadRegisters();
- void trkReloadThreads();
+ void codaReloadRegisters();
+ void codaReloadThreads();
signals:
void output(const QString &msg);
@@ -104,12 +104,12 @@ public:
void start(const QString &program, const QStringList &args,
QIODevice::OpenMode mode = QIODevice::ReadWrite);
void write(const QByteArray &data);
- bool isTrkAdapter() const { return true; }
+ bool isCodaAdapter() const { return true; }
virtual DumperHandling dumperHandling() const { return DumperNotAvailable; }
private:
- void setupTrkDeviceSignals();
+ void setupDeviceSignals();
void startAdapter();
void setupInferior();
void runEngine();
@@ -162,8 +162,8 @@ private:
void startGdb();
Q_SLOT void codaEvent(const Coda::CodaEvent &knownEvent);
void handleCodaRunControlModuleLoadContextSuspendedEvent(const Coda::CodaRunControlModuleLoadContextSuspendedEvent &e);
- inline void sendTrkContinue();
- void sendTrkStepRange();
+ inline void sendContinue();
+ void sendStepRange();
void handleStep(const Coda::CodaCommandResult &result);
void handleCreateProcess(const Coda::CodaCommandResult &result);
@@ -184,7 +184,7 @@ private:
bool m_gdbAckMode;
// Debuggee state
- trk::Session m_session; // global-ish data (process id, target information)
+ Coda::Session m_session; // global-ish data (process id, target information)
Symbian::Snapshot m_snapshot; // local-ish data (memory and registers)
QString m_remoteExecutable;
unsigned m_uid;
diff --git a/src/plugins/debugger/gdb/gdb.pri b/src/plugins/debugger/gdb/gdb.pri
index 821674030e..99b43101be 100644
--- a/src/plugins/debugger/gdb/gdb.pri
+++ b/src/plugins/debugger/gdb/gdb.pri
@@ -8,9 +8,7 @@ HEADERS += \
$$PWD/localplaingdbadapter.h \
$$PWD/termgdbadapter.h \
$$PWD/remotegdbserveradapter.h \
- $$PWD/trkgdbadapter.h \
$$PWD/codagdbadapter.h \
- $$PWD/s60debuggerbluetoothstarter.h \
$$PWD/abstractgdbprocess.h \
$$PWD/localgdbprocess.h \
$$PWD/remotegdbprocess.h \
@@ -30,9 +28,7 @@ SOURCES += \
$$PWD/localplaingdbadapter.cpp \
$$PWD/termgdbadapter.cpp \
$$PWD/remotegdbserveradapter.cpp \
- $$PWD/trkgdbadapter.cpp \
$$PWD/codagdbadapter.cpp \
- $$PWD/s60debuggerbluetoothstarter.cpp \
$$PWD/abstractgdbprocess.cpp \
$$PWD/localgdbprocess.cpp \
$$PWD/remotegdbprocess.cpp \
diff --git a/src/plugins/debugger/gdb/gdbengine.cpp b/src/plugins/debugger/gdb/gdbengine.cpp
index 4f7b722c7a..221fd66317 100644
--- a/src/plugins/debugger/gdb/gdbengine.cpp
+++ b/src/plugins/debugger/gdb/gdbengine.cpp
@@ -43,7 +43,6 @@
#include "termgdbadapter.h"
#include "remotegdbserveradapter.h"
#include "remoteplaingdbadapter.h"
-#include "trkgdbadapter.h"
#include "codagdbadapter.h"
#include "debuggeractions.h"
@@ -1618,8 +1617,8 @@ void GdbEngine::handleStop2()
reloadStack(false); // Will trigger register reload.
if (supportsThreads()) {
- if (m_gdbAdapter->isTrkAdapter()) {
- m_gdbAdapter->trkReloadThreads();
+ if (m_gdbAdapter->isCodaAdapter()) {
+ m_gdbAdapter->codaReloadThreads();
} else if (m_isMacGdb) {
postCommand("-thread-list-ids", Discardable, CB(handleThreadListIds));
} else {
@@ -1894,8 +1893,7 @@ AbstractGdbAdapter *GdbEngine::createAdapter()
// FIXME: 1 of 3 testing hacks.
if (sp.debugClient == DebuggerStartParameters::SymbianDebugClientCoda)
return new CodaGdbAdapter(this);
- else
- return new TrkGdbAdapter(this);
+ return 0;
}
switch (sp.startMode) {
@@ -1998,7 +1996,7 @@ void GdbEngine::executeStep()
setTokenBarrier();
notifyInferiorRunRequested();
showStatusMessage(tr("Step requested..."), 5000);
- if (m_gdbAdapter->isTrkAdapter() && stackHandler()->stackSize() > 0)
+ if (m_gdbAdapter->isCodaAdapter() && stackHandler()->stackSize() > 0)
postCommand("sal step,0x" + QByteArray::number(stackHandler()->topAddress(), 16));
if (isReverseDebugging()) {
postCommand("reverse-step", RunRequest, CB(handleExecuteStep));
@@ -2065,7 +2063,7 @@ void GdbEngine::executeNext()
setTokenBarrier();
notifyInferiorRunRequested();
showStatusMessage(tr("Step next requested..."), 5000);
- if (m_gdbAdapter->isTrkAdapter() && stackHandler()->stackSize() > 0)
+ if (m_gdbAdapter->isCodaAdapter() && stackHandler()->stackSize() > 0)
postCommand("sal next,0x" + QByteArray::number(stackHandler()->topAddress(), 16));
if (isReverseDebugging()) {
postCommand("reverse-next", RunRequest, CB(handleExecuteNext));
@@ -2805,7 +2803,7 @@ void GdbEngine::insertBreakpoint(BreakpointId id)
cmd = "-break-insert -a -f ";
} else if (m_isMacGdb) {
cmd = "-break-insert -l -1 -f ";
- } else if (m_gdbAdapter->isTrkAdapter()) {
+ } else if (m_gdbAdapter->isCodaAdapter()) {
cmd = "-break-insert -h -f ";
} else if (m_gdbVersion >= 70000) {
int spec = handler->threadSpec(id);
@@ -3185,7 +3183,7 @@ void GdbEngine::reloadStack(bool forceGotoLocation)
PENDING_DEBUG("RELOAD STACK");
QByteArray cmd = "-stack-list-frames";
int stackDepth = debuggerCore()->action(MaximalStackDepth)->value().toInt();
- if (stackDepth && !m_gdbAdapter->isTrkAdapter())
+ if (stackDepth && !m_gdbAdapter->isCodaAdapter())
cmd += " 0 " + QByteArray::number(stackDepth);
// FIXME: gdb 6.4 symbianelf likes to be asked twice. The first time it
// returns with "^error,msg="Previous frame identical to this frame
@@ -3194,7 +3192,7 @@ void GdbEngine::reloadStack(bool forceGotoLocation)
// this sometimes happens, ask the second time immediately instead
// of waiting for the first request to fail.
// FIXME: Seems to work with 6.8.
- if (m_gdbAdapter->isTrkAdapter() && m_gdbVersion < 6.8)
+ if (m_gdbAdapter->isCodaAdapter() && m_gdbVersion < 6.8)
postCommand(cmd);
postCommand(cmd, Discardable, CB(handleStackListFrames),
QVariant::fromValue<StackCookie>(StackCookie(false, forceGotoLocation)));
@@ -3435,13 +3433,13 @@ void GdbEngine::reloadRegisters()
if (!m_registerNamesListed) {
postCommand("-data-list-register-names", CB(handleRegisterListNames));
m_registerNamesListed = true;
- // FIXME: Maybe better completely re-do this logic in TRK adapter.
- if (m_gdbAdapter->isTrkAdapter())
+ // FIXME: Maybe better completely re-do this logic in CODA adapter.
+ if (m_gdbAdapter->isCodaAdapter())
return;
}
- if (m_gdbAdapter->isTrkAdapter()) {
- m_gdbAdapter->trkReloadRegisters();
+ if (m_gdbAdapter->isCodaAdapter()) {
+ m_gdbAdapter->codaReloadRegisters();
} else {
postCommand("-data-list-register-values x",
Discardable, CB(handleRegisterListValues));
@@ -3475,8 +3473,8 @@ void GdbEngine::handleRegisterListNames(const GdbResponse &response)
registerHandler()->setRegisters(registers);
- if (m_gdbAdapter->isTrkAdapter())
- m_gdbAdapter->trkReloadRegisters();
+ if (m_gdbAdapter->isCodaAdapter())
+ m_gdbAdapter->codaReloadRegisters();
}
void GdbEngine::handleRegisterListValues(const GdbResponse &response)
diff --git a/src/plugins/debugger/gdb/gdbengine.h b/src/plugins/debugger/gdb/gdbengine.h
index aa97124afb..d4aa4c07e4 100644
--- a/src/plugins/debugger/gdb/gdbengine.h
+++ b/src/plugins/debugger/gdb/gdbengine.h
@@ -69,7 +69,6 @@ class AttachGdbAdapter;
class CoreGdbAdapter;
class LocalPlainGdbAdapter;
class RemoteGdbServerAdapter;
-class TrkGdbAdapter;
enum DebuggingHelperState
{
@@ -230,7 +229,6 @@ private:
friend class TermGdbAdapter;
friend class RemoteGdbServerAdapter;
friend class RemotePlainGdbAdapter;
- friend class TrkGdbAdapter;
friend class CodaGdbAdapter;
private: ////////// General Interface //////////
diff --git a/src/plugins/debugger/gdb/pythongdbengine.cpp b/src/plugins/debugger/gdb/pythongdbengine.cpp
index f6826a0b3b..50ffd4bc0d 100644
--- a/src/plugins/debugger/gdb/pythongdbengine.cpp
+++ b/src/plugins/debugger/gdb/pythongdbengine.cpp
@@ -205,8 +205,8 @@ void GdbEngine::updateAllPython()
postCommand("-stack-list-frames", CB(handleStackListFrames),
QVariant::fromValue<StackCookie>(StackCookie(false, true)));
stackHandler()->setCurrentIndex(0);
- if (m_gdbAdapter->isTrkAdapter())
- m_gdbAdapter->trkReloadThreads();
+ if (m_gdbAdapter->isCodaAdapter())
+ m_gdbAdapter->codaReloadThreads();
else
postCommand("-thread-list-ids", CB(handleThreadListIds), 0);
reloadRegisters();
diff --git a/src/plugins/debugger/gdb/s60debuggerbluetoothstarter.cpp b/src/plugins/debugger/gdb/s60debuggerbluetoothstarter.cpp
deleted file mode 100644
index dd463f6d0a..0000000000
--- a/src/plugins/debugger/gdb/s60debuggerbluetoothstarter.cpp
+++ /dev/null
@@ -1,73 +0,0 @@
-/**************************************************************************
-**
-** This file is part of Qt Creator
-**
-** Copyright (c) 2011 Nokia Corporation and/or its subsidiary(-ies).
-**
-** Contact: Nokia Corporation (info@qt.nokia.com)
-**
-**
-** GNU Lesser General Public License Usage
-**
-** This file may be used under the terms of the GNU Lesser General Public
-** License version 2.1 as published by the Free Software Foundation and
-** appearing in the file LICENSE.LGPL included in the packaging of this file.
-** Please review the following information to ensure the GNU Lesser General
-** Public License version 2.1 requirements will be met:
-** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** Other Usage
-**
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at info@qt.nokia.com.
-**
-**************************************************************************/
-
-#include "s60debuggerbluetoothstarter.h"
-
-#include "bluetoothlistener.h"
-#include "debuggerengine.h"
-#include "trkdevice.h"
-
-namespace Debugger {
-namespace Internal {
-
-S60DebuggerBluetoothStarter::S60DebuggerBluetoothStarter
- (const TrkDevicePtr& trkDevice, QObject *parent)
- : trk::AbstractBluetoothStarter(trkDevice, parent)
-{
-}
-
-trk::BluetoothListener *S60DebuggerBluetoothStarter::createListener()
-{
- DebuggerEngine *engine = 0; // FIXME: ABC
- trk::BluetoothListener *rc = new trk::BluetoothListener(engine);
- rc->setMode(trk::BluetoothListener::Listen);
- connect(rc, SIGNAL(message(QString)), engine, SLOT(showDebuggerOutput(QString)));
- connect(rc, SIGNAL(terminated()), engine, SLOT(startFailed()));
- return rc;
-}
-
-trk::PromptStartCommunicationResult
-S60DebuggerBluetoothStarter::startCommunication(const TrkDevicePtr &trkDevice,
- QWidget *msgBoxParent,
- QString *errorMessage)
-{
- // Bluetooth?
- if (trkDevice->serialFrame()) {
- BaseCommunicationStarter serialStarter(trkDevice);
- return trk::promptStartSerial(serialStarter, msgBoxParent, errorMessage);
- }
- S60DebuggerBluetoothStarter bluetoothStarter(trkDevice);
- return trk::promptStartBluetooth(bluetoothStarter, msgBoxParent, errorMessage);
-}
-
-} // namespace Internal
-} // namespace Debugger
diff --git a/src/plugins/debugger/gdb/s60debuggerbluetoothstarter.h b/src/plugins/debugger/gdb/s60debuggerbluetoothstarter.h
deleted file mode 100644
index 2c3cbb273a..0000000000
--- a/src/plugins/debugger/gdb/s60debuggerbluetoothstarter.h
+++ /dev/null
@@ -1,66 +0,0 @@
-/**************************************************************************
-**
-** This file is part of Qt Creator
-**
-** Copyright (c) 2011 Nokia Corporation and/or its subsidiary(-ies).
-**
-** Contact: Nokia Corporation (info@qt.nokia.com)
-**
-**
-** GNU Lesser General Public License Usage
-**
-** This file may be used under the terms of the GNU Lesser General Public
-** License version 2.1 as published by the Free Software Foundation and
-** appearing in the file LICENSE.LGPL included in the packaging of this file.
-** Please review the following information to ensure the GNU Lesser General
-** Public License version 2.1 requirements will be met:
-** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** Other Usage
-**
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at info@qt.nokia.com.
-**
-**************************************************************************/
-
-#ifndef S60DEBUGGERBLUETOOTHSTARTER_H
-#define S60DEBUGGERBLUETOOTHSTARTER_H
-
-#include "communicationstarter.h"
-#include "bluetoothlistener_gui.h"
-
-namespace Debugger {
-namespace Internal {
-
-/* S60DebuggerBluetoothStarter: Creates a listener in 'Listen' mode
- * parented on the Debugger manager which outputs to the debugger window.
- * Note: This is a "last resort" starter, normally, the run configuration
- * should have already started a listener.
- * Provides a static convenience to prompt for both connection types. */
-
-class S60DebuggerBluetoothStarter : public trk::AbstractBluetoothStarter
-{
-public:
- static trk::PromptStartCommunicationResult
- startCommunication(const TrkDevicePtr &trkDevice,
- QWidget *msgBoxParent,
- QString *errorMessage);
-
-protected:
- virtual trk::BluetoothListener *createListener();
-
-private:
- explicit S60DebuggerBluetoothStarter(const TrkDevicePtr& trkDevice, QObject *parent = 0);
-};
-
-} // namespace Internal
-} // namespace Debugger
-
-#endif // S60DEBUGGERBLUETOOTHSTARTER_H
diff --git a/src/plugins/debugger/gdb/symbian.cpp b/src/plugins/debugger/gdb/symbian.cpp
index b758596f37..a3cf5f67df 100644
--- a/src/plugins/debugger/gdb/symbian.cpp
+++ b/src/plugins/debugger/gdb/symbian.cpp
@@ -33,7 +33,7 @@
#include "symbian.h"
#include "registerhandler.h"
#include "threadshandler.h"
-#include <trkutils.h>
+#include <codautils.h>
#include <utils/qtcassert.h>
@@ -120,7 +120,7 @@ QByteArray dumpRegister(uint n, uint value)
ba += QByteArray::number(n);
}
ba += '=';
- ba += trk::hexxNumber(value);
+ ba += Coda::hexxNumber(value);
return ba;
}
@@ -145,8 +145,8 @@ QByteArray Thread::gdbReportRegisters() const
{
QByteArray ba;
for (int i = 0; i < 16; ++i) {
- const uint reg = trk::swapEndian(registers[i]);
- ba += trk::hexNumber(reg, 8);
+ const uint reg = Coda::swapEndian(registers[i]);
+ ba += Coda::hexNumber(reg, 8);
}
return ba;
}
@@ -174,18 +174,18 @@ QByteArray Thread::gdbRegisterLogMessage(bool verbose) const
QByteArray Thread::gdbReportSingleRegister(unsigned i) const
{
if (i == RegisterPSGdb)
- i = RegisterPSTrk;
+ i = RegisterPSCoda;
if (i >= RegisterCount)
return QByteArray("0000"); // Unknown
QByteArray ba;
- appendInt(&ba, registers[i], trk::LittleEndian);
+ appendInt(&ba, registers[i], Coda::LittleEndian);
return ba.toHex();
}
QByteArray Thread::gdbSingleRegisterLogMessage(unsigned i) const
{
if (i == RegisterPSGdb)
- i = RegisterPSTrk;
+ i = RegisterPSCoda;
if (i >= RegisterCount)
return QByteArray("Read single unknown register #") + QByteArray::number(i);
QByteArray logMsg = "Read Register ";
@@ -395,7 +395,7 @@ QByteArray Snapshot::gdbQsThreadInfo() const
for (int i = 0; i < count; i++) {
if (i)
response += ',';
- response += trk::hexNumber(threadInfo.at(i).id);
+ response += Coda::hexNumber(threadInfo.at(i).id);
}
return response;
}
@@ -415,18 +415,18 @@ QByteArray Snapshot::gdbQThreadExtraInfo(const QByteArray &cmd) const
static void gdbAppendRegister(QByteArray *ba, uint regno, uint value)
{
- ba->append(trk::hexNumber(regno, 2));
+ ba->append(Coda::hexNumber(regno, 2));
ba->append(':');
- ba->append(trk::hexNumber(trk::swapEndian(value), 8));
+ ba->append(Coda::hexNumber(Coda::swapEndian(value), 8));
ba->append(';');
}
QByteArray Snapshot::gdbStopMessage(uint threadId, int signalNumber, bool reportThreadId) const
{
- QByteArray ba = ('T' + trk::hexNumber(signalNumber, 2));
+ QByteArray ba = ('T' + Coda::hexNumber(signalNumber, 2));
if (reportThreadId) {
ba += "thread:";
- ba += trk::hexNumber(threadId, 3);
+ ba += Coda::hexNumber(threadId, 3);
ba += ';';
}
const int threadIndex = indexOfThread(threadId);
@@ -437,7 +437,7 @@ QByteArray Snapshot::gdbStopMessage(uint threadId, int signalNumber, bool report
// FIXME: those are not understood by gdb 6.4
//for (int i = 16; i < 25; ++i)
// appendRegister(&ba, i, 0x0);
- gdbAppendRegister(&ba, RegisterPSGdb, thread.registers[RegisterPSTrk]);
+ gdbAppendRegister(&ba, RegisterPSGdb, thread.registers[RegisterPSCoda]);
return ba;
}
@@ -447,12 +447,12 @@ QByteArray Snapshot::memoryReadLogMessage(uint addr, uint threadId, bool verbose
QByteArray logMsg = "memory contents";
const uint *regs = registers(threadId);
if (verbose && regs) {
- logMsg += " addr: " + trk::hexxNumber(addr);
+ logMsg += " addr: " + Coda::hexxNumber(addr);
// indicate dereferencing of registers
if (ba.size() == 4) {
if (addr == regs[RegisterPC]) {
logMsg += "[PC]";
- } else if (addr == regs[RegisterPSTrk]) {
+ } else if (addr == regs[RegisterPSCoda]) {
logMsg += "[PSTrk]";
} else if (addr == regs[RegisterSP]) {
logMsg += "[SP]";
@@ -468,7 +468,7 @@ QByteArray Snapshot::memoryReadLogMessage(uint addr, uint threadId, bool verbose
logMsg += " length ";
logMsg += QByteArray::number(ba.size());
logMsg += " :";
- logMsg += trk::stringFromArray(ba, ba.size()).toAscii();
+ logMsg += Coda::stringFromArray(ba, ba.size()).toAscii();
}
return logMsg;
}
@@ -486,9 +486,9 @@ void Snapshot::syncRegisters(uint threadId, RegisterHandler *handler) const
qDebug() << "HAVE: " << debuggerRegisters.size(); return);
for (int i = 0; i < RegisterCount; ++i) {
- const int gdbIndex = i == RegisterPSTrk ? int(RegisterPSGdb) : i;
+ const int gdbIndex = i == RegisterPSCoda ? int(RegisterPSGdb) : i;
Register &reg = debuggerRegisters[gdbIndex];
- reg.value = trk::hexxNumber(thread.registers[i]);
+ reg.value = Coda::hexxNumber(thread.registers[i]);
}
handler->setAndMarkRegisters(debuggerRegisters);
}
@@ -658,7 +658,7 @@ QPair<uint, uint> parseGdbWriteRegisterWriteRequest(const QByteArray &cmd)
const QByteArray valueName = cmd.mid(pos + 1);
bool ok = false;
const uint registerNumber = regName.toUInt(&ok, 16);
- const uint value = trk::swapEndian(valueName.toUInt(&ok, 16));
+ const uint value = Coda::swapEndian(valueName.toUInt(&ok, 16));
return QPair<uint, uint>(registerNumber, value);
}
diff --git a/src/plugins/debugger/gdb/symbian.h b/src/plugins/debugger/gdb/symbian.h
index d2ddad89e4..d3a6a8591f 100644
--- a/src/plugins/debugger/gdb/symbian.h
+++ b/src/plugins/debugger/gdb/symbian.h
@@ -97,7 +97,7 @@ enum TargetConstants
RegisterLR = 14, // Return address
RegisterPC = 15, // Program counter
RegisterPSGdb = 25, // gdb's view of the world
- RegisterPSTrk = 16, // TRK's view of the world
+ RegisterPSCoda = 16, // CODA's view of the world
MemoryChunkSize = 256
};
diff --git a/src/plugins/debugger/gdb/trkgdbadapter.cpp b/src/plugins/debugger/gdb/trkgdbadapter.cpp
deleted file mode 100644
index 90c4f14823..0000000000
--- a/src/plugins/debugger/gdb/trkgdbadapter.cpp
+++ /dev/null
@@ -1,1996 +0,0 @@
-/**************************************************************************
-**
-** This file is part of Qt Creator
-**
-** Copyright (c) 2011 Nokia Corporation and/or its subsidiary(-ies).
-**
-** Contact: Nokia Corporation (info@qt.nokia.com)
-**
-**
-** GNU Lesser General Public License Usage
-**
-** This file may be used under the terms of the GNU Lesser General Public
-** License version 2.1 as published by the Free Software Foundation and
-** appearing in the file LICENSE.LGPL included in the packaging of this file.
-** Please review the following information to ensure the GNU Lesser General
-** Public License version 2.1 requirements will be met:
-** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** Other Usage
-**
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at info@qt.nokia.com.
-**
-**************************************************************************/
-
-#include "trkgdbadapter.h"
-
-#include "debuggerstartparameters.h"
-#include "gdbmi.h"
-#include "launcher.h"
-#include "symbiandevicemanager.h"
-#include "s60debuggerbluetoothstarter.h"
-#include "bluetoothlistener_gui.h"
-
-#include "registerhandler.h"
-#include "threadshandler.h"
-#include "debuggeractions.h"
-#include "debuggercore.h"
-#include "debuggerstringutils.h"
-#include "watchutils.h"
-#ifndef STANDALONE_RUNNER
-#include "gdbengine.h"
-#endif
-
-#include <utils/qtcassert.h>
-#include <utils/qtcprocess.h>
-#include <utils/savedaction.h>
-
-#include <QtCore/QTimer>
-#include <QtCore/QDir>
-#include <QtNetwork/QTcpServer>
-#include <QtNetwork/QTcpSocket>
-
-#ifdef Q_OS_WIN
-# include "dbgwinutils.h"
-#else
-# include <sys/types.h>
-# include <unistd.h>
-#endif
-
-#define CB(callback) \
- static_cast<GdbEngine::AdapterCallback>(&TrkGdbAdapter::callback), \
- STRINGIFY(callback)
-
-#define TrkCB(s) TrkCallback(this, &TrkGdbAdapter::s)
-
-using namespace trk;
-
-namespace Debugger {
-namespace Internal {
-using namespace Symbian;
-
-static inline void appendByte(QByteArray *ba, trk::byte b) { ba->append(b); }
-
-///////////////////////////////////////////////////////////////////////////
-//
-// TrkGdbAdapter
-//
-///////////////////////////////////////////////////////////////////////////
-
-/* Thread handling:
- * TRK does not report thread creation/termination. So, if we receive
- * a stop in a different thread, we store an additional thread in snapshot.
- * When continuing in trkContinueAll(), 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: Stop all threads once one stops? */
-
-TrkGdbAdapter::TrkGdbAdapter(GdbEngine *engine) :
- AbstractGdbAdapter(engine),
- m_running(false),
- m_gdbAckMode(true),
- m_verbose(0)
-{
- m_bufferedMemoryRead = true;
- // Disable buffering if gdb's dcache is used.
- m_bufferedMemoryRead = false;
-
- m_gdbServer = 0;
- m_gdbConnection = 0;
- m_snapshot.reset();
-#ifdef Q_OS_WIN
- const unsigned long portOffset = winGetCurrentProcessId() % 100;
-#else
- const uid_t portOffset = getuid();
-#endif
- m_gdbServerName = _("127.0.0.1:%1").arg(2222 + portOffset);
-
- setVerbose(debuggerCore()->boolSetting(VerboseLog));
-
- connect(debuggerCore()->action(VerboseLog), SIGNAL(valueChanged(QVariant)),
- this, SLOT(setVerbose(QVariant)));
-}
-
-TrkGdbAdapter::~TrkGdbAdapter()
-{
- cleanup();
- logMessage("Shutting down.\n");
-}
-
-void TrkGdbAdapter::setVerbose(const QVariant &value)
-{
- setVerbose(value.toInt());
-}
-
-void TrkGdbAdapter::setVerbose(int verbose)
-{
- m_verbose = verbose;
- if (!m_trkDevice.isNull())
- m_trkDevice->setVerbose(m_verbose);
-}
-
-void TrkGdbAdapter::trkLogMessage(const QString &msg)
-{
- logMessage("TRK " + msg);
-}
-
-void TrkGdbAdapter::setGdbServerName(const QString &name)
-{
- m_gdbServerName = name;
-}
-
-QString TrkGdbAdapter::gdbServerIP() const
-{
- int pos = m_gdbServerName.indexOf(':');
- if (pos == -1)
- return m_gdbServerName;
- return m_gdbServerName.left(pos);
-}
-
-uint TrkGdbAdapter::gdbServerPort() const
-{
- int pos = m_gdbServerName.indexOf(':');
- if (pos == -1)
- return 0;
- return m_gdbServerName.mid(pos + 1).toUInt();
-}
-
-QByteArray TrkGdbAdapter::trkContinueMessage(uint threadId)
-{
- QByteArray ba;
- appendInt(&ba, m_session.pid);
- appendInt(&ba, threadId);
- return ba;
-}
-
-QByteArray TrkGdbAdapter::trkWriteRegisterMessage(trk::byte reg, uint value)
-{
- QByteArray ba;
- appendByte(&ba, 0); // ?
- appendShort(&ba, reg);
- appendShort(&ba, reg);
- appendInt(&ba, m_session.pid);
- appendInt(&ba, m_session.tid);
- appendInt(&ba, value);
- return ba;
-}
-
-QByteArray TrkGdbAdapter::trkReadMemoryMessage(const MemoryRange &range)
-{
- return trk::Launcher::readMemoryMessage(m_session.pid, m_session.tid, range.from, range.size());
-}
-
-QByteArray TrkGdbAdapter::trkWriteMemoryMessage(uint addr, const QByteArray &data)
-{
- QByteArray ba;
- ba.reserve(11 + data.size());
- appendByte(&ba, 0x08); // Options, FIXME: why?
- appendShort(&ba, data.size());
- appendInt(&ba, addr);
- appendInt(&ba, m_session.pid);
- appendInt(&ba, m_session.tid);
- ba.append(data);
- return ba;
-}
-
-QByteArray TrkGdbAdapter::trkStepRangeMessage()
-{
- //qDebug() << "STEP ON " << hexxNumber(m_snapshot.registers[RegisterPC]);
- uint from = m_snapshot.lineFromAddress;
- uint to = m_snapshot.lineToAddress;
- const uint pc = m_snapshot.registerValue(m_session.tid, RegisterPC);
- trk::byte option = 0x01; // Step into.
- if (m_snapshot.stepOver)
- option = 0x11; // Step over.
- if (from <= pc && pc <= to) {
- //to = qMax(to - 4, from);
- //to = qMax(to - 4, from);
- showMessage(_("STEP IN ") + hexxNumber(from) + ' ' + hexxNumber(to)
- + _(" INSTEAD OF ") + hexxNumber(pc));
- } else {
- from = pc;
- to = pc;
- }
- logMessage(QString::fromLatin1("Stepping from 0x%1 to 0x%2 (current PC=0x%3), option 0x%4").
- arg(from, 0, 16).arg(to, 0, 16).arg(pc).arg(option, 0, 16));
- QByteArray ba;
- ba.reserve(17);
- appendByte(&ba, option);
- appendInt(&ba, from); // Start address
- appendInt(&ba, to); // End address
- appendInt(&ba, m_session.pid);
- appendInt(&ba, m_session.tid);
- return ba;
-}
-
-QByteArray TrkGdbAdapter::trkDeleteProcessMessage()
-{
- QByteArray ba;
- ba.reserve(6);
- appendByte(&ba, 0); // ?
- appendByte(&ba, 0); // Sub-command: Delete Process
- appendInt(&ba, m_session.pid);
- return ba;
-}
-
-QByteArray TrkGdbAdapter::trkInterruptMessage()
-{
- QByteArray ba;
- ba.reserve(9);
- // Stop the thread (2) or the process (1) or the whole system (0).
- // We choose 2, as 1 does not seem to work.
- appendByte(&ba, 2);
- appendInt(&ba, m_session.pid);
- appendInt(&ba, m_session.mainTid); // threadID: 4 bytes Variable number of bytes.
- return ba;
-}
-
-void TrkGdbAdapter::emitDelayedInferiorSetupFailed(const QString &msg)
-{
- m_adapterFailMessage = msg;
- QTimer::singleShot(0, this, SLOT(slotEmitDelayedInferiorSetupFailed()));
-}
-
-void TrkGdbAdapter::slotEmitDelayedInferiorSetupFailed()
-{
- m_engine->notifyInferiorSetupFailed(m_adapterFailMessage);
-}
-
-
-void TrkGdbAdapter::logMessage(const QString &msg, int logChannel)
-{
- if (m_verbose || logChannel != LogDebug)
- showMessage("TRK LOG: " + msg, logChannel);
- MEMORY_DEBUG("GDB: " << msg);
-}
-
-//
-// Gdb
-//
-void TrkGdbAdapter::handleGdbConnection()
-{
- logMessage("HANDLING GDB CONNECTION");
- QTC_ASSERT(m_gdbConnection == 0, /**/);
- m_gdbConnection = m_gdbServer->nextPendingConnection();
- QTC_ASSERT(m_gdbConnection, return);
- connect(m_gdbConnection, SIGNAL(disconnected()),
- m_gdbConnection, SLOT(deleteLater()));
- connect(m_gdbConnection, SIGNAL(readyRead()),
- this, SLOT(readGdbServerCommand()));
-}
-
-static inline QString msgGdbPacket(const QString &p)
-{
- return QLatin1String("gdb: ") + p;
-}
-
-void TrkGdbAdapter::readGdbServerCommand()
-{
- QTC_ASSERT(m_gdbConnection, return);
- QByteArray packet = m_gdbConnection->readAll();
- m_gdbReadBuffer.append(packet);
-
- logMessage("gdb: -> " + currentTime() + ' ' + QString::fromAscii(packet));
- if (packet != m_gdbReadBuffer)
- logMessage(QLatin1String("buffer: ") + m_gdbReadBuffer);
-
- QByteArray &ba = m_gdbReadBuffer;
- while (ba.size()) {
- char code = ba.at(0);
- ba = ba.mid(1);
-
- if (code == '+') {
- //logMessage("ACK");
- continue;
- }
-
- if (code == '-') {
- logMessage("NAK: Retransmission requested", LogError);
- // This seems too harsh.
- //emit adapterCrashed("Communication problem encountered.");
- continue;
- }
-
- if (code == char(0x03)) {
- logMessage("INTERRUPT RECEIVED");
- interruptInferior();
- continue;
- }
-
- if (code != '$') {
- logMessage("Broken package (2) " + quoteUnprintableLatin1(ba)
- + hexNumber(code), LogError);
- continue;
- }
-
- int pos = ba.indexOf('#');
- if (pos == -1) {
- logMessage("Invalid checksum format in "
- + quoteUnprintableLatin1(ba), LogError);
- continue;
- }
-
- bool ok = false;
- uint checkSum = ba.mid(pos + 1, 2).toUInt(&ok, 16);
- if (!ok) {
- logMessage("Invalid checksum format 2 in "
- + quoteUnprintableLatin1(ba), LogError);
- return;
- }
-
- //logMessage(QString("Packet checksum: %1").arg(checkSum));
- trk::byte sum = 0;
- for (int i = 0; i < pos; ++i)
- sum += ba.at(i);
-
- if (sum != checkSum) {
- logMessage(QString("ERROR: Packet checksum wrong: %1 %2 in "
- + quoteUnprintableLatin1(ba)).arg(checkSum).arg(sum), LogError);
- }
-
- QByteArray cmd = ba.left(pos);
- ba.remove(0, pos + 3);
- handleGdbServerCommand(cmd);
- }
-}
-
-bool TrkGdbAdapter::sendGdbServerPacket(const QByteArray &packet, bool doFlush)
-{
- if (!m_gdbConnection) {
- logMessage(_("Cannot write to gdb: No connection (%1)")
- .arg(_(packet)), LogError);
- return false;
- }
- if (m_gdbConnection->state() != QAbstractSocket::ConnectedState) {
- logMessage(_("Cannot write to gdb: Not connected (%1)")
- .arg(_(packet)), LogError);
- return false;
- }
- if (m_gdbConnection->write(packet) == -1) {
- logMessage(_("Cannot write to gdb: %1 (%2)")
- .arg(m_gdbConnection->errorString()).arg(_(packet)), LogError);
- return false;
- }
- if (doFlush)
- m_gdbConnection->flush();
- return true;
-}
-
-void TrkGdbAdapter::sendGdbServerAck()
-{
- if (!m_gdbAckMode)
- return;
- logMessage("gdb: <- +");
- sendGdbServerPacket(QByteArray(1, '+'), false);
-}
-
-void TrkGdbAdapter::sendGdbServerMessage(const QByteArray &msg, const QByteArray &logNote)
-{
- trk::byte sum = 0;
- for (int i = 0; i != msg.size(); ++i)
- sum += msg.at(i);
-
- char checkSum[30];
- qsnprintf(checkSum, sizeof(checkSum) - 1, "%02x ", sum);
-
- //logMessage(QString("Packet checksum: %1").arg(sum));
-
- QByteArray packet;
- packet.append('$');
- packet.append(msg);
- packet.append('#');
- packet.append(checkSum);
- int pad = qMax(0, 24 - packet.size());
- logMessage("gdb: <- " + currentTime() + ' ' + packet + QByteArray(pad, ' ') + logNote);
- sendGdbServerPacket(packet, true);
-}
-
-void TrkGdbAdapter::sendGdbServerMessageAfterTrkResponse(const QByteArray &msg,
- const QByteArray &logNote)
-{
- QByteArray ba = msg + char(1) + logNote;
- sendTrkMessage(TRK_WRITE_QUEUE_NOOP_CODE, TrkCB(reportToGdb), "", ba); // Answer gdb
-}
-
-void TrkGdbAdapter::reportToGdb(const TrkResult &result)
-{
- QByteArray message = result.cookie.toByteArray();
- QByteArray note;
- int pos = message.lastIndexOf(char(1)); // HACK
- if (pos != -1) {
- note = message.mid(pos + 1);
- message = message.left(pos);
- }
- message.replace("@CODESEG@", hexNumber(m_session.codeseg));
- message.replace("@DATASEG@", hexNumber(m_session.dataseg));
- message.replace("@PID@", hexNumber(m_session.pid));
- message.replace("@TID@", hexNumber(m_session.tid));
- sendGdbServerMessage(message, note);
-}
-
-QByteArray TrkGdbAdapter::trkBreakpointMessage(uint addr, uint len, bool armMode)
-{
- QByteArray ba;
- appendByte(&ba, 0x82); // unused option
- appendByte(&ba, armMode /*bp.mode == ArmMode*/ ? 0x00 : 0x01);
- appendInt(&ba, addr);
- appendInt(&ba, len);
- appendInt(&ba, 0x00000001);
- appendInt(&ba, m_session.pid);
- appendInt(&ba, 0xFFFFFFFF);
- return ba;
-}
-
-static QByteArray msgStepRangeReceived(unsigned from, unsigned to, bool over)
-{
- QByteArray rc = "Stepping range received for step ";
- rc += over ? "over" : "into";
- rc += " (0x";
- rc += QByteArray::number(from, 16);
- rc += " to 0x";
- rc += QByteArray::number(to, 16);
- rc += ')';
- return rc;
-}
-
-void TrkGdbAdapter::handleGdbServerCommand(const QByteArray &cmd)
-{
- // http://sourceware.org/gdb/current/onlinedocs/gdb_34.html
- if (0) {}
-
- else if (cmd == "!") {
- sendGdbServerAck();
- //sendGdbServerMessage("", "extended mode not enabled");
- sendGdbServerMessage("OK", "extended mode enabled");
- }
-
- else if (cmd.startsWith('?')) {
- logMessage(msgGdbPacket(QLatin1String("Query halted")));
- // Indicate the reason the target halted.
- // The reply is the same as for step and continue.
- sendGdbServerAck();
- // The command below will trigger fetching a stack trace while
- // the process does not seem to be fully functional. Most notably
- // the PC points to a 0x9..., which is not in "our" range
- //sendGdbServerMessage("T05library:r;", "target halted (library load)");
- //sendGdbServerMessage("S05", "target halted (trap)");
- sendGdbServerMessage("S00", "target halted (trap)");
- //sendGdbServerMessage("O" + QByteArray("Starting...").toHex());
- }
-
- else if (cmd == "c") {
- logMessage(msgGdbPacket(QLatin1String("Continue")));
- sendGdbServerAck();
- m_running = true;
- trkContinueAll("gdb 'c'");
- }
-
- else if (cmd.startsWith('C')) {
- logMessage(msgGdbPacket(QLatin1String("Continue with signal")));
- // C sig[;addr] Continue with signal sig (hex signal number)
- //Reply: See section D.3 Stop Reply Packets, for the reply specifications.
- //TODO: Meaning of the message is not clear.
- sendGdbServerAck();
- bool ok = false;
- const uint signalNumber = cmd.mid(1).toUInt(&ok, 16);
- logMessage(_("Not implemented 'Continue with signal' %1: ")
- .arg(signalNumber), LogWarning);
- sendGdbServerMessage('O' + QByteArray("Console output").toHex());
- sendGdbServerMessage("W81"); // "Process exited with result 1
- trkContinueAll("gdb 'C'");
- }
-
- else if (cmd.startsWith('D')) {
- sendGdbServerAck();
- sendGdbServerMessage("OK", "shutting down");
- }
-
- else if (cmd == "g") {
- // Read general registers.
- if (m_snapshot.registersValid(m_session.tid)) {
- //qDebug() << "Using cached register contents";
- logMessage(msgGdbPacket(QLatin1String("Read registers")));
- sendGdbServerAck();
- reportRegisters();
- } else {
- //qDebug() << "Fetching register contents";
- sendGdbServerAck();
- sendTrkMessage(0x12,
- TrkCB(handleAndReportReadRegisters),
- Launcher::readRegistersMessage(m_session.pid, m_session.tid));
- }
- }
-
- else if (cmd == "gg") {
- // Force re-reading general registers for debugging purpose.
- sendGdbServerAck();
- m_snapshot.setRegistersValid(m_session.tid, false);
- sendTrkMessage(0x12,
- TrkCB(handleAndReportReadRegisters),
- Launcher::readRegistersMessage(m_session.pid, m_session.tid));
- }
-
- else if (cmd.startsWith("salstep,")) {
- // Receive address range for current line for future use when stepping.
- sendGdbServerAck();
- m_snapshot.parseGdbStepRange(cmd, false);
- sendGdbServerMessage("", msgStepRangeReceived(m_snapshot.lineFromAddress, m_snapshot.lineToAddress, m_snapshot.stepOver));
- }
-
- else if (cmd.startsWith("salnext,")) {
- // Receive address range for current line for future use when stepping.
- sendGdbServerAck();
- m_snapshot.parseGdbStepRange(cmd, true);
- sendGdbServerMessage("", msgStepRangeReceived(m_snapshot.lineFromAddress, m_snapshot.lineToAddress, m_snapshot.stepOver));
- }
-
- else if (cmd.startsWith("Hc")) {
- sendGdbServerAck();
- gdbSetCurrentThread(cmd, "Set current thread for step & continue ");
- }
-
- else if (cmd.startsWith("Hg")) {
- sendGdbServerAck();
- gdbSetCurrentThread(cmd, "Set current thread ");
- }
-
- else if (cmd == "k" || cmd.startsWith("vKill")) {
- trkKill();
- }
-
- else if (cmd.startsWith('m')) {
- logMessage(msgGdbPacket(QLatin1String("Read memory")));
- // m addr,length
- sendGdbServerAck();
- const QPair<quint64, unsigned> addrLength = parseGdbReadMemoryRequest(cmd);
- if (addrLength.second) {
- readMemory(addrLength.first, addrLength.second, m_bufferedMemoryRead);
- } else {
- sendGdbServerMessage("E20", "Error " + cmd);
- }
- }
-
- else if (cmd.startsWith('p')) {
- logMessage(msgGdbPacket(QLatin1String("read register")));
- // 0xf == current instruction pointer?
- //sendGdbServerMessage("0000", "current IP");
- sendGdbServerAck();
- bool ok = false;
- const uint registerNumber = cmd.mid(1).toUInt(&ok, 16);
- const int threadIndex = m_snapshot.indexOfThread(m_session.tid);
- QTC_ASSERT(threadIndex != -1, return)
- const Symbian::Thread &thread = m_snapshot.threadInfo[threadIndex];
- if (thread.registerValid) {
- sendGdbServerMessage(thread.gdbReportSingleRegister(registerNumber), thread.gdbSingleRegisterLogMessage(registerNumber));
- } else {
- //qDebug() << "Fetching single register";
- sendTrkMessage(0x12,
- TrkCB(handleAndReportReadRegister),
- Launcher::readRegistersMessage(m_session.pid, m_session.tid), registerNumber);
- }
- }
-
- else if (cmd.startsWith('P')) {
- logMessage(msgGdbPacket(QLatin1String("write register")));
- // $Pe=70f96678#d3
- sendGdbServerAck();
- const QPair<uint, uint> regnumValue = parseGdbWriteRegisterWriteRequest(cmd);
- // FIXME: Assume all goes well.
- m_snapshot.setRegisterValue(m_session.tid, regnumValue.first, regnumValue.second);
- QByteArray ba = trkWriteRegisterMessage(regnumValue.first, regnumValue.second);
- sendTrkMessage(0x13, TrkCB(handleWriteRegister), ba, "Write register");
- // Note that App TRK refuses to write registers 13 and 14
- }
-
- else if (cmd == "qAttached") {
- //$qAttached#8f
- // 1: attached to an existing process
- // 0: created a new process
- sendGdbServerAck();
- sendGdbServerMessage(QByteArray(1, '0'), "new process created");
- //sendGdbServerMessage('1', "attached to existing process");
- //sendGdbServerMessage("E01", "new process created");
- }
-
- else if (cmd.startsWith("qC")) {
- logMessage(msgGdbPacket(QLatin1String("query thread id")));
- // Return the current thread ID
- //$qC#b4
- sendGdbServerAck();
- sendGdbServerMessageAfterTrkResponse("QC@TID@");
- }
-
- else if (cmd.startsWith("qSupported")) {
- //$qSupported#37
- //$qSupported:multiprocess+#c6
- //logMessage("Handling 'qSupported'");
- sendGdbServerAck();
- sendGdbServerMessage(Symbian::gdbQSupported);
- }
-
- // Tracepoint handling as of gdb 7.2 onwards
- else if (cmd == "qTStatus") { // Tracepoints
- sendGdbServerAck();
- sendGdbServerMessage("T0;tnotrun:0", QByteArray("No trace experiment running"));
- }
- // Trace variables as of gdb 7.2 onwards
- else if (cmd == "qTfV" || cmd == "qTsP" || cmd == "qTfP") {
- sendGdbServerAck();
- sendGdbServerMessage("l", QByteArray("No trace points"));
- }
-
- else if (cmd.startsWith("qThreadExtraInfo")) {
- // $qThreadExtraInfo,1f9#55
- sendGdbServerAck();
- sendGdbServerMessage(m_snapshot.gdbQThreadExtraInfo(cmd));
- }
-
- else if (cmd == "qfDllInfo") {
- // That's the _first_ query package.
- // Happens with gdb 6.4.50.20060226-cvs / CodeSourcery.
- // Never made it into FSF gdb that got qXfer:libraries:read instead.
- // http://sourceware.org/ml/gdb/2007-05/msg00038.html
- // Name=hexname,TextSeg=textaddr[,DataSeg=dataaddr]
- sendGdbServerAck();
- sendGdbServerMessage(m_session.gdbQsDllInfo(), "library information transferred");
- }
-
- else if (cmd == "qsDllInfo") {
- // That's a following query package
- sendGdbServerAck();
- sendGdbServerMessage(QByteArray(1, 'l'), "library information transfer finished");
- }
-
- else if (cmd == "qPacketInfo") {
- // happens with gdb 6.4.50.20060226-cvs / CodeSourcery
- // deprecated by qSupported?
- sendGdbServerAck();
- sendGdbServerMessage("", "FIXME: nothing?");
- }
-
- else if (cmd == "qOffsets") {
- sendGdbServerAck();
- sendGdbServerMessageAfterTrkResponse("TextSeg=@CODESEG@;DataSeg=@DATASEG@");
- }
-
- else if (cmd == "qSymbol::") {
- if (m_verbose)
- logMessage(msgGdbPacket(QLatin1String("notify can handle symbol lookup")));
- // Notify the target that GDB is prepared to serve symbol lookup requests.
- sendGdbServerAck();
- if (1)
- sendGdbServerMessage("OK", "no further symbols needed");
- else
- sendGdbServerMessage("qSymbol:" + QByteArray("_Z7E32Mainv").toHex(),
- "ask for more");
- }
-
- else if (cmd.startsWith("qXfer:features:read:target.xml:")) {
- // $qXfer:features:read:target.xml:0,7ca#46...Ack
- sendGdbServerAck();
- sendGdbServerMessage(Symbian::gdbArchitectureXml);
- }
-
- else if (cmd == "qfThreadInfo") {
- // That's the _first_ query package.
- sendGdbServerAck();
- sendGdbServerMessage(m_snapshot.gdbQsThreadInfo(), "thread information transferred");
- }
-
- else if (cmd == "qsThreadInfo") {
- // That's a following query package
- sendGdbServerAck();
- sendGdbServerMessage(QByteArray(1, 'l'), "thread information transfer finished");
- }
-
- else if (cmd.startsWith("qXfer:libraries:read")) {
- sendGdbServerAck();
- sendGdbServerMessage(m_session.gdbLibraryList(), "library information transferred");
- }
-
- else if (cmd == "QStartNoAckMode") {
- //$qSupported#37
- logMessage("Handling 'QStartNoAckMode'");
- sendGdbServerAck();
- sendGdbServerMessage("OK", "ack no-ack mode");
- m_gdbAckMode = false;
- }
-
- else if (cmd.startsWith("QPassSignals")) {
- // list of signals to pass directly to inferior
- // $QPassSignals:e;10;14;17;1a;1b;1c;21;24;25;4c;#8f
- // happens only if "QPassSignals+;" is qSupported
- sendGdbServerAck();
- // FIXME: use the parameters
- sendGdbServerMessage("OK", "passing signals accepted");
- }
-
- else if (cmd == "s" || cmd.startsWith("vCont;s")) {
- const uint pc = m_snapshot.registerValue(m_session.tid, RegisterPC);
- logMessage(msgGdbPacket(QString::fromLatin1("Step range from 0x%1").
- arg(pc, 0, 16)));
- sendGdbServerAck();
- //m_snapshot.reset();
- m_running = true;
- QByteArray ba = trkStepRangeMessage();
- sendTrkMessage(0x19, TrkCB(handleStep), ba, "Step range");
- }
-
- else if (cmd.startsWith('T')) {
- // FIXME: check whether thread is alive
- sendGdbServerAck();
- sendGdbServerMessage("OK"); // pretend all is well
- //sendGdbServerMessage("E nn");
- }
-
- else if (cmd == "vCont?") {
- // actions supported by the vCont packet
- sendGdbServerAck();
- //sendGdbServerMessage("OK"); // we don't support vCont.
- sendGdbServerMessage("vCont;c;C;s;S");
- }
-
- else if (cmd == "vCont;c") {
- // vCont[;action[:thread-id]]...'
- sendGdbServerAck();
- //m_snapshot.reset();
- m_running = true;
- trkContinueAll("gdb 'vCont;c'");
- }
-
- else if (cmd.startsWith("Z0,") || cmd.startsWith("Z1,")) {
- // Insert breakpoint
- sendGdbServerAck();
- logMessage(msgGdbPacket(QLatin1String("Insert breakpoint")));
- // $Z0,786a4ccc,4#99
- const QPair<quint64, unsigned> addrLen = parseGdbSetBreakpointRequest(cmd);
- if (addrLen.first) {
- //qDebug() << "ADDR: " << hexNumber(addr) << " LEN: " << len;
- logMessage(_("Inserting breakpoint at 0x%1, %2")
- .arg(addrLen.first, 0, 16).arg(addrLen.second));
- const bool armMode = addrLen.second == 4;
- const QByteArray ba = trkBreakpointMessage(addrLen.first, addrLen.second, armMode);
- sendTrkMessage(0x1B, TrkCB(handleAndReportSetBreakpoint), ba, QVariant(addrLen.first));
- } else {
- logMessage(QLatin1String("MISPARSED BREAKPOINT '") + cmd + "')", LogError);
- }
- }
-
- else if (cmd.startsWith("z0,") || cmd.startsWith("z1,")) {
- // Remove breakpoint
- sendGdbServerAck();
- logMessage(msgGdbPacket(QLatin1String("Remove breakpoint")));
- // $z0,786a4ccc,4#99
- const int pos = cmd.lastIndexOf(',');
- bool ok = false;
- const uint addr = cmd.mid(3, pos - 3).toUInt(&ok, 16);
- const uint len = cmd.mid(pos + 1).toUInt(&ok, 16);
- const uint bp = m_session.addressToBP[addr];
- if (bp == 0) {
- logMessage(_("NO RECORDED BP AT 0x%1, %2")
- .arg(addr, 0, 16).arg(len), LogError);
- sendGdbServerMessage("E00");
- } else {
- m_session.addressToBP.remove(addr);
- QByteArray ba;
- appendInt(&ba, bp);
- sendTrkMessage(0x1C, TrkCB(handleClearBreakpoint), ba, addr);
- }
- }
-
- else if (cmd.startsWith("qPart:") || cmd.startsWith("qXfer:")) {
- QByteArray data = cmd.mid(1 + cmd.indexOf(':'));
- // "qPart:auxv:read::0,147": Read OS auxiliary data (see info aux)
- bool handled = false;
- if (data.startsWith("auxv:read::")) {
- const int offsetPos = data.lastIndexOf(':') + 1;
- const int commaPos = data.lastIndexOf(',');
- if (commaPos != -1) {
- bool ok1 = false, ok2 = false;
- const int offset = data.mid(offsetPos, commaPos - offsetPos)
- .toUInt(&ok1, 16);
- const int length = data.mid(commaPos + 1).toUInt(&ok2, 16);
- if (ok1 && ok2) {
- const QString msg = _("Read of OS auxiliary "
- "vector (%1, %2) not implemented.").arg(offset).arg(length);
- logMessage(msgGdbPacket(msg), LogWarning);
- sendGdbServerMessage("E20", msg.toLatin1());
- handled = true;
- }
- }
- } // auxv read
-
- if (!handled) {
- const QString msg = QLatin1String("FIXME unknown 'XFER'-request: ")
- + QString::fromAscii(cmd);
- logMessage(msgGdbPacket(msg), LogWarning);
- sendGdbServerMessage("E20", msg.toLatin1());
- }
- } // qPart/qXfer
-
- else if (cmd.startsWith('X')) {
- logMessage(msgGdbPacket(QLatin1String("Write memory")));
- // X addr,length
- sendGdbServerAck();
- const QPair<quint64, unsigned> addrLength = parseGdbReadMemoryRequest(cmd);
- int pos = cmd.indexOf(':');
- m_snapshot.resetMemory();
- writeMemory(addrLength.first, cmd.mid(pos + 1, addrLength.second));
- }
-
- else {
- logMessage(msgGdbPacket(QLatin1String("FIXME unknown: ")
- + QString::fromAscii(cmd)), LogWarning);
- }
-}
-
-void TrkGdbAdapter::gdbSetCurrentThread(const QByteArray &cmd, const char *why)
-{
- // Thread ID from Hg/Hc commands: '-1': All, '0': arbitrary, else hex thread id.
- const QByteArray id = cmd.mid(2);
- const int threadId = id == "-1" ? -1 : id.toInt(0, 16);
- const QByteArray message = QByteArray(why) + QByteArray::number(threadId);
- logMessage(msgGdbPacket(QString::fromLatin1(message)));
- // Set thread for subsequent operations (`m', `M', `g', `G', et.al.).
- // for 'other operations. 0 - any thread
- //$Hg0#df
- m_session.tid = threadId <= 0 ? m_session.mainTid : uint(threadId);
- sendGdbServerMessage("OK", message);
-}
-
-void TrkGdbAdapter::trkKill()
-{
- // Kill inferior process
- logMessage(msgGdbPacket(QLatin1String("kill")));
- sendTrkMessage(0x41, TrkCB(handleDeleteProcess),
- trkDeleteProcessMessage(), "Delete process");
-}
-
-void TrkGdbAdapter::trkContinueAll(const char *why)
-{
- if (why)
- logMessage(QString::fromLatin1("Continuing %1 threads (%2)").
- arg(m_snapshot.threadInfo.size()).arg(QString::fromLatin1(why)));
-
- // Starting from the last one, continue all threads.
- QTC_ASSERT(!m_snapshot.threadInfo.isEmpty(), return; );
- trkContinueNext(m_snapshot.threadInfo.size() - 1);
-}
-
-void TrkGdbAdapter::trkContinueNext(int threadIndex)
-{
- const uint threadId = m_snapshot.threadInfo.at(threadIndex).id;
- logMessage(QString::fromLatin1("Continuing thread 0x%1 of %2").
- arg(threadId,0, 16).arg(m_snapshot.threadInfo.size()));
- sendTrkMessage(0x18, TrkCallback(this, &TrkGdbAdapter::handleTrkContinueNext),
- trkContinueMessage(threadId), QVariant(threadIndex));
-}
-
-void TrkGdbAdapter::handleTrkContinueNext(const TrkResult &result)
-{
- const int index = result.cookie.toInt();
- if (result.errorCode()) {
- logMessage("Error continuing thread: " + result.errorString(), LogError);
- return;
- }
- // Remove the thread (unless main) if it is continued since we
- // do not get thread creation/deletion events
- QTC_ASSERT(index < m_snapshot.threadInfo.size(), return; );
- if (m_snapshot.threadInfo.at(index).id != m_session.mainTid)
- m_snapshot.threadInfo.remove(index);
- if (index > 0 && m_running) // Stopped in-between
- trkContinueNext(index - 1);
-}
-
-void TrkGdbAdapter::sendTrkMessage(trk::byte code, TrkCallback callback,
- const QByteArray &data, const QVariant &cookie)
-{
- if (m_verbose >= 2)
- logMessage("trk: -> " + QByteArray::number(code, 16) + " "
- + stringFromArray(data));
- m_trkDevice->sendTrkMessage(code, callback, data, cookie);
-}
-
-void TrkGdbAdapter::sendTrkAck(trk::byte token)
-{
- //logMessage(QString("SENDING ACKNOWLEDGEMENT FOR TOKEN %1").arg(int(token)));
- m_trkDevice->sendTrkAck(token);
-}
-
-void TrkGdbAdapter::handleTrkError(const QString &msg)
-{
- logMessage("## TRK ERROR: " + msg, LogError);
- m_engine->handleAdapterCrashed("TRK problem encountered:\n" + msg);
-}
-
-void TrkGdbAdapter::handleTrkResult(const TrkResult &result)
-{
- if (m_verbose >= 2)
- logMessage("trk: <- " + result.toString());
- if (result.isDebugOutput) {
- // It looks like those messages _must not_ be acknowledged.
- // If we do so, TRK will complain about wrong sequencing.
- //sendTrkAck(result.token);
- logMessage(QString::fromAscii(result.data), AppOutput);
- sendGdbServerMessage('O' + result.data.toHex());
- return;
- }
- //logMessage("READ TRK " + result.toString());
- QByteArray prefix = "READ BUF: ";
- QByteArray str = result.toString().toUtf8();
- switch (result.code) {
- case 0x80: // ACK
- break;
- case 0xff: { // NAK. This mostly means transmission error, not command failed.
- QString logMsg;
- QTextStream(&logMsg) << prefix << "NAK: for token=" << result.token
- << " ERROR: " << errorMessage(result.data.at(0)) << ' ' << str;
- logMessage(logMsg, LogError);
- break;
- }
- case TrkNotifyStopped: { // 0x90 Notified Stopped
- // 90 01 78 6a 40 40 00 00 07 23 00 00 07 24 00 00
- showMessage(_("RESET SNAPSHOT (NOTIFY STOPPED)"));
- MEMORY_DEBUG("WE STOPPED");
- m_snapshot.reset();
- MEMORY_DEBUG(" AFTER CLEANING: " << m_snapshot.memory.size() << " BLOCKS LEFT");
- QString reason;
- uint addr;
- uint pid;
- uint tid;
- trk::Launcher::parseNotifyStopped(result.data, &pid, &tid, &addr, &reason);
- const QString msg = trk::Launcher::msgStopped(pid, tid, addr, reason);
- // Unknown thread: Add.
- m_session.tid = tid;
- if (m_snapshot.indexOfThread(tid) == -1)
- m_snapshot.addThread(tid);
- m_snapshot.setThreadState(tid, reason);
-
- logMessage(prefix + msg);
- showMessage(msg, LogMisc);
- sendTrkAck(result.token);
- if (addr) {
- // Todo: Do not send off GdbMessages if a synced gdb
- // query is pending, queue instead
- if (m_running) {
- m_running = false;
- }
- } else {
- logMessage(QLatin1String("Ignoring stop at 0"));
- }
-
-# if 1
- // We almost always need register values, so get them
- // now before informing gdb about the stop.s
- const int signalNumber = reason.contains(QLatin1String("exception"), Qt::CaseInsensitive)
- || reason.contains(QLatin1String("panic"), Qt::CaseInsensitive) ?
- gdbServerSignalSegfault : gdbServerSignalTrap;
- sendTrkMessage(0x12,
- TrkCB(handleAndReportReadRegistersAfterStop),
- Launcher::readRegistersMessage(m_session.pid, m_session.tid), signalNumber);
-# else
- // As a source-line step typically consists of
- // several instruction steps, better avoid the multiple
- // roundtrips through TRK in favour of an additional
- // roundtrip through gdb. But gdb will ask for all registers.
-# if 1
- sendGdbServerMessage("S05", "Target stopped");
-# else
- QByteArray ba = "T05";
- appendRegister(&ba, RegisterPSGdb, addr);
- sendGdbServerMessage(ba, "Registers");
-# endif
-# endif
- break;
- }
- case TrkNotifyException: { // 0x91 Notify Exception (obsolete)
- showMessage(_("RESET SNAPSHOT (NOTIFY EXCEPTION)"));
- m_snapshot.reset();
- logMessage(prefix + _("NOTE: EXCEPTION ") + str, AppError);
- sendTrkAck(result.token);
- break;
- }
- case 0x92: { //
- showMessage(_("RESET SNAPSHOT (NOTIFY INTERNAL ERROR)"));
- m_snapshot.reset();
- logMessage(prefix + _("NOTE: INTERNAL ERROR: ") + str, LogError);
- sendTrkAck(result.token);
- break;
- }
-
- // target->host OS notification
- case 0xa0: { // Notify Created
- // Sending this ACK does not seem to make a difference. Why?
- //sendTrkAck(result.token);
- m_snapshot.resetMemory();
- const char *data = result.data.data();
- const trk::byte error = result.data.at(0);
- // type: 1 byte; for dll item, this value is 2.
- const trk::byte type = result.data.at(1);
- const uint tid = extractInt(data + 6);
- const Library lib = Library(result);
- m_session.libraries.push_back(lib);
- m_session.modules += QString::fromAscii(lib.name);
- QString logMsg;
- QTextStream str(&logMsg);
- str << prefix << " NOTE: LIBRARY LOAD: token=" << result.token;
- if (error)
- str << " ERROR: " << int(error);
- str << " TYPE: " << int(type) << " PID: " << lib.pid << " TID: " << tid;
- str << " CODE: " << hexxNumber(lib.codeseg);
- str << " DATA: " << hexxNumber(lib.dataseg);
- str << " NAME: '" << lib.name << '\'';
- if (tid && tid != unsigned(-1) && m_snapshot.indexOfThread(tid) == -1)
- m_snapshot.addThread(tid);
- logMessage(logMsg);
- // Load local symbol file into gdb provided there is one
- if (lib.codeseg) {
- const QString localSymFileName = Symbian::localSymFileForLibrary(lib.name, m_symbolFileFolder);
- if (!localSymFileName.isEmpty()) {
- showMessage(Symbian::msgLoadLocalSymFile(localSymFileName, lib.name, lib.codeseg), LogMisc);
- m_engine->postCommand(Symbian::symFileLoadCommand(localSymFileName, lib.codeseg, lib.dataseg));
- } // has local sym
- } // code seg
-
- // This lets gdb trigger a register update etc.
- // With CS gdb 6.4 we get a non-standard $qfDllInfo#7f+ request
- // afterwards, so don't use it for now.
- //sendGdbServerMessage("T05library:;");
-/*
- // Causes too much "stopped" (by SIGTRAP) messages that need
- // to be answered by "continue". Auto-continuing each SIGTRAP
- // is not possible as this is also the real message for a user
- // initiated interrupt.
- sendGdbServerMessage("T05load:Name=" + lib.name.toHex()
- + ",TextSeg=" + hexNumber(lib.codeseg)
- + ",DataSeg=" + hexNumber(lib.dataseg) + ';');
-*/
-
- // After 'continue' the very first time after starting debugging
- // a process some library load events are generated, these are
- // actually static dependencies for the process. For these libraries,
- // the thread id is -1 which means the debugger doesn't have
- // to continue. The debugger can safely assume that the
- // thread resumption will be handled by the agent itself.
- if (tid != unsigned(-1))
- sendTrkMessage(0x18, TrkCallback(), trkContinueMessage(m_session.mainTid), "CONTINUE");
- break;
- }
- case 0xa1: { // NotifyDeleted
- const ushort itemType = extractByte(result.data.data() + 1);
- const ushort len = result.data.size() > 12
- ? extractShort(result.data.data() + 10) : ushort(0);
- const QString name = len
- ? QString::fromAscii(result.data.mid(12, len)) : QString();
- if (!name.isEmpty())
- m_session.modules.removeAll(name);
- logMessage(_("%1 %2 UNLOAD: %3")
- .arg(QString::fromAscii(prefix))
- .arg(itemType ? QLatin1String("LIB") : QLatin1String("PROCESS"))
- .arg(name));
- sendTrkAck(result.token);
- if (itemType == 0) {
- sendGdbServerMessage("W00", "Process exited");
- //sendTrkMessage(0x02, TrkCB(handleDisconnect));
- }
- break;
- }
- case 0xa2: { // NotifyProcessorStarted
- logMessage(prefix + _("NOTE: PROCESSOR STARTED: ") + str);
- sendTrkAck(result.token);
- break;
- }
- case 0xa6: { // NotifyProcessorStandby
- logMessage(prefix + _("NOTE: PROCESSOR STANDBY: ") + str);
- sendTrkAck(result.token);
- break;
- }
- case 0xa7: { // NotifyProcessorReset
- logMessage(prefix + _("NOTE: PROCESSOR RESET: ") + str);
- sendTrkAck(result.token);
- break;
- }
- default: {
- logMessage(prefix + _("INVALID: ") + str, LogError);
- break;
- }
- }
-}
-
-void TrkGdbAdapter::handleCpuType(const TrkResult &result)
-{
- //---TRK------------------------------------------------------
- // Command: 0x80 Acknowledge
- // Error: 0x00
- // [80 03 00 04 00 00 04 00 00 00]
- if (result.data.size() < 7) {
- logMessage(_("ERROR: CPUTYPE RESULT ") + result.errorString()
- + _(" NOT PARSABLE"), LogError);
- return;
- }
- m_session.cpuMajor = result.data[1];
- m_session.cpuMinor = result.data[2];
- m_session.bigEndian = result.data[3];
- m_session.defaultTypeSize = result.data[4];
- m_session.fpTypeSize = result.data[5];
- m_session.extended1TypeSize = result.data[6];
- //m_session.extended2TypeSize = result.data[6];
- QString logMsg;
- QTextStream(&logMsg) << "HANDLE CPU TYPE: CPU=" << m_session.cpuMajor << '.'
- << m_session.cpuMinor << " bigEndian=" << m_session.bigEndian
- << " defaultTypeSize=" << m_session.defaultTypeSize
- << " fpTypeSize=" << m_session.fpTypeSize
- << " extended1TypeSize=" << m_session.extended1TypeSize;
- logMessage(logMsg);
-}
-
-void TrkGdbAdapter::handleDeleteProcess(const TrkResult &result)
-{
- Q_UNUSED(result);
- logMessage("Inferior process killed");
- //sendTrkMessage(0x01, TrkCB(handleDeleteProcess2)); // Ping
- sendTrkMessage(0x02, TrkCB(handleDeleteProcess2)); // Disconnect
-}
-
-void TrkGdbAdapter::handleDeleteProcess2(const TrkResult &result)
-{
- Q_UNUSED(result);
- QString msg = QString::fromLatin1("App TRK disconnected");
-
- const bool emergencyShutdown = m_gdbProc.state() != QProcess::Running;
- if (emergencyShutdown)
- msg += QString::fromLatin1(" (emergency shutdown");
- logMessage(msg);
- if (emergencyShutdown) {
- cleanup();
- m_engine->notifyAdapterShutdownOk();
- } else {
- sendGdbServerAck();
- sendGdbServerMessage("", "process killed");
- }
-}
-
-void TrkGdbAdapter::handleReadRegisters(const TrkResult &result)
-{
- logMessage(" REGISTER RESULT: " + result.toString());
- // [80 0B 00 00 00 00 00 C9 24 FF BC 00 00 00 00 00
- // 60 00 00 00 00 00 00 78 67 79 70 00 00 00 00 00...]
- if (result.errorCode()) {
- logMessage("ERROR: " + result.errorString(), LogError);
- return;
- }
- const char *data = result.data.data() + 1; // Skip ok byte
- uint *registers = m_snapshot.registers(m_session.tid);
- QTC_ASSERT(registers, return;)
- for (int i = 0; i < RegisterCount; ++i)
- registers[i] = extractInt(data + 4 * i);
- m_snapshot.setRegistersValid(m_session.tid, true);
-}
-
-void TrkGdbAdapter::handleWriteRegister(const TrkResult &result)
-{
- logMessage(" RESULT: " + result.toString() + result.cookie.toString());
- if (result.errorCode()) {
- logMessage("ERROR: " + result.errorString(), LogError);
- sendGdbServerMessage("E01");
- return;
- }
- sendGdbServerMessage("OK");
-}
-
-void TrkGdbAdapter::reportRegisters()
-{
- const int threadIndex = m_snapshot.indexOfThread(m_session.tid);
- QTC_ASSERT(threadIndex != -1, return);
- const Symbian::Thread &thread = m_snapshot.threadInfo.at(threadIndex);
- sendGdbServerMessage(thread.gdbReportRegisters(), thread.gdbRegisterLogMessage(m_verbose));
-}
-
-void TrkGdbAdapter::handleAndReportReadRegisters(const TrkResult &result)
-{
- handleReadRegisters(result);
- reportRegisters();
-}
-
-void TrkGdbAdapter::handleAndReportReadRegister(const TrkResult &result)
-{
- handleReadRegisters(result);
- const uint registerNumber = result.cookie.toUInt();
- const int threadIndex = m_snapshot.indexOfThread(m_session.tid);
- QTC_ASSERT(threadIndex != -1, return);
- const Symbian::Thread &thread = m_snapshot.threadInfo.at(threadIndex);
- sendGdbServerMessage(thread.gdbReportSingleRegister(registerNumber), thread.gdbSingleRegisterLogMessage(registerNumber));
-}
-
-void TrkGdbAdapter::handleAndReportReadRegistersAfterStop(const TrkResult &result)
-{
- handleReadRegisters(result);
- const bool reportThread = m_session.tid != m_session.mainTid;
- const int signalNumber = result.cookie.isValid() ? result.cookie.toInt() : int(gdbServerSignalTrap);
- sendGdbServerMessage(m_snapshot.gdbStopMessage(m_session.tid, signalNumber, reportThread),
- "Stopped with registers in thread " + QByteArray::number(m_session.tid, 16));
-}
-
-static QString msgMemoryReadError(int code, uint addr, uint len = 0)
-{
- const QString lenS = len ? QString::number(len) : QLatin1String("<unknown>");
- return _("Memory read error %1 at: 0x%2 %3")
- .arg(code).arg(addr, 0, 16).arg(lenS);
-}
-
-void TrkGdbAdapter::handleReadMemoryBuffered(const TrkResult &result)
-{
- if (extractShort(result.data.data() + 1) + 3 != result.data.size())
- logMessage(_("\n BAD MEMORY RESULT: ") + result.data.toHex() + '\n', LogError);
- const MemoryRange range = result.cookie.value<MemoryRange>();
- MEMORY_DEBUG("HANDLE READ MEMORY ***BUFFERED*** FOR " << range);
- if (const int errorCode = result.errorCode()) {
- logMessage(_("TEMPORARY: ") + msgMemoryReadError(errorCode, range.from));
- logMessage(_("RETRYING UNBUFFERED"));
- // FIXME: This does not handle large requests properly.
- sendTrkMessage(0x10, TrkCB(handleReadMemoryUnbuffered),
- trkReadMemoryMessage(range), QVariant::fromValue(range));
- return;
- }
- const QByteArray ba = result.data.mid(3);
- MEMORY_DEBUG("INSERT KNOWN MEMORY RANGE: " << range << m_snapshot.memory.size() << " BLOCKS");
- m_snapshot.insertMemory(range, ba);
- tryAnswerGdbMemoryRequest(true);
-}
-
-void TrkGdbAdapter::handleReadMemoryUnbuffered(const TrkResult &result)
-{
- if (extractShort(result.data.data() + 1) + 3 != result.data.size())
- logMessage(_("\n BAD MEMORY RESULT: ") + result.data.toHex() + '\n', LogError);
- const MemoryRange range = result.cookie.value<MemoryRange>();
- MEMORY_DEBUG("HANDLE READ MEMORY UNBUFFERED FOR " << range);
- if (const int errorCode = result.errorCode()) {
- logMessage(_("TEMPORARY: ") + msgMemoryReadError(errorCode, range.from));
- logMessage(_("RETRYING UNBUFFERED"));
-#if 1
- const QByteArray ba = "E20";
- sendGdbServerMessage(ba, msgMemoryReadError(32, range.from).toLatin1());
-#else
- // emit bogus data to make Python happy
- MemoryRange wanted = m_snapshot.wantedMemory;
- qDebug() << "SENDING BOGUS DATA FOR " << wanted;
- m_snapshot.insertMemory(wanted, QByteArray(wanted.size(), 0xa5));
- tryAnswerGdbMemoryRequest(false);
-#endif
- return;
- }
- const QByteArray ba = result.data.mid(3);
- m_snapshot.insertMemory(range, ba);
- MEMORY_DEBUG("INSERT KNOWN MEMORY RANGE: " << range << m_snapshot.memory.size() << " BLOCKS");
- tryAnswerGdbMemoryRequest(false);
-}
-
-void TrkGdbAdapter::tryAnswerGdbMemoryRequest(bool buffered)
-{
- //logMessage("TRYING TO ANSWER MEMORY REQUEST ");
-
- MemoryRange wanted = m_snapshot.wantedMemory;
- MemoryRange needed = m_snapshot.wantedMemory;
- MEMORY_DEBUG("WANTED: " << wanted);
- Snapshot::Memory::const_iterator it = m_snapshot.memory.begin();
- Snapshot::Memory::const_iterator et = m_snapshot.memory.end();
- for ( ; it != et; ++it) {
- MEMORY_DEBUG(" NEEDED STEP: " << needed);
- needed -= it.key();
- }
- MEMORY_DEBUG("NEEDED FINAL: " << needed);
-
- if (needed.to == 0) {
- // FIXME: need to combine chunks first.
-
- // All fine. Send package to gdb.
- it = m_snapshot.memory.begin();
- et = m_snapshot.memory.end();
- for ( ; it != et; ++it) {
- if (it.key().from <= wanted.from && wanted.to <= it.key().to) {
- int offset = wanted.from - it.key().from;
- int len = wanted.to - wanted.from;
- QByteArray ba = it.value().mid(offset, len);
- sendGdbServerMessage(ba.toHex(),
- m_snapshot.memoryReadLogMessage(wanted.from, m_session.tid, m_verbose, ba));
- return;
- }
- }
- // Happens when chunks are not combined
- QTC_ASSERT(false, /**/);
- showMessage("CHUNKS NOT COMBINED");
-# ifdef MEMORY_DEBUG
- qDebug() << "CHUNKS NOT COMBINED";
- it = m_snapshot.memory.begin();
- et = m_snapshot.memory.end();
- for ( ; it != et; ++it)
- qDebug() << hexNumber(it.key().from) << hexNumber(it.key().to);
- qDebug() << "WANTED" << wanted.from << wanted.to;
-# endif
- sendGdbServerMessage("E22", "");
- return;
- }
-
- MEMORY_DEBUG("NEEDED AND UNSATISFIED: " << needed);
- if (buffered) {
- uint blockaddr = (needed.from / MemoryChunkSize) * MemoryChunkSize;
- logMessage(_("Requesting buffered memory %1 bytes from 0x%2")
- .arg(MemoryChunkSize).arg(blockaddr, 0, 16));
- MemoryRange range(blockaddr, blockaddr + MemoryChunkSize);
- MEMORY_DEBUG(" FETCH BUFFERED MEMORY : " << range);
- sendTrkMessage(0x10, TrkCB(handleReadMemoryBuffered),
- trkReadMemoryMessage(range),
- QVariant::fromValue(range));
- } else { // Unbuffered, direct requests
- int len = needed.to - needed.from;
- logMessage(_("Requesting unbuffered memory %1 bytes from 0x%2")
- .arg(len).arg(needed.from, 0, 16));
- MEMORY_DEBUG(" FETCH UNBUFFERED MEMORY : " << needed);
- sendTrkMessage(0x10, TrkCB(handleReadMemoryUnbuffered),
- trkReadMemoryMessage(needed),
- QVariant::fromValue(needed));
- }
-}
-
-/*
-void TrkGdbAdapter::reportReadMemoryBuffered(const TrkResult &result)
-{
- const MemoryRange range = result.cookie.value<MemoryRange>();
- // Gdb accepts less memory according to documentation.
- // Send E on complete failure.
- QByteArray ba;
- uint blockaddr = (range.from / MemoryChunkSize) * MemoryChunkSize;
- for (; blockaddr < addr + len; blockaddr += MemoryChunkSize) {
- const Snapshot::Memory::const_iterator it = m_snapshot.memory.constFind(blockaddr);
- if (it == m_snapshot.memory.constEnd())
- break;
- ba.append(it.value());
- }
- const int previousChunkOverlap = addr % MemoryChunkSize;
- if (previousChunkOverlap != 0 && ba.size() > previousChunkOverlap)
- ba.remove(0, previousChunkOverlap);
- if (ba.size() > int(len))
- ba.truncate(len);
-
- if (ba.isEmpty()) {
- ba = "E20";
- sendGdbServerMessage(ba, msgMemoryReadError(32, addr, len).toLatin1());
- } else {
- sendGdbServerMessage(ba.toHex(), memoryReadLogMessage(addr, len, ba));
- }
-}
-*/
-
-void TrkGdbAdapter::handleStep(const TrkResult &result)
-{
- if (result.errorCode()) {
- logMessage("ERROR: " + result.errorString() + " in handleStep", LogError);
-
- // Try fallback with Continue.
- showMessage("FALLBACK TO 'CONTINUE'");
- trkContinueAll("Step failed");
- //sendGdbServerMessage("S05", "Stepping finished");
-
- // Doing nothing as below does not work as gdb seems to insist on
- // making some progress through a 'step'.
- //sendTrkMessage(0x12,
- // TrkCB(handleAndReportReadRegistersAfterStop),
- // Launcher::readRegistersMessage(m_session.pid, m_session.tid));
- return;
- }
- // The gdb server response is triggered later by the Stop Reply packet.
- logMessage("STEP FINISHED " + currentTime());
-}
-
-void TrkGdbAdapter::handleAndReportSetBreakpoint(const TrkResult &result)
-{
- //---TRK------------------------------------------------------
- // Command: 0x80 Acknowledge
- // Error: 0x00
- // [80 09 00 00 00 00 0A]
- if (result.errorCode()) {
- logMessage("ERROR WHEN SETTING BREAKPOINT: " + result.errorString(), LogError);
- sendGdbServerMessage("E21");
- return;
- }
- uint bpnr = extractInt(result.data.data() + 1);
- uint addr = result.cookie.toUInt();
- m_session.addressToBP[addr] = bpnr;
- logMessage("SET BREAKPOINT " + hexxNumber(bpnr) + ' '
- + stringFromArray(result.data.data()));
- sendGdbServerMessage("OK");
- //sendGdbServerMessage("OK");
-}
-
-void TrkGdbAdapter::handleClearBreakpoint(const TrkResult &result)
-{
- logMessage("CLEAR BREAKPOINT ");
- if (result.errorCode()) {
- logMessage("ERROR: " + result.errorString(), LogError);
- //return;
- }
- sendGdbServerMessage("OK");
-}
-
-void TrkGdbAdapter::handleSupportMask(const TrkResult &result)
-{
- const char *data = result.data.data();
- QByteArray str;
- for (int i = 0; i < 32; ++i) {
- //str.append(" [" + formatByte(data[i]) + "]: ");
- for (int j = 0; j < 8; ++j)
- if (data[i] & (1 << j))
- str.append(QByteArray::number(i * 8 + j, 16));
- }
- logMessage(_("SUPPORTED: ") + str);
- }
-
-void TrkGdbAdapter::handleTrkVersionsStartGdb(const TrkResult &result)
-{
- QString logMsg;
- QTextStream str(&logMsg);
- str << "Versions: ";
- if (result.data.size() >= 5) {
- str << "App TRK version " << int(result.data.at(1)) << '.'
- << int(result.data.at(2))
- << ", TRK protocol version " << int(result.data.at(3))
- << '.' << int(result.data.at(4));
- }
- logMessage(logMsg);
- // As we are called from the TrkDevice handler, do not lock up when shutting
- // down the device in case of gdb launch errors.
- QTimer::singleShot(0, this, SLOT(slotStartGdb()));
-}
-
-void TrkGdbAdapter::slotStartGdb()
-{
- QStringList gdbArgs;
- gdbArgs.append(QLatin1String("--nx")); // Do not read .gdbinit file
- if (!m_engine->startGdb(gdbArgs)) {
- cleanup();
- return;
- }
- m_engine->handleAdapterStarted();
-}
-
-void TrkGdbAdapter::handleDisconnect(const TrkResult & /*result*/)
-{
- logMessage(QLatin1String("App TRK disconnected"));
-}
-
-void TrkGdbAdapter::readMemory(uint addr, uint len, bool buffered)
-{
- Q_ASSERT(len < (2 << 16));
-
- // We try to get medium-sized chunks of data from the device
- if (m_verbose > 2)
- logMessage(_("readMemory %1 bytes from 0x%2 blocksize=%3")
- .arg(len).arg(addr, 0, 16).arg(MemoryChunkSize));
-
- m_snapshot.wantedMemory = MemoryRange(addr, addr + len);
- tryAnswerGdbMemoryRequest(buffered);
-}
-
-void TrkGdbAdapter::writeMemory(uint addr, const QByteArray &data)
-{
- Q_ASSERT(data.size() < (2 << 16));
- if (m_verbose > 2) {
- logMessage(_("writeMemory %1 bytes from 0x%2 blocksize=%3 data=%4")
- .arg(data.size()).arg(addr, 0, 16).arg(MemoryChunkSize).arg(QString::fromLatin1(data.toHex())));
- }
-
- sendTrkMessage(0x11, TrkCB(handleWriteMemory),
- trkWriteMemoryMessage(addr, data));
-}
-
-void TrkGdbAdapter::handleWriteMemory(const TrkResult &result)
-{
- logMessage(" RESULT: " + result.toString() + result.cookie.toString());
- if (result.errorCode()) {
- logMessage("ERROR: " + result.errorString(), LogError);
- sendGdbServerMessage("E01");
- return;
- }
- sendGdbServerMessage("OK");
-}
-
-void TrkGdbAdapter::interruptInferior()
-{
- sendTrkMessage(0x1a, TrkCallback(), trkInterruptMessage(), "Interrupting...");
-}
-
-void TrkGdbAdapter::trkDeviceRemoved(const SymbianUtils::SymbianDevice &dev)
-{
- if (state() != DebuggerNotReady && !m_trkDevice.isNull() && m_trkDevice->port() == dev.portName()) {
- const QString message = QString::fromLatin1("Device '%1' has been disconnected.").arg(dev.friendlyName());
- logMessage(message);
- m_engine->handleAdapterCrashed(message);
- }
-}
-
-bool TrkGdbAdapter::initializeDevice(const QString &remoteChannel, QString *errorMessage)
-{
- if (remoteChannel.isEmpty()) {
- *errorMessage = tr("Port specification missing.");
- return false;
- }
- // Run config: Acquire from device manager.
- m_trkDevice = SymbianUtils::SymbianDeviceManager::instance()
- ->acquireDevice(remoteChannel);
- if (m_trkDevice.isNull()) {
- *errorMessage = tr("Unable to acquire a device on '%1'. It appears to be in use.").arg(remoteChannel);
- return false;
- }
- connect(SymbianUtils::SymbianDeviceManager::instance(), SIGNAL(deviceRemoved(const SymbianUtils::SymbianDevice)),
- this, SLOT(trkDeviceRemoved(SymbianUtils::SymbianDevice)));
- connect(m_trkDevice.data(), SIGNAL(messageReceived(trk::TrkResult)),
- this, SLOT(handleTrkResult(trk::TrkResult)));
- connect(m_trkDevice.data(), SIGNAL(error(QString)),
- this, SLOT(handleTrkError(QString)));
- connect(m_trkDevice.data(), SIGNAL(logMessage(QString)),
- this, SLOT(trkLogMessage(QString)));
- m_trkDevice->setVerbose(m_verbose);
-
- // Prompt the user to start communication
- const trk::PromptStartCommunicationResult src =
- S60DebuggerBluetoothStarter::startCommunication(m_trkDevice,
- 0, errorMessage);
- switch (src) {
- case trk::PromptStartCommunicationConnected:
- break;
- case trk::PromptStartCommunicationCanceled:
- errorMessage->clear();
- return false;
- case trk::PromptStartCommunicationError:
- return false;
- }
- return true;
-}
-
-void TrkGdbAdapter::startAdapter()
-{
- m_snapshot.fullReset();
-
- // Retrieve parameters
- const DebuggerStartParameters &parameters = startParameters();
- m_remoteExecutable = parameters.executable;
- m_remoteArguments = parameters.processArgs;
- m_symbolFile = parameters.symbolFileName;
- if (!m_symbolFile.isEmpty())
- m_symbolFileFolder = QFileInfo(m_symbolFile).absolutePath();
- QString remoteChannel = parameters.remoteChannel;
- // FIXME: testing hack, remove!
- if (m_remoteArguments.startsWith(__("@sym@ "))) {
- QStringList pa = Utils::QtcProcess::splitArgs(m_remoteArguments);
- remoteChannel = pa.at(1);
- m_remoteExecutable = pa.at(2);
- m_symbolFile = pa.at(3);
- m_remoteArguments.clear();
- }
- // Unixish gdbs accept only forward slashes
- m_symbolFile.replace(QLatin1Char('\\'), QLatin1Char('/'));
- // Start
- QTC_ASSERT(state() == EngineSetupRequested, qDebug() << state());
- showMessage(_("TRYING TO START ADAPTER"));
- logMessage(QLatin1String("### Starting TrkGdbAdapter"));
-
- // Prompt the user to start communication
- QString message;
- if (!initializeDevice(remoteChannel, &message)) {
- if (message.isEmpty()) {
- m_engine->handleAdapterStartFailed(QString(), QString());
- } else {
- logMessage(message, LogError);
- m_engine->handleAdapterStartFailed(message, QString());
- }
- return;
- }
-
- QTC_ASSERT(m_gdbServer == 0, delete m_gdbServer);
- QTC_ASSERT(m_gdbConnection == 0, m_gdbConnection = 0);
- m_gdbServer = new QTcpServer(this);
-
- if (!m_gdbServer->listen(QHostAddress(gdbServerIP()), gdbServerPort())) {
- QString msg = QString("Unable to start the gdb server at %1: %2.")
- .arg(m_gdbServerName).arg(m_gdbServer->errorString());
- logMessage(msg, LogError);
- m_engine->handleAdapterStartFailed(msg, QString());
- return;
- }
-
- logMessage(QString("Gdb server running on %1.\nLittle endian assumed.")
- .arg(m_gdbServerName));
-
- connect(m_gdbServer, SIGNAL(newConnection()),
- this, SLOT(handleGdbConnection()));
-
- m_trkDevice->sendTrkInitialPing();
- sendTrkMessage(0x02); // Disconnect, as trk might be still connected
- sendTrkMessage(0x01); // Connect
- sendTrkMessage(0x05, TrkCB(handleSupportMask));
- sendTrkMessage(0x06, TrkCB(handleCpuType));
- sendTrkMessage(0x04, TrkCB(handleTrkVersionsStartGdb)); // Versions
-}
-
-void TrkGdbAdapter::setupInferior()
-{
- QTC_ASSERT(state() == InferiorSetupRequested, qDebug() << state());
- sendTrkMessage(0x40, TrkCB(handleCreateProcess),
- trk::Launcher::startProcessMessage(m_remoteExecutable, m_remoteArguments));
-}
-
-void TrkGdbAdapter::handleCreateProcess(const TrkResult &result)
-{
- QTC_ASSERT(state() == InferiorSetupRequested, 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]
- if (result.errorCode()) {
- logMessage("ERROR: " + result.errorString(), LogError);
- QString msg = _("Cannot start executable \"%1\" on the device:\n%2")
- .arg(m_remoteExecutable).arg(result.errorString());
- // Delay cleanup as not to close a trk device from its read handler,
- // which blocks.
- emitDelayedInferiorSetupFailed(msg);
- return;
- }
- showMessage(_("RESET SNAPSHOT (NOTIFY CREATED)"));
- m_snapshot.fullReset();
- const char *data = result.data.data();
- m_session.pid = extractInt(data + 1);
- m_session.mainTid = m_session.tid = extractInt(data + 5);
- m_session.codeseg = extractInt(data + 9);
- m_session.dataseg = extractInt(data + 13);
- m_snapshot.addThread(m_session.mainTid);
- const QString startMsg =
- tr("Process started, PID: 0x%1, thread id: 0x%2, "
- "code segment: 0x%3, data segment: 0x%4.")
- .arg(m_session.pid, 0, 16).arg(m_session.tid, 0, 16)
- .arg(m_session.codeseg, 0, 16).arg(m_session.dataseg, 0, 16);
- logMessage(startMsg, LogMisc);
- // 26.8.2010: When paging occurs in S^3, bogus starting ROM addresses
- // like 0x500000 or 0x40000 are reported. Warn about symbol resolution errors.
- // Code duplicated in CodaAdapter. @TODO: Hopefully fixed in future TRK versions.
- if ((m_session.codeseg & 0xFFFFF) == 0) {
- const QString warnMessage = tr("The reported code segment address (0x%1) might be invalid. Symbol resolution or setting breakoints may not work.").
- arg(m_session.codeseg, 0, 16);
- logMessage(warnMessage, LogError);
- }
-
- m_engine->postCommand("set gnutarget arm-none-symbianelf");
-
- const QByteArray symbolFile = m_symbolFile.toLocal8Bit();
- if (symbolFile.isEmpty()) {
- logMessage(_("WARNING: No symbol file available."), LogError);
- } else {
- // Does not seem to be necessary anymore.
- // FIXME: Startup sequence can be streamlined now as we do not
- // have to wait for the TRK startup to learn the load address.
- //m_engine->postCommand("add-symbol-file \"" + symbolFile + "\" "
- // + QByteArray::number(m_session.codeseg));
- m_engine->postCommand("symbol-file \"" + symbolFile + "\"");
- }
- foreach(const QByteArray &s, Symbian::gdbStartupSequence())
- m_engine->postCommand(s);
- //m_engine->postCommand("set remotelogfile /tmp/gdb-remotelog");
- //m_engine->postCommand("set debug remote 1"); // FIXME: Make an option.
- m_engine->postCommand("target remote " + gdbServerName().toLatin1(),
- CB(handleTargetRemote));
-}
-
-void TrkGdbAdapter::handleTargetRemote(const GdbResponse &record)
-{
- QTC_ASSERT(state() == InferiorSetupRequested, qDebug() << state());
- if (record.resultClass == GdbResultDone) {
- m_engine->handleInferiorPrepared();
- } else {
- QString msg = tr("Connecting to TRK server adapter failed:\n")
- + QString::fromLocal8Bit(record.data.findChild("msg").data());
- m_engine->notifyInferiorSetupFailed(msg);
- }
-}
-
-void TrkGdbAdapter::runEngine()
-{
- QTC_ASSERT(state() == EngineRunRequested, qDebug() << state());
- m_engine->notifyEngineRunAndInferiorStopOk();
- m_engine->continueInferiorInternal();
-}
-
-//
-// AbstractGdbAdapter interface implementation
-//
-
-void TrkGdbAdapter::write(const QByteArray &data)
-{
- // Write magic packets directly to TRK.
- if (data.startsWith("@#")) {
- QByteArray data1 = data.mid(2);
- if (data1.endsWith(char(10)))
- data1.chop(1);
- if (data1.endsWith(char(13)))
- data1.chop(1);
- if (data1.endsWith(' '))
- data1.chop(1);
- bool ok;
- uint addr = data1.toUInt(&ok, 0);
- qDebug() << "Writing: " << quoteUnprintableLatin1(data1) << addr;
- directStep(addr);
- return;
- }
- if (data.startsWith("@$")) {
- QByteArray ba = QByteArray::fromHex(data.mid(2));
- qDebug() << "Writing: " << quoteUnprintableLatin1(ba);
- if (ba.size() >= 1)
- sendTrkMessage(ba.at(0), TrkCB(handleDirectTrk), ba.mid(1));
- return;
- }
- if (data.startsWith("@@")) {
- // Read data
- sendTrkMessage(0x10, TrkCB(handleDirectWrite1),
- Launcher::readMemoryMessage(m_session.pid, m_session.tid, m_session.dataseg, 12));
- return;
- }
- m_gdbProc.write(data);
-}
-
-uint oldPC;
-QByteArray oldMem;
-uint scratch;
-
-void TrkGdbAdapter::handleDirectWrite1(const TrkResult &response)
-{
- scratch = m_session.dataseg + 512;
- logMessage("DIRECT WRITE1: " + response.toString());
- if (const int errorCode = response.errorCode()) {
- logMessage("ERROR: " + response.errorString() + "in handleDirectWrite1", LogError);
- } else {
- oldMem = response.data.mid(3);
- oldPC = m_snapshot.registerValue(m_session.tid, RegisterPC);
- logMessage(_("READ MEM: ") + oldMem.toHex());
- //qDebug("READ MEM: " + oldMem.toHex());
- QByteArray ba;
- appendByte(&ba, 0xaa);
- appendByte(&ba, 0xaa);
- appendByte(&ba, 0xaa);
- appendByte(&ba, 0xaa);
-
-#if 0
- // Arm:
- // 0: e51f4004 ldr r4, [pc, #-4] ; 4 <.text+0x4>
- appendByte(&ba, 0x04);
- appendByte(&ba, 0x50); // R5
- appendByte(&ba, 0x1f);
- appendByte(&ba, 0xe5);
-#else
- // Thumb:
- // subs r0, #16
- appendByte(&ba, 0x08);
- appendByte(&ba, 0x3b);
- // subs r0, #16
- appendByte(&ba, 0x08);
- appendByte(&ba, 0x3b);
- //
- appendByte(&ba, 0x08);
- appendByte(&ba, 0x3b);
- // subs r0, #16
- appendByte(&ba, 0x08);
- appendByte(&ba, 0x3b);
-#endif
-
- // Write data
- sendTrkMessage(0x11, TrkCB(handleDirectWrite2),
- trkWriteMemoryMessage(scratch, ba));
- }
-}
-
-void TrkGdbAdapter::handleDirectWrite2(const TrkResult &response)
-{
- logMessage("DIRECT WRITE2: " + response.toString());
- if (const int errorCode = response.errorCode()) {
- logMessage("ERROR: " + response.errorString() + "in handleDirectWrite1", LogError);
- } else {
- // Check
- sendTrkMessage(0x10, TrkCB(handleDirectWrite3),
- trk::Launcher::readMemoryMessage(m_session.pid, m_session.tid, scratch, 12));
- }
-}
-
-void TrkGdbAdapter::handleDirectWrite3(const TrkResult &response)
-{
- logMessage("DIRECT WRITE3: " + response.toString());
- if (const int errorCode = response.errorCode()) {
- logMessage("ERROR: " + response.errorString() + "in handleDirectWrite1", LogError);
- } else {
- // Set PC
- sendTrkMessage(0x13, TrkCB(handleDirectWrite4),
- trkWriteRegisterMessage(RegisterPC, scratch + 4));
- }
-}
-
-void TrkGdbAdapter::handleDirectWrite4(const TrkResult &response)
-{
- m_snapshot.setRegisterValue(m_session.tid, RegisterPC, scratch + 4);
-return;
- logMessage("DIRECT WRITE4: " + response.toString());
- if (const int errorCode = response.errorCode()) {
- logMessage("ERROR: " + response.errorString() + "in handleDirectWrite1", LogError);
- } else {
- QByteArray ba1;
- appendByte(&ba1, 0x11); // options "step over"
- appendInt(&ba1, scratch + 4);
- appendInt(&ba1, scratch + 4);
- appendInt(&ba1, m_session.pid);
- appendInt(&ba1, m_session.tid);
- sendTrkMessage(0x19, TrkCB(handleDirectWrite5), ba1);
- }
-}
-
-void TrkGdbAdapter::handleDirectWrite5(const TrkResult &response)
-{
- logMessage("DIRECT WRITE5: " + response.toString());
- if (const int errorCode = response.errorCode()) {
- logMessage("ERROR: " + response.errorString() + "in handleDirectWrite1", LogError);
- } else {
- // Restore PC
- sendTrkMessage(0x13, TrkCB(handleDirectWrite6),
- trkWriteRegisterMessage(RegisterPC, oldPC));
- }
-}
-
-void TrkGdbAdapter::handleDirectWrite6(const TrkResult &response)
-{
- logMessage("DIRECT WRITE6: " + response.toString());
- if (const int errorCode = response.errorCode()) {
- logMessage("ERROR: " + response.errorString() + "in handleDirectWrite1", LogError);
- } else {
- // Restore memory
- sendTrkMessage(0x11, TrkCB(handleDirectWrite7),
- trkWriteMemoryMessage(scratch, oldMem));
- }
-}
-
-void TrkGdbAdapter::handleDirectWrite7(const TrkResult &response)
-{
- logMessage("DIRECT WRITE7: " + response.toString());
- if (const int errorCode = response.errorCode()) {
- logMessage("ERROR: " + response.errorString() + "in handleDirectWrite1", LogError);
- } else {
- // Check
- sendTrkMessage(0x10, TrkCB(handleDirectWrite8),
- trk::Launcher::readMemoryMessage(m_session.pid, m_session.tid,
- scratch, 8));
- }
-}
-
-void TrkGdbAdapter::handleDirectWrite8(const TrkResult &response)
-{
- logMessage("DIRECT WRITE8: " + response.toString());
- if (const int errorCode = response.errorCode()) {
- logMessage("ERROR: " + response.errorString() + "in handleDirectWrite1", LogError);
- } else {
- // Re-read registers
- sendTrkMessage(0x12,
- TrkCB(handleAndReportReadRegistersAfterStop),
- Launcher::readRegistersMessage(m_session.pid, m_session.tid));
- }
-}
-
-void TrkGdbAdapter::handleDirectWrite9(const TrkResult &response)
-{
- logMessage("DIRECT WRITE9: " + response.toString());
-}
-
-void TrkGdbAdapter::handleDirectTrk(const TrkResult &result)
-{
- logMessage("HANDLE DIRECT TRK: " + stringFromArray(result.data));
-}
-
-void TrkGdbAdapter::directStep(uint addr)
-{
- // Write PC:
- qDebug() << "ADDR: " << addr;
- oldPC = m_snapshot.registerValue(m_session.tid, RegisterPC);
- m_snapshot.setRegisterValue(m_session.tid, RegisterPC, addr);
- QByteArray ba = trkWriteRegisterMessage(RegisterPC, addr);
- sendTrkMessage(0x13, TrkCB(handleDirectStep1), ba, "Write PC");
-}
-
-void TrkGdbAdapter::handleDirectStep1(const TrkResult &result)
-{
- logMessage("HANDLE DIRECT STEP1: " + stringFromArray(result.data));
- QByteArray ba;
- const uint pc = oldPC = m_snapshot.registerValue(m_session.tid, RegisterPC);
- appendByte(&ba, 0x11); // options "step over"
- appendInt(&ba, pc);
- appendInt(&ba, pc);
- appendInt(&ba, m_session.pid);
- appendInt(&ba, m_session.tid);
- sendTrkMessage(0x19, TrkCB(handleDirectStep2), ba, "Direct step");
-}
-
-void TrkGdbAdapter::handleDirectStep2(const TrkResult &result)
-{
- logMessage("HANDLE DIRECT STEP2: " + stringFromArray(result.data));
- m_snapshot.setRegisterValue(m_session.tid, RegisterPC, oldPC);
- QByteArray ba = trkWriteRegisterMessage(RegisterPC, oldPC);
- sendTrkMessage(0x13, TrkCB(handleDirectStep3), ba, "Write PC");
-}
-
-void TrkGdbAdapter::handleDirectStep3(const TrkResult &result)
-{
- logMessage("HANDLE DIRECT STEP2: " + stringFromArray(result.data));
-}
-
-void TrkGdbAdapter::cleanup()
-{
- if (!m_trkDevice.isNull()) {
- m_trkDevice->close();
- m_trkDevice->disconnect(this);
- SymbianUtils::SymbianDeviceManager::instance()->releaseDevice(m_trkDevice->port());
- m_trkDevice = TrkDevicePtr();
- }
-
- delete m_gdbServer;
- m_gdbServer = 0;
-}
-
-void TrkGdbAdapter::shutdownInferior()
-{
- m_engine->defaultInferiorShutdown("kill");
-}
-
-void TrkGdbAdapter::shutdownAdapter()
-{
- if (m_gdbProc.state() == QProcess::Running) {
- cleanup();
- m_engine->notifyAdapterShutdownOk();
- } else {
- // Something is wrong, gdb crashed. Kill debuggee (see handleDeleteProcess2)
- if (m_trkDevice->isOpen()) {
- logMessage("Emergency shutdown of TRK", LogError);
- trkKill();
- }
- }
-}
-
-void TrkGdbAdapter::trkReloadRegisters()
-{
- m_snapshot.syncRegisters(m_session.tid, m_engine->registerHandler());
-}
-
-void TrkGdbAdapter::trkReloadThreads()
-{
- m_snapshot.syncThreads(m_engine->threadsHandler());
-}
-
-} // namespace Internal
-} // namespace Debugger
diff --git a/src/plugins/debugger/gdb/trkgdbadapter.h b/src/plugins/debugger/gdb/trkgdbadapter.h
deleted file mode 100644
index c376761b8a..0000000000
--- a/src/plugins/debugger/gdb/trkgdbadapter.h
+++ /dev/null
@@ -1,242 +0,0 @@
-/**************************************************************************
-**
-** This file is part of Qt Creator
-**
-** Copyright (c) 2011 Nokia Corporation and/or its subsidiary(-ies).
-**
-** Contact: Nokia Corporation (info@qt.nokia.com)
-**
-**
-** GNU Lesser General Public License Usage
-**
-** This file may be used under the terms of the GNU Lesser General Public
-** License version 2.1 as published by the Free Software Foundation and
-** appearing in the file LICENSE.LGPL included in the packaging of this file.
-** Please review the following information to ensure the GNU Lesser General
-** Public License version 2.1 requirements will be met:
-** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** Other Usage
-**
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at info@qt.nokia.com.
-**
-**************************************************************************/
-
-#ifndef DEBUGGER_TRKGDBADAPTER_H
-#define DEBUGGER_TRKGDBADAPTER_H
-
-#include "abstractgdbadapter.h"
-#include "localgdbprocess.h"
-#include "trkutils.h"
-#include "callback.h"
-#include "symbian.h"
-
-#include <QtCore/QPointer>
-#include <QtCore/QSharedPointer>
-#include <QtCore/QStringList>
-#include <QtCore/QHash>
-
-QT_BEGIN_NAMESPACE
-class QTcpServer;
-class QTcpSocket;
-QT_END_NAMESPACE
-
-namespace trk {
-struct TrkResult;
-struct TrkMessage;
-class TrkDevice;
-}
-
-namespace SymbianUtils {
-class SymbianDevice;
-}
-
-namespace Debugger {
-namespace Internal {
-
-struct MemoryRange;
-struct GdbResult;
-
-///////////////////////////////////////////////////////////////////////
-//
-// TrkGdbAdapter
-//
-///////////////////////////////////////////////////////////////////////
-
-class TrkGdbAdapter : public AbstractGdbAdapter
-{
- Q_OBJECT
-
-public:
- typedef trk::TrkResult TrkResult;
- typedef trk::Callback<const TrkResult &> TrkCallback;
- typedef trk::Callback<const GdbResult &> GdbCallback;
-
- TrkGdbAdapter(GdbEngine *engine);
- ~TrkGdbAdapter();
- void setGdbServerName(const QString &name);
- QString gdbServerName() const { return m_gdbServerName; }
- QString gdbServerIP() const;
- uint gdbServerPort() const;
- Q_SLOT void setVerbose(const QVariant &value);
- void setVerbose(int verbose);
- void setBufferedMemoryRead(bool b) { m_bufferedMemoryRead = b; }
- trk::Session &session() { return m_session; }
- void trkReloadRegisters();
- void trkReloadThreads();
-
-signals:
- void output(const QString &msg);
-
-private:
- QString m_gdbServerName; // 127.0.0.1:(2222+uid)
-
- bool m_running;
-
-public:
- //
- // Implementation of GdbProcessBase
- //
- void start(const QString &program, const QStringList &args,
- QIODevice::OpenMode mode = QIODevice::ReadWrite);
- void write(const QByteArray &data);
- bool isTrkAdapter() const { return true; }
-
- virtual DumperHandling dumperHandling() const { return DumperNotAvailable; }
-
-private:
- void startAdapter();
- bool initializeDevice(const QString &remoteChannel, QString *errorMessage);
- void setupInferior();
- void runEngine();
- void interruptInferior();
- void shutdownInferior();
- void shutdownAdapter();
- AbstractGdbProcess *gdbProc() { return &m_gdbProc; }
-
- void cleanup();
- void emitDelayedInferiorSetupFailed(const QString &msg);
- Q_SLOT void slotEmitDelayedInferiorSetupFailed();
-
- void handleTargetRemote(const GdbResponse &response);
-
- //
- // TRK
- //
- void sendTrkMessage(trk::byte code,
- TrkCallback callback = TrkCallback(),
- const QByteArray &data = QByteArray(),
- const QVariant &cookie = QVariant());
- Q_SLOT void handleTrkResult(const trk::TrkResult &data);
- Q_SLOT void handleTrkError(const QString &msg);
- void trkContinueAll(const char *why);
- void trkKill();
- void handleTrkContinueNext(const TrkResult &result);
- void trkContinueNext(int threadIndex);
-
- // convenience messages
- void sendTrkAck(trk::byte token);
-
- void handleCpuType(const TrkResult &result);
- void handleCreateProcess(const TrkResult &result);
- void handleClearBreakpoint(const TrkResult &result);
- void handleStop(const TrkResult &result);
- void handleSupportMask(const TrkResult &result);
- void handleTrkVersionsStartGdb(const TrkResult &result);
- Q_SLOT void slotStartGdb();
- void handleDisconnect(const TrkResult &result);
- void handleDeleteProcess(const TrkResult &result);
- void handleDeleteProcess2(const TrkResult &result);
- void handleAndReportCreateProcess(const TrkResult &result);
- void handleAndReportReadRegisters(const TrkResult &result);
- void handleAndReportReadRegister(const TrkResult &result);
- void handleAndReportReadRegistersAfterStop(const TrkResult &result);
- void reportRegisters();
- void handleAndReportSetBreakpoint(const TrkResult &result);
- void handleReadMemoryBuffered(const TrkResult &result);
- void handleReadMemoryUnbuffered(const TrkResult &result);
- void handleStep(const TrkResult &result);
- void handleReadRegisters(const TrkResult &result);
- void handleWriteRegister(const TrkResult &result);
- void handleWriteMemory(const TrkResult &result);
- void reportToGdb(const TrkResult &result);
- void gdbSetCurrentThread(const QByteArray &cmd, const char *why);
- //void reportReadMemoryBuffered(const TrkResult &result);
- //void reportReadMemoryUnbuffered(const TrkResult &result);
-
- void readMemory(uint addr, uint len, bool buffered);
- void writeMemory(uint addr, const QByteArray &data);
-
- void handleDirectTrk(const TrkResult &response);
- void directStep(uint addr);
- void handleDirectStep1(const TrkResult &response);
- void handleDirectStep2(const TrkResult &response);
- void handleDirectStep3(const TrkResult &response);
-
- void handleDirectWrite1(const TrkResult &response);
- void handleDirectWrite2(const TrkResult &response);
- void handleDirectWrite3(const TrkResult &response);
- void handleDirectWrite4(const TrkResult &response);
- void handleDirectWrite5(const TrkResult &response);
- void handleDirectWrite6(const TrkResult &response);
- void handleDirectWrite7(const TrkResult &response);
- void handleDirectWrite8(const TrkResult &response);
- void handleDirectWrite9(const TrkResult &response);
-
- QByteArray trkContinueMessage(uint threadId);
- QByteArray trkWriteRegisterMessage(trk::byte reg, uint value);
- QByteArray trkReadMemoryMessage(const MemoryRange &range);
- QByteArray trkWriteMemoryMessage(uint addr, const QByteArray &date);
- QByteArray trkBreakpointMessage(uint addr, uint len, bool armMode = true);
- QByteArray trkStepRangeMessage();
- QByteArray trkDeleteProcessMessage();
- QByteArray trkInterruptMessage();
- Q_SLOT void trkDeviceRemoved(const SymbianUtils::SymbianDevice &);
-
- QSharedPointer<trk::TrkDevice> m_trkDevice;
- QString m_adapterFailMessage;
-
- Q_SLOT void handleGdbConnection();
- Q_SLOT void readGdbServerCommand();
- void readGdbResponse();
- void handleGdbServerCommand(const QByteArray &cmd);
- void sendGdbServerMessage(const QByteArray &msg,
- const QByteArray &logNote = QByteArray());
- void sendGdbServerMessageAfterTrkResponse(const QByteArray &msg,
- const QByteArray &logNote = QByteArray());
- void sendGdbServerAck();
- bool sendGdbServerPacket(const QByteArray &packet, bool doFlush);
- void tryAnswerGdbMemoryRequest(bool buffered);
-
- void logMessage(const QString &msg, int logChannel = LogDebug); // triggers output() if m_verbose
- Q_SLOT void trkLogMessage(const QString &msg);
-
- QPointer<QTcpServer> m_gdbServer;
- QPointer<QTcpSocket> m_gdbConnection;
- QByteArray m_gdbReadBuffer;
- bool m_gdbAckMode;
-
- // Debuggee state
- trk::Session m_session; // global-ish data (process id, target information)
- Symbian::Snapshot m_snapshot; // local-ish data (memory and registers)
- QString m_remoteExecutable;
- QString m_remoteArguments;
- QString m_symbolFile;
- QString m_symbolFileFolder;
- int m_verbose;
- bool m_bufferedMemoryRead;
- LocalGdbProcess m_gdbProc;
-};
-
-} // namespace Internal
-} // namespace Debugger
-
-#endif // DEBUGGER_TRKGDBADAPTER_H
diff --git a/src/plugins/debugger/qml/qmladapter.cpp b/src/plugins/debugger/qml/qmladapter.cpp
index 975367e73e..504a11416a 100644
--- a/src/plugins/debugger/qml/qmladapter.cpp
+++ b/src/plugins/debugger/qml/qmladapter.cpp
@@ -128,12 +128,6 @@ void QmlAdapter::connectToViewer()
const DebuggerStartParameters &parameters = d->m_engine.data()->startParameters();
if (parameters.communicationChannel == DebuggerStartParameters::CommunicationChannelUsb) {
- if (parameters.debugClient == DebuggerStartParameters::SymbianDebugClientTrk) {
- d->m_connectionTimer.stop();
- showConnectionErrorMessage(tr("QML debugging is not supported when using TRK!"));
- emit connectionStartupFailed();
- return;
- }
const QString &port = parameters.remoteChannel;
showConnectionStatusMessage(tr("Connecting to debug server on %1").arg(port));
d->m_conn->connectToOst(port);
diff --git a/src/plugins/qt4projectmanager/qt-s60/codaruncontrol.cpp b/src/plugins/qt4projectmanager/qt-s60/codaruncontrol.cpp
index 323afcd66b..9db441cf45 100644
--- a/src/plugins/qt4projectmanager/qt-s60/codaruncontrol.cpp
+++ b/src/plugins/qt4projectmanager/qt-s60/codaruncontrol.cpp
@@ -134,7 +134,7 @@ bool CodaRunControl::setupLauncher()
connect(SymbianUtils::SymbianDeviceManager::instance(), SIGNAL(deviceRemoved(const SymbianUtils::SymbianDevice)),
this, SLOT(deviceRemoved(SymbianUtils::SymbianDevice)));
connect(m_codaDevice.data(), SIGNAL(error(QString)), this, SLOT(slotError(QString)));
- connect(m_codaDevice.data(), SIGNAL(logMessage(QString)), this, SLOT(slotTrkLogMessage(QString)));
+ connect(m_codaDevice.data(), SIGNAL(logMessage(QString)), this, SLOT(slotCodaLogMessage(QString)));
connect(m_codaDevice.data(), SIGNAL(codaEvent(Coda::CodaEvent)), this, SLOT(slotCodaEvent(Coda::CodaEvent)));
connect(m_codaDevice.data(), SIGNAL(serialPong(QString)), this, SLOT(slotSerialPong(QString)));
m_state = StateConnecting;
@@ -143,7 +143,7 @@ bool CodaRunControl::setupLauncher()
// For TCP we don't use device manager, we just set it up directly
m_codaDevice = QSharedPointer<Coda::CodaDevice>(new Coda::CodaDevice, &QObject::deleteLater); // finishRunControl, which deletes m_codaDevice, can get called from within a coda callback, so need to use deleteLater
connect(m_codaDevice.data(), SIGNAL(error(QString)), this, SLOT(slotError(QString)));
- connect(m_codaDevice.data(), SIGNAL(logMessage(QString)), this, SLOT(slotTrkLogMessage(QString)));
+ connect(m_codaDevice.data(), SIGNAL(logMessage(QString)), this, SLOT(slotCodaLogMessage(QString)));
connect(m_codaDevice.data(), SIGNAL(codaEvent(Coda::CodaEvent)), this, SLOT(slotCodaEvent(Coda::CodaEvent)));
const QSharedPointer<QTcpSocket> codaSocket(new QTcpSocket);
@@ -181,7 +181,7 @@ void CodaRunControl::slotError(const QString &error)
finishRunControl();
}
-void CodaRunControl::slotTrkLogMessage(const QString &log)
+void CodaRunControl::slotCodaLogMessage(const QString &log)
{
if (debug > 1)
qDebug("CODA log: %s", qPrintable(log.size()>200?log.left(200).append(QLatin1String(" ...")): log));
diff --git a/src/plugins/qt4projectmanager/qt-s60/codaruncontrol.h b/src/plugins/qt4projectmanager/qt-s60/codaruncontrol.h
index bf0b460b3d..d0dbd1413d 100644
--- a/src/plugins/qt4projectmanager/qt-s60/codaruncontrol.h
+++ b/src/plugins/qt4projectmanager/qt-s60/codaruncontrol.h
@@ -85,7 +85,7 @@ protected slots:
private slots:
void slotError(const QString &error);
- void slotTrkLogMessage(const QString &log);
+ void slotCodaLogMessage(const QString &log);
void slotCodaEvent(const Coda::CodaEvent &event);
void slotSerialPong(const QString &message);
diff --git a/src/plugins/qt4projectmanager/qt-s60/qt-s60.pri b/src/plugins/qt4projectmanager/qt-s60/qt-s60.pri
index 1d159e38cd..7369cb04a1 100644
--- a/src/plugins/qt4projectmanager/qt-s60/qt-s60.pri
+++ b/src/plugins/qt4projectmanager/qt-s60/qt-s60.pri
@@ -6,7 +6,6 @@ SOURCES += $$PWD/s60manager.cpp \
$$PWD/s60devicerunconfiguration.cpp \
$$PWD/s60devicerunconfigurationwidget.cpp \
$$PWD/rvcttoolchain.cpp \
- $$PWD/s60runconfigbluetoothstarter.cpp \
$$PWD/abldparser.cpp \
$$PWD/rvctparser.cpp \
$$PWD/winscwparser.cpp \
@@ -24,7 +23,6 @@ SOURCES += $$PWD/s60manager.cpp \
$$PWD/qt4symbiantarget.cpp \
$$PWD/s60runcontrolfactory.cpp \
$$PWD/codaruncontrol.cpp \
- $$PWD/trkruncontrol.cpp \
$$PWD/s60runcontrolbase.cpp \
$$PWD/s60publishingwizardfactories.cpp \
$$PWD/s60publishingwizardovi.cpp \
@@ -44,7 +42,6 @@ HEADERS += $$PWD/s60manager.h \
$$PWD/s60devicerunconfiguration.h \
$$PWD/s60devicerunconfigurationwidget.h \
$$PWD/rvcttoolchain.h \
- $$PWD/s60runconfigbluetoothstarter.h \
$$PWD/abldparser.h \
$$PWD/rvctparser.h \
$$PWD/winscwparser.h \
@@ -62,7 +59,6 @@ HEADERS += $$PWD/s60manager.h \
$$PWD/qt4symbiantarget.h \
$$PWD/s60runcontrolfactory.h \
$$PWD/codaruncontrol.h \
- $$PWD/trkruncontrol.h \
$$PWD/s60runcontrolbase.h \
$$PWD/s60publishingwizardfactories.h \
$$PWD/s60publishingwizardovi.h \
diff --git a/src/plugins/qt4projectmanager/qt-s60/qt4symbiantarget.cpp b/src/plugins/qt4projectmanager/qt-s60/qt4symbiantarget.cpp
index 1dee8e31ac..5c5ad17f82 100644
--- a/src/plugins/qt4projectmanager/qt-s60/qt4symbiantarget.cpp
+++ b/src/plugins/qt4projectmanager/qt-s60/qt4symbiantarget.cpp
@@ -168,7 +168,6 @@ bool Qt4SymbianTarget::isSymbianConnectionAvailable(QString &tooltipText)
if (!s60DeployConf)
return false;
switch (s60DeployConf->communicationChannel()) {
- case S60DeployConfiguration::CommunicationTrkSerialConnection:
case S60DeployConfiguration::CommunicationCodaSerialConnection: {
const SymbianUtils::SymbianDeviceManager *sdm = SymbianUtils::SymbianDeviceManager::instance();
const int deviceIndex = sdm->findByPortName(s60DeployConf->serialPortName());
diff --git a/src/plugins/qt4projectmanager/qt-s60/s60deployconfiguration.cpp b/src/plugins/qt4projectmanager/qt-s60/s60deployconfiguration.cpp
index a8f95b6c84..f79ece25a5 100644
--- a/src/plugins/qt4projectmanager/qt-s60/s60deployconfiguration.cpp
+++ b/src/plugins/qt4projectmanager/qt-s60/s60deployconfiguration.cpp
@@ -90,7 +90,7 @@ S60DeployConfiguration::S60DeployConfiguration(Target *parent) :
m_installationDrive('C'),
m_silentInstall(true),
m_devicePort(QLatin1String(DEFAULT_CODA_TCP_PORT)),
- m_communicationChannel(CommunicationTrkSerialConnection)
+ m_communicationChannel(CommunicationCodaSerialConnection)
{
ctor();
}
@@ -330,7 +330,7 @@ bool S60DeployConfiguration::fromMap(const QVariantMap &map)
m_deviceAddress = map.value(QLatin1String(DEVICE_ADDRESS_KEY)).toString();
m_devicePort = map.value(QLatin1String(DEVICE_PORT_KEY), QString(QLatin1String(DEFAULT_CODA_TCP_PORT))).toString();
m_communicationChannel = static_cast<CommunicationChannel>(map.value(QLatin1String(COMMUNICATION_CHANNEL_KEY),
- QVariant(CommunicationTrkSerialConnection)).toInt());
+ QVariant(CommunicationCodaSerialConnection)).toInt());
setDefaultDisplayName(defaultDisplayName());
return true;
diff --git a/src/plugins/qt4projectmanager/qt-s60/s60deployconfiguration.h b/src/plugins/qt4projectmanager/qt-s60/s60deployconfiguration.h
index 0c313009e7..606695cadd 100644
--- a/src/plugins/qt4projectmanager/qt-s60/s60deployconfiguration.h
+++ b/src/plugins/qt4projectmanager/qt-s60/s60deployconfiguration.h
@@ -61,7 +61,6 @@ class QT4PROJECTMANAGER_EXPORT S60DeployConfiguration : public ProjectExplorer::
public:
enum CommunicationChannel {
- CommunicationTrkSerialConnection,
CommunicationCodaSerialConnection,
CommunicationCodaTcpConnection
};
diff --git a/src/plugins/qt4projectmanager/qt-s60/s60deployconfigurationwidget.cpp b/src/plugins/qt4projectmanager/qt-s60/s60deployconfigurationwidget.cpp
index ffea34bb73..cd9654cf16 100644
--- a/src/plugins/qt4projectmanager/qt-s60/s60deployconfigurationwidget.cpp
+++ b/src/plugins/qt4projectmanager/qt-s60/s60deployconfigurationwidget.cpp
@@ -34,18 +34,12 @@
#include "s60deployconfiguration.h"
#include "s60devicerunconfiguration.h"
-#include "s60runconfigbluetoothstarter.h"
-#include <symbianutils/bluetoothlistener_gui.h>
-
-#include <symbianutils/launcher.h>
-#include <symbianutils/bluetoothlistener.h>
#include <symbianutils/symbiandevicemanager.h>
#include <codadevice.h>
#include <coreplugin/helpmanager.h>
#include "codaruncontrol.h"
-#include "trkruncontrol.h"
#include <utils/detailswidget.h>
#include <utils/ipaddresslineedit.h>
@@ -139,9 +133,6 @@ S60DeployConfigurationWidget::S60DeployConfigurationWidget(QWidget *parent)
m_serialRadioButton(new QRadioButton(tr("Serial:"))),
m_wlanRadioButton(new QRadioButton(tr("WLAN:"))),
m_ipAddress(new Utils::IpAddressLineEdit),
- m_trkRadioButton(new QRadioButton(tr("TRK"))),
- m_codaRadioButton(new QRadioButton(tr("CODA"))),
- m_codaInfoLabel(new QLabel(tr("<a href=\"qthelp://com.nokia.qtcreator/doc/creator-developing-symbian.html\">What are the prerequisites?</a>"))),
m_codaTimeout(new QTimer(this))
{
}
@@ -196,41 +187,11 @@ void S60DeployConfigurationWidget::init(ProjectExplorer::DeployConfiguration *dc
connect(SymbianUtils::SymbianDeviceManager::instance(), SIGNAL(updated()),
this, SLOT(updateSerialDevices()));
- //Debug Client
- QVBoxLayout *debugClientContentVBoxLayout = new QVBoxLayout;
- debugClientContentVBoxLayout->addWidget(m_codaInfoLabel);
-
- QHBoxLayout *debugClientHBoxLayout = new QHBoxLayout;
- debugClientContentVBoxLayout->addLayout(debugClientHBoxLayout);
-
- QVBoxLayout *debugClientVBoxLayout = new QVBoxLayout;
- debugClientVBoxLayout->addWidget(m_trkRadioButton);
- debugClientVBoxLayout->addWidget(m_codaRadioButton);
-
- debugClientVBoxLayout->addSpacerItem(new QSpacerItem(0, 0, QSizePolicy::Ignored, QSizePolicy::Expanding));
-
- debugClientHBoxLayout->addLayout(debugClientVBoxLayout);
-
- debugClientHBoxLayout->addWidget(createCommunicationChannel());
- debugClientHBoxLayout->addSpacerItem(new QSpacerItem(0, 0, QSizePolicy::Expanding, QSizePolicy::Ignored));
-
- QGroupBox *debugClientGroupBox = new QGroupBox(tr("Device Agent"));
- debugClientGroupBox->setLayout(debugClientContentVBoxLayout);
-
- bool usingTrk = m_deployConfiguration->communicationChannel() == S60DeployConfiguration::CommunicationTrkSerialConnection;
- m_trkRadioButton->setChecked(usingTrk);
- m_codaRadioButton->setChecked(!usingTrk);
-
bool usingTcp = m_deployConfiguration->communicationChannel() == S60DeployConfiguration::CommunicationCodaTcpConnection;
m_serialRadioButton->setChecked(!usingTcp);
m_wlanRadioButton->setChecked(usingTcp);
- connect(m_trkRadioButton, SIGNAL(clicked()), this, SLOT(updateCommunicationChannel()));
- connect(m_codaRadioButton, SIGNAL(clicked()), this, SLOT(updateCommunicationChannel()));
- connect(m_codaInfoLabel, SIGNAL(linkActivated(QString)),
- Core::HelpManager::instance(), SLOT(handleHelpRequest(QString)));
-
- formLayout->addRow(debugClientGroupBox);
+ formLayout->addRow(createCommunicationChannel());
// Device Info with button. Widgets are enabled in above call to updateSerialDevices()
QHBoxLayout *infoHBoxLayout = new QHBoxLayout;
@@ -415,58 +376,32 @@ void S60DeployConfigurationWidget::setSerialPort(int index)
void S60DeployConfigurationWidget::updateCommunicationChannelUi()
{
S60DeployConfiguration::CommunicationChannel channel = m_deployConfiguration->communicationChannel();
- if (channel == S60DeployConfiguration::CommunicationTrkSerialConnection) {
- m_trkRadioButton->setChecked(true);
- m_codaRadioButton->setChecked(false);
- m_serialRadioButton->setChecked(true);
- m_wlanRadioButton->setDisabled(true);
+ if (channel == S60DeployConfiguration::CommunicationCodaTcpConnection) {
+ m_ipAddress->setDisabled(false);
+ m_serialPortsCombo->setDisabled(true);
+ m_deviceInfoButton->setEnabled(true);
+ } else {
m_ipAddress->setDisabled(true);
m_serialPortsCombo->setDisabled(false);
updateSerialDevices();
- } else {
- m_trkRadioButton->setChecked(false);
- m_codaRadioButton->setChecked(true);
- m_wlanRadioButton->setDisabled(false);
- if (channel == S60DeployConfiguration::CommunicationCodaTcpConnection) {
- m_ipAddress->setDisabled(false);
- m_serialPortsCombo->setDisabled(true);
- m_deviceInfoButton->setEnabled(true);
- } else {
- m_ipAddress->setDisabled(true);
- m_serialPortsCombo->setDisabled(false);
- updateSerialDevices();
- }
}
}
void S60DeployConfigurationWidget::updateCommunicationChannel()
{
- if (!m_trkRadioButton->isChecked() && !m_codaRadioButton->isChecked())
- m_trkRadioButton->setChecked(true);
-
- if (m_trkRadioButton->isChecked()) {
+ if (!m_wlanRadioButton->isChecked() && !m_serialRadioButton->isChecked())
m_serialRadioButton->setChecked(true);
- m_wlanRadioButton->setDisabled(true);
+
+ if (m_wlanRadioButton->isChecked()) {
+ m_ipAddress->setDisabled(false);
+ m_serialPortsCombo->setDisabled(true);
+ m_deployConfiguration->setCommunicationChannel(S60DeployConfiguration::CommunicationCodaTcpConnection);
+ m_deviceInfoButton->setEnabled(true);
+ } else {
m_ipAddress->setDisabled(true);
m_serialPortsCombo->setDisabled(false);
- m_deployConfiguration->setCommunicationChannel(S60DeployConfiguration::CommunicationTrkSerialConnection);
+ m_deployConfiguration->setCommunicationChannel(S60DeployConfiguration::CommunicationCodaSerialConnection);
updateSerialDevices();
- } else if (m_codaRadioButton->isChecked()) {
- if (!m_wlanRadioButton->isChecked() && !m_serialRadioButton->isChecked())
- m_serialRadioButton->setChecked(true);
- m_wlanRadioButton->setDisabled(false);
-
- if (m_wlanRadioButton->isChecked()) {
- m_ipAddress->setDisabled(false);
- m_serialPortsCombo->setDisabled(true);
- m_deployConfiguration->setCommunicationChannel(S60DeployConfiguration::CommunicationCodaTcpConnection);
- m_deviceInfoButton->setEnabled(true);
- } else {
- m_ipAddress->setDisabled(true);
- m_serialPortsCombo->setDisabled(false);
- m_deployConfiguration->setCommunicationChannel(S60DeployConfiguration::CommunicationCodaSerialConnection);
- updateSerialDevices();
- }
}
}
@@ -507,78 +442,10 @@ void S60DeployConfigurationWidget::setDeviceInfoLabel(const QString &message, bo
m_deviceInfoLabel->adjustSize();
}
-void S60DeployConfigurationWidget::slotLauncherStateChanged(int s)
-{
- switch (s) {
- case trk::Launcher::WaitingForTrk: {
- // Entered trk wait state..open message box
- QMessageBox *mb = TrkRunControl::createTrkWaitingMessageBox(m_infoLauncher->trkServerName(), this);
- connect(m_infoLauncher, SIGNAL(stateChanged(int)), mb, SLOT(close()));
- connect(mb, SIGNAL(finished(int)), this, SLOT(slotWaitingForTrkClosed()));
- mb->open();
- }
- break;
- case trk::Launcher::DeviceDescriptionReceived: // All ok, done
- setDeviceInfoLabel(m_infoLauncher->deviceDescription());
- m_deviceInfoButton->setEnabled(true);
- m_infoLauncher->deleteLater();
- break;
- }
-}
-
-void S60DeployConfigurationWidget::slotWaitingForTrkClosed()
-{
- if (m_infoLauncher && m_infoLauncher->state() == trk::Launcher::WaitingForTrk) {
- m_infoLauncher->deleteLater();
- clearDeviceInfo();
- m_deviceInfoButton->setEnabled(true);
- }
-}
-
void S60DeployConfigurationWidget::updateDeviceInfo()
{
setDeviceInfoLabel(tr("Connecting"));
- if (m_deployConfiguration->communicationChannel() == S60DeployConfiguration::CommunicationTrkSerialConnection) {
- QTC_ASSERT(!m_infoLauncher, return)
-
- // Do a launcher run with the ping protocol. Prompt to connect and
- // go asynchronous afterwards to pop up launch trk box if a timeout occurs.
- QString message;
- const SymbianUtils::SymbianDevice commDev = currentDevice();
- m_infoLauncher = trk::Launcher::acquireFromDeviceManager(commDev.portName(), this, &message);
- if (!m_infoLauncher) {
- setDeviceInfoLabel(message, true);
- return;
- }
- connect(m_infoLauncher, SIGNAL(stateChanged(int)), this, SLOT(slotLauncherStateChanged(int)));
-
- m_infoLauncher->setSerialFrame(commDev.type() == SymbianUtils::SerialPortCommunication);
- m_infoLauncher->setTrkServerName(commDev.portName());
-
- // Prompt user
- const trk::PromptStartCommunicationResult src =
- S60RunConfigBluetoothStarter::startCommunication(m_infoLauncher->trkDevice(),
- this, &message);
- switch (src) {
- case trk::PromptStartCommunicationConnected:
- break;
- case trk::PromptStartCommunicationCanceled:
- clearDeviceInfo();
- m_infoLauncher->deleteLater();
- return;
- case trk::PromptStartCommunicationError:
- setDeviceInfoLabel(message, true);
- m_infoLauncher->deleteLater();
- return;
- };
- if (!m_infoLauncher->startServer(&message)) {
- setDeviceInfoLabel(message, true);
- m_infoLauncher->deleteLater();
- return;
- }
- // Wait for either timeout or results
- m_deviceInfoButton->setEnabled(false);
- } else if (m_deployConfiguration->communicationChannel() == S60DeployConfiguration::CommunicationCodaSerialConnection) {
+ if (m_deployConfiguration->communicationChannel() == S60DeployConfiguration::CommunicationCodaSerialConnection) {
const SymbianUtils::SymbianDevice commDev = currentDevice();
m_codaInfoDevice = SymbianUtils::SymbianDeviceManager::instance()->getCodaDevice(commDev.portName());
if (m_codaInfoDevice.isNull()) {
diff --git a/src/plugins/qt4projectmanager/qt-s60/s60deployconfigurationwidget.h b/src/plugins/qt4projectmanager/qt-s60/s60deployconfigurationwidget.h
index 6348176fa9..9402a17c86 100644
--- a/src/plugins/qt4projectmanager/qt-s60/s60deployconfigurationwidget.h
+++ b/src/plugins/qt4projectmanager/qt-s60/s60deployconfigurationwidget.h
@@ -52,10 +52,6 @@ namespace Utils {
class IpAddressLineEdit;
}
-namespace trk {
- class Launcher;
-}
-
namespace SymbianUtils {
class SymbianDevice;
}
@@ -96,8 +92,6 @@ private slots:
void setSerialPort(int index);
void updateDeviceInfo();
void clearDeviceInfo();
- void slotLauncherStateChanged(int);
- void slotWaitingForTrkClosed();
void silentInstallChanged(int);
void updateCommunicationChannel();
void updateCommunicationChannelUi();
@@ -129,15 +123,11 @@ private:
QToolButton *m_deviceInfoButton;
QLabel *m_deviceInfoDescriptionLabel;
QLabel *m_deviceInfoLabel;
- QPointer<trk::Launcher> m_infoLauncher;
QComboBox *m_installationDriveCombo;
QCheckBox *m_silentInstallCheckBox;
QRadioButton *m_serialRadioButton;
QRadioButton *m_wlanRadioButton;
Utils::IpAddressLineEdit *m_ipAddress;
- QRadioButton *m_trkRadioButton;
- QRadioButton *m_codaRadioButton;
- QLabel *m_codaInfoLabel;
QSharedPointer<Coda::CodaDevice> m_codaInfoDevice;
QString m_deviceInfo;
QTimer *m_codaTimeout;
diff --git a/src/plugins/qt4projectmanager/qt-s60/s60deploystep.cpp b/src/plugins/qt4projectmanager/qt-s60/s60deploystep.cpp
index 5642aa2698..a2151e3154 100644
--- a/src/plugins/qt4projectmanager/qt-s60/s60deploystep.cpp
+++ b/src/plugins/qt4projectmanager/qt-s60/s60deploystep.cpp
@@ -35,9 +35,7 @@
#include "qt4buildconfiguration.h"
#include "s60deployconfiguration.h"
#include "s60devicerunconfiguration.h"
-#include "s60runconfigbluetoothstarter.h"
#include "codadevice.h"
-#include "trkruncontrol.h"
#include "codaruncontrol.h"
#include <coreplugin/icore.h>
@@ -46,7 +44,6 @@
#include <projectexplorer/projectexplorerconstants.h>
#include <qt4projectmanagerconstants.h>
-#include <symbianutils/launcher.h>
#include <symbianutils/symbiandevicemanager.h>
#include <utils/qtcassert.h>
@@ -63,6 +60,7 @@
#include <QtNetwork/QTcpSocket>
using namespace ProjectExplorer;
+using namespace SymbianUtils;
using namespace Qt4ProjectManager::Internal;
enum { debug = 0 };
@@ -105,9 +103,6 @@ S60DeployStep::S60DeployStep(ProjectExplorer::BuildStepList *bc,
S60DeployStep *bs):
BuildStep(bc, bs), m_timer(0),
m_timeoutTimer(new QTimer(this)),
- m_releaseDeviceAfterLauncherFinish(bs->m_releaseDeviceAfterLauncherFinish),
- m_handleDeviceRemoval(bs->m_handleDeviceRemoval),
- m_launcher(0),
m_eventLoop(0),
m_state(StateUninit),
m_putWriteOk(false),
@@ -124,16 +119,13 @@ S60DeployStep::S60DeployStep(ProjectExplorer::BuildStepList *bc,
S60DeployStep::S60DeployStep(ProjectExplorer::BuildStepList *bc):
BuildStep(bc, QLatin1String(S60_DEPLOY_STEP_ID)), m_timer(0),
m_timeoutTimer(new QTimer(this)),
- m_releaseDeviceAfterLauncherFinish(true),
- m_handleDeviceRemoval(true),
- m_launcher(0),
m_eventLoop(0),
m_state(StateUninit),
m_putWriteOk(false),
m_putLastChunkSize(0),
m_putChunkSize(DEFAULT_CHUNK_SIZE),
m_currentFileIndex(0),
- m_channel(S60DeployConfiguration::CommunicationTrkSerialConnection),
+ m_channel(S60DeployConfiguration::CommunicationCodaSerialConnection),
m_deployCanceled(false),
m_copyProgress(0)
{
@@ -152,7 +144,6 @@ void S60DeployStep::ctor()
S60DeployStep::~S60DeployStep()
{
delete m_timer;
- delete m_launcher;
delete m_eventLoop;
}
@@ -164,21 +155,11 @@ bool S60DeployStep::init()
if (!deployConfiguration)
return false;
m_serialPortName = deployConfiguration->serialPortName();
- m_serialPortFriendlyName = SymbianUtils::SymbianDeviceManager::instance()->friendlyNameForPort(m_serialPortName);
+ m_serialPortFriendlyName = SymbianDeviceManager::instance()->friendlyNameForPort(m_serialPortName);
m_packageFileNamesWithTarget = deployConfiguration->packageFileNamesWithTargetInfo();
m_signedPackages = deployConfiguration->signedPackages();
m_installationDrive = deployConfiguration->installationDrive();
m_silentInstall = deployConfiguration->silentInstall();
-
- switch (deployConfiguration->communicationChannel()) {
- case S60DeployConfiguration::CommunicationTrkSerialConnection:
- break;
- case S60DeployConfiguration::CommunicationCodaTcpConnection:
- m_address = deployConfiguration->deviceAddress();
- m_port = deployConfiguration->devicePort().toInt();
- default:
- break;
- }
m_channel = deployConfiguration->communicationChannel();
if (m_signedPackages.isEmpty()) {
@@ -186,36 +167,9 @@ bool S60DeployStep::init()
return false;
}
- if (m_channel == S60DeployConfiguration::CommunicationTrkSerialConnection) {
- QString message;
- if (m_launcher) {
- trk::Launcher::releaseToDeviceManager(m_launcher);
- delete m_launcher;
- m_launcher = 0;
- }
-
- m_launcher = trk::Launcher::acquireFromDeviceManager(m_serialPortName, this, &message);
- if (!message.isEmpty() || !m_launcher) {
- if (m_launcher)
- trk::Launcher::releaseToDeviceManager(m_launcher);
- delete m_launcher;
- m_launcher = 0;
- appendMessage(message, true);
- return true;
- }
-
- // Prompt the user to start up the Bluetooth connection
- const trk::PromptStartCommunicationResult src =
- S60RunConfigBluetoothStarter::startCommunication(m_launcher->trkDevice(),
- 0, &message);
- if (src != trk::PromptStartCommunicationConnected) {
- if (!message.isEmpty())
- trk::Launcher::releaseToDeviceManager(m_launcher);
- delete m_launcher;
- m_launcher = 0;
- appendMessage(message, true);
- return false;
- }
+ if (m_channel == S60DeployConfiguration::CommunicationCodaTcpConnection) {
+ m_address = deployConfiguration->deviceAddress();
+ m_port = deployConfiguration->devicePort().toInt();
}
return true;
}
@@ -281,29 +235,24 @@ void S60DeployStep::start()
{
QString errorMessage;
- bool serialConnection = (m_channel == S60DeployConfiguration::CommunicationTrkSerialConnection
- || m_channel == S60DeployConfiguration::CommunicationCodaSerialConnection);
- bool trkClient = m_channel == S60DeployConfiguration::CommunicationTrkSerialConnection;
+ bool serialConnection = m_channel == S60DeployConfiguration::CommunicationCodaSerialConnection;
- if ((serialConnection && m_serialPortName.isEmpty())
- || (trkClient && !m_launcher)) {
+ if (serialConnection && m_serialPortName.isEmpty()) {
errorMessage = tr("No device is connected. Please connect a device and try again.");
reportError(errorMessage);
return;
}
- if (!trkClient) {
- QTC_ASSERT(!m_codaDevice.data(), return);
- if (m_address.isEmpty() && !serialConnection) {
- errorMessage = tr("No address for a device has been defined. Please define an address and try again.");
- reportError(errorMessage);
- return;
- }
+ QTC_ASSERT(!m_codaDevice.data(), return);
+ if (m_address.isEmpty() && !serialConnection) {
+ errorMessage = tr("No address for a device has been defined. Please define an address and try again.");
+ reportError(errorMessage);
+ return;
}
// make sure we have the right name of the sis package
- if (processPackageName(errorMessage)) {
+ if (processPackageName(errorMessage))
startDeployment();
- } else {
+ else {
errorMessage = tr("Failed to find package %1").arg(errorMessage);
reportError(errorMessage);
stop();
@@ -312,21 +261,16 @@ void S60DeployStep::start()
void S60DeployStep::stop()
{
- if (m_channel == S60DeployConfiguration::CommunicationTrkSerialConnection) {
- if (m_launcher)
- m_launcher->terminate();
- } else {
- if (m_codaDevice) {
- switch (state()) {
- case StateSendingData:
- closeFiles();
- break;
- default:
- break; //should also stop the package installatrion, but CODA does not support it yet
- }
- disconnect(m_codaDevice.data(), 0, this, 0);
- SymbianUtils::SymbianDeviceManager::instance()->releaseCodaDevice(m_codaDevice);
+ if (m_codaDevice) {
+ switch (state()) {
+ case StateSendingData:
+ closeFiles();
+ break;
+ default:
+ break; //should also stop the package installation, but CODA does not support it yet
}
+ disconnect(m_codaDevice.data(), 0, this, 0);
+ SymbianDeviceManager::instance()->releaseCodaDevice(m_codaDevice);
}
setState(StateUninit);
emit finished(false);
@@ -334,69 +278,26 @@ void S60DeployStep::stop()
void S60DeployStep::setupConnections()
{
- if (m_channel == S60DeployConfiguration::CommunicationTrkSerialConnection
- || m_channel == S60DeployConfiguration::CommunicationCodaSerialConnection)
- connect(SymbianUtils::SymbianDeviceManager::instance(), SIGNAL(deviceRemoved(SymbianUtils::SymbianDevice)),
- this, SLOT(deviceRemoved(SymbianUtils::SymbianDevice)));
-
- if (m_channel == S60DeployConfiguration::CommunicationTrkSerialConnection) {
- connect(m_launcher, SIGNAL(finished()), this, SLOT(launcherFinished()));
- connect(m_launcher, SIGNAL(canNotConnect(QString)), this, SLOT(connectFailed(QString)));
- connect(m_launcher, SIGNAL(copyingStarted(QString)), this, SLOT(printCopyingNotice(QString)));
- connect(m_launcher, SIGNAL(fileCopied(QString)), this, SLOT(printCopyingFinished(QString)));
- connect(m_launcher, SIGNAL(canNotCreateFile(QString,QString)), this, SLOT(createFileFailed(QString,QString)));
- connect(m_launcher, SIGNAL(canNotWriteFile(QString,QString)), this, SLOT(writeFileFailed(QString,QString)));
- connect(m_launcher, SIGNAL(canNotCloseFile(QString,QString)), this, SLOT(closeFileFailed(QString,QString)));
- connect(m_launcher, SIGNAL(installingStarted(QString)), this, SLOT(printInstallingNotice(QString)));
- connect(m_launcher, SIGNAL(canNotInstall(QString,QString)), this, SLOT(installFailed(QString,QString)));
- connect(m_launcher, SIGNAL(installingFinished()), this, SLOT(printInstallingFinished()));
- connect(m_launcher, SIGNAL(stateChanged(int)), this, SLOT(slotLauncherStateChanged(int)));
- connect(m_launcher, SIGNAL(copyProgress(int)), this, SLOT(setCopyProgress(int)));
- } else {
- connect(m_codaDevice.data(), SIGNAL(error(QString)), this, SLOT(slotError(QString)));
- connect(m_codaDevice.data(), SIGNAL(logMessage(QString)), this, SLOT(slotTrkLogMessage(QString)));
- connect(m_codaDevice.data(), SIGNAL(codaEvent(Coda::CodaEvent)), this, SLOT(slotCodaEvent(Coda::CodaEvent)), Qt::DirectConnection);
- connect(m_codaDevice.data(), SIGNAL(serialPong(QString)), this, SLOT(slotSerialPong(QString)));
- connect(this, SIGNAL(manualInstallation()), this, SLOT(showManualInstallationInfo()));
- }
+ if (m_channel == S60DeployConfiguration::CommunicationCodaSerialConnection)
+ connect(SymbianDeviceManager::instance(), SIGNAL(deviceRemoved(SymbianDevice)), this, SLOT(deviceRemoved(SymbianDevice)));
+
+ connect(m_codaDevice.data(), SIGNAL(error(QString)), this, SLOT(slotError(QString)));
+ connect(m_codaDevice.data(), SIGNAL(logMessage(QString)), this, SLOT(slotCodaLogMessage(QString)));
+ connect(m_codaDevice.data(), SIGNAL(codaEvent(Coda::CodaEvent)), this, SLOT(slotCodaEvent(Coda::CodaEvent)), Qt::DirectConnection);
+ connect(m_codaDevice.data(), SIGNAL(serialPong(QString)), this, SLOT(slotSerialPong(QString)));
+ connect(this, SIGNAL(manualInstallation()), this, SLOT(showManualInstallationInfo()));
}
void S60DeployStep::startDeployment()
{
- if (m_channel == S60DeployConfiguration::CommunicationTrkSerialConnection) {
- QTC_ASSERT(m_launcher, return);
- }
QTC_ASSERT(!m_codaDevice.data(), return);
// We need to defer setupConnections() in the case of CommunicationCodaSerialConnection
//setupConnections();
- if (m_channel == S60DeployConfiguration::CommunicationTrkSerialConnection) {
- setupConnections();
- QStringList copyDst;
- foreach (const QString &signedPackage, m_signedPackages)
- copyDst << QString::fromLatin1("%1:\\Data\\%2").arg(m_installationDrive).arg(QFileInfo(signedPackage).fileName());
-
- m_launcher->setCopyFileNames(m_signedPackages, copyDst);
- m_launcher->setInstallFileNames(copyDst);
- m_launcher->setInstallationDrive(m_installationDrive);
- m_launcher->setInstallationMode(m_silentInstall?trk::Launcher::InstallationModeSilentAndUser:
- trk::Launcher::InstallationModeUser);
- m_launcher->addStartupActions(trk::Launcher::ActionCopyInstall);
-
- // TODO readd information about packages? msgListFile(m_signedPackage)
- appendMessage(tr("Deploying application to '%2'...").arg(m_serialPortFriendlyName), false);
-
- QString errorMessage;
- if (!m_launcher->startServer(&errorMessage)) {
- errorMessage = tr("Could not connect to phone on port '%1': %2\n"
- "Check if the phone is connected and App TRK is running.").arg(m_serialPortName, errorMessage);
- reportError(errorMessage);
- stop();
- }
- } else if (m_channel == S60DeployConfiguration::CommunicationCodaSerialConnection) {
+ if (m_channel == S60DeployConfiguration::CommunicationCodaSerialConnection) {
appendMessage(tr("Deploying application to '%1'...").arg(m_serialPortFriendlyName), false);
- m_codaDevice = SymbianUtils::SymbianDeviceManager::instance()->getCodaDevice(m_serialPortName);
+ m_codaDevice = SymbianDeviceManager::instance()->getCodaDevice(m_serialPortName);
bool ok = m_codaDevice && m_codaDevice->device()->isOpen();
if (!ok) {
QString deviceError = tr("No such port");
@@ -430,16 +331,10 @@ void S60DeployStep::run(QFutureInterface<bool> &fi)
m_futureInterface->setProgressRange(0, 100*m_signedPackages.count());
- if (m_channel == S60DeployConfiguration::CommunicationTrkSerialConnection) {
- connect(this, SIGNAL(finished(bool)), this, SLOT(launcherFinished(bool)));
- connect(this, SIGNAL(finishNow(bool)), this, SLOT(launcherFinished(bool)), Qt::DirectConnection);
- } else {
- connect(this, SIGNAL(finished(bool)), this, SLOT(deploymentFinished(bool)));
- connect(this, SIGNAL(finishNow(bool)), this, SLOT(deploymentFinished(bool)), Qt::DirectConnection);
- connect(this, SIGNAL(allFilesSent()), this, SLOT(startInstalling()), Qt::DirectConnection);
- connect(this, SIGNAL(allFilesInstalled()), this, SIGNAL(finished()), Qt::DirectConnection);
- }
-
+ connect(this, SIGNAL(finished(bool)), this, SLOT(deploymentFinished(bool)));
+ connect(this, SIGNAL(finishNow(bool)), this, SLOT(deploymentFinished(bool)), Qt::DirectConnection);
+ connect(this, SIGNAL(allFilesSent()), this, SLOT(startInstalling()), Qt::DirectConnection);
+ connect(this, SIGNAL(allFilesInstalled()), this, SIGNAL(finished()), Qt::DirectConnection);
connect(this, SIGNAL(copyProgressChanged(int)), this, SLOT(updateProgress(int)));
start();
@@ -454,7 +349,7 @@ void S60DeployStep::run(QFutureInterface<bool> &fi)
if (m_codaDevice) {
disconnect(m_codaDevice.data(), 0, this, 0);
- SymbianUtils::SymbianDeviceManager::instance()->releaseCodaDevice(m_codaDevice);
+ SymbianDeviceManager::instance()->releaseCodaDevice(m_codaDevice);
}
delete m_eventLoop;
@@ -463,12 +358,18 @@ void S60DeployStep::run(QFutureInterface<bool> &fi)
m_futureInterface = 0;
}
+void S60DeployStep::slotWaitingForCodaClosed(int result)
+{
+ if (result == QMessageBox::Cancel)
+ m_deployCanceled = true;
+}
+
void S60DeployStep::slotError(const QString &error)
{
reportError(tr("Error: %1").arg(error));
}
-void S60DeployStep::slotTrkLogMessage(const QString &log)
+void S60DeployStep::slotCodaLogMessage(const QString &log)
{
if (debug > 1)
qDebug() << "CODA log:" << log;
@@ -678,7 +579,7 @@ void S60DeployStep::checkForTimeout()
connect(this, SIGNAL(codaConnected()), mb, SLOT(close()));
connect(this, SIGNAL(finished()), mb, SLOT(close()));
connect(this, SIGNAL(finishNow()), mb, SLOT(close()));
- connect(mb, SIGNAL(finished(int)), this, SLOT(slotWaitingForTckTrkClosed(int)));
+ connect(mb, SIGNAL(finished(int)), this, SLOT(slotWaitingForCodaClosed(int)));
mb->open();
}
@@ -694,81 +595,6 @@ void S60DeployStep::showManualInstallationInfo()
mb->open();
}
-void S60DeployStep::slotWaitingForTckTrkClosed(int result)
-{
- if (result == QMessageBox::Cancel)
- m_deployCanceled = true;
-}
-
-void S60DeployStep::setReleaseDeviceAfterLauncherFinish(bool v)
-{
- m_releaseDeviceAfterLauncherFinish = v;
-}
-
-void S60DeployStep::slotLauncherStateChanged(int s)
-{
- if (s == trk::Launcher::WaitingForTrk) {
- QMessageBox *mb = TrkRunControl::createTrkWaitingMessageBox(m_launcher->trkServerName(),
- Core::ICore::instance()->mainWindow());
- connect(m_launcher, SIGNAL(stateChanged(int)), mb, SLOT(close()));
- connect(mb, SIGNAL(finished(int)), this, SLOT(slotWaitingForTrkClosed()));
- mb->open();
- }
-}
-
-void S60DeployStep::slotWaitingForTrkClosed()
-{
- if (m_launcher && m_launcher->state() == trk::Launcher::WaitingForTrk)
- m_deployCanceled = true;
-}
-
-void S60DeployStep::createFileFailed(const QString &filename, const QString &errorMessage)
-{
- reportError(tr("Could not create file %1 on device: %2").arg(filename, errorMessage));
-}
-
-void S60DeployStep::writeFileFailed(const QString &filename, const QString &errorMessage)
-{
- reportError(tr("Could not write to file %1 on device: %2").arg(filename, errorMessage));
-}
-
-void S60DeployStep::closeFileFailed(const QString &filename, const QString &errorMessage)
-{
- const QString msg = tr("Could not close file %1 on device: %2. It will be closed when App TRK is closed.");
- reportError( msg.arg(filename, errorMessage));
-}
-
-void S60DeployStep::connectFailed(const QString &errorMessage)
-{
- reportError(tr("Could not connect to App TRK on device: %1. Restarting App TRK might help.").arg(errorMessage));
-}
-
-void S60DeployStep::printCopyingNotice(const QString &fileName)
-{
- appendMessage(tr("Copying \"%1\"...").arg(fileName), false);
-}
-
-void S60DeployStep::printCopyingFinished(const QString &fileName)
-{
- Q_UNUSED(fileName)
- appendMessage(QLatin1String("\n"), false);
-}
-
-void S60DeployStep::printInstallingNotice(const QString &packageName)
-{
- appendMessage(tr("Installing package \"%1\" on drive %2:...").arg(packageName).arg(m_installationDrive), false);
-}
-
-void S60DeployStep::printInstallingFinished()
-{
- appendMessage(tr("Installation has finished"), false);
-}
-
-void S60DeployStep::installFailed(const QString &filename, const QString &errorMessage)
-{
- reportError(tr("Could not install from package %1 on device: %2").arg(filename, errorMessage));
-}
-
void S60DeployStep::checkForCancel()
{
if ((m_futureInterface->isCanceled() || m_deployCanceled) && m_timer->isActive()) {
@@ -784,22 +610,6 @@ void S60DeployStep::checkForCancel()
}
}
-void S60DeployStep::launcherFinished(bool success)
-{
- m_deployResult = success;
- if(m_deployResult && m_futureInterface)
- m_futureInterface->setProgressValue(m_futureInterface->progressMaximum());
- if (m_releaseDeviceAfterLauncherFinish && m_launcher) {
- m_handleDeviceRemoval = false;
- trk::Launcher::releaseToDeviceManager(m_launcher);
- }
- if (m_launcher)
- m_launcher->deleteLater();
- m_launcher = 0;
- if (m_eventLoop)
- m_eventLoop->exit();
-}
-
void S60DeployStep::deploymentFinished(bool success)
{
m_deployResult = success;
@@ -809,10 +619,10 @@ void S60DeployStep::deploymentFinished(bool success)
m_eventLoop->exit();
}
-void S60DeployStep::deviceRemoved(const SymbianUtils::SymbianDevice &d)
+void S60DeployStep::deviceRemoved(const SymbianDevice &device)
{
- if (m_handleDeviceRemoval && d.portName() == m_serialPortName)
- reportError(tr("The device '%1' has been disconnected").arg(d.friendlyName()));
+ if (device.portName() == m_serialPortName)
+ reportError(tr("The device '%1' has been disconnected").arg(device.friendlyName()));
}
void S60DeployStep::setCopyProgress(int progress)
diff --git a/src/plugins/qt4projectmanager/qt-s60/s60deploystep.h b/src/plugins/qt4projectmanager/qt-s60/s60deploystep.h
index 5c59fbd205..4748a36ac3 100644
--- a/src/plugins/qt4projectmanager/qt-s60/s60deploystep.h
+++ b/src/plugins/qt4projectmanager/qt-s60/s60deploystep.h
@@ -44,10 +44,6 @@ namespace SymbianUtils {
class SymbianDevice;
}
-namespace trk{
-class Launcher;
-}
-
namespace Coda {
struct CodaCommandResult;
class CodaDevice;
@@ -102,8 +98,6 @@ public:
virtual void run(QFutureInterface<bool> &fi);
virtual ProjectExplorer::BuildStepConfigWidget *createConfigWidget();
- void setReleaseDeviceAfterLauncherFinish(bool);
-
virtual QVariantMap toMap() const;
protected:
@@ -113,24 +107,12 @@ protected slots:
void deviceRemoved(const SymbianUtils::SymbianDevice &);
private slots:
- void connectFailed(const QString &errorMessage);
- void printCopyingNotice(const QString &fileName);
- void printCopyingFinished(const QString &fileName);
- void createFileFailed(const QString &filename, const QString &errorMessage);
- void writeFileFailed(const QString &filename, const QString &errorMessage);
- void closeFileFailed(const QString &filename, const QString &errorMessage);
- void printInstallingNotice(const QString &packageName);
- void installFailed(const QString &filename, const QString &errorMessage);
- void printInstallingFinished();
- void launcherFinished(bool success = true);
- void slotLauncherStateChanged(int);
- void slotWaitingForTrkClosed();
void checkForCancel();
void checkForTimeout();
void timeout();
void slotError(const QString &error);
- void slotTrkLogMessage(const QString &log);
+ void slotCodaLogMessage(const QString &log);
void slotSerialPong(const QString &message);
void slotCodaEvent(const Coda::CodaEvent &event);
@@ -138,7 +120,7 @@ private slots:
void startTransferring();
void deploymentFinished(bool success);
- void slotWaitingForTckTrkClosed(int result);
+ void slotWaitingForCodaClosed(int result);
void showManualInstallationInfo();
void setCopyProgress(int progress);
@@ -204,13 +186,8 @@ private:
QTimer *m_timer;
QTimer* m_timeoutTimer;
- bool m_releaseDeviceAfterLauncherFinish;
- bool m_handleDeviceRemoval;
-
QFutureInterface<bool> *m_futureInterface; //not owned
- trk::Launcher *m_launcher;
-
QSharedPointer<Coda::CodaDevice> m_codaDevice;
QEventLoop *m_eventLoop;
diff --git a/src/plugins/qt4projectmanager/qt-s60/s60devicedebugruncontrol.cpp b/src/plugins/qt4projectmanager/qt-s60/s60devicedebugruncontrol.cpp
index 8844e9dc03..d43a455b5f 100644
--- a/src/plugins/qt4projectmanager/qt-s60/s60devicedebugruncontrol.cpp
+++ b/src/plugins/qt4projectmanager/qt-s60/s60devicedebugruncontrol.cpp
@@ -107,9 +107,7 @@ static Debugger::DebuggerStartParameters s60DebuggerStartParams(const S60DeviceR
Debugger::DebuggerStartParameters::CommunicationChannelTcpIp:
Debugger::DebuggerStartParameters::CommunicationChannelUsb;
- sp.debugClient = activeDeployConf->communicationChannel() == S60DeployConfiguration::CommunicationTrkSerialConnection?
- Debugger::DebuggerStartParameters::SymbianDebugClientTrk:
- Debugger::DebuggerStartParameters::SymbianDebugClientCoda;
+ sp.debugClient = Debugger::DebuggerStartParameters::SymbianDebugClientCoda;
if (const ProjectExplorer::Project *project = rc->target()->project()) {
sp.projectSourceDirectory = project->projectDirectory();
diff --git a/src/plugins/qt4projectmanager/qt-s60/s60runconfigbluetoothstarter.cpp b/src/plugins/qt4projectmanager/qt-s60/s60runconfigbluetoothstarter.cpp
deleted file mode 100644
index ed88c4aa23..0000000000
--- a/src/plugins/qt4projectmanager/qt-s60/s60runconfigbluetoothstarter.cpp
+++ /dev/null
@@ -1,73 +0,0 @@
-/**************************************************************************
-**
-** This file is part of Qt Creator
-**
-** Copyright (c) 2011 Nokia Corporation and/or its subsidiary(-ies).
-**
-** Contact: Nokia Corporation (info@qt.nokia.com)
-**
-**
-** GNU Lesser General Public License Usage
-**
-** This file may be used under the terms of the GNU Lesser General Public
-** License version 2.1 as published by the Free Software Foundation and
-** appearing in the file LICENSE.LGPL included in the packaging of this file.
-** Please review the following information to ensure the GNU Lesser General
-** Public License version 2.1 requirements will be met:
-** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** Other Usage
-**
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at info@qt.nokia.com.
-**
-**************************************************************************/
-
-#include "s60runconfigbluetoothstarter.h"
-#include <symbianutils/bluetoothlistener.h>
-#include <symbianutils/symbiandevicemanager.h>
-#include <symbianutils/trkdevice.h>
-
-#include <coreplugin/icore.h>
-#include <coreplugin/messagemanager.h>
-
-namespace Qt4ProjectManager {
-namespace Internal {
-
-S60RunConfigBluetoothStarter::S60RunConfigBluetoothStarter(const TrkDevicePtr& trkDevice, QObject *parent) :
- trk::AbstractBluetoothStarter(trkDevice, parent)
-{
-}
-
-trk::BluetoothListener *S60RunConfigBluetoothStarter::createListener()
-{
- Core::ICore *core = Core::ICore::instance();
- trk::BluetoothListener *rc = new trk::BluetoothListener(core);
- rc->setMode(trk::BluetoothListener::Listen);
- connect(rc, SIGNAL(message(QString)), core->messageManager(), SLOT(printToOutputPane(QString)));
- return rc;
-}
-
-trk::PromptStartCommunicationResult
-S60RunConfigBluetoothStarter::startCommunication(const TrkDevicePtr &trkDevice,
- QWidget *msgBoxParent,
- QString *errorMessage)
-{
- // Bluetooth?
- if (trkDevice->serialFrame()) {
- BaseCommunicationStarter serialStarter(trkDevice);
- return trk::promptStartSerial(serialStarter, msgBoxParent, errorMessage);
- }
- S60RunConfigBluetoothStarter bluetoothStarter(trkDevice);
- return trk::promptStartBluetooth(bluetoothStarter, msgBoxParent, errorMessage);
-}
-
-} // namespace Internal
-} // namespace Qt4ProjectManager
diff --git a/src/plugins/qt4projectmanager/qt-s60/s60runconfigbluetoothstarter.h b/src/plugins/qt4projectmanager/qt-s60/s60runconfigbluetoothstarter.h
deleted file mode 100644
index 5a87c6a5b5..0000000000
--- a/src/plugins/qt4projectmanager/qt-s60/s60runconfigbluetoothstarter.h
+++ /dev/null
@@ -1,68 +0,0 @@
-/**************************************************************************
-**
-** This file is part of Qt Creator
-**
-** Copyright (c) 2011 Nokia Corporation and/or its subsidiary(-ies).
-**
-** Contact: Nokia Corporation (info@qt.nokia.com)
-**
-**
-** GNU Lesser General Public License Usage
-**
-** This file may be used under the terms of the GNU Lesser General Public
-** License version 2.1 as published by the Free Software Foundation and
-** appearing in the file LICENSE.LGPL included in the packaging of this file.
-** Please review the following information to ensure the GNU Lesser General
-** Public License version 2.1 requirements will be met:
-** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** Other Usage
-**
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at info@qt.nokia.com.
-**
-**************************************************************************/
-
-#ifndef S60RUNCONFIGBLUETOOTHSTARTER_H
-#define S60RUNCONFIGBLUETOOTHSTARTER_H
-
-#include <symbianutils/communicationstarter.h>
-#include <symbianutils/bluetoothlistener_gui.h>
-
-namespace Qt4ProjectManager {
-namespace Internal {
-
-/* S60RunConfigBluetoothStarter: Creates a listener in 'Listen' mode
- * parented on the Qt Creator core which outputs to the message manager.
- * Provides a static convenience to prompt for both connection types. */
-
-class S60RunConfigBluetoothStarter : public trk::AbstractBluetoothStarter
-{
-public:
- typedef trk::AbstractBluetoothStarter::TrkDevicePtr TrkDevicePtr;
-
- // Convenience function to start communication depending on type,
- // passing on the right messages.
- static trk::PromptStartCommunicationResult
- startCommunication(const TrkDevicePtr &trkDevice,
- QWidget *msgBoxParent,
- QString *errorMessage);
-
-protected:
- virtual trk::BluetoothListener *createListener();
-
-private:
- explicit S60RunConfigBluetoothStarter(const TrkDevicePtr& trkDevice, QObject *parent = 0);
-};
-
-} // namespace Internal
-} // namespace Qt4ProjectManager
-
-#endif // S60RUNCONFIGBLUETOOTHSTARTER_H
diff --git a/src/plugins/qt4projectmanager/qt-s60/s60runcontrolfactory.cpp b/src/plugins/qt4projectmanager/qt-s60/s60runcontrolfactory.cpp
index 25602e296e..741541e7d3 100644
--- a/src/plugins/qt4projectmanager/qt-s60/s60runcontrolfactory.cpp
+++ b/src/plugins/qt4projectmanager/qt-s60/s60runcontrolfactory.cpp
@@ -35,7 +35,6 @@
#include "codaruncontrol.h"
#include "s60devicerunconfiguration.h"
#include "s60deployconfiguration.h"
-#include "trkruncontrol.h"
#include "qt4symbiantarget.h"
#include <utils/qtcassert.h>
@@ -72,9 +71,6 @@ RunControl* S60RunControlFactory::create(RunConfiguration *runConfiguration, con
S60DeployConfiguration *activeDeployConf = qobject_cast<S60DeployConfiguration *>(rc->target()->activeDeployConfiguration());
if (!activeDeployConf)
return 0;
-
- if (activeDeployConf->communicationChannel() == S60DeployConfiguration::CommunicationTrkSerialConnection)
- return new TrkRunControl(rc, mode);
return new CodaRunControl(rc, mode);
}
diff --git a/src/plugins/qt4projectmanager/qt-s60/trkruncontrol.cpp b/src/plugins/qt4projectmanager/qt-s60/trkruncontrol.cpp
deleted file mode 100644
index 99503617cd..0000000000
--- a/src/plugins/qt4projectmanager/qt-s60/trkruncontrol.cpp
+++ /dev/null
@@ -1,246 +0,0 @@
-/**************************************************************************
-**
-** This file is part of Qt Creator
-**
-** Copyright (c) 2011 Nokia Corporation and/or its subsidiary(-ies).
-**
-** Contact: Nokia Corporation (info@qt.nokia.com)
-**
-**
-** GNU Lesser General Public License Usage
-**
-** This file may be used under the terms of the GNU Lesser General Public
-** License version 2.1 as published by the Free Software Foundation and
-** appearing in the file LICENSE.LGPL included in the packaging of this file.
-** Please review the following information to ensure the GNU Lesser General
-** Public License version 2.1 requirements will be met:
-** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** Other Usage
-**
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at info@qt.nokia.com.
-**
-**************************************************************************/
-
-#include "trkruncontrol.h"
-
-#include "s60deployconfiguration.h"
-#include "s60devicerunconfiguration.h"
-#include "s60runconfigbluetoothstarter.h"
-
-#include "qt4buildconfiguration.h"
-#include "qt4symbiantarget.h"
-#include "qt4target.h"
-
-#include <symbianutils/bluetoothlistener_gui.h>
-#include <symbianutils/launcher.h>
-#include <symbianutils/symbiandevicemanager.h>
-#include <projectexplorer/projectexplorerconstants.h>
-
-#include <utils/qtcassert.h>
-
-#include <coreplugin/icore.h>
-
-#include <QtGui/QMessageBox>
-#include <QtGui/QMainWindow>
-
-using namespace ProjectExplorer;
-using namespace Qt4ProjectManager;
-using namespace Qt4ProjectManager::Internal;
-
-enum { debug = 0 };
-
-TrkRunControl::TrkRunControl(RunConfiguration *runConfiguration, const QString &mode) :
- S60RunControlBase(runConfiguration, mode),
- m_launcher(0)
-{
- const S60DeviceRunConfiguration *s60runConfig = qobject_cast<S60DeviceRunConfiguration *>(runConfiguration);
- QTC_ASSERT(s60runConfig, return);
- const S60DeployConfiguration *activeDeployConf = qobject_cast<S60DeployConfiguration *>(s60runConfig->target()->activeDeployConfiguration());
- QTC_ASSERT(activeDeployConf, return);
-
- m_serialPortName = activeDeployConf->serialPortName();
- m_serialPortFriendlyName = SymbianUtils::SymbianDeviceManager::instance()->friendlyNameForPort(m_serialPortName);
-}
-
-TrkRunControl::~TrkRunControl()
-{
- if (m_launcher)
- m_launcher->deleteLater();
-}
-
-bool TrkRunControl::doStart()
-{
- if (m_serialPortName.isEmpty()) {
- cancelProgress();
- QString msg = tr("No device is connected. Please connect a device and try again.\n");
- appendMessage(msg, Utils::NormalMessageFormat);
- return false;
- }
-
- appendMessage(tr("Executable file: %1\n").arg(msgListFile(executableFileName())),
- Utils::NormalMessageFormat);
- return true;
-}
-
-bool TrkRunControl::isRunning() const
-{
- return m_launcher && (m_launcher->state() == trk::Launcher::Connecting
- || m_launcher->state() == trk::Launcher::Connected
- || m_launcher->state() == trk::Launcher::WaitingForTrk);
-}
-
-QIcon TrkRunControl::icon() const
-{
- return QIcon(ProjectExplorer::Constants::ICON_DEBUG_SMALL);
-}
-
-bool TrkRunControl::setupLauncher()
-{
- connect(SymbianUtils::SymbianDeviceManager::instance(), SIGNAL(deviceRemoved(const SymbianUtils::SymbianDevice)),
- this, SLOT(deviceRemoved(SymbianUtils::SymbianDevice)));
- QString errorMessage;
- m_launcher = trk::Launcher::acquireFromDeviceManager(m_serialPortName, 0, &errorMessage);
- if (!m_launcher) {
- appendMessage(errorMessage, Utils::ErrorMessageFormat);
- return false;
- }
-
- connect(m_launcher, SIGNAL(finished()), this, SLOT(launcherFinished()));
- connect(m_launcher, SIGNAL(canNotConnect(QString)), this, SLOT(printConnectFailed(QString)));
- connect(m_launcher, SIGNAL(stateChanged(int)), this, SLOT(slotLauncherStateChanged(int)));
- connect(m_launcher, SIGNAL(processStopped(uint,uint,uint,QString)),
- this, SLOT(processStopped(uint,uint,uint,QString)));
-
- if (!commandLineArguments().isEmpty())
- m_launcher->setCommandLineArgs(commandLineArguments());
-
- const QString runFileName = QString::fromLatin1("%1:\\sys\\bin\\%2.exe").arg(installationDrive()).arg(targetName());
- initLauncher(runFileName, m_launcher);
- const trk::PromptStartCommunicationResult src =
- S60RunConfigBluetoothStarter::startCommunication(m_launcher->trkDevice(),
- 0, &errorMessage);
- if (src != trk::PromptStartCommunicationConnected)
- return false;
-
- if (!m_launcher->startServer(&errorMessage)) {
- appendMessage(tr("Could not connect to phone on port '%1': %2\n"
- "Check if the phone is connected and App TRK is running.").arg(m_serialPortName, errorMessage), Utils::ErrorMessageFormat);
- return false;
- }
- return true;
-}
-
-void TrkRunControl::doStop()
-{
- if (m_launcher)
- m_launcher->terminate();
-}
-
-void TrkRunControl::printConnectFailed(const QString &errorMessage)
-{
- appendMessage(tr("Could not connect to App TRK on device: %1. Restarting App TRK might help.\n").arg(errorMessage),
- Utils::ErrorMessageFormat);
-}
-
-void TrkRunControl::launcherFinished()
-{
- trk::Launcher::releaseToDeviceManager(m_launcher);
- m_launcher->deleteLater();
- m_launcher = 0;
- emit finished();
-}
-
-void TrkRunControl::processStopped(uint pc, uint pid, uint tid, const QString &reason)
-{
- appendMessage(trk::Launcher::msgStopped(pid, tid, pc, reason), Utils::StdOutFormat);
- m_launcher->terminate();
-}
-
-QMessageBox *TrkRunControl::createTrkWaitingMessageBox(const QString &port, QWidget *parent)
-{
- const QString title = tr("Waiting for App TRK");
- const QString text = tr("Qt Creator is waiting for the TRK application to connect on %1.<br>"
- "Please make sure the application is running on "
- "your mobile phone and the right port is "
- "configured in the project settings.").arg(port);
- QMessageBox *rc = new QMessageBox(QMessageBox::Information, title, text,
- QMessageBox::Cancel, parent);
- return rc;
-}
-
-void TrkRunControl::slotLauncherStateChanged(int s)
-{
- if (s == trk::Launcher::WaitingForTrk) {
- QMessageBox *mb = TrkRunControl::createTrkWaitingMessageBox(m_launcher->trkServerName(),
- Core::ICore::instance()->mainWindow());
- connect(m_launcher, SIGNAL(stateChanged(int)), mb, SLOT(close()));
- connect(mb, SIGNAL(finished(int)), this, SLOT(slotWaitingForTrkClosed()));
- mb->open();
- }
-}
-
-void TrkRunControl::slotWaitingForTrkClosed()
-{
- if (m_launcher && m_launcher->state() == trk::Launcher::WaitingForTrk) {
- stop();
- appendMessage(tr("Canceled.\n"), Utils::ErrorMessageFormat);
- emit finished();
- }
-}
-
-void TrkRunControl::printApplicationOutput(const QString &output)
-{
- printApplicationOutput(output, false);
-}
-
-void TrkRunControl::printApplicationOutput(const QString &output, bool onStdErr)
-{
- appendMessage(output, onStdErr ? Utils::StdErrFormat : Utils::StdOutFormat);
-}
-
-void TrkRunControl::deviceRemoved(const SymbianUtils::SymbianDevice &d)
-{
- if (m_launcher && d.portName() == m_serialPortName) {
- trk::Launcher::releaseToDeviceManager(m_launcher);
- m_launcher->deleteLater();
- m_launcher = 0;
- QString msg = tr("The device '%1' has been disconnected.\n").arg(d.friendlyName());
- appendMessage(msg, Utils::ErrorMessageFormat);
- emit finished();
- }
-}
-
-void TrkRunControl::initLauncher(const QString &executable, trk::Launcher *launcher)
-{
- connect(launcher, SIGNAL(startingApplication()), this, SLOT(printStartingNotice()));
- connect(launcher, SIGNAL(applicationRunning(uint)), this, SLOT(applicationRunNotice(uint)));
- connect(launcher, SIGNAL(canNotRun(QString)), this, SLOT(applicationRunFailedNotice(QString)));
- connect(launcher, SIGNAL(applicationOutputReceived(QString)), this, SLOT(printApplicationOutput(QString)));
- launcher->addStartupActions(trk::Launcher::ActionRun);
- launcher->setFileName(executable);
-}
-
-void TrkRunControl::printStartingNotice()
-{
- appendMessage(tr("Starting application...\n"), Utils::NormalMessageFormat);
-}
-
-void TrkRunControl::applicationRunNotice(uint pid)
-{
- appendMessage(tr("Application running with pid %1.\n").arg(pid), Utils::NormalMessageFormat);
- setProgress(maxProgress());
-}
-
-void TrkRunControl::applicationRunFailedNotice(const QString &errorMessage)
-{
- appendMessage(tr("Could not start application: %1\n").arg(errorMessage), Utils::NormalMessageFormat);
-}
diff --git a/src/plugins/qt4projectmanager/qt-s60/trkruncontrol.h b/src/plugins/qt4projectmanager/qt-s60/trkruncontrol.h
deleted file mode 100644
index 47a8edb249..0000000000
--- a/src/plugins/qt4projectmanager/qt-s60/trkruncontrol.h
+++ /dev/null
@@ -1,99 +0,0 @@
-/**************************************************************************
-**
-** This file is part of Qt Creator
-**
-** Copyright (c) 2011 Nokia Corporation and/or its subsidiary(-ies).
-**
-** Contact: Nokia Corporation (info@qt.nokia.com)
-**
-**
-** GNU Lesser General Public License Usage
-**
-** This file may be used under the terms of the GNU Lesser General Public
-** License version 2.1 as published by the Free Software Foundation and
-** appearing in the file LICENSE.LGPL included in the packaging of this file.
-** Please review the following information to ensure the GNU Lesser General
-** Public License version 2.1 requirements will be met:
-** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** Other Usage
-**
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at info@qt.nokia.com.
-**
-**************************************************************************/
-
-#ifndef TRKRUNCONTROL_H
-#define TRKRUNCONTROL_H
-
-#include "s60runcontrolbase.h"
-
-QT_BEGIN_NAMESPACE
-class QMessageBox;
-class QWidget;
-QT_END_NAMESPACE
-
-namespace SymbianUtils {
-class SymbianDevice;
-}
-
-namespace trk {
-class Launcher;
-}
-
-namespace Qt4ProjectManager {
-namespace Internal {
-
-// TrkRunControl configures launcher to run the application
-class TrkRunControl : public S60RunControlBase
-{
- Q_OBJECT
-public:
- TrkRunControl(ProjectExplorer::RunConfiguration *runConfiguration, const QString &mode);
- ~TrkRunControl();
- virtual bool isRunning() const;
- virtual QIcon icon() const;
-
- static QMessageBox *createTrkWaitingMessageBox(const QString &port, QWidget *parent = 0);
-
-protected:
- virtual bool doStart();
- virtual void doStop();
- virtual bool setupLauncher();
- virtual void initLauncher(const QString &executable, trk::Launcher *);
-
-protected slots:
- void printApplicationOutput(const QString &output, bool onStdErr);
- void printApplicationOutput(const QString &output);
- void printStartingNotice();
- void applicationRunNotice(uint pid);
- void applicationRunFailedNotice(const QString &errorMessage);
- void deviceRemoved(const SymbianUtils::SymbianDevice &);
-
-private slots:
- void processStopped(uint pc, uint pid, uint tid, const QString &reason);
- void printConnectFailed(const QString &errorMessage);
- void launcherFinished();
- void slotLauncherStateChanged(int);
- void slotWaitingForTrkClosed();
-
-private:
- void initCommunication();
-
-private:
- trk::Launcher *m_launcher;
- QString m_serialPortName;
- QString m_serialPortFriendlyName;
-};
-
-} // namespace Internal
-} // namespace Qt4ProjectManager
-
-#endif // TRKRUNCONTROL_H
diff --git a/src/shared/symbianutils/bluetoothlistener.cpp b/src/shared/symbianutils/bluetoothlistener.cpp
deleted file mode 100644
index c7e12e1f9f..0000000000
--- a/src/shared/symbianutils/bluetoothlistener.cpp
+++ /dev/null
@@ -1,215 +0,0 @@
-/**************************************************************************
-**
-** This file is part of Qt Creator
-**
-** Copyright (c) 2011 Nokia Corporation and/or its subsidiary(-ies).
-**
-** Contact: Nokia Corporation (info@qt.nokia.com)
-**
-**
-** GNU Lesser General Public License Usage
-**
-** This file may be used under the terms of the GNU Lesser General Public
-** License version 2.1 as published by the Free Software Foundation and
-** appearing in the file LICENSE.LGPL included in the packaging of this file.
-** Please review the following information to ensure the GNU Lesser General
-** Public License version 2.1 requirements will be met:
-** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** Other Usage
-**
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at info@qt.nokia.com.
-**
-**************************************************************************/
-
-#include "bluetoothlistener.h"
-#include "trkdevice.h"
-
-#include <QtCore/QDebug>
-
-#ifdef Q_OS_UNIX
-# include <unistd.h>
-# include <signal.h>
-#else
-# include <windows.h>
-#endif
-
-// Process id helpers.
-#ifdef Q_OS_WIN
-inline DWORD processId(const QProcess &p)
-{
- if (const Q_PID processInfoStruct = p.pid())
- return processInfoStruct->dwProcessId;
- return 0;
-}
-#else
-inline Q_PID processId(const QProcess &p)
-{
- return p.pid();
-}
-#endif
-
-
-enum { debug = 0 };
-
-namespace trk {
-
-struct BluetoothListenerPrivate {
- BluetoothListenerPrivate();
- QString device;
- QProcess process;
-#ifdef Q_OS_WIN
- DWORD pid;
-#else
- Q_PID pid;
-#endif
- bool printConsoleMessages;
- BluetoothListener::Mode mode;
-};
-
-BluetoothListenerPrivate::BluetoothListenerPrivate() :
- pid(0),
- printConsoleMessages(false),
- mode(BluetoothListener::Listen)
-{
-}
-
-BluetoothListener::BluetoothListener(QObject *parent) :
- QObject(parent),
- d(new BluetoothListenerPrivate)
-{
- d->process.setProcessChannelMode(QProcess::MergedChannels);
-
- connect(&d->process, SIGNAL(readyReadStandardError()),
- this, SLOT(slotStdError()));
- connect(&d->process, SIGNAL(readyReadStandardOutput()),
- this, SLOT(slotStdOutput()));
- connect(&d->process, SIGNAL(finished(int, QProcess::ExitStatus)),
- this, SLOT(slotProcessFinished(int,QProcess::ExitStatus)));
- connect(&d->process, SIGNAL(error(QProcess::ProcessError)),
- this, SLOT(slotProcessError(QProcess::ProcessError)));
-}
-
-BluetoothListener::~BluetoothListener()
-{
- const int trc = terminateProcess();
- if (debug)
- qDebug() << "~BluetoothListener: terminated" << trc;
- delete d;
-}
-
-BluetoothListener::Mode BluetoothListener::mode() const
-{
- return d->mode;
-}
-
-void BluetoothListener::setMode(Mode m)
-{
- d->mode = m;
-}
-
-bool BluetoothListener::printConsoleMessages() const
-{
- return d->printConsoleMessages;
-}
-
-void BluetoothListener::setPrintConsoleMessages(bool p)
-{
- d->printConsoleMessages = p;
-}
-
-int BluetoothListener::terminateProcess()
-{
- enum { TimeOutMS = 200 };
- if (debug)
- qDebug() << "terminateProcess" << d->process.pid() << d->process.state();
- if (d->process.state() == QProcess::NotRunning)
- return -1;
- emitMessage(tr("%1: Stopping listener %2...").arg(d->device).arg(processId(d->process)));
- // When listening, the process should terminate by itself after closing the connection
- if (mode() == Listen && d->process.waitForFinished(TimeOutMS))
- return 0;
-#ifdef Q_OS_UNIX
- kill(d->process.pid(), SIGHUP); // Listens for SIGHUP
- if (d->process.waitForFinished(TimeOutMS))
- return 1;
-#endif
- d->process.terminate();
- if (d->process.waitForFinished(TimeOutMS))
- return 2;
- d->process.kill();
- return 3;
-}
-
-bool BluetoothListener::start(const QString &device, QString *errorMessage)
-{
- if (d->process.state() != QProcess::NotRunning) {
- *errorMessage = QLatin1String("Internal error: Still running.");
- return false;
- }
- d->device = device;
- const QString binary = QLatin1String("rfcomm");
- QStringList arguments;
- arguments << QLatin1String("-r")
- << (d->mode == Listen ? QLatin1String("listen") : QLatin1String("watch"))
- << device << QString(QLatin1Char('1'));
- if (debug)
- qDebug() << binary << arguments;
- emitMessage(tr("%1: Starting Bluetooth listener %2...").arg(device, binary));
- d->pid = 0;
- d->process.start(binary, arguments);
- if (!d->process.waitForStarted()) {
- *errorMessage = tr("Unable to run '%1': %2").arg(binary, d->process.errorString());
- return false;
- }
- d->pid = processId(d->process); // Forgets it after crash/termination
- emitMessage(tr("%1: Bluetooth listener running (%2).").arg(device).arg(processId(d->process)));
- return true;
-}
-
-void BluetoothListener::slotStdOutput()
-{
- emitMessage(QString::fromLocal8Bit(d->process.readAllStandardOutput()));
-}
-
-void BluetoothListener::emitMessage(const QString &m)
-{
- if (d->printConsoleMessages || debug)
- qDebug("%s\n", qPrintable(m));
- emit message(m);
-}
-
-void BluetoothListener::slotStdError()
-{
- emitMessage(QString::fromLocal8Bit(d->process.readAllStandardError()));
-}
-
-void BluetoothListener::slotProcessFinished(int ex, QProcess::ExitStatus state)
-{
- switch (state) {
- case QProcess::NormalExit:
- emitMessage(tr("%1: Process %2 terminated with exit code %3.")
- .arg(d->device).arg(d->pid).arg(ex));
- break;
- case QProcess::CrashExit:
- emitMessage(tr("%1: Process %2 crashed.").arg(d->device).arg(d->pid));
- break;
- }
- emit terminated();
-}
-
-void BluetoothListener::slotProcessError(QProcess::ProcessError error)
-{
- emitMessage(tr("%1: Process error %2: %3")
- .arg(d->device).arg(error).arg(d->process.errorString()));
-}
-
-} // namespace trk
diff --git a/src/shared/symbianutils/bluetoothlistener.h b/src/shared/symbianutils/bluetoothlistener.h
deleted file mode 100644
index 8a86b8c759..0000000000
--- a/src/shared/symbianutils/bluetoothlistener.h
+++ /dev/null
@@ -1,94 +0,0 @@
-/**************************************************************************
-**
-** This file is part of Qt Creator
-**
-** Copyright (c) 2011 Nokia Corporation and/or its subsidiary(-ies).
-**
-** Contact: Nokia Corporation (info@qt.nokia.com)
-**
-**
-** GNU Lesser General Public License Usage
-**
-** This file may be used under the terms of the GNU Lesser General Public
-** License version 2.1 as published by the Free Software Foundation and
-** appearing in the file LICENSE.LGPL included in the packaging of this file.
-** Please review the following information to ensure the GNU Lesser General
-** Public License version 2.1 requirements will be met:
-** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** Other Usage
-**
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at info@qt.nokia.com.
-**
-**************************************************************************/
-
-#ifndef BLUETOOTHLISTENER_H
-#define BLUETOOTHLISTENER_H
-
-#include "symbianutils_global.h"
-
-#include <QtCore/QObject>
-#include <QtCore/QProcess>
-
-namespace trk {
-struct BluetoothListenerPrivate;
-
-/* BluetoothListener: Starts a helper process watching connections on a
- * Bluetooth device, Linux only:
- * The rfcomm command is used. It process can be started in the background
- * while connection attempts (TrkDevice::open()) are made in the foreground. */
-
-class SYMBIANUTILS_EXPORT BluetoothListener : public QObject
-{
- Q_OBJECT
- Q_DISABLE_COPY(BluetoothListener)
-public:
- // The Mode property must be set before calling start().
- enum Mode {
- Listen, /* Terminate after client closed (read: Trk app
- * on the phone terminated or disconnected).*/
- Watch // Keep running, watch for next connection from client
- };
-
- explicit BluetoothListener(QObject *parent = 0);
- virtual ~BluetoothListener();
-
- Mode mode() const;
- void setMode(Mode m);
-
- bool start(const QString &device, QString *errorMessage);
-
- // Print messages on the console.
- bool printConsoleMessages() const;
- void setPrintConsoleMessages(bool p);
-
-signals:
- void terminated();
- void message(const QString &);
-
-public slots:
- void emitMessage(const QString &m); // accessed by starter
-
-private slots:
- void slotStdOutput();
- void slotStdError();
- void slotProcessFinished(int, QProcess::ExitStatus);
- void slotProcessError(QProcess::ProcessError error);
-
-private:
- int terminateProcess();
-
- BluetoothListenerPrivate *d;
-};
-
-} // namespace trk
-
-#endif // BLUETOOTHLISTENER_H
diff --git a/src/shared/symbianutils/bluetoothlistener_gui.cpp b/src/shared/symbianutils/bluetoothlistener_gui.cpp
deleted file mode 100644
index 07fe5e3646..0000000000
--- a/src/shared/symbianutils/bluetoothlistener_gui.cpp
+++ /dev/null
@@ -1,102 +0,0 @@
-/**************************************************************************
-**
-** This file is part of Qt Creator
-**
-** Copyright (c) 2011 Nokia Corporation and/or its subsidiary(-ies).
-**
-** Contact: Nokia Corporation (info@qt.nokia.com)
-**
-**
-** GNU Lesser General Public License Usage
-**
-** This file may be used under the terms of the GNU Lesser General Public
-** License version 2.1 as published by the Free Software Foundation and
-** appearing in the file LICENSE.LGPL included in the packaging of this file.
-** Please review the following information to ensure the GNU Lesser General
-** Public License version 2.1 requirements will be met:
-** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** Other Usage
-**
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at info@qt.nokia.com.
-**
-**************************************************************************/
-
-#include "bluetoothlistener_gui.h"
-#include "bluetoothlistener.h"
-#include "communicationstarter.h"
-
-#include <QtGui/QMessageBox>
-#include <QtGui/QPushButton>
-#include <QtCore/QCoreApplication>
-#include <QtCore/QDebug>
-
-namespace trk {
-
-SYMBIANUTILS_EXPORT PromptStartCommunicationResult
- promptStartCommunication(BaseCommunicationStarter &starter,
- const QString &msgBoxTitle,
- const QString &msgBoxText,
- QWidget *msgBoxParent,
- QString *errorMessage)
-{
- errorMessage->clear();
- // Initial connection attempt.
- switch (starter.start()) {
- case BaseCommunicationStarter::Started:
- break;
- case BaseCommunicationStarter::ConnectionSucceeded:
- return PromptStartCommunicationConnected;
- case BaseCommunicationStarter::StartError:
- *errorMessage = starter.errorString();
- return PromptStartCommunicationError;
- }
- // Run the starter with the event loop of a message box, have the box
- // closed by the signals of the starter.
- QMessageBox messageBox(QMessageBox::Information, msgBoxTitle, msgBoxText, QMessageBox::Cancel, msgBoxParent);
- QObject::connect(&starter, SIGNAL(connected()), &messageBox, SLOT(close()));
- QObject::connect(&starter, SIGNAL(timeout()), &messageBox, SLOT(close()));
- messageBox.exec();
- // Only starter.state() is reliable here to obtain the state.
- switch (starter.state()) {
- case AbstractBluetoothStarter::Running:
- *errorMessage = QCoreApplication::translate("trk::promptStartCommunication", "Connection on %1 canceled.").arg(starter.device());
- return PromptStartCommunicationCanceled;
- case AbstractBluetoothStarter::TimedOut:
- *errorMessage = starter.errorString();
- return PromptStartCommunicationError;
- case AbstractBluetoothStarter::Connected:
- break;
- }
- return PromptStartCommunicationConnected;
-}
-
-SYMBIANUTILS_EXPORT PromptStartCommunicationResult
- promptStartSerial(BaseCommunicationStarter &starter,
- QWidget *msgBoxParent,
- QString *errorMessage)
-{
- const QString title = QCoreApplication::translate("trk::promptStartCommunication", "Waiting for App TRK");
- const QString message = QCoreApplication::translate("trk::promptStartCommunication", "Waiting for App TRK to start on %1...").arg(starter.device());
- return promptStartCommunication(starter, title, message, msgBoxParent, errorMessage);
-}
-
-SYMBIANUTILS_EXPORT PromptStartCommunicationResult
- promptStartBluetooth(BaseCommunicationStarter &starter,
- QWidget *msgBoxParent,
- QString *errorMessage)
-{
- const QString title = QCoreApplication::translate("trk::promptStartCommunication", "Waiting for Bluetooth Connection");
- const QString message = QCoreApplication::translate("trk::promptStartCommunication", "Connecting to %1...").arg(starter.device());
- return promptStartCommunication(starter, title, message, msgBoxParent, errorMessage);
-}
-
-} // namespace trk
diff --git a/src/shared/symbianutils/bluetoothlistener_gui.h b/src/shared/symbianutils/bluetoothlistener_gui.h
deleted file mode 100644
index b0211d3bb7..0000000000
--- a/src/shared/symbianutils/bluetoothlistener_gui.h
+++ /dev/null
@@ -1,80 +0,0 @@
-/**************************************************************************
-**
-** This file is part of Qt Creator
-**
-** Copyright (c) 2011 Nokia Corporation and/or its subsidiary(-ies).
-**
-** Contact: Nokia Corporation (info@qt.nokia.com)
-**
-**
-** GNU Lesser General Public License Usage
-**
-** This file may be used under the terms of the GNU Lesser General Public
-** License version 2.1 as published by the Free Software Foundation and
-** appearing in the file LICENSE.LGPL included in the packaging of this file.
-** Please review the following information to ensure the GNU Lesser General
-** Public License version 2.1 requirements will be met:
-** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** Other Usage
-**
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at info@qt.nokia.com.
-**
-**************************************************************************/
-
-#ifndef BLUETOOTHLISTENER_GUI_H
-#define BLUETOOTHLISTENER_GUI_H
-
-#include "symbianutils_global.h"
-
-#include <QtCore/QtGlobal>
-
-QT_BEGIN_NAMESPACE
-class QWidget;
-QT_END_NAMESPACE
-
-namespace trk {
-class BaseCommunicationStarter;
-
-/* promptStartCommunication(): Convenience functions that
- * prompt the user to start a communication (launching or
- * connecting TRK) using a modal message box in which they can cancel.
- * Pass in the starter with device and parameters set up. */
-
-enum PromptStartCommunicationResult {
- PromptStartCommunicationConnected,
- PromptStartCommunicationCanceled,
- PromptStartCommunicationError
-};
-
-SYMBIANUTILS_EXPORT PromptStartCommunicationResult
- promptStartCommunication(BaseCommunicationStarter &starter,
- const QString &msgBoxTitle,
- const QString &msgBoxText,
- QWidget *msgBoxParent,
- QString *errorMessage);
-
-// Convenience to start a serial connection (messages prompting
-// to launch Trk).
-SYMBIANUTILS_EXPORT PromptStartCommunicationResult
- promptStartSerial(BaseCommunicationStarter &starter,
- QWidget *msgBoxParent,
- QString *errorMessage);
-
-// Convenience to start blue tooth connection (messages
-// prompting to connect).
-SYMBIANUTILS_EXPORT PromptStartCommunicationResult
- promptStartBluetooth(BaseCommunicationStarter &starter,
- QWidget *msgBoxParent,
- QString *errorMessage);
-} // namespace trk
-
-#endif // BLUETOOTHLISTENER_GUI_H
diff --git a/src/shared/symbianutils/callback.h b/src/shared/symbianutils/callback.h
index 89c9bf193b..4f46c48de9 100644
--- a/src/shared/symbianutils/callback.h
+++ b/src/shared/symbianutils/callback.h
@@ -35,7 +35,7 @@
#include "symbianutils_global.h"
-namespace trk {
+namespace Coda {
namespace Internal {
/* Helper class for the 1-argument functor:
@@ -146,6 +146,6 @@ private:
Internal::CallbackImplBase<Argument> *m_impl;
};
-} // namespace trk
+} // namespace Coda
#endif // DEBUGGER_CALLBACK_H
diff --git a/src/shared/symbianutils/codadevice.cpp b/src/shared/symbianutils/codadevice.cpp
index 02dec9e1db..30226fc64d 100644
--- a/src/shared/symbianutils/codadevice.cpp
+++ b/src/shared/symbianutils/codadevice.cpp
@@ -32,7 +32,7 @@
#include "codadevice.h"
#include "json.h"
-#include "trkutils.h"
+#include "codautils.h"
#include <QtNetwork/QAbstractSocket>
#include <QtCore/QDebug>
@@ -71,7 +71,7 @@ static inline void encodeSerialFrame(const QByteArray &data, QByteArray *target,
{
target->append(char(0x01));
target->append(protocolId);
- appendShort(target, ushort(data.size()), trk::BigEndian);
+ appendShort(target, ushort(data.size()), Coda::BigEndian);
target->append(data);
}
@@ -465,7 +465,7 @@ void CodaDevice::slotDeviceReadyRead()
const QByteArray newData = d->m_device->readAll();
d->m_readBuffer += newData;
if (debug)
- qDebug("ReadBuffer: %s", qPrintable(trk::stringFromArray(newData)));
+ qDebug("ReadBuffer: %s", qPrintable(Coda::stringFromArray(newData)));
if (d->m_serialFrame) {
deviceReadyReadSerial();
} else {
@@ -484,11 +484,11 @@ QPair<int, int> CodaDevice::findSerialHeader(QByteArray &in)
while (in.size() >= 4) {
if (in.at(0) == header1 && in.at(1) == codaProtocolId) {
// Good packet
- const int length = trk::extractShort(in.constData() + 2);
+ const int length = Coda::extractShort(in.constData() + 2);
return QPair<int, int>(4, length);
} else if (in.at(0) == header1 && in.at(1) >= validProtocolIdStart && in.at(1) <= validProtocolIdEnd) {
// We recognise it but it's not a CODA message - emit it for any interested party to handle
- const int length = trk::extractShort(in.constData() + 2);
+ const int length = Coda::extractShort(in.constData() + 2);
if (4 + length <= in.size()) {
// We have all the data
QByteArray data(in.mid(4, length));
@@ -505,7 +505,7 @@ QPair<int, int> CodaDevice::findSerialHeader(QByteArray &in)
int nextHeader = in.indexOf(header1, 1);
QByteArray bad = in.mid(0, nextHeader);
qWarning("Bogus data received on serial line: %s\n"
- "Frame Header at: %d", qPrintable(trk::stringFromArray(bad)), nextHeader);
+ "Frame Header at: %d", qPrintable(Coda::stringFromArray(bad)), nextHeader);
in.remove(0, bad.length());
// and continue
}
@@ -533,7 +533,7 @@ void CodaDevice::deviceReadyReadSerial()
void CodaDevice::processSerialMessage(const QByteArray &message)
{
if (debug > 1)
- qDebug("Serial message: %s",qPrintable(trk::stringFromArray(message)));
+ qDebug("Serial message: %s",qPrintable(Coda::stringFromArray(message)));
if (message.isEmpty())
return;
// Is thing a ping/pong response
diff --git a/src/shared/symbianutils/codadevice.h b/src/shared/symbianutils/codadevice.h
index 9a12c579c5..8bcace8070 100644
--- a/src/shared/symbianutils/codadevice.h
+++ b/src/shared/symbianutils/codadevice.h
@@ -56,7 +56,7 @@ struct CodaDevicePrivate;
struct Breakpoint;
/* Command error handling in CODA:
- * 1) 'Severe' errors (JSON format, parameter format): Trk emits a
+ * 1) 'Severe' errors (JSON format, parameter format): Coda emits a
* nonstandard message (\3\2 error parameters) and closes the connection.
* 2) Protocol errors: 'N' without error message is returned.
* 3) Errors in command execution: 'R' with a CODA error hash is returned
@@ -121,7 +121,7 @@ struct SYMBIANUTILS_EXPORT CodaStatResponse
QDateTime accessTime;
};
-typedef trk::Callback<const CodaCommandResult &> CodaCallback;
+typedef Coda::Callback<const CodaCommandResult &> CodaCallback;
/* CodaDevice: CODA communication helper using an asynchronous QIODevice
* implementing the CODA protocol according to:
diff --git a/src/shared/symbianutils/codamessage.h b/src/shared/symbianutils/codamessage.h
index c4f8ab7e14..fc0eb7a2a4 100644
--- a/src/shared/symbianutils/codamessage.h
+++ b/src/shared/symbianutils/codamessage.h
@@ -30,8 +30,8 @@
**
**************************************************************************/
-#ifndef TRCFTRKMESSAGE_H
-#define TRCFTRKMESSAGE_H
+#ifndef CODAMESSAGE_H
+#define CODAMESSAGE_H
#include "symbianutils_global.h"
@@ -52,13 +52,13 @@ enum Services {
RunControlService,
ProcessesService,
MemoryService,
- SettingsService, // non-standard, trk specific
+ SettingsService, // non-standard, CODA specific
BreakpointsService,
RegistersService,
- LoggingService, // non-standard, trk specific
+ LoggingService, // non-standard, CODA specific
FileSystemService,
- SymbianInstallService, // non-standard, trk specific
- SymbianOSData, // non-standard, trk specific
+ SymbianInstallService, // non-standard, CODA specific
+ SymbianOSData, // non-standard, CODA specific
UnknownService
}; // Note: Check string array 'serviceNamesC' of same size when modifying this.
@@ -196,7 +196,7 @@ private:
QStringList m_services;
};
-// Logging event (non-standard, trk specific)
+// Logging event (non-standard, CODA specific)
class SYMBIANUTILS_EXPORT CodaLoggingWriteEvent : public CodaEvent {
public:
explicit CodaLoggingWriteEvent(const QByteArray &console, const QByteArray &message);
@@ -306,4 +306,4 @@ private:
};
} // namespace Coda
-#endif // TRCFTRKMESSAGE_H
+#endif // CODAMESSAGE_H
diff --git a/src/shared/symbianutils/trkutils.cpp b/src/shared/symbianutils/codautils.cpp
index 1c74af68de..63b91c8090 100644
--- a/src/shared/symbianutils/trkutils.cpp
+++ b/src/shared/symbianutils/codautils.cpp
@@ -30,7 +30,7 @@
**
**************************************************************************/
-#include "trkutils.h"
+#include "codautils.h"
#include <ctype.h>
#include <QtCore/QCoreApplication>
@@ -39,18 +39,18 @@
#include <QtCore/QDateTime>
#include <QtCore/QTime>
-#define logMessage(s) do { qDebug() << "TRKCLIENT: " << s; } while (0)
+#define logMessage(s) do { qDebug() << "CODACLIENT: " << s; } while (0)
-namespace trk {
+namespace Coda {
Library::Library() : codeseg(0), dataseg(0), pid(0)
{
}
-Library::Library(const TrkResult &result) : codeseg(0), dataseg(0), pid(0)
+Library::Library(const CodaResult &result) : codeseg(0), dataseg(0), pid(0)
{
if (result.data.size() < 20) {
- qWarning("Invalid trk creation notification received.");
+ qWarning("Invalid CODA creation notification received.");
return;
}
@@ -62,14 +62,14 @@ Library::Library(const TrkResult &result) : codeseg(0), dataseg(0), pid(0)
name = result.data.mid(20, len);
}
-TrkAppVersion::TrkAppVersion()
+CodaAppVersion::CodaAppVersion()
{
reset();
}
-void TrkAppVersion::reset()
+void CodaAppVersion::reset()
{
- trkMajor = trkMinor= protocolMajor = protocolMinor = 0;
+ codaMajor = codaMinor = protocolMajor = protocolMinor = 0;
}
Session::Session()
@@ -93,7 +93,7 @@ void Session::reset()
dataseg = 0;
libraries.clear();
- trkAppVersion.reset();
+ codaAppVersion.reset();
}
static QString formatCpu(int major, int minor)
@@ -101,7 +101,7 @@ static QString formatCpu(int major, int minor)
//: CPU description of an S60 device
//: %1 major verison, %2 minor version
//: %3 real name of major verison, %4 real name of minor version
- const QString str = QCoreApplication::translate("trk::Session", "CPU: v%1.%2%3%4");
+ const QString str = QCoreApplication::translate("Coda::Session", "CPU: v%1.%2%3%4");
QString majorStr;
QString minorStr;
switch (major) {
@@ -117,11 +117,11 @@ static QString formatCpu(int major, int minor)
return str.arg(major).arg(minor).arg(majorStr).arg(minorStr);
}
-QString formatTrkVersion(const TrkAppVersion &version)
+QString formatCodaVersion(const CodaAppVersion &version)
{
- QString str = QCoreApplication::translate("trk::Session",
- "App TRK: v%1.%2 TRK protocol: v%3.%4");
- str = str.arg(version.trkMajor).arg(version.trkMinor);
+ QString str = QCoreApplication::translate("Coda::Session",
+ "CODA: v%1.%2 CODA protocol: v%3.%4");
+ str = str.arg(version.codaMajor).arg(version.codaMinor);
return str.arg(version.protocolMajor).arg(version.protocolMinor);
}
@@ -134,22 +134,22 @@ QString Session::deviceDescription(unsigned verbose) const
//: description of an S60 device
//: %1 CPU description, %2 endianness
//: %3 default type size (if any), %4 float size (if any)
- //: %5 TRK version
- QString msg = QCoreApplication::translate("trk::Session", "%1, %2%3%4, %5");
+ //: %5 Coda version
+ QString msg = QCoreApplication::translate("Coda::Session", "%1, %2%3%4, %5");
QString endianness = bigEndian
- ? QCoreApplication::translate("trk::Session", "big endian")
- : QCoreApplication::translate("trk::Session", "little endian");
+ ? QCoreApplication::translate("Coda::Session", "big endian")
+ : QCoreApplication::translate("Coda::Session", "little endian");
msg = msg.arg(formatCpu(cpuMajor, cpuMinor)).arg(endianness);
QString defaultTypeSizeStr;
QString fpTypeSizeStr;
if (verbose && defaultTypeSize)
//: will be inserted into s60description
- defaultTypeSizeStr = QCoreApplication::translate("trk::Session", ", type size: %1").arg(defaultTypeSize);
+ defaultTypeSizeStr = QCoreApplication::translate("Coda::Session", ", type size: %1").arg(defaultTypeSize);
if (verbose && fpTypeSize)
//: will be inserted into s60description
- fpTypeSizeStr = QCoreApplication::translate("trk::Session", ", float size: %1").arg(fpTypeSize);
+ fpTypeSizeStr = QCoreApplication::translate("Coda::Session", ", float size: %1").arg(fpTypeSize);
msg = msg.arg(defaultTypeSizeStr).arg(fpTypeSizeStr);
- return msg.arg(formatTrkVersion(trkAppVersion));
+ return msg.arg(formatCodaVersion(codaAppVersion));
}
QByteArray Session::gdbLibraryList() const
@@ -157,18 +157,18 @@ QByteArray Session::gdbLibraryList() const
const int count = libraries.size();
QByteArray response = "l<library-list>";
for (int i = 0; i != count; ++i) {
- const trk::Library &lib = libraries.at(i);
+ const Coda::Library &lib = libraries.at(i);
response += "<library name=\"";
response += lib.name;
response += "\">";
response += "<section address=\"0x";
- response += trk::hexNumber(lib.codeseg);
+ response += Coda::hexNumber(lib.codeseg);
response += "\"/>";
response += "<section address=\"0x";
- response += trk::hexNumber(lib.dataseg);
+ response += Coda::hexNumber(lib.dataseg);
response += "\"/>";
response += "<section address=\"0x";
- response += trk::hexNumber(lib.dataseg);
+ response += Coda::hexNumber(lib.dataseg);
response += "\"/>";
response += "</library>";
}
@@ -305,14 +305,14 @@ SYMBIANUTILS_EXPORT QByteArray hexxNumber(uint n, int digits)
return "0x" + hexNumber(n, digits);
}
-TrkResult::TrkResult() :
+CodaResult::CodaResult() :
code(0),
token(0),
isDebugOutput(false)
{
}
-void TrkResult::clear()
+void CodaResult::clear()
{
code = token= 0;
isDebugOutput = false;
@@ -320,7 +320,7 @@ void TrkResult::clear()
cookie = QVariant();
}
-QString TrkResult::toString() const
+QString CodaResult::toString() const
{
QString res = stringFromByte(code);
res += QLatin1String(" [");
@@ -366,7 +366,7 @@ QByteArray frameMessage(byte command, byte token, const QByteArray &data, bool s
/* returns 0 if array doesn't represent a result,
otherwise returns the length of the result data */
-ushort isValidTrkResult(const QByteArray &buffer, bool serialFrame, ushort& mux)
+ushort isValidCodaResult(const QByteArray &buffer, bool serialFrame, ushort& mux)
{
if (serialFrame) {
// Serial protocol with length info
@@ -381,7 +381,7 @@ ushort isValidTrkResult(const QByteArray &buffer, bool serialFrame, ushort& mux)
const int firstDelimiterPos = buffer.indexOf(delimiter);
// Regular message delimited by 0x7e..0x7e
if (firstDelimiterPos == 0) {
- mux = MuxTrk;
+ mux = MuxCoda;
const int endPos = buffer.indexOf(delimiter, firstDelimiterPos + 1);
return endPos != -1 ? endPos + 1 - firstDelimiterPos : 0;
}
@@ -389,22 +389,22 @@ ushort isValidTrkResult(const QByteArray &buffer, bool serialFrame, ushort& mux)
return firstDelimiterPos != -1 ? firstDelimiterPos : buffer.size();
}
-bool extractResult(QByteArray *buffer, bool serialFrame, TrkResult *result, bool &linkEstablishmentMode, QByteArray *rawData)
+bool extractResult(QByteArray *buffer, bool serialFrame, CodaResult *result, bool &linkEstablishmentMode, QByteArray *rawData)
{
result->clear();
if(rawData)
rawData->clear();
- ushort len = isValidTrkResult(*buffer, serialFrame, result->multiplex);
+ ushort len = isValidCodaResult(*buffer, serialFrame, result->multiplex);
// handle receiving application output, which is not a regular command
const int delimiterPos = serialFrame ? 4 : 0;
if (linkEstablishmentMode) {
//when "hot connecting" a device, we can receive partial frames.
- //this code resyncs by discarding data until a TRK frame is found
+ //this code resyncs by discarding data until a CODA frame is found
while (buffer->length() > delimiterPos
&& result->multiplex != MuxTextTrace
- && !(result->multiplex == MuxTrk && buffer->at(delimiterPos) == 0x7e)) {
+ && !(result->multiplex == MuxCoda && buffer->at(delimiterPos) == 0x7e)) {
buffer->remove(0,1);
- len = isValidTrkResult(*buffer, serialFrame, result->multiplex);
+ len = isValidCodaResult(*buffer, serialFrame, result->multiplex);
}
}
if (!len)
@@ -435,7 +435,7 @@ bool extractResult(QByteArray *buffer, bool serialFrame, TrkResult *result, bool
//logMessage(" CURR DATA: " << stringFromArray(data));
//QByteArray prefix = "READ BUF: ";
//logMessage((prefix + "HEADER: " + stringFromArray(header).toLatin1()).data());
- linkEstablishmentMode = false; //have received a good TRK packet, therefore in sync
+ linkEstablishmentMode = false; //have received a good CODA packet, therefore in sync
return true;
}
@@ -568,7 +568,7 @@ uint swapEndian(uint in)
return (in>>24) | ((in<<8) & 0x00FF0000) | ((in>>8) & 0x0000FF00) | (in<<24);
}
-int TrkResult::errorCode() const
+int CodaResult::errorCode() const
{
// NAK means always error, else data sized 1 with a non-null element
const bool isNAK = code == 0xff;
@@ -579,7 +579,7 @@ int TrkResult::errorCode() const
return isNAK ? 0xff : 0;
}
-QString TrkResult::errorString() const
+QString CodaResult::errorString() const
{
// NAK means always error, else data sized 1 with a non-null element
if (code == 0xff)
@@ -589,5 +589,5 @@ QString TrkResult::errorString() const
return errorMessage(data.at(0));
}
-} // namespace trk
+} // namespace Coda
diff --git a/src/shared/symbianutils/trkutils.h b/src/shared/symbianutils/codautils.h
index 93f44cb9f2..e400d9821c 100644
--- a/src/shared/symbianutils/trkutils.h
+++ b/src/shared/symbianutils/codautils.h
@@ -30,8 +30,8 @@
**
**************************************************************************/
-#ifndef DEBUGGER_TRK_UTILS
-#define DEBUGGER_TRK_UTILS
+#ifndef DEBUGGER_CODA_UTILS
+#define DEBUGGER_CODA_UTILS
#include "symbianutils_global.h"
@@ -44,107 +44,15 @@ QT_BEGIN_NAMESPACE
class QDateTime;
QT_END_NAMESPACE
-namespace trk {
+namespace Coda {
typedef unsigned char byte;
-struct TrkResult;
-
-enum Command {
- //meta commands
- TrkPing = 0x00,
- TrkConnect = 0x01,
- TrkDisconnect = 0x02,
- TrkReset = 0x03,
- TrkVersions = 0x04,
- TrkSupported = 0x05,
- TrkCpuType = 0x06,
- TrkConfigTransport = 0x07,
- TrkVersions2 = 0x08,
- TrkHostVersions = 0x09,
-
- //state commands
- TrkReadMemory = 0x10,
- TrkWriteMemory = 0x11,
- TrkReadRegisters = 0x12,
- TrkWriteRegisters = 0x13,
- TrkFillMemory = 0x14,
- TrkCopyMemory = 0x15,
- TrkFlushCache = 0x16,
-
- //execution commands
- TrkContinue = 0x18,
- TrkStep = 0x19,
- TrkStop = 0x1a,
- TrkSetBreak = 0x1b,
- TrkClearBreak = 0x1c,
- TrkDownload = 0x1d,
- TrkModifyBreakThread = 0x1e,
-
- //host -> target IO management
- TrkNotifyFileInput = 0x20,
- TrkBlockFileIo = 0x21,
-
- //host -> target os commands
- TrkCreateItem = 0x40,
- TrkDeleteItem = 0x41,
- TrkReadInfo = 0x42,
- TrkWriteInfo = 0x43,
-
- TrkWriteFile = 0x48,
- TrkReadFile = 0x49,
- TrkOpenFile = 0x4a,
- TrkCloseFile = 0x4b,
- TrkPositionFile = 0x4c,
- TrkInstallFile = 0x4d,
- TrkInstallFile2 = 0x4e,
-
- TrkPhoneSwVersion = 0x4f,
- TrkPhoneName = 0x50,
- TrkVersions3 = 0x51,
-
- //replies
- TrkNotifyAck = 0x80,
- TrkNotifyNak = 0xff,
-
- //target -> host notification
- TrkNotifyStopped = 0x90,
- TrkNotifyException = 0x91,
- TrkNotifyInternalError = 0x92,
- TrkNotifyStopped2 = 0x94,
-
- //target -> host OS notification
- TrkNotifyCreated = 0xa0,
- TrkNotifyDeleted = 0xa1,
- TrkNotifyProcessorStarted = 0xa2,
- TrkNotifyProcessorStandBy = 0xa6,
- TrkNotifyProcessorReset = 0xa7,
-
- //target -> host support commands (these are defined but not implemented in TRK)
- TrkDSWriteFile = 0xd0,
- TrkDSReadFile = 0xd1,
- TrkDSOpenFile = 0xd2,
- TrkDSCloseFile = 0xd3,
- TrkDSPositionFile = 0xd4
-};
-
-enum DSOSItemTypes {
- kDSOSProcessItem = 0x0000,
- kDSOSThreadItem = 0x0001,
- kDSOSDLLItem = 0x0002,
- kDSOSAppItem = 0x0003,
- kDSOSMemBlockItem = 0x0004,
- kDSOSProcAttachItem = 0x0005,
- kDSOSThreadAttachItem = 0x0006,
- kDSOSProcAttach2Item = 0x0007,
- kDSOSProcRunItem = 0x0008
- /* 0x0009 - 0x00ff reserved for general expansion */
- /* 0x0100 - 0xffff available for target-specific use */
-};
+struct CodaResult;
enum SerialMultiplexor {
MuxRaw = 0,
MuxTextTrace = 0x0102,
- MuxTrk = 0x0190
+ MuxCoda = 0x0190
};
inline byte extractByte(const char *data) { return *data; }
@@ -171,7 +79,7 @@ SYMBIANUTILS_EXPORT void appendString(QByteArray *ba, const QByteArray &str, End
struct SYMBIANUTILS_EXPORT Library
{
Library();
- explicit Library(const TrkResult &r);
+ explicit Library(const CodaResult &r);
QByteArray name;
uint codeseg;
@@ -180,13 +88,13 @@ struct SYMBIANUTILS_EXPORT Library
uint pid;
};
-struct SYMBIANUTILS_EXPORT TrkAppVersion
+struct SYMBIANUTILS_EXPORT CodaAppVersion
{
- TrkAppVersion();
+ CodaAppVersion();
void reset();
- int trkMajor;
- int trkMinor;
+ int codaMajor;
+ int codaMinor;
int protocolMajor;
int protocolMinor;
};
@@ -202,7 +110,7 @@ struct SYMBIANUTILS_EXPORT Session
// Answer to qsDllInfo, can be sent chunk-wise.
QByteArray gdbQsDllInfo(int start = 0, int count = -1) const;
- // Trk feedback
+ // CODA feedback
byte cpuMajor;
byte cpuMinor;
byte bigEndian;
@@ -210,7 +118,7 @@ struct SYMBIANUTILS_EXPORT Session
byte fpTypeSize;
byte extended1TypeSize;
byte extended2TypeSize;
- TrkAppVersion trkAppVersion;
+ CodaAppVersion codaAppVersion;
uint pid;
uint mainTid;
uint tid;
@@ -225,9 +133,9 @@ struct SYMBIANUTILS_EXPORT Session
QStringList modules;
};
-struct SYMBIANUTILS_EXPORT TrkResult
+struct SYMBIANUTILS_EXPORT CodaResult
{
- TrkResult();
+ CodaResult();
void clear();
QString toString() const;
// 0 for no error.
@@ -247,6 +155,6 @@ SYMBIANUTILS_EXPORT QByteArray hexNumber(uint n, int digits = 0);
SYMBIANUTILS_EXPORT QByteArray hexxNumber(uint n, int digits = 0); // prepends '0x', too
SYMBIANUTILS_EXPORT uint swapEndian(uint in);
-} // namespace trk
+} // namespace Coda
-#endif // DEBUGGER_TRK_UTILS
+#endif // DEBUGGER_CODA_UTILS
diff --git a/src/shared/symbianutils/trkutils_p.h b/src/shared/symbianutils/codautils_p.h
index 9f5370ca97..6035698a82 100644
--- a/src/shared/symbianutils/trkutils_p.h
+++ b/src/shared/symbianutils/codautils_p.h
@@ -30,24 +30,24 @@
**
**************************************************************************/
-#ifndef DEBUGGER_TRK_PRIVATE_UTILS
-#define DEBUGGER_TRK_PRIVATE_UTILS
+#ifndef DEBUGGER_CODA_PRIVATE_UTILS
+#define DEBUGGER_CODA_PRIVATE_UTILS
-#include "trkutils.h"
+#include "codautils.h"
#include "symbianutils_global.h"
QT_BEGIN_NAMESPACE
class QDateTime;
QT_END_NAMESPACE
-namespace trk {
+namespace Coda {
void appendDateTime(QByteArray *ba, QDateTime dateTime, Endianness = TargetByteOrder);
// returns a QByteArray containing optionally
// the serial frame [0x01 0x90 <len>] and 0x7e encoded7d(ba) 0x7e
QByteArray frameMessage(byte command, byte token, const QByteArray &data, bool serialFrame);
-bool extractResult(QByteArray *buffer, bool serialFrame, TrkResult *r, bool& linkEstablishmentMode, QByteArray *rawData = 0);
+bool extractResult(QByteArray *buffer, bool serialFrame, CodaResult *r, bool& linkEstablishmentMode, QByteArray *rawData = 0);
-} // namespace trk
+} // namespace Coda
-#endif // DEBUGGER_TRK_PRIVATE_UTILS
+#endif // DEBUGGER_CODA_PRIVATE_UTILS
diff --git a/src/shared/symbianutils/communicationstarter.cpp b/src/shared/symbianutils/communicationstarter.cpp
deleted file mode 100644
index 353ffaf55c..0000000000
--- a/src/shared/symbianutils/communicationstarter.cpp
+++ /dev/null
@@ -1,242 +0,0 @@
-/**************************************************************************
-**
-** This file is part of Qt Creator
-**
-** Copyright (c) 2011 Nokia Corporation and/or its subsidiary(-ies).
-**
-** Contact: Nokia Corporation (info@qt.nokia.com)
-**
-**
-** GNU Lesser General Public License Usage
-**
-** This file may be used under the terms of the GNU Lesser General Public
-** License version 2.1 as published by the Free Software Foundation and
-** appearing in the file LICENSE.LGPL included in the packaging of this file.
-** Please review the following information to ensure the GNU Lesser General
-** Public License version 2.1 requirements will be met:
-** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** Other Usage
-**
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at info@qt.nokia.com.
-**
-**************************************************************************/
-
-#include "communicationstarter.h"
-#include "bluetoothlistener.h"
-#include "trkdevice.h"
-
-#include <QtCore/QTimer>
-#include <QtCore/QEventLoop>
-
-namespace trk {
-
-// --------------- AbstractBluetoothStarter
-struct BaseCommunicationStarterPrivate {
- explicit BaseCommunicationStarterPrivate(const BaseCommunicationStarter::TrkDevicePtr &d);
-
- const BaseCommunicationStarter::TrkDevicePtr trkDevice;
- BluetoothListener *listener;
- QTimer *timer;
- int intervalMS;
- int attempts;
- int n;
- QString errorString;
- BaseCommunicationStarter::State state;
-};
-
-BaseCommunicationStarterPrivate::BaseCommunicationStarterPrivate(const BaseCommunicationStarter::TrkDevicePtr &d) :
- trkDevice(d),
- listener(0),
- timer(0),
- intervalMS(1000),
- attempts(-1),
- n(0),
- state(BaseCommunicationStarter::TimedOut)
-{
-}
-
-BaseCommunicationStarter::BaseCommunicationStarter(const TrkDevicePtr &trkDevice, QObject *parent) :
- QObject(parent),
- d(new BaseCommunicationStarterPrivate(trkDevice))
-{
-}
-
-BaseCommunicationStarter::~BaseCommunicationStarter()
-{
- stopTimer();
- delete d;
-}
-
-void BaseCommunicationStarter::stopTimer()
-{
- if (d->timer && d->timer->isActive())
- d->timer->stop();
-}
-
-bool BaseCommunicationStarter::initializeStartupResources(QString *errorMessage)
-{
- errorMessage->clear();
- return true;
-}
-
-BaseCommunicationStarter::StartResult BaseCommunicationStarter::start()
-{
- if (state() == Running) {
- d->errorString = QLatin1String("Internal error, attempt to re-start BaseCommunicationStarter.\n");
- return StartError;
- }
- // Before we instantiate timers, and such, try to open the device,
- // which should succeed if another listener is already running in
- // 'Watch' mode
- if (d->trkDevice->open(&(d->errorString)))
- return ConnectionSucceeded;
- // Pull up resources for next attempt
- d->n = 0;
- if (!initializeStartupResources(&(d->errorString)))
- return StartError;
- // Start timer
- if (!d->timer) {
- d->timer = new QTimer;
- connect(d->timer, SIGNAL(timeout()), this, SLOT(slotTimer()));
- }
- d->timer->setInterval(d->intervalMS);
- d->timer->setSingleShot(false);
- d->timer->start();
- d->state = Running;
- return Started;
-}
-
-BaseCommunicationStarter::State BaseCommunicationStarter::state() const
-{
- return d->state;
-}
-
-int BaseCommunicationStarter::intervalMS() const
-{
- return d->intervalMS;
-}
-
-void BaseCommunicationStarter::setIntervalMS(int i)
-{
- d->intervalMS = i;
- if (d->timer)
- d->timer->setInterval(i);
-}
-
-int BaseCommunicationStarter::attempts() const
-{
- return d->attempts;
-}
-
-void BaseCommunicationStarter::setAttempts(int a)
-{
- d->attempts = a;
-}
-
-QString BaseCommunicationStarter::device() const
-{
- return d->trkDevice->port();
-}
-
-QString BaseCommunicationStarter::errorString() const
-{
- return d->errorString;
-}
-
-void BaseCommunicationStarter::slotTimer()
-{
- ++d->n;
- // Check for timeout
- if (d->attempts >= 0 && d->n >= d->attempts) {
- stopTimer();
- d->errorString = tr("%1: timed out after %n attempts using an interval of %2ms.", 0, d->n)
- .arg(d->trkDevice->port()).arg(d->intervalMS);
- d->state = TimedOut;
- emit timeout();
- } else {
- // Attempt n to connect?
- if (d->trkDevice->open(&(d->errorString))) {
- stopTimer();
- const QString msg = tr("%1: Connection attempt %2 succeeded.").arg(d->trkDevice->port()).arg(d->n);
- emit message(msg);
- d->state = Connected;
- emit connected();
- } else {
- const QString msg = tr("%1: Connection attempt %2 failed: %3 (retrying)...")
- .arg(d->trkDevice->port()).arg(d->n).arg(d->errorString);
- emit message(msg);
- }
- }
-}
-
-// --------------- AbstractBluetoothStarter
-
-AbstractBluetoothStarter::AbstractBluetoothStarter(const TrkDevicePtr &trkDevice, QObject *parent) :
- BaseCommunicationStarter(trkDevice, parent)
-{
-}
-
-bool AbstractBluetoothStarter::initializeStartupResources(QString *errorMessage)
-{
- // Create the listener and forward messages to it.
- BluetoothListener *listener = createListener();
- connect(this, SIGNAL(message(QString)), listener, SLOT(emitMessage(QString)));
- return listener->start(device(), errorMessage);
-}
-
-// -------- ConsoleBluetoothStarter
-ConsoleBluetoothStarter::ConsoleBluetoothStarter(const TrkDevicePtr &trkDevice,
- QObject *listenerParent,
- QObject *parent) :
-AbstractBluetoothStarter(trkDevice, parent),
-m_listenerParent(listenerParent)
-{
-}
-
-BluetoothListener *ConsoleBluetoothStarter::createListener()
-{
- BluetoothListener *rc = new BluetoothListener(m_listenerParent);
- rc->setMode(BluetoothListener::Listen);
- rc->setPrintConsoleMessages(true);
- return rc;
-}
-
-bool ConsoleBluetoothStarter::startBluetooth(const TrkDevicePtr &trkDevice,
- QObject *listenerParent,
- int attempts,
- QString *errorMessage)
-{
- // Set up a console starter to print to stdout.
- ConsoleBluetoothStarter starter(trkDevice, listenerParent);
- starter.setAttempts(attempts);
- switch (starter.start()) {
- case Started:
- break;
- case ConnectionSucceeded:
- return true;
- case StartError:
- *errorMessage = starter.errorString();
- return false;
- }
- // Run the starter with an event loop. @ToDo: Implement
- // some asynchronous keypress read to cancel.
- QEventLoop eventLoop;
- connect(&starter, SIGNAL(connected()), &eventLoop, SLOT(quit()));
- connect(&starter, SIGNAL(timeout()), &eventLoop, SLOT(quit()));
- eventLoop.exec(QEventLoop::ExcludeUserInputEvents);
- if (starter.state() != AbstractBluetoothStarter::Connected) {
- *errorMessage = starter.errorString();
- return false;
- }
- return true;
-}
-} // namespace trk
diff --git a/src/shared/symbianutils/communicationstarter.h b/src/shared/symbianutils/communicationstarter.h
deleted file mode 100644
index 75ab782c67..0000000000
--- a/src/shared/symbianutils/communicationstarter.h
+++ /dev/null
@@ -1,151 +0,0 @@
-/**************************************************************************
-**
-** This file is part of Qt Creator
-**
-** Copyright (c) 2011 Nokia Corporation and/or its subsidiary(-ies).
-**
-** Contact: Nokia Corporation (info@qt.nokia.com)
-**
-**
-** GNU Lesser General Public License Usage
-**
-** This file may be used under the terms of the GNU Lesser General Public
-** License version 2.1 as published by the Free Software Foundation and
-** appearing in the file LICENSE.LGPL included in the packaging of this file.
-** Please review the following information to ensure the GNU Lesser General
-** Public License version 2.1 requirements will be met:
-** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** Other Usage
-**
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at info@qt.nokia.com.
-**
-**************************************************************************/
-
-#ifndef COMMUNICATIONSTARTER_H
-#define COMMUNICATIONSTARTER_H
-
-#include "symbianutils_global.h"
-
-#include <QtCore/QSharedPointer>
-#include <QtCore/QObject>
-
-namespace trk {
-class TrkDevice;
-class BluetoothListener;
-struct BaseCommunicationStarterPrivate;
-
-/* BaseCommunicationStarter: A QObject that repeatedly tries to open a
- * trk device until a connection succeeds or a timeout occurs (emitting
- * signals), allowing to do something else in the foreground (local event loop
- * [say QMessageBox] or some asynchronous operation). If the initial
- * connection attempt in start() fails, the
- * virtual initializeStartupResources() is called to initialize resources
- * required to pull up the communication (namely Bluetooth listeners).
- * The base class can be used as is to prompt the user to launch App TRK for a
- * serial communication as this requires no further resource setup. */
-
-class SYMBIANUTILS_EXPORT BaseCommunicationStarter : public QObject {
- Q_OBJECT
- Q_DISABLE_COPY(BaseCommunicationStarter)
-public:
- typedef QSharedPointer<TrkDevice> TrkDevicePtr;
-
- enum State { Running, Connected, TimedOut };
-
- explicit BaseCommunicationStarter(const TrkDevicePtr& trkDevice, QObject *parent = 0);
- virtual ~BaseCommunicationStarter();
-
- int intervalMS() const;
- void setIntervalMS(int i);
-
- int attempts() const;
- void setAttempts(int a);
-
- QString device() const; // via TrkDevice
-
- State state() const;
- QString errorString() const;
-
- enum StartResult {
- Started, // Starter is now running.
- ConnectionSucceeded, /* Initial connection attempt succeeded,
- * no need to keep running. */
- StartError // Error occurred during start.
- };
-
- StartResult start();
-
-signals:
- void connected();
- void timeout();
- void message(const QString &);
-
-private slots:
- void slotTimer();
-
-protected:
- virtual bool initializeStartupResources(QString *errorMessage);
-
-private:
- inline void stopTimer();
-
- BaseCommunicationStarterPrivate *d;
-};
-
-/* AbstractBluetoothStarter: Repeatedly tries to open a trk Bluetooth
- * device. Note that in case a Listener is already running mode, the
- * connection will succeed immediately.
- * initializeStartupResources() is implemented to fire up the listener.
- * Introduces a new virtual createListener() that derived classes must
- * implement as a factory function that creates and sets up the
- * listener (mode, message connection, etc). */
-
-class SYMBIANUTILS_EXPORT AbstractBluetoothStarter : public BaseCommunicationStarter {
- Q_OBJECT
- Q_DISABLE_COPY(AbstractBluetoothStarter)
-public:
-
-protected:
- explicit AbstractBluetoothStarter(const TrkDevicePtr& trkDevice, QObject *parent = 0);
-
- // Implemented to fire up the listener.
- virtual bool initializeStartupResources(QString *errorMessage);
- // New virtual: Overwrite to create and parametrize the listener.
- virtual BluetoothListener *createListener() = 0;
-};
-
-/* ConsoleBluetoothStarter: Convenience class for console processes. Creates a
- * listener in "Listen" mode with the messages redirected to standard output. */
-
-class SYMBIANUTILS_EXPORT ConsoleBluetoothStarter : public AbstractBluetoothStarter {
- Q_OBJECT
- Q_DISABLE_COPY(ConsoleBluetoothStarter)
-public:
- static bool startBluetooth(const TrkDevicePtr& trkDevice,
- QObject *listenerParent,
- int attempts,
- QString *errorMessage);
-
-protected:
- virtual BluetoothListener *createListener();
-
-private:
- explicit ConsoleBluetoothStarter(const TrkDevicePtr& trkDevice,
- QObject *listenerParent,
- QObject *parent = 0);
-
- QObject *m_listenerParent;
-};
-
-} // namespace trk
-
-#endif // COMMUNICATIONSTARTER_H
diff --git a/src/shared/symbianutils/launcher.cpp b/src/shared/symbianutils/launcher.cpp
deleted file mode 100644
index 6306208e74..0000000000
--- a/src/shared/symbianutils/launcher.cpp
+++ /dev/null
@@ -1,1117 +0,0 @@
-/**************************************************************************
-**
-** This file is part of Qt Creator
-**
-** Copyright (c) 2011 Nokia Corporation and/or its subsidiary(-ies).
-**
-** Contact: Nokia Corporation (info@qt.nokia.com)
-**
-**
-** GNU Lesser General Public License Usage
-**
-** This file may be used under the terms of the GNU Lesser General Public
-** License version 2.1 as published by the Free Software Foundation and
-** appearing in the file LICENSE.LGPL included in the packaging of this file.
-** Please review the following information to ensure the GNU Lesser General
-** Public License version 2.1 requirements will be met:
-** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** Other Usage
-**
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at info@qt.nokia.com.
-**
-**************************************************************************/
-
-#include "launcher.h"
-#include "trkutils.h"
-#include "trkutils_p.h"
-#include "trkdevice.h"
-#include "bluetoothlistener.h"
-#include "symbiandevicemanager.h"
-
-#include <QtCore/QTimer>
-#include <QtCore/QDateTime>
-#include <QtCore/QVariant>
-#include <QtCore/QDebug>
-#include <QtCore/QQueue>
-#include <QtCore/QFile>
-#include <QtCore/QFileInfo>
-#include <QtCore/QScopedPointer>
-
-#include <cstdio>
-
-namespace trk {
-
-struct CrashReportState {
- CrashReportState();
- void clear();
-
- typedef uint Thread;
- typedef QList<Thread> Threads;
- Threads threads;
-
- QList<uint> registers;
- QByteArray stack;
- uint sp;
- uint fetchingStackPID;
- uint fetchingStackTID;
-};
-
-CrashReportState::CrashReportState()
-{
- clear();
-}
-
-void CrashReportState::clear()
-{
- threads.clear();
- stack.clear();
- sp = fetchingStackPID = fetchingStackTID = 0;
-}
-
-struct LauncherPrivate {
- struct TransferState {
- int currentFileName;
- uint copyFileHandle;
- QScopedPointer<QByteArray> data;
- qint64 position;
- QScopedPointer<QFile> localFile;
- };
-
- struct CopyState : public TransferState {
- QStringList sourceFileNames;
- QStringList destinationFileNames;
- };
-
- struct DownloadState : public TransferState {
- QString sourceFileName;
- QString destinationFileName;
- };
-
- explicit LauncherPrivate(const TrkDevicePtr &d);
-
- TrkDevicePtr m_device;
- QByteArray m_trkReadBuffer;
- Launcher::State m_state;
-
- void logMessage(const QString &msg);
- // Debuggee state
- Session m_session; // global-ish data (process id, target information)
-
- CopyState m_copyState;
- DownloadState m_downloadState;
- QString m_fileName;
- QString m_commandLineArgs;
- QStringList m_installFileNames;
- int m_currentInstallFileName;
- int m_verbose;
- Launcher::Actions m_startupActions;
- bool m_closeDevice;
- CrashReportState m_crashReportState;
- Launcher::InstallationMode m_installationMode;
- Launcher::InstallationMode m_currentInstallationStep;
- char m_installationDrive;
-};
-
-LauncherPrivate::LauncherPrivate(const TrkDevicePtr &d) :
- m_device(d),
- m_state(Launcher::Disconnected),
- m_verbose(0),
- m_closeDevice(true),
- m_installationMode(Launcher::InstallationModeSilentAndUser),
- m_currentInstallationStep(Launcher::InstallationModeSilent),
- m_installationDrive('C')
-{
- if (m_device.isNull())
- m_device = TrkDevicePtr(new TrkDevice);
-}
-
-Launcher::Launcher(Actions startupActions,
- const TrkDevicePtr &dev,
- QObject *parent) :
- QObject(parent),
- d(new LauncherPrivate(dev))
-{
- d->m_startupActions = startupActions;
- connect(d->m_device.data(), SIGNAL(messageReceived(trk::TrkResult)), this, SLOT(handleResult(trk::TrkResult)));
-}
-
-Launcher::~Launcher()
-{
- // Destroyed before protocol was through: Close
- if (d->m_closeDevice && d->m_device->isOpen())
- d->m_device->close();
- emit destroyed(d->m_device->port());
- logMessage("Shutting down.\n");
- delete d;
-}
-
-Launcher::State Launcher::state() const
-{
- return d->m_state;
-}
-
-void Launcher::setState(State s)
-{
- if (s != d->m_state) {
- d->m_state = s;
- emit stateChanged(s);
- }
-}
-
-void Launcher::setInstallationMode(InstallationMode installation)
-{
- d->m_installationMode = installation;
-}
-
-void Launcher::setInstallationDrive(char drive)
-{
- d->m_installationDrive = drive;
-}
-
-void Launcher::addStartupActions(trk::Launcher::Actions startupActions)
-{
- d->m_startupActions = Actions(d->m_startupActions | startupActions);
-}
-
-void Launcher::setTrkServerName(const QString &name)
-{
- d->m_device->setPort(name);
-}
-
-QString Launcher::trkServerName() const
-{
- return d->m_device->port();
-}
-
-TrkDevicePtr Launcher::trkDevice() const
-{
- return d->m_device;
-}
-
-void Launcher::setFileName(const QString &name)
-{
- d->m_fileName = name;
-}
-
-void Launcher::setCopyFileNames(const QStringList &srcNames, const QStringList &dstNames)
-{
- d->m_copyState.sourceFileNames = srcNames;
- d->m_copyState.destinationFileNames = dstNames;
- d->m_copyState.currentFileName = 0;
-}
-
-void Launcher::setDownloadFileName(const QString &srcName, const QString &dstName)
-{
- d->m_downloadState.sourceFileName = srcName;
- d->m_downloadState.destinationFileName = dstName;
-}
-
-void Launcher::setInstallFileNames(const QStringList &names)
-{
- d->m_installFileNames = names;
- d->m_currentInstallFileName = 0;
-}
-
-void Launcher::setCommandLineArgs(const QString &args)
-{
- d->m_commandLineArgs = args;
-}
-
-void Launcher::setSerialFrame(bool b)
-{
- d->m_device->setSerialFrame(b);
-}
-
-bool Launcher::serialFrame() const
-{
- return d->m_device->serialFrame();
-}
-
-bool Launcher::closeDevice() const
-{
- return d->m_closeDevice;
-}
-
-void Launcher::setCloseDevice(bool c)
-{
- d->m_closeDevice = c;
-}
-
-Launcher::InstallationMode Launcher::installationMode() const
-{
- return d->m_installationMode;
-}
-
-char Launcher::installationDrive() const
-{
- return d->m_installationDrive;
-}
-
-bool Launcher::startServer(QString *errorMessage)
-{
- errorMessage->clear();
- d->m_crashReportState.clear();
- if (d->m_verbose) {
- QString msg;
- QTextStream str(&msg);
- str.setIntegerBase(16);
- str << "Actions=0x" << d->m_startupActions;
- str.setIntegerBase(10);
- str << " Port=" << trkServerName();
- if (!d->m_fileName.isEmpty())
- str << " Executable=" << d->m_fileName;
- if (!d->m_commandLineArgs.isEmpty())
- str << " Arguments= " << d->m_commandLineArgs;
- for (int i = 0; i < d->m_copyState.sourceFileNames.size(); ++i) {
- str << " Package/Source=" << d->m_copyState.sourceFileNames.at(i);
- str << " Remote Package/Destination=" << d->m_copyState.destinationFileNames.at(i);
- }
- if (!d->m_downloadState.sourceFileName.isEmpty())
- str << " Source=" << d->m_downloadState.sourceFileName;
- if (!d->m_downloadState.destinationFileName.isEmpty())
- str << " Destination=" << d->m_downloadState.destinationFileName;
- if (!d->m_installFileNames.isEmpty())
- foreach (const QString &installFileName, d->m_installFileNames)
- str << " Install file=" << installFileName;
- logMessage(msg);
- }
- if (d->m_startupActions & ActionCopy) {
- if (d->m_copyState.sourceFileNames.isEmpty()) {
- qWarning("No local filename given for copying package.");
- return false;
- } else if (d->m_copyState.destinationFileNames.isEmpty()) {
- qWarning("No remote filename given for copying package.");
- return false;
- }
- }
- if (d->m_startupActions & ActionInstall && d->m_installFileNames.isEmpty()) {
- qWarning("No package name given for installing.");
- return false;
- }
- if (d->m_startupActions & ActionRun && d->m_fileName.isEmpty()) {
- qWarning("No remote executable given for running.");
- return false;
- }
- if (!d->m_device->isOpen() && !d->m_device->open(errorMessage))
- return false;
- setState(Connecting);
- // Set up the temporary 'waiting' state if we do not get immediate connection
- QTimer::singleShot(1000, this, SLOT(slotWaitingForTrk()));
- d->m_device->sendTrkInitialPing();
- d->m_device->sendTrkMessage(TrkDisconnect); // Disconnect, as trk might be still connected
- d->m_device->sendTrkMessage(TrkSupported, TrkCallback(this, &Launcher::handleSupportMask));
- d->m_device->sendTrkMessage(TrkCpuType, TrkCallback(this, &Launcher::handleCpuType));
- d->m_device->sendTrkMessage(TrkVersions, TrkCallback(this, &Launcher::handleTrkVersion));
- if (d->m_startupActions != ActionPingOnly)
- d->m_device->sendTrkMessage(TrkConnect, TrkCallback(this, &Launcher::handleConnect));
- return true;
-}
-
-void Launcher::slotWaitingForTrk()
-{
- // Set temporary state if we are still in connected state
- if (state() == Connecting)
- setState(WaitingForTrk);
-}
-
-void Launcher::handleConnect(const TrkResult &result)
-{
- if (result.errorCode()) {
- emit canNotConnect(result.errorString());
- return;
- }
- setState(Connected);
- if (d->m_startupActions & ActionCopy)
- copyFileToRemote();
- else if (d->m_startupActions & ActionInstall)
- installRemotePackage();
- else if (d->m_startupActions & ActionRun)
- startInferiorIfNeeded();
- else if (d->m_startupActions & ActionDownload)
- copyFileFromRemote();
-}
-
-void Launcher::setVerbose(int v)
-{
- d->m_verbose = v;
- d->m_device->setVerbose(v);
-}
-
-void Launcher::logMessage(const QString &msg)
-{
- if (d->m_verbose)
- qDebug() << "LAUNCHER: " << qPrintable(msg);
-}
-
-void Launcher::handleFinished()
-{
- if (d->m_closeDevice)
- d->m_device->close();
- emit finished();
-}
-
-void Launcher::terminate()
-{
- switch (state()) {
- case DeviceDescriptionReceived:
- case Connected:
- if (d->m_session.pid) {
- QByteArray ba;
- appendShort(&ba, 0x0000, TargetByteOrder);
- appendInt(&ba, d->m_session.pid, TargetByteOrder);
- d->m_device->sendTrkMessage(TrkDeleteItem, TrkCallback(this, &Launcher::handleRemoteProcessKilled), ba);
- return;
- }
- if (d->m_copyState.copyFileHandle)
- closeRemoteFile(true);
- disconnectTrk();
- break;
- case Disconnected:
- break;
- case Connecting:
- case WaitingForTrk:
- setState(Disconnected);
- handleFinished();
- break;
- }
-}
-
-void Launcher::handleRemoteProcessKilled(const TrkResult &result)
-{
- Q_UNUSED(result)
- disconnectTrk();
-}
-
-QString Launcher::msgStopped(uint pid, uint tid, uint address, const QString &why)
-{
- return QString::fromLatin1("Process %1, thread %2 stopped at 0x%3: %4").
- arg(pid).arg(tid).arg(address, 0, 16).
- arg(why.isEmpty() ? QString::fromLatin1("<Unknown reason>") : why);
-}
-
-bool Launcher::parseNotifyStopped(const QByteArray &dataBA,
- uint *pid, uint *tid, uint *address,
- QString *why /* = 0 */)
-{
- if (why)
- why->clear();
- *address = *pid = *tid = 0;
- if (dataBA.size() < 12)
- return false;
- const char *data = dataBA.data();
- *address = extractInt(data);
- *pid = extractInt(data + 4);
- *tid = extractInt(data + 8);
- if (why && dataBA.size() >= 14) {
- const unsigned short len = extractShort(data + 12);
- if (len > 0)
- *why = QString::fromLatin1(data + 14, len);
- }
- return true;
-}
-
-void Launcher::handleResult(const TrkResult &result)
-{
- QByteArray prefix = "READ BUF: ";
- QByteArray str = result.toString().toUtf8();
- if (result.isDebugOutput) { // handle application output
- QString msg;
- if (result.multiplex == MuxTextTrace) {
- if (result.data.length() > 8) {
- quint64 timestamp = extractInt64(result.data) & 0x0FFFFFFFFFFFFFFFULL;
- quint64 secs = timestamp / 1000000000;
- quint64 ns = timestamp % 1000000000;
- msg = QString("[%1.%2] %3").arg(secs).arg(ns).arg(QString(result.data.mid(8)));
- logMessage("TEXT TRACE: " + msg);
- }
- } else {
- logMessage("APPLICATION OUTPUT: " + stringFromArray(result.data));
- msg = result.data;
- }
- msg.replace("\r\n", "\n");
- if(!msg.endsWith('\n')) msg.append('\n');
- emit applicationOutputReceived(msg);
- return;
- }
- switch (result.code) {
- case TrkNotifyAck:
- break;
- case TrkNotifyNak: { // NAK
- logMessage(prefix + QLatin1String("NAK: ") + str);
- //logMessage(prefix << "TOKEN: " << result.token);
- logMessage(prefix + QLatin1String("ERROR: ") + errorMessage(result.data.at(0)));
- break;
- }
- case TrkNotifyStopped: { // Notified Stopped
- QString reason;
- uint pc;
- uint pid;
- uint tid;
- parseNotifyStopped(result.data, &pid, &tid, &pc, &reason);
- logMessage(prefix + msgStopped(pid, tid, pc, reason));
- emit(processStopped(pc, pid, tid, reason));
- d->m_device->sendTrkAck(result.token);
- break;
- }
- case TrkNotifyException: { // Notify Exception (obsolete)
- logMessage(prefix + QLatin1String("NOTE: EXCEPTION ") + str);
- d->m_device->sendTrkAck(result.token);
- break;
- }
- case TrkNotifyInternalError: { //
- logMessage(prefix + QLatin1String("NOTE: INTERNAL ERROR: ") + str);
- d->m_device->sendTrkAck(result.token);
- break;
- }
-
- // target->host OS notification
- case TrkNotifyCreated: { // Notify Created
-
- if (result.data.size() < 10)
- break;
- const char *data = result.data.constData();
- const byte error = result.data.at(0);
- Q_UNUSED(error)
- const byte type = result.data.at(1); // type: 1 byte; for dll item, this value is 2.
- const uint tid = extractInt(data + 6); //threadID: 4 bytes
- Q_UNUSED(tid)
- if (type == kDSOSDLLItem && result.data.size() >=20) {
- const Library lib = Library(result);
- d->m_session.libraries.push_back(lib);
- emit libraryLoaded(lib);
- }
- QByteArray ba;
- ba.append(result.data.mid(2, 8));
- d->m_device->sendTrkMessage(TrkContinue, TrkCallback(), ba, "CONTINUE");
- break;
- }
- case TrkNotifyDeleted: { // NotifyDeleted
- const ushort itemType = (unsigned char)result.data.at(1);
- const uint pid = result.data.size() >= 6 ? extractShort(result.data.constData() + 2) : 0;
- const uint tid = result.data.size() >= 10 ? extractShort(result.data.constData() + 6) : 0;
- Q_UNUSED(tid)
- const ushort len = result.data.size() > 12 ? extractShort(result.data.constData() + 10) : ushort(0);
- const QString name = len ? QString::fromAscii(result.data.mid(12, len)) : QString();
- logMessage(QString::fromLatin1("%1 %2 UNLOAD: %3").
- arg(QString::fromAscii(prefix)).arg(itemType ? QLatin1String("LIB") : QLatin1String("PROCESS")).
- arg(name));
- d->m_device->sendTrkAck(result.token);
- if (itemType == kDSOSProcessItem // process
- && result.data.size() >= 10
- && d->m_session.pid == extractInt(result.data.data() + 6)) {
- if (d->m_startupActions & ActionDownload)
- copyFileFromRemote();
- else
- disconnectTrk();
- }
- else if (itemType == kDSOSDLLItem && len) {
- // Remove libraries of process.
- for (QList<Library>::iterator it = d->m_session.libraries.begin(); it != d->m_session.libraries.end(); ) {
- if ((*it).pid == pid && (*it).name == name) {
- emit libraryUnloaded(*it);
- it = d->m_session.libraries.erase(it);
- } else {
- ++it;
- }
- }
- }
- break;
- }
- case TrkNotifyProcessorStarted: { // NotifyProcessorStarted
- logMessage(prefix + QLatin1String("NOTE: PROCESSOR STARTED: ") + str);
- d->m_device->sendTrkAck(result.token);
- break;
- }
- case TrkNotifyProcessorStandBy: { // NotifyProcessorStandby
- logMessage(prefix + QLatin1String("NOTE: PROCESSOR STANDBY: ") + str);
- d->m_device->sendTrkAck(result.token);
- break;
- }
- case TrkNotifyProcessorReset: { // NotifyProcessorReset
- logMessage(prefix + QLatin1String("NOTE: PROCESSOR RESET: ") + str);
- d->m_device->sendTrkAck(result.token);
- break;
- }
- default: {
- logMessage(prefix + QLatin1String("INVALID: ") + str);
- break;
- }
- }
-}
-
-QString Launcher::deviceDescription(unsigned verbose) const
-{
- return d->m_session.deviceDescription(verbose);
-}
-
-void Launcher::handleTrkVersion(const TrkResult &result)
-{
- if (result.errorCode() || result.data.size() < 5) {
- if (d->m_startupActions == ActionPingOnly) {
- setState(Disconnected);
- handleFinished();
- }
- return;
- }
- d->m_session.trkAppVersion.trkMajor = result.data.at(1);
- d->m_session.trkAppVersion.trkMinor = result.data.at(2);
- d->m_session.trkAppVersion.protocolMajor = result.data.at(3);
- d->m_session.trkAppVersion.protocolMinor = result.data.at(4);
- setState(DeviceDescriptionReceived);
- const QString msg = deviceDescription();
- emit deviceDescriptionReceived(trkServerName(), msg);
- // Ping mode: Log & Terminate
- if (d->m_startupActions == ActionPingOnly) {
- qWarning("%s", qPrintable(msg));
- setState(Disconnected);
- handleFinished();
- }
-}
-
-static inline QString msgCannotOpenRemoteFile(const QString &fileName, const QString &message)
-{
- return Launcher::tr("Cannot open remote file '%1': %2").arg(fileName, message);
-}
-
-static inline QString msgCannotOpenLocalFile(const QString &fileName, const QString &message)
-{
- return Launcher::tr("Cannot open '%1': %2").arg(fileName, message);
-}
-
-void Launcher::handleFileCreation(const TrkResult &result)
-{
- if (result.errorCode() || result.data.size() < 6) {
- const QString msg = msgCannotOpenRemoteFile(d->m_copyState.destinationFileNames.at(d->m_copyState.currentFileName), result.errorString());
- logMessage(msg);
- emit canNotCreateFile(d->m_copyState.destinationFileNames.at(d->m_copyState.currentFileName), msg);
- disconnectTrk();
- return;
- }
- const char *data = result.data.data();
- d->m_copyState.copyFileHandle = extractInt(data + 2);
- const QString localFileName = d->m_copyState.sourceFileNames.at(d->m_copyState.currentFileName);
- QFile file(localFileName);
- d->m_copyState.position = 0;
- if (!file.open(QIODevice::ReadOnly)) {
- const QString msg = msgCannotOpenLocalFile(localFileName, file.errorString());
- logMessage(msg);
- emit canNotOpenLocalFile(localFileName, msg);
- closeRemoteFile(true);
- disconnectTrk();
- return;
- }
- d->m_copyState.data.reset(new QByteArray(file.readAll()));
- file.close();
- continueCopying();
-}
-
-void Launcher::handleFileOpened(const TrkResult &result)
-{
- if (result.errorCode() || result.data.size() < 6) {
- const QString msg = msgCannotOpenRemoteFile(d->m_downloadState.sourceFileName, result.errorString());
- logMessage(msg);
- emit canNotOpenFile(d->m_downloadState.sourceFileName, msg);
- disconnectTrk();
- return;
- }
- d->m_downloadState.position = 0;
- const QString localFileName = d->m_downloadState.destinationFileName;
- bool opened = false;
- if (localFileName == QLatin1String("-")) {
- d->m_downloadState.localFile.reset(new QFile);
- opened = d->m_downloadState.localFile->open(stdout, QFile::WriteOnly);
- } else {
- d->m_downloadState.localFile.reset(new QFile(localFileName));
- opened = d->m_downloadState.localFile->open(QFile::WriteOnly | QFile::Truncate);
- }
- if (!opened) {
- const QString msg = msgCannotOpenLocalFile(localFileName, d->m_downloadState.localFile->errorString());
- logMessage(msg);
- emit canNotOpenLocalFile(localFileName, msg);
- closeRemoteFile(true);
- disconnectTrk();
- }
- continueReading();
-}
-
-void Launcher::continueReading()
-{
- QByteArray ba;
- appendInt(&ba, d->m_downloadState.copyFileHandle, TargetByteOrder);
- appendShort(&ba, 2048, TargetByteOrder);
- d->m_device->sendTrkMessage(TrkReadFile, TrkCallback(this, &Launcher::handleRead), ba);
-}
-
-void Launcher::handleRead(const TrkResult &result)
-{
- if (result.errorCode() || result.data.size() < 4) {
- d->m_downloadState.localFile->close();
- closeRemoteFile(true);
- disconnectTrk();
- } else {
- int length = extractShort(result.data.data() + 2);
- //TRK doesn't tell us the file length, so we need to keep reading until it returns 0 length
- if (length > 0) {
- d->m_downloadState.localFile->write(result.data.data() + 4, length);
- continueReading();
- } else {
- closeRemoteFile(true);
- disconnectTrk();
- }
- }
-}
-
-void Launcher::handleCopy(const TrkResult &result)
-{
- if (result.errorCode() || result.data.size() < 4) {
- closeRemoteFile(true);
- emit canNotWriteFile(d->m_copyState.destinationFileNames.at(d->m_copyState.currentFileName), result.errorString());
- disconnectTrk();
- } else {
- continueCopying(extractShort(result.data.data() + 2));
- }
-}
-
-void Launcher::continueCopying(uint lastCopiedBlockSize)
-{
- qint64 size = d->m_copyState.data->length();
- d->m_copyState.position += lastCopiedBlockSize;
- if (size == 0)
- emit copyProgress(100);
- else {
- const qint64 hundred = 100;
- const qint64 percent = qMin( (d->m_copyState.position * hundred) / size, hundred);
- emit copyProgress(static_cast<int>(percent));
- }
- if (d->m_copyState.position < size) {
- QByteArray ba;
- appendInt(&ba, d->m_copyState.copyFileHandle, TargetByteOrder);
- appendString(&ba, d->m_copyState.data->mid(d->m_copyState.position, 2048), TargetByteOrder, false);
- d->m_device->sendTrkMessage(TrkWriteFile, TrkCallback(this, &Launcher::handleCopy), ba);
- } else {
- closeRemoteFile();
- }
-}
-
-void Launcher::closeRemoteFile(bool failed)
-{
- QByteArray ba;
- appendInt(&ba, d->m_copyState.copyFileHandle, TargetByteOrder);
- appendDateTime(&ba, QDateTime::currentDateTime(), TargetByteOrder);
- d->m_device->sendTrkMessage(TrkCloseFile,
- failed ? TrkCallback() : TrkCallback(this, &Launcher::handleFileCopied),
- ba);
- d->m_copyState.data.reset(0);
- d->m_copyState.copyFileHandle = 0;
- d->m_copyState.position = 0;
-}
-
-void Launcher::handleFileCopied(const TrkResult &result)
-{
- if (result.errorCode())
- emit canNotCloseFile(d->m_copyState.destinationFileNames.at(d->m_copyState.currentFileName), result.errorString());
- emit fileCopied(d->m_copyState.destinationFileNames.at(d->m_copyState.currentFileName));
-
- ++d->m_copyState.currentFileName;
-
- if (d->m_startupActions & ActionInstall && d->m_copyState.currentFileName < d->m_copyState.sourceFileNames.size()) {
- copyFileToRemote();
- } else if (d->m_startupActions & ActionInstall) {
- installRemotePackage();
- } else if (d->m_startupActions & ActionRun) {
- startInferiorIfNeeded();
- } else if (d->m_startupActions & ActionDownload) {
- copyFileFromRemote();
- } else {
- disconnectTrk();
- }
-}
-
-void Launcher::handleCpuType(const TrkResult &result)
-{
- logMessage("HANDLE CPU TYPE: " + result.toString());
- if(result.errorCode() || result.data.size() < 7)
- return;
- //---TRK------------------------------------------------------
- // Command: 0x80 Acknowledge
- // Error: 0x00
- // [80 03 00 04 00 00 04 00 00 00]
- d->m_session.cpuMajor = result.data.at(1);
- d->m_session.cpuMinor = result.data.at(2);
- d->m_session.bigEndian = result.data.at(3);
- d->m_session.defaultTypeSize = result.data.at(4);
- d->m_session.fpTypeSize = result.data.at(5);
- d->m_session.extended1TypeSize = result.data.at(6);
- //d->m_session.extended2TypeSize = result.data[6];
-}
-
-void Launcher::handleCreateProcess(const TrkResult &result)
-{
- if (result.errorCode()) {
- emit canNotRun(result.errorString());
- disconnectTrk();
- return;
- }
- // 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]
- const char *data = result.data.data();
- d->m_session.pid = extractInt(data + 1);
- d->m_session.tid = extractInt(data + 5);
- d->m_session.codeseg = extractInt(data + 9);
- d->m_session.dataseg = extractInt(data + 13);
- if (d->m_verbose) {
- const QString msg = QString::fromLatin1("Process id: %1 Thread id: %2 code: 0x%3 data: 0x%4").
- arg(d->m_session.pid).arg(d->m_session.tid).arg(d->m_session.codeseg, 0, 16).
- arg(d->m_session.dataseg, 0 ,16);
- logMessage(msg);
- }
- emit applicationRunning(d->m_session.pid);
- //create a "library" entry for the executable which launched the process
- Library lib;
- lib.pid = d->m_session.pid;
- lib.codeseg = d->m_session.codeseg;
- lib.dataseg = d->m_session.dataseg;
- lib.name = d->m_fileName.toUtf8();
- d->m_session.libraries << lib;
- emit libraryLoaded(lib);
-
- QByteArray ba;
- appendInt(&ba, d->m_session.pid);
- appendInt(&ba, d->m_session.tid);
- d->m_device->sendTrkMessage(TrkContinue, TrkCallback(), ba, "CONTINUE");
-}
-
-void Launcher::handleWaitForFinished(const TrkResult &result)
-{
- logMessage(" FINISHED: " + stringFromArray(result.data));
- setState(Disconnected);
- handleFinished();
-}
-
-void Launcher::handleSupportMask(const TrkResult &result)
-{
- if (result.errorCode() || result.data.size() < 32)
- return;
- const char *data = result.data.data() + 1;
-
- if (d->m_verbose > 1) {
- QString str = QLatin1String("SUPPORTED: ");
- for (int i = 0; i < 32; ++i) {
- for (int j = 0; j < 8; ++j) {
- if (data[i] & (1 << j)) {
- str.append(QString::number(i * 8 + j, 16));
- str.append(QLatin1Char(' '));
- }
- }
- }
- logMessage(str);
- }
-}
-
-void Launcher::cleanUp()
-{
- //
- //---IDE------------------------------------------------------
- // Command: 0x41 Delete Item
- // Sub Cmd: Delete Process
- //ProcessID: 0x0000071F (1823)
- // [41 24 00 00 00 00 07 1F]
- QByteArray ba(2, char(0));
- appendInt(&ba, d->m_session.pid);
- d->m_device->sendTrkMessage(TrkDeleteItem, TrkCallback(), ba, "Delete process");
-
- //---TRK------------------------------------------------------
- // Command: 0x80 Acknowledge
- // Error: 0x00
- // [80 24 00]
-
- //---IDE------------------------------------------------------
- // Command: 0x1C Clear Break
- // [1C 25 00 00 00 0A 78 6A 43 40]
-
- //---TRK------------------------------------------------------
- // Command: 0xA1 Notify Deleted
- // [A1 09 00 00 00 00 00 00 00 00 07 1F]
- //---IDE------------------------------------------------------
- // Command: 0x80 Acknowledge
- // Error: 0x00
- // [80 09 00]
-
- //---TRK------------------------------------------------------
- // Command: 0x80 Acknowledge
- // Error: 0x00
- // [80 25 00]
-
- //---IDE------------------------------------------------------
- // Command: 0x1C Clear Break
- // [1C 26 00 00 00 0B 78 6A 43 70]
- //---TRK------------------------------------------------------
- // Command: 0x80 Acknowledge
- // Error: 0x00
- // [80 26 00]
-
-
- //---IDE------------------------------------------------------
- // Command: 0x02 Disconnect
- // [02 27]
-// sendTrkMessage(0x02, TrkCallback(this, &Launcher::handleDisconnect));
- //---TRK------------------------------------------------------
- // Command: 0x80 Acknowledge
- // Error: 0x00
-}
-
-void Launcher::disconnectTrk()
-{
- d->m_device->sendTrkMessage(TrkDisconnect, TrkCallback(this, &Launcher::handleWaitForFinished));
-}
-
-void Launcher::copyFileToRemote()
-{
- QFileInfo fileInfo(d->m_copyState.destinationFileNames.at(d->m_copyState.currentFileName));
- emit copyingStarted(fileInfo.fileName());
- QByteArray ba;
- ba.append(char(10)); //kDSFileOpenWrite | kDSFileOpenBinary
- appendString(&ba, d->m_copyState.destinationFileNames.at(d->m_copyState.currentFileName).toLocal8Bit(), TargetByteOrder, false);
- d->m_device->sendTrkMessage(TrkOpenFile, TrkCallback(this, &Launcher::handleFileCreation), ba);
-}
-
-void Launcher::copyFileFromRemote()
-{
- QFileInfo fileInfo(d->m_copyState.destinationFileNames.at(d->m_copyState.currentFileName));
- emit copyingStarted(fileInfo.fileName());
- QByteArray ba;
- ba.append(char(9)); //kDSFileOpenRead | kDSFileOpenBinary
- appendString(&ba, d->m_downloadState.sourceFileName.toLocal8Bit(), TargetByteOrder, false);
- d->m_device->sendTrkMessage(TrkOpenFile, TrkCallback(this, &Launcher::handleFileOpened), ba);
-}
-
-void Launcher::installRemotePackageSilently()
-{
- emit installingStarted(d->m_installFileNames.at(d->m_currentInstallFileName));
- d->m_currentInstallationStep = InstallationModeSilent;
- QByteArray ba;
- ba.append(static_cast<char>(QChar::toUpper((ushort)d->m_installationDrive)));
- appendString(&ba, d->m_installFileNames.at(d->m_currentInstallFileName).toLocal8Bit(), TargetByteOrder, false);
- d->m_device->sendTrkMessage(TrkInstallFile, TrkCallback(this, &Launcher::handleInstallPackageFinished), ba);
-}
-
-void Launcher::installRemotePackageByUser()
-{
- emit installingStarted(d->m_installFileNames.at(d->m_currentInstallFileName));
- d->m_currentInstallationStep = InstallationModeUser;
- QByteArray ba;
- appendString(&ba, d->m_installFileNames.at(d->m_currentInstallFileName).toLocal8Bit(), TargetByteOrder, false);
- d->m_device->sendTrkMessage(TrkInstallFile2, TrkCallback(this, &Launcher::handleInstallPackageFinished), ba);
-}
-
-void Launcher::installRemotePackage()
-{
- switch (installationMode()) {
- case InstallationModeSilent:
- case InstallationModeSilentAndUser:
- installRemotePackageSilently();
- break;
- case InstallationModeUser:
- installRemotePackageByUser();
- break;
- default:
- break;
- }
-}
-
-void Launcher::handleInstallPackageFinished(const TrkResult &result)
-{
- if (result.errorCode()) {
- if (installationMode() == InstallationModeSilentAndUser
- && d->m_currentInstallationStep & InstallationModeSilent) {
- installRemotePackageByUser();
- return;
- }
- emit canNotInstall(d->m_installFileNames.at(d->m_currentInstallFileName), result.errorString());
- disconnectTrk();
- return;
- }
-
- ++d->m_currentInstallFileName;
-
- if (d->m_currentInstallFileName == d->m_installFileNames.size())
- emit installingFinished();
-
- if (d->m_startupActions & ActionInstall && d->m_currentInstallFileName < d->m_installFileNames.size()) {
- installRemotePackage();
- } else if (d->m_startupActions & ActionRun) {
- startInferiorIfNeeded();
- } else if (d->m_startupActions & ActionDownload) {
- copyFileFromRemote();
- } else {
- disconnectTrk();
- }
-}
-
-QByteArray Launcher::startProcessMessage(const QString &executable,
- const QString &arguments)
-{
- // It's not started yet
- QByteArray ba;
- appendShort(&ba, 0, TargetByteOrder); // create new process (kDSOSProcessItem)
- ba.append(char(0)); // options - currently unused
- // One string consisting of binary terminated by '\0' and arguments terminated by '\0'
- QByteArray commandLineBa = executable.toLocal8Bit();
- commandLineBa.append(char(0));
- if (!arguments.isEmpty())
- commandLineBa.append(arguments.toLocal8Bit());
- appendString(&ba, commandLineBa, TargetByteOrder, true);
- return ba;
-}
-
-QByteArray Launcher::readMemoryMessage(uint pid, uint tid, uint from, uint len)
-{
- QByteArray ba;
- ba.reserve(11);
- ba.append(char(0x8)); // Options, FIXME: why?
- appendShort(&ba, len);
- appendInt(&ba, from);
- appendInt(&ba, pid);
- appendInt(&ba, tid);
- return ba;
-}
-
-QByteArray Launcher::readRegistersMessage(uint pid, uint tid)
-{
- QByteArray ba;
- ba.reserve(15);
- ba.append(char(0)); // Register set, only 0 supported
- appendShort(&ba, 0); //R0
- appendShort(&ba, 16); // last register CPSR
- appendInt(&ba, pid);
- appendInt(&ba, tid);
- return ba;
-}
-
-void Launcher::startInferiorIfNeeded()
-{
- emit startingApplication();
- if (d->m_session.pid != 0) {
- logMessage("Process already 'started'");
- return;
- }
-
- d->m_device->sendTrkMessage(TrkCreateItem, TrkCallback(this, &Launcher::handleCreateProcess),
- startProcessMessage(d->m_fileName, d->m_commandLineArgs)); // Create Item
-}
-
-void Launcher::resumeProcess(uint pid, uint tid)
-{
- QByteArray ba;
- appendInt(&ba, pid, BigEndian);
- appendInt(&ba, tid, BigEndian);
- d->m_device->sendTrkMessage(TrkContinue, TrkCallback(), ba, "CONTINUE");
-}
-
-// Acquire a device from SymbianDeviceManager, return 0 if not available.
-Launcher *Launcher::acquireFromDeviceManager(const QString &serverName,
- QObject *parent,
- QString *errorMessage)
-{
- SymbianUtils::SymbianDeviceManager *sdm = SymbianUtils::SymbianDeviceManager::instance();
- const QSharedPointer<trk::TrkDevice> device = sdm->acquireDevice(serverName);
- if (device.isNull()) {
- if (serverName.isEmpty())
- *errorMessage = tr("No device is connected. Please connect a device and try again.");
- else
- *errorMessage = tr("Unable to acquire a device for port '%1'. It appears to be in use.").arg(serverName);
- return 0;
- }
- // Wire release signal.
- Launcher *rc = new Launcher(trk::Launcher::ActionPingOnly, device, parent);
- connect(rc, SIGNAL(deviceDescriptionReceived(QString,QString)),
- sdm, SLOT(setAdditionalInformation(QString,QString)));
- connect(rc, SIGNAL(destroyed(QString)), sdm, SLOT(releaseDevice(QString)));
- return rc;
-}
-
-// Preliminary release of device, disconnecting the signal.
-void Launcher::releaseToDeviceManager(Launcher *launcher)
-{
- Q_ASSERT(launcher);
-
- SymbianUtils::SymbianDeviceManager *sdm = SymbianUtils::SymbianDeviceManager::instance();
- // Disentangle launcher and its device, remove connection from destroyed
- launcher->setCloseDevice(false);
- TrkDevice *device = launcher->trkDevice().data();
- launcher->disconnect(device);
- device->disconnect(launcher);
- launcher->disconnect(sdm);
- sdm->releaseDevice(launcher->trkServerName());
-}
-
-void Launcher::getRegistersAndCallStack(uint pid, uint tid)
-{
- d->m_device->sendTrkMessage(TrkReadRegisters,
- TrkCallback(this, &Launcher::handleReadRegisters),
- Launcher::readRegistersMessage(pid, tid));
- d->m_crashReportState.fetchingStackPID = pid;
- d->m_crashReportState.fetchingStackTID = tid;
-}
-
-void Launcher::handleReadRegisters(const TrkResult &result)
-{
- if(result.errorCode() || result.data.size() < (17*4)) {
- terminate();
- return;
- }
- const char* data = result.data.constData() + 1;
- d->m_crashReportState.registers.clear();
- d->m_crashReportState.stack.clear();
- for (int i=0;i<17;i++) {
- uint r = extractInt(data);
- data += 4;
- d->m_crashReportState.registers.append(r);
- }
- d->m_crashReportState.sp = d->m_crashReportState.registers.at(13);
-
- const ushort len = 1024 - (d->m_crashReportState.sp % 1024); //read to 1k boundary first
- const QByteArray ba = Launcher::readMemoryMessage(d->m_crashReportState.fetchingStackPID,
- d->m_crashReportState.fetchingStackTID,
- d->m_crashReportState.sp,
- len);
- d->m_device->sendTrkMessage(TrkReadMemory, TrkCallback(this, &Launcher::handleReadStack), ba);
- d->m_crashReportState.sp += len;
-}
-
-void Launcher::handleReadStack(const TrkResult &result)
-{
- if (result.errorCode()) {
- //error implies memory fault when reaching end of stack
- emit registersAndCallStackReadComplete(d->m_crashReportState.registers, d->m_crashReportState.stack);
- return;
- }
-
- const uint len = extractShort(result.data.constData() + 1);
- d->m_crashReportState.stack.append(result.data.mid(3, len));
-
- if (d->m_crashReportState.sp - d->m_crashReportState.registers.at(13) > 0x10000) {
- //read enough stack, stop here
- emit registersAndCallStackReadComplete(d->m_crashReportState.registers, d->m_crashReportState.stack);
- return;
- }
- //read 1k more
- const QByteArray ba = Launcher::readMemoryMessage(d->m_crashReportState.fetchingStackPID,
- d->m_crashReportState.fetchingStackTID,
- d->m_crashReportState.sp,
- 1024);
- d->m_device->sendTrkMessage(TrkReadMemory, TrkCallback(this, &Launcher::handleReadStack), ba);
- d->m_crashReportState.sp += 1024;
-}
-
-} // namespace trk
diff --git a/src/shared/symbianutils/launcher.h b/src/shared/symbianutils/launcher.h
deleted file mode 100644
index 4e11f143b1..0000000000
--- a/src/shared/symbianutils/launcher.h
+++ /dev/null
@@ -1,218 +0,0 @@
-/**************************************************************************
-**
-** This file is part of Qt Creator
-**
-** Copyright (c) 2011 Nokia Corporation and/or its subsidiary(-ies).
-**
-** Contact: Nokia Corporation (info@qt.nokia.com)
-**
-**
-** GNU Lesser General Public License Usage
-**
-** This file may be used under the terms of the GNU Lesser General Public
-** License version 2.1 as published by the Free Software Foundation and
-** appearing in the file LICENSE.LGPL included in the packaging of this file.
-** Please review the following information to ensure the GNU Lesser General
-** Public License version 2.1 requirements will be met:
-** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** Other Usage
-**
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at info@qt.nokia.com.
-**
-**************************************************************************/
-#ifndef LAUNCHER_H
-#define LAUNCHER_H
-
-#include "trkdevice.h"
-#include "trkutils.h"
-
-#include <QtCore/QObject>
-#include <QtCore/QVariant>
-#include <QtCore/QSharedPointer>
-
-namespace trk {
-
-struct TrkResult;
-struct TrkMessage;
-struct LauncherPrivate;
-
-typedef QSharedPointer<TrkDevice> TrkDevicePtr;
-
-class SYMBIANUTILS_EXPORT Launcher : public QObject
-{
- Q_OBJECT
- Q_DISABLE_COPY(Launcher)
-public:
- typedef void (Launcher::*TrkCallBack)(const TrkResult &);
-
- enum InstallationMode {
- InstallationModeSilent = 0x1,
- InstallationModeUser = 0x2,
- InstallationModeSilentAndUser = InstallationModeSilent|InstallationModeUser
- //first attempt is silent and if it fails then the user installation is launched
- };
-
- enum Actions {
- ActionPingOnly = 0x0,
- ActionCopy = 0x1,
- ActionInstall = 0x2,
- ActionCopyInstall = ActionCopy | ActionInstall,
- ActionRun = 0x4,
- ActionDownload = 0x8,
- ActionCopyRun = ActionCopy | ActionRun,
- ActionInstallRun = ActionInstall | ActionRun,
- ActionCopyInstallRun = ActionCopy | ActionInstall | ActionRun
- };
-
- enum State { Disconnected, Connecting, Connected,
- WaitingForTrk, // This occurs only if the initial ping times out after
- // a reasonable timeout, indicating that Trk is not
- // running. Note that this will never happen with
- // Bluetooth as communication immediately starts
- // after connecting.
- DeviceDescriptionReceived };
-
- explicit Launcher(trk::Launcher::Actions startupActions = trk::Launcher::ActionPingOnly,
- const TrkDevicePtr &trkDevice = TrkDevicePtr(),
- QObject *parent = 0);
- ~Launcher();
-
- State state() const;
-
- void addStartupActions(trk::Launcher::Actions startupActions);
- void setTrkServerName(const QString &name);
- QString trkServerName() const;
- void setFileName(const QString &name);
- void setCopyFileNames(const QStringList &srcName, const QStringList &dstName);
- void setDownloadFileName(const QString &srcName, const QString &dstName);
- void setInstallFileNames(const QStringList &names);
- void setCommandLineArgs(const QString &args);
- bool startServer(QString *errorMessage);
- void setInstallationMode(InstallationMode installation);
- void setInstallationDrive(char drive);
- void setVerbose(int v);
- void setSerialFrame(bool b);
-
- InstallationMode installationMode() const;
- char installationDrive() const;
-
- bool serialFrame() const;
- // Close device or leave it open
- bool closeDevice() const;
- void setCloseDevice(bool c);
-
- TrkDevicePtr trkDevice() const;
-
- // becomes valid after successful execution of ActionPingOnly
- QString deviceDescription(unsigned verbose = 0u) const;
-
- // Acquire a device from SymbianDeviceManager, return 0 if not available.
- // The device will be released on destruction.
- static Launcher *acquireFromDeviceManager(const QString &serverName,
- QObject *parent,
- QString *errorMessage);
- // Preliminary release of device, disconnecting the signal.
- static void releaseToDeviceManager(Launcher *l);
-
- // Create Trk message to start a process.
- static QByteArray startProcessMessage(const QString &executable,
- const QString &arguments);
- // Create Trk message to read memory
- static QByteArray readMemoryMessage(uint pid, uint tid, uint from, uint len);
- static QByteArray readRegistersMessage(uint pid, uint tid);
- // Parse a TrkNotifyStopped message
- static bool parseNotifyStopped(const QByteArray &a,
- uint *pid, uint *tid, uint *address,
- QString *why = 0);
- // Helper message
- static QString msgStopped(uint pid, uint tid, uint address, const QString &why);
-
-signals:
- void deviceDescriptionReceived(const QString &port, const QString &description);
- void copyingStarted(const QString &fileName);
- void fileCopied(const QString &fileName);
- void canNotConnect(const QString &errorMessage);
- void canNotCreateFile(const QString &filename, const QString &errorMessage);
- void canNotOpenFile(const QString &filename, const QString &errorMessage);
- void canNotOpenLocalFile(const QString &filename, const QString &errorMessage);
- void canNotWriteFile(const QString &filename, const QString &errorMessage);
- void canNotCloseFile(const QString &filename, const QString &errorMessage);
- void installingStarted(const QString &packageName);
- void canNotInstall(const QString &packageFilename, const QString &errorMessage);
- void installingFinished();
- void startingApplication();
- void applicationRunning(uint pid);
- void canNotRun(const QString &errorMessage);
- void finished();
- void applicationOutputReceived(const QString &output);
- void copyProgress(int percent);
- void stateChanged(int);
- void processStopped(uint pc, uint pid, uint tid, const QString &reason);
- void processResumed(uint pid, uint tid);
- void libraryLoaded(const trk::Library &lib);
- void libraryUnloaded(const trk::Library &lib);
- void registersAndCallStackReadComplete(const QList<uint>& registers, const QByteArray& stack);
- // Emitted by the destructor, for releasing devices of SymbianDeviceManager by name
- void destroyed(const QString &serverName);
-
-public slots:
- void terminate();
- void resumeProcess(uint pid, uint tid);
- //can be used to obtain traceback after a breakpoint / exception
- void getRegistersAndCallStack(uint pid, uint tid);
-
-private slots:
- void handleResult(const trk::TrkResult &data);
- void slotWaitingForTrk();
-
-private:
- // kill process and breakpoints
- void cleanUp();
- void disconnectTrk();
-
- void handleRemoteProcessKilled(const TrkResult &result);
- void handleConnect(const TrkResult &result);
- void handleFileCreation(const TrkResult &result);
- void handleFileOpened(const TrkResult &result);
- void handleCopy(const TrkResult &result);
- void handleRead(const TrkResult &result);
- void continueCopying(uint lastCopiedBlockSize = 0);
- void continueReading();
- void closeRemoteFile(bool failed = false);
- void handleFileCopied(const TrkResult &result);
- void handleInstallPackageFinished(const TrkResult &result);
- void handleCpuType(const TrkResult &result);
- void handleCreateProcess(const TrkResult &result);
- void handleWaitForFinished(const TrkResult &result);
- void handleStop(const TrkResult &result);
- void handleSupportMask(const TrkResult &result);
- void handleTrkVersion(const TrkResult &result);
- void handleReadRegisters(const TrkResult &result);
- void handleReadStack(const TrkResult &result);
-
- void copyFileToRemote();
- void copyFileFromRemote();
- void installRemotePackageSilently();
- void installRemotePackageByUser();
- void installRemotePackage();
- void startInferiorIfNeeded();
- void handleFinished();
-
- void logMessage(const QString &msg);
- void setState(State s);
-
- LauncherPrivate *d;
-};
-
-} // namespace Trk
-
-#endif // LAUNCHER_H
diff --git a/src/shared/symbianutils/symbiandevicemanager.cpp b/src/shared/symbianutils/symbiandevicemanager.cpp
index b329246730..77bd1c69b5 100644
--- a/src/shared/symbianutils/symbiandevicemanager.cpp
+++ b/src/shared/symbianutils/symbiandevicemanager.cpp
@@ -31,7 +31,6 @@
**************************************************************************/
#include "symbiandevicemanager.h"
-#include "trkdevice.h"
#include "codadevice.h"
#include "virtualserialdevice.h"
@@ -85,7 +84,6 @@ public:
QString additionalInformation;
DeviceCommunicationType type;
- QSharedPointer<trk::TrkDevice> device;
QSharedPointer<Coda::CodaDevice> codaDevice;
int deviceAcquired;
};
@@ -98,11 +96,7 @@ SymbianDeviceData::SymbianDeviceData() :
bool SymbianDeviceData::isOpen() const
{
- if (device)
- return device->isOpen();
- if (codaDevice)
- return codaDevice->device()->isOpen();
- return false;
+ return codaDevice && codaDevice->device()->isOpen();
}
SymbianDeviceData::~SymbianDeviceData()
@@ -120,10 +114,7 @@ void SymbianDeviceData::forcedClose()
if (deviceAcquired)
qWarning("Device on '%s' unplugged while an operation is in progress.",
qPrintable(portName));
- if (device)
- device->close();
- else
- codaDevice->device()->close();
+ codaDevice->device()->close();
}
}
@@ -177,41 +168,6 @@ void SymbianDevice::setAdditionalInformation(const QString &a)
m_data->additionalInformation = a;
}
-SymbianDevice::TrkDevicePtr SymbianDevice::acquireDevice()
-{
- if (debug)
- qDebug() << "SymbianDevice::acquireDevice" << m_data->portName
- << "acquired: " << m_data->deviceAcquired << " open: " << isOpen();
- if (isNull() || m_data->deviceAcquired)
- return TrkDevicePtr();
- if (m_data->device.isNull()) {
- m_data->device = TrkDevicePtr(new trk::TrkDevice);
- m_data->device->setPort(m_data->portName);
- m_data->device->setSerialFrame(m_data->type == SerialPortCommunication);
- }
- m_data->deviceAcquired = 1;
- return m_data->device;
-}
-
-void SymbianDevice::releaseDevice(TrkDevicePtr *ptr /* = 0 */)
-{
- if (debug)
- qDebug() << "SymbianDevice::releaseDevice" << m_data->portName
- << " open: " << isOpen();
- if (m_data->deviceAcquired) {
- if (m_data->device->isOpen())
- m_data->device->clearWriteQueue();
- // Release if a valid pointer was passed in.
- if (ptr && !ptr->isNull()) {
- ptr->data()->disconnect();
- *ptr = TrkDevicePtr();
- }
- m_data->deviceAcquired = 0;
- } else {
- qWarning("Internal error: Attempt to release device that is not acquired.");
- }
-}
-
QString SymbianDevice::deviceDesc() const
{
return m_data->deviceDesc;
@@ -365,23 +321,6 @@ QString SymbianDeviceManager::friendlyNameForPort(const QString &port) const
return idx == -1 ? QString() : d->m_devices.at(idx).friendlyName();
}
-SymbianDeviceManager::TrkDevicePtr
- SymbianDeviceManager::acquireDevice(const QString &port)
-{
- ensureInitialized();
- const int idx = findByPortName(port);
- if (idx == -1) {
- qWarning("Attempt to acquire device '%s' that does not exist.", qPrintable(port));
- if (debug)
- qDebug() << *this;
- return TrkDevicePtr();
- }
- const TrkDevicePtr rc = d->m_devices[idx].acquireDevice();
- if (debug)
- qDebug() << "SymbianDeviceManager::acquireDevice" << port << " returns " << !rc.isNull();
- return rc;
-}
-
CodaDevicePtr SymbianDeviceManager::getCodaDevice(const QString &port)
{
ensureInitialized();
@@ -394,10 +333,6 @@ CodaDevicePtr SymbianDeviceManager::getCodaDevice(const QString &port)
return CodaDevicePtr();
}
SymbianDevice& device = d->m_devices[idx];
- if (device.m_data->device && device.m_data->device.data()->isOpen()) {
- qWarning("Attempting to open a port '%s' that is configured for TRK!", qPrintable(port));
- return CodaDevicePtr();
- }
CodaDevicePtr& devicePtr = device.m_data->codaDevice;
if (devicePtr.isNull() || !devicePtr->device()->isOpen()) {
// Check we instanciate in the correct thread - we can't afford to create the CodaDevice (and more specifically, open the VirtualSerialDevice) in a thread that isn't guaranteed to be long-lived.
@@ -487,17 +422,6 @@ void SymbianDeviceManager::update()
update(true);
}
-void SymbianDeviceManager::releaseDevice(const QString &port)
-{
- const int idx = findByPortName(port);
- if (debug)
- qDebug() << "SymbianDeviceManager::releaseDevice" << port << idx << sender();
- if (idx != -1)
- d->m_devices[idx].releaseDevice();
- else
- qWarning("Attempt to release non-existing device %s.", qPrintable(port));
-}
-
void SymbianDeviceManager::setAdditionalInformation(const QString &port, const QString &ai)
{
const int idx = findByPortName(port);
@@ -669,7 +593,7 @@ SymbianDeviceManager::SymbianDeviceList SymbianDeviceManager::serialPorts() cons
if (kernResult == KERN_SUCCESS) {
CFStringRef className = IOObjectCopyClass(grandparent);
if (CFStringCompare(className, CFSTR("IOBluetoothSerialClient"), 0) == 0) {
- // CODA doesn't support bluetooth and TRK makes connections back to the PC so we're not going to support it - use CODA :)
+ // CODA doesn't support bluetooth
match = false;
}
else if (CFStringCompare(className, CFSTR("AppleUSBCDCACMData"), 0) == 0) {
@@ -689,7 +613,7 @@ SymbianDeviceManager::SymbianDeviceList SymbianDeviceManager::serialPorts() cons
}
}
else {
- // We don't expect TRK/CODA on any other type of serial port
+ // We don't expect CODA on any other type of serial port
match = false;
}
CFRelease(className);
@@ -735,8 +659,7 @@ SymbianDeviceManager::SymbianDeviceList SymbianDeviceManager::blueToothDevices()
rc.push_back(SymbianDevice(device.take()));
}
}
- // New kernel versions support /dev/ttyUSB0, /dev/ttyUSB1. Trk responds
- // on the latter (usually), try first.
+ // New kernel versions support /dev/ttyUSB0, /dev/ttyUSB1.
static const char *usbTtyDevices[] = {
"/dev/ttyUSB3", "/dev/ttyUSB2", "/dev/ttyUSB1", "/dev/ttyUSB0",
"/dev/ttyACM3", "/dev/ttyACM2", "/dev/ttyACM1", "/dev/ttyACM0"};
diff --git a/src/shared/symbianutils/symbiandevicemanager.h b/src/shared/symbianutils/symbiandevicemanager.h
index 9deb52b232..334ea920a5 100644
--- a/src/shared/symbianutils/symbiandevicemanager.h
+++ b/src/shared/symbianutils/symbiandevicemanager.h
@@ -44,9 +44,6 @@ class QDebug;
class QTextStream;
QT_END_NAMESPACE
-namespace trk {
- class TrkDevice;
-}
namespace Coda {
class CodaDevice;
}
@@ -64,16 +61,15 @@ enum DeviceCommunicationType {
typedef QSharedPointer<Coda::CodaDevice> CodaDevicePtr;
-// SymbianDevice: Explicitly shared device data and a TrkDevice
+// SymbianDevice: Explicitly shared device data and a CodaDevice
// instance that can be acquired (exclusively) for use.
// A device removal from the manager will result in the
// device being closed.
class SYMBIANUTILS_EXPORT SymbianDevice {
explicit SymbianDevice(SymbianDeviceData *data);
friend class SymbianDeviceManager;
-public:
- typedef QSharedPointer<trk::TrkDevice> TrkDevicePtr;
+public:
SymbianDevice();
SymbianDevice(const SymbianDevice &rhs);
SymbianDevice &operator=(const SymbianDevice &rhs);
@@ -97,14 +93,6 @@ public:
QString toString() const;
private:
- // Acquire: Mark the device as 'out' and return a shared pointer
- // unless it is already in use by another owner. The result should not
- // be passed on further.
- // TRK only
- TrkDevicePtr acquireDevice();
- // Give back a device and mark it as 'free'. TRK only.
- void releaseDevice(TrkDevicePtr *ptr = 0);
-
void forcedClose();
QExplicitlySharedDataPointer<SymbianDeviceData> m_data;
@@ -129,7 +117,6 @@ class SYMBIANUTILS_EXPORT SymbianDeviceManager : public QObject
Q_OBJECT
public:
typedef QList<SymbianDevice> SymbianDeviceList;
- typedef QSharedPointer<trk::TrkDevice> TrkDevicePtr;
static const char *linuxBlueToothDeviceRootC;
@@ -143,9 +130,6 @@ public:
SymbianDeviceList devices() const;
QString toString() const;
- // Acquire a TRK device for use. Assuming the port is found, equivalent to devices()[findByPortName(port)].acquireDevice(). See also releaseDevice().
- TrkDevicePtr acquireDevice(const QString &port);
-
//// The CODA code prefers to set up the CodaDevice object itself, so we let it and just handle opening the underlying QIODevice and keeping track of the CodaDevice
//// Returns true if port was opened successfully.
@@ -167,8 +151,6 @@ public:
public slots:
void update();
- // Release a device, make it available for further use. Only for use with a TRK device
- void releaseDevice(const QString &port);
void setAdditionalInformation(const QString &port, const QString &ai);
signals:
diff --git a/src/shared/symbianutils/symbianutils.pri b/src/shared/symbianutils/symbianutils.pri
index e71dd6052d..7bb782f514 100644
--- a/src/shared/symbianutils/symbianutils.pri
+++ b/src/shared/symbianutils/symbianutils.pri
@@ -5,23 +5,15 @@ QT += network
# Input
HEADERS += $$PWD/symbianutils_global.h \
$$PWD/callback.h \
- $$PWD/trkutils.h \
- $$PWD/trkutils_p.h \
- $$PWD/trkdevice.h \
- $$PWD/launcher.h \
- $$PWD/bluetoothlistener.h \
- $$PWD/communicationstarter.h \
+ $$PWD/codautils.h \
+ $$PWD/codautils_p.h \
$$PWD/symbiandevicemanager.h \
$$PWD/codadevice.h \
$$PWD/codamessage.h \
$$PWD/json.h \
$$PWD/virtualserialdevice.h
-SOURCES += $$PWD/trkutils.cpp \
- $$PWD/trkdevice.cpp \
- $$PWD/launcher.cpp \
- $$PWD/bluetoothlistener.cpp \
- $$PWD/communicationstarter.cpp \
+SOURCES += $$PWD/codautils.cpp \
$$PWD/symbiandevicemanager.cpp \
$$PWD/codadevice.cpp \
$$PWD/codamessage.cpp \
@@ -32,12 +24,4 @@ DEFINES += HAS_SERIALPORT
win32:SOURCES += $$PWD/virtualserialdevice_win.cpp
unix:SOURCES += $$PWD/virtualserialdevice_posix.cpp
-# Tests/trklauncher is a console application
-contains(QT, gui) {
- HEADERS += $$PWD/bluetoothlistener_gui.h
- SOURCES += $$PWD/bluetoothlistener_gui.cpp
-} else {
- message(Trk: Console ...)
-}
-
macx:LIBS += -framework IOKit -framework CoreFoundation
diff --git a/src/shared/symbianutils/trkdevice.cpp b/src/shared/symbianutils/trkdevice.cpp
deleted file mode 100644
index 6f9c0424f3..0000000000
--- a/src/shared/symbianutils/trkdevice.cpp
+++ /dev/null
@@ -1,1196 +0,0 @@
-/**************************************************************************
-**
-** This file is part of Qt Creator
-**
-** Copyright (c) 2011 Nokia Corporation and/or its subsidiary(-ies).
-**
-** Contact: Nokia Corporation (info@qt.nokia.com)
-**
-**
-** GNU Lesser General Public License Usage
-**
-** This file may be used under the terms of the GNU Lesser General Public
-** License version 2.1 as published by the Free Software Foundation and
-** appearing in the file LICENSE.LGPL included in the packaging of this file.
-** Please review the following information to ensure the GNU Lesser General
-** Public License version 2.1 requirements will be met:
-** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** Other Usage
-**
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at info@qt.nokia.com.
-**
-**************************************************************************/
-
-#include "trkdevice.h"
-#include "trkutils.h"
-#include "trkutils_p.h"
-
-#include <QtCore/QString>
-#include <QtCore/QDebug>
-#include <QtCore/QQueue>
-#include <QtCore/QHash>
-#include <QtCore/QMap>
-#include <QtCore/QThread>
-#include <QtCore/QMutex>
-#include <QtCore/QWaitCondition>
-#include <QtCore/QSharedPointer>
-#include <QtCore/QScopedPointer>
-#include <QtCore/QMetaType>
-
-#ifdef Q_OS_WIN
-# include <windows.h>
-#else
-# include <QtCore/QFile>
-
-# include <stdio.h>
-# include <sys/ioctl.h>
-# include <sys/types.h>
-# include <termios.h>
-# include <errno.h>
-# include <string.h>
-# include <unistd.h>
-/* Required headers for select() according to POSIX.1-2001 */
-# include <sys/select.h>
-/* Required headers for select() according to earlier standards:
-# include <sys/time.h>
-# include <sys/types.h>
-# include <unistd.h>
-*/
-#endif
-
-#ifdef Q_OS_WIN
-
-// Format windows error from GetLastError() value:
-// TODO: Use the one provided by the utils lib.
-QString winErrorMessage(unsigned long error)
-{
- QString rc = QString::fromLatin1("#%1: ").arg(error);
- ushort *lpMsgBuf;
-
- const int len = FormatMessage(
- FORMAT_MESSAGE_ALLOCATE_BUFFER
- | FORMAT_MESSAGE_FROM_SYSTEM
- | FORMAT_MESSAGE_IGNORE_INSERTS,
- NULL, error, 0, (LPTSTR)&lpMsgBuf, 0, NULL);
- if (len) {
- rc = QString::fromUtf16(lpMsgBuf, len);
- LocalFree(lpMsgBuf);
- } else {
- rc += QString::fromLatin1("<unknown error>");
- }
- return rc;
-}
-
-#endif
-
-enum { verboseTrk = 0 };
-
-static inline QString msgAccessingClosedDevice(const QString &msg)
-{
- return QString::fromLatin1("Error: Attempt to access device '%1', which is closed.").arg(msg);
-}
-
-namespace trk {
-
-///////////////////////////////////////////////////////////////////////
-//
-// TrkMessage
-//
-///////////////////////////////////////////////////////////////////////
-
-/* A message to be send to TRK, triggering a callback on receipt
- * of the answer. */
-struct TrkMessage
-{
- explicit TrkMessage(byte code = 0u, byte token = 0u,
- TrkCallback callback = TrkCallback());
-
- byte code;
- byte token;
- QByteArray data;
- QVariant cookie;
- TrkCallback callback;
-};
-
-TrkMessage::TrkMessage(byte c, byte t, TrkCallback cb) :
- code(c),
- token(t),
- callback(cb)
-{
-}
-
-QDebug operator<<(QDebug d, const TrkMessage &msg)
-{
- return d << "Message: Code: " << msg.code
- << " Token: " << msg.token << " " << msg.data.toHex();
-}
-
-} // namespace trk
-
-Q_DECLARE_METATYPE(trk::TrkMessage)
-Q_DECLARE_METATYPE(trk::TrkResult)
-
-namespace trk {
-
-///////////////////////////////////////////////////////////////////////
-//
-// TrkWriteQueue: Mixin class that manages a write queue of Trk messages.
-// pendingMessage()/notifyWriteResult() should be called from a worked/timer
-// that writes the messages. The class does not take precautions for multithreading.
-// A no-op message is simply taken off the queue. The calling class
-// can use the helper invokeNoopMessage() to trigger its callback.
-//
-///////////////////////////////////////////////////////////////////////
-
-class TrkWriteQueue
-{
- Q_DISABLE_COPY(TrkWriteQueue)
-public:
- explicit TrkWriteQueue();
- void clear();
-
- // Enqueue messages.
- void queueTrkMessage(byte code, TrkCallback callback,
- const QByteArray &data, const QVariant &cookie);
- void queueTrkInitialPing();
-
- // Call this from the device read notification with the results.
- void slotHandleResult(const TrkResult &result, QMutex *mutex = 0);
-
- // pendingMessage() can be called periodically in a timer to retrieve
- // the pending messages to be sent.
- enum PendingMessageResult {
- NoMessage, // No message in queue.
- PendingMessage, /* There is a queued message. The calling class
- * can write it out and use notifyWriteResult()
- * to notify about the result. */
- NoopMessageDequeued // A no-op message has been dequeued. see invokeNoopMessage().
- };
-
- PendingMessageResult pendingMessage(TrkMessage *message);
- // Notify the queue about the success of the write operation
- // after taking the pendingMessage off.
- enum WriteResult {
- WriteOk,
- WriteFailedDiscard, // Discard failed message
- WriteFailedKeep // Keep failed message
- };
- void notifyWriteResult(WriteResult ok);
-
- // Helper function that invokes the callback of a no-op message
- static void invokeNoopMessage(trk::TrkMessage);
-
-private:
- typedef QMap<byte, TrkMessage> TokenMessageMap;
-
- byte nextTrkWriteToken();
-
- byte m_trkWriteToken;
- QQueue<TrkMessage> m_trkWriteQueue;
- TokenMessageMap m_writtenTrkMessages;
- bool m_trkWriteBusy;
-};
-
-TrkWriteQueue::TrkWriteQueue() :
- m_trkWriteToken(0),
- m_trkWriteBusy(false)
-{
-}
-
-void TrkWriteQueue::clear()
-{
- m_trkWriteToken = 0;
- m_trkWriteBusy = false;
- m_trkWriteQueue.clear();
- const int discarded = m_writtenTrkMessages.size();
- m_writtenTrkMessages.clear();
- if (verboseTrk)
- qDebug() << "TrkWriteQueue::clear: discarded " << discarded;
-}
-
-byte TrkWriteQueue::nextTrkWriteToken()
-{
- ++m_trkWriteToken;
- if (m_trkWriteToken == 0)
- ++m_trkWriteToken;
- if (verboseTrk)
- qDebug() << "nextTrkWriteToken:" << m_trkWriteToken;
- return m_trkWriteToken;
-}
-
-void TrkWriteQueue::queueTrkMessage(byte code, TrkCallback callback,
- const QByteArray &data, const QVariant &cookie)
-{
- const byte token = code == TRK_WRITE_QUEUE_NOOP_CODE ?
- byte(0) : nextTrkWriteToken();
- TrkMessage msg(code, token, callback);
- msg.data = data;
- msg.cookie = cookie;
- m_trkWriteQueue.append(msg);
-}
-
-TrkWriteQueue::PendingMessageResult TrkWriteQueue::pendingMessage(TrkMessage *message)
-{
- // Invoked from timer, try to flush out message queue
- if (m_trkWriteBusy || m_trkWriteQueue.isEmpty())
- return NoMessage;
- // Handle the noop message, just invoke CB in slot (ower thread)
- if (m_trkWriteQueue.front().code == TRK_WRITE_QUEUE_NOOP_CODE) {
- *message = m_trkWriteQueue.dequeue();
- return NoopMessageDequeued;
- }
- // Insert into map fir answers (as reading threads might get an
- // answer before notifyWriteResult(true)) is called.
- *message = m_trkWriteQueue.front();
- m_writtenTrkMessages.insert(message->token, *message);
- m_trkWriteBusy = true;
- return PendingMessage;
-}
-
-void TrkWriteQueue::invokeNoopMessage(trk::TrkMessage noopMessage)
-{
- TrkResult result;
- result.code = noopMessage.code;
- result.token = noopMessage.token;
- result.data = noopMessage.data;
- result.cookie = noopMessage.cookie;
- noopMessage.callback(result);
-}
-
-void TrkWriteQueue::notifyWriteResult(WriteResult wr)
-{
- // On success, dequeue message and await result
- const byte token = m_trkWriteQueue.front().token;
- switch (wr) {
- case WriteOk:
- m_trkWriteQueue.dequeue();
- break;
- case WriteFailedKeep:
- case WriteFailedDiscard:
- m_writtenTrkMessages.remove(token);
- m_trkWriteBusy = false;
- if (wr == WriteFailedDiscard)
- m_trkWriteQueue.dequeue();
- break;
- }
-}
-
-void TrkWriteQueue::slotHandleResult(const TrkResult &result, QMutex *mutex)
-{
- // Find which request the message belongs to and invoke callback
- // if ACK or on NAK if desired.
- if (mutex)
- mutex->lock();
- m_trkWriteBusy = false;
- const TokenMessageMap::iterator it = m_writtenTrkMessages.find(result.token);
- if (it == m_writtenTrkMessages.end()) {
- if (mutex)
- mutex->unlock();
- return;
- }
- TrkCallback callback = it.value().callback;
- const QVariant cookie = it.value().cookie;
- m_writtenTrkMessages.erase(it);
- if (mutex)
- mutex->unlock();
- // Invoke callback
- if (callback) {
- TrkResult result1 = result;
- result1.cookie = cookie;
- callback(result1);
- }
-}
-
-void TrkWriteQueue::queueTrkInitialPing()
-{
- // Ping, reset sequence count
- m_trkWriteToken = 0;
- m_trkWriteQueue.append(TrkMessage(TrkPing, 0));
-}
-
-///////////////////////////////////////////////////////////////////////
-//
-// DeviceContext to be shared between threads
-//
-///////////////////////////////////////////////////////////////////////
-
-struct DeviceContext {
- DeviceContext();
-#ifdef Q_OS_WIN
- HANDLE device;
- OVERLAPPED readOverlapped;
- OVERLAPPED writeOverlapped;
-#else
- QFile file;
-#endif
- bool serialFrame;
- QMutex mutex;
-};
-
-DeviceContext::DeviceContext() :
-#ifdef Q_OS_WIN
- device(INVALID_HANDLE_VALUE),
-#endif
- serialFrame(true)
-{
-}
-
-///////////////////////////////////////////////////////////////////////
-//
-// TrkWriterThread: A thread operating a TrkWriteQueue.
-// with exception of the handling of the TRK_WRITE_QUEUE_NOOP_CODE
-// synchronization message. The invocation of the callback is then
-// done by the thread owning the TrkWriteQueue, while pendingMessage() is called
-// from another thread. This happens via a Qt::BlockingQueuedConnection.
-
-///////////////////////////////////////////////////////////////////////
-
-class WriterThread : public QThread
-{
- Q_OBJECT
- Q_DISABLE_COPY(WriterThread)
-public:
- explicit WriterThread(const QSharedPointer<DeviceContext> &context);
-
- // Enqueue messages.
- void queueTrkMessage(byte code, TrkCallback callback,
- const QByteArray &data, const QVariant &cookie);
- void queueTrkInitialPing();
-
- void clearWriteQueue();
-
- // Call this from the device read notification with the results.
- void slotHandleResult(const TrkResult &result);
-
- virtual void run();
-
-signals:
- void error(const QString &);
- void internalNoopMessageDequeued(const trk::TrkMessage&);
-
-public slots:
- bool trkWriteRawMessage(const TrkMessage &msg);
- void terminate();
- void tryWrite();
-
-private slots:
- void invokeNoopMessage(const trk::TrkMessage &);
-
-private:
- bool write(const QByteArray &data, QString *errorMessage);
- inline int writePendingMessage();
-
- const QSharedPointer<DeviceContext> m_context;
- QMutex m_dataMutex;
- QMutex m_waitMutex;
- QWaitCondition m_waitCondition;
- TrkWriteQueue m_queue;
- bool m_terminate;
-};
-
-WriterThread::WriterThread(const QSharedPointer<DeviceContext> &context) :
- m_context(context),
- m_terminate(false)
-{
- static const int trkMessageMetaId = qRegisterMetaType<trk::TrkMessage>();
- Q_UNUSED(trkMessageMetaId)
- connect(this, SIGNAL(internalNoopMessageDequeued(trk::TrkMessage)),
- this, SLOT(invokeNoopMessage(trk::TrkMessage)), Qt::BlockingQueuedConnection);
-}
-
-void WriterThread::run()
-{
- while (writePendingMessage() == 0) ;
-}
-
-int WriterThread::writePendingMessage()
-{
- enum { MaxAttempts = 100, RetryIntervalMS = 200 };
-
- // Wait. Use a timeout in case something is already queued before we
- // start up or some weird hanging exit condition
- m_waitMutex.lock();
- m_waitCondition.wait(&m_waitMutex, 100);
- m_waitMutex.unlock();
- if (m_terminate)
- return 1;
-
- // Send off message
- m_dataMutex.lock();
- TrkMessage message;
- const TrkWriteQueue::PendingMessageResult pr = m_queue.pendingMessage(&message);
- m_dataMutex.unlock();
-
- switch (pr) {
- case TrkWriteQueue::NoMessage:
- break;
- case TrkWriteQueue::PendingMessage: {
- //qDebug() << "Write pending message " << message;
- // Untested: try to re-send a few times
- bool success = false;
- for (int r = 0; !success && (r < MaxAttempts); r++) {
- success = trkWriteRawMessage(message);
- if (!success) {
- emit error(QString::fromLatin1("Write failure, attempt %1 of %2.").arg(r).arg(int(MaxAttempts)));
- if (m_terminate)
- return 1;
- QThread::msleep(RetryIntervalMS);
- }
- }
- // Notify queue. If still failed, give up.
- m_dataMutex.lock();
- m_queue.notifyWriteResult(success ? TrkWriteQueue::WriteOk : TrkWriteQueue::WriteFailedDiscard);
- m_dataMutex.unlock();
- }
- break;
- case TrkWriteQueue::NoopMessageDequeued:
- // Sync with thread that owns us via a blocking signal
- if (verboseTrk)
- qDebug() << "Noop message dequeued" << message;
- emit internalNoopMessageDequeued(message);
- break;
- } // switch
- return 0;
-}
-
-void WriterThread::invokeNoopMessage(const trk::TrkMessage &msg)
-{
- TrkWriteQueue::invokeNoopMessage(msg);
-}
-
-void WriterThread::terminate()
-{
- m_terminate = true;
- m_waitCondition.wakeAll();
- wait();
- m_terminate = false;
- m_queue.clear();
-}
-
-#ifdef Q_OS_WIN
-
-static inline QString msgTerminated(int size)
-{
- return QString::fromLatin1("Terminated with %1 bytes pending.").arg(size);
-}
-
-// Interruptible synchronous write function.
-static inline bool overlappedSyncWrite(HANDLE file,
- const bool &terminateFlag,
- const char *data,
- DWORD size, DWORD *charsWritten,
- OVERLAPPED *overlapped,
- QString *errorMessage)
-{
- if (WriteFile(file, data, size, charsWritten, overlapped))
- return true;
- const DWORD writeError = GetLastError();
- if (writeError != ERROR_IO_PENDING) {
- *errorMessage = QString::fromLatin1("WriteFile failed: %1").arg(winErrorMessage(writeError));
- return false;
- }
- // Wait for written or thread terminated
- const DWORD timeoutMS = 200;
- const unsigned maxAttempts = 20;
- DWORD wr = WaitForSingleObject(overlapped->hEvent, timeoutMS);
- for (unsigned n = 0; wr == WAIT_TIMEOUT && n < maxAttempts && !terminateFlag;
- wr = WaitForSingleObject(overlapped->hEvent, timeoutMS), n++);
- if (terminateFlag) {
- *errorMessage = msgTerminated(size);
- return false;
- }
- switch (wr) {
- case WAIT_OBJECT_0:
- break;
- case WAIT_TIMEOUT:
- *errorMessage = QString::fromLatin1("Write timed out.");
- return false;
- default:
- *errorMessage = QString::fromLatin1("Error while waiting for WriteFile results: %1").arg(winErrorMessage(GetLastError()));
- return false;
- }
- if (!GetOverlappedResult(file, overlapped, charsWritten, TRUE)) {
- *errorMessage = QString::fromLatin1("Error writing %1 bytes: %2").arg(size).arg(winErrorMessage(GetLastError()));
- return false;
- }
- return true;
-}
-#endif
-
-bool WriterThread::write(const QByteArray &data, QString *errorMessage)
-{
- if (verboseTrk)
- qDebug() << "Write raw data: " << stringFromArray(data).toLatin1();
- QMutexLocker locker(&m_context->mutex);
-#ifdef Q_OS_WIN
- DWORD charsWritten;
- if (!overlappedSyncWrite(m_context->device, m_terminate, data.data(), data.size(), &charsWritten, &m_context->writeOverlapped, errorMessage)) {
- return false;
- }
- FlushFileBuffers(m_context->device);
- return true;
-#else
- if (m_context->file.write(data) == -1 || !m_context->file.flush()) {
- *errorMessage = QString::fromLatin1("Cannot write: %1").arg(m_context->file.errorString());
- return false;
- }
- return true;
-#endif
-}
-
-bool WriterThread::trkWriteRawMessage(const TrkMessage &msg)
-{
- const QByteArray ba = frameMessage(msg.code, msg.token, msg.data, m_context->serialFrame);
- QString errorMessage;
- const bool rc = write(ba, &errorMessage);
- if (!rc) {
- qWarning("%s\n", qPrintable(errorMessage));
- emit error(errorMessage);
- }
- return rc;
-}
-
-void WriterThread::tryWrite()
-{
- m_waitCondition.wakeAll();
-}
-
-void WriterThread::queueTrkMessage(byte code, TrkCallback callback,
- const QByteArray &data, const QVariant &cookie)
-{
- m_dataMutex.lock();
- m_queue.queueTrkMessage(code, callback, data, cookie);
- m_dataMutex.unlock();
- tryWrite();
-}
-
-void WriterThread::clearWriteQueue()
-{
- m_dataMutex.lock();
- m_queue.clear();
- m_dataMutex.unlock();
-}
-
-void WriterThread::queueTrkInitialPing()
-{
- m_dataMutex.lock();
- m_queue.queueTrkInitialPing();
- m_dataMutex.unlock();
- tryWrite();
-}
-
-// Call this from the device read notification with the results.
-void WriterThread::slotHandleResult(const TrkResult &result)
-{
- m_queue.slotHandleResult(result, &m_dataMutex);
- tryWrite(); // Have messages been enqueued in-between?
-}
-
-
-///////////////////////////////////////////////////////////////////////
-//
-// ReaderThreadBase: Base class for a thread that reads data from
-// the device, decodes the messages and emit signals for the messages.
-// A Qt::BlockingQueuedConnection should be used for the message signal
-// to ensure messages are processed in the correct sequence.
-//
-///////////////////////////////////////////////////////////////////////
-
-class ReaderThreadBase : public QThread
-{
- Q_OBJECT
- Q_DISABLE_COPY(ReaderThreadBase)
-public:
-
- int bytesPending() const { return m_trkReadBuffer.size(); }
-
-signals:
- void messageReceived(const trk::TrkResult &result, const QByteArray &rawData);
-
-protected:
- explicit ReaderThreadBase(const QSharedPointer<DeviceContext> &context);
- void processData(const QByteArray &a);
- void processData(char c);
-
- const QSharedPointer<DeviceContext> m_context;
-
-private:
- void readMessages();
-
- QByteArray m_trkReadBuffer;
- bool linkEstablishmentMode;
-};
-
-ReaderThreadBase::ReaderThreadBase(const QSharedPointer<DeviceContext> &context) :
- m_context(context), linkEstablishmentMode(true)
-{
- static const int trkResultMetaId = qRegisterMetaType<trk::TrkResult>();
- Q_UNUSED(trkResultMetaId)
-}
-
-void ReaderThreadBase::processData(const QByteArray &a)
-{
- m_trkReadBuffer += a;
- readMessages();
-}
-
-void ReaderThreadBase::processData(char c)
-{
- m_trkReadBuffer += c;
- if (m_trkReadBuffer.size() > 1)
- readMessages();
-}
-
-void ReaderThreadBase::readMessages()
-{
- TrkResult r;
- QByteArray rawData;
- while (extractResult(&m_trkReadBuffer, m_context->serialFrame, &r, linkEstablishmentMode, &rawData)) {
- emit messageReceived(r, rawData);
- }
-}
-
-#ifdef Q_OS_WIN
-///////////////////////////////////////////////////////////////////////
-//
-// WinReaderThread: A thread reading from the device using Windows API.
-// Waits on an overlapped I/O handle and an event that tells the thread to
-// terminate.
-//
-///////////////////////////////////////////////////////////////////////
-
-class WinReaderThread : public ReaderThreadBase
-{
- Q_OBJECT
- Q_DISABLE_COPY(WinReaderThread)
-public:
- explicit WinReaderThread(const QSharedPointer<DeviceContext> &context);
- ~WinReaderThread();
-
- virtual void run();
-
-signals:
- void error(const QString &);
-
-public slots:
- void terminate();
-
-private:
- enum Handles { FileHandle, TerminateEventHandle, HandleCount };
-
- inline int tryRead();
-
- HANDLE m_handles[HandleCount];
- bool m_terminated;
-};
-
-WinReaderThread::WinReaderThread(const QSharedPointer<DeviceContext> &context) :
- ReaderThreadBase(context), m_terminated(false)
-{
- m_handles[FileHandle] = NULL;
- m_handles[TerminateEventHandle] = CreateEvent(NULL, FALSE, FALSE, NULL);
-}
-
-WinReaderThread::~WinReaderThread()
-{
- CloseHandle(m_handles[TerminateEventHandle]);
-}
-
-// Return 0 to continue or error code
-int WinReaderThread::tryRead()
-{
- enum { BufSize = 1024 };
- char buffer[BufSize];
- // Check if there are already bytes waiting. If not, wait for first byte
- COMSTAT comStat;
- if (!ClearCommError(m_context->device, NULL, &comStat)){
- emit error(QString::fromLatin1("ClearCommError failed: %1").arg(winErrorMessage(GetLastError())));
- return -7;
- }
- const DWORD bytesToRead = qMax(DWORD(1), qMin(comStat.cbInQue, DWORD(BufSize)));
- // Trigger read
- DWORD bytesRead = 0;
- if (ReadFile(m_context->device, &buffer, bytesToRead, &bytesRead, &m_context->readOverlapped)) {
- if (m_terminated)
- return 1;
- switch (bytesRead) {
- case 0:
- //happens when the USB port has a different settings then the default ones
- Sleep(100);
- break;
- case 1:
- processData(buffer[0]);
- break;
- default:
- processData(QByteArray(buffer, bytesRead));
- break;
- }
- return 0;
- }
- const DWORD readError = GetLastError();
- if (readError != ERROR_IO_PENDING) {
- emit error(QString::fromLatin1("Read error: %1").arg(winErrorMessage(readError)));
- return -1;
- }
- // Wait for either termination or data
- const DWORD wr = WaitForMultipleObjects(HandleCount, m_handles, false, INFINITE);
- if (wr == WAIT_FAILED) {
- emit error(QString::fromLatin1("Wait failed: %1").arg(winErrorMessage(GetLastError())));
- return -2;
- }
- if (wr - WAIT_OBJECT_0 == TerminateEventHandle) {
- return 1; // Terminate
- }
- // Check data
- if (!GetOverlappedResult(m_context->device, &m_context->readOverlapped, &bytesRead, true)) {
- emit error(QString::fromLatin1("GetOverlappedResult failed: %1").arg(winErrorMessage(GetLastError())));
- return -3;
- }
- if (bytesRead == 1) {
- processData(buffer[0]);
- } else {
- processData(QByteArray(buffer, bytesRead));
- }
- return 0;
-}
-
-void WinReaderThread::run()
-{
- m_handles[FileHandle] = m_context->readOverlapped.hEvent;
- while ( tryRead() == 0) ;
-}
-
-void WinReaderThread::terminate()
-{
- m_terminated = true;
- SetEvent(m_handles[TerminateEventHandle]);
- wait();
-}
-
-typedef WinReaderThread ReaderThread;
-
-#else
-
-///////////////////////////////////////////////////////////////////////
-//
-// UnixReaderThread: A thread reading from the device.
-// Uses select() to wait and a special ioctl() to find out the number
-// of bytes queued. For clean termination, the self-pipe trick is used.
-// The class maintains a pipe, on whose read end the select waits besides
-// the device file handle. To terminate, a byte is written to the pipe.
-//
-///////////////////////////////////////////////////////////////////////
-
-static inline QString msgUnixCallFailedErrno(const char *func, int errorNumber)
-{
- return QString::fromLatin1("Call to %1() failed: %2").arg(QLatin1String(func), QString::fromLocal8Bit(strerror(errorNumber)));
-}
-
-class UnixReaderThread : public ReaderThreadBase {
- Q_OBJECT
- Q_DISABLE_COPY(UnixReaderThread)
-public:
- explicit UnixReaderThread(const QSharedPointer<DeviceContext> &context);
- ~UnixReaderThread();
-
- virtual void run();
-
-signals:
- void error(const QString &);
-
-public slots:
- void terminate();
-
-private:
- inline int tryRead();
-
- int m_terminatePipeFileDescriptors[2];
-};
-
-UnixReaderThread::UnixReaderThread(const QSharedPointer<DeviceContext> &context) :
- ReaderThreadBase(context)
-{
- m_terminatePipeFileDescriptors[0] = m_terminatePipeFileDescriptors[1] = -1;
- // Set up pipes for termination. Should not fail
- if (pipe(m_terminatePipeFileDescriptors) < 0)
- qWarning("%s\n", qPrintable(msgUnixCallFailedErrno("pipe", errno)));
-}
-
-UnixReaderThread::~UnixReaderThread()
-{
- close(m_terminatePipeFileDescriptors[0]);
- close(m_terminatePipeFileDescriptors[1]);
-}
-
-int UnixReaderThread::tryRead()
-{
- fd_set readSet, tempReadSet, tempExceptionSet;
- struct timeval timeOut;
- const int fileDescriptor = m_context->file.handle();
- FD_ZERO(&readSet);
- FD_SET(fileDescriptor, &readSet);
- FD_SET(m_terminatePipeFileDescriptors[0], &readSet);
- const int maxFileDescriptor = qMax(m_terminatePipeFileDescriptors[0], fileDescriptor);
- int result = 0;
- do {
- memcpy(&tempReadSet, &readSet, sizeof(fd_set));
- memcpy(&tempExceptionSet, &readSet, sizeof(fd_set));
- timeOut.tv_sec = 1;
- timeOut.tv_usec = 0;
- result = select(maxFileDescriptor + 1, &tempReadSet, NULL, &tempExceptionSet, &timeOut);
- } while ( result < 0 && errno == EINTR );
- // Timeout?
- if (result == 0)
- return 0;
- // Something wrong?
- if (result < 0) {
- emit error(msgUnixCallFailedErrno("select", errno));
- return -1;
- }
- // Did the exception set trigger on the device?
- if (FD_ISSET(fileDescriptor,&tempExceptionSet)) {
- emit error(QLatin1String("An Exception occurred on the device."));
- return -2;
- }
- // Check termination pipe.
- if (FD_ISSET(m_terminatePipeFileDescriptors[0], &tempReadSet)
- || FD_ISSET(m_terminatePipeFileDescriptors[0], &tempExceptionSet))
- return 1;
-
- // determine number of pending bytes and read
- int numBytes;
- if (ioctl(fileDescriptor, FIONREAD, &numBytes) < 0) {
- emit error(msgUnixCallFailedErrno("ioctl", errno));
- return -1;
- }
- m_context->mutex.lock();
- const QByteArray data = m_context->file.read(numBytes);
- m_context->mutex.unlock();
- processData(data);
- return 0;
-}
-
-void UnixReaderThread::run()
-{
- // Read loop
- while (tryRead() == 0)
- ;
-}
-
-void UnixReaderThread::terminate()
-{
- // Trigger select() by writing to the pipe
- char c = 0;
- const int written = write(m_terminatePipeFileDescriptors[1], &c, 1);
- Q_UNUSED(written)
- wait();
-}
-
-typedef UnixReaderThread ReaderThread;
-
-#endif
-
-///////////////////////////////////////////////////////////////////////
-//
-// TrkDevicePrivate
-//
-///////////////////////////////////////////////////////////////////////
-
-struct TrkDevicePrivate
-{
- TrkDevicePrivate();
-
- QSharedPointer<DeviceContext> deviceContext;
- QScopedPointer<WriterThread> writerThread;
- QScopedPointer<ReaderThread> readerThread;
-
- QByteArray trkReadBuffer;
- int verbose;
- QString errorString;
- QString port;
-};
-
-///////////////////////////////////////////////////////////////////////
-//
-// TrkDevice
-//
-///////////////////////////////////////////////////////////////////////
-
-TrkDevicePrivate::TrkDevicePrivate() :
- deviceContext(new DeviceContext),
- verbose(0)
-{
-}
-
-///////////////////////////////////////////////////////////////////////
-//
-// TrkDevice
-//
-///////////////////////////////////////////////////////////////////////
-
-TrkDevice::TrkDevice(QObject *parent) :
- QObject(parent),
- d(new TrkDevicePrivate)
-{}
-
-TrkDevice::~TrkDevice()
-{
- close();
- delete d;
-}
-
-bool TrkDevice::open(QString *errorMessage)
-{
- if (d->verbose || verboseTrk)
- qDebug() << "Opening" << port() << "is open: " << isOpen() << " serialFrame=" << serialFrame();
- if (isOpen())
- return true;
- if (d->port.isEmpty()) {
- *errorMessage = QLatin1String("Internal error: No port set on TrkDevice");
- return false;
- }
-#ifdef Q_OS_WIN
- const QString fullPort = QLatin1String("\\\\.\\") + d->port;
- d->deviceContext->device = CreateFile(reinterpret_cast<const WCHAR*>(fullPort.utf16()),
- GENERIC_READ | GENERIC_WRITE,
- 0,
- NULL,
- OPEN_EXISTING,
- FILE_ATTRIBUTE_NORMAL|FILE_FLAG_NO_BUFFERING|FILE_FLAG_OVERLAPPED,
- NULL);
-
- if (INVALID_HANDLE_VALUE == d->deviceContext->device) {
- *errorMessage = QString::fromLatin1("Could not open device '%1': %2").arg(port(), winErrorMessage(GetLastError()));
- return false;
- }
-
- //reset COM settings to the default values
- COMMTIMEOUTS timeouts;
- timeouts.ReadIntervalTimeout = 0;
- timeouts.ReadTotalTimeoutMultiplier = 0;
- timeouts.ReadTotalTimeoutConstant = 0;
- timeouts.WriteTotalTimeoutMultiplier = 0;
- timeouts.WriteTotalTimeoutConstant = 0;
- SetCommTimeouts(d->deviceContext->device, &timeouts);
-
- memset(&d->deviceContext->readOverlapped, 0, sizeof(OVERLAPPED));
- d->deviceContext->readOverlapped.hEvent = CreateEvent(NULL, TRUE, FALSE, NULL);
- memset(&d->deviceContext->writeOverlapped, 0, sizeof(OVERLAPPED));
- d->deviceContext->writeOverlapped.hEvent = CreateEvent(NULL, TRUE, FALSE, NULL);
- if (d->deviceContext->readOverlapped.hEvent == NULL || d->deviceContext->writeOverlapped.hEvent == NULL) {
- *errorMessage = QString::fromLatin1("Failed to create events: %1").arg(winErrorMessage(GetLastError()));
- return false;
- }
-#else
- d->deviceContext->file.setFileName(d->port);
- if (!d->deviceContext->file.open(QIODevice::ReadWrite|QIODevice::Unbuffered)) {
- *errorMessage = QString::fromLatin1("Cannot open %1: %2").arg(d->port, d->deviceContext->file.errorString());
- return false;
- }
-
- struct termios termInfo;
- if (tcgetattr(d->deviceContext->file.handle(), &termInfo) < 0) {
- *errorMessage = QString::fromLatin1("Unable to retrieve terminal settings: %1 %2").arg(errno).arg(QString::fromAscii(strerror(errno)));
- return false;
- }
- // Turn off terminal echo as not get messages back, among other things
- termInfo.c_cflag |= CREAD|CLOCAL;
- termInfo.c_lflag &= (~(ICANON|ECHO|ECHOE|ECHOK|ECHONL|ISIG));
- termInfo.c_iflag &= (~(INPCK|IGNPAR|PARMRK|ISTRIP|ICRNL|IXANY));
- termInfo.c_oflag &= (~OPOST);
- termInfo.c_cc[VMIN] = 0;
- termInfo.c_cc[VINTR] = _POSIX_VDISABLE;
- termInfo.c_cc[VQUIT] = _POSIX_VDISABLE;
- termInfo.c_cc[VSTART] = _POSIX_VDISABLE;
- termInfo.c_cc[VSTOP] = _POSIX_VDISABLE;
- termInfo.c_cc[VSUSP] = _POSIX_VDISABLE;
- if (tcsetattr(d->deviceContext->file.handle(), TCSAFLUSH, &termInfo) < 0) {
- *errorMessage = QString::fromLatin1("Unable to apply terminal settings: %1 %2").arg(errno).arg(QString::fromAscii(strerror(errno)));
- return false;
- }
-#endif
- d->readerThread.reset(new ReaderThread(d->deviceContext));
- connect(d->readerThread.data(), SIGNAL(error(QString)), this, SLOT(emitError(QString)),
- Qt::QueuedConnection);
- connect(d->readerThread.data(), SIGNAL(messageReceived(trk::TrkResult,QByteArray)),
- this, SLOT(slotMessageReceived(trk::TrkResult,QByteArray)),
- Qt::QueuedConnection);
- d->readerThread->start();
-
- d->writerThread.reset(new WriterThread(d->deviceContext));
- connect(d->writerThread.data(), SIGNAL(error(QString)), this, SLOT(emitError(QString)),
- Qt::QueuedConnection);
- d->writerThread->start();
-
- if (d->verbose || verboseTrk)
- qDebug() << "Opened" << d->port << d->readerThread.data() << d->writerThread.data();
- return true;
-}
-
-void TrkDevice::close()
-{
- if (verboseTrk)
- qDebug() << "close" << d->port << " is open: " << isOpen()
- << " read pending " << (d->readerThread.isNull() ? 0 : d->readerThread->bytesPending())
- << sender();
- if (!isOpen())
- return;
- if (d->readerThread)
- d->readerThread->terminate();
- if (d->writerThread)
- d->writerThread->terminate();
-#ifdef Q_OS_WIN
- CloseHandle(d->deviceContext->device);
- d->deviceContext->device = INVALID_HANDLE_VALUE;
- CloseHandle(d->deviceContext->readOverlapped.hEvent);
- CloseHandle(d->deviceContext->writeOverlapped.hEvent);
- d->deviceContext->readOverlapped.hEvent = d->deviceContext->writeOverlapped.hEvent = NULL;
-#else
- d->deviceContext->file.close();
-#endif
-
- if (d->verbose)
- emitLogMessage("Close");
-}
-
-bool TrkDevice::isOpen() const
-{
-#ifdef Q_OS_WIN
- return d->deviceContext->device != INVALID_HANDLE_VALUE;
-#else
- return d->deviceContext->file.isOpen();
-#endif
-}
-
-QString TrkDevice::port() const
-{
- return d->port;
-}
-
-void TrkDevice::setPort(const QString &p)
-{
- if (verboseTrk)
- qDebug() << "setPort" << p;
- d->port = p;
-}
-
-QString TrkDevice::errorString() const
-{
- return d->errorString;
-}
-
-bool TrkDevice::serialFrame() const
-{
- return d->deviceContext->serialFrame;
-}
-
-void TrkDevice::setSerialFrame(bool f)
-{
- if (verboseTrk)
- qDebug() << "setSerialFrame" << f;
- d->deviceContext->serialFrame = f;
-}
-
-int TrkDevice::verbose() const
-{
- return d->verbose;
-}
-
-void TrkDevice::setVerbose(int b)
-{
- d->verbose = b;
-}
-
-void TrkDevice::slotMessageReceived(const trk::TrkResult &result, const QByteArray &rawData)
-{
- if (isOpen()) { // Might receive bytes after closing due to queued connections.
- d->writerThread->slotHandleResult(result);
- if (d->verbose > 1)
- qDebug() << "TRK DEVICE Received: " << result.toString();
- emit messageReceived(result);
- if (!rawData.isEmpty())
- emit rawDataReceived(rawData);
- }
-}
-
-void TrkDevice::emitError(const QString &s)
-{
- d->errorString = s;
- qWarning("%s\n", qPrintable(s));
- emit error(s);
-}
-
-void TrkDevice::clearWriteQueue()
-{
- if (isOpen())
- d->writerThread->clearWriteQueue();
-}
-
-void TrkDevice::sendTrkMessage(byte code, TrkCallback callback,
- const QByteArray &data, const QVariant &cookie)
-{
- if (!isOpen()) {
- emitError(msgAccessingClosedDevice(d->port));
- return;
- }
- if (!d->writerThread.isNull()) {
- if (d->verbose > 1) {
- QByteArray msg = "Sending: 0x";
- msg += QByteArray::number(code, 16);
- msg += ": ";
- msg += stringFromArray(data).toLatin1();
- if (cookie.isValid())
- msg += " Cookie: " + cookie.toString().toLatin1();
- qDebug("%s", msg.data());
- }
- d->writerThread->queueTrkMessage(code, callback, data, cookie);
- }
-}
-
-void TrkDevice::sendTrkInitialPing()
-{
- if (!isOpen()) {
- emitError(msgAccessingClosedDevice(d->port));
- return;
- }
- if (!d->writerThread.isNull())
- d->writerThread->queueTrkInitialPing();
-}
-
-bool TrkDevice::sendTrkAck(byte token)
-{
- if (!isOpen()) {
- emitError(msgAccessingClosedDevice(d->port));
- return false;
- }
- if (d->writerThread.isNull())
- return false;
- // The acknowledgement must not be queued!
- TrkMessage msg(0x80, token);
- msg.token = token;
- msg.data.append('\0');
- if (verboseTrk)
- qDebug() << "Write synchroneous message: " << msg;
- return d->writerThread->trkWriteRawMessage(msg);
- // 01 90 00 07 7e 80 01 00 7d 5e 7e
-}
-
-void TrkDevice::emitLogMessage(const QString &msg)
-{
- if (d->verbose)
- qDebug("%s\n", qPrintable(msg));
- emit logMessage(msg);
-}
-
-} // namespace trk
-
-#include "trkdevice.moc"
diff --git a/src/shared/symbianutils/trkdevice.h b/src/shared/symbianutils/trkdevice.h
deleted file mode 100644
index a8b0d339b4..0000000000
--- a/src/shared/symbianutils/trkdevice.h
+++ /dev/null
@@ -1,134 +0,0 @@
-/**************************************************************************
-**
-** This file is part of Qt Creator
-**
-** Copyright (c) 2011 Nokia Corporation and/or its subsidiary(-ies).
-**
-** Contact: Nokia Corporation (info@qt.nokia.com)
-**
-**
-** GNU Lesser General Public License Usage
-**
-** This file may be used under the terms of the GNU Lesser General Public
-** License version 2.1 as published by the Free Software Foundation and
-** appearing in the file LICENSE.LGPL included in the packaging of this file.
-** Please review the following information to ensure the GNU Lesser General
-** Public License version 2.1 requirements will be met:
-** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** Other Usage
-**
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at info@qt.nokia.com.
-**
-**************************************************************************/
-
-#ifndef TRKDEVICE_H
-#define TRKDEVICE_H
-
-#include "symbianutils_global.h"
-#include "callback.h"
-
-#include <QtCore/QObject>
-#include <QtCore/QVariant>
-#include <QtCore/QByteArray>
-#include <QtCore/QSharedPointer>
-
-QT_BEGIN_NAMESPACE
-class QIODevice;
-QT_END_NAMESPACE
-
-namespace trk {
-
-struct TrkResult;
-struct TrkMessage;
-struct TrkDevicePrivate;
-
-/* TrkDevice: Implements a Windows COM or Linux device for
- * Trk communications. Provides synchronous write and asynchronous
- * read operation.
- * The serialFrames property specifies whether packets are encapsulated in
- * "0x90 <length>" frames, which is currently the case for serial ports.
- * Contains a write message queue allowing
- * for queueing messages with a notification callback. If the message receives
- * an ACK, the callback is invoked.
- * The special message TRK_WRITE_QUEUE_NOOP_CODE code can be used for synchronization.
- * The respective message will not be sent, the callback is just invoked.
- * Note that calling open/close in quick succession can cause crashes
- * due to the use of queused signals. */
-
-enum { TRK_WRITE_QUEUE_NOOP_CODE = 0x7f };
-
-typedef trk::Callback<const TrkResult &> TrkCallback;
-
-class SYMBIANUTILS_EXPORT TrkDevice : public QObject
-{
- Q_OBJECT
- Q_PROPERTY(bool serialFrame READ serialFrame WRITE setSerialFrame)
- Q_PROPERTY(bool verbose READ verbose WRITE setVerbose)
- Q_PROPERTY(QString port READ port WRITE setPort)
-public:
- explicit TrkDevice(QObject *parent = 0);
- virtual ~TrkDevice();
-
- bool open(QString *errorMessage);
- bool isOpen() const;
-
- QString port() const;
- void setPort(const QString &p);
-
- QString errorString() const;
-
- bool serialFrame() const;
- void setSerialFrame(bool f);
-
- int verbose() const;
- void setVerbose(int b);
-
- // Enqueue a message with a notification callback.
- void sendTrkMessage(unsigned char code,
- TrkCallback callBack = TrkCallback(),
- const QByteArray &data = QByteArray(),
- const QVariant &cookie = QVariant());
-
- // Enqeue an initial ping
- void sendTrkInitialPing();
-
- // Send an Ack synchronously, bypassing the queue
- bool sendTrkAck(unsigned char token);
-
-public slots:
- void clearWriteQueue();
-
-signals:
- void messageReceived(const trk::TrkResult &result);
- // Emitted with the contents of messages enclosed in 07e, not for log output
- void rawDataReceived(const QByteArray &data);
- void error(const QString &msg);
- void logMessage(const QString &msg);
-
-private slots:
- void slotMessageReceived(const trk::TrkResult &result, const QByteArray &a);
-
-protected slots:
- void emitError(const QString &msg);
- void emitLogMessage(const QString &msg);
-
-public slots:
- void close();
-
-private:
- void readMessages();
- TrkDevicePrivate *d;
-};
-
-} // namespace trk
-
-#endif // TRKDEVICE_H