Passed target state to GDB command handlers, and removed unnecessary PC read

This commit is contained in:
Nav
2024-12-14 16:17:02 +00:00
parent 87ffc10306
commit 48a7ae5dd0
55 changed files with 66 additions and 25 deletions

View File

@@ -38,6 +38,7 @@ namespace DebugServer::Gdb::RiscVGdb::CommandPackets
Gdb::DebugSession& debugSession,
const RiscVGdbTargetDescriptor& gdbTargetDescriptor,
const Targets::TargetDescriptor& targetDescriptor,
const Targets::TargetState& targetState,
TargetControllerService& targetControllerService
) {
Logger::info("Handling ReadRegister packet");
@@ -46,12 +47,7 @@ namespace DebugServer::Gdb::RiscVGdb::CommandPackets
Logger::debug("Reading GDB register ID: " + std::to_string(this->registerId));
if (this->registerId == gdbTargetDescriptor.programCounterGdbRegisterId) {
/*
* GDB has requested the program counter. We can't access this in the same way as we do with other
* registers.
*/
const auto programCounter = targetControllerService.getProgramCounter();
const auto programCounter = targetState.programCounter.load().value();
debugSession.connection.writePacket(
ResponsePacket{Services::StringService::toHex(Targets::TargetMemoryBuffer{
static_cast<unsigned char>(programCounter),