]> gcc.gnu.org Git - gcc.git/blob - libstdc++-v3/include/debug/debug.h
run_doxygen: Remove html_output_dir.
[gcc.git] / libstdc++-v3 / include / debug / debug.h
1 // Debugging support implementation -*- C++ -*-
2
3 // Copyright (C) 2003, 2004, 2005, 2006, 2007, 2008
4 // Free Software Foundation, Inc.
5 //
6 // This file is part of the GNU ISO C++ Library. This library is free
7 // software; you can redistribute it and/or modify it under the
8 // terms of the GNU General Public License as published by the
9 // Free Software Foundation; either version 2, or (at your option)
10 // any later version.
11
12 // This library is distributed in the hope that it will be useful,
13 // but WITHOUT ANY WARRANTY; without even the implied warranty of
14 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 // GNU General Public License for more details.
16
17 // You should have received a copy of the GNU General Public License along
18 // with this library; see the file COPYING. If not, write to the Free
19 // Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
20 // USA.
21
22 // As a special exception, you may use this file as part of a free software
23 // library without restriction. Specifically, if other files instantiate
24 // templates or use macros or inline functions from this file, or you compile
25 // this file and link it with other files to produce an executable, this
26 // file does not by itself cause the resulting executable to be covered by
27 // the GNU General Public License. This exception does not however
28 // invalidate any other reasons why the executable file might be covered by
29 // the GNU General Public License.
30
31 /** @file debug/debug.h
32 * This file is a GNU debug extension to the Standard C++ Library.
33 */
34
35 #ifndef _GLIBCXX_DEBUG_MACRO_SWITCH_H
36 #define _GLIBCXX_DEBUG_MACRO_SWITCH_H 1
37
38 /** Macros and namespaces used by the implementation outside of debug
39 * wrappers to verify certain properties. The __glibcxx_requires_xxx
40 * macros are merely wrappers around the __glibcxx_check_xxx wrappers
41 * when we are compiling with debug mode, but disappear when we are
42 * in release mode so that there is no checking performed in, e.g.,
43 * the standard library algorithms.
44 */
45
46 // Debug mode namespaces.
47
48 /**
49 * @namespace std::__debug
50 * @brief GNU debug code, replaces standard behavior with debug behavior.
51 */
52 namespace std
53 {
54 namespace __debug { }
55 }
56
57 /** @namespace __gnu_debug
58 * @brief GNU debug classes for public use.
59 */
60 namespace __gnu_debug
61 {
62 using namespace std::__debug;
63 }
64
65 #ifndef _GLIBCXX_DEBUG
66
67 # define _GLIBCXX_DEBUG_ASSERT(_Condition)
68 # define _GLIBCXX_DEBUG_PEDASSERT(_Condition)
69 # define _GLIBCXX_DEBUG_ONLY(_Statement) ;
70 # define __glibcxx_requires_cond(_Cond,_Msg)
71 # define __glibcxx_requires_valid_range(_First,_Last)
72 # define __glibcxx_requires_sorted(_First,_Last)
73 # define __glibcxx_requires_sorted_pred(_First,_Last,_Pred)
74 # define __glibcxx_requires_sorted_set(_First1,_Last1,_First2)
75 # define __glibcxx_requires_sorted_set_pred(_First1,_Last1,_First2,_Pred)
76 # define __glibcxx_requires_partitioned_lower(_First,_Last,_Value)
77 # define __glibcxx_requires_partitioned_upper(_First,_Last,_Value)
78 # define __glibcxx_requires_partitioned_lower_pred(_First,_Last,_Value,_Pred)
79 # define __glibcxx_requires_partitioned_upper_pred(_First,_Last,_Value,_Pred)
80 # define __glibcxx_requires_heap(_First,_Last)
81 # define __glibcxx_requires_heap_pred(_First,_Last,_Pred)
82 # define __glibcxx_requires_nonempty()
83 # define __glibcxx_requires_string(_String)
84 # define __glibcxx_requires_string_len(_String,_Len)
85 # define __glibcxx_requires_subscript(_N)
86
87 #else
88
89 # include <cstdio>
90 # include <debug/macros.h>
91
92 namespace std
93 {
94 namespace __debug
95 {
96 // Avoid the use of assert, because we're trying to keep the <cassert>
97 // include out of the mix.
98 inline void
99 __replacement_assert(const char* __file, int __line,
100 const char* __function, const char* __condition)
101 {
102 printf("%s:%d: %s: Assertion '%s' failed.\n", __file, __line,
103 __function, __condition);
104 __builtin_abort();
105 }
106 } // namespace __debug
107 } // namespace std
108
109 #define _GLIBCXX_DEBUG_ASSERT(_Condition) \
110 do \
111 { \
112 if (! (_Condition)) \
113 std::__debug::__replacement_assert(__FILE__, __LINE__, \
114 __PRETTY_FUNCTION__, #_Condition); \
115 } while (false)
116
117 #ifdef _GLIBCXX_DEBUG_PEDANTIC
118 # define _GLIBCXX_DEBUG_PEDASSERT(_Condition) _GLIBCXX_DEBUG_ASSERT(_Condition)
119 #else
120 # define _GLIBCXX_DEBUG_PEDASSERT(_Condition)
121 #endif
122
123 # define _GLIBCXX_DEBUG_ONLY(_Statement) _Statement
124
125 # define __glibcxx_requires_cond(_Cond,_Msg) _GLIBCXX_DEBUG_VERIFY(_Cond,_Msg)
126 # define __glibcxx_requires_valid_range(_First,_Last) \
127 __glibcxx_check_valid_range(_First,_Last)
128 # define __glibcxx_requires_sorted(_First,_Last) \
129 __glibcxx_check_sorted(_First,_Last)
130 # define __glibcxx_requires_sorted_pred(_First,_Last,_Pred) \
131 __glibcxx_check_sorted_pred(_First,_Last,_Pred)
132 # define __glibcxx_requires_sorted_set(_First1,_Last1,_First2) \
133 __glibcxx_check_sorted_set(_First1,_Last1,_First2)
134 # define __glibcxx_requires_sorted_set_pred(_First1,_Last1,_First2,_Pred) \
135 __glibcxx_check_sorted_set_pred(_First1,_Last1,_First2,_Pred)
136 # define __glibcxx_requires_partitioned_lower(_First,_Last,_Value) \
137 __glibcxx_check_partitioned_lower(_First,_Last,_Value)
138 # define __glibcxx_requires_partitioned_upper(_First,_Last,_Value) \
139 __glibcxx_check_partitioned_upper(_First,_Last,_Value)
140 # define __glibcxx_requires_partitioned_lower_pred(_First,_Last,_Value,_Pred) \
141 __glibcxx_check_partitioned_lower_pred(_First,_Last,_Value,_Pred)
142 # define __glibcxx_requires_partitioned_upper_pred(_First,_Last,_Value,_Pred) \
143 __glibcxx_check_partitioned_upper_pred(_First,_Last,_Value,_Pred)
144 # define __glibcxx_requires_heap(_First,_Last) \
145 __glibcxx_check_heap(_First,_Last)
146 # define __glibcxx_requires_heap_pred(_First,_Last,_Pred) \
147 __glibcxx_check_heap_pred(_First,_Last,_Pred)
148 # define __glibcxx_requires_nonempty() __glibcxx_check_nonempty()
149 # define __glibcxx_requires_string(_String) __glibcxx_check_string(_String)
150 # define __glibcxx_requires_string_len(_String,_Len) \
151 __glibcxx_check_string_len(_String,_Len)
152 # define __glibcxx_requires_subscript(_N) __glibcxx_check_subscript(_N)
153
154 # include <debug/functions.h>
155 # include <debug/formatter.h>
156
157 #endif
158
159 #endif // _GLIBCXX_DEBUG_MACRO_SWITCH_H
This page took 0.04237 seconds and 5 git commands to generate.