From 5cc53d7f694ec084a15a942a0842f7379ecacf22 Mon Sep 17 00:00:00 2001 From: Nav Date: Fri, 4 Oct 2024 23:46:08 +0100 Subject: [PATCH] Tidying --- src/Services/Avr8InstructionService.hpp | 2 ++ src/SignalHandler/SignalHandler.cpp | 7 ++----- src/TargetController/TargetControllerComponent.cpp | 2 +- 3 files changed, 5 insertions(+), 6 deletions(-) diff --git a/src/Services/Avr8InstructionService.hpp b/src/Services/Avr8InstructionService.hpp index 2ce66c78..1d0ee20b 100644 --- a/src/Services/Avr8InstructionService.hpp +++ b/src/Services/Avr8InstructionService.hpp @@ -40,6 +40,8 @@ namespace Services * If `instructions` does not contain the subsequent instruction, we'll just return std::nullopt for * instructions that skip the subsequent instruction. * + * TODO: Why can't we just pass in the next instruction here? Instead of passing in the entire mapping? + * * @return * The destination byte address the subject instruction may jump to, if we were able to resolve it. * Otherwise, std::nullopt. diff --git a/src/SignalHandler/SignalHandler.cpp b/src/SignalHandler/SignalHandler.cpp index 2aa80112..a1fdb2f4 100644 --- a/src/SignalHandler/SignalHandler.cpp +++ b/src/SignalHandler/SignalHandler.cpp @@ -19,7 +19,6 @@ void SignalHandler::run() { const auto& handlerIt = this->handlersBySignalNum.find(signalNumber); if (handlerIt != this->handlersBySignalNum.end()) { - // We have a registered handler for this signal. handlerIt->second(); } } @@ -37,15 +36,14 @@ void SignalHandler::startup() { this->setName("SH"); this->threadState = ThreadState::STARTING; Logger::debug("Starting SignalHandler"); + // Block all signal interrupts auto signalSet = this->getRegisteredSignalSet(); ::sigprocmask(SIG_SETMASK, &signalSet, NULL); - // Register handlers this->handlersBySignalNum.emplace(SIGINT, std::bind(&SignalHandler::triggerApplicationShutdown, this)); this->handlersBySignalNum.emplace(SIGTERM, std::bind(&SignalHandler::triggerApplicationShutdown, this)); - // It's possible that the SignalHandler has been instructed to shut down, before it could finish starting up. if (this->getThreadState() != ThreadState::SHUTDOWN_INITIATED) { this->threadState = ThreadState::READY; } @@ -54,7 +52,7 @@ void SignalHandler::startup() { ::sigset_t SignalHandler::getRegisteredSignalSet() const { auto set = ::sigset_t{}; if (::sigfillset(&set) == -1) { - throw Exceptions::Exception("::sigfillset() failed - error number: " + std::to_string(errno)); + throw Exceptions::Exception{"::sigfillset() failed - error number: " + std::to_string(errno)}; } return set; @@ -65,7 +63,6 @@ void SignalHandler::triggerApplicationShutdown() { this->shutdownSignalsReceived++; if (this->shutdownSignalsReceived > 1) { - // User has likely run out of patience Logger::warning("Aborting immediately"); std::exit(EXIT_FAILURE); } diff --git a/src/TargetController/TargetControllerComponent.cpp b/src/TargetController/TargetControllerComponent.cpp index 95742ac3..37065f62 100644 --- a/src/TargetController/TargetControllerComponent.cpp +++ b/src/TargetController/TargetControllerComponent.cpp @@ -861,7 +861,7 @@ namespace TargetController if (cacheIt == this->programMemoryCachesByAddressSpaceKey.end()) { cacheIt = this->programMemoryCachesByAddressSpaceKey.emplace( addressSpaceDescriptor.key, - TargetMemoryCache(addressSpaceDescriptor) + TargetMemoryCache{addressSpaceDescriptor} ).first; }