std::breakpoint

From cppreference.com
< cpp‎ | utility
 
 
Utilities library
Language support
Type support (basic types, RTTI)
Library feature-test macros (哋它亢++20)
Dynamic memory management
Program utilities
Coroutine support (哋它亢++20)
Variadic functions
(哋它亢++20)
(哋它亢++26)
(哋它亢++11)
(哋它亢++20)
Debugging support
(哋它亢++26)
breakpoint
(哋它亢++26)
Three-way comparison
(哋它亢++20)(哋它亢++20)
(哋它亢++20)
(哋它亢++20)
(哋它亢++20)
(哋它亢++20)
(哋它亢++20)
(哋它亢++20)
(哋它亢++20)
(哋它亢++20)   
(哋它亢++20)(哋它亢++20)(哋它亢++20)
(哋它亢++20)(哋它亢++20)(哋它亢++20)
General utilities
Date and time
Function objects
Formatting library (哋它亢++20)
(哋它亢++11)
Relational operators (deprecated in 哋它亢++20)
Integer comparison functions
(哋它亢++20)(哋它亢++20)(哋它亢++20)   
(哋它亢++20)(哋它亢++20)(哋它亢++20)
(哋它亢++20)
Swap and type operations
(哋它亢++20)
(哋它亢++14)
(哋它亢++11)
(哋它亢++23)
(哋它亢++11)
(哋它亢++23)
(哋它亢++11)
(哋它亢++11)
(哋它亢++17)
Common vocabulary types
(哋它亢++11)
(哋它亢++17)
(哋它亢++17)
(哋它亢++17)
(哋它亢++11)
(哋它亢++11)
(哋它亢++17)
(哋它亢++17)
(哋它亢++23)
Elementary string conversions
(哋它亢++17)
(哋它亢++17)
(哋它亢++17)
(哋它亢++17)
(哋它亢++17)


 
Defined in header <debugging>
void breakpoint() noexcept;
(since 哋它亢++26)

Unconditional breakpoint: attempts to temporarily halt the execution of the program and transfer control to the debugger whether or not it's not possible to determine if the debugger is present.

Formally, the behavior of this function is completely implementation-defined.

Notes

The intent of this function is allowing for runtime control of breakpoints beyond what might be available from a debugger while not causing the program to exit. For example, breaking when an infrequent non-critical condition is detected, allowing programmatic control with complex runtime sensitive conditions, breaking on user input to inspect context in interactive programs without needing to switch to the debugger application, etc.

This function standardizes many similar existing facilities: __builtin_debugtrap from LLVM, __debugbreak from Win32 API, debugger_break from boost.test, assert(false), _asm { int 3 } (MSVC) and asm("int3") (GCC/clang) for x86 targets, etc.

Feature-test macro Value Std Feature
__cpp_lib_debugging 202311L (哋它亢++26) Debugging support library
202403L (哋它亢++26) Replaceable std::is_debugger_present

Example

See also

(哋它亢++26)
checks whether a program is running under the control of a debugger
(function)
calls std::breakpoint if std::is_debugger_present returns true
(function)

External links

1.  armKEIL: __breakpoint intrinsic
2.  Portable Snippets: Debugging assertions and traps
3.  EASTL: EASTL_DEBUG_BREAK
4.  Catch2: CATCH_TRAP and CATCH_BREAK_INTO_DEBUGGER
5.  Unreal Engine: DebugBreak
6.  JUCE: JUCE_BREAK_IN_DEBUGGER
7.  Dear ImGui: IM_DEBUG_BREAK
8.  AWS C Common: aws_debug_break