From 9df41ccfc5481e6afcd088d7450cb1cb73f52b57 Mon Sep 17 00:00:00 2001 From: Nav Date: Fri, 25 Oct 2024 23:12:04 +0100 Subject: [PATCH] Made VCont step/continue command handlers generic (non-target-specific) --- src/DebugServer/CMakeLists.txt | 4 ++-- src/DebugServer/Gdb/AvrGdb/AvrGdbRsp.cpp | 12 ------------ .../CommandPackets/VContContinueExecution.cpp | 4 ++-- .../CommandPackets/VContContinueExecution.hpp | 6 +++--- .../CommandPackets/VContStepExecution.cpp | 4 ++-- .../CommandPackets/VContStepExecution.hpp | 6 +++--- src/DebugServer/Gdb/GdbRspDebugServer.hpp | 10 ++++++++++ 7 files changed, 22 insertions(+), 24 deletions(-) rename src/DebugServer/Gdb/{AvrGdb => }/CommandPackets/VContContinueExecution.cpp (90%) rename src/DebugServer/Gdb/{AvrGdb => }/CommandPackets/VContContinueExecution.hpp (75%) rename src/DebugServer/Gdb/{AvrGdb => }/CommandPackets/VContStepExecution.cpp (89%) rename src/DebugServer/Gdb/{AvrGdb => }/CommandPackets/VContStepExecution.hpp (72%) diff --git a/src/DebugServer/CMakeLists.txt b/src/DebugServer/CMakeLists.txt index 6b4e10bd..548800bc 100755 --- a/src/DebugServer/CMakeLists.txt +++ b/src/DebugServer/CMakeLists.txt @@ -25,6 +25,8 @@ target_sources( ${CMAKE_CURRENT_SOURCE_DIR}/Gdb/CommandPackets/ListRegistersMonitor.cpp ${CMAKE_CURRENT_SOURCE_DIR}/Gdb/CommandPackets/ReadRegistersMonitor.cpp ${CMAKE_CURRENT_SOURCE_DIR}/Gdb/CommandPackets/WriteRegisterMonitor.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/Gdb/CommandPackets/VContContinueExecution.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/Gdb/CommandPackets/VContStepExecution.cpp # AVR GDB RSP Server ${CMAKE_CURRENT_SOURCE_DIR}/Gdb/AvrGdb/AvrGdbRsp.cpp @@ -39,8 +41,6 @@ target_sources( ${CMAKE_CURRENT_SOURCE_DIR}/Gdb/AvrGdb/CommandPackets/FlashWrite.cpp ${CMAKE_CURRENT_SOURCE_DIR}/Gdb/AvrGdb/CommandPackets/FlashDone.cpp ${CMAKE_CURRENT_SOURCE_DIR}/Gdb/AvrGdb/CommandPackets/VContSupportedActionsQuery.cpp - ${CMAKE_CURRENT_SOURCE_DIR}/Gdb/AvrGdb/CommandPackets/VContContinueExecution.cpp - ${CMAKE_CURRENT_SOURCE_DIR}/Gdb/AvrGdb/CommandPackets/VContStepExecution.cpp ${CMAKE_CURRENT_SOURCE_DIR}/Gdb/AvrGdb/CommandPackets/VContRangeStep.cpp ${CMAKE_CURRENT_SOURCE_DIR}/Gdb/AvrGdb/CommandPackets/EepromFill.cpp ) diff --git a/src/DebugServer/Gdb/AvrGdb/AvrGdbRsp.cpp b/src/DebugServer/Gdb/AvrGdb/AvrGdbRsp.cpp index c63c5efc..b32d9038 100644 --- a/src/DebugServer/Gdb/AvrGdb/AvrGdbRsp.cpp +++ b/src/DebugServer/Gdb/AvrGdb/AvrGdbRsp.cpp @@ -13,8 +13,6 @@ #include "CommandPackets/FlashWrite.hpp" #include "CommandPackets/FlashDone.hpp" #include "CommandPackets/VContSupportedActionsQuery.hpp" -#include "CommandPackets/VContContinueExecution.hpp" -#include "CommandPackets/VContStepExecution.hpp" #include "CommandPackets/VContRangeStep.hpp" #include "src/DebugServer/Gdb/CommandPackets/Monitor.hpp" @@ -56,8 +54,6 @@ namespace DebugServer::Gdb::AvrGdb using CommandPackets::FlashWrite; using CommandPackets::FlashDone; using CommandPackets::VContSupportedActionsQuery; - using CommandPackets::VContContinueExecution; - using CommandPackets::VContStepExecution; using CommandPackets::VContRangeStep; using CommandPackets::EepromFill; @@ -108,14 +104,6 @@ namespace DebugServer::Gdb::AvrGdb return std::make_unique(rawPacket); } - if (rawPacketString.find("vCont;c") == 0 || rawPacketString.find("vCont;C") == 0) { - return std::make_unique(rawPacket); - } - - if (rawPacketString.find("vCont;s") == 0 || rawPacketString.find("vCont;S") == 0) { - return std::make_unique(rawPacket); - } - if (this->debugServerConfig.rangeStepping) { if (rawPacketString.find("vCont;r") == 0) { return std::make_unique(rawPacket); diff --git a/src/DebugServer/Gdb/AvrGdb/CommandPackets/VContContinueExecution.cpp b/src/DebugServer/Gdb/CommandPackets/VContContinueExecution.cpp similarity index 90% rename from src/DebugServer/Gdb/AvrGdb/CommandPackets/VContContinueExecution.cpp rename to src/DebugServer/Gdb/CommandPackets/VContContinueExecution.cpp index 8be68342..95206942 100644 --- a/src/DebugServer/Gdb/AvrGdb/CommandPackets/VContContinueExecution.cpp +++ b/src/DebugServer/Gdb/CommandPackets/VContContinueExecution.cpp @@ -2,7 +2,7 @@ #include "src/DebugServer/Gdb/ResponsePackets/ErrorResponsePacket.hpp" -namespace DebugServer::Gdb::AvrGdb::CommandPackets +namespace DebugServer::Gdb::CommandPackets { using Services::TargetControllerService; @@ -16,7 +16,7 @@ namespace DebugServer::Gdb::AvrGdb::CommandPackets void VContContinueExecution::handle( DebugSession& debugSession, - const AvrGdbTargetDescriptor& gdbTargetDescriptor, + const TargetDescriptor& gdbTargetDescriptor, const Targets::TargetDescriptor& targetDescriptor, TargetControllerService& targetControllerService ) { diff --git a/src/DebugServer/Gdb/AvrGdb/CommandPackets/VContContinueExecution.hpp b/src/DebugServer/Gdb/CommandPackets/VContContinueExecution.hpp similarity index 75% rename from src/DebugServer/Gdb/AvrGdb/CommandPackets/VContContinueExecution.hpp rename to src/DebugServer/Gdb/CommandPackets/VContContinueExecution.hpp index 4dfe9886..f5844384 100644 --- a/src/DebugServer/Gdb/AvrGdb/CommandPackets/VContContinueExecution.hpp +++ b/src/DebugServer/Gdb/CommandPackets/VContContinueExecution.hpp @@ -4,20 +4,20 @@ #include "CommandPacket.hpp" -namespace DebugServer::Gdb::AvrGdb::CommandPackets +namespace DebugServer::Gdb::CommandPackets { /** * The VContContinueExecution class implements a structure for "vCont;c" and "vCont;C" packets. These packets * instruct the server to continue execution on the target. */ - class VContContinueExecution: public CommandPackets::CommandPacket + class VContContinueExecution: public CommandPacket { public: explicit VContContinueExecution(const RawPacket& rawPacket); void handle( DebugSession& debugSession, - const AvrGdbTargetDescriptor& gdbTargetDescriptor, + const TargetDescriptor& gdbTargetDescriptor, const Targets::TargetDescriptor& targetDescriptor, Services::TargetControllerService& targetControllerService ) override; diff --git a/src/DebugServer/Gdb/AvrGdb/CommandPackets/VContStepExecution.cpp b/src/DebugServer/Gdb/CommandPackets/VContStepExecution.cpp similarity index 89% rename from src/DebugServer/Gdb/AvrGdb/CommandPackets/VContStepExecution.cpp rename to src/DebugServer/Gdb/CommandPackets/VContStepExecution.cpp index 85508af5..1b3b0053 100644 --- a/src/DebugServer/Gdb/AvrGdb/CommandPackets/VContStepExecution.cpp +++ b/src/DebugServer/Gdb/CommandPackets/VContStepExecution.cpp @@ -2,7 +2,7 @@ #include "src/DebugServer/Gdb/ResponsePackets/ErrorResponsePacket.hpp" -namespace DebugServer::Gdb::AvrGdb::CommandPackets +namespace DebugServer::Gdb::CommandPackets { using Services::TargetControllerService; @@ -16,7 +16,7 @@ namespace DebugServer::Gdb::AvrGdb::CommandPackets void VContStepExecution::handle( DebugSession& debugSession, - const AvrGdbTargetDescriptor& gdbTargetDescriptor, + const TargetDescriptor& gdbTargetDescriptor, const Targets::TargetDescriptor& targetDescriptor, TargetControllerService& targetControllerService ) { diff --git a/src/DebugServer/Gdb/AvrGdb/CommandPackets/VContStepExecution.hpp b/src/DebugServer/Gdb/CommandPackets/VContStepExecution.hpp similarity index 72% rename from src/DebugServer/Gdb/AvrGdb/CommandPackets/VContStepExecution.hpp rename to src/DebugServer/Gdb/CommandPackets/VContStepExecution.hpp index 247d75c6..0157a8c1 100644 --- a/src/DebugServer/Gdb/AvrGdb/CommandPackets/VContStepExecution.hpp +++ b/src/DebugServer/Gdb/CommandPackets/VContStepExecution.hpp @@ -4,19 +4,19 @@ #include "CommandPacket.hpp" -namespace DebugServer::Gdb::AvrGdb::CommandPackets +namespace DebugServer::Gdb::CommandPackets { /** * The VContStepExecution class implements a structure for "vCont;s" and "vCont;S" packets. */ - class VContStepExecution: public CommandPackets::CommandPacket + class VContStepExecution: public CommandPacket { public: explicit VContStepExecution(const RawPacket& rawPacket); void handle( DebugSession& debugSession, - const AvrGdbTargetDescriptor& gdbTargetDescriptor, + const TargetDescriptor& gdbTargetDescriptor, const Targets::TargetDescriptor& targetDescriptor, Services::TargetControllerService& targetControllerService ) override; diff --git a/src/DebugServer/Gdb/GdbRspDebugServer.hpp b/src/DebugServer/Gdb/GdbRspDebugServer.hpp index 82e568da..a4ecc8a3 100644 --- a/src/DebugServer/Gdb/GdbRspDebugServer.hpp +++ b/src/DebugServer/Gdb/GdbRspDebugServer.hpp @@ -60,6 +60,8 @@ #include "CommandPackets/ListRegistersMonitor.hpp" #include "CommandPackets/ReadRegistersMonitor.hpp" #include "CommandPackets/WriteRegisterMonitor.hpp" +#include "CommandPackets/VContContinueExecution.hpp" +#include "CommandPackets/VContStepExecution.hpp" #ifndef EXCLUDE_INSIGHT #include "CommandPackets/ActivateInsight.hpp" @@ -441,6 +443,14 @@ namespace DebugServer::Gdb return std::make_unique(rawPacket); } + if (rawPacketString.find("vCont;c") == 0 || rawPacketString.find("vCont;C") == 0) { + return std::make_unique(rawPacket); + } + + if (rawPacketString.find("vCont;s") == 0 || rawPacketString.find("vCont;S") == 0) { + return std::make_unique(rawPacket); + } + if (rawPacketString.find("qRcmd") == 0) { // This is a monitor packet auto monitorCommand = std::make_unique(rawPacket);