2 Copyright © 1995-96, The AROS Development Team. All rights reserved.
5 This include file can be included several times !
10 extern int _SD_SpacesWritten
;
20 /* Remove all macros. They get new values each time this file is
33 /* Macros for "stair debugging" */
41 # ifndef SDEBUG_INDENT
42 # define SDEBUG_INDENT 2
45 /* This is some new macros for making debug output more readable,
46 ** by indenting for each functioncall made.
47 ** Usage: Call the SDInit() macro before anything else in your main().
48 ** Start the functions you want to debug with EnterFunc(bug("something"))
49 ** and ALWAYS match these with a Returnxxxx type macro
50 ** at the end of the func.
51 ** Inside the func you can use the normal D(bug()) macro.
53 ** To enable the macros, just add a #define SDEBUG 1
57 #define EnterFunc(x) { \
59 for (_written = 0; _written < _SD_SpacesWritten; _written ++) printf(" "); \
60 _SD_SpacesWritten += SDEBUG_INDENT; } \
63 /* User macro. Add into start of your main() routine */
65 int _SD_SpacesWritten = 0
72 for (_written = 0; _written < _SD_SpacesWritten; _written ++) printf(" "); }
77 _SD_SpacesWritten -= SDEBUG_INDENT; \
78 for (_written = 0; _written < _SD_SpacesWritten; _written ++) printf(" "); }
85 # define EnterFunc(x) D(x)
91 # define D(x) Indent x
96 # define DB2(x) /* eps */
101 /* return-macros. NOTE: I make a copy of the value in __aros_val, because
102 the return-value might have side effects (like return x++;). */
103 # define ReturnVoid(name) { ExitFunc printf ("Exit " name "()\n"); return; }
104 # define ReturnPtr(name,type,val) { type __aros_val = (type)val; \
105 ExitFunc printf ("Exit " name "=%08lx\n", \
106 (ULONG)__aros_val); return __aros_val; }
107 # define ReturnStr(name,type,val) { type __aros_val = (type)val; \
108 ExitFunc printf ("Exit " name "=\"%s\"\n", \
109 __aros_val); return __aros_val; }
110 # define ReturnInt(name,type,val) { type __aros_val = (type)val; \
111 ExitFunc printf ("Exit " name "=%ld\n", \
112 (ULONG)__aros_val); return __aros_val; }
113 # define ReturnXInt(name,type,val) { type __aros_val = (type)val; \
114 ExitFunc printf ("Exit " name "=%lx\n", \
115 (ULONG)__aros_val); return __aros_val; }
116 # define ReturnFloat(name,type,val) { type __aros_val = (type)val; \
117 ExitFunc printf ("Exit " name "=%g\n", \
118 (ULONG)__aros_val); return __aros_val; }
119 # define ReturnSpecial(name,type,val,fmt) { type __aros_val = (type)val; \
120 ExitFunc printf ("Exit " name "=" fmt "\n", \
121 (ULONG)__aros_val); return __aros_val; }
122 # define ReturnBool(name,val) { BOOL __aros_val = (val != 0); \
123 ExitFunc printf ("Exit " name "=%s\n", \
124 __aros_val ? "TRUE" : "FALSE"); \
127 # define D(x) /* eps */
128 # define DB2(x) /* eps */
130 # define ReturnVoid(name) return
131 # define ReturnPtr(name,type,val) return val
132 # define ReturnStr(name,type,val) return val
133 # define ReturnInt(name,type,val) return val
134 # define ReturnXInt(name,type,val) return val
135 # define ReturnFloat(name,type,val) return val
136 # define ReturnSpecial(name,type,val,fmt) return val
137 # define ReturnBool(name,val) return val