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
00041
00042
00043
00044
00045
00046
00047
00048
00049
00050
00051
00052 #ifndef EXCTRACE_H__
00053 #define EXCTRACE_H__
00054
00055 #include <stdio.h>
00056 #include <stdlib.h>
00057 #include <iostream>
00058 #include <fstream>
00059 #ifndef GCC_295
00060 #include <ostream>
00061 #endif
00062 #include <string.h>
00063 #include <time.h>
00064 #include <sys/timeb.h>
00065 #include <sys/types.h>
00066
00067 #include <iostream>
00068 #include <strstream>
00069 #ifdef UNIX_SRC
00070 #include <typeinfo>
00071 #else
00072 #include <typeinfo.h>
00073 #endif
00074
00075
00076
00077
00078
00079
00080
00081
00082
00083
00084
00085
00086
00087
00088
00089
00090
00091
00092
00093
00094
00095
00096
00097 #ifndef UNIX_SRC
00098
00099
00100 #define DEBUG
00101 #endif
00102
00103 #define EXC throw 1;
00104
00105
00106 #ifdef NORMAL
00107 #define Guard(function)
00108 #define UnGuard
00109 #define Trace
00110 #define Error
00111 #else
00112 #ifdef LOG
00113 static std::ofstream logfile("callstack.log",std::ios::app);\
00114 #define Guard(function) static char * __FUNCTION_NAME__ = #function;\
00115 try {
00116 #define UnGuard } catch (...) {\
00117 time_t tt;struct tm *ttb;tt = time(NULL);ttb = localtime(&tt);\
00118 logfile<<"*********************CALL STACK*********************"<<std::endl;\
00119 logfile<<"* Date : "<<asctime(ttb);\
00120 logfile<<"* Module : "<<__FUNCTION_NAME__<<std::endl;\
00121 logfile<<"* Line : "<<__LINE__<<std::endl;\
00122 logfile<<"* File : "<<__FILE__<<std::endl;\
00123 logfile<<"* Make date : "<<__DATE__<<" "<<__TIME__<<std::endl;\
00124 logfile<<"***************************************************"<<std::endl;\
00125 throw; }
00126 #elif defined DEBUG
00127 #define Guard(function) static char * __FUNCTION_NAME__ = #function;\
00128 try {
00129 #define UnGuard } catch (...) {\
00130 time_t tt;struct tm *ttb;tt = time(NULL);ttb = localtime(&tt);\
00131 std::cout<<"*********************CALL STACK*********************"<<std::endl;\
00132 std::cout<<"* Date : "<<asctime(ttb);\
00133 std::cout<<"* Module : "<<__FUNCTION_NAME__<<std::endl;\
00134 std::cout<<"* Line : "<<__LINE__<<std::endl;\
00135 std::cout<<"* File : "<<__FILE__<<std::endl;\
00136 std::cout<<"* Make date : "<<__DATE__<<" "<<__TIME__<<std::endl;\
00137 std::cout<<"***************************************************"<<std::endl;\
00138 throw; }
00139 #elif defined TRACE
00140 #define Guard(function) static char * __FUNCTION_NAME__ = #function;\
00141 std::cout<<">>>> Module : "<<__FUNCTION_NAME__<<std::endl;
00142 #define UnGuard std::cout<<"<<<< Module : "<<__FUNCTION_NAME__<<std::endl;
00143
00144
00145 #elif defined TRACETIME
00146 static std::ofstream logfile("TraceTime.log",std::ios::out);
00147 #define Guard(function) static char * __FUNCTION_NAME__ = #function;\
00148 __timeb64 ltime,ltime2;\
00149 logfile<<"Enter function : "<<__FUNCTION_NAME__<<std::endl;\
00150 _ftime64(<ime );
00151 #define UnGuard _ftime64(<ime2 );\
00152 logfile<<"Time in func : "<<ltime2.millitm-ltime.millitm <<std::endl;\
00153 logfile<<"Leave function : "<<__FUNCTION_NAME__<<std::endl;
00154
00155 #endif //TRACETIME
00156
00157
00158 #define Trace(why) static char * __WHY__ = #why;\
00159 time_t tt;struct tm *ttb;tt = time(NULL);ttb = localtime(&tt);\
00160 std::cout<<"***********************TRACE***********************"<<std::endl;\
00161 std::cout<<"* Date : "<<asctime(ttb);\
00162 std::cout<<"* Module : "<<__FUNCTION_NAME__<<std::endl;\
00163 std::cout<<"* Line : "<<__LINE__<<std::endl;\
00164 std::cout<<"* File : "<<__FILE__<<std::endl;\
00165 std::cout<<"* Make date : "<<__DATE__<<" "<<__TIME__<<std::endl;\
00166 std::cout<<"* Cause : "<<__WHY__<<std::endl;\
00167 std::cout<<"* Error : "<<errno<<std::endl;\
00168 std::cout<<"***************************************************"<<std::endl;
00169
00170 #endif // !NORMAL
00171
00172
00173 #endif // EXCTRACE_H__