Files
cppdraft_translate/cppdraft/debugging/utility.md
2025-10-25 03:02:53 +03:00

83 lines
2.6 KiB
Markdown
Raw Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

[debugging.utility]
# 19 Diagnostics library [[diagnostics]](./#diagnostics)
## 19.7 Debugging [[debugging]](debugging#utility)
### 19.7.3 Utility [debugging.utility]
[🔗](#lib:breakpoint)
`void breakpoint() noexcept;
`
[1](#1)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/diagnostics.tex#L2444)
The semantics of this function are implementation-defined[.](#1.sentence-1)
[*Note [1](#note-1)*:
It is intended that, when invoked with a debugger present, the execution of the
program temporarily halts and execution is handed to the debugger until the
program is either terminated by the debugger or the debugger resumes execution
of the program as if the function was not invoked[.](#1.sentence-2)
In particular, there is no
intent for a call to this function to accomodate resumption of the program in a
different manner[.](#1.sentence-3)
If there is no debugger present, execution of the program can
end abnormally[.](#1.sentence-4)
— *end note*]
[🔗](#lib:breakpoint_if_debugging)
`void breakpoint_if_debugging() noexcept;
`
[2](#2)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/diagnostics.tex#L2466)
*Effects*: Equivalent to:if (is_debugger_present()) breakpoint();
[🔗](#lib:is_debugger_present)
`bool is_debugger_present() noexcept;
`
[3](#3)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/diagnostics.tex#L2481)
*Required behavior*: This function has no preconditions[.](#3.sentence-1)
[4](#4)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/diagnostics.tex#L2485)
*Default behavior*: implementation-defined[.](#4.sentence-1)
[*Note [2](#note-2)*:
It is intended that, using an immediate (uncached) query to determine if the
program is being traced by a debugger, an implementation returns true only when tracing the execution of the program with a debugger[.](#4.sentence-2)
On Windows or
equivalent systems, this can be achieved by calling the::IsDebuggerPresent() Win32 function[.](#4.sentence-3)
For systems compatible with
ISO/IEC 23360:2021, this can be achieved by checking for a tracing process, with
a best-effort determination that such a tracing process is a debugger[.](#4.sentence-4)
— *end note*]
[5](#5)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/diagnostics.tex#L2499)
*Remarks*: This function is replaceable ([[dcl.fct.def.replace]](dcl.fct.def.replace#term.replaceable.function "9.6.5Replaceable function definitions"))[.](#5.sentence-1)