Moving to main tree, needed by SysExplorer
[AROS.git] / workbench / classes / zune / nlist / nbalance_mcc / Debug.h
blob70e7c21bf59746a493d5909d4977b80b3426b542
1 /***************************************************************************
3 NBalance.mcc - New Balance MUI Custom Class
4 Copyright (C) 2008 by NList Open Source Team
6 This library is free software; you can redistribute it and/or
7 modify it under the terms of the GNU Lesser General Public
8 License as published by the Free Software Foundation; either
9 version 2.1 of the License, or (at your option) any later version.
11 This library is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 Lesser General Public License for more details.
16 NList classes Support Site: http://www.sf.net/projects/nlist-classes
18 $Id$
20 ***************************************************************************/
22 #ifndef DEBUG_H
23 #define DEBUG_H
25 // first we make sure all previously defined symbols are undefined now so
26 // that no other debug system interferes with ours.
27 #undef ENTER
28 #undef LEAVE
29 #undef RETURN
30 #undef SHOWVALUE
31 #undef SHOWPOINTER
32 #undef SHOWSTRING
33 #undef SHOWMSG
34 #undef STARTCLOCK
35 #undef STOPCLOCK
36 #undef D
37 #undef E
38 #undef W
39 #undef ASSERT
41 #if defined(DEBUG)
43 #include <assert.h>
45 #ifndef EXEC_TYPES_H
46 #include <exec/types.h>
47 #endif
49 #if defined(__amigaos4__)
50 #include <proto/exec.h>
51 #ifdef __USE_INLINE__
52 #ifdef DebugPrintF
53 #undef DebugPrintF
54 #endif
55 #endif
56 #ifndef kprintf
57 #define kprintf(format, args...) ((struct ExecIFace *)((*(struct ExecBase **)4)->MainInterface))->DebugPrintF(format, ## args)
58 #endif
59 #elif defined(__MORPHOS__)
60 #include <exec/rawfmt.h>
61 #include <proto/exec.h>
62 #define KPutFmt(format, args) VNewRawDoFmt(format, (APTR)RAWFMTFUNC_SERIAL, NULL, args)
63 void kprintf(const char *formatString,...);
64 #else
65 void kprintf(const char *formatString,...);
66 #endif
68 // debug classes
69 #define DBC_CTRACE (1<<0) // call tracing (ENTER/LEAVE etc.)
70 #define DBC_REPORT (1<<1) // reports (SHOWVALUE/SHOWSTRING etc.)
71 #define DBC_ASSERT (1<<2) // asserts (ASSERT)
72 #define DBC_TIMEVAL (1<<3) // time evaluations (STARTCLOCK/STOPCLOCK)
73 #define DBC_DEBUG (1<<4) // debugging output D()
74 #define DBC_ERROR (1<<5) // error output E()
75 #define DBC_WARNING (1<<6) // warning output W()
76 #define DBC_ALL 0xffffffff
78 // debug flags
79 #define DBF_ALWAYS (1<<0)
80 #define DBF_STARTUP (1<<1) // for startup/shutdown events
81 #define DBF_INPUT (1<<2)
82 #define DBF_ALL 0xffffffff
84 void SetupDebug(void);
85 void CleanupDebug(void);
87 void _ENTER(unsigned long dclass, const char *file, int line, const char *function);
88 void _LEAVE(unsigned long dclass, const char *file, int line, const char *function);
89 void _RETURN(unsigned long dclass, const char *file, int line, const char *function, unsigned long result);
90 void _SHOWVALUE(unsigned long dclass, unsigned long dflags, unsigned long value, int size, const char *name, const char *file, int line);
91 void _SHOWPOINTER(unsigned long dclass, unsigned long dflags, const void *p, const char *name, const char *file, int line);
92 void _SHOWSTRING(unsigned long dclass, unsigned long dflags, const char *string, const char *name, const char *file, int line);
93 void _SHOWMSG(unsigned long dclass, unsigned long dflags, const char *msg, const char *file, int line);
94 void _DPRINTF(unsigned long dclass, unsigned long dflags, const char *file, int line, const char *format, ...);
96 // Core class information class messages
97 #define ENTER() _ENTER(DBC_CTRACE, __FILE__, __LINE__, __FUNCTION__)
98 #define LEAVE() _LEAVE(DBC_CTRACE, __FILE__, __LINE__, __FUNCTION__)
99 #define RETURN(r) _RETURN(DBC_CTRACE, __FILE__, __LINE__, __FUNCTION__, (long)r)
100 #define SHOWVALUE(f, v) _SHOWVALUE(DBC_REPORT, f, (long)v, sizeof(v), #v, __FILE__, __LINE__)
101 #define SHOWPOINTER(f, p) _SHOWPOINTER(DBC_REPORT, f, p, #p, __FILE__, __LINE__)
102 #define SHOWSTRING(f, s) _SHOWSTRING(DBC_REPORT, f, s, #s, __FILE__, __LINE__)
103 #define SHOWMSG(f, m) _SHOWMSG(DBC_REPORT, f, m, __FILE__, __LINE__)
104 #define D(f, s, vargs...) _DPRINTF(DBC_DEBUG, f, __FILE__, __LINE__, s, ## vargs)
105 #define E(f, s, vargs...) _DPRINTF(DBC_ERROR, f, __FILE__, __LINE__, s, ## vargs)
106 #define W(f, s, vargs...) _DPRINTF(DBC_WARNING, f, __FILE__, __LINE__, s, ## vargs)
107 #define ASSERT(expression) \
108 ((void) \
109 ((expression) ? 0 : \
111 _DPRINTF(DBC_ASSERT, \
112 DBF_ALWAYS, \
113 __FILE__, \
114 __LINE__, \
115 "failed assertion '%s'", \
116 #expression), \
117 assert(#expression), \
123 #else // DEBUG
125 #define ENTER() ((void)0)
126 #define LEAVE() ((void)0)
127 #define RETURN(r) ((void)0)
128 #define SHOWVALUE(f, v) ((void)0)
129 #define SHOWPOINTER(f, p) ((void)0)
130 #define SHOWSTRING(f, s) ((void)0)
131 #define SHOWMSG(f, m) ((void)0)
132 #define D(f, s, vargs...) ((void)0)
133 #define E(f, s, vargs...) ((void)0)
134 #define W(f, s, vargs...) ((void)0)
135 #define ASSERT(expression) ((void)0)
137 #endif // DEBUG
139 #endif // DEBUG_H