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.

779 lines
31 KiB

  1. /*++
  2. Copyright (c) 1997-1999 Microsoft Corporation
  3. Module Name:
  4. debug.c
  5. Abstract:
  6. This header file defines data structures and macros related to internal
  7. FRS monitoring and activity logging. The activity log is always present
  8. but the amount of information placed in the log can be controlled by a
  9. severity level parameter. See below.
  10. In addition, FRS contains constraint checks throughout the code using the
  11. FRS_ASSERT() macro. FRS follows a "Fail Fast" model for failure recovery.
  12. If the constraint is not satisfied FRS places an entry in the event log
  13. and abruptly shuts down. The objective is to minimize the likelyhood that
  14. continued execution will propagate invalid state into the FRS database.
  15. The WIN2K Service Controller is set to automatically restart FRS after a
  16. short delay.
  17. Author:
  18. David A. Orbits 20-Mar-1997
  19. --*/
  20. // Guidelines for Severity Level Use in DPRINT():
  21. //
  22. // 0 - Most severe, eg. fatal inconsistency, mem alloc fail. Least noisey.
  23. // 1 - Important info, eg. Key config parameters, unexpected conditions
  24. // 2 -
  25. // 3 - Change Order Process trace records.
  26. // 4 - Status results, e.g. table lookup failures, new entry inserted
  27. // 5 - Information level messages to show flow. Noisest level. Maybe in a loop
  28. //
  29. /* Debug output macros
  30. This is a simple debugging package for generating conditional
  31. printf output.
  32. AT RUN-TIME
  33. There are 2 run-time options:
  34. 1 - A list of subsystems to be debugged. Either a list of subsystem
  35. names delimited by a ":" or an "*" which means debug all
  36. (e.g. sub1:sub2: Sub3:). (Names are case sensitive and spaces
  37. between names are ignored.)
  38. 2 - A severity level (1-5) that indicates the level of detailed
  39. information to be produced. (The higher the level, the more
  40. data produced.
  41. AT COMPILE-TIME
  42. Compile with the /DDBG=1 option to define the preprocessor variable
  43. DBG to 1. This will generate debug source code. For customer shipment,
  44. set /DDBG=0 and all debug code will be removed. (Actually a
  45. ";" will be generated.)
  46. AT CODE-TIME
  47. 1 - Include the DEBUG.H header at the top of your source listing.
  48. 2 - #DEFINE DEBSUB to contain the name (a string delimited by a ":") of
  49. the software subsystem contained in this source (e.g. #define DEBSUB
  50. "MySub:") (You could optionally redefine DEBSUB for each function in
  51. your source to give you function-level debugging.)
  52. 3 - Invoke the DEBUGINIT macro that calls the Debug function before any
  53. source debug statements are executed. This funciton prompts STDIN for
  54. the user specified run-time options. (Alternatively you could
  55. hardcode your own assignment of the DebugInfo data structure which
  56. holds the run-time options.)
  57. 4 - Everywhere you want to a printf for debugging, put a DPRINT statement
  58. instead and specify a severity level with the statement. The
  59. statement will be printed if the severity is this level or higher
  60. (assuming that the subsystem is to be debugged). The severity level
  61. allows for different amounts of output to be generated if problem
  62. is very bad.
  63. For example, a severity of 1 DPRINT statement might just indicate that
  64. a certain function was entered while a severity of 5 might print
  65. information that is inside a tight loop.
  66. (Actually there are 6 DPRINT statements provided depending on the
  67. number of printf arguments.)
  68. NOTE
  69. All printf's are surrounded by semaphores. Be careful not to invoke
  70. routines as parms to printf because you can have a deadlock situation.
  71. EXAMPLE PROGRAM
  72. ** include "debug.h"
  73. ** include "string.h"
  74. **
  75. ** #define DEBSUB "sub1:"
  76. **
  77. ** main()
  78. ** {
  79. ** DEBUGINIT;
  80. **
  81. ** DPRINT(4,"this is a sub1 debug of 4\n");
  82. ** DPRINT(1,"this is a sub1 debug of 1\n");
  83. ** }
  84. */
  85. #ifndef _debug_h_
  86. #define _debug_h_
  87. #ifdef __cplusplus
  88. extern "C" {
  89. #endif
  90. // <DebugInfo>, of type DEBUGARG, contains the debug run-time settings.
  91. //
  92. // DebSubSystems contains a list of subsystem names to be debugged
  93. // delimited by ":". An "*" found in this array indicates that all
  94. // subsystems are to be debugged.
  95. //
  96. // The severity indicates the amount of debug information to be produced.
  97. // The higher the severity the more data that will be dumped.
  98. //
  99. // A specific thread can be traced by entering its ID. An id of 0 means all.
  100. //
  101. typedef struct _DEBUGARG {
  102. ULONG Severity; // 1 - 5 on stdout
  103. PCHAR Systems; // subsystem to debug
  104. ULONG ThreadId; // thread id to debug (0 = All)
  105. BOOL Disabled; // debugging has been disabled
  106. BOOL Suppress; // suppress debug print
  107. BOOL DisableCompression; // Enable support for compression.
  108. ULONG LogSeverity; // 1 - 5 on log file
  109. ULONG MaxLogLines; // max dprint log lines
  110. ULONG LogLines; // current dprint lines logged
  111. ULONG TotalLogLines; // total dprint lines logged
  112. PWCHAR LogFile; // dprint log file
  113. PWCHAR LogDir; // dprint log directory.
  114. FILE *LogFILE; // open log file stream
  115. ULONG Interval; // scheduling interval
  116. BOOL TestFid; // enable the rename-fid tests
  117. PCHAR Recipients; // email recipients
  118. PCHAR Profile; // email profile
  119. PCHAR BuildLab; // Build lab ID string from registry.
  120. PWCHAR AssertShare; // share to copy assert files
  121. BOOL CopyLogs; // copy logs into assert share
  122. ULONG AssertFiles; // number of assert files
  123. ULONG LogFiles; // number of log files
  124. BOOL PrintStats; // Print stats at DebUnLock()
  125. BOOL PrintingStats; // Currently printing stats
  126. ULONG RestartSeconds; // Must run this long for restart
  127. BOOL Restart; // restart on assertion failure
  128. ULONGLONG StartSeconds; // start time in seconds
  129. PWCHAR CommandLine; // Original command line
  130. BOOL Break; // Break into the debugger on assert
  131. ULONG AssertSeconds; // assert after this many seconds
  132. BOOL VvJoinTests; // enable VvJoin Tests
  133. ULONG Tests; // Enable random tests
  134. ULONG UnjoinTrigger; // unjoin trigger
  135. LONG FetchRetryTrigger; // fetch retry trigger
  136. LONG FetchRetryReset; // fetch retry trigger reset
  137. LONG FetchRetryInc; // fetch retry trigger reset inc
  138. BOOL ForceVvJoin; // force vvjoin at every true join
  139. BOOL Mem; // Check memory allocations/frees
  140. BOOL MemCompact; // Compact mem at every free
  141. BOOL Queues; // Check queues
  142. DWORD DbsOutOfSpace; // Create REAL out of space errors on DB
  143. DWORD DbsOutOfSpaceTrigger; // dummy out-of-space error
  144. LONG LogFlushInterval; // Flush the log every n lines.
  145. CRITICAL_SECTION DbsOutOfSpaceLock; // lock for out-of-space tests
  146. CRITICAL_SECTION Lock; // single thread semaphore
  147. } DEBUGARG, *PDEBUGARG;
  148. #define DBG_DBS_OUT_OF_SPACE_OP_NONE (0) // no out of space errors
  149. #define DBG_DBS_OUT_OF_SPACE_OP_CREATE (1) // out of space error during create
  150. #define DBG_DBS_OUT_OF_SPACE_OP_DELETE (2) // out of space error during delete
  151. #define DBG_DBS_OUT_OF_SPACE_OP_WRITE (3) // out of space error during write
  152. #define DBG_DBS_OUT_OF_SPACE_OP_REMOVE (4) // out of space error during remove
  153. #define DBG_DBS_OUT_OF_SPACE_OP_MULTI (5) // out of space error during multi
  154. #define DBG_DBS_OUT_OF_SPACE_OP_MAX (5) // Max value for param
  155. extern DEBUGARG DebugInfo;
  156. //
  157. // forward declare actual functions used by DPRINT's
  158. //
  159. VOID
  160. DebLock(
  161. VOID
  162. );
  163. VOID
  164. DebUnLock(
  165. VOID
  166. );
  167. VOID
  168. DebPrintNoLock(
  169. IN ULONG,
  170. IN BOOL,
  171. IN PUCHAR,
  172. IN PCHAR,
  173. IN UINT,
  174. ...
  175. );
  176. VOID
  177. DebPrintTrackingNoLock(
  178. IN ULONG Sev,
  179. IN PUCHAR Str,
  180. IN ... );
  181. VOID
  182. DebPrint(
  183. IN ULONG,
  184. IN PUCHAR,
  185. IN PCHAR,
  186. IN UINT,
  187. ...
  188. );
  189. BOOL
  190. DoDebug(
  191. IN ULONG,
  192. IN PUCHAR
  193. );
  194. //
  195. // These are used instead of printf statements. Semaphores surround the
  196. // printf and all output is provided by the subsystem.
  197. //
  198. #define DPRINT(_sev_,str) \
  199. DebPrint((_sev_), (PUCHAR)str, DEBSUB, __LINE__)
  200. #define DPRINT1(_sev_, str,p1) \
  201. DebPrint((_sev_), (PUCHAR)str, DEBSUB, __LINE__, p1 )
  202. #define DPRINT2(_sev_, str,p1,p2) \
  203. DebPrint((_sev_), (PUCHAR)str, DEBSUB, __LINE__, p1, p2 )
  204. #define DPRINT3(_sev_, str,p1,p2,p3) \
  205. DebPrint((_sev_), (PUCHAR)str, DEBSUB, __LINE__, p1, p2, p3 )
  206. #define DPRINT4(_sev_, str,p1,p2,p3,p4) \
  207. DebPrint((_sev_), (PUCHAR)str, DEBSUB, __LINE__, p1, p2, p3, p4 )
  208. #define DPRINT5(_sev_, str,p1,p2,p3,p4,p5) \
  209. DebPrint((_sev_), (PUCHAR)str, DEBSUB, __LINE__, p1, p2, p3, p4, p5 )
  210. #define DPRINT6(_sev_, str,p1,p2,p3,p4,p5,p6) \
  211. DebPrint((_sev_), (PUCHAR)str, DEBSUB, __LINE__, p1, p2, p3, p4, p5, p6 )
  212. #define DPRINT7(_sev_, str,p1,p2,p3,p4,p5,p6,p7) \
  213. DebPrint((_sev_), (PUCHAR)str, DEBSUB, __LINE__, p1,p2,p3,p4,p5,p6,p7)
  214. #define DPRINT8(_sev_, str,p1,p2,p3,p4,p5,p6,p7,p8) \
  215. DebPrint((_sev_), (PUCHAR)str, DEBSUB, __LINE__, p1,p2,p3,p4,p5,p6,p7,p8 )
  216. #define DPRINT_NOLOCK(_sev_, str) \
  217. DebPrintNoLock((_sev_), TRUE, (PUCHAR)str, DEBSUB, __LINE__)
  218. #define DPRINT_NOLOCK1(_sev_, str,p1) \
  219. DebPrintNoLock((_sev_), TRUE, (PUCHAR)str, DEBSUB, __LINE__, p1 )
  220. #define DPRINT_NOLOCK2(_sev_, str,p1,p2) \
  221. DebPrintNoLock((_sev_), TRUE, (PUCHAR)str, DEBSUB, __LINE__, p1, p2 )
  222. #define DPRINT_NOLOCK3(_sev_, str,p1,p2,p3) \
  223. DebPrintNoLock((_sev_), TRUE, (PUCHAR)str, DEBSUB, __LINE__, p1, p2, p3 )
  224. #define DPRINT_NOLOCK4(_sev_, str,p1,p2,p3,p4) \
  225. DebPrintNoLock((_sev_), TRUE, (PUCHAR)str, DEBSUB, __LINE__, p1, p2, p3, p4 )
  226. #define DPRINT_NOLOCK5(_sev_, str,p1,p2,p3,p4,p5) \
  227. DebPrintNoLock((_sev_), TRUE, (PUCHAR)str, DEBSUB, __LINE__, p1, p2, p3, p4, p5 )
  228. #define DPRINT_NOLOCK6(_sev_, str,p1,p2,p3,p4,p5,p6) \
  229. DebPrintNoLock((_sev_), TRUE, (PUCHAR)str, DEBSUB, __LINE__, p1, p2, p3, p4, p5, p6 )
  230. //
  231. // DPRINT_FS(sev, "display text", FStatus)
  232. //
  233. #define DPRINT_FS(_sev_, _str, _fstatus) \
  234. if (!FRS_SUCCESS(_fstatus)) { \
  235. DebPrint((_sev_), \
  236. (PUCHAR)(_str " FStatus: %s\n"), \
  237. DEBSUB, __LINE__, ErrLabelFrs(_fstatus) ); \
  238. }
  239. #define DPRINT1_FS(_sev_, _str, _p1, _fstatus) \
  240. if (!FRS_SUCCESS(_fstatus)) { \
  241. DebPrint((_sev_), \
  242. (PUCHAR)(_str " FStatus: %s\n"), \
  243. DEBSUB, __LINE__, _p1, ErrLabelFrs(_fstatus) ); \
  244. }
  245. #define DPRINT2_FS(_sev_, _str, _p1, _p2, _fstatus) \
  246. if (!FRS_SUCCESS(_fstatus)) { \
  247. DebPrint((_sev_), \
  248. (PUCHAR)(_str " FStatus: %s\n"), \
  249. DEBSUB, __LINE__, _p1, _p2, ErrLabelFrs(_fstatus) ); \
  250. }
  251. #define DPRINT3_FS(_sev_, _str, _p1, _p2, _p3, _fstatus) \
  252. if (!FRS_SUCCESS(_fstatus)) { \
  253. DebPrint((_sev_), \
  254. (PUCHAR)(_str " FStatus: %s\n"), \
  255. DEBSUB, __LINE__, _p1, _p2, _p3, ErrLabelFrs(_fstatus) ); \
  256. }
  257. #define DPRINT4_FS(_sev_, _str, _p1, _p2, _p3, _p4, _fstatus) \
  258. if (!FRS_SUCCESS(_fstatus)) { \
  259. DebPrint((_sev_), \
  260. (PUCHAR)(_str " FStatus: %s\n"), \
  261. DEBSUB, __LINE__, _p1, _p2, _p3, _p4, ErrLabelFrs(_fstatus)); \
  262. }
  263. //
  264. // CLEANUP_FS(sev, "display text", FStatus, branch_target)
  265. // Like DPRINT but takes a branch target as last arg if success test fails.
  266. //
  267. #define CLEANUP_FS(_sev_, _str, _fstatus, _branch) \
  268. if (!FRS_SUCCESS(_fstatus)) { \
  269. DebPrint((_sev_), \
  270. (PUCHAR)(_str " FStatus: %s\n"), \
  271. DEBSUB, __LINE__, ErrLabelFrs(_fstatus) ); \
  272. goto _branch; \
  273. }
  274. #define CLEANUP1_FS(_sev_, _str, _p1, _fstatus, _branch) \
  275. if (!FRS_SUCCESS(_fstatus)) { \
  276. DebPrint((_sev_), \
  277. (PUCHAR)(_str " FStatus: %s\n"), \
  278. DEBSUB, __LINE__, _p1, ErrLabelFrs(_fstatus) ); \
  279. goto _branch; \
  280. }
  281. #define CLEANUP2_FS(_sev_, _str, _p1, _p2, _fstatus, _branch) \
  282. if (!FRS_SUCCESS(_fstatus)) { \
  283. DebPrint((_sev_), \
  284. (PUCHAR)(_str " FStatus: %s\n"), \
  285. DEBSUB, __LINE__, _p1, _p2, ErrLabelFrs(_fstatus) ); \
  286. goto _branch; \
  287. }
  288. #define CLEANUP3_FS(_sev_, _str, _p1, _p2, _p3, _fstatus, _branch) \
  289. if (!FRS_SUCCESS(_fstatus)) { \
  290. DebPrint((_sev_), \
  291. (PUCHAR)(_str " FStatus: %s\n"), \
  292. DEBSUB, __LINE__, _p1, _p2, _p3, ErrLabelFrs(_fstatus) ); \
  293. goto _branch; \
  294. }
  295. #define CLEANUP4_FS(_sev_, _str, _p1, _p2, _p3, _p4, _fstatus, _branch) \
  296. if (!FRS_SUCCESS(_fstatus)) { \
  297. DebPrint((_sev_), \
  298. (PUCHAR)(_str " FStatus: %s\n"), \
  299. DEBSUB, __LINE__, _p1, _p2, _p3, _p4, ErrLabelFrs(_fstatus) ); \
  300. goto _branch; \
  301. }
  302. //
  303. // DPRINT_WS(sev, "display text", WStatus)
  304. //
  305. #define DPRINT_WS(_sev_, _str, _wstatus) \
  306. if (!WIN_SUCCESS(_wstatus)) { \
  307. DebPrint((_sev_), \
  308. (PUCHAR)(_str " WStatus: %s\n"), \
  309. DEBSUB, __LINE__, ErrLabelW32(_wstatus) ); \
  310. }
  311. #define DPRINT1_WS(_sev_, _str, _p1, _wstatus) \
  312. if (!WIN_SUCCESS(_wstatus)) { \
  313. DebPrint((_sev_), \
  314. (PUCHAR)(_str " WStatus: %s\n"), \
  315. DEBSUB, __LINE__, _p1, ErrLabelW32(_wstatus) ); \
  316. }
  317. #define DPRINT2_WS(_sev_, _str, _p1, _p2, _wstatus) \
  318. if (!WIN_SUCCESS(_wstatus)) { \
  319. DebPrint((_sev_), \
  320. (PUCHAR)(_str " WStatus: %s\n"), \
  321. DEBSUB, __LINE__, _p1, _p2, ErrLabelW32(_wstatus) ); \
  322. }
  323. #define DPRINT3_WS(_sev_, _str, _p1, _p2, _p3, _wstatus) \
  324. if (!WIN_SUCCESS(_wstatus)) { \
  325. DebPrint((_sev_), \
  326. (PUCHAR)(_str " WStatus: %s\n"), \
  327. DEBSUB, __LINE__, _p1, _p2, _p3, ErrLabelW32(_wstatus) ); \
  328. }
  329. #define DPRINT4_WS(_sev_, _str, _p1, _p2, _p3, _p4, _wstatus) \
  330. if (!WIN_SUCCESS(_wstatus)) { \
  331. DebPrint((_sev_), \
  332. (PUCHAR)(_str " WStatus: %s\n"), \
  333. DEBSUB, __LINE__, _p1, _p2, _p3, _p4, ErrLabelW32(_wstatus) ); \
  334. }
  335. //
  336. // CLEANUP_WS(sev, "display text", wstatus, branch_target)
  337. // Like DPRINT but takes a branch target as last arg if success test fails.
  338. //
  339. #define CLEANUP_WS(_sev_, _str, _wstatus, _branch) \
  340. if (!WIN_SUCCESS(_wstatus)) { \
  341. DebPrint((_sev_), \
  342. (PUCHAR)(_str " WStatus: %s\n"), \
  343. DEBSUB, __LINE__, ErrLabelW32(_wstatus) ); \
  344. goto _branch; \
  345. }
  346. #define CLEANUP1_WS(_sev_, _str, _p1, _wstatus, _branch) \
  347. if (!WIN_SUCCESS(_wstatus)) { \
  348. DebPrint((_sev_), \
  349. (PUCHAR)(_str " WStatus: %s\n"), \
  350. DEBSUB, __LINE__, _p1, ErrLabelW32(_wstatus) ); \
  351. goto _branch; \
  352. }
  353. #define CLEANUP2_WS(_sev_, _str, _p1, _p2, _wstatus, _branch) \
  354. if (!WIN_SUCCESS(_wstatus)) { \
  355. DebPrint((_sev_), \
  356. (PUCHAR)(_str " WStatus: %s\n"), \
  357. DEBSUB, __LINE__, _p1, _p2, ErrLabelW32(_wstatus) ); \
  358. goto _branch; \
  359. }
  360. #define CLEANUP3_WS(_sev_, _str, _p1, _p2, _p3, _wstatus, _branch) \
  361. if (!WIN_SUCCESS(_wstatus)) { \
  362. DebPrint((_sev_), \
  363. (PUCHAR)(_str " WStatus: %s\n"), \
  364. DEBSUB, __LINE__, _p1, _p2, _p3, ErrLabelW32(_wstatus) ); \
  365. goto _branch; \
  366. }
  367. //
  368. // DPRINT_NT(sev, "display text", Nttatus)
  369. //
  370. #define DPRINT_NT(_sev_, _str, _NtStatus) \
  371. if (!NT_SUCCESS(_NtStatus)) { \
  372. DebPrint((_sev_), \
  373. (PUCHAR)(_str " NTStatus: %s\n"), \
  374. DEBSUB, __LINE__, ErrLabelNT(_NtStatus) ); \
  375. }
  376. #define DPRINT1_NT(_sev_, _str, _p1, _NtStatus) \
  377. if (!NT_SUCCESS(_NtStatus)) { \
  378. DebPrint((_sev_), \
  379. (PUCHAR)(_str " NTStatus: %s\n"), \
  380. DEBSUB, __LINE__, _p1, ErrLabelNT(_NtStatus) ); \
  381. }
  382. #define DPRINT2_NT(_sev_, _str, _p1, _p2, _NtStatus) \
  383. if (!NT_SUCCESS(_NtStatus)) { \
  384. DebPrint((_sev_), \
  385. (PUCHAR)(_str " NTStatus: %s\n"), \
  386. DEBSUB, __LINE__, _p1, _p2, ErrLabelNT(_NtStatus) ); \
  387. }
  388. #define DPRINT3_NT(_sev_, _str, _p1, _p2, _p3, _NtStatus) \
  389. if (!NT_SUCCESS(_NtStatus)) { \
  390. DebPrint((_sev_), \
  391. (PUCHAR)(_str " NTStatus: %s\n"), \
  392. DEBSUB, __LINE__, _p1, _p2, _p3, ErrLabelNT(_NtStatus) ); \
  393. }
  394. #define DPRINT4_NT(_sev_, _str, _p1, _p2, _p3, _p4, _NtStatus) \
  395. if (!NT_SUCCESS(_NtStatus)) { \
  396. DebPrint((_sev_), \
  397. (PUCHAR)(_str " NTStatus: %s\n"), \
  398. DEBSUB, __LINE__, _p1, _p2, _p3, _p4, ErrLabelNT(_NtStatus) ); \
  399. }
  400. //
  401. // CLEANUP_NT(sev, "display text", NtStatus, branch_target)
  402. // Like DPRINT but takes a branch target as last arg if success test fails.
  403. //
  404. #define CLEANUP_NT(_sev_, _str, _NtStatus, _branch) \
  405. if (!NT_SUCCESS(_NtStatus)) { \
  406. DebPrint((_sev_), \
  407. (PUCHAR)(_str " NTStatus: %s\n"), \
  408. DEBSUB, __LINE__, ErrLabelNT(_NtStatus) ); \
  409. goto _branch; \
  410. }
  411. #define CLEANUP1_NT(_sev_, _str, _p1, _NtStatus, _branch) \
  412. if (!NT_SUCCESS(_NtStatus)) { \
  413. DebPrint((_sev_), \
  414. (PUCHAR)(_str " NTStatus: %s\n"), \
  415. DEBSUB, __LINE__, _p1, ErrLabelNT(_NtStatus) ); \
  416. goto _branch; \
  417. }
  418. #define CLEANUP2_NT(_sev_, _str, _p1, _p2, _NtStatus, _branch) \
  419. if (!NT_SUCCESS(_NtStatus)) { \
  420. DebPrint((_sev_), \
  421. (PUCHAR)(_str " NTStatus: %s\n"), \
  422. DEBSUB, __LINE__, _p1, _p2, ErrLabelNT(_NtStatus) ); \
  423. goto _branch; \
  424. }
  425. #define CLEANUP3_NT(_sev_, _str, _p1, _p2, _p3, _NtStatus, _branch) \
  426. if (!NT_SUCCESS(_NtStatus)) { \
  427. DebPrint((_sev_), \
  428. (PUCHAR)(_str " NTStatus: %s\n"), \
  429. DEBSUB, __LINE__, _p1, _p2, _p3, ErrLabelNT(_NtStatus) ); \
  430. goto _branch; \
  431. }
  432. //
  433. // DPRINT_JS(sev, "display text", jerr)
  434. //
  435. #define DPRINT_JS(_sev_, _str, _jerr) \
  436. if (!JET_SUCCESS(_jerr)) { \
  437. DebPrint((_sev_), \
  438. (PUCHAR)(_str " JStatus: %s\n"), \
  439. DEBSUB, __LINE__, ErrLabelJet(_jerr) ); \
  440. }
  441. #define DPRINT1_JS(_sev_, _str, _p1, _jerr) \
  442. if (!JET_SUCCESS(_jerr)) { \
  443. DebPrint((_sev_), \
  444. (PUCHAR)(_str " JStatus: %s\n"), \
  445. DEBSUB, __LINE__, _p1, ErrLabelJet(_jerr) ); \
  446. }
  447. #define DPRINT2_JS(_sev_, _str, _p1, _p2, _jerr) \
  448. if (!JET_SUCCESS(_jerr)) { \
  449. DebPrint((_sev_), \
  450. (PUCHAR)(_str " JStatus: %s\n"), \
  451. DEBSUB, __LINE__, _p1, _p2, ErrLabelJet(_jerr) ); \
  452. }
  453. //
  454. // CLEANUP_JS(sev, "display text", jerr, branch_target)
  455. // Like DPRINT but takes a branch target as last arg if success test fails.
  456. //
  457. #define CLEANUP_JS(_sev_, _str, _jerr, _branch) \
  458. if (!JET_SUCCESS(_jerr)) { \
  459. DebPrint((_sev_), \
  460. (PUCHAR)(_str " JStatus: %s\n"), \
  461. DEBSUB, __LINE__, ErrLabelJet(_jerr) ); \
  462. goto _branch; \
  463. }
  464. #define CLEANUP1_JS(_sev_, _str, _p1, _jerr, _branch) \
  465. if (!JET_SUCCESS(_jerr)) { \
  466. DebPrint((_sev_), \
  467. (PUCHAR)(_str " JStatus: %s\n"), \
  468. DEBSUB, __LINE__, _p1, ErrLabelJet(_jerr) ); \
  469. goto _branch; \
  470. }
  471. #define CLEANUP2_JS(_sev_, _str, _p1, _p2, _jerr, _branch) \
  472. if (!JET_SUCCESS(_jerr)) { \
  473. DebPrint((_sev_), \
  474. (PUCHAR)(_str " JStatus: %s\n"), \
  475. DEBSUB, __LINE__, _p1, _p2, ErrLabelJet(_jerr) ); \
  476. goto _branch; \
  477. }
  478. //
  479. // DPRINT_LS(sev, "display text", LDAP_Status)
  480. //
  481. #define DPRINT_LS(_sev_, _str, _LStatus) \
  482. if (!LDP_SUCCESS(_LStatus)) { \
  483. DebPrint((_sev_), \
  484. (PUCHAR)(_str " Ldap Status: %ws\n"), \
  485. DEBSUB, __LINE__, ldap_err2string(_LStatus) ); \
  486. }
  487. #define DPRINT1_LS(_sev_, _str, _p1, _LStatus) \
  488. if (!LDP_SUCCESS(_LStatus)) { \
  489. DebPrint((_sev_), \
  490. (PUCHAR)(_str " Ldap Status: %ws\n"), \
  491. DEBSUB, __LINE__, _p1, ldap_err2string(_LStatus) ); \
  492. }
  493. #define DPRINT2_LS(_sev_, _str, _p1, _p2, _LStatus) \
  494. if (!LDP_SUCCESS(_LStatus)) { \
  495. DebPrint((_sev_), \
  496. (PUCHAR)(_str " Ldap Status: %ws\n"), \
  497. DEBSUB, __LINE__, _p1, _p2, ldap_err2string(_LStatus) ); \
  498. }
  499. #define DPRINT3_LS(_sev_, _str, _p1, _p2, _p3, _LStatus) \
  500. if (!LDP_SUCCESS(_LStatus)) { \
  501. DebPrint((_sev_), \
  502. (PUCHAR)(_str " Ldap Status: %ws\n"), \
  503. DEBSUB, __LINE__, _p1, _p2, _p3, ldap_err2string(_LStatus) ); \
  504. }
  505. //
  506. // CLEANUP_LS(sev, "display text", LDAP_Status, branch_target)
  507. // Like DPRINT but takes a branch target as last arg if success test fails.
  508. //
  509. #define CLEANUP_LS(_sev_, _str, _LStatus, _branch) \
  510. if (!LDP_SUCCESS(_LStatus)) { \
  511. DebPrint((_sev_), \
  512. (PUCHAR)(_str " Ldap Status: %ws\n"), \
  513. DEBSUB, __LINE__, ldap_err2string(_LStatus) ); \
  514. goto _branch; \
  515. }
  516. #define CLEANUP1_LS(_sev_, _str, _p1, _LStatus, _branch) \
  517. if (!LDP_SUCCESS(_LStatus)) { \
  518. DebPrint((_sev_), \
  519. (PUCHAR)(_str " Ldap Status: %ws\n"), \
  520. DEBSUB, __LINE__, _p1, ldap_err2string(_LStatus) ); \
  521. goto _branch; \
  522. }
  523. #define CLEANUP2_LS(_sev_, _str, _p1, _p2, _LStatus, _branch) \
  524. if (!LDP_SUCCESS(_LStatus)) { \
  525. DebPrint((_sev_), \
  526. (PUCHAR)(_str " Ldap Status: %ws\n"), \
  527. DEBSUB, __LINE__, _p1, _p2, ldap_err2string(_LStatus) ); \
  528. goto _branch; \
  529. }
  530. #define CLEANUP3_LS(_sev_, _str, _p1, _p2, _p3, _LStatus, _branch) \
  531. if (!LDP_SUCCESS(_LStatus)) { \
  532. DebPrint((_sev_), \
  533. (PUCHAR)(_str " Ldap Status: %ws\n"), \
  534. DEBSUB, __LINE__, _p1, _p2, _p3, ldap_err2string(_LStatus) ); \
  535. goto _branch; \
  536. }
  537. //
  538. // Send Mail
  539. //
  540. #if 0
  541. VOID
  542. DbgSendMail(
  543. IN PCHAR Subject,
  544. IN PCHAR Content
  545. );
  546. #define SENDMAIL(_Subject_, _Content_) DbgSendMail(_Subject_, _Content_)
  547. #endif 0
  548. //
  549. // Define the debug initialization routine
  550. //
  551. VOID
  552. DbgInitLogTraceFile(
  553. IN LONG argc,
  554. IN PWCHAR *argv
  555. );
  556. VOID
  557. DbgMustInit(
  558. IN LONG argc,
  559. IN PWCHAR *argv
  560. );
  561. VOID
  562. DbgCaptureThreadInfo(
  563. PWCHAR ArgName,
  564. PTHREAD_START_ROUTINE EntryPoint
  565. );
  566. VOID
  567. DbgCaptureThreadInfo2(
  568. PWCHAR ArgName,
  569. PTHREAD_START_ROUTINE EntryPoint,
  570. ULONG ThreadId
  571. );
  572. VOID
  573. DbgMinimumInit(
  574. VOID
  575. );
  576. VOID
  577. DbgFlush(
  578. VOID
  579. );
  580. #define DEBUG_FLUSH() DbgFlush()
  581. VOID
  582. DbgDoAssert(
  583. IN PCHAR,
  584. IN UINT,
  585. IN PCHAR
  586. );
  587. #define FRS_ASSERT(_exp) { if (!(_exp)) DbgDoAssert(#_exp, __LINE__, DEBSUB); }
  588. #define FRS_FORCE_ACCVIO \
  589. DPRINT(0, "FRS_FORCE_ACCVIO\n"); \
  590. *((PULONG) (0)) = 0;
  591. #define XRAISEGENEXCEPTION(_x) {RaiseException((_x) ,EXCEPTION_NONCONTINUABLE,0,0);}
  592. //
  593. // Used for stack trace and tests
  594. //
  595. #define STACK_TRACE(_Stack_, _Depth_) \
  596. DbgStackTrace(_Stack_, _Depth_)
  597. #define STACK_PRINT(_Severity_, _Stack_, _Depth_) \
  598. DbgStackPrint(_Severity_, DEBSUB, __LINE__, _Stack_, _Depth_)
  599. #define STACK_TRACE_AND_PRINT(_Severity_) \
  600. DbgPrintStackTrace(_Severity_, DEBSUB, __LINE__)
  601. VOID
  602. DbgStackTrace(
  603. PULONG_PTR Stack,
  604. ULONG Depth
  605. );
  606. VOID
  607. DbgStackPrint(
  608. ULONG Severity,
  609. PCHAR Debsub,
  610. UINT LineNo,
  611. PULONG_PTR Stack,
  612. ULONG Depth
  613. );
  614. VOID
  615. DbgPrintStackTrace(
  616. ULONG Severity,
  617. PCHAR Debsub,
  618. UINT LineNo
  619. );
  620. //
  621. // check for improper cleanup at shutdown
  622. //
  623. extern VOID JrnlDumpVmeFilterTable(VOID);
  624. #ifdef __cplusplus
  625. }
  626. #endif
  627. #endif /* _debug_h_ */