debug.h
Upload User: xhy777
Upload Date: 2007-02-14
Package Size: 24088k
Code Size: 4k
Category:

Windows Kernel

Development Platform:

Visual C++

  1. #define NOSHELLDEBUG // don't take shell versions of this
  2. // NOTE: You can #define your own DM_* values using bits in the HI BYTE
  3.                                                                
  4. #define DM_TRACE    0x0001      // Trace messages              
  5. #define DM_WARNING  0x0002      // Warning                     
  6. #define DM_ERROR    0x0004      // Error                       
  7. #define DM_ASSERT   0x0008      // Assertions                  
  8.                                                                
  9. // NOTE: Default debug mask is 0x00ff (show everything)        
  10. //                                                             
  11. // Inside debugger, you can modify wDebugMask variable.        
  12. //                                                             
  13. // Set debug mask; returning previous.                         
  14. //                                                             
  15. UINT SetDebugMask(UINT mask);                           
  16.                                                                
  17. // Get debug mask.                                             
  18. //                                                             
  19. UINT GetDebugMask();                                    
  20.                                                                
  21. // Use this macro to declare message text that will be placed  
  22. // in the CODE segment (useful if DS is getting full)          
  23. //                                                             
  24. // Ex: DBGTEXT(szMsg, "Invalid whatever: %d");               
  25. //                                                             
  26. #define DBGTEXT(sz, msg)      static const char sz[] = msg;                    
  27.                                                                
  28. #ifdef _DEBUG
  29. // Assert(f)  -- Generate "assertion failed in line x of file.c"
  30. //               message if f is NOT true.
  31. //
  32. // AssertMsg(f, msg, args...)  -- Generate wsprintf-formatted msg w/params
  33. //                          if f is NOT true.                  
  34. //                                                             
  35. // DebugMsg(mask, msg, args...) -                              
  36. //         Generate wsprintf-formatted msg using               
  37. //         specified debug mask.  System debug mask
  38. //         governs whether message is output.
  39. //                                                             
  40. void AssertFailed(LPCSTR szFile, int line);
  41. #define Assert(f)                           
  42.     {                                       
  43.         DBGTEXT(szFile, __FILE__);          
  44.         if (!(f))                           
  45.             AssertFailed(szFile, __LINE__); 
  46.     }                                       
  47. #define AssertE(f) Assert(f)                
  48.                                                                
  49. void __cdecl _AssertMsg(BOOL f, LPCSTR pszMsg, ...);        
  50. #define AssertMsg   _AssertMsg                                 
  51.                                                                
  52. void __cdecl _DebugMsg(UINT mask, LPCSTR psz, ...);        
  53. #define DebugMsg    _DebugMsg                                  
  54.                                                                
  55. #else
  56. // retail versions to produce no code, no data
  57.                                                                
  58. #define Assert(f)                                              
  59. #define AssertE(f)      (f)                                    
  60. #define AssertMsg   1 ? (void)0 : (void)                       
  61. #define DebugMsg    1 ? (void)0 : (void)                       
  62.                                                                
  63. #endif