summaryrefslogtreecommitdiffstats
path: root/tools
diff options
context:
space:
mode:
authorShane Kearns <shane.kearns@sosco.com>2010-01-21 08:40:24 (GMT)
committerShane Kearns <shane.kearns@sosco.com>2010-01-21 09:06:58 (GMT)
commit984c931c4a7385281d0acbc22adb22e49ded768e (patch)
tree7aa77d92e3e3de1f46f69ba92c2d521b711d1186 /tools
parent15bf93ba9acf7dceef2a2b16d4664b172d264086 (diff)
downloadQt-984c931c4a7385281d0acbc22adb22e49ded768e.zip
Qt-984c931c4a7385281d0acbc22adb22e49ded768e.tar.gz
Qt-984c931c4a7385281d0acbc22adb22e49ded768e.tar.bz2
Merge TRK client changes from upstream (QtCreator)
commit 1b77161e7183cdd4b5493698b4cddc727468f0f5 Author: hjk <qtc-committer@nokia.com> Date: Fri Jan 15 12:01:26 2010 +0100 debugger: clean up verbosity settings in trk adapter commit 4d7341becac684f5feb908e45d8b1756b4823c20 Author: hjk <qtc-committer@nokia.com> Date: Wed Jan 13 14:48:29 2010 +0100 debugger: whitespace commit d3cdfe813444b6afca483c7d13ac80c4c8eda62b Author: hjk <qtc-committer@nokia.com> Date: Wed Jan 13 14:46:13 2010 +0100 debugger: add some debug output to trk device commit 7cd27f2eecd5f77bc35f6b705c6f0422b09e534d Author: hjk <qtc-committer@nokia.com> Date: Mon Jan 4 13:17:38 2010 +0100 debugger: add list of thread ids to TRK session state object Reviewed-by: Shane Kearns
Diffstat (limited to 'tools')
-rw-r--r--tools/runonphone/trk/trkdevice.cpp34
-rw-r--r--tools/runonphone/trk/trkutils.h7
2 files changed, 36 insertions, 5 deletions
diff --git a/tools/runonphone/trk/trkdevice.cpp b/tools/runonphone/trk/trkdevice.cpp
index 53f4490..fe3261b 100644
--- a/tools/runonphone/trk/trkdevice.cpp
+++ b/tools/runonphone/trk/trkdevice.cpp
@@ -99,6 +99,8 @@ QString winErrorMessage(unsigned long error)
#endif
+enum { verboseTrk = 0 };
+
namespace trk {
///////////////////////////////////////////////////////////////////////
@@ -128,6 +130,12 @@ TrkMessage::TrkMessage(byte c, byte t, TrkCallback 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)
@@ -204,6 +212,8 @@ byte TrkWriteQueue::nextTrkWriteToken()
++m_trkWriteToken;
if (m_trkWriteToken == 0)
++m_trkWriteToken;
+ if (verboseTrk)
+ qDebug() << "Write token: " << m_trkWriteToken;
return m_trkWriteToken;
}
@@ -334,7 +344,8 @@ DeviceContext::DeviceContext() :
///////////////////////////////////////////////////////////////////////
-class WriterThread : public QThread {
+class WriterThread : public QThread
+{
Q_OBJECT
Q_DISABLE_COPY(WriterThread)
public:
@@ -400,15 +411,18 @@ int WriterThread::writePendingMessage()
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++) {
@@ -428,6 +442,8 @@ int WriterThread::writePendingMessage()
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
@@ -499,6 +515,8 @@ static inline bool overlappedSyncWrite(HANDLE file,
bool WriterThread::write(const QByteArray &data, QString *errorMessage)
{
+ if (verboseTrk)
+ qDebug() << "Write raw data: " << data.toHex();
QMutexLocker locker(&m_context->mutex);
#ifdef Q_OS_WIN
DWORD charsWritten;
@@ -557,6 +575,7 @@ void WriterThread::slotHandleResult(const TrkResult &result)
tryWrite(); // Have messages been enqueued in-between?
}
+
///////////////////////////////////////////////////////////////////////
//
// ReaderThreadBase: Base class for a thread that reads data from
@@ -566,7 +585,8 @@ void WriterThread::slotHandleResult(const TrkResult &result)
//
///////////////////////////////////////////////////////////////////////
-class ReaderThreadBase : public QThread {
+class ReaderThreadBase : public QThread
+{
Q_OBJECT
Q_DISABLE_COPY(ReaderThreadBase)
public:
@@ -625,7 +645,8 @@ void ReaderThreadBase::readMessages()
//
///////////////////////////////////////////////////////////////////////
-class WinReaderThread : public ReaderThreadBase {
+class WinReaderThread : public ReaderThreadBase
+{
Q_OBJECT
Q_DISABLE_COPY(WinReaderThread)
public:
@@ -835,7 +856,8 @@ void UnixReaderThread::terminate()
{
// Trigger select() by writing to the pipe
char c = 0;
- write(m_terminatePipeFileDescriptors[1], &c, 1);
+ int written = write(m_terminatePipeFileDescriptors[1], &c, 1);
+ // FIXME: Use result.
wait();
}
@@ -1021,6 +1043,8 @@ void TrkDevice::setVerbose(int b)
void TrkDevice::slotMessageReceived(const trk::TrkResult &result, const QByteArray &rawData)
{
d->writerThread->slotHandleResult(result);
+ if (d->verbose > 1)
+ qDebug() << "Received: " << result.toString();
emit messageReceived(result);
if (!rawData.isEmpty())
emit rawDataReceived(rawData);
@@ -1057,6 +1081,8 @@ bool TrkDevice::sendTrkAck(byte token)
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
}
diff --git a/tools/runonphone/trk/trkutils.h b/tools/runonphone/trk/trkutils.h
index c636ac0..328dd2b 100644
--- a/tools/runonphone/trk/trkutils.h
+++ b/tools/runonphone/trk/trkutils.h
@@ -119,7 +119,8 @@ struct Library
uint dataseg;
};
-struct TrkAppVersion {
+struct TrkAppVersion
+{
TrkAppVersion();
void reset();
@@ -153,6 +154,10 @@ struct Session
typedef QList<Library> Libraries;
Libraries libraries;
+ typedef uint Thread;
+ typedef QList<Thread> Threads;
+ Threads threads;
+
// Gdb request
uint currentThread;
QStringList modules;