From 9743e9a719f60584b95782487453f5c03ab4b5c3 Mon Sep 17 00:00:00 2001 From: Nav Date: Sat, 25 Nov 2023 19:35:54 +0000 Subject: [PATCH] Use post-increment function to increment address when reading memory in `RiscV::readMemory()` --- src/Targets/RiscV/RiscV.cpp | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/src/Targets/RiscV/RiscV.cpp b/src/Targets/RiscV/RiscV.cpp index 1ba6e65c..ca039fc6 100644 --- a/src/Targets/RiscV/RiscV.cpp +++ b/src/Targets/RiscV/RiscV.cpp @@ -299,18 +299,22 @@ namespace Targets::RiscV auto output = TargetMemoryBuffer(); output.reserve(bytes); + /* + * We only need to set the address once. No need to update it as we use the post-increment function to + * increment the address. See MemoryAccessControlField::postIncrement + */ + this->riscVDebugInterface->writeDebugModuleRegister(RegisterAddress::ABSTRACT_DATA_1, startAddress); + for (auto address = startAddress; address <= (startAddress + bytes - 1); address += 4) { auto command = AbstractCommandRegister(); command.commandType = AbstractCommandRegister::CommandType::MEMORY_ACCESS; command.control = MemoryAccessControlField( false, - false, + true, MemoryAccessControlField::MemorySize::SIZE_32, false ).value(); - this->riscVDebugInterface->writeDebugModuleRegister(RegisterAddress::ABSTRACT_DATA_1, address); - this->executeAbstractCommand(command); const auto data = this->riscVDebugInterface->readDebugModuleRegister(RegisterAddress::ABSTRACT_DATA_0);