00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00042
00044
00045
00046
00047
00048
00049
00050
00051
00052
00053
00054
00055
00056
00057
00058
00059
00060 #ifndef _ABKASSERT_H_
00061 #define _ABKASSERT_H_
00062
00063 #include <iostream>
00064 #include "abkseed.h"
00065
00066 using std::cerr;
00067 using std::cout;
00068 using std::ostream;
00069 using std::istream;
00070 using std::endl;
00071
00072
00073
00074
00075
00076 extern void abkassert_stop_here();
00077 extern void abkguess_stop_here();
00078
00079 extern void abkfatal_stop_here();
00080 extern void abkwarn_stop_here();
00081
00082
00083 extern void abk_dump_stack();
00084
00085 extern void abk_call_debugger();
00086
00087 #ifdef ABKDEBUG
00088 #define STACK_DUMP abk_dump_stack();
00089 #define abkfatal_breakpoint abkfatal_stop_here();
00090 #define abkwarn_breakpoint abkwarn_stop_here();
00091 #else
00092 #define STACK_DUMP 0;
00093 #define abkfatal_breakpoint 0;
00094 #define abkwarn_breakpoint 0;
00095 #endif
00096
00097 const char* SgnPartOfFileName(const char * fileName);
00098
00099 char* BaseFileName(char *filename);
00100
00101 #ifdef ABKDEBUG
00102
00103
00104
00105
00106
00107
00108 #define abkassert(CONDITION, ERRMESSAGE) \
00109 { if (!(CONDITION)) \
00110 { cerr << endl << (ERRMESSAGE) << endl; \
00111 cerr << " (Error in " << SgnPartOfFileName(__FILE__) \
00112 << ":" << __LINE__ <<")"<<endl; \
00113 {SeedCleaner clean_err_exit;} \
00114 abk_dump_stack(); \
00115 abkassert_stop_here(); \
00116 abort(); \
00117 } \
00118 }
00119 #else
00120 #define abkassert(CONDITION, ERRMESSAGE) ((void) 0)
00121 #endif
00122
00123
00124
00125 #ifdef ABKDEBUG
00126 #define abkassert2(CONDITION, ERR1, ERR2) \
00127 { if (!(CONDITION)) \
00128 { cerr << endl << (ERR1) << (ERR2) << endl; \
00129 cerr << " (Error in " << SgnPartOfFileName(__FILE__) \
00130 << ":" << __LINE__ <<")"<<endl; \
00131 {SeedCleaner clean_err_exit;} \
00132 abk_dump_stack(); \
00133 abkassert_stop_here(); \
00134 abort(); char * __p=(char *) 0;__p[0]=0; \
00135 } \
00136 }
00137 #else
00138 #define abkassert2(CONDITION, ERR1, ERR2) ((void) 0)
00139 #endif
00140
00141 #ifdef ABKDEBUG
00142 #define abkassert3(CONDITION, ERR1, ERR2, ERR3) \
00143 { if (!(CONDITION)) \
00144 { cerr << endl << (ERR1) << (ERR2) <<(ERR3) << endl; \
00145 cerr << " (Error in " << SgnPartOfFileName(__FILE__) \
00146 << ":" << __LINE__ <<")"<<endl; \
00147 {SeedCleaner clean_err_exit;} \
00148 abk_dump_stack(); \
00149 abkassert_stop_here(); \
00150 abort();char * __p=(char *) 0;__p[0]=0; \
00151 } \
00152 }
00153 #else
00154 #define abkassert3(CONDITION, ERR1, ERR2, ERR3) ((void) 0)
00155 #endif
00156
00157 #ifdef ABKDEBUG
00158
00159 #define abkguess(CONDITION, ERRMESSAGE) \
00160 { if (!(CONDITION)) \
00161 { cerr << endl << (ERRMESSAGE); \
00162 cerr << " in line "<<__LINE__<<", file "<<__FILE__<<endl; \
00163 abkguess_stop_here(); \
00164 } \
00165 }
00166 #else
00167 #define abkguess(CONDITION, ERRMESSAGE) ((void) 0)
00168 #endif
00169
00170 #ifdef ABKDEBUG
00171 #define abkguess2(CONDITION, ERR1,ERR2 ) \
00172 { if (!(CONDITION)) \
00173 { cerr << endl << (ERR1) << (ERR2); \
00174 cerr << " in line "<<__LINE__<<", file "<<__FILE__<<endl; \
00175 abkguess_stop_here(); \
00176 } \
00177 }
00178 #else
00179 #define abkguess2(CONDITION, ERR1, ERR2) ((void) 0)
00180 #endif
00181
00182 #ifdef ABKDEBUG
00183 #define abkguess3(CONDITION,ERR1,ERR2,ERR3) \
00184 { if (!(CONDITION)) \
00185 { cerr << endl << (ERR1) << (ERR2) << (ERR3); \
00186 cerr << " in line "<<__LINE__<<", file "<<__FILE__<<endl; \
00187 abkguess_stop_here(); \
00188 } \
00189 }
00190 #else
00191 #define abkguess3(CONDITION, ERR1, ERR2, ERR3) ((void) 0)
00192 #endif
00193
00194
00195
00196
00197 #define abkfatal(CONDITION, ERRMESSAGE) \
00198 { if (!(CONDITION)) \
00199 { cerr << endl << (ERRMESSAGE) ; \
00200 cerr<<" (Fatal error in " << SgnPartOfFileName(__FILE__) \
00201 << ":" << __LINE__ <<")"<<endl; \
00202 {SeedCleaner clean_err_exit;} \
00203 STACK_DUMP; \
00204 abkfatal_breakpoint; \
00205 abort(); char * __p=(char *) 0;__p[0]=0; \
00206 } \
00207 }
00208
00209 #define abkfatal2(CONDITION, ERR1, ERR2) \
00210 { if (!(CONDITION)) \
00211 { cerr << endl << (ERR1) << (ERR2); \
00212 cerr<<" (Fatal error in " << SgnPartOfFileName(__FILE__) \
00213 << ":" << __LINE__ <<")"<<endl; \
00214 {SeedCleaner clean_err_exit;} \
00215 STACK_DUMP; \
00216 abkfatal_breakpoint; \
00217 abort(); char * __p=(char *) 0;__p[0]=0; \
00218 } \
00219 }
00220
00221 #define abkfatal3(CONDITION, ERR1, ERR2, ERR3) \
00222 { if (!(CONDITION)) \
00223 { cerr << endl << (ERR1) << (ERR2) << (ERR3); \
00224 cerr<<" (Fatal error in " << SgnPartOfFileName(__FILE__) \
00225 << ":" << __LINE__ <<")"<<endl; \
00226 {SeedCleaner clean_err_exit;} \
00227 STACK_DUMP; \
00228 abkfatal_breakpoint; \
00229 abort(); char * __p=(char *) 0;__p[0]=0; \
00230 } \
00231 }
00232
00233
00234
00235
00236 #define abkwarn(CONDITION, ERRMESSAGE) \
00237 { if (!(CONDITION)) \
00238 { cerr << endl << (ERRMESSAGE); \
00239 cerr << " (Warning in " << SgnPartOfFileName(__FILE__) \
00240 << ":" << __LINE__ <<")"<<endl; \
00241 abkwarn_breakpoint; \
00242 } \
00243 }
00244
00245 #define abkwarn2(CONDITION, ERR1, ERR2) \
00246 { if (!(CONDITION)) \
00247 { cerr << endl << (ERR1) << (ERR2); \
00248 cerr << " (Warning in " << SgnPartOfFileName(__FILE__) \
00249 << ":" << __LINE__ <<")"<<endl; \
00250 abkwarn_breakpoint; \
00251 } \
00252 }
00253
00254 #define abkwarn3(CONDITION, ERR1, ERR2, ERR3) \
00255 { if (!(CONDITION)) \
00256 { cerr << endl << (ERR1) << (ERR2) << (ERR3); \
00257 cerr << " (Warning in " << SgnPartOfFileName(__FILE__) \
00258 << ":" << __LINE__ <<")"<<endl; \
00259 abkwarn_breakpoint; \
00260 } \
00261 }
00262 #endif