diff --git a/src/DebugServer/Gdb/CommandPackets/ContinueExecution.cpp b/src/DebugServer/Gdb/CommandPackets/ContinueExecution.cpp index d1e9021e..5a7110e1 100644 --- a/src/DebugServer/Gdb/CommandPackets/ContinueExecution.cpp +++ b/src/DebugServer/Gdb/CommandPackets/ContinueExecution.cpp @@ -15,9 +15,9 @@ namespace Bloom::DebugServer::Gdb::CommandPackets ContinueExecution::ContinueExecution(const RawPacket& rawPacket) : CommandPacket(rawPacket) { - if (this->data.size() > 1) { - this->fromProgramCounter = static_cast( - std::stoi(std::string(this->data.begin(), this->data.end()), nullptr, 16) + if (this->data.size() > 2) { + this->fromAddress = static_cast( + std::stoi(std::string(this->data.begin() + 2, this->data.end()), nullptr, 16) ); } } @@ -26,7 +26,7 @@ namespace Bloom::DebugServer::Gdb::CommandPackets Logger::debug("Handling ContinueExecution packet"); try { - targetControllerService.continueTargetExecution(this->fromProgramCounter); + targetControllerService.continueTargetExecution(this->fromAddress, std::nullopt); debugSession.waitingForBreak = true; } catch (const Exception& exception) { diff --git a/src/DebugServer/Gdb/CommandPackets/ContinueExecution.hpp b/src/DebugServer/Gdb/CommandPackets/ContinueExecution.hpp index aec146c7..0253392f 100644 --- a/src/DebugServer/Gdb/CommandPackets/ContinueExecution.hpp +++ b/src/DebugServer/Gdb/CommandPackets/ContinueExecution.hpp @@ -24,7 +24,7 @@ namespace Bloom::DebugServer::Gdb::CommandPackets * * Although the packet *can* contain this address, it is not required, hence the std::optional type. */ - std::optional fromProgramCounter; + std::optional fromAddress; explicit ContinueExecution(const RawPacket& rawPacket); diff --git a/src/DebugServer/Gdb/CommandPackets/StepExecution.cpp b/src/DebugServer/Gdb/CommandPackets/StepExecution.cpp index 72722ba0..20ba1e46 100644 --- a/src/DebugServer/Gdb/CommandPackets/StepExecution.cpp +++ b/src/DebugServer/Gdb/CommandPackets/StepExecution.cpp @@ -16,9 +16,9 @@ namespace Bloom::DebugServer::Gdb::CommandPackets StepExecution::StepExecution(const RawPacket& rawPacket) : CommandPacket(rawPacket) { - if (this->data.size() > 1) { - this->fromProgramCounter = static_cast( - std::stoi(std::string(this->data.begin(), this->data.end()), nullptr, 16) + if (this->data.size() > 2) { + this->fromAddress = static_cast( + std::stoi(std::string(this->data.begin() + 2, this->data.end()), nullptr, 16) ); } } @@ -27,7 +27,7 @@ namespace Bloom::DebugServer::Gdb::CommandPackets Logger::debug("Handling StepExecution packet"); try { - targetControllerService.stepTargetExecution(this->fromProgramCounter); + targetControllerService.stepTargetExecution(this->fromAddress); debugSession.waitingForBreak = true; } catch (const Exception& exception) { diff --git a/src/DebugServer/Gdb/CommandPackets/StepExecution.hpp b/src/DebugServer/Gdb/CommandPackets/StepExecution.hpp index b4e883d3..a433fe36 100644 --- a/src/DebugServer/Gdb/CommandPackets/StepExecution.hpp +++ b/src/DebugServer/Gdb/CommandPackets/StepExecution.hpp @@ -19,7 +19,7 @@ namespace Bloom::DebugServer::Gdb::CommandPackets /** * The address from which to begin the step. */ - std::optional fromProgramCounter; + std::optional fromAddress; explicit StepExecution(const RawPacket& rawPacket); diff --git a/src/Services/TargetControllerService.cpp b/src/Services/TargetControllerService.cpp index 3f6e8123..3a474d67 100644 --- a/src/Services/TargetControllerService.cpp +++ b/src/Services/TargetControllerService.cpp @@ -126,11 +126,18 @@ namespace Bloom::Services ); } - void TargetControllerService::continueTargetExecution(std::optional fromAddress) const { + void TargetControllerService::continueTargetExecution( + std::optional fromAddress, + std::optional toAddress + ) const { auto resumeExecutionCommand = std::make_unique(); if (fromAddress.has_value()) { - resumeExecutionCommand->fromProgramCounter = fromAddress.value(); + resumeExecutionCommand->fromAddress = fromAddress.value(); + } + + if (toAddress.has_value()) { + resumeExecutionCommand->toAddress = toAddress.value(); } this->commandManager.sendCommandAndWaitForResponse( diff --git a/src/Services/TargetControllerService.hpp b/src/Services/TargetControllerService.hpp index efda40c9..80544ddc 100644 --- a/src/Services/TargetControllerService.hpp +++ b/src/Services/TargetControllerService.hpp @@ -83,7 +83,10 @@ namespace Bloom::Services * * @param fromAddress */ - void continueTargetExecution(std::optional fromAddress) const; + void continueTargetExecution( + std::optional fromAddress, + std::optional toAddress + ) const; /** * Requests the TargetController to step execution on the target. diff --git a/src/TargetController/Commands/ResumeTargetExecution.hpp b/src/TargetController/Commands/ResumeTargetExecution.hpp index 8a09f8e0..d637312a 100644 --- a/src/TargetController/Commands/ResumeTargetExecution.hpp +++ b/src/TargetController/Commands/ResumeTargetExecution.hpp @@ -14,11 +14,13 @@ namespace Bloom::TargetController::Commands static constexpr CommandType type = CommandType::RESUME_TARGET_EXECUTION; static const inline std::string name = "ResumeTargetExecution"; - std::optional fromProgramCounter; + std::optional fromAddress; + std::optional toAddress; ResumeTargetExecution() = default; - explicit ResumeTargetExecution(Targets::TargetProgramCounter fromProgramCounter) - : fromProgramCounter(fromProgramCounter) + ResumeTargetExecution(Targets::TargetMemoryAddress fromAddress, Targets::TargetMemoryAddress toAddress) + : fromAddress(fromAddress) + , toAddress(toAddress) {}; [[nodiscard]] CommandType getType() const override { diff --git a/src/TargetController/TargetControllerComponent.cpp b/src/TargetController/TargetControllerComponent.cpp index 961b768f..4a1b24c6 100644 --- a/src/TargetController/TargetControllerComponent.cpp +++ b/src/TargetController/TargetControllerComponent.cpp @@ -797,11 +797,11 @@ namespace Bloom::TargetController ResumeTargetExecution& command ) { if (this->target->getState() != TargetState::RUNNING) { - if (command.fromProgramCounter.has_value()) { - this->target->setProgramCounter(command.fromProgramCounter.value()); + if (command.fromAddress.has_value()) { + this->target->setProgramCounter(*command.fromAddress); } - this->target->run(); + this->target->run(command.toAddress); this->lastTargetState = TargetState::RUNNING; } diff --git a/src/Targets/Microchip/AVR/AVR8/Avr8.cpp b/src/Targets/Microchip/AVR/AVR8/Avr8.cpp index ec806879..58a3c7a7 100644 --- a/src/Targets/Microchip/AVR/AVR8/Avr8.cpp +++ b/src/Targets/Microchip/AVR/AVR8/Avr8.cpp @@ -276,7 +276,11 @@ namespace Bloom::Targets::Microchip::Avr::Avr8Bit return descriptor; } - void Avr8::run() { + void Avr8::run(std::optional toAddress) { + if (toAddress.has_value()) { + return this->avr8DebugInterface->runTo(*toAddress); + } + this->avr8DebugInterface->run(); } diff --git a/src/Targets/Microchip/AVR/AVR8/Avr8.hpp b/src/Targets/Microchip/AVR/AVR8/Avr8.hpp index dab65241..8b273228 100644 --- a/src/Targets/Microchip/AVR/AVR8/Avr8.hpp +++ b/src/Targets/Microchip/AVR/AVR8/Avr8.hpp @@ -87,7 +87,7 @@ namespace Bloom::Targets::Microchip::Avr::Avr8Bit TargetDescriptor getDescriptor() override; - void run() override; + void run(std::optional toAddress = std::nullopt) override; void stop() override; void step() override; void reset() override; diff --git a/src/Targets/Target.hpp b/src/Targets/Target.hpp index fbffa49c..1b3fb3af 100644 --- a/src/Targets/Target.hpp +++ b/src/Targets/Target.hpp @@ -179,8 +179,10 @@ namespace Bloom::Targets /** * Should resume execution on the target. + * + * @param toAddress */ - virtual void run() = 0; + virtual void run(std::optional toAddress = std::nullopt) = 0; /** * Should halt execution on the target.