Leaked source code of windows server 2003
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.

685 lines
18 KiB

  1. //+---------------------------------------------------------------------------
  2. // Copyright (C) 1991, Microsoft Corporation.
  3. //
  4. // File: DEBNOT.h
  5. //
  6. // Contents: Private project-wide Win 4 definitions
  7. //
  8. // History: 23-Jul-91 KyleP Created.
  9. // 15-Oct-91 KevinRo Major changes and comments added
  10. // 18-Oct-91 vich Consolidated win4p.hxx
  11. // 22-Oct-91 SatoNa Added SHLSTRICT
  12. // 29-Apr-92 BartoszM Moved from win4p.h
  13. // 3-Jun-92 BruceFo Added SMUISTRICT
  14. // 17-Dec-92 AlexT Moved UN..._PARM out of DEVL==1
  15. // 30-Sep-93 KyleP DEVL obsolete
  16. //
  17. //----------------------------------------------------------------------------
  18. #ifndef __DEBNOT_H__
  19. #define __DEBNOT_H__
  20. #include <stdarg.h>
  21. //----------------------------------------------------------------------------
  22. // Parameter Macros
  23. //
  24. // To avoid compiler warnings for unimplemented functions, use
  25. // UNIMPLEMENTED_PARM(x) for each unreferenced parameter. This will
  26. // later be defined to nul to reveal functions that we forgot to implement.
  27. //
  28. // For functions which will never use a parameter, use
  29. // UNREFERENCED_PARM(x).
  30. //
  31. #define UNIMPLEMENTED_PARM(x) (x)
  32. #define UNREFERENCED_PARM(x) (x)
  33. //----------------------------------------------------------------------------
  34. //
  35. // New STRICT defines should be added in two places below:
  36. //
  37. // 1) Add the following within the ifdef ALLSTRICT/endif:
  38. //
  39. // #ifndef xxSTRICT
  40. // # define xxSTRICT
  41. // #endif
  42. //
  43. // These entries are in alphabetical order.
  44. //
  45. // 2) Add the following to the #if clause that defines ANYSTRICT:
  46. //
  47. // #if ... || defined(xxSTRICT) || ...
  48. //
  49. // so that ANYSTRICT is defined if any of the STRICT defines are.
  50. //
  51. #if (DBG == 1) || (OFSDBG == 1)
  52. # ifndef CATSTRICT
  53. # define CATSTRICT
  54. # endif
  55. # ifndef CISTRICT
  56. # define CISTRICT
  57. # endif
  58. # ifndef CMSSTRICT
  59. # define CMSSTRICT
  60. # endif
  61. # ifndef DLOSSTRICT
  62. # define DLOSSTRICT
  63. # endif
  64. # ifndef EVSTRICT
  65. # define EVSTRICT
  66. # endif
  67. # ifndef ICLSTRICT
  68. # define ICLSTRICT
  69. # endif
  70. # ifndef INSSTRICT
  71. # define INSSTRICT
  72. # endif
  73. # ifndef JWSTRICT
  74. # define JWSTRICT
  75. # endif
  76. # ifndef NSSTRICT
  77. # define NSSTRICT
  78. # endif
  79. # ifndef OLSTRICT
  80. # define OLSTRICT
  81. # endif
  82. # ifndef OMSTRICT
  83. # define OMSTRICT
  84. # endif
  85. # ifndef REPLSTRICT
  86. # define REPLSTRICT
  87. # endif
  88. # ifndef SHLSTRICT
  89. # define SHLSTRICT
  90. # endif
  91. # ifndef SLSTRICT
  92. # define SLSTRICT
  93. # endif
  94. # ifndef SMUISTRICT
  95. # define SMUISTRICT
  96. # endif
  97. # ifndef SOMSTRICT
  98. # define SOMSTRICT
  99. # endif
  100. # ifndef VCSTRICT
  101. # define VCSTRICT
  102. # endif
  103. # ifndef VQSTRICT
  104. # define VQSTRICT
  105. # endif
  106. # ifndef WMASTRICT
  107. # define WMASTRICT
  108. # endif
  109. #endif // (DBG == 1) || (OFSDBG == 1)
  110. //
  111. // ANYSTRICT
  112. //
  113. #if defined(CATSTRICT) || \
  114. defined(CISTRICT) || \
  115. defined(CMSSTRICT) || \
  116. defined(DLOSSTRICT)|| \
  117. defined(ICLSTRICT) || \
  118. defined(INSSTRICT) || \
  119. defined(JWSTRICT) || \
  120. defined(NSSTRICT) || \
  121. defined(OLSTRICT) || \
  122. defined(OMSTRICT) || \
  123. defined(REPLSTRICT)|| \
  124. defined(SHLSTRICT) || \
  125. defined(SLSTRICT) || \
  126. defined(SMUISTRICT)|| \
  127. defined(SOMSTRICT) || \
  128. defined(VCSTRICT) || \
  129. defined(VQSTRICT) || \
  130. defined(WMASTRICT)
  131. # define ANYSTRICT
  132. #endif
  133. #if (DBG != 1 && OFSDBG != 1) && defined(ANYSTRICT)
  134. #pragma message BUGBUG: Asserts are defined in a RETAIL build...
  135. #endif
  136. #if defined(WIN32)
  137. #ifndef DEBFAR
  138. #define DEBFAR
  139. #endif
  140. #include <windef.h>
  141. #if WIN32 > 200
  142. #include <winnot.h>
  143. #endif
  144. #else
  145. #ifndef DEBFAR
  146. #define DEBFAR __far
  147. #endif
  148. #endif
  149. #ifndef EXPORTDEF
  150. #define EXPORTDEF
  151. #endif
  152. #ifndef EXPORTIMP
  153. #define EXPORTIMP
  154. #endif
  155. #ifndef EXPORTED
  156. #define EXPORTED _cdecl
  157. #endif
  158. #ifndef APINOT
  159. #ifdef _X86_
  160. #define APINOT _stdcall
  161. #else
  162. #define APINOT _cdecl
  163. #endif
  164. #endif
  165. //
  166. // DEBUG -- DEBUG -- DEBUG -- DEBUG -- DEBUG
  167. //
  168. #if (DBG == 1) || (OFSDBG == 1)
  169. //
  170. // Debug print functions.
  171. //
  172. #ifdef __cplusplus
  173. extern "C" {
  174. # define EXTRNC "C"
  175. #else
  176. # define EXTRNC
  177. #endif
  178. // vdprintf should only be called from xxDebugOut()
  179. EXPORTDEF void APINOT
  180. vdprintf(
  181. unsigned long ulCompMask,
  182. char const DEBFAR *pszComp,
  183. char const DEBFAR *ppszfmt,
  184. va_list ArgList);
  185. #define _Win4Assert Win4AssertEx
  186. EXPORTDEF void APINOT
  187. Win4AssertEx(
  188. char const DEBFAR *pszFile,
  189. int iLine,
  190. char const DEBFAR *pszMsg);
  191. EXPORTDEF int APINOT
  192. PopUpError(
  193. char const DEBFAR *pszMsg,
  194. int iLine,
  195. char const DEBFAR *pszFile);
  196. #define _SetWin4InfoLevel SetWin4InfoLevel
  197. EXPORTDEF unsigned long APINOT
  198. SetWin4InfoLevel(
  199. unsigned long ulNewLevel);
  200. EXPORTDEF unsigned long APINOT
  201. SetWin4InfoMask(
  202. unsigned long ulNewMask);
  203. #define _SetWin4AssertLevel SetWin4AssertLevel
  204. EXPORTDEF unsigned long APINOT
  205. SetWin4AssertLevel(
  206. unsigned long ulNewLevel);
  207. EXPORTDEF unsigned long APINOT
  208. SetWin4ExceptionLevel(
  209. unsigned long ulNewLevel);
  210. #ifdef __cplusplus
  211. }
  212. #endif // __cplusplus
  213. # define EXSTRICT // (EXception STRICT) - Enabled if ANYSTRICT is enabled
  214. # define Win4Assert(x) if ( !(x) ) \
  215. Win4AssertEx ( __FILE__, __LINE__, #x );
  216. //
  217. // Debug print macros
  218. //
  219. # define DEB_ERROR 0x00000001 // exported error paths
  220. # define DEB_WARN 0x00000002 // exported warnings
  221. # define DEB_TRACE 0x00000004 // exported trace messages
  222. # define DEB_DBGOUT 0x00000010 // Output to debugger
  223. # define DEB_STDOUT 0x00000020 // Output to stdout
  224. # define DEB_IERROR 0x00000100 // internal error paths
  225. # define DEB_IWARN 0x00000200 // internal warnings
  226. # define DEB_ITRACE 0x00000400 // internal trace messages
  227. # define DEB_USER1 0x00010000 // User defined
  228. # define DEB_USER2 0x00020000 // User defined
  229. # define DEB_USER3 0x00040000 // User defined
  230. # define DEB_USER4 0x00080000 // User defined
  231. # define DEB_USER5 0x00100000 // User defined
  232. # define DEB_USER6 0x00200000 // User defined
  233. # define DEB_USER7 0x00400000 // User defined
  234. # define DEB_USER8 0x00800000 // User defined
  235. # define DEB_USER9 0x01000000 // User defined
  236. # define DEB_USER10 0x02000000 // User defined
  237. # define DEB_USER11 0x04000000 // User defined
  238. # define DEB_USER12 0x08000000 // User defined
  239. # define DEB_USER13 0x10000000 // User defined
  240. # define DEB_USER14 0x20000000 // User defined
  241. # define DEB_USER15 0x40000000 // User defined
  242. # define DEB_NOCOMPNAME 0x80000000 // suppress component name
  243. # define DEB_FORCE 0x7fffffff // force message
  244. # define ASSRT_MESSAGE 0x00000001 // Output a message
  245. # define ASSRT_BREAK 0x00000002 // Int 3 on assertion
  246. # define ASSRT_POPUP 0x00000004 // And popup message
  247. # define EXCEPT_MESSAGE 0x00000001 // Output a message
  248. # define EXCEPT_BREAK 0x00000002 // Int 3 on exception
  249. # define EXCEPT_POPUP 0x00000004 // Popup message
  250. # define EXCEPT_FAULT 0x00000008 // generate int 3 on access violation
  251. //+----------------------------------------------------------------------
  252. //
  253. // DECLARE_DEBUG(comp)
  254. // DECLARE_INFOLEVEL(comp)
  255. //
  256. // This macro defines xxDebugOut where xx is the component prefix
  257. // to be defined. This declares a static variable 'xxInfoLevel', which
  258. // can be used to control the type of xxDebugOut messages printed to
  259. // the terminal. For example, xxInfoLevel may be set at the debug terminal.
  260. // This will enable the user to turn debugging messages on or off, based
  261. // on the type desired. The predefined types are defined below. Component
  262. // specific values should use the upper 24 bits
  263. //
  264. // To Use:
  265. //
  266. // 1) In your components main include file, include the line
  267. // DECLARE_DEBUG(comp)
  268. // where comp is your component prefix
  269. //
  270. // 2) In one of your components source files, include the line
  271. // DECLARE_INFOLEVEL(comp)
  272. // where comp is your component prefix. This will define the
  273. // global variable that will control output.
  274. //
  275. // It is suggested that any component define bits be combined with
  276. // existing bits. For example, if you had a specific error path that you
  277. // wanted, you might define DEB_<comp>_ERRORxxx as being
  278. //
  279. // (0x100 | DEB_ERROR)
  280. //
  281. // This way, we can turn on DEB_ERROR and get the error, or just 0x100
  282. // and get only your error.
  283. //
  284. // Define values that are specific to your xxInfoLevel variable in your
  285. // own file, like ciquery.hxx.
  286. //
  287. //-----------------------------------------------------------------------
  288. # ifndef DEF_INFOLEVEL
  289. # define DEF_INFOLEVEL (DEB_ERROR | DEB_WARN)
  290. # endif
  291. # if (WIN32 > 200) && defined(WIN32) && defined(__cplusplus) && !defined(KERNEL)
  292. # include <dbgpoint.hxx>
  293. # endif
  294. //+----------------------------------------------------------------------
  295. //
  296. // This next section makes for some really dense reading! Most of it is
  297. // used for the debugging window. It defines some macros that make it
  298. // easier to define debug groups and debug break points, since the macros
  299. // expand to nothing if DEVL != 1. Check out dbgpoint.hxx for more info.
  300. //
  301. //
  302. // The following macros allow you to do things like this
  303. //
  304. // DECLARE_GROUP(FooDebugingGroup)
  305. //
  306. // DECLARE_BREAKPOINT(FooBreakPoint,FooDebuggingGroup,FALSE)
  307. //
  308. // foo()
  309. // {
  310. // TEST_BREAKPOINT(FooBreakPoint);
  311. // }
  312. //
  313. //
  314. //-----------------------------------------------------------------------
  315. # if (WIN32 > 200) && defined(__cplusplus) && defined(WIN32) && !defined(KERNEL)
  316. //
  317. // The following class is used to register debug groups as static
  318. // members. Its only needed when DBG is set.
  319. //
  320. //
  321. // The easy way to declare a group, and have it registered for you
  322. //
  323. # define DECLARE_GROUP(grpName) \
  324. CDebugGroupClass grpName ((L#grpName));
  325. //
  326. // The easy way to define a group in a header file for use cross module
  327. //
  328. # define DEFINE_GROUP(grpName) extern CDebugGroupClass grpName;
  329. //
  330. // The easy way to declare a breakpoint is with the following macro.
  331. //
  332. # define DECLARE_BREAKPOINT(Name,hGroup,fEnabled) \
  333. CDebugBreakPoint Name((L#Name),hGroup,fEnabled)
  334. //
  335. // If you need to have global access to a break point, use this in
  336. // an include file
  337. //
  338. # define DEFINE_BREAKPOINT(Name) \
  339. extern CDebugBreakPoint Name;
  340. //
  341. // A debug value is a class that allows you to wrap the contents of any
  342. // integer value, and publish it in the debug window. The actual debug
  343. // value keeps a reference to the actual value. Therefore, you can attach
  344. // it to any long in the program.
  345. //
  346. // If you use the CDebugValue::SetValue() to change it, the change will
  347. // be reflected in the window immediately.
  348. //
  349. // DECLARE_DEBUGVALUE( Name of Debug Value, Group, Reference to data object)
  350. //
  351. # define DECLARE_DEBUGVALUE(Name,hGroup,Value) \
  352. CDebugValue Name((L#Name),hGroup,Value)
  353. # define DEFINE_DEBUGVALUE(Name) \
  354. extern CDebugValue Name;
  355. //
  356. // This is the same as above, only you can specify your own title for the
  357. // debug value.
  358. //
  359. // DECLARE_DEBUGVALUEEX( Name of Debug Value, Title, Group, Reference to data object)
  360. //
  361. # define DECLARE_DEBUGVALUEEX(Name,Title,hGroup,Value) \
  362. CDebugValue Name(Title,hGroup,Value)
  363. //
  364. // If you need to have global access to a break point, use this in
  365. // an include file
  366. //
  367. # define DEFINE_BREAKPOINT(Name) \
  368. extern CDebugBreakPoint Name;
  369. //
  370. // This test uses a default value for the HRESULT in the window. Use it
  371. // when you don't have one. If you have an HRESULT you could display,
  372. // please use TEST_BREAKPOINTHR
  373. //
  374. # define TEST_BREAKPOINT(x) if( (x).BreakPointTest() && \
  375. (x).BreakPointMessage(__FILE__,__LINE__) )\
  376. { DebugBreak(); }
  377. //
  378. // This test includes an HRESULT as a parameter. You should use this one
  379. //
  380. # define TEST_BREAKPOINTHR(x,hr) if( (x).BreakPointTest() && \
  381. (x).BreakPointMessage(__FILE__,__LINE__,hr) )\
  382. { DebugBreak(); }
  383. # define MAKE_CINFOLEVEL(comp) \
  384. CInfoLevel comp##CInfoLevel((L#comp),comp##InfoLevel);
  385. # else // (WIN32 > 200) && defined(__cplusplus) && defined(WIN32) && !defined(KERNEL)
  386. //
  387. // In the non debug version or C version, don't define these
  388. //
  389. # define MAKE_CINFOLEVEL(comp)
  390. # define DECLARE_GROUP(Name)
  391. # define DEFINE_GROUP(Name)
  392. # define DEFINE_BREAKPOINT(Name)
  393. # define DECLARE_BREAKPOINT(Name,hGroup,fEnabled)
  394. # define TEST_BREAKPOINT(x)
  395. # define TEST_BREAKPOINTHR(x,hr)
  396. # define DECLARE_DEBUGVALUE(Name,hGroup,Value)
  397. # define DECLARE_DEBUGVALUEEX(Name,Title,hGroup,Value)
  398. # define DEFINE_DEBUGVALUE(Name)
  399. # endif // #if (WIN32 > 200) && defined(__cplusplus) && defined(WIN32) && !defined(KERNEL)
  400. //
  401. // Back to the info level stuff.
  402. //
  403. # ifdef __cplusplus
  404. extern "C" {
  405. # endif // __cplusplus
  406. # define DECLARE_INFOLEVEL(comp) \
  407. extern EXTRNC unsigned long comp##InfoLevel = DEF_INFOLEVEL;\
  408. extern EXTRNC char *comp##InfoLevelString = #comp;\
  409. MAKE_CINFOLEVEL(comp)
  410. # ifdef __cplusplus
  411. }
  412. # endif
  413. # ifdef __cplusplus
  414. # define DECLARE_DEBUG(comp) \
  415. extern EXTRNC unsigned long comp##InfoLevel; \
  416. extern EXTRNC char *comp##InfoLevelString; \
  417. _inline void \
  418. comp##InlineDebugOut(unsigned long fDebugMask, char const DEBFAR *pszfmt, ...) \
  419. { \
  420. if (comp##InfoLevel & fDebugMask) \
  421. { \
  422. va_list va; \
  423. va_start (va, pszfmt); \
  424. vdprintf(fDebugMask, comp##InfoLevelString, pszfmt, va);\
  425. va_end(va); \
  426. } \
  427. } \
  428. \
  429. class comp##CDbgTrace\
  430. {\
  431. private:\
  432. unsigned long _ulFlags;\
  433. char const DEBFAR * const _pszName;\
  434. public:\
  435. comp##CDbgTrace(unsigned long ulFlags, char const DEBFAR * const pszName);\
  436. ~comp##CDbgTrace();\
  437. };\
  438. \
  439. inline comp##CDbgTrace::comp##CDbgTrace(\
  440. unsigned long ulFlags,\
  441. char const DEBFAR * const pszName)\
  442. : _ulFlags(ulFlags), _pszName(pszName)\
  443. {\
  444. comp##InlineDebugOut(_ulFlags, "Entering %s\n", _pszName);\
  445. }\
  446. \
  447. inline comp##CDbgTrace::~comp##CDbgTrace()\
  448. {\
  449. comp##InlineDebugOut(_ulFlags, "Exiting %s\n", _pszName);\
  450. }
  451. # else // ! __cplusplus
  452. # define DECLARE_DEBUG(comp) \
  453. extern EXTRNC unsigned long comp##InfoLevel; \
  454. extern EXTRNC char *comp##InfoLevelString; \
  455. _inline void \
  456. comp##InlineDebugOut(unsigned long fDebugMask, char const DEBFAR *pszfmt, ...) \
  457. { \
  458. if (comp##InfoLevel & fDebugMask) \
  459. { \
  460. va_list va; \
  461. va_start (va, pszfmt); \
  462. vdprintf(fDebugMask, comp##InfoLevelString, pszfmt, va);\
  463. va_end(va); \
  464. } \
  465. }
  466. # endif // ! __cplusplus
  467. #else // DBG == 0
  468. //
  469. // NO DEBUG -- NO DEBUG -- NO DEBUG -- NO DEBUG -- NO DEBUG
  470. //
  471. # define Win4Assert(x)
  472. # define Assert(x) // OBSOLETE!
  473. # define Verify(x) (x) // OBSOLETE!
  474. # define MAKE_CINFOLEVEL(comp)
  475. # define DECLARE_GROUP(Name)
  476. # define DEFINE_GROUP(Name)
  477. # define DEFINE_BREAKPOINT(Name)
  478. # define DECLARE_BREAKPOINT(Name,hGroup,fEnabled)
  479. # define TEST_BREAKPOINT(x)
  480. # define TEST_BREAKPOINTHR(x,hr)
  481. # define DECLARE_DEBUGVALUE(Name,hGroup,Value)
  482. # define DECLARE_DEBUGVALUEEX(Name,Title,hGroup,Value)
  483. # define DEFINE_DEBUGVALUE(Name)
  484. # define DECLARE_DEBUG(comp)
  485. # define DECLARE_INFOLEVEL(comp)
  486. #endif // DBG == 0
  487. //
  488. // The following section adds the API's used for the performance snapshots
  489. //
  490. #if PERFSNAP == 1
  491. #ifdef __cplusplus
  492. extern "C" {
  493. #endif
  494. void _stdcall InitPerformanceMetering(char const DEBFAR * const);
  495. void _stdcall Perfon(char const DEBFAR * const);
  496. void _stdcall Perfsnap(char const DEBFAR * const, int const);
  497. void _stdcall Perfcomment(char const DEBFAR * const s);
  498. void _stdcall Perfdelta(char const DEBFAR * const, int const);
  499. void _stdcall Perfoff(char const DEBFAR * const);
  500. void _stdcall EndPerformanceMetering(char const DEBFAR * const);
  501. #ifdef __cplusplus
  502. }
  503. #endif
  504. #define PSNAPINIT(pszFileKey) InitPerformanceMetering(pszFileKey)
  505. #define PSNAPEND() EndPerformanceMetering(NULL)
  506. #define PSNAP(s) Perfsnap(s,0)
  507. #define PSNAPL(s,l) Perfsnap(s,l)
  508. #define PSNAPC(s) Perfcomment(s)
  509. #define PSNAPDELTA(s) Perfdelta(s,0)
  510. #define PSNAPDELTAL(s,l) Perfdelta(s,l)
  511. #define PSNAPON(s) Perfon(s)
  512. #define PSNAPOFF(s) Perfoff(s)
  513. #else // PERFSNAP == 1
  514. #define InitPerformanceMetering(x)
  515. #define Perfon(x)
  516. #define Perfsnap(x,y)
  517. #define Perfcomment(x)
  518. #define Perfdelta(x,y)
  519. #define Perfoff(x)
  520. #define EndPerformanceMetering(x)
  521. #define PSNAPINIT(pszFileKey)
  522. #define PSNAPEND()
  523. #define PSNAP(s)
  524. #define PSNAPL(s,l)
  525. #define PSNAPC(s)
  526. #define PSNAPDELTA(s)
  527. #define PSNAPDELTAL(s,l)
  528. #define PSNAPON(s)
  529. #define PSNAPOFF(s)
  530. #endif
  531. //
  532. // If the sampling profiler is to be used, then here are its includes
  533. //
  534. //
  535. #ifdef WIN32
  536. #if (DBG == 1) || (RTLPROFILE == 1)
  537. #ifdef __cplusplus
  538. extern "C" {
  539. #endif
  540. void _stdcall InitSamplingProfiler(void);
  541. void _stdcall EndSamplingProfiler(void);
  542. #ifdef __cplusplus
  543. }
  544. #endif
  545. #define INITSAMPLINGPROFILER InitSamplingProfiler()
  546. #define ENDSAMPLINGPROFILER EndSamplingProfiler()
  547. #else // RTLPROFILE == 1
  548. #define INITSAMPLINGPROFILER
  549. #define ENDSAMPLINGPROFILER
  550. #endif // RTLPROFILE == 1
  551. #endif // WIN32
  552. #endif // __DEBNOT_H__