libstdc++: debugging Source File

libstdc++

debugging
Go to the documentation of this file.
1// Debugging support -*- C++ -*-
2
3// Copyright The GNU Toolchain Authors.
4//
5// This file is part of the GNU ISO C++ Library. This library is free
6// software; you can redistribute it and/or modify it under the
7// terms of the GNU General Public License as published by the
8// Free Software Foundation; either version 3.
9
10// This library is distributed in the hope that it will be useful,
11// but WITHOUT ANY WARRANTY; without even the implied warranty of
12// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13// GNU General Public License for more details.
14
15// Under Section 7 of GPL version 3, you are granted additional
16// permissions described in the GCC Runtime Library Exception, version
17// 3.1, as published by the Free Software Foundation.
18
19// You should have received a copy of the GNU General Public License and
20// a copy of the GCC Runtime Library Exception along with this program;
21// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
22// <http://www.gnu.org/licenses/>.
23
24/** @file include/debugging
25 * This is a Standard C++ Library header.
26 */
27
28#ifndef _GLIBCXX_DEBUGGING
29#define _GLIBCXX_DEBUGGING 1
30
31#define __glibcxx_want_debugging
32#include <bits/version.h>
33
34#if __cpp_lib_debugging // C++ >= 26
35namespace std _GLIBCXX_VISIBILITY(default)
36{
37// N.B. _GLIBCXX_BEGIN_NAMESPACE_VERSION is not used here.
38
39/** Try to determine if the program is running under control of a debugger.
40 *
41 * On GNU/Linux systems this function will only return true if the program
42 * is being traced by another program which is known to be a debugger.
43 * This is determined by checking the command name of the tracing program
44 * against a list of known debuggers, such as "gdb".
45 *
46 * On other POSIX-based systems, this function will return true if the
47 * program is being traced by any other process, which means it can return
48 * true for non-debugger utilities that use the ptrace system call.
49 *
50 * @since C++26
51 */
52bool
53is_debugger_present() noexcept;
54
55/** Stop the program with a breakpoint or debug trap.
56 *
57 * The details of how a breakpoint is implemented are platform-specific.
58 * Some systems provide a special instruction, such as `int3` in x86.
59 * When no more appropriate mechanism is available, this will stop the
60 * program using `__builtin_trap()`. It might not be possible for the
61 * program to continue after such a breakpoint.
62 *
63 * @since C++26
64 */
65void
66breakpoint() noexcept;
67
68/** Stop the program if it is running under control of a debugger.
69 *
70 * @since C++26
71 */
72void
73breakpoint_if_debugging() noexcept;
74
75} // namespace std
76#endif
77#endif // _GLIBCXX_DEBUGGING
version.h
std
ISO C++ entities toplevel namespace is std.