From 06e4f306d2b3eace843bb1d6a1a8930fea7f6e88 Mon Sep 17 00:00:00 2001 From: Axel Huebl Date: Mon, 23 Sep 2024 16:37:42 -0700 Subject: [PATCH] Env Variable: `AMREX_DEBUG` Introduce control of backtrace handling and exception throwing via the environment variable `AMREX_DEBUG`. This is very handly when running CI/CD and IDE workflows to quickly debug a failing test without overwriting default init parameters. --- Docs/sphinx_documentation/source/Debugging.rst | 8 ++++---- Src/Base/AMReX.cpp | 5 ++--- 2 files changed, 6 insertions(+), 7 deletions(-) diff --git a/Docs/sphinx_documentation/source/Debugging.rst b/Docs/sphinx_documentation/source/Debugging.rst index 96cf295351..6808bc2715 100644 --- a/Docs/sphinx_documentation/source/Debugging.rst +++ b/Docs/sphinx_documentation/source/Debugging.rst @@ -100,14 +100,14 @@ The following runtime options need to be set in order to prevent AMReX from catc This default behavior can also be modified by applications, see for example `this custom application initializer `__. -The above default can also be achieve by setting the environment variable ``AMREX_DEBUG``: +Alternatively, set the environment variable ``AMREX_DEBUG`` to change the defaults in the same way: -.. highlight:: console - -:: +.. code-block: console export AMREX_DEBUG=1 +Note that input and command line arguments always have precedence over environment variables. + .. _sec:gpu:debugging: diff --git a/Src/Base/AMReX.cpp b/Src/Base/AMReX.cpp index 67c1689517..e30c81220b 100644 --- a/Src/Base/AMReX.cpp +++ b/Src/Base/AMReX.cpp @@ -66,6 +66,7 @@ #include #endif +#include #include #include #include @@ -339,7 +340,7 @@ amrex::Initialize (int& argc, char**& argv, bool build_parm_parse, bool amrex_debug = false; if (env_amrex_debug != nullptr) { std::string str_amrex_debug{env_amrex_debug}; - for(auto& c : test) { c = tolower(c); } + for(auto& c : str_amrex_debug) { c = std::tolower(c); } if (str_amrex_debug == "1" || str_amrex_debug == "on" || str_amrex_debug == "true") { amrex_debug = true; @@ -349,8 +350,6 @@ amrex::Initialize (int& argc, char**& argv, bool build_parm_parse, system::exename.clear(); // system::verbose = 0; system::regtest_reduction = false; - - system::signal_handling = !amrex_debug; system::handle_sigsegv = true; system::handle_sigterm = false;