Commit e4f253ea authored by Friedemann Kleint's avatar Friedemann Kleint
Browse files

Trk/Debugger: Invoke memory read callback directly if no requests

are sent.
parent 6baeb06a
......@@ -1155,7 +1155,11 @@ void TrkGdbAdapter::reportReadMemoryBuffered(const TrkResult &result)
const qulonglong cookie = result.cookie.toULongLong();
const uint addr = cookie >> 32;
const uint len = uint(cookie);
reportReadMemoryBuffered(addr, len);
}
void TrkGdbAdapter::reportReadMemoryBuffered(uint addr, uint len)
{
// Gdb accepts less memory according to documentation.
// Send E on complete failure.
QByteArray ba;
......@@ -1320,6 +1324,7 @@ void TrkGdbAdapter::readMemory(uint addr, uint len)
.arg(len).arg(addr, 0, 16).arg(MemoryChunkSize));
if (m_bufferedMemoryRead) {
uint requests = 0;
uint blockaddr = (addr / MemoryChunkSize) * MemoryChunkSize;
for (; blockaddr < addr + len; blockaddr += MemoryChunkSize) {
if (!m_snapshot.memory.contains(blockaddr)) {
......@@ -1330,12 +1335,19 @@ void TrkGdbAdapter::readMemory(uint addr, uint len)
sendTrkMessage(0x10, TrkCB(handleReadMemoryBuffered),
trkReadMemoryMessage(blockaddr, MemoryChunkSize),
QVariant(blockaddr));
requests++;
}
}
const qulonglong cookie = (qulonglong(addr) << 32) + len;
sendTrkMessage(TRK_WRITE_QUEUE_NOOP_CODE, TrkCB(reportReadMemoryBuffered),
QByteArray(), cookie);
} else {
// If requests have been sent: Sync
if (requests) {
const qulonglong cookie = (qulonglong(addr) << 32) + len;
sendTrkMessage(TRK_WRITE_QUEUE_NOOP_CODE, TrkCB(reportReadMemoryBuffered),
QByteArray(), cookie);
} else {
// Everything is already buffered: invoke callback directly
reportReadMemoryBuffered(addr, len);
}
} else { // Unbuffered, direct requests
if (m_verbose)
logMessage(QString::fromLatin1("Requesting unbuffered memory %1 "
"bytes from 0x%2").arg(len).arg(addr, 0, 16));
......
......@@ -170,6 +170,7 @@ public:
void handleStepOver2(const TrkResult &result);
void handleReadRegisters(const TrkResult &result);
void reportReadMemoryBuffered(const TrkResult &result);
void reportReadMemoryBuffered(uint addr, uint len);
void handleWriteRegister(const TrkResult &result);
void reportToGdb(const TrkResult &result);
......
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