- Document number:
-
ISO/IEC/JTC1/SC22/WG21/P2810R4
- Date:
-
2024-03-20
- Audience:
-
LEWG
- Project:
-
ISO/IEC JTC1/SC22/WG21 14882: Programming Language — C++
- Reply-to:
-
René Ferdinand Rivera Morell - grafikrobot at gmail dot com
Ben Craig - ben dot craig at gmail dot com
1. Abstract
This proposes to add std::is_debugger_present
, proposed in P2546
[1],
to the set of replacement functions to allow users the flexibility to control
the result of the function when otherwise it would not be possible to determine
the platform specific result.
2. Revision History
3. Motivation
The debugging support proposed in P2546
[1] defines its functions as available in
both hosted and freestanding realms. In it the std::is_debugger_present
function poses some challenges for embedded platforms where determining the
circumstances of debuggers in a freestanding environment is most times
impossible. Hence it is reasonable to allow the user to control what the
function returns by some means. While some options are possible, like
environment variables, platform configuration files, alternate runtime
implementations, they are not ideal. As even those options may not be
implementable for the platform. It is also ideal to not remove the function
from freestanding as that will complicate the use of the functions with macro
checks and alternative implementations. Placing the C++ ecosystem in yet more
reliance on the preprocessor.
The option we propose is to allow users to replace the function in their programs, i.e. a replaceable function. This has the benefits of giving users the ability to overcome any deficiencies in the default platform implementation and to have fine control over the result even on hosted platforms. Possible user implementations could:
-
Wire it to return
true
in special verifying builds of their application. -
Wire it to return
true
from external input like: a key press or other external mechanical signal, a software signal as might be caught by a process signal handler, and so on.
5. Polls
5.1. SG15: P2810R0 (2023-06-16)
Poll: Forward P2810R0 is_debugger_present is_replaceable to LEWG.
Outcome: Unanimous Consent
5.2. LEWG: P2810R1 (2023-09-19)
Poll: We should mandate a replaced is_debugger_present
implementation to
have no preconditions.
Outcome: Unanimous Consent
Poll: Send "P2810R1: is_debugger_present is_replaceable" to LWG for C++26, to be confirmed by electronic poll.
SF | F | N | A | SA |
---|---|---|---|---|
5 |
6 |
1 |
0 |
1 |
Attendance: 18
Number of Authors: 2
Author Position: 2 SF
Outcome: Consensus in favor
Strongly Against: Lack of implementation experience (Walter Brown).
6. Wording
Wording is relative to P2546R5. [1]
6.1. Feature Test Macro
In [version.syn] change date on adoption:
#define __cpp_lib_debugging YYYYMML // freestanding, also in <debugging>
6.2. Library
Insert the following paragraph between [replacement.functions] par. 2 and par. 3.
A C++ program may provide the definition of the following function signature
declared in header <debugging>
([debugging.syn]):
bool std::is_debugger_present() noexcept
Change wording of definition of is_debugger_present
in [debugging.utility] as:
bool is_debugger_present() noexcept;
The semantics of this function are implementation-defined.
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.