Replaced SetProgramCounterOnTarget event with TC command
This commit is contained in:
@@ -29,8 +29,6 @@ namespace Bloom::Events
|
|||||||
TARGET_EXECUTION_RESUMED,
|
TARGET_EXECUTION_RESUMED,
|
||||||
TARGET_EXECUTION_STOPPED,
|
TARGET_EXECUTION_STOPPED,
|
||||||
MEMORY_WRITTEN_TO_TARGET,
|
MEMORY_WRITTEN_TO_TARGET,
|
||||||
SET_PROGRAM_COUNTER_ON_TARGET,
|
|
||||||
PROGRAM_COUNTER_SET_ON_TARGET,
|
|
||||||
EXTRACT_TARGET_DESCRIPTOR,
|
EXTRACT_TARGET_DESCRIPTOR,
|
||||||
TARGET_DESCRIPTOR_EXTRACTED,
|
TARGET_DESCRIPTOR_EXTRACTED,
|
||||||
INSIGHT_THREAD_STATE_CHANGED,
|
INSIGHT_THREAD_STATE_CHANGED,
|
||||||
|
|||||||
@@ -16,8 +16,6 @@
|
|||||||
#include "TargetExecutionResumed.hpp"
|
#include "TargetExecutionResumed.hpp"
|
||||||
#include "TargetExecutionStopped.hpp"
|
#include "TargetExecutionStopped.hpp"
|
||||||
#include "MemoryWrittenToTarget.hpp"
|
#include "MemoryWrittenToTarget.hpp"
|
||||||
#include "SetProgramCounterOnTarget.hpp"
|
|
||||||
#include "ProgramCounterSetOnTarget.hpp"
|
|
||||||
#include "ExtractTargetDescriptor.hpp"
|
#include "ExtractTargetDescriptor.hpp"
|
||||||
#include "TargetDescriptorExtracted.hpp"
|
#include "TargetDescriptorExtracted.hpp"
|
||||||
#include "InsightThreadStateChanged.hpp"
|
#include "InsightThreadStateChanged.hpp"
|
||||||
|
|||||||
@@ -1,23 +0,0 @@
|
|||||||
#pragma once
|
|
||||||
|
|
||||||
#include <string>
|
|
||||||
|
|
||||||
#include "Event.hpp"
|
|
||||||
|
|
||||||
namespace Bloom::Events
|
|
||||||
{
|
|
||||||
class ProgramCounterSetOnTarget: public Event
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
static constexpr EventType type = EventType::PROGRAM_COUNTER_SET_ON_TARGET;
|
|
||||||
static inline const std::string name = "ProgramCounterSetOnTarget";
|
|
||||||
|
|
||||||
[[nodiscard]] EventType getType() const override {
|
|
||||||
return ProgramCounterSetOnTarget::type;
|
|
||||||
}
|
|
||||||
|
|
||||||
[[nodiscard]] std::string getName() const override {
|
|
||||||
return ProgramCounterSetOnTarget::name;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
}
|
|
||||||
@@ -1,28 +0,0 @@
|
|||||||
#pragma once
|
|
||||||
|
|
||||||
#include <cstdint>
|
|
||||||
#include <string>
|
|
||||||
|
|
||||||
#include "Event.hpp"
|
|
||||||
#include "ProgramCounterSetOnTarget.hpp"
|
|
||||||
|
|
||||||
namespace Bloom::Events
|
|
||||||
{
|
|
||||||
class SetProgramCounterOnTarget: public Event
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
using TargetControllerResponseType = ProgramCounterSetOnTarget;
|
|
||||||
|
|
||||||
static constexpr EventType type = EventType::SET_PROGRAM_COUNTER_ON_TARGET;
|
|
||||||
static inline const std::string name = "SetProgramCounterOnTarget";
|
|
||||||
std::uint32_t address = 0;
|
|
||||||
|
|
||||||
[[nodiscard]] EventType getType() const override {
|
|
||||||
return SetProgramCounterOnTarget::type;
|
|
||||||
}
|
|
||||||
|
|
||||||
[[nodiscard]] std::string getName() const override {
|
|
||||||
return SetProgramCounterOnTarget::name;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
}
|
|
||||||
@@ -19,5 +19,6 @@ namespace Bloom::TargetController::Commands
|
|||||||
WRITE_TARGET_MEMORY,
|
WRITE_TARGET_MEMORY,
|
||||||
SET_BREAKPOINT,
|
SET_BREAKPOINT,
|
||||||
REMOVE_BREAKPOINT,
|
REMOVE_BREAKPOINT,
|
||||||
|
SET_PROGRAM_COUNTER,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|||||||
32
src/TargetController/Commands/SetProgramCounter.hpp
Normal file
32
src/TargetController/Commands/SetProgramCounter.hpp
Normal file
@@ -0,0 +1,32 @@
|
|||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include <cstdint>
|
||||||
|
|
||||||
|
#include "Command.hpp"
|
||||||
|
|
||||||
|
#include "src/Targets/TargetBreakpoint.hpp"
|
||||||
|
|
||||||
|
namespace Bloom::TargetController::Commands
|
||||||
|
{
|
||||||
|
class SetProgramCounter: public Command
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
static constexpr CommandType type = CommandType::SET_PROGRAM_COUNTER;
|
||||||
|
static inline const std::string name = "SetProgramCounter";
|
||||||
|
|
||||||
|
std::uint32_t address = 0;
|
||||||
|
|
||||||
|
SetProgramCounter() = default;
|
||||||
|
explicit SetProgramCounter(std::uint32_t address)
|
||||||
|
: address(address)
|
||||||
|
{};
|
||||||
|
|
||||||
|
[[nodiscard]] CommandType getType() const override {
|
||||||
|
return SetProgramCounter::type;
|
||||||
|
}
|
||||||
|
|
||||||
|
[[nodiscard]] bool requiresStoppedTargetState() const override {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
||||||
@@ -33,6 +33,7 @@ namespace Bloom::TargetController
|
|||||||
using Commands::StepTargetExecution;
|
using Commands::StepTargetExecution;
|
||||||
using Commands::SetBreakpoint;
|
using Commands::SetBreakpoint;
|
||||||
using Commands::RemoveBreakpoint;
|
using Commands::RemoveBreakpoint;
|
||||||
|
using Commands::SetProgramCounter;
|
||||||
|
|
||||||
using Responses::Response;
|
using Responses::Response;
|
||||||
using Responses::TargetRegistersRead;
|
using Responses::TargetRegistersRead;
|
||||||
@@ -397,10 +398,10 @@ namespace Bloom::TargetController
|
|||||||
this->deregisterCommandHandler(StepTargetExecution::type);
|
this->deregisterCommandHandler(StepTargetExecution::type);
|
||||||
this->deregisterCommandHandler(SetBreakpoint::type);
|
this->deregisterCommandHandler(SetBreakpoint::type);
|
||||||
this->deregisterCommandHandler(RemoveBreakpoint::type);
|
this->deregisterCommandHandler(RemoveBreakpoint::type);
|
||||||
|
this->deregisterCommandHandler(SetProgramCounter::type);
|
||||||
|
|
||||||
this->eventListener->deregisterCallbacksForEventType<Events::DebugSessionFinished>();
|
this->eventListener->deregisterCallbacksForEventType<Events::DebugSessionFinished>();
|
||||||
this->eventListener->deregisterCallbacksForEventType<Events::ExtractTargetDescriptor>();
|
this->eventListener->deregisterCallbacksForEventType<Events::ExtractTargetDescriptor>();
|
||||||
this->eventListener->deregisterCallbacksForEventType<Events::SetProgramCounterOnTarget>();
|
|
||||||
this->eventListener->deregisterCallbacksForEventType<Events::InsightThreadStateChanged>();
|
this->eventListener->deregisterCallbacksForEventType<Events::InsightThreadStateChanged>();
|
||||||
this->eventListener->deregisterCallbacksForEventType<Events::RetrieveTargetPinStates>();
|
this->eventListener->deregisterCallbacksForEventType<Events::RetrieveTargetPinStates>();
|
||||||
this->eventListener->deregisterCallbacksForEventType<Events::SetTargetPinState>();
|
this->eventListener->deregisterCallbacksForEventType<Events::SetTargetPinState>();
|
||||||
@@ -465,6 +466,10 @@ namespace Bloom::TargetController
|
|||||||
std::bind(&TargetControllerComponent::handleRemoveBreakpoint, this, std::placeholders::_1)
|
std::bind(&TargetControllerComponent::handleRemoveBreakpoint, this, std::placeholders::_1)
|
||||||
);
|
);
|
||||||
|
|
||||||
|
this->registerCommandHandler<SetProgramCounter>(
|
||||||
|
std::bind(&TargetControllerComponent::handleSetProgramCounter, this, std::placeholders::_1)
|
||||||
|
);
|
||||||
|
|
||||||
this->eventListener->registerCallbackForEventType<Events::DebugSessionFinished>(
|
this->eventListener->registerCallbackForEventType<Events::DebugSessionFinished>(
|
||||||
std::bind(&TargetControllerComponent::onDebugSessionFinishedEvent, this, std::placeholders::_1)
|
std::bind(&TargetControllerComponent::onDebugSessionFinishedEvent, this, std::placeholders::_1)
|
||||||
);
|
);
|
||||||
@@ -473,10 +478,6 @@ namespace Bloom::TargetController
|
|||||||
std::bind(&TargetControllerComponent::onExtractTargetDescriptor, this, std::placeholders::_1)
|
std::bind(&TargetControllerComponent::onExtractTargetDescriptor, this, std::placeholders::_1)
|
||||||
);
|
);
|
||||||
|
|
||||||
this->eventListener->registerCallbackForEventType<Events::SetProgramCounterOnTarget>(
|
|
||||||
std::bind(&TargetControllerComponent::onSetProgramCounterEvent, this, std::placeholders::_1)
|
|
||||||
);
|
|
||||||
|
|
||||||
this->eventListener->registerCallbackForEventType<Events::RetrieveTargetPinStates>(
|
this->eventListener->registerCallbackForEventType<Events::RetrieveTargetPinStates>(
|
||||||
std::bind(&TargetControllerComponent::onRetrieveTargetPinStatesEvent, this, std::placeholders::_1)
|
std::bind(&TargetControllerComponent::onRetrieveTargetPinStatesEvent, this, std::placeholders::_1)
|
||||||
);
|
);
|
||||||
@@ -871,24 +872,9 @@ namespace Bloom::TargetController
|
|||||||
return std::make_unique<Response>();
|
return std::make_unique<Response>();
|
||||||
}
|
}
|
||||||
|
|
||||||
void TargetControllerComponent::onSetProgramCounterEvent(const Events::SetProgramCounterOnTarget& event) {
|
std::unique_ptr<Response> TargetControllerComponent::handleSetProgramCounter(SetProgramCounter& command) {
|
||||||
try {
|
this->target->setProgramCounter(command.address);
|
||||||
if (this->target->getState() != TargetState::STOPPED) {
|
return std::make_unique<Response>();
|
||||||
throw TargetOperationFailure(
|
|
||||||
"Invalid target state - target must be stopped before the program counter can be updated"
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
this->target->setProgramCounter(event.address);
|
|
||||||
auto programCounterSetEvent = std::make_shared<Events::ProgramCounterSetOnTarget>();
|
|
||||||
programCounterSetEvent->correlationId = event.id;
|
|
||||||
|
|
||||||
EventManager::triggerEvent(programCounterSetEvent);
|
|
||||||
|
|
||||||
} catch (const TargetOperationFailure& exception) {
|
|
||||||
Logger::error("Failed to set program counter on target - " + exception.getMessage());
|
|
||||||
this->emitErrorEvent(event.id, exception.getMessage());
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void TargetControllerComponent::onRetrieveTargetPinStatesEvent(const Events::RetrieveTargetPinStates& event) {
|
void TargetControllerComponent::onRetrieveTargetPinStatesEvent(const Events::RetrieveTargetPinStates& event) {
|
||||||
|
|||||||
@@ -29,6 +29,7 @@
|
|||||||
#include "Commands/StepTargetExecution.hpp"
|
#include "Commands/StepTargetExecution.hpp"
|
||||||
#include "Commands/SetBreakpoint.hpp"
|
#include "Commands/SetBreakpoint.hpp"
|
||||||
#include "Commands/RemoveBreakpoint.hpp"
|
#include "Commands/RemoveBreakpoint.hpp"
|
||||||
|
#include "Commands/SetProgramCounter.hpp"
|
||||||
|
|
||||||
// Responses
|
// Responses
|
||||||
#include "Responses/Response.hpp"
|
#include "Responses/Response.hpp"
|
||||||
@@ -310,14 +311,7 @@ namespace Bloom::TargetController
|
|||||||
std::unique_ptr<Responses::Response> handleStepTargetExecution(Commands::StepTargetExecution& command);
|
std::unique_ptr<Responses::Response> handleStepTargetExecution(Commands::StepTargetExecution& command);
|
||||||
std::unique_ptr<Responses::Response> handleSetBreakpoint(Commands::SetBreakpoint& command);
|
std::unique_ptr<Responses::Response> handleSetBreakpoint(Commands::SetBreakpoint& command);
|
||||||
std::unique_ptr<Responses::Response> handleRemoveBreakpoint(Commands::RemoveBreakpoint& command);
|
std::unique_ptr<Responses::Response> handleRemoveBreakpoint(Commands::RemoveBreakpoint& command);
|
||||||
|
std::unique_ptr<Responses::Response> handleSetProgramCounter(Commands::SetProgramCounter& command);
|
||||||
/**
|
|
||||||
* Will update the program counter value on the target. On success, a ProgramCounterSetOnTarget event is
|
|
||||||
* emitted.
|
|
||||||
*
|
|
||||||
* @param event
|
|
||||||
*/
|
|
||||||
void onSetProgramCounterEvent(const Events::SetProgramCounterOnTarget& event);
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Will attempt to obtain the pin states from the target. Will emit a TargetPinStatesRetrieved event on success.
|
* Will attempt to obtain the pin states from the target. Will emit a TargetPinStatesRetrieved event on success.
|
||||||
|
|||||||
@@ -16,6 +16,7 @@
|
|||||||
#include "Commands/StepTargetExecution.hpp"
|
#include "Commands/StepTargetExecution.hpp"
|
||||||
#include "Commands/SetBreakpoint.hpp"
|
#include "Commands/SetBreakpoint.hpp"
|
||||||
#include "Commands/RemoveBreakpoint.hpp"
|
#include "Commands/RemoveBreakpoint.hpp"
|
||||||
|
#include "Commands/SetProgramCounter.hpp"
|
||||||
|
|
||||||
#include "src/Logger/Logger.hpp"
|
#include "src/Logger/Logger.hpp"
|
||||||
|
|
||||||
@@ -36,6 +37,7 @@ namespace Bloom::TargetController
|
|||||||
using Commands::StepTargetExecution;
|
using Commands::StepTargetExecution;
|
||||||
using Commands::SetBreakpoint;
|
using Commands::SetBreakpoint;
|
||||||
using Commands::RemoveBreakpoint;
|
using Commands::RemoveBreakpoint;
|
||||||
|
using Commands::SetProgramCounter;
|
||||||
|
|
||||||
TargetControllerConsole::TargetControllerConsole(EventListener& eventListener)
|
TargetControllerConsole::TargetControllerConsole(EventListener& eventListener)
|
||||||
: eventListener(eventListener)
|
: eventListener(eventListener)
|
||||||
@@ -156,6 +158,13 @@ namespace Bloom::TargetController
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void TargetControllerConsole::setProgramCounter(std::uint32_t address) {
|
||||||
|
this->commandManager.sendCommandAndWaitForResponse(
|
||||||
|
std::make_unique<SetProgramCounter>(address),
|
||||||
|
this->defaultTimeout
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
Targets::TargetPinStateMappingType TargetControllerConsole::getPinStates(int variantId) {
|
Targets::TargetPinStateMappingType TargetControllerConsole::getPinStates(int variantId) {
|
||||||
auto requestEvent = std::make_shared<RetrieveTargetPinStates>();
|
auto requestEvent = std::make_shared<RetrieveTargetPinStates>();
|
||||||
requestEvent->variantId = variantId;
|
requestEvent->variantId = variantId;
|
||||||
|
|||||||
@@ -144,6 +144,13 @@ namespace Bloom::TargetController
|
|||||||
*/
|
*/
|
||||||
void removeBreakpoint(Targets::TargetBreakpoint breakpoint);
|
void removeBreakpoint(Targets::TargetBreakpoint breakpoint);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets the target's program counter to the given address.
|
||||||
|
*
|
||||||
|
* @param address
|
||||||
|
*/
|
||||||
|
void setProgramCounter(std::uint32_t address);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Retrieves the pin states for a particular target variant.
|
* Retrieves the pin states for a particular target variant.
|
||||||
*
|
*
|
||||||
|
|||||||
Reference in New Issue
Block a user