New GetTargetProgramCounter TC command
This commit is contained in:
@@ -23,6 +23,7 @@ namespace Bloom::TargetController::Commands
|
||||
GET_TARGET_PIN_STATES,
|
||||
SET_TARGET_PIN_STATE,
|
||||
GET_TARGET_STACK_POINTER,
|
||||
GET_TARGET_PROGRAM_COUNTER,
|
||||
GET_TARGET_DESCRIPTOR,
|
||||
};
|
||||
}
|
||||
|
||||
25
src/TargetController/Commands/GetTargetProgramCounter.hpp
Normal file
25
src/TargetController/Commands/GetTargetProgramCounter.hpp
Normal file
@@ -0,0 +1,25 @@
|
||||
#pragma once
|
||||
|
||||
#include "Command.hpp"
|
||||
|
||||
#include "src/TargetController/Responses/TargetProgramCounter.hpp"
|
||||
|
||||
namespace Bloom::TargetController::Commands
|
||||
{
|
||||
class GetTargetProgramCounter: public Command
|
||||
{
|
||||
public:
|
||||
using SuccessResponseType = Responses::TargetProgramCounter;
|
||||
|
||||
static constexpr CommandType type = CommandType::GET_TARGET_PROGRAM_COUNTER;
|
||||
static inline const std::string name = "GetTargetProgramCounter";
|
||||
|
||||
[[nodiscard]] CommandType getType() const override {
|
||||
return GetTargetProgramCounter::type;
|
||||
}
|
||||
|
||||
[[nodiscard]] bool requiresStoppedTargetState() const override {
|
||||
return true;
|
||||
}
|
||||
};
|
||||
}
|
||||
@@ -13,6 +13,7 @@ namespace Bloom::TargetController::Responses
|
||||
TARGET_STATE,
|
||||
TARGET_PIN_STATES,
|
||||
TARGET_STACK_POINTER,
|
||||
TARGET_PROGRAM_COUNTER,
|
||||
TARGET_DESCRIPTOR,
|
||||
};
|
||||
}
|
||||
|
||||
24
src/TargetController/Responses/TargetProgramCounter.hpp
Normal file
24
src/TargetController/Responses/TargetProgramCounter.hpp
Normal file
@@ -0,0 +1,24 @@
|
||||
#pragma once
|
||||
|
||||
#include <cstdint>
|
||||
|
||||
#include "Response.hpp"
|
||||
|
||||
namespace Bloom::TargetController::Responses
|
||||
{
|
||||
class TargetProgramCounter: public Response
|
||||
{
|
||||
public:
|
||||
static constexpr ResponseType type = ResponseType::TARGET_PROGRAM_COUNTER;
|
||||
|
||||
std::uint32_t programCounter;
|
||||
|
||||
explicit TargetProgramCounter(std::uint32_t programCounter)
|
||||
: programCounter(programCounter)
|
||||
{}
|
||||
|
||||
[[nodiscard]] ResponseType getType() const override {
|
||||
return TargetProgramCounter::type;
|
||||
}
|
||||
};
|
||||
}
|
||||
@@ -38,12 +38,14 @@ namespace Bloom::TargetController
|
||||
using Commands::GetTargetPinStates;
|
||||
using Commands::SetTargetPinState;
|
||||
using Commands::GetTargetStackPointer;
|
||||
using Commands::GetTargetProgramCounter;
|
||||
|
||||
using Responses::Response;
|
||||
using Responses::TargetRegistersRead;
|
||||
using Responses::TargetMemoryRead;
|
||||
using Responses::TargetPinStates;
|
||||
using Responses::TargetStackPointer;
|
||||
using Responses::TargetProgramCounter;
|
||||
|
||||
TargetControllerComponent::TargetControllerComponent(
|
||||
const ProjectConfig& projectConfig,
|
||||
@@ -410,6 +412,7 @@ namespace Bloom::TargetController
|
||||
this->deregisterCommandHandler(GetTargetPinStates::type);
|
||||
this->deregisterCommandHandler(SetTargetPinState::type);
|
||||
this->deregisterCommandHandler(GetTargetStackPointer::type);
|
||||
this->deregisterCommandHandler(GetTargetProgramCounter::type);
|
||||
|
||||
this->eventListener->deregisterCallbacksForEventType<Events::DebugSessionFinished>();
|
||||
|
||||
@@ -492,6 +495,10 @@ namespace Bloom::TargetController
|
||||
std::bind(&TargetControllerComponent::handleGetTargetStackPointer, this, std::placeholders::_1)
|
||||
);
|
||||
|
||||
this->registerCommandHandler<GetTargetProgramCounter>(
|
||||
std::bind(&TargetControllerComponent::handleGetTargetProgramCounter, this, std::placeholders::_1)
|
||||
);
|
||||
|
||||
this->eventListener->registerCallbackForEventType<Events::DebugSessionFinished>(
|
||||
std::bind(&TargetControllerComponent::onDebugSessionFinishedEvent, this, std::placeholders::_1)
|
||||
);
|
||||
@@ -895,4 +902,10 @@ namespace Bloom::TargetController
|
||||
) {
|
||||
return std::make_unique<TargetStackPointer>(this->target->getStackPointer());
|
||||
}
|
||||
|
||||
std::unique_ptr<TargetProgramCounter> TargetControllerComponent::handleGetTargetProgramCounter(
|
||||
GetTargetProgramCounter& command
|
||||
) {
|
||||
return std::make_unique<TargetProgramCounter>(this->target->getProgramCounter());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -34,6 +34,7 @@
|
||||
#include "Commands/GetTargetPinStates.hpp"
|
||||
#include "Commands/SetTargetPinState.hpp"
|
||||
#include "Commands/GetTargetStackPointer.hpp"
|
||||
#include "Commands/GetTargetProgramCounter.hpp"
|
||||
|
||||
// Responses
|
||||
#include "Responses/Response.hpp"
|
||||
@@ -43,6 +44,7 @@
|
||||
#include "Responses/TargetMemoryRead.hpp"
|
||||
#include "Responses/TargetPinStates.hpp"
|
||||
#include "Responses/TargetStackPointer.hpp"
|
||||
#include "Responses/TargetProgramCounter.hpp"
|
||||
|
||||
#include "TargetControllerState.hpp"
|
||||
|
||||
@@ -318,5 +320,8 @@ namespace Bloom::TargetController
|
||||
std::unique_ptr<Responses::TargetStackPointer> handleGetTargetStackPointer(
|
||||
Commands::GetTargetStackPointer& command
|
||||
);
|
||||
std::unique_ptr<Responses::TargetProgramCounter> handleGetTargetProgramCounter(
|
||||
Commands::GetTargetProgramCounter& command
|
||||
);
|
||||
};
|
||||
}
|
||||
|
||||
@@ -21,6 +21,7 @@
|
||||
#include "Commands/GetTargetPinStates.hpp"
|
||||
#include "Commands/SetTargetPinState.hpp"
|
||||
#include "Commands/GetTargetStackPointer.hpp"
|
||||
#include "Commands/GetTargetProgramCounter.hpp"
|
||||
|
||||
#include "src/Logger/Logger.hpp"
|
||||
|
||||
@@ -46,6 +47,7 @@ namespace Bloom::TargetController
|
||||
using Commands::GetTargetPinStates;
|
||||
using Commands::SetTargetPinState;
|
||||
using Commands::GetTargetStackPointer;
|
||||
using Commands::GetTargetProgramCounter;
|
||||
|
||||
TargetControllerConsole::TargetControllerConsole(EventListener& eventListener)
|
||||
: eventListener(eventListener)
|
||||
@@ -167,6 +169,13 @@ namespace Bloom::TargetController
|
||||
);
|
||||
}
|
||||
|
||||
std::uint32_t TargetControllerConsole::getProgramCounter() {
|
||||
return this->commandManager.sendCommandAndWaitForResponse(
|
||||
std::make_unique<GetTargetProgramCounter>(),
|
||||
this->defaultTimeout
|
||||
)->programCounter;
|
||||
}
|
||||
|
||||
void TargetControllerConsole::setProgramCounter(std::uint32_t address) {
|
||||
this->commandManager.sendCommandAndWaitForResponse(
|
||||
std::make_unique<SetProgramCounter>(address),
|
||||
|
||||
@@ -144,6 +144,13 @@ namespace Bloom::TargetController
|
||||
*/
|
||||
void removeBreakpoint(Targets::TargetBreakpoint breakpoint);
|
||||
|
||||
/**
|
||||
* Retrieves the current program counter value from the target.
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
std::uint32_t getProgramCounter();
|
||||
|
||||
/**
|
||||
* Sets the target's program counter to the given address.
|
||||
*
|
||||
|
||||
Reference in New Issue
Block a user