Main Page   Reference Manual   Namespace List   Compound List   Namespace Members   Compound Members   File Members  

libcwd/debug.h

Go to the documentation of this file.
00001 // $Header: /cvsroot/libcwd/libcwd/include/libcwd/debug.h,v 1.5 2004/05/27 03:03:52 libcw Exp $
00002 //
00003 // Copyright (C) 2000 - 2003, by
00004 // 
00005 // Carlo Wood, Run on IRC <carlo@alinoe.com>
00006 // RSA-1024 0x624ACAD5 1997-01-26                    Sign & Encrypt
00007 // Fingerprint16 = 32 EC A7 B6 AC DB 65 A6  F6 F6 55 DD 1C DC FF 61
00008 //
00009 // This file may be distributed under the terms of the Q Public License
00010 // version 1.0 as appearing in the file LICENSE.QPL included in the
00011 // packaging of this file.
00012 //
00013 
00023 #ifndef LIBCWD_DEBUG_H
00024 #define LIBCWD_DEBUG_H
00025 
00026 #ifndef LIBCWD_SYS_H
00027 #error "You need to #include "sys.h" at the top of every source file (which in turn should #include <libcwd/sys.h>)."
00028 #endif
00029 
00030 #ifndef CWDEBUG
00031 
00032 // If you run into this error then you included <libcwd/debug.h> (or any other libcwd header file)
00033 // while the macro CWDEBUG was not defined.  Doing so would cause the compilation of your
00034 // application to fail on machines that do not have libcwd installed.  Instead you should use:
00035 // #include "debug.h"
00036 // and add a file debug.h to your applications distribution.  Please see the the example-project
00037 // that comes with the source code of libcwd (or is included in the documentation that comes with
00038 // the rpm (ie: /usr/doc/libcwd-1.0/example-project) for a description of the content of "debug.h".
00039 // Note1: CWDEBUG should be defined on the compiler commandline, for example: g++ -DCWDEBUG ...
00040 #error "You are including <libcwd/debug.h> while CWDEBUG is not defined.  See the comments in this header file for more information."
00041 
00042 #else // CWDEBUG (normal usage of this file):
00043 
00044 #include <libcwd/config.h>
00045 
00046 //===================================================================================================
00047 // The global debug channels used by libcwd.
00048 //
00049 
00050 #include <libcwd/class_channel.h>
00051 #include <libcwd/class_fatal_channel.h>
00052 #include <libcwd/class_continued_channel.h>
00053 #include <libcwd/class_always_channel.h>
00054 
00055 #ifndef DEBUGCHANNELS
00056 
00062 #define DEBUGCHANNELS ::libcwd::channels
00063 #endif
00064 
00065 namespace libcwd {
00066 
00067 namespace channels {
00068 
00076   namespace dc {
00077     extern channel_ct debug;
00078     extern channel_ct notice;
00079     extern channel_ct system;
00080     extern channel_ct warning;
00081 #if CWDEBUG_ALLOC
00082 #ifdef LIBCWD_USE_EXTERNAL_C_LINKAGE_FOR_MALLOC
00083     extern channel_ct malloc;
00084 #else
00085     extern channel_ct __libcwd_malloc;
00086 #endif
00087 #else // !CWDEBUG_ALLOC
00088     extern channel_ct malloc;
00089 #endif
00090 #if CWDEBUG_LOCATION
00091     extern channel_ct bfd;
00092 #endif
00093     extern fatal_channel_ct fatal;
00094     extern fatal_channel_ct core;
00095     extern continued_channel_ct continued;
00096     extern continued_channel_ct finish;
00097     extern always_channel_ct always;
00098 
00099   } // namespace dc
00100 } // namespace channels
00101 
00102 } // namespace libcwd
00103 
00104 
00105 //===================================================================================================
00106 // The global debug object
00107 //
00108 
00109 #include <libcwd/class_debug.h>
00110 
00111 namespace libcwd {
00112 
00113 extern debug_ct libcw_do;
00114 
00115 } // namespace libcwd
00116 
00117 //===================================================================================================
00118 // Macros
00119 //
00120 
00121 #include <libcwd/macro_Libcwd_macros.h>
00122 
00123 // For use in library header files: do not redefine these!
00124 // Developers of libraries are recommended to define their own macro names.
00125 #define __Debug(x) \
00126     LibcwDebug(::libcwd::channels, x)
00127 #define __Dout(cntrl, data) \
00128     LibcwDout(::libcwd::channels, ::libcwd::libcw_do, cntrl, data)
00129 #define __DoutFatal(cntrl, data) \
00130     LibcwDoutFatal(::libcwd::channels, ::libcwd::libcw_do, cntrl, data)
00131 
00132 // For use in applications
00159 #define Debug(x) \
00160     LibcwDebug(DEBUGCHANNELS, x)
00161 
00189 #define Dout(cntrl, data) \
00190     LibcwDout(DEBUGCHANNELS, ::libcwd::libcw_do, cntrl, data)
00191 
00199 #define DoutFatal(cntrl, data) \
00200     LibcwDoutFatal(DEBUGCHANNELS, ::libcwd::libcw_do, cntrl, data)
00201 
00202 //===================================================================================================
00203 // Miscellaneous
00204 //
00205 
00206 namespace libcwd {
00207 
00208 extern channel_ct* find_channel(char const* label);
00209 extern void list_channels_on(debug_ct& debug_object);
00210 
00211 // Make the inserter functions of std accessible in libcwd.
00212 using std::operator<<;
00213 
00214 } // namespace libcwd
00215 
00216 // Make the inserter functions of libcwd accessible in global namespace.
00217 #ifndef HIDE_FROM_DOXYGEN
00218 namespace libcwd_inserters {
00219   using libcwd::operator<<;
00220 } // namespace libcwd_inserters
00221 using namespace libcwd_inserters;
00222 #endif
00223 
00224 #include <libcwd/macro_ForAllDebugChannels.h>
00225 #include <libcwd/macro_ForAllDebugObjects.h>
00226 #include <libcwd/private_environ.h>
00227 #include <libcwd/class_rcfile.h>
00228 #include <libcwd/attach_gdb.h>
00229 #include <libcwd/demangle.h>
00230 
00231 // Include the inline functions.
00232 #include <libcwd/private_allocator.inl>         // Implementation of allocator_adaptor template.
00233 #include <libcwd/class_channel.inl>             // Debug channels.
00234 #include <libcwd/class_fatal_channel.inl>
00235 #include <libcwd/class_continued_channel.inl>
00236 #include <libcwd/class_always_channel.inl>
00237 #include <libcwd/class_debug.inl>               // Debug objects (debug_ct).
00238 #include <libcwd/class_debug_string.inl>                // Public member of debug_ct.
00239 #include <libcwd/class_channel_set.inl>         // Used in macro Dout et al.
00240 
00241 // Include optional features.
00242 #if CWDEBUG_LOCATION                            // --enable-location
00243 #include <libcwd/bfd.h>
00244 #endif
00245 #include <libcwd/debugmalloc.h>                 // --enable-alloc
00246 
00247 // Finally, in order for Dout() to be usable, we need this.
00248 #ifndef LIBCW_IOSTREAM
00249 #define LIBCW_IOSTREAM
00250 #include <iostream>
00251 #endif
00252 
00253 #endif // CWDEBUG
00254 #endif // LIBCWD_DEBUG_H
Copyright © 2001 - 2004 Carlo Wood.  All rights reserved.