OpenCores
URL https://opencores.org/ocsvn/altor32/altor32/trunk

Subversion Repositories altor32

[/] [altor32/] [trunk/] [gcc-x64/] [or1knd-elf/] [or1knd-elf/] [include/] [c++/] [4.8.0/] [debug/] [macros.h] - Blame information for rev 35

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 35 ultra_embe
// Debugging support implementation -*- C++ -*-
2
 
3
// Copyright (C) 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012
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 3, 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
// Under Section 7 of GPL version 3, you are granted additional
18
// permissions described in the GCC Runtime Library Exception, version
19
// 3.1, as published by the Free Software Foundation.
20
 
21
// You should have received a copy of the GNU General Public License and
22
// a copy of the GCC Runtime Library Exception along with this program;
23
// see the files COPYING3 and COPYING.RUNTIME respectively.  If not, see
24
// <http://www.gnu.org/licenses/>.
25
 
26
/** @file debug/macros.h
27
 *  This file is a GNU debug extension to the Standard C++ Library.
28
 */
29
 
30
#ifndef _GLIBCXX_DEBUG_MACROS_H
31
#define _GLIBCXX_DEBUG_MACROS_H 1
32
 
33
/**
34
 * Macros used by the implementation to verify certain
35
 * properties. These macros may only be used directly by the debug
36
 * wrappers. Note that these are macros (instead of the more obviously
37
 * @a correct choice of making them functions) because we need line and
38
 * file information at the call site, to minimize the distance between
39
 * the user error and where the error is reported.
40
 *
41
 */
42
#define _GLIBCXX_DEBUG_VERIFY_AT(_Condition,_ErrorMessage,_File,_Line)  \
43
  do                                                                    \
44
  {                                                                     \
45
    if (! (_Condition))                                                 \
46
      __gnu_debug::_Error_formatter::_M_at(_File, _Line)                \
47
          ._ErrorMessage._M_error();                                    \
48
  } while (false)
49
 
50
#define _GLIBCXX_DEBUG_VERIFY(_Condition,_ErrorMessage)                 \
51
  _GLIBCXX_DEBUG_VERIFY_AT(_Condition,_ErrorMessage,__FILE__,__LINE__)
52
 
