home *** CD-ROM | disk | FTP | other *** search
/ Team Palmtops 7 / Palmtops_numero07.iso / WinCE / SDKWindowsCE / AutoPC / apcsdk10.exe / data1.cab / Emulation_Include_Files / dbgapi.h < prev    next >
Encoding:
C/C++ Source or Header  |  1999-05-13  |  5.3 KB  |  151 lines

  1. /*++
  2.  
  3. Copyright (c) 1997  Microsoft Corporation
  4.  
  5. Module Name: dbgapi.h
  6.  
  7. Purpose: Debug Message and Zone APIs.
  8.  
  9. --*/
  10. #ifndef __DBGAPI_H__
  11. #define __DBGAPI_H__
  12.  
  13. #ifdef __cplusplus
  14. extern "C" {
  15. #endif
  16.     
  17. void WINAPIV NKDbgPrintfW(LPWSTR lpszFmt, ...);
  18.  
  19. /*
  20. @doc    EXTERNAL    KERNEL
  21. @struct DBGPARAM | Debug zone information structure
  22. @comm   The name of the module is used to look for zone initialization
  23.         information in the host PC registry. Zone names are displayed by
  24.         the control app (eg shell) which allows the user to dynamically
  25.         set zones.
  26. @xref   <f DEBUGREGISTER>
  27. */
  28. typedef struct _DBGPARAM {
  29.     WCHAR    lpszName[32];           // @field Name of module
  30.     WCHAR   rglpszZones[16][32];    // @field names of zones for first 16 bits
  31.     ULONG   ulZoneMask;             // @field Current zone Mask
  32. } DBGPARAM, *LPDBGPARAM;
  33.  
  34. /*
  35. @func   BOOL | DEBUGZONE | Associates a mask bit with a zone
  36. @parm   int | bitnum | Bitnumber being defined
  37. @rdesc  A boolean which is TRUE if bitnum in '1' else is FALSE
  38. @ex     Example of use is |
  39.         // associate bit 0 with an info zone
  40.         #define ZONE_INFO   DEBUGZONE(0)
  41.         // we can now use ZONE_INFO as a boolean for anything.
  42.         // We'd typically use it in a DEBUGMSG ...
  43. */
  44. #define DEBUGZONE(n)  (dpCurSettings.ulZoneMask&(0x00000001<<n))
  45.  
  46. #ifdef SHIP_BUILD
  47.  
  48. #define ERRORMSG(cond,printf_exp) ((void)0)
  49. #define RETAILMSG(cond,printf_exp) ((void)0)
  50. #define DEBUGMSG(cond,printf_exp) ((void)0)
  51. #define DBGCHK(module,exp) ((void)0)
  52. #define DEBUGCHK(exp) ((void)0)
  53. #define DEBUGREGISTER(hMod) ((void)0)
  54.  
  55. #else 
  56.  
  57. #ifdef DEBUG
  58.  
  59. /*
  60. @func BOOL | DEBUGMSG | Output a debug message conditionally
  61. @parm BOOL | cond | The condition under which the message is printed
  62. @parm <null> | (printf_exp) | A printf style expression to be output. Must be enclosed
  63.       in parentheses. Gets passed on to the <f NKDbgPrintf> function.
  64. @ex   Example of use |
  65.       DEBUGMSG(ZONE_INFO, (L"FOODLL: Entered func1. Param 1 = %d\r\n", par1));
  66. @xref <f RETAILMSG> <tab> <f ERRORMSG> <tab> <f NKDbgPrintf>
  67. */
  68. #define DEBUGMSG(cond,printf_exp)   \
  69.    ((void)((cond)?(NKDbgPrintfW printf_exp),1:0))
  70. #define DBGCHK(module,exp) \
  71.    ((void)((exp)?1:(          \
  72.        NKDbgPrintfW ( TEXT("%s: DEBUGCHK failed in file %s at line %d \r\n"), \
  73.                  (LPWSTR)module, TEXT(__FILE__) ,__LINE__ ),    \
  74.        DebugBreak(), \
  75.        0  \
  76.    )))
  77. /*
  78. @func BOOL | DEBUGCHK | Asserts an expression
  79. @parm BOOL | exp | Expression to be asserted
  80. @comm If the expression is false, this will cause a DebugBreak to be hit which
  81.       will cause you to enter the debugger if you are running with one. It will
  82.       also give you the line number and file name where the assert failed.
  83. */
  84. #define DEBUGCHK(exp) DBGCHK(dpCurSettings.lpszName, exp)
  85. extern  DBGPARAM    dpCurSettings;
  86. /*
  87. @func  BOOL | DEBUGREGISTER | Registers debug settings for a process / module
  88. @parm  HINSTANCE | hInstance | If target is a module this is it's hInstance. If
  89.        target is a process this should be NULL.
  90. @comm  This simply calls through to <f RegisterDebugZones>. It assumes that
  91.        there is a variable of name <b dpCurSettings> visible in the code.
  92. */
  93. BOOL RegisterDbgZones(HMODULE hMod, LPDBGPARAM lpdbgparam);
  94. #define DEBUGREGISTER(hMod)  RegisterDbgZones(hMod, &dpCurSettings)
  95. #else
  96.  
  97. #define DEBUGMSG(cond,printf_exp) ((void)0)
  98. #define DBGCHK(module,exp) ((void)0)
  99. #define DEBUGCHK(exp) ((void)0)
  100. #define DEBUGREGISTER(hMod) ((void)0)
  101.  
  102. #endif
  103.  
  104. /*
  105. @func BOOL | RETAILMSG | Output a message in retail builds
  106. @parm BOOL | cond | The condition under which the message is printed
  107. @parm <null> | (printf_exp) | A printf style expression to be output. Must be enclosed
  108.       in parentheses. This is simply passed in to the <f NKDbgPrintf> function.
  109. @comm This should be used in a very limited fashion since it can increase
  110.       the size of your retail build.
  111. @ex   Example of use |
  112.       RETAILMSG(x==y, (L"FOODLL: Wierdness. x===y = %d\r\n", x));
  113. @xref <f DEBUGMSG> <tab> <f ERRORMSG> <tab> <f NKDbgPrintf>
  114. */
  115. #define RETAILMSG(cond,printf_exp)   \
  116.    ((cond)?(NKDbgPrintfW printf_exp),1:0)
  117.  
  118. /*
  119. @func BOOL | ERRORMSG | Output an error msg
  120. @parm BOOL | cond | The condition under which the message is printed
  121. @parm <null> | (printf_exp) | A printf style expression to be output. Must be enclosed
  122.       in parentheses. This is passed in to the <f NKDbgPrintf> function.
  123. @comm Very similar to <f RETAILMSG> except that this will prefix the message
  124.       with a big bold ERROR and give the file name & line number of the error
  125.       also.
  126. @ex   Example of use |
  127.       ERRORMSG(x==y, (L"FOODLL: Wierdness. x===y = %d\r\n", x));
  128. @xref <f DEBUGMSG> <tab> <f RETAILMSG> <tab> <f NKDbgPrintf>
  129. */
  130. #define ERRORMSG(cond,printf_exp)     \
  131.    ((cond)?(NKDbgPrintfW(TEXT("ERROR: %s line %d: "),TEXT(__FILE__),__LINE__), NKDbgPrintfW printf_exp),1:0)
  132.  
  133. #endif
  134.  
  135. // some alternate ways to get to these
  136. #define ASSERTMSG(msg, exp) (DEBUGMSG(!exp,(msg)),DBGCHK(TEXT("Unknown"),exp))
  137. #define ASSERT( exp )   DBGCHK(TEXT("Unknown"), exp)
  138. #define ASSERT_IMPLIES( cond, exp ) ASSERT( !(cond) || (exp) )
  139. #ifdef DEBUG
  140. #define VERIFY(exp)  ASSERT(exp)
  141. #else
  142. #define VERIFY(exp)  ((void)(exp))
  143. #endif
  144.  
  145. #ifdef __cplusplus
  146. }
  147. #endif
  148.     
  149. #endif
  150.  
  151.