Source code of Windows XP (NT5)
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

207 lines
7.7 KiB

  1. #ifdef MOS
  2. #include <_DEBUG.h>
  3. #endif
  4. #ifdef __cplusplus
  5. extern "C" {
  6. #endif
  7. #ifndef ORKIN
  8. #define ORKIN
  9. /*****************************************************************************
  10. * *
  11. * ORKIN.H *
  12. * *
  13. * Copyright (C) Microsoft Corporation 1991. *
  14. * All Rights reserved. *
  15. * *
  16. ******************************************************************************
  17. * *
  18. * Module Description: DEBUGGING LIBRARY *
  19. * *
  20. ******************************************************************************
  21. * *
  22. * Current Owner: DAVIDJES *
  23. * *
  24. ******************************************************************************
  25. * *
  26. * Revision History: *
  27. * -- Dec 1991 Created *
  28. * -- Mar 1992 Waynej Added assert description string *
  29. * *
  30. * *
  31. ******************************************************************************
  32. * *
  33. * Known Bugs: NONE *
  34. * *
  35. ******************************************************************************
  36. * *
  37. * How it could be improved: *
  38. * *
  39. *****************************************************************************/
  40. //
  41. // This only assumes you have included <windows.h> before <orkin>
  42. //
  43. #if defined(_DEBUG)
  44. #if defined(_WIN32) || defined(_MAC)
  45. #ifndef _loadds
  46. #define _loadds
  47. #endif
  48. #endif
  49. #ifndef EXPORT_API
  50. #define EXPORT_API
  51. #endif
  52. //******************
  53. //
  54. // ASSERT
  55. //
  56. // usage: assert(c) where the condition c is any expression of type BOOL
  57. //
  58. // notes: An assertion is a logical proposition about the state space of
  59. // the program at a particular point in program execution. Evaluation of
  60. // the condition MUST NOT have side effects! (Otherwise your _DEBUG and
  61. // nondebug programs have different semantics). Do not expect any value
  62. // back from the assert. For example, don't do "if (assert(f)) foo()"
  63. //
  64. // A false condition implies an inconsistent or invalid program state.
  65. // If this occurs the assertion routine will display a message box giving
  66. // the file and line number of the failed assert. The message box will
  67. // include options to ignore and continue or break into the debugger.
  68. //
  69. // When you break in the debugger you will be at an INT 3 instruction.
  70. // Increment the IP register to step over the INT 3 then step out of the
  71. // assertion routine. You will return to the statement immediately following
  72. // the failed assert. All symbolic information should be available.
  73. //
  74. // Use asserts liberally! The time they take to insert will be saved
  75. // tenfold over the time that would otherwise be required later to
  76. // track down pesky bugs.
  77. //
  78. // The assertion routine is defined in ASSERT.C
  79. //
  80. //*******************
  81. #ifdef MOS
  82. // Reroute to stuff in _DEBUG.h
  83. #define assert(x) Assert((int)(x))
  84. #else
  85. extern void far pascal _assertion(WORD wLine, LPSTR lpstrFile);
  86. #define assert(f) ((f)?(void)0:_assertion(__LINE__,s_aszModule))
  87. #define Assert(f) assert(f)
  88. #define ITASSERT(f) assert(f)
  89. #endif
  90. //*******************
  91. //
  92. // DEBUGGING OUTPUT
  93. //
  94. // the following was ripped off from the \\looney\brothers skelapp2 project:
  95. //
  96. // InitializeDebugOutput(szAppName):
  97. //
  98. // Read _DEBUG level for this application (named <szAppName>) from
  99. // win.ini's [_DEBUG] section, which should look like this:
  100. //
  101. // [_DEBUG]
  102. // location=aux ; use OutputDebugString() to output
  103. // foobar=2 ; this app has _DEBUG level 2
  104. // blorg=0 ; this app has _DEBUG output disabled
  105. //
  106. // If you want _DEBUG output to go to a file instead of to the AUX
  107. // device (or the debugger), use "location=>filename". To append to
  108. // the file instead of rewriting the file, use "location=>>filename".
  109. //
  110. // If _DEBUG is not #define'd, then the call to InitializeDebugOutput()
  111. // generates no code,
  112. //
  113. // TerminateDebugOutput():
  114. //
  115. // End _DEBUG output for this application. If _DEBUG is not #define'd,
  116. // then the call to InitializeDebugOutput() generates no code,
  117. //
  118. // DPF(szFormat, args...)
  119. // CPF
  120. //
  121. // If debugging output for this applicaton is enabled (see
  122. // InitializeDebugOutput()), print _DEBUG output specified by format
  123. // string <szFormat>, which may contain wsprintf()-style formatting
  124. // codes corresponding to arguments <args>. Example:
  125. //
  126. // DPF("in WriteFile(): szFile='%s', dwFlags=0x%08lx\n",
  127. // CPF (LSPTR) szFile, dwFlags);
  128. //
  129. // If the DPF statement occupies more than one line, then all
  130. // lines following the first line should have CPF before any text.
  131. // Reason: if _DEBUG is #define'd, DPF is #define'd to call _DPFx()
  132. // and CPF is #define'd to nothing, but if _DEBUG is not #define'd then
  133. // DPF and CPF are both #define'd to be // (comment to end of line).
  134. //
  135. // DPF2(szFormat, args...)
  136. // DPF3(szFormat, args...)
  137. // DPF4(szFormat, args...)
  138. //
  139. // Like DPF, but only output the _DEBUG string if the _DEBUG level for
  140. // this application is at least 2, 3, or 4, respectively.
  141. //
  142. // These output routines are defined in BUGOUT.C
  143. //
  144. //*******************
  145. /* _DEBUG printf macros */
  146. #define DPF _DPF1
  147. #define DPF1 _DPF1
  148. #define DPF1 _DPF1
  149. #define DPF2 _DPF2
  150. #define DPF3 _DPF3
  151. #define DPF4 _DPF4
  152. #define CPF
  153. /* prototypes */
  154. #define InitializeDebugOutput _InitializeDebugOutput
  155. #define TerminateDebugOutput _TerminateDebugOutput
  156. void FAR PASCAL EXPORT_API _InitializeDebugOutput(LPSTR szAppName);
  157. void FAR PASCAL EXPORT_API _TerminateDebugOutput(void);
  158. void FAR EXPORT_API __cdecl _DPF1(LPSTR szFormat, ...);
  159. void FAR EXPORT_API __cdecl _DPF2(LPSTR szFormat, ...);
  160. void FAR EXPORT_API __cdecl _DPF3(LPSTR szFormat, ...);
  161. void FAR EXPORT_API __cdecl _DPF4(LPSTR szFormat, ...);
  162. #else
  163. //******************
  164. //
  165. // If debugging is not turned on we will define all debugging calls
  166. // into nothingness...
  167. //
  168. //******************
  169. #define assert(f)
  170. #define Assert(f)
  171. #define ITASSERT(f)
  172. /* _DEBUG printf macros */
  173. #define DPF 0; / ## /
  174. #define DPF1 0;
  175. #define DPF2 0; / ## /
  176. #define DPF3 0; / ## /
  177. #define DPF4 0; / ## /
  178. #define CPF / ## /
  179. /* stubs for debugging function prototypes */
  180. #define InitializeDebugOutput(szAppName) 0
  181. #define TerminateDebugOutput() 0
  182. #endif // _DEBUG
  183. #endif // orkin
  184. #ifdef __cplusplus
  185. }
  186. #endif