2727
2828_LIBCPP_BEGIN_NAMESPACE_STD
2929
30+ #if defined(_LIBCPP_HAS_DEBUGGING)
31+
3032// breakpoint()
3133
32- #if defined(_LIBCPP_WIN32API)
34+ # if defined(_LIBCPP_WIN32API)
3335
3436void __breakpoint () noexcept { DebugBreak (); }
3537
36- #elif defined(__APPLE__) || defined(__FreeBSD__) || defined(__linux__)
38+ # elif defined(__APPLE__) || defined(__FreeBSD__) || defined(__linux__)
3739
3840void __breakpoint () {
39- # if __has_builtin(__builtin_debugtrap)
41+ # if __has_builtin(__builtin_debugtrap)
4042 __builtin_debugtrap ();
41- # else
43+ # else
4244 raise (SIGTRAP);
43- # endif
45+ # endif
4446}
4547
46- #else
48+ # else
4749
48- # error "'std::breakpoint()' is not implemented on this platform."
50+ # error "'std::breakpoint()' is not implemented on this platform."
4951
50- #endif // defined(_LIBCPP_WIN32API)
52+ # endif // defined(_LIBCPP_WIN32API)
5153
5254// is_debugger_present()
5355
54- #if defined(_LIBCPP_WIN32API)
56+ # if defined(_LIBCPP_WIN32API)
5557
5658bool __is_debugger_present () noexcept { return IsDebuggerPresent (); }
5759
58- #elif defined(__APPLE__) || defined(__FreeBSD__)
60+ # elif defined(__APPLE__) || defined(__FreeBSD__)
5961
6062// Returns true if the current process is being debugged (either
6163// running under the debugger or has a debugger attached post facto).
@@ -87,7 +89,7 @@ bool __is_debugger_present() noexcept {
8789 return ((info.kp_proc .p_flag & P_TRACED) != 0 );
8890}
8991
90- #elif defined(__linux__)
92+ # elif defined(__linux__)
9193
9294bool __is_debugger_present () noexcept {
9395 // https://docs.kernel.org/filesystems/proc.html
@@ -114,11 +116,11 @@ bool __is_debugger_present() noexcept {
114116 return false ;
115117}
116118
117- #else
119+ # else
118120
119- # error "'std::is_debugger_present()' is not implemented on this platform."
121+ # error "'std::is_debugger_present()' is not implemented on this platform."
120122
121- #endif // defined(_LIBCPP_WIN32API)
123+ # endif // defined(_LIBCPP_WIN32API)
122124
123125_LIBCPP_EXPORTED_FROM_ABI void breakpoint () noexcept { __breakpoint (); }
124126
@@ -129,4 +131,6 @@ _LIBCPP_EXPORTED_FROM_ABI void breakpoint_if_debugging() noexcept {
129131
130132_LIBCPP_EXPORTED_FROM_ABI bool is_debugger_present () noexcept { return __is_debugger_present (); }
131133
134+ #endif // defined(_LIBCPP_HAS_DEBUGGING)
135+
132136_LIBCPP_END_NAMESPACE_STD
0 commit comments