Replaced ExtractTargetDescriptor event with TC command
This commit is contained in:
@@ -29,8 +29,6 @@ namespace Bloom::Events
|
||||
TARGET_EXECUTION_RESUMED,
|
||||
TARGET_EXECUTION_STOPPED,
|
||||
MEMORY_WRITTEN_TO_TARGET,
|
||||
EXTRACT_TARGET_DESCRIPTOR,
|
||||
TARGET_DESCRIPTOR_EXTRACTED,
|
||||
INSIGHT_THREAD_STATE_CHANGED,
|
||||
TARGET_RESET,
|
||||
};
|
||||
|
||||
@@ -16,8 +16,6 @@
|
||||
#include "TargetExecutionResumed.hpp"
|
||||
#include "TargetExecutionStopped.hpp"
|
||||
#include "MemoryWrittenToTarget.hpp"
|
||||
#include "ExtractTargetDescriptor.hpp"
|
||||
#include "TargetDescriptorExtracted.hpp"
|
||||
#include "InsightThreadStateChanged.hpp"
|
||||
#include "TargetReset.hpp"
|
||||
|
||||
|
||||
@@ -1,27 +0,0 @@
|
||||
#pragma once
|
||||
|
||||
#include <string>
|
||||
|
||||
#include "Event.hpp"
|
||||
|
||||
#include "TargetDescriptorExtracted.hpp"
|
||||
|
||||
namespace Bloom::Events
|
||||
{
|
||||
class ExtractTargetDescriptor: public Event
|
||||
{
|
||||
public:
|
||||
using TargetControllerResponseType = TargetDescriptorExtracted;
|
||||
|
||||
static constexpr EventType type = EventType::EXTRACT_TARGET_DESCRIPTOR;
|
||||
static inline const std::string name = "ExtractTargetDescriptor";
|
||||
|
||||
[[nodiscard]] EventType getType() const override {
|
||||
return ExtractTargetDescriptor::type;
|
||||
}
|
||||
|
||||
[[nodiscard]] std::string getName() const override {
|
||||
return ExtractTargetDescriptor::name;
|
||||
}
|
||||
};
|
||||
}
|
||||
@@ -1,25 +0,0 @@
|
||||
#pragma once
|
||||
|
||||
#include <string>
|
||||
|
||||
#include "Event.hpp"
|
||||
#include "src/Targets/TargetDescriptor.hpp"
|
||||
|
||||
namespace Bloom::Events
|
||||
{
|
||||
class TargetDescriptorExtracted: public Event
|
||||
{
|
||||
public:
|
||||
static constexpr EventType type = EventType::TARGET_DESCRIPTOR_EXTRACTED;
|
||||
static inline const std::string name = "TargetDescriptorExtracted";
|
||||
Targets::TargetDescriptor targetDescriptor;
|
||||
|
||||
[[nodiscard]] EventType getType() const override {
|
||||
return TargetDescriptorExtracted::type;
|
||||
}
|
||||
|
||||
[[nodiscard]] std::string getName() const override {
|
||||
return TargetDescriptorExtracted::name;
|
||||
}
|
||||
};
|
||||
}
|
||||
@@ -23,5 +23,6 @@ namespace Bloom::TargetController::Commands
|
||||
GET_TARGET_PIN_STATES,
|
||||
SET_TARGET_PIN_STATE,
|
||||
GET_TARGET_STACK_POINTER,
|
||||
GET_TARGET_DESCRIPTOR,
|
||||
};
|
||||
}
|
||||
|
||||
21
src/TargetController/Commands/GetTargetDescriptor.hpp
Normal file
21
src/TargetController/Commands/GetTargetDescriptor.hpp
Normal file
@@ -0,0 +1,21 @@
|
||||
#pragma once
|
||||
|
||||
#include "Command.hpp"
|
||||
|
||||
#include "src/TargetController/Responses/TargetDescriptor.hpp"
|
||||
|
||||
namespace Bloom::TargetController::Commands
|
||||
{
|
||||
class GetTargetDescriptor: public Command
|
||||
{
|
||||
public:
|
||||
using SuccessResponseType = Responses::TargetDescriptor;
|
||||
|
||||
static constexpr CommandType type = CommandType::GET_TARGET_DESCRIPTOR;
|
||||
static inline const std::string name = "GetTargetDescriptor";
|
||||
|
||||
[[nodiscard]] CommandType getType() const override {
|
||||
return GetTargetDescriptor::type;
|
||||
}
|
||||
};
|
||||
}
|
||||
@@ -13,5 +13,6 @@ namespace Bloom::TargetController::Responses
|
||||
TARGET_STATE,
|
||||
TARGET_PIN_STATES,
|
||||
TARGET_STACK_POINTER,
|
||||
TARGET_DESCRIPTOR,
|
||||
};
|
||||
}
|
||||
|
||||
26
src/TargetController/Responses/TargetDescriptor.hpp
Normal file
26
src/TargetController/Responses/TargetDescriptor.hpp
Normal file
@@ -0,0 +1,26 @@
|
||||
#pragma once
|
||||
|
||||
#include <cstdint>
|
||||
|
||||
#include "Response.hpp"
|
||||
|
||||
#include "src/Targets/TargetDescriptor.hpp"
|
||||
|
||||
namespace Bloom::TargetController::Responses
|
||||
{
|
||||
class TargetDescriptor: public Response
|
||||
{
|
||||
public:
|
||||
static constexpr ResponseType type = ResponseType::TARGET_DESCRIPTOR;
|
||||
|
||||
Targets::TargetDescriptor targetDescriptor;
|
||||
|
||||
explicit TargetDescriptor(const Targets::TargetDescriptor& targetDescriptor)
|
||||
: targetDescriptor(targetDescriptor)
|
||||
{}
|
||||
|
||||
[[nodiscard]] ResponseType getType() const override {
|
||||
return TargetDescriptor::type;
|
||||
}
|
||||
};
|
||||
}
|
||||
@@ -22,6 +22,7 @@ namespace Bloom::TargetController
|
||||
|
||||
using Commands::Command;
|
||||
using Commands::CommandIdType;
|
||||
using Commands::GetTargetDescriptor;
|
||||
using Commands::GetTargetState;
|
||||
using Commands::StopTargetExecution;
|
||||
using Commands::ResumeTargetExecution;
|
||||
@@ -393,6 +394,7 @@ namespace Bloom::TargetController
|
||||
+ std::string(exception.what()));
|
||||
}
|
||||
|
||||
this->deregisterCommandHandler(GetTargetDescriptor::type);
|
||||
this->deregisterCommandHandler(GetTargetState::type);
|
||||
this->deregisterCommandHandler(StopTargetExecution::type);
|
||||
this->deregisterCommandHandler(ResumeTargetExecution::type);
|
||||
@@ -410,7 +412,6 @@ namespace Bloom::TargetController
|
||||
this->deregisterCommandHandler(GetTargetStackPointer::type);
|
||||
|
||||
this->eventListener->deregisterCallbacksForEventType<Events::DebugSessionFinished>();
|
||||
this->eventListener->deregisterCallbacksForEventType<Events::ExtractTargetDescriptor>();
|
||||
|
||||
this->lastTargetState = TargetState::UNKNOWN;
|
||||
this->cachedTargetDescriptor = std::nullopt;
|
||||
@@ -427,6 +428,10 @@ namespace Bloom::TargetController
|
||||
this->acquireHardware();
|
||||
this->loadRegisterDescriptors();
|
||||
|
||||
this->registerCommandHandler<GetTargetDescriptor>(
|
||||
std::bind(&TargetControllerComponent::handleGetTargetDescriptor, this, std::placeholders::_1)
|
||||
);
|
||||
|
||||
this->registerCommandHandler<GetTargetState>(
|
||||
std::bind(&TargetControllerComponent::handleGetTargetState, this, std::placeholders::_1)
|
||||
);
|
||||
@@ -491,10 +496,6 @@ namespace Bloom::TargetController
|
||||
std::bind(&TargetControllerComponent::onDebugSessionFinishedEvent, this, std::placeholders::_1)
|
||||
);
|
||||
|
||||
this->eventListener->registerCallbackForEventType<Events::ExtractTargetDescriptor>(
|
||||
std::bind(&TargetControllerComponent::onExtractTargetDescriptor, this, std::placeholders::_1)
|
||||
);
|
||||
|
||||
TargetControllerComponent::state = TargetControllerState::ACTIVE;
|
||||
EventManager::triggerEvent(
|
||||
std::make_shared<TargetControllerStateChanged>(TargetControllerComponent::state)
|
||||
@@ -710,14 +711,6 @@ namespace Bloom::TargetController
|
||||
this->shutdown();
|
||||
}
|
||||
|
||||
void TargetControllerComponent::onExtractTargetDescriptor(const Events::ExtractTargetDescriptor& event) {
|
||||
auto targetDescriptorExtracted = std::make_shared<TargetDescriptorExtracted>();
|
||||
targetDescriptorExtracted->targetDescriptor = this->getTargetDescriptor();
|
||||
|
||||
targetDescriptorExtracted->correlationId = event.id;
|
||||
EventManager::triggerEvent(targetDescriptorExtracted);
|
||||
}
|
||||
|
||||
void TargetControllerComponent::onDebugSessionStartedEvent(const Events::DebugSessionStarted&) {
|
||||
if (TargetControllerComponent::state == TargetControllerState::SUSPENDED) {
|
||||
Logger::debug("Waking TargetController");
|
||||
@@ -738,6 +731,12 @@ namespace Bloom::TargetController
|
||||
}
|
||||
}
|
||||
|
||||
std::unique_ptr<Responses::TargetDescriptor> TargetControllerComponent::handleGetTargetDescriptor(
|
||||
GetTargetDescriptor& command
|
||||
) {
|
||||
return std::make_unique<Responses::TargetDescriptor>(this->getTargetDescriptor());
|
||||
}
|
||||
|
||||
std::unique_ptr<Responses::TargetState> TargetControllerComponent::handleGetTargetState(GetTargetState& command) {
|
||||
return std::make_unique<Responses::TargetState>(this->target->getState());
|
||||
}
|
||||
|
||||
@@ -18,6 +18,7 @@
|
||||
|
||||
// Commands
|
||||
#include "Commands/Command.hpp"
|
||||
#include "Commands/GetTargetDescriptor.hpp"
|
||||
#include "Commands/GetTargetState.hpp"
|
||||
#include "Commands/StopTargetExecution.hpp"
|
||||
#include "Commands/ResumeTargetExecution.hpp"
|
||||
@@ -36,6 +37,7 @@
|
||||
|
||||
// Responses
|
||||
#include "Responses/Response.hpp"
|
||||
#include "Responses/TargetDescriptor.hpp"
|
||||
#include "Responses/TargetState.hpp"
|
||||
#include "Responses/TargetRegistersRead.hpp"
|
||||
#include "Responses/TargetMemoryRead.hpp"
|
||||
@@ -282,13 +284,6 @@ namespace Bloom::TargetController
|
||||
*/
|
||||
void onShutdownTargetControllerEvent(const Events::ShutdownTargetController& event);
|
||||
|
||||
/**
|
||||
* Obtains a TargetDescriptor from the target and includes it in a TargetDescriptorExtracted event.
|
||||
*
|
||||
* @param event
|
||||
*/
|
||||
void onExtractTargetDescriptor(const Events::ExtractTargetDescriptor& event);
|
||||
|
||||
/**
|
||||
* Will hold the target stopped at it's current state.
|
||||
*
|
||||
@@ -303,6 +298,7 @@ namespace Bloom::TargetController
|
||||
*/
|
||||
void onDebugSessionFinishedEvent(const Events::DebugSessionFinished& event);
|
||||
|
||||
std::unique_ptr<Responses::TargetDescriptor> handleGetTargetDescriptor(Commands::GetTargetDescriptor& command);
|
||||
std::unique_ptr<Responses::TargetState> handleGetTargetState(Commands::GetTargetState& command);
|
||||
std::unique_ptr<Responses::Response> handleStopTargetExecution(Commands::StopTargetExecution& command);
|
||||
std::unique_ptr<Responses::Response> handleResumeTargetExecution(Commands::ResumeTargetExecution& command);
|
||||
|
||||
@@ -5,6 +5,7 @@
|
||||
#include "TargetControllerComponent.hpp"
|
||||
|
||||
// Commands
|
||||
#include "Commands/GetTargetDescriptor.hpp"
|
||||
#include "Commands/GetTargetState.hpp"
|
||||
#include "Commands/StopTargetExecution.hpp"
|
||||
#include "Commands/ResumeTargetExecution.hpp"
|
||||
@@ -29,6 +30,7 @@ namespace Bloom::TargetController
|
||||
using namespace Bloom::Events;
|
||||
using namespace Bloom::Exceptions;
|
||||
|
||||
using Commands::GetTargetDescriptor;
|
||||
using Commands::GetTargetState;
|
||||
using Commands::StopTargetExecution;
|
||||
using Commands::ResumeTargetExecution;
|
||||
@@ -63,8 +65,9 @@ namespace Bloom::TargetController
|
||||
}
|
||||
|
||||
Targets::TargetDescriptor TargetControllerConsole::getTargetDescriptor() {
|
||||
return this->triggerTargetControllerEventAndWaitForResponse(
|
||||
std::make_shared<ExtractTargetDescriptor>()
|
||||
return this->commandManager.sendCommandAndWaitForResponse(
|
||||
std::make_unique<GetTargetDescriptor>(),
|
||||
this->defaultTimeout
|
||||
)->targetDescriptor;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user