Preparation for support for the GDB vCont command packet
Also fixed a bug in the `StepExecution` and `ContinueExecution` constructors, where the from address wasn't being extracted properly
This commit is contained in:
@@ -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<Targets::TargetProgramCounter>(
|
||||
std::stoi(std::string(this->data.begin(), this->data.end()), nullptr, 16)
|
||||
if (this->data.size() > 2) {
|
||||
this->fromAddress = static_cast<Targets::TargetProgramCounter>(
|
||||
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) {
|
||||
|
||||
@@ -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<Targets::TargetProgramCounter> fromProgramCounter;
|
||||
std::optional<Targets::TargetMemoryAddress> fromAddress;
|
||||
|
||||
explicit ContinueExecution(const RawPacket& rawPacket);
|
||||
|
||||
|
||||
@@ -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<Targets::TargetProgramCounter>(
|
||||
std::stoi(std::string(this->data.begin(), this->data.end()), nullptr, 16)
|
||||
if (this->data.size() > 2) {
|
||||
this->fromAddress = static_cast<Targets::TargetProgramCounter>(
|
||||
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) {
|
||||
|
||||
@@ -19,7 +19,7 @@ namespace Bloom::DebugServer::Gdb::CommandPackets
|
||||
/**
|
||||
* The address from which to begin the step.
|
||||
*/
|
||||
std::optional<Targets::TargetProgramCounter> fromProgramCounter;
|
||||
std::optional<Targets::TargetMemoryAddress> fromAddress;
|
||||
|
||||
explicit StepExecution(const RawPacket& rawPacket);
|
||||
|
||||
|
||||
@@ -126,11 +126,18 @@ namespace Bloom::Services
|
||||
);
|
||||
}
|
||||
|
||||
void TargetControllerService::continueTargetExecution(std::optional<TargetProgramCounter> fromAddress) const {
|
||||
void TargetControllerService::continueTargetExecution(
|
||||
std::optional<TargetMemoryAddress> fromAddress,
|
||||
std::optional<Targets::TargetMemoryAddress> toAddress
|
||||
) const {
|
||||
auto resumeExecutionCommand = std::make_unique<ResumeTargetExecution>();
|
||||
|
||||
if (fromAddress.has_value()) {
|
||||
resumeExecutionCommand->fromProgramCounter = fromAddress.value();
|
||||
resumeExecutionCommand->fromAddress = fromAddress.value();
|
||||
}
|
||||
|
||||
if (toAddress.has_value()) {
|
||||
resumeExecutionCommand->toAddress = toAddress.value();
|
||||
}
|
||||
|
||||
this->commandManager.sendCommandAndWaitForResponse(
|
||||
|
||||
@@ -83,7 +83,10 @@ namespace Bloom::Services
|
||||
*
|
||||
* @param fromAddress
|
||||
*/
|
||||
void continueTargetExecution(std::optional<Targets::TargetProgramCounter> fromAddress) const;
|
||||
void continueTargetExecution(
|
||||
std::optional<Targets::TargetMemoryAddress> fromAddress,
|
||||
std::optional<Targets::TargetMemoryAddress> toAddress
|
||||
) const;
|
||||
|
||||
/**
|
||||
* Requests the TargetController to step execution on the target.
|
||||
|
||||
@@ -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<Targets::TargetProgramCounter> fromProgramCounter;
|
||||
std::optional<Targets::TargetMemoryAddress> fromAddress;
|
||||
std::optional<Targets::TargetMemoryAddress> 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 {
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
@@ -276,7 +276,11 @@ namespace Bloom::Targets::Microchip::Avr::Avr8Bit
|
||||
return descriptor;
|
||||
}
|
||||
|
||||
void Avr8::run() {
|
||||
void Avr8::run(std::optional<TargetMemoryAddress> toAddress) {
|
||||
if (toAddress.has_value()) {
|
||||
return this->avr8DebugInterface->runTo(*toAddress);
|
||||
}
|
||||
|
||||
this->avr8DebugInterface->run();
|
||||
}
|
||||
|
||||
|
||||
@@ -87,7 +87,7 @@ namespace Bloom::Targets::Microchip::Avr::Avr8Bit
|
||||
|
||||
TargetDescriptor getDescriptor() override;
|
||||
|
||||
void run() override;
|
||||
void run(std::optional<TargetMemoryAddress> toAddress = std::nullopt) override;
|
||||
void stop() override;
|
||||
void step() override;
|
||||
void reset() override;
|
||||
|
||||
@@ -179,8 +179,10 @@ namespace Bloom::Targets
|
||||
|
||||
/**
|
||||
* Should resume execution on the target.
|
||||
*
|
||||
* @param toAddress
|
||||
*/
|
||||
virtual void run() = 0;
|
||||
virtual void run(std::optional<TargetMemoryAddress> toAddress = std::nullopt) = 0;
|
||||
|
||||
/**
|
||||
* Should halt execution on the target.
|
||||
|
||||
Reference in New Issue
Block a user