This commit is contained in:
Nav
2024-10-04 23:46:08 +01:00
parent d906f2f426
commit 5cc53d7f69
3 changed files with 5 additions and 6 deletions

View File

@@ -40,6 +40,8 @@ namespace Services
* If `instructions` does not contain the subsequent instruction, we'll just return std::nullopt for * If `instructions` does not contain the subsequent instruction, we'll just return std::nullopt for
* instructions that skip the subsequent instruction. * 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 * @return
* The destination byte address the subject instruction may jump to, if we were able to resolve it. * The destination byte address the subject instruction may jump to, if we were able to resolve it.
* Otherwise, std::nullopt. * Otherwise, std::nullopt.

View File

@@ -19,7 +19,6 @@ void SignalHandler::run() {
const auto& handlerIt = this->handlersBySignalNum.find(signalNumber); const auto& handlerIt = this->handlersBySignalNum.find(signalNumber);
if (handlerIt != this->handlersBySignalNum.end()) { if (handlerIt != this->handlersBySignalNum.end()) {
// We have a registered handler for this signal.
handlerIt->second(); handlerIt->second();
} }
} }
@@ -37,15 +36,14 @@ void SignalHandler::startup() {
this->setName("SH"); this->setName("SH");
this->threadState = ThreadState::STARTING; this->threadState = ThreadState::STARTING;
Logger::debug("Starting SignalHandler"); Logger::debug("Starting SignalHandler");
// Block all signal interrupts // Block all signal interrupts
auto signalSet = this->getRegisteredSignalSet(); auto signalSet = this->getRegisteredSignalSet();
::sigprocmask(SIG_SETMASK, &signalSet, NULL); ::sigprocmask(SIG_SETMASK, &signalSet, NULL);
// Register handlers
this->handlersBySignalNum.emplace(SIGINT, std::bind(&SignalHandler::triggerApplicationShutdown, this)); this->handlersBySignalNum.emplace(SIGINT, std::bind(&SignalHandler::triggerApplicationShutdown, this));
this->handlersBySignalNum.emplace(SIGTERM, 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) { if (this->getThreadState() != ThreadState::SHUTDOWN_INITIATED) {
this->threadState = ThreadState::READY; this->threadState = ThreadState::READY;
} }
@@ -54,7 +52,7 @@ void SignalHandler::startup() {
::sigset_t SignalHandler::getRegisteredSignalSet() const { ::sigset_t SignalHandler::getRegisteredSignalSet() const {
auto set = ::sigset_t{}; auto set = ::sigset_t{};
if (::sigfillset(&set) == -1) { 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; return set;
@@ -65,7 +63,6 @@ void SignalHandler::triggerApplicationShutdown() {
this->shutdownSignalsReceived++; this->shutdownSignalsReceived++;
if (this->shutdownSignalsReceived > 1) { if (this->shutdownSignalsReceived > 1) {
// User has likely run out of patience
Logger::warning("Aborting immediately"); Logger::warning("Aborting immediately");
std::exit(EXIT_FAILURE); std::exit(EXIT_FAILURE);
} }

View File

@@ -861,7 +861,7 @@ namespace TargetController
if (cacheIt == this->programMemoryCachesByAddressSpaceKey.end()) { if (cacheIt == this->programMemoryCachesByAddressSpaceKey.end()) {
cacheIt = this->programMemoryCachesByAddressSpaceKey.emplace( cacheIt = this->programMemoryCachesByAddressSpaceKey.emplace(
addressSpaceDescriptor.key, addressSpaceDescriptor.key,
TargetMemoryCache(addressSpaceDescriptor) TargetMemoryCache{addressSpaceDescriptor}
).first; ).first;
} }