forked from qt-creator/qt-creator
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>
This commit is contained in:
@@ -286,6 +286,34 @@ void Launcher::handleRemoteProcessKilled(const TrkResult &result)
|
|||||||
disconnectTrk();
|
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)
|
void Launcher::handleResult(const TrkResult &result)
|
||||||
{
|
{
|
||||||
QByteArray prefix = "READ BUF: ";
|
QByteArray prefix = "READ BUF: ";
|
||||||
@@ -305,13 +333,13 @@ void Launcher::handleResult(const TrkResult &result)
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case TrkNotifyStopped: { // Notified Stopped
|
case TrkNotifyStopped: { // Notified Stopped
|
||||||
logMessage(prefix + "NOTE: STOPPED " + str);
|
QString reason;
|
||||||
// 90 01 78 6a 40 40 00 00 07 23 00 00 07 24 00 00
|
uint pc;
|
||||||
//const char *data = result.data.data();
|
uint pid;
|
||||||
// uint addr = extractInt(data); //code address: 4 bytes; code base address for the library
|
uint tid;
|
||||||
// uint pid = extractInt(data + 4); // ProcessID: 4 bytes;
|
parseNotifyStopped(result.data, &pid, &tid, &pc, &reason);
|
||||||
// uint tid = extractInt(data + 8); // ThreadID: 4 bytes
|
logMessage(prefix + msgStopped(pid, tid, pc, reason));
|
||||||
//logMessage(prefix << " ADDR: " << addr << " PID: " << pid << " TID: " << tid);
|
emit(processStopped(pc, pid, tid, reason));
|
||||||
d->m_device->sendTrkAck(result.token);
|
d->m_device->sendTrkAck(result.token);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@@ -685,4 +713,12 @@ void Launcher::startInferiorIfNeeded()
|
|||||||
d->m_device->sendTrkMessage(TrkCreateItem, TrkCallback(this, &Launcher::handleCreateProcess),
|
d->m_device->sendTrkMessage(TrkCreateItem, TrkCallback(this, &Launcher::handleCreateProcess),
|
||||||
startProcessMessage(d->m_fileName, d->m_commandLineArgs)); // Create Item
|
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
|
} // namespace trk
|
||||||
|
@@ -98,6 +98,12 @@ public:
|
|||||||
|
|
||||||
static QByteArray startProcessMessage(const QString &executable,
|
static QByteArray startProcessMessage(const QString &executable,
|
||||||
const QStringList &arguments);
|
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:
|
signals:
|
||||||
void copyingStarted();
|
void copyingStarted();
|
||||||
@@ -114,9 +120,11 @@ signals:
|
|||||||
void applicationOutputReceived(const QString &output);
|
void applicationOutputReceived(const QString &output);
|
||||||
void copyProgress(int percent);
|
void copyProgress(int percent);
|
||||||
void stateChanged(int);
|
void stateChanged(int);
|
||||||
|
void processStopped(uint pc, uint pid, uint tid, const QString& reason);
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
void terminate();
|
void terminate();
|
||||||
|
void resumeProcess(uint pid, uint tid);
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
void handleResult(const trk::TrkResult &data);
|
void handleResult(const trk::TrkResult &data);
|
||||||
|
Reference in New Issue
Block a user