libstdc++
debug.h
Go to the documentation of this file.
1 // Debugging support implementation -*- C++ -*-
2 
3 // Copyright (C) 2003-2014 Free Software Foundation, Inc.
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, or (at your option)
9 // any later version.
10 
11 // This library is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 // GNU General Public License for more details.
15 
16 // Under Section 7 of GPL version 3, you are granted additional
17 // permissions described in the GCC Runtime Library Exception, version
18 // 3.1, as published by the Free Software Foundation.
19 
20 // You should have received a copy of the GNU General Public License and
21 // a copy of the GCC Runtime Library Exception along with this program;
22 // see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
23 // <http://www.gnu.org/licenses/>.
24 
25 /** @file debug/debug.h
26  * This file is a GNU debug extension to the Standard C++ Library.
27  */
28 
29 #ifndef _GLIBCXX_DEBUG_MACRO_SWITCH_H
30 #define _GLIBCXX_DEBUG_MACRO_SWITCH_H 1
31 
32 /** Macros and namespaces used by the implementation outside of debug
33  * wrappers to verify certain properties. The __glibcxx_requires_xxx
34  * macros are merely wrappers around the __glibcxx_check_xxx wrappers
35  * when we are compiling with debug mode, but disappear when we are
36  * in release mode so that there is no checking performed in, e.g.,
37  * the standard library algorithms.
38 */
39 
40 // Debug mode namespaces.
41 
42 /**
43  * @namespace std::__debug
44  * @brief GNU debug code, replaces standard behavior with debug behavior.
45  */
46 namespace std
47 {
48  namespace __debug { }
49 }
50 
51 /** @namespace __gnu_debug
52  * @brief GNU debug classes for public use.
53 */
54 namespace __gnu_debug
55 {
56  using namespace std::__debug;
57 }
58 
59 #ifndef _GLIBCXX_DEBUG
60 
61 # define _GLIBCXX_DEBUG_ASSERT(_Condition)
62 # define _GLIBCXX_DEBUG_PEDASSERT(_Condition)
63 # define _GLIBCXX_DEBUG_ONLY(_Statement) ;
64 # define __glibcxx_requires_cond(_Cond,_Msg)
65 # define __glibcxx_requires_valid_range(_First,_Last)
66 # define __glibcxx_requires_non_empty_range(_First,_Last)
67 # define __glibcxx_requires_sorted(_First,_Last)
68 # define __glibcxx_requires_sorted_pred(_First,_Last,_Pred)
69 # define __glibcxx_requires_sorted_set(_First1,_Last1,_First2)
70 # define __glibcxx_requires_sorted_set_pred(_First1,_Last1,_First2,_Pred)
71 # define __glibcxx_requires_partitioned_lower(_First,_Last,_Value)
72 # define __glibcxx_requires_partitioned_upper(_First,_Last,_Value)
73 # define __glibcxx_requires_partitioned_lower_pred(_First,_Last,_Value,_Pred)
74 # define __glibcxx_requires_partitioned_upper_pred(_First,_Last,_Value,_Pred)
75 # define __glibcxx_requires_heap(_First,_Last)
76 # define __glibcxx_requires_heap_pred(_First,_Last,_Pred)
77 # define __glibcxx_requires_nonempty()
78 # define __glibcxx_requires_string(_String)
79 # define __glibcxx_requires_string_len(_String,_Len)
80 # define __glibcxx_requires_subscript(_N)
81 
82 #else
83 
84 # include <debug/macros.h>
85 
86 #define _GLIBCXX_DEBUG_ASSERT(_Condition) __glibcxx_assert(_Condition)
87 
88 #ifdef _GLIBCXX_DEBUG_PEDANTIC
89 # define _GLIBCXX_DEBUG_PEDASSERT(_Condition) _GLIBCXX_DEBUG_ASSERT(_Condition)
90 #else
91 # define _GLIBCXX_DEBUG_PEDASSERT(_Condition)
92 #endif
93 
94 # define _GLIBCXX_DEBUG_ONLY(_Statement) _Statement
95 
96 # define __glibcxx_requires_cond(_Cond,_Msg) _GLIBCXX_DEBUG_VERIFY(_Cond,_Msg)
97 # define __glibcxx_requires_valid_range(_First,_Last) \
98  __glibcxx_check_valid_range(_First,_Last)
99 # define __glibcxx_requires_non_empty_range(_First,_Last) \
100  __glibcxx_check_non_empty_range(_First,_Last)
101 # define __glibcxx_requires_sorted(_First,_Last) \
102  __glibcxx_check_sorted(_First,_Last)
103 # define __glibcxx_requires_sorted_pred(_First,_Last,_Pred) \
104  __glibcxx_check_sorted_pred(_First,_Last,_Pred)
105 # define __glibcxx_requires_sorted_set(_First1,_Last1,_First2) \
106  __glibcxx_check_sorted_set(_First1,_Last1,_First2)
107 # define __glibcxx_requires_sorted_set_pred(_First1,_Last1,_First2,_Pred) \
108  __glibcxx_check_sorted_set_pred(_First1,_Last1,_First2,_Pred)
109 # define __glibcxx_requires_partitioned_lower(_First,_Last,_Value) \
110  __glibcxx_check_partitioned_lower(_First,_Last,_Value)
111 # define __glibcxx_requires_partitioned_upper(_First,_Last,_Value) \
112  __glibcxx_check_partitioned_upper(_First,_Last,_Value)
113 # define __glibcxx_requires_partitioned_lower_pred(_First,_Last,_Value,_Pred) \
114  __glibcxx_check_partitioned_lower_pred(_First,_Last,_Value,_Pred)
115 # define __glibcxx_requires_partitioned_upper_pred(_First,_Last,_Value,_Pred) \
116  __glibcxx_check_partitioned_upper_pred(_First,_Last,_Value,_Pred)
117 # define __glibcxx_requires_heap(_First,_Last) \
118  __glibcxx_check_heap(_First,_Last)
119 # define __glibcxx_requires_heap_pred(_First,_Last,_Pred) \
120  __glibcxx_check_heap_pred(_First,_Last,_Pred)
121 # define __glibcxx_requires_nonempty() __glibcxx_check_nonempty()
122 # define __glibcxx_requires_string(_String) __glibcxx_check_string(_String)
123 # define __glibcxx_requires_string_len(_String,_Len) \
124  __glibcxx_check_string_len(_String,_Len)
125 # define __glibcxx_requires_subscript(_N) __glibcxx_check_subscript(_N)
126 
127 # include <debug/functions.h>
128 
129 #endif
130 
131 #endif // _GLIBCXX_DEBUG_MACRO_SWITCH_H