]>
git.ipfire.org Git - thirdparty/gcc.git/blob - libstdc++-v3/include/debug/debug.h
1 // Debugging support implementation -*- C++ -*-
3 // Copyright (C) 2003, 2004, 2005, 2006, 2007, 2008
4 // Free Software Foundation, Inc.
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)
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.
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,
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.
31 /** @file debug/debug.h
32 * This file is a GNU debug extension to the Standard C++ Library.
35 #ifndef _GLIBCXX_DEBUG_MACRO_SWITCH_H
36 #define _GLIBCXX_DEBUG_MACRO_SWITCH_H 1
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.
46 // Debug mode namespaces.
54 using namespace std::__debug
;
57 #ifndef _GLIBCXX_DEBUG
59 # define _GLIBCXX_DEBUG_ASSERT(_Condition)
60 # define _GLIBCXX_DEBUG_PEDASSERT(_Condition)
61 # define _GLIBCXX_DEBUG_ONLY(_Statement) ;
62 # define __glibcxx_requires_cond(_Cond,_Msg)
63 # define __glibcxx_requires_valid_range(_First,_Last)
64 # define __glibcxx_requires_sorted(_First,_Last)
65 # define __glibcxx_requires_sorted_pred(_First,_Last,_Pred)
66 # define __glibcxx_requires_sorted_set(_First1,_Last1,_First2)
67 # define __glibcxx_requires_sorted_set_pred(_First1,_Last1,_First2,_Pred)
68 # define __glibcxx_requires_partitioned_lower(_First,_Last,_Value)
69 # define __glibcxx_requires_partitioned_upper(_First,_Last,_Value)
70 # define __glibcxx_requires_partitioned_lower_pred(_First,_Last,_Value,_Pred)
71 # define __glibcxx_requires_partitioned_upper_pred(_First,_Last,_Value,_Pred)
72 # define __glibcxx_requires_heap(_First,_Last)
73 # define __glibcxx_requires_heap_pred(_First,_Last,_Pred)
74 # define __glibcxx_requires_nonempty()
75 # define __glibcxx_requires_string(_String)
76 # define __glibcxx_requires_string_len(_String,_Len)
77 # define __glibcxx_requires_subscript(_N)
82 # include <debug/macros.h>
88 // Avoid the use of assert, because we're trying to keep the <cassert>
89 // include out of the mix.
91 __replacement_assert(const char* __file
, int __line
,
92 const char* __function
, const char* __condition
)
94 printf("%s:%d: %s: Assertion '%s' failed.\n", __file
, __line
,
95 __function
, __condition
);
98 } // namespace __debug
101 #define _GLIBCXX_DEBUG_ASSERT(_Condition) \
104 if (! (_Condition)) \
105 std::__debug::__replacement_assert(__FILE__, __LINE__, \
106 __PRETTY_FUNCTION__, #_Condition); \
109 #ifdef _GLIBCXX_DEBUG_PEDANTIC
110 # define _GLIBCXX_DEBUG_PEDASSERT(_Condition) _GLIBCXX_DEBUG_ASSERT(_Condition)
112 # define _GLIBCXX_DEBUG_PEDASSERT(_Condition)
115 # define _GLIBCXX_DEBUG_ONLY(_Statement) _Statement
117 # define __glibcxx_requires_cond(_Cond,_Msg) _GLIBCXX_DEBUG_VERIFY(_Cond,_Msg)
118 # define __glibcxx_requires_valid_range(_First,_Last) \
119 __glibcxx_check_valid_range(_First,_Last)
120 # define __glibcxx_requires_sorted(_First,_Last) \
121 __glibcxx_check_sorted(_First,_Last)
122 # define __glibcxx_requires_sorted_pred(_First,_Last,_Pred) \
123 __glibcxx_check_sorted_pred(_First,_Last,_Pred)
124 # define __glibcxx_requires_sorted_set(_First1,_Last1,_First2) \
125 __glibcxx_check_sorted_set(_First1,_Last1,_First2)
126 # define __glibcxx_requires_sorted_set_pred(_First1,_Last1,_First2,_Pred) \
127 __glibcxx_check_sorted_set_pred(_First1,_Last1,_First2,_Pred)
128 # define __glibcxx_requires_partitioned_lower(_First,_Last,_Value) \
129 __glibcxx_check_partitioned_lower(_First,_Last,_Value)
130 # define __glibcxx_requires_partitioned_upper(_First,_Last,_Value) \
131 __glibcxx_check_partitioned_upper(_First,_Last,_Value)
132 # define __glibcxx_requires_partitioned_lower_pred(_First,_Last,_Value,_Pred) \
133 __glibcxx_check_partitioned_lower_pred(_First,_Last,_Value,_Pred)
134 # define __glibcxx_requires_partitioned_upper_pred(_First,_Last,_Value,_Pred) \
135 __glibcxx_check_partitioned_upper_pred(_First,_Last,_Value,_Pred)
136 # define __glibcxx_requires_heap(_First,_Last) \
137 __glibcxx_check_heap(_First,_Last)
138 # define __glibcxx_requires_heap_pred(_First,_Last,_Pred) \
139 __glibcxx_check_heap_pred(_First,_Last,_Pred)
140 # define __glibcxx_requires_nonempty() __glibcxx_check_nonempty()
141 # define __glibcxx_requires_string(_String) __glibcxx_check_string(_String)
142 # define __glibcxx_requires_string_len(_String,_Len) \
143 __glibcxx_check_string_len(_String,_Len)
144 # define __glibcxx_requires_subscript(_N) __glibcxx_check_subscript(_N)
146 # include <debug/functions.h>
147 # include <debug/formatter.h>
151 #endif // _GLIBCXX_DEBUG_MACRO_SWITCH_H