]>
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
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 namespace __debug
{ };
59 using namespace std::__debug
;
60 using namespace __gnu_cxx::__debug
;
63 #ifndef _GLIBCXX_DEBUG
65 # define _GLIBCXX_DEBUG_ASSERT(_Condition)
66 # define _GLIBCXX_DEBUG_PEDASSERT(_Condition)
67 # define _GLIBCXX_DEBUG_ONLY(_Statement) ;
68 # define __glibcxx_requires_cond(_Cond,_Msg)
69 # define __glibcxx_requires_valid_range(_First,_Last)
70 # define __glibcxx_requires_sorted(_First,_Last)
71 # define __glibcxx_requires_sorted_pred(_First,_Last,_Pred)
72 # define __glibcxx_requires_partitioned(_First,_Last,_Value)
73 # define __glibcxx_requires_partitioned_pred(_First,_Last,_Value,_Pred)
74 # define __glibcxx_requires_heap(_First,_Last)
75 # define __glibcxx_requires_heap_pred(_First,_Last,_Pred)
76 # define __glibcxx_requires_nonempty()
77 # define __glibcxx_requires_string(_String)
78 # define __glibcxx_requires_string_len(_String,_Len)
79 # define __glibcxx_requires_subscript(_N)
84 # include <debug/macros.h>
90 // Avoid the use of assert, because we're trying to keep the <cassert>
91 // include out of the mix.
93 __replacement_assert(const char* __file
, int __line
,
94 const char* __function
, const char* __condition
)
96 printf("%s:%d: %s: Assertion '%s' failed.\n", __file
, __line
,
97 __function
, __condition
);
100 } // namespace __debug
103 #define _GLIBCXX_DEBUG_ASSERT(_Condition) \
106 if (! (_Condition)) \
107 std::__debug::__replacement_assert(__FILE__, __LINE__, \
108 __PRETTY_FUNCTION__, #_Condition); \
111 #ifdef _GLIBCXX_DEBUG_PEDANTIC
112 # define _GLIBCXX_DEBUG_PEDASSERT(_Condition) _GLIBCXX_DEBUG_ASSERT(_Condition)
114 # define _GLIBCXX_DEBUG_PEDASSERT(_Condition)
116 # define _GLIBCXX_DEBUG_ONLY(_Statement) _Statement
118 # define __glibcxx_requires_cond(_Cond,_Msg) _GLIBCXX_DEBUG_VERIFY(_Cond,_Msg)
119 # define __glibcxx_requires_valid_range(_First,_Last) \
120 __glibcxx_check_valid_range(_First,_Last)
121 # define __glibcxx_requires_sorted(_First,_Last) \
122 __glibcxx_check_sorted(_First,_Last)
123 # define __glibcxx_requires_sorted_pred(_First,_Last,_Pred) \
124 __glibcxx_check_sorted_pred(_First,_Last,_Pred)
125 # define __glibcxx_requires_partitioned(_First,_Last,_Value) \
126 __glibcxx_check_partitioned(_First,_Last,_Value)
127 # define __glibcxx_requires_partitioned_pred(_First,_Last,_Value,_Pred) \
128 __glibcxx_check_partitioned_pred(_First,_Last,_Value,_Pred)
129 # define __glibcxx_requires_heap(_First,_Last) \
130 __glibcxx_check_heap(_First,_Last)
131 # define __glibcxx_requires_heap_pred(_First,_Last,_Pred) \
132 __glibcxx_check_heap_pred(_First,_Last,_Pred)
133 # define __glibcxx_requires_nonempty() __glibcxx_check_nonempty()
134 # define __glibcxx_requires_string(_String) __glibcxx_check_string(_String)
135 # define __glibcxx_requires_string_len(_String,_Len) \
136 __glibcxx_check_string_len(_String,_Len)
137 # define __glibcxx_requires_subscript(_N) __glibcxx_check_subscript(_N)
139 # include <debug/functions.h>
140 # include <debug/formatter.h>
144 #endif // _GLIBCXX_DEBUG_MACRO_SWITCH_H