53
// Verify that [_First, _Last) forms a valid iterator range.
54
#define __glibcxx_check_valid_range(_First,_Last)                       \
55
_GLIBCXX_DEBUG_VERIFY(__gnu_debug::__valid_range(_First, _Last),        \
56
                      _M_message(__gnu_debug::__msg_valid_range)        \
57
                      ._M_iterator(_First, #_First)                     \
58
                      ._M_iterator(_Last, #_Last))
59
 
60
// Verify that [_First, _Last) forms a non-empty iterator range.
61
#define __glibcxx_check_non_empty_range(_First,_Last)                   \
62
_GLIBCXX_DEBUG_VERIFY(_First != _Last,                                  \
63
                      _M_message(__gnu_debug::__msg_non_empty_range)    \
64
                      ._M_iterator(_First, #_First)                     \
65
                      ._M_iterator(_Last, #_Last))
66
 
67
/** Verify that we can insert into *this with the iterator _Position.
68
 *  Insertion into a container at a specific position requires that
69
 *  the iterator be nonsingular, either dereferenceable or past-the-end,
70
 *  and that it reference the sequence we are inserting into. Note that
71
 *  this macro is only valid when the container is a_Safe_sequence and
72
 *  the iterator is a _Safe_iterator.
73
*/
74
#define __glibcxx_check_insert(_Position)                               \
75
_GLIBCXX_DEBUG_VERIFY(!_Position._M_singular(),                         \
76
                      _M_message(__gnu_debug::__msg_insert_singular) \
77
                      ._M_sequence(*this, "this")                       \
78
                      ._M_iterator(_Position, #_Position));             \
79
_GLIBCXX_DEBUG_VERIFY(_Position._M_attached_to(this),                   \
80
                      _M_message(__gnu_debug::__msg_insert_different) \
81
                      ._M_sequence(*this, "this")                       \
82
                      ._M_iterator(_Position, #_Position))
83
 
84
/** Verify that we can insert into *this after the iterator _Position.
85
 *  Insertion into a container after a specific position requires that
86
 *  the iterator be nonsingular, either dereferenceable or before-begin,
87
 *  and that it reference the sequence we are inserting into. Note that
88
 *  this macro is only valid when the container is a_Safe_sequence and
89
 *  the iterator is a _Safe_iterator.
90
*/
91
#define __glibcxx_check_insert_after(_Position)                         \
92
__glibcxx_check_insert(_Position);                                      \
93
_GLIBCXX_DEBUG_VERIFY(!_Position._M_is_end(),                           \
94
                      _M_message(__gnu_debug::__msg_insert_after_end)   \
95
                      ._M_sequence(*this, "this")                       \
96
                      ._M_iterator(_Position, #_Position))
97
 
98
/** Verify that we can insert the values in the iterator range
99
 *  [_First, _Last) into *this with the iterator _Position.  Insertion
100
 *  into a container at a specific position requires that the iterator
101
 *  be nonsingular (i.e., either dereferenceable or past-the-end),
102
 *  that it reference the sequence we are inserting into, and that the
103
 *  iterator range [_First, Last) is a valid (possibly empty)
104
 *  range. Note that this macro is only valid when the container is a
105
 *  _Safe_sequence and the iterator is a _Safe_iterator.
106
 *
107
 *  @todo We would like to be able to check for noninterference of
108
 *  _Position and the range [_First, _Last), but that can't (in
109
 *  general) be done.
110
*/
111
#define __glibcxx_check_insert_range(_Position,_First,_Last)            \
112
__glibcxx_check_valid_range(_First,_Last);                              \
113
__glibcxx_check_insert(_Position)
114
 
115
/** Verify that we can insert the values in the iterator range
116
 *  [_First, _Last) into *this after the iterator _Position.  Insertion
117
 *  into a container after a specific position requires that the iterator
118
 *  be nonsingular (i.e., either dereferenceable or past-the-end),
119
 *  that it reference the sequence we are inserting into, and that the
120
 *  iterator range [_First, Last) is a valid (possibly empty)
121
 *  range. Note that this macro is only valid when the container is a
122
 *  _Safe_sequence and the iterator is a _Safe_iterator.
123
 *
124
 *  @todo We would like to be able to check for noninterference of
125
 *  _Position and the range [_First, _Last), but that can't (in
126
 *  general) be done.
127
*/
128
#define __glibcxx_check_insert_range_after(_Position,_First,_Last)      \
129
__glibcxx_check_valid_range(_First,_Last);                              \
130
__glibcxx_check_insert_after(_Position)
131
 
132
/** Verify that we can erase the element referenced by the iterator
133
 * _Position. We can erase the element if the _Position iterator is
134
 * dereferenceable and references this sequence.
135
*/
136
#define __glibcxx_check_erase(_Position)                                \
137
_GLIBCXX_DEBUG_VERIFY(_Position._M_dereferenceable(),                   \
138
                      _M_message(__gnu_debug::__msg_erase_bad)          \
139
                      ._M_sequence(*this, "this")                       \
140
                      ._M_iterator(_Position, #_Position));             \
141
_GLIBCXX_DEBUG_VERIFY(_Position._M_attached_to(this),                   \
142
                      _M_message(__gnu_debug::__msg_erase_different)    \
143
                      ._M_sequence(*this, "this")                       \
144
                      ._M_iterator(_Position, #_Position))
145
 
146
/** Verify that we can erase the element after the iterator
147
 * _Position. We can erase the element if the _Position iterator is
148
 * before a dereferenceable one and references this sequence.
149
*/
150
#define __glibcxx_check_erase_after(_Position)                          \
151
_GLIBCXX_DEBUG_VERIFY(_Position._M_before_dereferenceable(),            \
152
                      _M_message(__gnu_debug::__msg_erase_after_bad)    \
153
                      ._M_sequence(*this, "this")                       \
154
                      ._M_iterator(_Position, #_Position));             \
155
_GLIBCXX_DEBUG_VERIFY(_Position._M_attached_to(this),                   \
156
                      _M_message(__gnu_debug::__msg_erase_different)    \
157
                      ._M_sequence(*this, "this")                       \
158
                      ._M_iterator(_Position, #_Position))
159
 
160
/** Verify that we can erase the elements in the iterator range
161
 *  [_First, _Last). We can erase the elements if [_First, _Last) is a
162
 *  valid iterator range within this sequence.
163
*/
164
#define __glibcxx_check_erase_range(_First,_Last)                       \
165
__glibcxx_check_valid_range(_First,_Last);                              \
166
_GLIBCXX_DEBUG_VERIFY(_First._M_attached_to(this),                      \
167
                      _M_message(__gnu_debug::__msg_erase_different)    \
168
                      ._M_sequence(*this, "this")                       \
169
                      ._M_iterator(_First, #_First)                     \
170
                      ._M_iterator(_Last, #_Last))
171
 
172
/** Verify that we can erase the elements in the iterator range
173
 *  (_First, _Last). We can erase the elements if (_First, _Last) is a
174
 *  valid iterator range within this sequence.
175
*/
176
#define __glibcxx_check_erase_range_after(_First,_Last)                 \
177
_GLIBCXX_DEBUG_VERIFY(_First._M_can_compare(_Last),                     \
178
                      _M_message(__gnu_debug::__msg_erase_different)    \
179
                      ._M_sequence(*this, "this")                       \
180
                      ._M_iterator(_First, #_First)                     \
181
                      ._M_iterator(_Last, #_Last));                     \
182
_GLIBCXX_DEBUG_VERIFY(_First._M_attached_to(this),                      \
183
                      _M_message(__gnu_debug::__msg_erase_different)    \
184
                      ._M_sequence(*this, "this")                       \
185
                      ._M_iterator(_First, #_First));                   \
186
_GLIBCXX_DEBUG_VERIFY(_First != _Last,                                  \
187
                      _M_message(__gnu_debug::__msg_valid_range2)       \
188
                      ._M_sequence(*this, "this")                       \
189
                      ._M_iterator(_First, #_First)                     \
190
                      ._M_iterator(_Last, #_Last));                     \
191
_GLIBCXX_DEBUG_VERIFY(_First._M_incrementable(),                        \
192
                      _M_message(__gnu_debug::__msg_valid_range2)       \
193
                      ._M_sequence(*this, "this")                       \
194
                      ._M_iterator(_First, #_First)                     \
195
                      ._M_iterator(_Last, #_Last));                     \
196
_GLIBCXX_DEBUG_VERIFY(!_Last._M_is_before_begin(),                      \
197
                      _M_message(__gnu_debug::__msg_valid_range2)       \
198
                      ._M_sequence(*this, "this")                       \
199
                      ._M_iterator(_First, #_First)                     \
200
                      ._M_iterator(_Last, #_Last))                      \
201
 
202
// Verify that the subscript _N is less than the container's size.
203
#define __glibcxx_check_subscript(_N)                                   \
204
_GLIBCXX_DEBUG_VERIFY(_N < this->size(),                                \
205
                      _M_message(__gnu_debug::__msg_subscript_oob)      \
206
                      ._M_sequence(*this, "this")                       \
207
                      ._M_integer(_N, #_N)                              \
208
                      ._M_integer(this->size(), "size"))
209
 
210
// Verify that the bucket _N is less than the container's buckets count.
211
#define __glibcxx_check_bucket_index(_N)                                \
212
_GLIBCXX_DEBUG_VERIFY(_N < this->bucket_count(),                        \
213
                      _M_message(__gnu_debug::__msg_bucket_index_oob)   \
214
                      ._M_sequence(*this, "this")                       \
215
                      ._M_integer(_N, #_N)                              \
216
                      ._M_integer(this->bucket_count(), "size"))
217
 
218
// Verify that the container is nonempty
219
#define __glibcxx_check_nonempty()                                      \
220
_GLIBCXX_DEBUG_VERIFY(! this->empty(),                                  \
221
                      _M_message(__gnu_debug::__msg_empty)              \
222
                      ._M_sequence(*this, "this"))
223
 
224
// Verify that the iterator range [_First, _Last) is sorted
225
#define __glibcxx_check_sorted(_First,_Last)                            \
226
__glibcxx_check_valid_range(_First,_Last);                              \
227
_GLIBCXX_DEBUG_VERIFY(__gnu_debug::__check_sorted(_First, _Last),       \
228
                      _M_message(__gnu_debug::__msg_unsorted)           \
229
                      ._M_iterator(_First, #_First)                     \
230
                      ._M_iterator(_Last, #_Last))
231
 
232
/** Verify that the iterator range [_First, _Last) is sorted by the
233
    predicate _Pred. */
234
#define __glibcxx_check_sorted_pred(_First,_Last,_Pred)                 \
235
__glibcxx_check_valid_range(_First,_Last);                              \
236
_GLIBCXX_DEBUG_VERIFY(__gnu_debug::__check_sorted(_First, _Last, _Pred), \
237
                      _M_message(__gnu_debug::__msg_unsorted_pred)      \
238
                      ._M_iterator(_First, #_First)                     \
239
                      ._M_iterator(_Last, #_Last)                       \
240
                      ._M_string(#_Pred))
241
 
242
// Special variant for std::merge, std::includes, std::set_*
243
#define __glibcxx_check_sorted_set(_First1,_Last1,_First2)              \
244
__glibcxx_check_valid_range(_First1,_Last1);                            \
245
_GLIBCXX_DEBUG_VERIFY(                                                  \
246
  __gnu_debug::__check_sorted_set(_First1, _Last1, _First2),            \
247
  _M_message(__gnu_debug::__msg_unsorted)                               \
248
  ._M_iterator(_First1, #_First1)                                       \
249
  ._M_iterator(_Last1, #_Last1))
250
 
251
// Likewise with a _Pred.
252
#define __glibcxx_check_sorted_set_pred(_First1,_Last1,_First2,_Pred)   \
253
__glibcxx_check_valid_range(_First1,_Last1);                            \
254
_GLIBCXX_DEBUG_VERIFY(                                                  \
255
  __gnu_debug::__check_sorted_set(_First1, _Last1, _First2, _Pred),     \
256
  _M_message(__gnu_debug::__msg_unsorted_pred)                          \
257
  ._M_iterator(_First1, #_First1)                                       \
258
  ._M_iterator(_Last1, #_Last1)                                         \
259
  ._M_string(#_Pred))
260
 
261
/** Verify that the iterator range [_First, _Last) is partitioned
262
    w.r.t. the value _Value. */
263
#define __glibcxx_check_partitioned_lower(_First,_Last,_Value)          \
264
__glibcxx_check_valid_range(_First,_Last);                              \
265
_GLIBCXX_DEBUG_VERIFY(__gnu_debug::__check_partitioned_lower(_First, _Last, \
266
                                                            _Value),    \
267
                      _M_message(__gnu_debug::__msg_unpartitioned)      \
268
                      ._M_iterator(_First, #_First)                     \
269
                      ._M_iterator(_Last, #_Last)                       \
270
                      ._M_string(#_Value))
271
 
272
#define __glibcxx_check_partitioned_upper(_First,_Last,_Value)          \
273
__glibcxx_check_valid_range(_First,_Last);                              \
274
_GLIBCXX_DEBUG_VERIFY(__gnu_debug::__check_partitioned_upper(_First, _Last, \
275
                                                            _Value),    \
276
                      _M_message(__gnu_debug::__msg_unpartitioned)      \
277
                      ._M_iterator(_First, #_First)                     \
278
                      ._M_iterator(_Last, #_Last)                       \
279
                      ._M_string(#_Value))
280
 
281
/** Verify that the iterator range [_First, _Last) is partitioned
282
    w.r.t. the value _Value and predicate _Pred. */
283
#define __glibcxx_check_partitioned_lower_pred(_First,_Last,_Value,_Pred) \
284
__glibcxx_check_valid_range(_First,_Last);                              \
285
_GLIBCXX_DEBUG_VERIFY(__gnu_debug::__check_partitioned_lower(_First, _Last, \
286
                                                         _Value, _Pred), \
287
                      _M_message(__gnu_debug::__msg_unpartitioned_pred) \
288
                      ._M_iterator(_First, #_First)                     \
289
                      ._M_iterator(_Last, #_Last)                       \
290
                      ._M_string(#_Pred)                                \
291
                      ._M_string(#_Value))
292
 
293
/** Verify that the iterator range [_First, _Last) is partitioned
294
    w.r.t. the value _Value and predicate _Pred. */
295
#define __glibcxx_check_partitioned_upper_pred(_First,_Last,_Value,_Pred) \
296
__glibcxx_check_valid_range(_First,_Last);                              \
297
_GLIBCXX_DEBUG_VERIFY(__gnu_debug::__check_partitioned_upper(_First, _Last, \
298
                                                         _Value, _Pred), \
299
                      _M_message(__gnu_debug::__msg_unpartitioned_pred) \
300
                      ._M_iterator(_First, #_First)                     \
301
                      ._M_iterator(_Last, #_Last)                       \
302
                      ._M_string(#_Pred)                                \
303
                      ._M_string(#_Value))
304
 
305
// Verify that the iterator range [_First, _Last) is a heap
306
#define __glibcxx_check_heap(_First,_Last)                              \
307
  _GLIBCXX_DEBUG_VERIFY(std::__is_heap(__gnu_debug::__base(_First),     \
308
                                       __gnu_debug::__base(_Last)),     \
309
                      _M_message(__gnu_debug::__msg_not_heap)           \
310
                      ._M_iterator(_First, #_First)                     \
311
                      ._M_iterator(_Last, #_Last))
312
 
313
/** Verify that the iterator range [_First, _Last) is a heap
314
    w.r.t. the predicate _Pred. */
315
#define __glibcxx_check_heap_pred(_First,_Last,_Pred)                   \
316
  _GLIBCXX_DEBUG_VERIFY(std::__is_heap(__gnu_debug::__base(_First),     \
317
                                       __gnu_debug::__base(_Last),      \
318
                                       _Pred),                          \
319
                      _M_message(__gnu_debug::__msg_not_heap_pred)      \
320
                      ._M_iterator(_First, #_First)                     \
321
                      ._M_iterator(_Last, #_Last)                       \
322
                      ._M_string(#_Pred))
323
 
324
// Verify that the container is not self move assigned
325
#define __glibcxx_check_self_move_assign(_Other)                        \
326
_GLIBCXX_DEBUG_VERIFY(this != &_Other,                                  \
327
                      _M_message(__gnu_debug::__msg_self_move_assign)   \
328
                      ._M_sequence(*this, "this"))
329
 
330
// Verify that load factor is position
331
#define __glibcxx_check_max_load_factor(_F)                             \
332
_GLIBCXX_DEBUG_VERIFY(_F > 0.0f,                                        \
333
                      _M_message(__gnu_debug::__msg_valid_load_factor)  \
334
                      ._M_sequence(*this, "this"))
335
 
336
#define __glibcxx_check_equal_allocs(_Other)                    \
337
_GLIBCXX_DEBUG_VERIFY(this->get_allocator() == _Other.get_allocator(),  \
338
                      _M_message(__gnu_debug::__msg_equal_allocs)       \
339
                      ._M_sequence(*this, "this"))
340
 
341
#ifdef _GLIBCXX_DEBUG_PEDANTIC
342
#  define __glibcxx_check_string(_String) _GLIBCXX_DEBUG_ASSERT(_String != 0)
343
#  define __glibcxx_check_string_len(_String,_Len) \
344
       _GLIBCXX_DEBUG_ASSERT(_String != 0 || _Len == 0)
345
#else
346
#  define __glibcxx_check_string(_String)
347
#  define __glibcxx_check_string_len(_String,_Len)
348
#endif
349
 
350
#endif

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.