debug.h 5.1 KB

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