19#define __FUNCTION_LOCATION__ std::string(__FILE__) + ": " + std::string(__FUNCTION__)
23#define DEBUG_DISPLAY_ON
24#define DEBUG_DISPLAY_OFF
25#define SET_DEBUG_LEVEL(a) MDebug::setLevelNotEnabled(a)
27#define PROFILE(id, a, b) \
29 if(b == MAIA_DEBUG_TRACE_IN) { \
30 Profile::s_functionTimings[id].in(); \
31 } else if(b == MAIA_DEBUG_TRACE_OUT) { \
32 Profile::s_functionTimings[id].out(); \
40 static MInt timingId = Profile::getTimingId(FUN_); \
41 maia::debug::Tracer USE_ONLY_ONCE_PER_METHOD(FUN_, LOC_, timingId, false)
43#define TRACE_PROFILE() \
44 static MInt timingId = Profile::getTimingId(FUN_); \
45 maia::debug::Tracer USE_ONLY_ONCE_PER_METHOD(FUN_, LOC_, timingId, true)
47#elif defined MAIA_DEBUG_FUNCTION
49#define DEBUG_DISPLAY_ON MDebug::displayOn();
50#define DEBUG_DISPLAY_OFF MDebug::displayOff();
51#define SET_DEBUG_LEVEL(a) MDebug::setLevel(a);
54 std::ostringstream message; \
56 MDebug::maiaprint(message.str(), b); \
58#define PROFILE(id, a, b)
59#define TRACE() maia::debug::Tracer USE_ONLY_ONCE_PER_METHOD(FUN_, LOC_)
60#define TRACE_PROFILE() TRACE()
64#define DEBUG_DISPLAY_ON
65#define DEBUG_DISPLAY_OFF
66#define SET_DEBUG_LEVEL(a) MDebug::setLevelNotEnabled(a)
68#define PROFILE(id, a, b)
70#define TRACE_PROFILE()
75#ifdef MAIA_DEBUG_FUNCTION
78 std::cerr << "DEBUG: VALUE: '" << #a << "' = '" << a << "' at " << AT_ << std::endl; \
81#define DOUT_IF(condition, a) \
84 std::cerr << "DEBUG: VALUE: '" << #a << "' = '" << a << "' at " << AT_ << std::endl; \
90 std::cerr << "DEBUG: DOMAIN: " << globalDomainId() << "; LOCATION: " << AT_ << std::endl; \
94 std::cerr << "DEBUG: " << globalDomainId() << "; MESSAGE: '" << a << "' at " << AT_ << std::endl; \
102#define DOUT_IF(condition, a) \
115 MAIA_DEBUG_ASSERTION = 1,
117 MAIA_DEBUG_ALLOCATION = 4,
118 MAIA_DEBUG_TRACE = 8,
119 MAIA_DEBUG_TRACE_IN = 16,
120 MAIA_DEBUG_TRACE_OUT = 32,
121 MAIA_DEBUG_LEVEL1 = 64,
122 MAIA_DEBUG_LEVEL2 = 128,
123 MAIA_DEBUG_LEVEL3 = 256,
124 MAIA_DEBUG_LEVEL4 = 512,
125 MAIA_DEBUG_LEVEL5 = 1024,
126 MAIA_DEBUG_USER1 = 2048,
127 MAIA_DEBUG_USER2 = 4096,
128 MAIA_DEBUG_USER3 = 8192,
129 MAIA_DEBUG_USER4 = 16384,
130 MAIA_DEBUG_USER5 = 32768
210 if(debugLevel != 0) {
211 cerr0 <<
"WARNING: trying to set debug level " << debugLevel <<
" but MAIA_DEBUG_FUNCTION is not enabled."
225 if(adiv.quot == 1 &&
a == (
MUint)debugLevel) {
226 if(debugLevel == MAIA_DEBUG_TRACE_OUT) {
231 if(debugLevel == MAIA_DEBUG_TRACE_IN) {
239 }
while(adiv.rem != 0);
244#if(defined(MAIA_DEBUG_FUNCTION) || defined(MAIA_PROFILING))
253 PROFILE(timingId, fun, MAIA_DEBUG_TRACE_IN);
255 DEBUG(fun +
" entry (" + loc +
")", MAIA_DEBUG_TRACE_IN);
258 DEBUG(fun +
" entry (" + loc +
")", MAIA_DEBUG_TRACE_IN);
266 DEBUG(
m_fun <<
" return", MAIA_DEBUG_TRACE_OUT);
269 DEBUG(
m_fun <<
" return", MAIA_DEBUG_TRACE_OUT);
The DEBUG class for the maia.
static void setLevelNotEnabled(const MInt debugLevel)
static const MInt m_minLevel
static void maiaerror(MString message, MDebugLevel debugLevel)
static MString debugMessage
static std::basic_string< char > m_traceSpaces
static const MInt m_maxLevel
static void maiaprint(const MString &message, MDebugLevel debugLevel)
static void setLevel(MInt debugLevel)
enum { MAIA_DEBUG_ASSERTION=1, MAIA_DEBUG_IO=2, MAIA_DEBUG_ALLOCATION=4, MAIA_DEBUG_TRACE=8, MAIA_DEBUG_TRACE_IN=16, MAIA_DEBUG_TRACE_OUT=32, MAIA_DEBUG_LEVEL1=64, MAIA_DEBUG_LEVEL2=128, MAIA_DEBUG_LEVEL3=256, MAIA_DEBUG_LEVEL4=512, MAIA_DEBUG_LEVEL5=1024, MAIA_DEBUG_USER1=2048, MAIA_DEBUG_USER2=4096, MAIA_DEBUG_USER3=8192, MAIA_DEBUG_USER4=16384, MAIA_DEBUG_USER5=32768 } MDebugLevel
This enum holds the error levels of the DEBUG class.
const MString const MString & message
MInt globalDomainId()
Return global domain id.
std::basic_string< char > MString
Namespace for auxiliary functions/classes.
Tracer(const MString &fun, const MString &loc, const MInt timingId, const MBool profile=false)