22 General utilities library [utilities]

22.16 Debugging [debugging]

22.16.1 General [debugging.general]

Subclause [debugging] describes functionality to introspect and interact with the execution of the program.
[Note 1: 
The facilities provided by the debugging functionality interact with a program that could be tracing the execution of a C++ program, such as a debugger.
— end note]

22.16.2 Header <debugging> synopsis [debugging.syn]

// all freestanding namespace std { // [debugging.utility], utility void breakpoint() noexcept; void breakpoint_if_debugging() noexcept; bool is_debugger_present() noexcept; }

22.16.3 Utility [debugging.utility]

void breakpoint() noexcept;
The semantics of this function are implementation-defined.
[Note 1: 
When invoked, the execution of the program temporarily halts and execution is handed to the debugger until such a time as: The program is terminated by the debugger, or the debugger resumes execution of the program as if the function was not invoked.
— end note]
void breakpoint_if_debugging() noexcept;
Effects: Equivalent to: if (is_debugger_present()) breakpoint();
bool is_debugger_present() noexcept;
Replaceable: A C++ program may define a function with this function signature, and thereby displace the default version defined by the C++ standard library.
Required behavior: This function has no preconditions.
Default behavior: implementation-defined.
[Note 2: 
When tracing the execution of a program with a debugger, an implementation returns true.
An implementation performs an immediate query, as needed, to determine if the program is traced by a debugger.
On Windows or equivalent systems, this can be achieved by calling the ​::​IsDebuggerPresent() Win32 function.
On POSIX, this can be achieved by checking for a tracer parent process, with best effort determination that such a tracer parent process is a debugger.
— end note]