Replaced static TargetController state object access with new GetState command

This corrects a bug where the DebugServer checks if the TargetController is in
service just before it's about to suspend. The DebugServer then attempts to start
a new debug session, only for the TargetController to go into a suspended state.
A fatal error occurs and a shutdown follows. This bug is only apparent when
the user stops and starts debug sessions very quickly, with releasePostDebugSession
set to true.
This commit is contained in:
Nav
2022-08-14 17:44:52 +01:00
parent 0665ef2927
commit c4bcf71424
7 changed files with 73 additions and 10 deletions

View File

@@ -23,6 +23,7 @@ namespace Bloom::TargetController
using Commands::CommandIdType;
using Commands::Command;
using Commands::GetState;
using Commands::GetTargetDescriptor;
using Commands::GetTargetState;
using Commands::StopTargetExecution;
@@ -109,10 +110,6 @@ namespace Bloom::TargetController
this->shutdown();
}
TargetControllerState TargetControllerComponent::getState() {
return TargetControllerComponent::state;
}
void TargetControllerComponent::registerCommand(std::unique_ptr<Command> command) {
auto commandQueueLock = TargetControllerComponent::commandQueue.acquireLock();
TargetControllerComponent::commandQueue.getValue().push(std::move(command));
@@ -171,6 +168,9 @@ namespace Bloom::TargetController
TargetControllerComponent::checkUdevRules();
// Register command handlers
this->registerCommandHandler<GetState>(
std::bind(&TargetControllerComponent::handleGetState, this, std::placeholders::_1)
);
this->registerCommandHandler<GetTargetDescriptor>(
std::bind(&TargetControllerComponent::handleGetTargetDescriptor, this, std::placeholders::_1)
@@ -761,6 +761,10 @@ namespace Bloom::TargetController
}
}
std::unique_ptr<Responses::State> TargetControllerComponent::handleGetState(GetState& command) {
return std::make_unique<Responses::State>(this->state);
}
std::unique_ptr<Responses::TargetDescriptor> TargetControllerComponent::handleGetTargetDescriptor(
GetTargetDescriptor& command
) {