diff --git a/src/plugins/debugger/gdb/trkgdbadapter.cpp b/src/plugins/debugger/gdb/trkgdbadapter.cpp index daaa4fa066c045950b8a5b209bbeeb883b8fd1de..f45268fe6da667558ac184cc1de5290f2ba4ffc6 100644 --- a/src/plugins/debugger/gdb/trkgdbadapter.cpp +++ b/src/plugins/debugger/gdb/trkgdbadapter.cpp @@ -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)); diff --git a/src/plugins/debugger/gdb/trkgdbadapter.h b/src/plugins/debugger/gdb/trkgdbadapter.h index fb8420446fd46f27401cdbeebb96e3b8ace5336f..38ec1d35af381f4e5327e4ade1e8550b2fe28351 100644 --- a/src/plugins/debugger/gdb/trkgdbadapter.h +++ b/src/plugins/debugger/gdb/trkgdbadapter.h @@ -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);