From 9684136e97ad162335c7390cb2482306e1fb17d6 Mon Sep 17 00:00:00 2001 From: Florian Schmaus <flow@cs.fau.de> Date: Mon, 16 Nov 2020 13:10:38 +0100 Subject: [PATCH] [test] Enable "stacktrace on aborts" in tests --- emper/Runtime.cpp | 18 ++++++++++++++---- tests/meson.build | 1 + 2 files changed, 15 insertions(+), 4 deletions(-) diff --git a/emper/Runtime.cpp b/emper/Runtime.cpp index 48f1a8b9..041bcc4b 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 b45b091d..2ac875c0 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', } ) -- GitLab