~ubuntu-branches/ubuntu/trusty/kvirc/trusty

« back to all changes in this revision

Viewing changes to src/kvilib/config/kvi_debug.h

  • Committer: Bazaar Package Importer
  • Author(s): Kai Wasserbäch, Kai Wasserbäch, Raúl Sánchez Siles
  • Date: 2011-02-12 10:40:21 UTC
  • mfrom: (14.1.3 sid)
  • Revision ID: james.westby@ubuntu.com-20110212104021-5mh4f75jlku20mnt
The combined "Twisted Experiment" and "Nocturnal Raid" release.

[ Kai Wasserbäch ]
* Synced to upstream's SVN revision 5467.
* debian/rules:
  - Added .PHONY line.
  - Resurrect -DMANUAL_REVISION, got lost somewhere and we build SVN
    revisions again.
  - Replace "-DWITH_NO_EMBEDDED_CODE=YES" with "-DWANT_CRYPTOPP=YES".
  - Change the remaining -DWITH/-DWITHOUT to the new -DWANT syntax.
* debian/control:
  - Removed DMUA, I'm a DD now.
  - Changed my e-mail address.
  - Removed unneeded relationships (no upgrades over two releases are
    supported).
  - Fix Suggests for kvirc-dbg.
  - kvirc-data: Make the "Suggests: kvirc" a Recommends, doesn't make much
    sense to install the -data package without the program.
* debian/source/local-options: Added with "unapply-patches".
* debian/kvirc.lintian-overrides: Updated to work for 4.1.1.
* debian/patches/21_make_shared-mime-info_B-D_superfluous.patch: Updated.
* debian/kvirc-data.install: Added .notifyrc.

[ Raúl Sánchez Siles ]
* Stating the right version where kvirc-data break and replace should happen.
* Fixing link to license file.
* Added French and Portuguese man pages.

Show diffs side-by-side

added added

removed removed

Lines of Context:
6
6
//   File : kvi_debug.h
7
7
//   Creation date : Fri Mar 19 1999 03:10:39 CEST by Szymon Stefanek
8
8
//
9
 
//   This file is part of the KVirc irc client distribution
10
 
//   Copyright (C) 1999-2009 Szymon Stefanek (pragma at kvirc dot net)
 
9
//   This file is part of the KVIrc irc client distribution
 
10
//   Copyright (C) 1999-2010 Szymon Stefanek (pragma at kvirc dot net)
11
11
//
12
12
//   This program is FREE software. You can redistribute it and/or
13
13
//   modify it under the terms of the GNU General Public License
27
27
 
28
28
#include <QtGlobal>
29
29
 
 
30
#include "kvi_sysconfig.h"
 
31
 
30
32
/**
31
33
* \file kvi_debug.h
32
34
* \author Szymon Stefanek
33
35
* \brief This file contains the definition of the debug macros;
34
 
*        You can enable ALL the debugging output by uncommenting the line that defines _KVI_DEBUG_CHECK_RANGE_
35
 
*/
36
 
 
37
 
//=============================================================================
38
 
//
39
 
// You can enable ALL the debugging output by uncommenting the next line
40
 
// #define _KVI_DEBUG_CHECK_RANGE_
41
 
//
42
 
//=============================================================================
43
 
 
44
 
/**
45
 
* \brief Debug macros
46
 
*
47
 
* \def __range_valid Assert that ensures that its parameter is true
48
 
* \def __range_invalid Assert that ensures that its parameter is false
49
 
* \def __ASSERT Assert that ensures that its parameter is true; enabled only if _KVI_DEBUG_or __KVI_DEBUG__ is defined
50
 
*/
51
 
 
52
 
 
53
 
#ifdef _KVI_DEBUG_CHECK_RANGE_
54
 
        #define __range_valid(_expr) if(!(_expr))debug("[kvirc]: ASSERT FAILED: \"%s\" is false in %s (%d)",#_expr,__FILE__,__LINE__)
55
 
        #define __range_invalid(_expr) if(_expr)debug("[kvirc]: ASSERT FAILED: \"%s\" is true in %s (%d)",#_expr,__FILE__,__LINE__)
56
 
#else
57
 
        #define __range_valid(_expr)
58
 
        #define __range_invalid(_expr)
59
 
#endif
60
 
 
61
 
#if defined(_KVI_DEBUG_) || defined(__KVI_DEBUG__)
62
 
        #define __ASSERT(_expr) if(!(_expr))debug("[kvirc]: ASSERT FAILED: \"%s\" is false in %s (%d)",#_expr,__FILE__,__LINE__)
63
 
#else
64
 
        #define __ASSERT(_expr)
65
 
#endif
 
36
*/
 
37
 
 
38
#include <stdlib.h> // abort
 
39
 
 
40
#ifdef __GNUC__
 
41
 
 
42
        #define kvi_debug(fmt,arg...) qDebug(fmt,##arg)
 
43
        #define kvi_warning(fmt,arg...) qWarning(fmt,##arg)
 
44
        #define kvi_fatal(fmt,arg...) do { qFatal(fmt,##arg); abort(); } while(0) 
 
45
        #define KVI_PRETTY_FUNCTION __PRETTY_FUNCTION__
 
46
 
 
47
#else //!__GNUC__
 
48
 
 
49
        // assume MSVC
 
50
 
 
51
        #define kvi_debug(fmt,...) qDebug(fmt,__VA_ARGS__)
 
52
        #define kvi_warning(fmt,...) qWarning(fmt,__VA_ARGS__)
 
53
        #define kvi_fatal(fmt,...) do { qFatal(fmt,__VA_ARGS__); abort(); } while(0) 
 
54
        #define KVI_PRETTY_FUNCTION __FUNCTION__
 
55
 
 
56
#endif //!__GNUC__
 
57
 
 
58
#ifdef COMPILE_DEBUG_MODE
 
59
 
 
60
        #define KVI_ASSERT(__condition__) \
 
61
                        do { \
 
62
                                if(!(__condition__)) \
 
63
                                        qFatal("[ASSERT FAILED] (" # __condition__ ") in %s at %s:%u",KVI_PRETTY_FUNCTION,__FILE__,__LINE__); \
 
64
                        } while(0)
 
65
 
 
66
        #define KVI_ASSERT_MSG(__condition__,__message__) \
 
67
                        do { \
 
68
                                if(!(__condition__)) \
 
69
                                { \
 
70
                                        qFatal("[ASSERT FAILED] (" # __condition__ ") in %s at %s:%u",KVI_PRETTY_FUNCTION,__FILE__,__LINE__); \
 
71
                                        qFatal("[ASSERT FAILED] " __message__); \
 
72
                                } \
 
73
                        } while(0)
 
74
 
 
75
        #include "KviDebugContext.h"
 
76
 
 
77
        // The following two macros are used to create unique variable names
 
78
        // by the means of the __LINE__ builtin macro.
 
79
        // The ## token paste operator must be called inside a macro and must
 
80
        // preceede a macro parameter. This is why we can't use directly
 
81
        //
 
82
        // #define UNIQUEVARIABLE int name ## __LINE__
 
83
        //
 
84
        // We need something like
 
85
        //
 
86
        // #define PASTE(x,y) x ## y
 
87
        // #define UNIQUEVARIABLE int PASTE(x,__LINE__)
 
88
        //
 
89
        // But this doesn't work since the specification of the token pasting operator is
 
90
        //
 
91
        // "If a formal parameter in a macro definition is preceded or followed by the token-pasting operator,
 
92
        // the formal parameter is immediately replaced by the __unexpanded__ actual argument. Macro expansion 
 
93
        // is __not performed__ on the argument prior to replacement."
 
94
        //
 
95
        // So to actually have __LINE__ expanded we need another level of indirection
 
96
        //
 
97
        // #define PASTE(x,y) x ## y
 
98
        // #define EXPAND_Y_AND_THEN_PASTE(x,y) PASTE(x,y)
 
99
        // #define UNIQUEVARIABLE int EXPAND_Y_AND_THEN_PASTE(x,__LINE__)
 
100
 
 
101
        #define KVI_TRACE_HACK_TOKENPASTE_2(x,y) x ## y
 
102
        #define KVI_TRACE_HACK_TOKENPASTE_1(x,y) KVI_TRACE_HACK_TOKENPASTE_2(x,y)
 
103
 
 
104
        #ifdef __GNUC__
 
105
                #define KVI_TRACE_FUNCTION \
 
106
                                KviDebugContext KVI_TRACE_HACK_TOKENPASTE_1(ctx,__LINE__)(__PRETTY_FUNCTION__)
 
107
 
 
108
                #define KVI_TRACE_BLOCK(_szBlockDescription) \
 
109
                                KviDebugContext KVI_TRACE_HACK_TOKENPASTE_1(ctx,__LINE__)("%s - %s",__PRETTY_FUNCTION__,_szBlockDescription)
 
110
                
 
111
                #define KVI_TRACE(_szFmt,arg...) KviDebugContext::trace(_szFmt,##arg)
 
112
 
 
113
        #else
 
114
                #define KVI_TRACE_FUNCTION \
 
115
                                KviDebugContext KVI_TRACE_HACK_TOKENPASTE_1(ctx,__LINE__)(__FUNCTION__)
 
116
 
 
117
                #define KVI_TRACE_BLOCK(_szBlockDescription) \
 
118
                                KviDebugContext KVI_TRACE_HACK_TOKENPASTE_1(ctx,__LINE__)("%s - %s",__FUNCTION__,_szBlockDescription)
 
119
 
 
120
                #define KVI_TRACE(_szFmt,...) KviDebugContext::trace(_szFmt,__VA_ARGS__)
 
121
 
 
122
        #endif
 
123
 
 
124
#else //!COMPILE_DEBUG_MODE
 
125
 
 
126
        #define KVI_ASSERT(__condition__) do { } while(0)
 
127
        #define KVI_ASSERT_MSG(__condition__,__message__) do { } while(0)
 
128
 
 
129
        #define KVI_TRACE_FUNCTION \
 
130
                        do { } while(0)
 
131
 
 
132
        #define KVI_TRACE_BLOCK(_szBlockDescription) \
 
133
                        do { } while(0)
 
134
 
 
135
        #ifdef __GNUC__
 
136
                #define KVI_TRACE(_szFmt,arg...) do { } while(0)
 
137
        #else
 
138
                #define KVI_TRACE(_szFmt,...) do { } while(0)
 
139
        #endif 
 
140
        
 
141
#endif //!COMPILE_DEBUG_MODE
 
142
 
 
143
 
 
144
 
 
145
 
66
146
 
67
147
#endif //_KVI_DEBUG_H_