From 9e5d69dee4f0d2d128d61944920475855168c749 Mon Sep 17 00:00:00 2001 From: Nav Date: Sat, 14 Dec 2024 16:17:54 +0000 Subject: [PATCH] Tidying --- src/DebugServer/Gdb/AvrGdb/AvrGdbRsp.cpp | 18 +++++++++--------- src/DebugServer/Gdb/AvrGdb/AvrGdbRsp.hpp | 2 +- src/DebugServer/Gdb/GdbRspDebugServer.hpp | 2 +- src/Targets/Microchip/AVR8/Avr8.cpp | 2 +- src/Targets/RiscV/Wch/WchRiscV.cpp | 11 ++++++++--- 5 files changed, 20 insertions(+), 15 deletions(-) diff --git a/src/DebugServer/Gdb/AvrGdb/AvrGdbRsp.cpp b/src/DebugServer/Gdb/AvrGdb/AvrGdbRsp.cpp index 1a3dd373..f67378e6 100644 --- a/src/DebugServer/Gdb/AvrGdb/AvrGdbRsp.cpp +++ b/src/DebugServer/Gdb/AvrGdb/AvrGdbRsp.cpp @@ -156,17 +156,17 @@ namespace DebugServer::Gdb::AvrGdb return output; } - void AvrGdbRsp::handleTargetStoppedGdbResponse(Targets::TargetMemoryAddress programAddress) { + void AvrGdbRsp::handleTargetStoppedGdbResponse(Targets::TargetMemoryAddress programCounter) { using Services::StringService; - Logger::debug("Target stopped at byte address: 0x" + StringService::toHex(programAddress)); + Logger::debug("Target stopped at byte address: 0x" + StringService::toHex(programCounter)); auto& activeRangeSteppingSession = this->debugSession->activeRangeSteppingSession; if ( activeRangeSteppingSession.has_value() - && programAddress >= activeRangeSteppingSession->range.startAddress - && programAddress < activeRangeSteppingSession->range.endAddress + && programCounter >= activeRangeSteppingSession->range.startAddress + && programCounter < activeRangeSteppingSession->range.endAddress ) { /* * The target stopped within the stepping range of an active range stepping session. @@ -176,7 +176,7 @@ namespace DebugServer::Gdb::AvrGdb if ( this->debugSession->externalBreakpointRegistry.contains( activeRangeSteppingSession->addressSpaceDescriptor.id, - programAddress + programCounter ) ) { /* @@ -187,10 +187,10 @@ namespace DebugServer::Gdb::AvrGdb Logger::debug("Reached external breakpoint within stepping range"); this->debugSession->terminateRangeSteppingSession(this->targetControllerService); - return GdbRspDebugServer::handleTargetStoppedGdbResponse(programAddress); + return GdbRspDebugServer::handleTargetStoppedGdbResponse(programCounter); } - if (activeRangeSteppingSession->interceptedAddresses.contains(programAddress)) { + if (activeRangeSteppingSession->interceptedAddresses.contains(programCounter)) { /* * The target stopped due to an intercepting breakpoint, but we're still within the stepping range, * which can only mean that we weren't sure where this instruction would lead to. @@ -199,7 +199,7 @@ namespace DebugServer::Gdb::AvrGdb * range, we'll end the session and report back to GDB. */ Logger::debug("Reached intercepting breakpoint within stepping range"); - Logger::debug("Attempting single step from 0x" + StringService::toHex(programAddress)); + Logger::debug("Attempting single step from 0x" + StringService::toHex(programCounter)); activeRangeSteppingSession->singleStepping = true; this->targetControllerService.stepTargetExecution(); @@ -232,6 +232,6 @@ namespace DebugServer::Gdb::AvrGdb } // Report the stop to GDB - return GdbRspDebugServer::handleTargetStoppedGdbResponse(programAddress); + return GdbRspDebugServer::handleTargetStoppedGdbResponse(programCounter); } } diff --git a/src/DebugServer/Gdb/AvrGdb/AvrGdbRsp.hpp b/src/DebugServer/Gdb/AvrGdb/AvrGdbRsp.hpp index 01d2b252..5bb3675f 100644 --- a/src/DebugServer/Gdb/AvrGdb/AvrGdbRsp.hpp +++ b/src/DebugServer/Gdb/AvrGdb/AvrGdbRsp.hpp @@ -27,6 +27,6 @@ namespace DebugServer::Gdb::AvrGdb const RawPacket& rawPacket ) override; std::set>> getSupportedFeatures() override; - void handleTargetStoppedGdbResponse(Targets::TargetMemoryAddress programAddress) override; + void handleTargetStoppedGdbResponse(Targets::TargetMemoryAddress programCounter) override; }; } diff --git a/src/DebugServer/Gdb/GdbRspDebugServer.hpp b/src/DebugServer/Gdb/GdbRspDebugServer.hpp index 79ad29fa..980fc5d0 100644 --- a/src/DebugServer/Gdb/GdbRspDebugServer.hpp +++ b/src/DebugServer/Gdb/GdbRspDebugServer.hpp @@ -573,7 +573,7 @@ namespace DebugServer::Gdb } } - virtual void handleTargetStoppedGdbResponse(Targets::TargetMemoryAddress programAddress) { + virtual void handleTargetStoppedGdbResponse(Targets::TargetMemoryAddress programCounter) { if (this->debugSession->activeRangeSteppingSession.has_value()) { this->debugSession->terminateRangeSteppingSession(this->targetControllerService); } diff --git a/src/Targets/Microchip/AVR8/Avr8.cpp b/src/Targets/Microchip/AVR8/Avr8.cpp index 8972ff5d..c56b92bd 100644 --- a/src/Targets/Microchip/AVR8/Avr8.cpp +++ b/src/Targets/Microchip/AVR8/Avr8.cpp @@ -103,7 +103,7 @@ namespace Targets::Microchip::Avr8 && this->targetConfig.physicalInterface != TargetPhysicalInterface::JTAG ) { Logger::warning( - "The 'manageOcdenFuseBit' parameter only applies to JTAG targets. It will be ignored in this session." + "The 'manage_ocden_fuse_bit' parameter only applies to JTAG targets. It will be ignored in this session." ); } } diff --git a/src/Targets/RiscV/Wch/WchRiscV.cpp b/src/Targets/RiscV/Wch/WchRiscV.cpp index a13a4ca4..9a94f76b 100644 --- a/src/Targets/RiscV/Wch/WchRiscV.cpp +++ b/src/Targets/RiscV/Wch/WchRiscV.cpp @@ -6,6 +6,7 @@ #include "src/Exceptions/InvalidConfig.hpp" #include "src/Exceptions/Exception.hpp" +#include "src/Services/StringService.hpp" #include "src/Logger/Logger.hpp" namespace Targets::RiscV::Wch @@ -256,6 +257,8 @@ namespace Targets::RiscV::Wch } TargetMemoryAddress WchRiscV::getProgramCounter() { + using Services::StringService; + const auto programCounter = RiscV::getProgramCounter(); if (this->mappedSegmentDescriptor.addressRange.contains(programCounter)) { @@ -283,12 +286,14 @@ namespace Targets::RiscV::Wch * aliased address. That way, it will be clear to all external entities, that the target is currently * executing code in a different memory segment to the one that was selected for debugging. */ + const auto transformedAddress = this->transformMappedAddress(programCounter, actualAliasedSegment); Logger::warning( "The mapped program memory segment is currently aliasing a foreign segment (\"" - + actualAliasedSegment.key + "\") - the program counter will be transformed to its aliased" - " address" + + actualAliasedSegment.key + "\") - the program counter (0x" + + StringService::toHex(programCounter) + ") has been transformed to the aliased address (0x" + + StringService::toHex(transformedAddress) + ")" ); - return this->transformMappedAddress(programCounter, actualAliasedSegment); + return transformedAddress; } }