Debug.h 644 B

12345678910111213141516171819202122
  1. #ifndef __DEBUG_H
  2. #define __DEBUG_H
  3. class Debug
  4. {
  5. public:
  6. static const char *GetFileName();
  7. static int GetLineNumber();
  8. static void SetFileAndLine(const char *file,int lineNumber);
  9. // Linux uses signals to
  10. // Display an error from a segmentation fault.
  11. static void ErrorHandler(int signum);
  12. // Add error handlers for segmenation faults not caught with try/catch.
  13. static void AddErrorHandler();
  14. // Make sure the signals don't point to some function that might not exist in the future.
  15. static void RemoveErrorHandler();
  16. };
  17. // Turn this on to debug segmentation faults:
  18. #define DEBUG Debug::SetFileAndLine(__FILE__,__LINE__)
  19. #endif