diff --git a/.clang-tidy b/.clang-tidy index 85e06ebcdd923aa1d2cf58e592c901e027d934db..aa5e578a53b61611ad8ea619967ce466c75d79ef 100644 --- a/.clang-tidy +++ b/.clang-tidy @@ -14,6 +14,8 @@ Checks: > -readability-magic-numbers, WarningsAsErrors: > + bugprone-*, + modernize-*, clang-*, readability-*, performance-*, diff --git a/emper/Debug.hpp b/emper/Debug.hpp index ff0cc2a4fe6d87c05564aeb31e7eb4108db11b97..a3945529427c35dae75d48cb52fce6df3dc56a27 100644 --- a/emper/Debug.hpp +++ b/emper/Debug.hpp @@ -79,30 +79,22 @@ void worker_log(const std::string& prefix, const std::string& message); template <LogSubsystem logSubsystem> class Logger { private: - static constexpr LogLevel getLevelFor(LogSubsystem system) { + static constexpr auto getLevelFor(LogSubsystem system) -> LogLevel { switch (system) { case LogSubsystem::PS: - return ALL; case LogSubsystem::F: - return ALL; case LogSubsystem::C: - return ALL; case LogSubsystem::CM: - return ALL; case LogSubsystem::DISP: - return ALL; case LogSubsystem::SCHED: - return ALL; case LogSubsystem::RUNTI: - return ALL; case LogSubsystem::U_B_MPSC_Q: - return ALL; default: return ALL; } } - static constexpr char const* getTagFor(LogSubsystem system) { + static constexpr auto getTagFor(LogSubsystem system) -> char const* { switch (system) { case LogSubsystem::PS: return "PS "; diff --git a/emper/Runtime.cpp b/emper/Runtime.cpp index 48f1a8b96978f1cd8f1fcb5c5b568ebd47d1a349..041bcc4bc7c52b6f634a0ed39ae513d119aa6889 100644 --- a/emper/Runtime.cpp +++ b/emper/Runtime.cpp @@ -10,16 +10,19 @@ #include <sys/sysinfo.h> // for get_nprocs #include <cstdlib> // for rand, srand, abort -#include <memory> // for __shared_ptr_access, shared_ptr +#include <cstring> +#include <memory> // for __shared_ptr_access, shared_ptr +#include <string> // for string #include "Common.hpp" // for DIE_MSG_ERRNO, DIE, DIE_MSG #include "ContextManager.hpp" // for ContextManager #include "Debug.hpp" // for DBG, ABORT, LOGD, LOGE #include "Dispatcher.hpp" // for Dispatcher #include "Emper.hpp" -#include "Fiber.hpp" // for Fiber -#include "RuntimeStrategy.hpp" // for RuntimeStrategy -#include "RuntimeStrategyStats.hpp" // for RuntimeStrategyStats +#include "Fiber.hpp" // for Fiber +#include "RuntimeStrategy.hpp" // for RuntimeStrategy +#include "RuntimeStrategyStats.hpp" // for RuntimeStrategyStats +#include "lib/DebugUtil.hpp" #include "strategies/ws/WsStrategy.hpp" // for WsStrategy, WsStrategy::INST... #ifndef NDEBUG @@ -87,6 +90,13 @@ Runtime::Runtime(workerid_t workerCount, RuntimeStrategy& strategy, unsigned int DIE_MSG("could not register printStats() with at_exit()"); } } + + const std::string stacktraceOnAbortsEnvVar("EMPER_STACKTRACE_ON_ABORTS"); + const char* envValueEnableStacktraces = std::getenv(stacktraceOnAbortsEnvVar.c_str()); + if (envValueEnableStacktraces && !std::strcmp(envValueEnableStacktraces, "true")) { + DBG(stacktraceOnAbortsEnvVar << " set to 'true': Enabling stacktrace on abort"); + enableStacktraceOnAborts(); + } } Runtime::~Runtime() { diff --git a/tests/meson.build b/tests/meson.build index b45b091d0f0703262eaf94051cf3008930e24f5e..2ac875c0ee7d3dc4c9f4b46f8437b9a815ec26b3 100644 --- a/tests/meson.build +++ b/tests/meson.build @@ -39,6 +39,7 @@ test_env = environment( # memory will be initialized with 0x01, and that free'ed memory # will be set to 0xFE (I think). 'MALLOC_PERTURB_': '1', + 'EMPER_STACKTRACE_ON_ABORTS': 'true', } )