debug.h

Go to the documentation of this file.
00001 // Debugging support implementation -*- C++ -*-
00002 
00003 // Copyright (C) 2003, 2005
00004 // Free Software Foundation, Inc.
00005 //
00006 // This file is part of the GNU ISO C++ Library.  This library is free
00007 // software; you can redistribute it and/or modify it under the
00008 // terms of the GNU General Public License as published by the
00009 // Free Software Foundation; either version 2, or (at your option)
00010 // any later version.
00011 
00012 // This library is distributed in the hope that it will be useful,
00013 // but WITHOUT ANY WARRANTY; without even the implied warranty of
00014 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00015 // GNU General Public License for more details.
00016 
00017 // You should have received a copy of the GNU General Public License along
00018 // with this library; see the file COPYING.  If not, write to the Free
00019 // Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
00020 // USA.
00021 
00022 // As a special exception, you may use this file as part of a free software
00023 // library without restriction.  Specifically, if other files instantiate
00024 // templates or use macros or inline functions from this file, or you compile
00025 // this file and link it with other files to produce an executable, this
00026 // file does not by itself cause the resulting executable to be covered by
00027 // the GNU General Public License.  This exception does not however
00028 // invalidate any other reasons why the executable file might be covered by
00029 // the GNU General Public License.
00030 
00031 #ifndef _GLIBCXX_DEBUG_DEBUG_H
00032 #define _GLIBCXX_DEBUG_DEBUG_H 1
00033 
00042 #ifdef _GLIBCXX_DEBUG
00043 
00044 # include <debug/macros.h>
00045 # include <cstdlib>
00046 # include <cstdio>
00047 
00048 // Avoid the use of assert, because we're trying to keep the <cassert>
00049 // include out of the mix.
00050 namespace __gnu_debug
00051 { 
00052   inline void
00053   __replacement_assert(const char* __file, int __line, const char* __function,
00054                const char* __condition)
00055   {
00056     std::printf("%s:%d: %s: Assertion '%s' failed.\n", __file, __line,
00057         __function, __condition);
00058     std::abort();
00059   }
00060 }
00061 
00062 #define _GLIBCXX_DEBUG_ASSERT(_Condition)                               \
00063   do {                                                                  \
00064     if (! (_Condition))                                                 \
00065       ::__gnu_debug::__replacement_assert(__FILE__, __LINE__,           \
00066                    __PRETTY_FUNCTION__,                 \
00067                    #_Condition);                        \
00068   } while (false)
00069 
00070 #  ifdef _GLIBCXX_DEBUG_PEDANTIC
00071 #    define _GLIBCXX_DEBUG_PEDASSERT(_Condition) _GLIBCXX_DEBUG_ASSERT(_Condition)
00072 #  else
00073 #    define _GLIBCXX_DEBUG_PEDASSERT(_Condition)
00074 #  endif
00075 
00076 #  define __glibcxx_requires_cond(_Cond,_Msg) _GLIBCXX_DEBUG_VERIFY(_Cond,_Msg)
00077 #  define __glibcxx_requires_valid_range(_First,_Last) \
00078      __glibcxx_check_valid_range(_First,_Last)
00079 #  define __glibcxx_requires_sorted(_First,_Last) \
00080      __glibcxx_check_sorted(_First,_Last)
00081 #  define __glibcxx_requires_sorted_pred(_First,_Last,_Pred) \
00082      __glibcxx_check_sorted_pred(_First,_Last,_Pred)
00083 #  define __glibcxx_requires_partitioned(_First,_Last,_Value)   \
00084      __glibcxx_check_partitioned(_First,_Last,_Value)
00085 #  define __glibcxx_requires_partitioned_pred(_First,_Last,_Value,_Pred) \
00086      __glibcxx_check_partitioned_pred(_First,_Last,_Value,_Pred)
00087 #  define __glibcxx_requires_heap(_First,_Last) \
00088      __glibcxx_check_heap(_First,_Last)
00089 #  define __glibcxx_requires_heap_pred(_First,_Last,_Pred) \
00090      __glibcxx_check_heap_pred(_First,_Last,_Pred)
00091 #  define __glibcxx_requires_nonempty() __glibcxx_check_nonempty()
00092 #  define __glibcxx_requires_string(_String) __glibcxx_check_string(_String)
00093 #  define __glibcxx_requires_string_len(_String,_Len)   \
00094      __glibcxx_check_string_len(_String,_Len)
00095 #  define __glibcxx_requires_subscript(_N) __glibcxx_check_subscript(_N)
00096 
00097 #  include <debug/functions.h>
00098 #  include <debug/formatter.h>
00099 #else
00100 #  define _GLIBCXX_DEBUG_ASSERT(_Condition)
00101 #  define _GLIBCXX_DEBUG_PEDASSERT(_Condition)
00102 #  define __glibcxx_requires_cond(_Cond,_Msg)
00103 #  define __glibcxx_requires_valid_range(_First,_Last)
00104 #  define __glibcxx_requires_sorted(_First,_Last)
00105 #  define __glibcxx_requires_sorted_pred(_First,_Last,_Pred)
00106 #  define __glibcxx_requires_partitioned(_First,_Last,_Value)
00107 #  define __glibcxx_requires_partitioned_pred(_First,_Last,_Value,_Pred)
00108 #  define __glibcxx_requires_heap(_First,_Last)
00109 #  define __glibcxx_requires_heap_pred(_First,_Last,_Pred)
00110 #  define __glibcxx_requires_nonempty()
00111 #  define __glibcxx_requires_string(_String)
00112 #  define __glibcxx_requires_string_len(_String,_Len)
00113 #  define __glibcxx_requires_subscript(_N)
00114 #endif
00115 
00116 #endif

Generated on Tue Feb 2 16:55:52 2010 for GNU C++ STL by  doxygen 1.4.7