]>
git.ipfire.org Git - thirdparty/gcc.git/blob - libstdc++-v3/include/debug/debug.h
1 // Debugging support implementation -*- C++ -*-
3 // Copyright (C) 2003, 2005, 2006
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 #ifndef _GLIBCXX_DEBUG_DEBUG_H
32 #define _GLIBCXX_DEBUG_DEBUG_H 1
34 /** Macros used by the implementation outside of debug wrappers to
35 * verify certain properties. The __glibcxx_requires_xxx macros are
36 * merely wrappers around the __glibcxx_check_xxx wrappers when we
37 * are compiling with debug mode, but disappear when we are in
38 * release mode so that there is no checking performed in, e.g., the
39 * standard library algorithms.
44 namespace __gnu_debug_def
{ }
45 namespace __gnu_debug
{ using namespace __gnu_debug_def
; }
46 namespace debug
= __gnu_debug
;
51 namespace __gnu_debug
{ };
52 namespace debug
= __gnu_debug
;
57 using namespace std::debug
;
58 using namespace __gnu_cxx::debug
;
65 # include <debug/macros.h>
71 // Avoid the use of assert, because we're trying to keep the <cassert>
72 // include out of the mix.
74 __replacement_assert(const char* __file
, int __line
, const char* __function
,
75 const char* __condition
)
77 std::printf("%s:%d: %s: Assertion '%s' failed.\n", __file
, __line
,
78 __function
, __condition
);
81 } // namespace __gnu_debug
84 #define _GLIBCXX_DEBUG_ASSERT(_Condition) \
87 std::__gnu_debug::__replacement_assert(__FILE__, __LINE__, \
88 __PRETTY_FUNCTION__, \
92 # ifdef _GLIBCXX_DEBUG_PEDANTIC
93 # define _GLIBCXX_DEBUG_PEDASSERT(_Condition) _GLIBCXX_DEBUG_ASSERT(_Condition)
95 # define _GLIBCXX_DEBUG_PEDASSERT(_Condition)
98 # define __glibcxx_requires_cond(_Cond,_Msg) _GLIBCXX_DEBUG_VERIFY(_Cond,_Msg)
99 # define __glibcxx_requires_valid_range(_First,_Last) \
100 __glibcxx_check_valid_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_partitioned(_First,_Last,_Value) \
106 __glibcxx_check_partitioned(_First,_Last,_Value)
107 # define __glibcxx_requires_partitioned_pred(_First,_Last,_Value,_Pred) \
108 __glibcxx_check_partitioned_pred(_First,_Last,_Value,_Pred)
109 # define __glibcxx_requires_heap(_First,_Last) \
110 __glibcxx_check_heap(_First,_Last)
111 # define __glibcxx_requires_heap_pred(_First,_Last,_Pred) \
112 __glibcxx_check_heap_pred(_First,_Last,_Pred)
113 # define __glibcxx_requires_nonempty() __glibcxx_check_nonempty()
114 # define __glibcxx_requires_string(_String) __glibcxx_check_string(_String)
115 # define __glibcxx_requires_string_len(_String,_Len) \
116 __glibcxx_check_string_len(_String,_Len)
117 # define __glibcxx_requires_subscript(_N) __glibcxx_check_subscript(_N)
119 # include <debug/functions.h>
120 # include <debug/formatter.h>
122 # define _GLIBCXX_DEBUG_ASSERT(_Condition)
123 # define _GLIBCXX_DEBUG_PEDASSERT(_Condition)
124 # define __glibcxx_requires_cond(_Cond,_Msg)
125 # define __glibcxx_requires_valid_range(_First,_Last)
126 # define __glibcxx_requires_sorted(_First,_Last)
127 # define __glibcxx_requires_sorted_pred(_First,_Last,_Pred)
128 # define __glibcxx_requires_partitioned(_First,_Last,_Value)
129 # define __glibcxx_requires_partitioned_pred(_First,_Last,_Value,_Pred)
130 # define __glibcxx_requires_heap(_First,_Last)
131 # define __glibcxx_requires_heap_pred(_First,_Last,_Pred)
132 # define __glibcxx_requires_nonempty()
133 # define __glibcxx_requires_string(_String)
134 # define __glibcxx_requires_string_len(_String,_Len)
135 # define __glibcxx_requires_subscript(_N)