Commit 6ce0a236 authored by hjk's avatar hjk

debugger: work on trk integration

parent 40d54a84
......@@ -160,24 +160,24 @@ private:
byte nextTrkWriteToken();
byte trkWriteToken;
QQueue<TrkMessage> trkWriteQueue;
TokenMessageMap writtenTrkMessages;
bool trkWriteBusy;
byte m_trkWriteToken;
QQueue<TrkMessage> m_trkWriteQueue;
TokenMessageMap m_writtenTrkMessages;
bool m_trkWriteBusy;
};
TrkWriteQueue::TrkWriteQueue() :
trkWriteToken(0),
trkWriteBusy(false)
m_trkWriteToken(0),
m_trkWriteBusy(false)
{
}
byte TrkWriteQueue::nextTrkWriteToken()
{
++trkWriteToken;
if (trkWriteToken == 0)
++trkWriteToken;
return trkWriteToken;
++m_trkWriteToken;
if (m_trkWriteToken == 0)
++m_trkWriteToken;
return m_trkWriteToken;
}
void TrkWriteQueue::queueTrkMessage(byte code, TrkCallback callback,
......@@ -188,17 +188,17 @@ void TrkWriteQueue::queueTrkMessage(byte code, TrkCallback callback,
TrkMessage msg(code, token, callback);
msg.data = data;
msg.cookie = cookie;
trkWriteQueue.append(msg);
m_trkWriteQueue.append(msg);
}
bool TrkWriteQueue::pendingMessage(TrkMessage *message)
{
// Invoked from timer, try to flush out message queue
if (trkWriteBusy || trkWriteQueue.isEmpty())
if (m_trkWriteBusy || m_trkWriteQueue.isEmpty())
return false;
// Handle the noop message, just invoke CB
if (trkWriteQueue.front().code == TRK_WRITE_QUEUE_NOOP_CODE) {
TrkMessage noopMessage = trkWriteQueue.dequeue();
if (m_trkWriteQueue.front().code == TRK_WRITE_QUEUE_NOOP_CODE) {
TrkMessage noopMessage = m_trkWriteQueue.dequeue();
if (noopMessage.callback) {
TrkResult result;
result.code = noopMessage.code;
......@@ -209,10 +209,10 @@ bool TrkWriteQueue::pendingMessage(TrkMessage *message)
}
}
// Check again for real messages
if (trkWriteQueue.isEmpty())
if (m_trkWriteQueue.isEmpty())
return false;
if (message)
*message = trkWriteQueue.front();
*message = m_trkWriteQueue.front();
return true;
}
......@@ -220,21 +220,21 @@ void TrkWriteQueue::notifyWriteResult(bool ok)
{
// On success, dequeue message and await result
if (ok) {
TrkMessage firstMsg = trkWriteQueue.dequeue();
writtenTrkMessages.insert(firstMsg.token, firstMsg);
trkWriteBusy = true;
TrkMessage firstMsg = m_trkWriteQueue.dequeue();
m_writtenTrkMessages.insert(firstMsg.token, firstMsg);
m_trkWriteBusy = true;
}
}
void TrkWriteQueue::slotHandleResult(const TrkResult &result)
{
trkWriteBusy = false;
m_trkWriteBusy = false;
//if (result.code != TrkNotifyAck && result.code != TrkNotifyNak)
// return;
// Find which request the message belongs to and invoke callback
// if ACK or on NAK if desired.
const TokenMessageMap::iterator it = writtenTrkMessages.find(result.token);
if (it == writtenTrkMessages.end())
const TokenMessageMap::iterator it = m_writtenTrkMessages.find(result.token);
if (it == m_writtenTrkMessages.end())
return;
const bool invokeCB = it.value().callback;
if (invokeCB) {
......@@ -242,13 +242,14 @@ void TrkWriteQueue::slotHandleResult(const TrkResult &result)
result1.cookie = it.value().cookie;
it.value().callback(result1);
}
writtenTrkMessages.erase(it);
m_writtenTrkMessages.erase(it);
}
void TrkWriteQueue::queueTrkInitialPing()
{
// Ping, reset sequence count
trkWriteQueue.append(TrkMessage(0, 0));
m_trkWriteToken = 0;
m_trkWriteQueue.append(TrkMessage(0, 0));
}
......@@ -270,7 +271,7 @@ struct TrkDevicePrivate
#endif
QByteArray trkReadBuffer;
bool trkWriteBusy;
bool m_trkWriteBusy;
int timerId;
bool serialFrame;
bool verbose;
......@@ -287,7 +288,7 @@ TrkDevicePrivate::TrkDevicePrivate() :
#ifdef Q_OS_WIN
hdevice(INVALID_HANDLE_VALUE),
#endif
trkWriteBusy(false),
m_trkWriteBusy(false),
timerId(-1),
serialFrame(true),
verbose(false)
......
......@@ -459,8 +459,7 @@ void TrkGdbAdapter::handleGdbServerCommand(const QByteArray &cmd)
// Read general registers.
logMessage(msgGdbPacket(QLatin1String("Read registers")));
sendGdbServerAck();
sendTrkMessage(0x12, TrkCB(handleAndReportReadRegisters),
trkReadRegisterMessage());
reportRegisters();
}
else if (cmd.startsWith("Hc")) {
......@@ -537,9 +536,9 @@ void TrkGdbAdapter::handleGdbServerCommand(const QByteArray &cmd)
logMsg += dumpRegister(registerNumber, m_snapshot.registers[registerNumber]);
sendGdbServerMessage(ba.toHex(), logMsg);
} else {
//sendGdbServerMessage("0000", "read single unknown register #"
// + QByteArray::number(registerNumber));
sendGdbServerMessage("E01", "read single unknown register");
sendGdbServerMessage("0000", "read single unknown register #"
+ QByteArray::number(registerNumber));
//sendGdbServerMessage("E01", "read single unknown register");
}
}
......@@ -735,9 +734,6 @@ void TrkGdbAdapter::executeCommand(const QString &msg)
sendTrkMessage(0x19, TrkCallback(), trkStepRangeMessage(0x01), "STEP");
} else if (msg == "N") {
sendTrkMessage(0x19, TrkCallback(), trkStepRangeMessage(0x11), "NEXT");
} else if (msg == "R") {
sendTrkMessage(0x12, TrkCB(handleReadRegisters),
trkReadRegisterMessage(), "READ REGS");
} else if (msg == "I") {
interruptInferior();
} else {
......@@ -799,16 +795,16 @@ void TrkGdbAdapter::handleTrkResult(const TrkResult &result)
// query is pending, queue instead
if (m_running) {
m_running = false;
// We almost always need register values, so get them
// now before informing gdb about the stop. In theory
//sendGdbServerMessage("S05", "Target stopped");
sendTrkMessage(0x12,
TrkCB(handleAndReportReadRegistersAfterStop),
trkReadRegisterMessage());
}
} else {
logMessage(QLatin1String("Ignoring stop at 0"));
}
// We almost always need register values, so get them
// now before informing gdb about the stop. In theory
//sendGdbServerMessage("S05", "Target stopped");
sendTrkMessage(0x12,
TrkCB(handleAndReportReadRegistersAfterStop),
trkReadRegisterMessage());
break;
}
case 0x91: { // Notify Exception (obsolete)
......@@ -950,9 +946,8 @@ void TrkGdbAdapter::handleReadRegisters(const TrkResult &result)
m_snapshot.registers[i] = extractInt(data + 4 * i);
}
void TrkGdbAdapter::handleAndReportReadRegisters(const TrkResult &result)
void TrkGdbAdapter::reportRegisters()
{
handleReadRegisters(result);
QByteArray ba;
for (int i = 0; i < 16; ++i) {
const uint reg = swapEndian(m_snapshot.registers[i]);
......@@ -982,6 +977,7 @@ void TrkGdbAdapter::handleAndReportReadRegistersAfterStop(const TrkResult &resul
QByteArray ba = "T05";
for (int i = 0; i < 16; ++i)
appendRegister(&ba, i, m_snapshot.registers[i]);
// FIXME: those are not understood by gdb 6.4
//for (int i = 16; i < 25; ++i)
// appendRegister(&ba, i, 0x0);
appendRegister(&ba, RegisterPSGdb, m_snapshot.registers[RegisterPSTrk]);
......
......@@ -157,8 +157,8 @@ public:
void handleDisconnect(const TrkResult &result);
void handleAndReportCreateProcess(const TrkResult &result);
void handleAndReportReadRegisters(const TrkResult &result);
void handleAndReportReadRegistersAfterStop(const TrkResult &result);
void reportRegisters();
QByteArray memoryReadLogMessage(uint addr, uint len, const QByteArray &ba) const;
QByteArray trkContinueMessage();
QByteArray trkReadRegisterMessage();
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment