Fixed building of catalogs.
[AROS.git] / workbench / classes / zune / nlist / nlist_mcc / Debug.h
blobe43aab6eba26d6ce7207157f3028cca2267b67e2
1 /***************************************************************************
3 TextEditor.mcc - Textediting MUI Custom Class
4 Copyright (C) 1997-2000 Allan Odgaard
5 Copyright (C) 2005 by TextEditor.mcc Open Source Team
7 This library is free software; you can redistribute it and/or
8 modify it under the terms of the GNU Lesser General Public
9 License as published by the Free Software Foundation; either
10 version 2.1 of the License, or (at your option) any later version.
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 GNU
15 Lesser General Public License for more details.
17 TextEditor class Support Site: http://www.sf.net/projects/texteditor-mcc
19 $Id$
21 ***************************************************************************/
23 #ifndef DEBUG_H
24 #define DEBUG_H
26 // first we make sure all previously defined symbols are undefined now so
27 // that no other debug system interferes with ours.
28 #undef ENTER
29 #undef LEAVE
30 #undef RETURN
31 #undef SHOWVALUE
32 #undef SHOWPOINTER
33 #undef SHOWSTRING
34 #undef SHOWMSG
35 #undef STARTCLOCK
36 #undef STOPCLOCK
37 #undef D
38 #undef E
39 #undef W
40 #undef ASSERT
42 #if defined(DEBUG)
44 #include <assert.h>
46 #ifndef EXEC_TYPES_H
47 #include <exec/types.h>
48 #endif
50 #if defined(__amigaos4__)
51 #include <proto/exec.h>
52 #ifdef __USE_INLINE__
53 #ifdef DebugPrintF
54 #undef DebugPrintF
55 #endif
56 #endif
57 #ifndef kprintf
58 #define kprintf(format, args...) ((struct ExecIFace *)((*(struct ExecBase **)4)->MainInterface))->DebugPrintF(format, ## args)
59 #endif
60 #elif defined(__MORPHOS__)
61 #include <exec/rawfmt.h>
62 #include <proto/exec.h>
63 #define KPutFmt(format, args) VNewRawDoFmt(format, (APTR)RAWFMTFUNC_SERIAL, NULL, args)
64 void kprintf(const char *formatString,...);
65 #else
66 void kprintf(const char *formatString,...);
67 #endif
69 // debug classes
70 #define DBC_CTRACE (1<<0) // call tracing (ENTER/LEAVE etc.)
71 #define DBC_REPORT (1<<1) // reports (SHOWVALUE/SHOWSTRING etc.)
72 #define DBC_ASSERT (1<<2) // asserts (ASSERT)
73 #define DBC_TIMEVAL (1<<3) // time evaluations (STARTCLOCK/STOPCLOCK)
74 #define DBC_DEBUG (1<<4) // debugging output D()
75 #define DBC_ERROR (1<<5) // error output E()
76 #define DBC_WARNING (1<<6) // warning output W()
77 #define DBC_ALL 0xffffffff
79 // debug flags
80 #define DBF_ALWAYS (1<<0)
81 #define DBF_STARTUP (1<<1) // for startup/shutdown events (YAM.c)
82 #define DBF_SELECT (1<<2)
83 #define DBF_INPUT (1<<3)
84 #define DBF_CLIPBOARD (1<<4)
85 #define DBF_DRAW (1<<5)
86 #define DBF_ALL 0xffffffff
88 void SetupDebug(void);
89 void CleanupDebug(void);
91 void _ENTER(unsigned long dclass, const char *file, int line, const char *function);
92 void _LEAVE(unsigned long dclass, const char *file, int line, const char *function);
93 void _RETURN(unsigned long dclass, const char *file, int line, const char *function, unsigned long result);
94 void _SHOWVALUE(unsigned long dclass, unsigned long dflags, unsigned long value, int size, const char *name, const char *file, int line);
95 void _SHOWPOINTER(unsigned long dclass, unsigned long dflags, const void *p, const char *name, const char *file, int line);
96 void _SHOWSTRING(unsigned long dclass, unsigned long dflags, const char *string, const char *name, const char *file, int line);
97 void _SHOWMSG(unsigned long dclass, unsigned long dflags, const char *msg, const char *file, int line);
98 void _DPRINTF(unsigned long dclass, unsigned long dflags, const char *file, int line, const char *format, ...);
99 void _STARTCLOCK(unsigned long dclass, unsigned long dflags, const char *file, unsigned long line);
100 void _STOPCLOCK(unsigned long dclass, unsigned long dflags, const char *file, unsigned long line, const char *msg);
102 // Core class information class messages
103 #define ENTER() _ENTER(DBC_CTRACE, __FILE__, __LINE__, __FUNCTION__)
104 #define LEAVE() _LEAVE(DBC_CTRACE, __FILE__, __LINE__, __FUNCTION__)
105 #define RETURN(r) _RETURN(DBC_CTRACE, __FILE__, __LINE__, __FUNCTION__, (long)r)
106 #define SHOWVALUE(f, v) _SHOWVALUE(DBC_REPORT, f, (long)v, sizeof(v), #v, __FILE__, __LINE__)
107 #define SHOWPOINTER(f, p) _SHOWPOINTER(DBC_REPORT, f, p, #p, __FILE__, __LINE__)
108 #define SHOWSTRING(f, s) _SHOWSTRING(DBC_REPORT, f, s, #s, __FILE__, __LINE__)
109 #define SHOWMSG(f, m) _SHOWMSG(DBC_REPORT, f, m, __FILE__, __LINE__)
110 #define STARTCLOCK(f) _STARTCLOCK(DBC_TIMEVAL, f, __FILE__, __LINE__)
111 #define STOPCLOCK(f, msg) _STOPCLOCK(DBC_TIMEVAL, f, __FILE__, __LINE__, msg)
112 #define D(f, s, vargs...) _DPRINTF(DBC_DEBUG, f, __FILE__, __LINE__, s, ## vargs)
113 #define E(f, s, vargs...) _DPRINTF(DBC_ERROR, f, __FILE__, __LINE__, s, ## vargs)
114 #define W(f, s, vargs...) _DPRINTF(DBC_WARNING, f, __FILE__, __LINE__, s, ## vargs)
115 #define ASSERT(expression) \
116 ((void) \
117 ((expression) ? 0 : \
119 _DPRINTF(DBC_ASSERT, \
120 DBF_ALWAYS, \
121 __FILE__, \
122 __LINE__, \
123 "failed assertion '%s'", \
124 #expression), \
125 assert(#expression), \
131 #else // DEBUG
133 #define ENTER() ((void)0)
134 #define LEAVE() ((void)0)
135 #define RETURN(r) ((void)0)
136 #define SHOWVALUE(f, v) ((void)0)
137 #define SHOWPOINTER(f, p) ((void)0)
138 #define SHOWSTRING(f, s) ((void)0)
139 #define SHOWMSG(f, m) ((void)0)
140 #define STARTCLOCK(f) ((void)0)
141 #define STOPCLOCK(f, m) ((void)0)
142 #define D(f, s, vargs...) ((void)0)
143 #define E(f, s, vargs...) ((void)0)
144 #define W(f, s, vargs...) ((void)0)
145 #define ASSERT(expression) ((void)0)
147 #endif // DEBUG
149 #endif // DEBUG_H