* Jonathan Wakely:

> +/** Stop the program with a breakpoint or debug trap.
> + *
> + * The details of how a breakpoint is implemented are platform-specific.
> + * Some systems provide a special instruction, such as `int3` in x86.
> + * When no more appropriate mechanism is available, this will stop the
> + * program using `__builtin_trap()`. It might not be possible for the
> + * program to continue after such a breakpoint.
> + *
> + * @since C++26
> + */
> +void
> +breakpoint() noexcept;

Would it make sense to have a special function symbol for this, on which
the debugger sets the breakpoint?  We already have this for a slightly
different purpose in glibc, see _dl_debug_state.

Otherwise you'll get crashes if the debugger detection delivers a false
positive (e.g. when running under an strace-equivalent if libstdc++
cannot check the process name).

Or is_debugger_present should perhaps read a volatile bool that is
updated by the debugger as needed, and not bother with any ptrace
checks.

Thanks,
Florian

Reply via email to