Replaced StopTargetExecution event with TC command
This commit is contained in:
@@ -15,7 +15,6 @@ namespace Bloom::Events
|
|||||||
enum class EventType: std::uint8_t
|
enum class EventType: std::uint8_t
|
||||||
{
|
{
|
||||||
GENERIC,
|
GENERIC,
|
||||||
STOP_TARGET_EXECUTION,
|
|
||||||
RESUME_TARGET_EXECUTION,
|
RESUME_TARGET_EXECUTION,
|
||||||
RESET_TARGET,
|
RESET_TARGET,
|
||||||
DEBUG_SESSION_STARTED,
|
DEBUG_SESSION_STARTED,
|
||||||
|
|||||||
@@ -3,7 +3,6 @@
|
|||||||
#include <memory>
|
#include <memory>
|
||||||
|
|
||||||
#include "Event.hpp"
|
#include "Event.hpp"
|
||||||
#include "StopTargetExecution.hpp"
|
|
||||||
#include "ResumeTargetExecution.hpp"
|
#include "ResumeTargetExecution.hpp"
|
||||||
#include "ResetTarget.hpp"
|
#include "ResetTarget.hpp"
|
||||||
#include "DebugSessionStarted.hpp"
|
#include "DebugSessionStarted.hpp"
|
||||||
|
|||||||
@@ -1,26 +0,0 @@
|
|||||||
#pragma once
|
|
||||||
|
|
||||||
#include <string>
|
|
||||||
|
|
||||||
#include "Event.hpp"
|
|
||||||
#include "TargetExecutionStopped.hpp"
|
|
||||||
|
|
||||||
namespace Bloom::Events
|
|
||||||
{
|
|
||||||
class StopTargetExecution: public Event
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
using TargetControllerResponseType = TargetExecutionStopped;
|
|
||||||
|
|
||||||
static constexpr EventType type = EventType::STOP_TARGET_EXECUTION;
|
|
||||||
static inline const std::string name = "StopTargetExecution";
|
|
||||||
|
|
||||||
[[nodiscard]] EventType getType() const override {
|
|
||||||
return StopTargetExecution::type;
|
|
||||||
}
|
|
||||||
|
|
||||||
[[nodiscard]] std::string getName() const override {
|
|
||||||
return StopTargetExecution::name;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
}
|
|
||||||
@@ -7,5 +7,6 @@ namespace Bloom::TargetController::Commands
|
|||||||
enum class CommandType: std::uint8_t
|
enum class CommandType: std::uint8_t
|
||||||
{
|
{
|
||||||
GENERIC,
|
GENERIC,
|
||||||
|
STOP_TARGET_EXECUTION,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|||||||
17
src/TargetController/Commands/StopTargetExecution.hpp
Normal file
17
src/TargetController/Commands/StopTargetExecution.hpp
Normal file
@@ -0,0 +1,17 @@
|
|||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include "Command.hpp"
|
||||||
|
|
||||||
|
namespace Bloom::TargetController::Commands
|
||||||
|
{
|
||||||
|
class StopTargetExecution: public Command
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
static constexpr CommandType type = CommandType::STOP_TARGET_EXECUTION;
|
||||||
|
static inline const std::string name = "StopTargetExecution";
|
||||||
|
|
||||||
|
[[nodiscard]] CommandType getType() const override {
|
||||||
|
return StopTargetExecution::type;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
||||||
@@ -22,7 +22,10 @@ namespace Bloom::TargetController
|
|||||||
|
|
||||||
using Commands::Command;
|
using Commands::Command;
|
||||||
using Commands::CommandIdType;
|
using Commands::CommandIdType;
|
||||||
|
using Commands::StopTargetExecution;
|
||||||
|
|
||||||
using Responses::Response;
|
using Responses::Response;
|
||||||
|
|
||||||
TargetControllerComponent::TargetControllerComponent(
|
TargetControllerComponent::TargetControllerComponent(
|
||||||
const ProjectConfig& projectConfig,
|
const ProjectConfig& projectConfig,
|
||||||
const EnvironmentConfig& environmentConfig
|
const EnvironmentConfig& environmentConfig
|
||||||
@@ -366,9 +369,10 @@ namespace Bloom::TargetController
|
|||||||
+ std::string(exception.what()));
|
+ std::string(exception.what()));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
this->deregisterCommandHandler(StopTargetExecution::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::StopTargetExecution>();
|
|
||||||
this->eventListener->deregisterCallbacksForEventType<Events::StepTargetExecution>();
|
this->eventListener->deregisterCallbacksForEventType<Events::StepTargetExecution>();
|
||||||
this->eventListener->deregisterCallbacksForEventType<Events::ResumeTargetExecution>();
|
this->eventListener->deregisterCallbacksForEventType<Events::ResumeTargetExecution>();
|
||||||
this->eventListener->deregisterCallbacksForEventType<Events::RetrieveRegistersFromTarget>();
|
this->eventListener->deregisterCallbacksForEventType<Events::RetrieveRegistersFromTarget>();
|
||||||
@@ -398,6 +402,10 @@ namespace Bloom::TargetController
|
|||||||
this->acquireHardware();
|
this->acquireHardware();
|
||||||
this->loadRegisterDescriptors();
|
this->loadRegisterDescriptors();
|
||||||
|
|
||||||
|
this->registerCommandHandler<StopTargetExecution>(
|
||||||
|
std::bind(&TargetControllerComponent::handleStopTargetExecution, 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)
|
||||||
);
|
);
|
||||||
@@ -406,10 +414,6 @@ namespace Bloom::TargetController
|
|||||||
std::bind(&TargetControllerComponent::onExtractTargetDescriptor, this, std::placeholders::_1)
|
std::bind(&TargetControllerComponent::onExtractTargetDescriptor, this, std::placeholders::_1)
|
||||||
);
|
);
|
||||||
|
|
||||||
this->eventListener->registerCallbackForEventType<Events::StopTargetExecution>(
|
|
||||||
std::bind(&TargetControllerComponent::onStopTargetExecutionEvent, this, std::placeholders::_1)
|
|
||||||
);
|
|
||||||
|
|
||||||
this->eventListener->registerCallbackForEventType<Events::StepTargetExecution>(
|
this->eventListener->registerCallbackForEventType<Events::StepTargetExecution>(
|
||||||
std::bind(&TargetControllerComponent::onStepTargetExecutionEvent, this, std::placeholders::_1)
|
std::bind(&TargetControllerComponent::onStepTargetExecutionEvent, this, std::placeholders::_1)
|
||||||
);
|
);
|
||||||
@@ -723,19 +727,18 @@ namespace Bloom::TargetController
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void TargetControllerComponent::onStopTargetExecutionEvent(const Events::StopTargetExecution& event) {
|
std::unique_ptr<Response> TargetControllerComponent::handleStopTargetExecution(StopTargetExecution& command) {
|
||||||
if (this->target->getState() != TargetState::STOPPED) {
|
if (this->target->getState() != TargetState::STOPPED) {
|
||||||
this->target->stop();
|
this->target->stop();
|
||||||
this->lastTargetState = TargetState::STOPPED;
|
this->lastTargetState = TargetState::STOPPED;
|
||||||
}
|
}
|
||||||
|
|
||||||
auto executionStoppedEvent = std::make_shared<Events::TargetExecutionStopped>(
|
EventManager::triggerEvent(std::make_shared<Events::TargetExecutionStopped>(
|
||||||
this->target->getProgramCounter(),
|
this->target->getProgramCounter(),
|
||||||
TargetBreakCause::UNKNOWN
|
TargetBreakCause::UNKNOWN
|
||||||
);
|
));
|
||||||
|
|
||||||
executionStoppedEvent->correlationId = event.id;
|
return std::make_unique<Response>();
|
||||||
EventManager::triggerEvent(executionStoppedEvent);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void TargetControllerComponent::onStepTargetExecutionEvent(const Events::StepTargetExecution& event) {
|
void TargetControllerComponent::onStepTargetExecutionEvent(const Events::StepTargetExecution& event) {
|
||||||
|
|||||||
@@ -17,6 +17,7 @@
|
|||||||
|
|
||||||
// Commands
|
// Commands
|
||||||
#include "Commands/Command.hpp"
|
#include "Commands/Command.hpp"
|
||||||
|
#include "Commands/StopTargetExecution.hpp"
|
||||||
|
|
||||||
// Responses
|
// Responses
|
||||||
#include "Responses/Response.hpp"
|
#include "Responses/Response.hpp"
|
||||||
@@ -287,12 +288,7 @@ namespace Bloom::TargetController
|
|||||||
*/
|
*/
|
||||||
void onDebugSessionFinishedEvent(const Events::DebugSessionFinished& event);
|
void onDebugSessionFinishedEvent(const Events::DebugSessionFinished& event);
|
||||||
|
|
||||||
/**
|
std::unique_ptr<Responses::Response> handleStopTargetExecution(Commands::StopTargetExecution& command);
|
||||||
* Will attempt to stop execution on the target and emit a TargetExecutionStopped event.
|
|
||||||
*
|
|
||||||
* @param event
|
|
||||||
*/
|
|
||||||
void onStopTargetExecutionEvent(const Events::StopTargetExecution& event);
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Will attempt to step execution on the target and emit a TargetExecutionResumed event.
|
* Will attempt to step execution on the target and emit a TargetExecutionResumed event.
|
||||||
|
|||||||
@@ -1,6 +1,10 @@
|
|||||||
#include "TargetControllerConsole.hpp"
|
#include "TargetControllerConsole.hpp"
|
||||||
|
|
||||||
#include "src/EventManager/Events/Events.hpp"
|
#include "src/EventManager/Events/Events.hpp"
|
||||||
|
|
||||||
|
// Commands
|
||||||
|
#include "Commands/StopTargetExecution.hpp"
|
||||||
|
|
||||||
#include "src/Logger/Logger.hpp"
|
#include "src/Logger/Logger.hpp"
|
||||||
|
|
||||||
namespace Bloom::TargetController
|
namespace Bloom::TargetController
|
||||||
@@ -9,6 +13,8 @@ namespace Bloom::TargetController
|
|||||||
using namespace Bloom::Events;
|
using namespace Bloom::Events;
|
||||||
using namespace Bloom::Exceptions;
|
using namespace Bloom::Exceptions;
|
||||||
|
|
||||||
|
using Commands::StopTargetExecution;
|
||||||
|
|
||||||
TargetControllerConsole::TargetControllerConsole(EventListener& eventListener)
|
TargetControllerConsole::TargetControllerConsole(EventListener& eventListener)
|
||||||
: eventListener(eventListener)
|
: eventListener(eventListener)
|
||||||
{}
|
{}
|
||||||
@@ -35,7 +41,10 @@ namespace Bloom::TargetController
|
|||||||
}
|
}
|
||||||
|
|
||||||
void TargetControllerConsole::stopTargetExecution() {
|
void TargetControllerConsole::stopTargetExecution() {
|
||||||
this->triggerTargetControllerEventAndWaitForResponse(std::make_shared<StopTargetExecution>());
|
this->commandManager.sendCommandAndWaitForResponse(
|
||||||
|
std::make_unique<StopTargetExecution>(),
|
||||||
|
this->defaultTimeout
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
void TargetControllerConsole::continueTargetExecution(std::optional<std::uint32_t> fromAddress) {
|
void TargetControllerConsole::continueTargetExecution(std::optional<std::uint32_t> fromAddress) {
|
||||||
|
|||||||
Reference in New Issue
Block a user