debug.hpp

Basic tools for use in developing high-assurance code.

This file is part of Empirical, https://github.com/devosoft/Empirical Copyright (C) 2015-2025 Michigan State University MIT Software license; see doc/LICENSE.md

Note

Status: BETA

Defines

INCLUDE_EMP_DEBUG_DEBUG_HPP_GUARD
BlockRelease(BLOCK)

BlockRelease(true) will halt compilation if NDEBUG is on and EMP_NO_BLOCK is off. It is useful to include alongside debug code that you want to remember to remove when you are done debugging; it is automatically included with the emp_debug() function below. If you want to intentionally compile in release mode, make sure to define EMP_NO_BLOCK.

emp_debug_only(...)

emp_debug_only() will print its contents as a message in debug mode and BLOCK release mode until it is removed. It’s a useful too for printing “Ping1”, “Ping2”, etc, but not forgetting to remove them.

emp_debug(...)

emp_debug(…) will print its contents in debug mode, but ignore them otherwise.

Functions

constexpr bool test_debug()
template<typename ...Ts>
void emp_debug_print(Ts&&... args)
static auto &GetDebugLineMap()

Track particular lines of code to report errors about them from elsewhere.

static bool HasDebugLine(std::string name)
static auto &GetDebugLine(std::string name)
static void AddDebugLine(std::string name, std::string file, size_t line)