00001
00002
00003
00004
00005
00006
00007
00008 #ifndef __Debugging_h_
00009 #define __Debugging_h_
00010
00011
00012
00013
00014
00015
00016 #include "Tools/Debugging/DebugKeyTable.h"
00017 #include "Tools/MessageQueue/OutMessage.h"
00018 #include "Tools/Debugging/DebugRequest.h"
00019 #include "Tools/Debugging/DebugDataTable.h"
00020
00021
00022
00023
00024
00025
00026
00027 void initDebugging(OutMessage* queue, DebugKeyTable* table, DebugRequestTable* debugRequestTable);
00028
00029
00030
00031
00032 OutMessage& getDebugOut();
00033
00034
00035
00036
00037 DebugKeyTable& getDebugKeyTable();
00038
00039
00040
00041
00042 DebugRequestTable& getDebugRequestTable();
00043
00044
00045 #ifdef NDEBUG
00046
00047 #define INFO(key,type,format,expression)
00048 #define OUTPUT(type,format,expression)
00049 #define WATCH(key,type,format,expression)
00050 #define DEBUG_RESPONSE(description, expression)
00051 #define DEBUG_RESPONSE_NOT(description, expression) { expression }
00052 #define NOT_POLLABLE_DEBUG_RESPONSE(description, expression)
00053 #define DEBUG_CHECK_CRASH
00054
00055 #else //NDEBUG
00056
00057
00058
00059
00060
00061
00062
00063
00064
00065
00066
00067
00068
00069
00070
00071
00072 #define INFO(key,type,format,expression) \
00073 if (getDebugKeyTable().isActive(DebugKeyTable::key)) {\
00074 getDebugOut().format << expression;\
00075 getDebugOut().finishMessage(type);\
00076 }\
00077
00078
00079
00080
00081
00082
00083
00084
00085
00086
00087
00088
00089
00090
00091
00092 #define OUTPUT(type,format,expression) \
00093 { getDebugOut().format << expression;\
00094 getDebugOut().finishMessage(type); }
00095
00096 #define DEBUG_RESPONSE(description, expression) \
00097 {\
00098 if(getDebugRequestTable().poll && getDebugRequestTable().notYetPolled(description)) \
00099 { \
00100 OUTPUT(idDebugResponse, text, description << \
00101 int(getDebugRequestTable().isActive(description) && !getDebugRequestTable().once(description))); \
00102 } \
00103 if(getDebugRequestTable().isActive(description)) \
00104 { \
00105 if(getDebugRequestTable().once(description)) \
00106 getDebugRequestTable().disable(description); \
00107 expression \
00108 } \
00109 }
00110
00111 #define NOT_POLLABLE_DEBUG_RESPONSE(description, expression) \
00112 {\
00113 if(getDebugRequestTable().isActive(description)) \
00114 { \
00115 if(getDebugRequestTable().once(description)) \
00116 getDebugRequestTable().disable(description); \
00117 expression \
00118 } \
00119 }
00120
00121 #define DEBUG_RESPONSE_NOT(description, expression) \
00122 {\
00123 if(getDebugRequestTable().poll && getDebugRequestTable().notYetPolled(description)) \
00124 { \
00125 OUTPUT(idDebugResponse, text, description << \
00126 int(getDebugRequestTable().isActive(description) && !getDebugRequestTable().once(description))); \
00127 } \
00128 if(! (getDebugRequestTable().isActive(description))) \
00129 { \
00130 if(getDebugRequestTable().once(description)) \
00131 getDebugRequestTable().disable(description); \
00132 expression \
00133 } \
00134 }
00135
00136 #if defined(_WIN32) && !defined(SIMROBOT)
00137
00138
00139
00140
00141
00142
00143 #define WATCH(key,type,format,expression) \
00144 OUTPUT(type,format,expression);
00145
00146
00147 #else
00148
00149
00150
00151
00152
00153
00154 #define WATCH(key,type,format,expression) \
00155 INFO(key,type,format,expression);
00156
00157 #endif
00158
00159 #include <iostream>
00160
00161 #define DEBUG_CHECK_CRASH { if (SystemCall::getCurrentSystemTime () - entryTime > 2000) {std::cout << "breakpoint in " << __FILE__ << ":" << __LINE__ << "; \n was executed more than 2 seconds\n"; while (true); }; };
00162
00163 #endif //NDEBUG
00164
00165 #endif //__Debugging_h_