diff options
author | Friedemann Kleint <Friedemann.Kleint@nokia.com> | 2010-01-21 15:24:47 +0100 |
---|---|---|
committer | Friedemann Kleint <Friedemann.Kleint@nokia.com> | 2010-01-21 15:24:47 +0100 |
commit | 9ac451eabacf57f5972420a4df43ad120d2cb496 (patch) | |
tree | b066b0c2b4628c2c6879e74c9cb0d79876fc0fcf | |
parent | 670647b8207bf4a35b93ce23f47b4e5cde025a93 (diff) |
trk: Handle TrkNotifyStopped in launcher.
Add signal and static utility functions to parse message.
Reviewed-by: Robert Loehning <robert.loehning@nokia.com>
Initial-patch-by: Shane Kearns <shane.kearns@sosco.com>
-rw-r--r-- | src/shared/trk/launcher.cpp | 50 | ||||
-rw-r--r-- | src/shared/trk/launcher.h | 8 |
2 files changed, 51 insertions, 7 deletions
diff --git a/src/shared/trk/launcher.cpp b/src/shared/trk/launcher.cpp index 24b114ab65..8be5dcd132 100644 --- a/src/shared/trk/launcher.cpp +++ b/src/shared/trk/launcher.cpp @@ -286,6 +286,34 @@ void Launcher::handleRemoteProcessKilled(const TrkResult &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: "; @@ -305,13 +333,13 @@ void Launcher::handleResult(const TrkResult &result) break; } case TrkNotifyStopped: { // Notified Stopped - logMessage(prefix + "NOTE: STOPPED " + str); - // 90 01 78 6a 40 40 00 00 07 23 00 00 07 24 00 00 - //const char *data = result.data.data(); -// uint addr = extractInt(data); //code address: 4 bytes; code base address for the library -// uint pid = extractInt(data + 4); // ProcessID: 4 bytes; -// uint tid = extractInt(data + 8); // ThreadID: 4 bytes - //logMessage(prefix << " ADDR: " << addr << " PID: " << pid << " TID: " << tid); + 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; } @@ -685,4 +713,12 @@ void Launcher::startInferiorIfNeeded() 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"); +} } // namespace trk diff --git a/src/shared/trk/launcher.h b/src/shared/trk/launcher.h index 764264c044..c70b05c879 100644 --- a/src/shared/trk/launcher.h +++ b/src/shared/trk/launcher.h @@ -98,6 +98,12 @@ public: static QByteArray startProcessMessage(const QString &executable, const QStringList &arguments); + // 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 copyingStarted(); @@ -114,9 +120,11 @@ signals: void applicationOutputReceived(const QString &output); void copyProgress(int percent); void stateChanged(int); + void processStopped(uint pc, uint pid, uint tid, const QString& reason); public slots: void terminate(); + void resumeProcess(uint pid, uint tid); private slots: void handleResult(const trk::TrkResult &data); |