12345678910111213141516171819202122232425262728293031323334353637 |
- #ifndef __DEBUG_H
- #define __DEBUG_H
- #include "error_signals.h"
- // To turn debugging on, uncomment the following line. To turn debugging off, comment the following line.
- #define SHOULD_DEBUG
- #ifdef SHOULD_DEBUG
- #define DEBUG_FUNCTION Debug debug(__FILE__,__func__,__LINE__);
- #define DEBUG_LINE debug = __LINE__;
- #else
- #define DEBUG_FUNCTION
- #define DEBUG_LINE
- #endif
- // Use DEBUG_FUNCTION at the start of every function.
- // Use DEBUG_LINE several times during the function before and after critical pieces of code that might crash.
- // Example:
- // Debug debug(__FILE__,__func__,__LINE__);
- // debug = __LINE__;
- class Debug
- {
- public:
- int LineNumber;
- Debug(int lineNumber);
- Debug(const char *fileName,const char *functionName,int lineNumber);
- ~Debug();
- void SaveLineNumbers(); // Call SaveLineNumbers before rewinding the stack because Thread.LineNumbers points to LineNumber in other Debug objects.
- void operator=(int lineNumber) { LineNumber = lineNumber; };
- private:
- error_signals *_thread;
- };
- #endif
|