Split target memory reads (via InsightWorker task) to numerous reads, in order to prevent occupying the TargetController for too long (which can result in GDB timeouts)
This commit is contained in:
@@ -1,17 +1,40 @@
|
|||||||
#include "ReadTargetMemory.hpp"
|
#include "ReadTargetMemory.hpp"
|
||||||
|
|
||||||
|
#include <cmath>
|
||||||
|
|
||||||
|
#include "src/Targets/TargetMemory.hpp"
|
||||||
|
|
||||||
namespace Bloom
|
namespace Bloom
|
||||||
{
|
{
|
||||||
using TargetController::TargetControllerConsole;
|
using TargetController::TargetControllerConsole;
|
||||||
|
|
||||||
void ReadTargetMemory::run(TargetControllerConsole& targetControllerConsole) {
|
void ReadTargetMemory::run(TargetControllerConsole& targetControllerConsole) {
|
||||||
emit this->targetMemoryRead(
|
/*
|
||||||
targetControllerConsole.readMemory(
|
* To prevent locking up the TargetController for too long, we split the read into numerous reads.
|
||||||
this->memoryType,
|
*
|
||||||
this->startAddress,
|
* This allows the TargetController to service other commands in-between reads, reducing the likelihood of
|
||||||
this->size,
|
* command timeouts when we're reading lots of data.
|
||||||
this->excludedAddressRanges
|
*/
|
||||||
)
|
constexpr auto readSize = 256;
|
||||||
|
const auto readsRequired = static_cast<std::uint32_t>(
|
||||||
|
std::ceil(static_cast<float>(this->size) / static_cast<float>(readSize))
|
||||||
);
|
);
|
||||||
|
|
||||||
|
Targets::TargetMemoryBuffer data;
|
||||||
|
|
||||||
|
for (auto i = 0; i < readsRequired; i++) {
|
||||||
|
auto dataSegment = targetControllerConsole.readMemory(
|
||||||
|
this->memoryType,
|
||||||
|
this->startAddress + static_cast<std::uint32_t>(readSize * i),
|
||||||
|
(this->size - data.size()) >= readSize
|
||||||
|
? readSize
|
||||||
|
: static_cast<std::uint32_t>(this->size - data.size()),
|
||||||
|
this->excludedAddressRanges
|
||||||
|
);
|
||||||
|
|
||||||
|
std::move(dataSegment.begin(), dataSegment.end(), std::back_inserter(data));
|
||||||
|
}
|
||||||
|
|
||||||
|
emit this->targetMemoryRead(data);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user