diff --git a/configure.ac b/configure.ac index c0bf072d..4baea960 100644 --- a/configure.ac +++ b/configure.ac @@ -28,6 +28,16 @@ AC_CHECK_LIB([pthread], [pthread_create]) # Program checks AC_CHECK_PROGS(TAR, tar) +# Enable/Disable debug mode +AC_ARG_ENABLE( + [debug], + [AS_HELP_STRING([--enable-debug], [Enable debug mode (disabled by default)])] +) +AS_IF( + [test "x$enable_debug" == "xyes"], + [AC_DEFINE(DEBUG_MODE, 1, [Debug enabled])] +) + # Enable/disable options AC_ARG_ENABLE( diff --git a/scripts/github_actions/build_ci.bash b/scripts/github_actions/build_ci.bash index 5a688ecd..38f5162b 100755 --- a/scripts/github_actions/build_ci.bash +++ b/scripts/github_actions/build_ci.bash @@ -17,7 +17,7 @@ sudo ln -s /usr/share/docutils/scripts/python3/rst2man /usr/bin/rst2man.py # Build Swupd autoreconf --verbose --warnings=none --install --force -./configure CFLAGS="$CFLAGS -fsanitize=address -Werror" --prefix=/usr --with-fallback-capaths="$PWD"/swupd_test_certificates --with-systemdsystemunitdir=/usr/lib/systemd/system --with-config-file-path="$PWD"/testconfig +./configure CFLAGS="$CFLAGS -fsanitize=address -Werror" --prefix=/usr --with-fallback-capaths="$PWD"/swupd_test_certificates --with-systemdsystemunitdir=/usr/lib/systemd/system --with-config-file-path="$PWD"/testconfig --enable-debug make -j$CORES # Needed to initialize the host for auto-update. Without these steps auto-update diff --git a/src/lib/macros.h b/src/lib/macros.h index 6efbe719..71cd2f15 100644 --- a/src/lib/macros.h +++ b/src/lib/macros.h @@ -18,4 +18,14 @@ /** @brief Return the max between 2 values. */ #define MAX(_a, _b) ((_a) > (_b) ? (_a) : (_b)) +#ifdef DEBUG_MODE +#define UNEXPECTED() abort() +#else +/** + * @brief To be used in all checks where we assume swupd should never get in to. + * This macro aborts execution only when DEBUG_MODE is used. + */ +#define UNEXPECTED() +#endif + #endif