From deec72d1682123881c7ddeb1286b86f46204b5c0 Mon Sep 17 00:00:00 2001 From: Nav Date: Sun, 11 Dec 2022 15:26:14 +0000 Subject: [PATCH] Convert relative EEPROM addresses to absolute addresses in GDB memory access command packet handlers. --- src/DebugServer/Gdb/AvrGdb/CommandPackets/ReadMemory.cpp | 5 +++++ src/DebugServer/Gdb/AvrGdb/CommandPackets/WriteMemory.cpp | 5 +++++ 2 files changed, 10 insertions(+) diff --git a/src/DebugServer/Gdb/AvrGdb/CommandPackets/ReadMemory.cpp b/src/DebugServer/Gdb/AvrGdb/CommandPackets/ReadMemory.cpp index 401897a4..2fa47881 100644 --- a/src/DebugServer/Gdb/AvrGdb/CommandPackets/ReadMemory.cpp +++ b/src/DebugServer/Gdb/AvrGdb/CommandPackets/ReadMemory.cpp @@ -78,6 +78,11 @@ namespace Bloom::DebugServer::Gdb::AvrGdb::CommandPackets const auto& memoryDescriptor = memoryDescriptorIt->second; + if (this->memoryType == Targets::TargetMemoryType::EEPROM) { + // GDB sends EEPROM addresses in relative form - we convert them to absolute form, here. + this->startAddress = memoryDescriptor.addressRange.startAddress + this->startAddress; + } + /* * In AVR targets, RAM is mapped to many registers and peripherals - we don't want to block GDB from * accessing them. diff --git a/src/DebugServer/Gdb/AvrGdb/CommandPackets/WriteMemory.cpp b/src/DebugServer/Gdb/AvrGdb/CommandPackets/WriteMemory.cpp index b446c3f6..e473692a 100644 --- a/src/DebugServer/Gdb/AvrGdb/CommandPackets/WriteMemory.cpp +++ b/src/DebugServer/Gdb/AvrGdb/CommandPackets/WriteMemory.cpp @@ -101,6 +101,11 @@ namespace Bloom::DebugServer::Gdb::AvrGdb::CommandPackets const auto& memoryDescriptor = memoryDescriptorIt->second; + if (this->memoryType == Targets::TargetMemoryType::EEPROM) { + // GDB sends EEPROM addresses in relative form - we convert them to absolute form, here. + this->startAddress = memoryDescriptor.addressRange.startAddress + this->startAddress; + } + /* * In AVR targets, RAM is mapped to many registers and peripherals - we don't want to block GDB from * accessing them.