TRLC Platform Library  1.0.0
Header-only C++ library for compile-time platform detection and abstraction
debug.hpp File Reference

Portable debug and assertion utilities. More...

#include <atomic>
#include <cstdlib>
#include <iostream>
#include <string>

Go to the source code of this file.

Classes

class  trlc::platform::DebugUtils
 Debug utilities class with static methods. More...
 

Namespaces

 trlc
 
 trlc::platform
 

Macros

#define TRLC_DEBUG_BUILD   1
 
#define TRLC_ASSERT(expr)
 
#define TRLC_DEBUG_ONLY(code)   code
 
#define TRLC_UNREACHABLE()   trlc::platform::DebugUtils::unreachable()
 
#define TRLC_ABORT(msg)   trlc::platform::DebugUtils::abort(msg)
 
#define TRLC_DEBUG_BREAK()   trlc::platform::DebugUtils::debugBreak()
 

Typedefs

using trlc::platform::AssertionHandler = void(*)(const char *expression, const char *file, int line, const char *function)
 Assertion handler function pointer type. More...
 

Functions

void trlc::platform::defaultAssertionHandler (const char *expression, const char *file, int line, const char *function)
 Default assertion handler implementation. More...
 
static bool trlc::platform::isDebugBuild ()
 
static bool trlc::platform::isReleaseBuild ()
 Check if the current build is a release build. More...
 
static bool trlc::platform::hasDebugInfo ()
 Check if debug information is available. More...
 

Detailed Description

Portable debug and assertion utilities.

This header provides comprehensive debug utilities including assertion handling, debug mode detection, breakpoint support, and stack trace capabilities. It offers portable implementations that work across different platforms and compilers.

Features:

  • Debug/release build detection at compile time
  • Customizable assertion handling with stack trace support
  • Platform-specific debug break implementations
  • Unreachable code marking and controlled program termination
  • Optional stack trace capture and printing
  • Thread-safe assertion handler management
  • Graceful degradation on unsupported platforms

All debug utilities are designed to be zero-overhead in release builds while providing comprehensive debugging support in development builds.

Author
TRLC Platform Team
Version
1.0.0

Definition in file debug.hpp.

Macro Definition Documentation

◆ TRLC_ABORT

#define TRLC_ABORT (   msg)    trlc::platform::DebugUtils::abort(msg)

Definition at line 605 of file debug.hpp.

◆ TRLC_ASSERT

#define TRLC_ASSERT (   expr)
Value:
((expr) ? void(0) \
#expr, __FILE__, __LINE__, __func__))
static AssertionHandler getAssertionHandler()
Get the current assertion handler.
Definition: debug.hpp:200

Definition at line 536 of file debug.hpp.

◆ TRLC_DEBUG_BREAK

#define TRLC_DEBUG_BREAK ( )    trlc::platform::DebugUtils::debugBreak()

Definition at line 637 of file debug.hpp.

◆ TRLC_DEBUG_BUILD

#define TRLC_DEBUG_BUILD   1

Definition at line 514 of file debug.hpp.

◆ TRLC_DEBUG_ONLY

#define TRLC_DEBUG_ONLY (   code)    code

Definition at line 560 of file debug.hpp.

◆ TRLC_UNREACHABLE

#define TRLC_UNREACHABLE ( )    trlc::platform::DebugUtils::unreachable()

Definition at line 588 of file debug.hpp.