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.

838 lines
49 KiB

  1. /**INC+**********************************************************************/
  2. /* Header: atrcapi.h */
  3. /* */
  4. /* Purpose: tracing API header */
  5. /* */
  6. /* Copyright(C) Microsoft Corporation 1997 */
  7. /* */
  8. /****************************************************************************/
  9. /** Changes:
  10. * $Log: Y:/logs/h/dcl/atrcapi.h_v $
  11. *
  12. * Rev 1.12 05 Sep 1997 10:36:56 SJ
  13. * SFR1334: Zippy enhancements
  14. *
  15. * Rev 1.11 01 Sep 1997 19:44:04 SJ
  16. * SFR1333: win16 trace DLL fails to set its default trace options
  17. *
  18. * Rev 1.10 28 Aug 1997 14:46:08 SJ
  19. * SFR1004: Use new trace groups - modify zippy accordingly
  20. *
  21. * Rev 1.9 22 Aug 1997 15:10:20 SJ
  22. * SFR1291: Win16 Trace DLL doesn't write integers to ini file properly
  23. *
  24. * Rev 1.8 19 Aug 1997 10:58:26 SJ
  25. * SFR1219: UT_Malloc and UT_Free tracing is confusing
  26. *
  27. * Rev 1.7 31 Jul 1997 19:40:38 SJ
  28. * SFR1041: Port zippy to Win16
  29. *
  30. * Rev 1.6 14 Jul 1997 12:47:36 SJ
  31. * SFR1004: Use new trace groups
  32. *
  33. * Rev 1.5 09 Jul 1997 17:05:00 AK
  34. * SFR1016: Initial changes to support Unicode
  35. **/
  36. /**INC-**********************************************************************/
  37. #ifndef _H_ATRCAPI
  38. #define _H_ATRCAPI
  39. #ifdef __cplusplus
  40. extern "C" {
  41. #endif /* __cplusplus */
  42. /****************************************************************************/
  43. /* */
  44. /* CONSTANTS */
  45. /* */
  46. /****************************************************************************/
  47. /****************************************************************************/
  48. /* Define the trace level. */
  49. /* */
  50. /* TRC_LEVEL_DBG : All tracing is enabled */
  51. /* TRC_LEVEL_NRM : Debug level tracing is disabled */
  52. /* TRC_LEVEL_ALT : Normal and debug level tracing is disabled */
  53. /* TRC_LEVEL_ERR : Alert, normal and debug level tracing is */
  54. /* disabled */
  55. /* TRC_LEVEL_ASSERT : Error, alert, normal and debug level tracing */
  56. /* is disabled */
  57. /* TRC_LEVEL_DIS : All tracing is disabled. */
  58. /****************************************************************************/
  59. #define TRC_LEVEL_DBG 0
  60. #define TRC_LEVEL_NRM 1
  61. #define TRC_LEVEL_ALT 2
  62. #define TRC_LEVEL_ERR 3
  63. #define TRC_LEVEL_ASSERT 4
  64. #define TRC_LEVEL_DIS 5
  65. /****************************************************************************/
  66. /* Trace type for profile tracing (function entry / exit) */
  67. /****************************************************************************/
  68. #define TRC_PROFILE_TRACE 8
  69. /****************************************************************************/
  70. /* Tracing can be switched off at compile time to allow for 'debug' and */
  71. /* 'retail' versions of the product. The following macros disable specific */
  72. /* trace processing. */
  73. /* */
  74. /* TRC_ENABLE_DBG - Enable debug tracing */
  75. /* TRC_ENABLE_NRM - Enable normal tracing */
  76. /* TRC_ENABLE_ALT - Enable alert tracing */
  77. /* TRC_ENABLE_ERR - Enable error tracing */
  78. /* TRC_ENABLE_ASSERT - Enable assert tracing */
  79. /* TRC_ENABLE_PRF - Enable function profile tracing */
  80. /****************************************************************************/
  81. #if (TRC_CL == TRC_LEVEL_DBG)
  82. #define TRC_ENABLE_DBG
  83. #define TRC_ENABLE_NRM
  84. #define TRC_ENABLE_ALT
  85. #define TRC_ENABLE_ERR
  86. #define TRC_ENABLE_ASSERT
  87. #endif
  88. #if (TRC_CL == TRC_LEVEL_NRM)
  89. #define TRC_ENABLE_NRM
  90. #define TRC_ENABLE_ALT
  91. #define TRC_ENABLE_ERR
  92. #define TRC_ENABLE_ASSERT
  93. #endif
  94. #if (TRC_CL == TRC_LEVEL_ALT)
  95. #define TRC_ENABLE_ALT
  96. #define TRC_ENABLE_ERR
  97. #define TRC_ENABLE_ASSERT
  98. #endif
  99. #if (TRC_CL == TRC_LEVEL_ERR)
  100. #define TRC_ENABLE_ERR
  101. #define TRC_ENABLE_ASSERT
  102. #endif
  103. #if (TRC_CL == TRC_LEVEL_ASSERT)
  104. #define TRC_ENABLE_ASSERT
  105. #endif
  106. #ifdef TRC_CP
  107. #define TRC_ENABLE_PRF
  108. #endif
  109. /****************************************************************************/
  110. /* Component groups. These are as follows: */
  111. /* */
  112. /* Client side: */
  113. /* TRC_GROUP_NETWORK : Network layer */
  114. /* TRC_GROUP_SECURITY : Security layer */
  115. /* TRC_GROUP_CORE : The core */
  116. /* TRC_GROUP_UI : User Interface */
  117. /* TRC_GROUP_UTILITIES : Utilities */
  118. /* TRC_GROUP_UNUSEDx : UNUSED */
  119. /* TRC_GROUP_TRACE */
  120. /* */
  121. /****************************************************************************/
  122. #define TRC_GROUP_NETWORK DCFLAGN(0)
  123. #define TRC_GROUP_SECURITY DCFLAGN(1)
  124. #define TRC_GROUP_CORE DCFLAGN(2)
  125. #define TRC_GROUP_UI DCFLAGN(3)
  126. #define TRC_GROUP_UTILITIES DCFLAGN(4)
  127. #define TRC_GROUP_UNUSED1 DCFLAGN(5)
  128. #define TRC_GROUP_UNUSED2 DCFLAGN(6)
  129. #define TRC_GROUP_UNUSED3 DCFLAGN(7)
  130. #define TRC_GROUP_UNUSED4 DCFLAGN(8)
  131. #define TRC_GROUP_UNUSED5 DCFLAGN(9)
  132. #define TRC_GROUP_TRACE DCFLAGN(10)
  133. /****************************************************************************/
  134. /* TRC_GROUP must be defined - if it is not defined then display an error. */
  135. /****************************************************************************/
  136. #ifndef TRC_GROUP
  137. #error TRC_GROUP must be defined
  138. #endif /* ifndef TRC_GROUP */
  139. /****************************************************************************/
  140. /* Trace option flags. These set various tracing options as follows: */
  141. /* */
  142. /* TRC_OPT_BREAK_ON_ERROR : Break to the debugger on an error. */
  143. /* TRC_OPT_BEEP_ON_ERROR : Beep on an error. */
  144. /* TRC_OPT_FILE_OUTPUT : Direct trace output to a disk file. */
  145. /* TRC_OPT_DEBUGGER_OUTPUT : Direct trace output to the debugger. */
  146. /* TRC_OPT_FLUSH_ON_TRACE : Flush each trace line to the disk file. */
  147. /* TRC_OPT_PROFILE_TRACING : Enable profile tracing. */
  148. /* TRC_OPT_STACK_TRACING : Enable stack tracing. */
  149. /* TRC_OPT_PROCESS_ID : Display the process ID on every trace line.*/
  150. /* TRC_OPT_THREAD_ID : Display the thread (Win32 only) on every */
  151. /* trace line. */
  152. /* TRC_OPT_TIME_STAMP : Display the time stamp on every line. */
  153. /* TRC_OPT_RELATIVE_TIME_STAMP : (Reserved) Display the relative time. */
  154. /* TRC_OPT_BREAK_ON_ASSERT : Break to the debugger on ASSERTS */
  155. /****************************************************************************/
  156. #define TRC_OPT_BREAK_ON_ERROR DCFLAG32(0)
  157. #define TRC_OPT_BEEP_ON_ERROR DCFLAG32(1)
  158. #define TRC_OPT_FILE_OUTPUT DCFLAG32(2)
  159. #define TRC_OPT_DEBUGGER_OUTPUT DCFLAG32(3)
  160. #define TRC_OPT_FLUSH_ON_TRACE DCFLAG32(4)
  161. #define TRC_OPT_PROFILE_TRACING DCFLAG32(5)
  162. #define TRC_OPT_STACK_TRACING DCFLAG32(6)
  163. #define TRC_OPT_PROCESS_ID DCFLAG32(7)
  164. #define TRC_OPT_THREAD_ID DCFLAG32(8)
  165. #define TRC_OPT_TIME_STAMP DCFLAG32(9)
  166. #define TRC_OPT_RELATIVE_TIME_STAMP DCFLAG32(10)
  167. #define TRC_OPT_BREAK_ON_ASSERT DCFLAG32(11)
  168. /****************************************************************************/
  169. /* Character versions of the maximum and minimum trace levels. */
  170. /****************************************************************************/
  171. #define TRC_LEVEL_MIN_CHAR '0'
  172. #define TRC_LEVEL_MAX_CHAR '5'
  173. /****************************************************************************/
  174. /* Character for function entry / exit tracing. */
  175. /****************************************************************************/
  176. #define TRC_LEVEL_PRF_CHAR 'P'
  177. /****************************************************************************/
  178. /* The TRC_TEST macro can be compiled in or out. When compiled in, it is */
  179. /* equivalent to TRC_DBG. It is normally compiled out. To compile it in, */
  180. /* define TRC_ENABLE_TST. */
  181. /****************************************************************************/
  182. #ifdef TRC_ENABLE_TST
  183. #define TRC_TST TRC_DBG
  184. #else
  185. #define TRC_TST(x)
  186. #endif /* TRC_ENABLE_TST */
  187. /****************************************************************************/
  188. /* The trace function naming macro. */
  189. /****************************************************************************/
  190. #if (TRC_CL < TRC_LEVEL_DIS)
  191. #define TRC_FN(A) static const DCTCHAR __fnname[] = _T(A); \
  192. PDCTCHAR trc_fn = (PDCTCHAR)__fnname; \
  193. PDCTCHAR trc_file = _file_name_;
  194. #else
  195. #define TRC_FN(A)
  196. #endif
  197. /****************************************************************************/
  198. /* Entry and exit trace macros. */
  199. /****************************************************************************/
  200. #define TRC_ENTRY TRC_PRF((TB, TEXT("Enter {")));
  201. #define TRC_EXIT TRC_PRF((TB, TEXT("Exit }")));
  202. /****************************************************************************/
  203. /* Trace buffer definition. */
  204. /* see TRCX below */
  205. /* the second parameter is the length of the output buffer in characters */
  206. /* (TRC_LINE_BUFFER_SIZE) */
  207. /****************************************************************************/
  208. #define TB TRC_GetBuffer(), 255
  209. /****************************************************************************/
  210. /* Internal buffer sizes. */
  211. /* */
  212. /* TRC_PREFIX_LIST_SIZE : the length of the prefix string */
  213. /* TRC_LINE_BUFFER_SIZE : the length of the raw trace string as output by */
  214. /* an application */
  215. /* TRC_FRMT_BUFFER_SIZE : the length of the formatted trace string */
  216. /* buffer - this includes the time, process ID, */
  217. /* thread ID and function name - It must be longer */
  218. /* than TRC_LINE_BUFFER_SIZE */
  219. /* TRC_FILE_NAME_SIZE : the maximum length of the fully qualified */
  220. /* trace output file name. */
  221. /****************************************************************************/
  222. #define TRC_PREFIX_LIST_SIZE 100
  223. #define TRC_LINE_BUFFER_SIZE 256
  224. #define TRC_FRMT_BUFFER_SIZE 400
  225. #define TRC_FILE_NAME_SIZE DC_MAX_PATH
  226. /****************************************************************************/
  227. /* The number of trace files. This must be set to 2 - any other number is */
  228. /* not supported. */
  229. /****************************************************************************/
  230. #define TRC_NUM_FILES 2
  231. /****************************************************************************/
  232. /* The minimum and maximum file sizes. */
  233. /* In Win32, the trace DLL will fail to initialize if the file size is set */
  234. /* to zero or to too high a value. */
  235. /* Go for 1 Kb to 32 Meg. */
  236. /****************************************************************************/
  237. #define TRC_MIN_TRC_FILE_SIZE (0x400)
  238. #define TRC_MAX_TRC_FILE_SIZE (0x2000000)
  239. /****************************************************************************/
  240. /* Defaults */
  241. /****************************************************************************/
  242. /****************************************************************************/
  243. /* This is a copy of the comment in TRCSetDefaults, which should be updated */
  244. /* whenever these defaults change. */
  245. /* */
  246. /* We set the following things: */
  247. /* */
  248. /* - trace level to Alert. */
  249. /* - enable all component groups. */
  250. /* - remove all prefixes. */
  251. /* - set the maximum trace file size to the default value. */
  252. /* - set the data truncation size to the default value. */
  253. /* - set the function name size to the default value. */
  254. /* - enable the beep and file flags. */
  255. /* - set the first trace file name to TRC1.TXT */
  256. /* - set the second trace file name to TRC2.TXT */
  257. /* In Win32, additionally */
  258. /* - set time stamp */
  259. /* - set process ID */
  260. /* - set thread ID */
  261. /* */
  262. /****************************************************************************/
  263. #define TRC_DEFAULT_MAX_FILE_SIZE (100000)
  264. #define TRC_DEFAULT_FUNC_NAME_LENGTH (12)
  265. #define TRC_DEFAULT_DATA_TRUNC_SIZE (64)
  266. #define TRC_DEFAULT_PREFIX_LIST (0)
  267. #define TRC_DEFAULT_COMPONENTS (0xFFFFFFFF)
  268. #ifdef OS_WIN32
  269. #ifdef OS_WINCE
  270. #define TRC_DEFAULT_FLAGS (TRC_OPT_BEEP_ON_ERROR | \
  271. TRC_OPT_DEBUGGER_OUTPUT | \
  272. TRC_OPT_THREAD_ID | \
  273. TRC_OPT_TIME_STAMP )
  274. #else // OS_WINCE
  275. #define TRC_DEFAULT_FLAGS (TRC_OPT_DEBUGGER_OUTPUT | \
  276. TRC_OPT_FILE_OUTPUT | \
  277. TRC_OPT_PROCESS_ID | \
  278. TRC_OPT_THREAD_ID | \
  279. TRC_OPT_TIME_STAMP )
  280. #endif // OS_WINCE
  281. #else ifdef OS_WIN16
  282. #define TRC_DEFAULT_FLAGS (TRC_OPT_BEEP_ON_ERROR | \
  283. TRC_OPT_DEBUGGER_OUTPUT | \
  284. TRC_OPT_FILE_OUTPUT )
  285. #endif
  286. #define TRC_DEFAULT_TRACE_LEVEL (TRC_LEVEL_ERR)
  287. #define TRC_DEFAULT_FILE_NAME0 (_T("TRC1.TXT"))
  288. #define TRC_DEFAULT_FILE_NAME1 (_T("TRC2.TXT"))
  289. /****************************************************************************/
  290. /* */
  291. /* TYPEDEFS */
  292. /* */
  293. /****************************************************************************/
  294. /****************************************************************************/
  295. /* TRC_CONFIG */
  296. /* ========== */
  297. /* This structure stores information about the current trace configuration. */
  298. /* */
  299. /* traceLevel : the current trace level. */
  300. /* components : currently enabled component groups. */
  301. /* maxFileSize : the maximum trace file size. */
  302. /* dataTruncSize : the amount of data that can be traced at a time. */
  303. /* flags : trace flags. */
  304. /* funcNameLength : number of characters of the function name traced to */
  305. /* the output file. */
  306. /* prefixList : a list of prefixes. */
  307. /* fileNames : the name of the trace files. */
  308. /* */
  309. /****************************************************************************/
  310. typedef struct tagTRC_CONFIG
  311. {
  312. DCUINT32 traceLevel;
  313. DCUINT32 dataTruncSize;
  314. DCUINT32 funcNameLength;
  315. DCUINT32 components;
  316. DCUINT32 maxFileSize;
  317. DCUINT32 flags;
  318. DCTCHAR prefixList[TRC_PREFIX_LIST_SIZE];
  319. DCTCHAR fileNames[TRC_NUM_FILES][TRC_FILE_NAME_SIZE];
  320. } TRC_CONFIG;
  321. typedef TRC_CONFIG DCPTR PTRC_CONFIG;
  322. /****************************************************************************/
  323. /* */
  324. /* MACROS */
  325. /* */
  326. /****************************************************************************/
  327. /****************************************************************************/
  328. /* STANDARD TRACING AND ASSERTION MACROS */
  329. /* */
  330. /* TRC_ASSERT is for internal assertions and traces an error before popping */
  331. /* up a message box and then terminating. It is not NLS enabled and should */
  332. /* only be used for calls from one DC component to another. External APIs */
  333. /* must not use TRC_ASSERT. */
  334. /* */
  335. /* TRC_ABORT is used on logically unreachable paths (for example */
  336. /* the default brach of a switch which should cover all cases already). */
  337. /* */
  338. /* A typical trace statement will have the form: */
  339. /* */
  340. /* TRC_NRM((TB, _T("Hello world: %hu"), worldNumber)); */
  341. /* */
  342. /* The following macros either expand this to: */
  343. /* */
  344. /* TRCX(TRC_LEVEL_NRM, (TB, _T("Hello world: %hu"), worldNumber)); */
  345. /* */
  346. /* if normal level tracing is enabled or ignore it if normal level tracing */
  347. /* is disabled. */
  348. /* */
  349. /****************************************************************************/
  350. #ifdef TRC_ENABLE_DBG
  351. #define TRC_DBG(string) TRCX(TRC_LEVEL_DBG, string)
  352. #else
  353. #define TRC_DBG(string)
  354. #endif
  355. #ifdef TRC_ENABLE_NRM
  356. #define TRC_NRM(string) TRCX(TRC_LEVEL_NRM, string)
  357. #else
  358. #define TRC_NRM(string)
  359. #endif
  360. #ifdef TRC_ENABLE_ALT
  361. #define TRC_ALT(string) TRCX(TRC_LEVEL_ALT, string)
  362. #else
  363. #define TRC_ALT(string)
  364. #endif
  365. #ifdef TRC_ENABLE_ERR
  366. #define TRC_ERR(string) TRCX(TRC_LEVEL_ERR, string)
  367. #else
  368. #define TRC_ERR(string)
  369. #endif
  370. #ifdef TRC_ENABLE_ASSERT
  371. #define TRC_ASSERT(condition, string) \
  372. if (!(condition)) TRCX(TRC_LEVEL_ASSERT, string)
  373. #define TRC_ABORT(string) TRCX(TRC_LEVEL_ASSERT, string)
  374. #else
  375. #define TRC_ASSERT(condition, string)
  376. #define TRC_ABORT(string)
  377. #endif
  378. /****************************************************************************/
  379. /* Function profile (entry/exit) tracing. */
  380. /****************************************************************************/
  381. #ifdef TRC_ENABLE_PRF
  382. #define TRC_PRF(string) TRCP(string)
  383. #else
  384. #define TRC_PRF(string)
  385. #endif
  386. VOID TRCSaferSprintf(PDCTCHAR outBuf, UINT cchLen, const PDCTCHAR format,...);
  387. /****************************************************************************/
  388. /* Now define the actual tracing macro, TRCX. This macro compares the */
  389. /* tracer's level against the global trace level. If the tracer's level is */
  390. /* the same or higher than the global trace level then we: */
  391. /* */
  392. /* - print the 'string' which is in the form: */
  393. /* (TB, _T("Hello world %hu"), worldNumber) which expands to */
  394. /* (TRC_BufferGet(), "Hello world %hu", worldNumber) */
  395. /* - call TRC_BufferTrace to actually trace the line out. */
  396. /* */
  397. /* Note that TRC_BufferGet() also grabs the mutex to prevent other threads */
  398. /* from pre-empting us while we are tracing and that TRC_BufferTrace() will */
  399. /* free the mutex for us once the trace line has been written. */
  400. /****************************************************************************/
  401. /****************************************************************************/
  402. /* Use the comma operator to make sure that TRCX macros to an Lvalue. */
  403. /* The innermost trc_fn is simply there to ensure that the whole expression */
  404. /* is assignable. It can be replaced by any other variable, if need be. */
  405. /****************************************************************************/
  406. #if !defined(TRC_CONVERTOANSI)
  407. #define TRCX(level, string) \
  408. ( \
  409. (level >= TRC_GetTraceLevel()) ? \
  410. ( \
  411. (TRCSaferSprintf string, \
  412. TRC_TraceBuffer(level, TRC_GROUP, (DCUINT)__LINE__, trc_fn, trc_file),\
  413. trc_fn) \
  414. ) \
  415. : \
  416. 0 \
  417. )
  418. #define TRCP(string) \
  419. { \
  420. if (TRC_ProfileTraceEnabled()) \
  421. { \
  422. TRCSaferSprintf string, \
  423. TRC_TraceBuffer(TRC_PROFILE_TRACE, \
  424. TRC_GROUP, \
  425. (DCUINT)__LINE__, \
  426. trc_fn, \
  427. trc_file); \
  428. } \
  429. }
  430. #else
  431. #define TRCX(level, string) \
  432. ( \
  433. (level >= TRC_GetTraceLevel()) ? \
  434. ( \
  435. ( \
  436. TRC_ConvertAndSprintf string, \
  437. TRC_TraceBuffer(level, TRC_GROUP, (DCUINT)__LINE__, trc_fn, trc_file),\
  438. trc_fn) \
  439. ) \
  440. : \
  441. 0 \
  442. )
  443. #define TRCP(string) \
  444. { \
  445. if (TRC_ProfileTraceEnabled()) \
  446. { \
  447. TRC_ConvertAndSprintf string; \
  448. TRC_TraceBuffer(TRC_PROFILE_TRACE, \
  449. TRC_GROUP, \
  450. (DCUINT)__LINE__, \
  451. trc_fn, \
  452. trc_file); \
  453. } \
  454. }
  455. #endif
  456. /****************************************************************************/
  457. /* TRACE DATA MACROS */
  458. /* */
  459. /* These are very similar to the standard tracing macros defined above */
  460. /* except that they do not accept a variable number of parameters. */
  461. /* */
  462. /* A typical ObMan data trace line will have the form: */
  463. /* */
  464. /* TRC_DATA_NRM("Some data", pData, sizeof(SOME_DATA)); */
  465. /* */
  466. /* If the appropriate level of tracing is enabled (normal in this case) */
  467. /* then this line will be expanded by the following macros to: */
  468. /* */
  469. /* TRCX_DATA(TRC_GROUP_OBMAN, TRC_LEVEL_NRM, "Some data", pData, size); */
  470. /* */
  471. /****************************************************************************/
  472. #ifdef TRC_ENABLE_DBG
  473. #define TRC_DATA_DBG(string, buffer, length) \
  474. TRCX_DATA(TRC_GROUP, TRC_LEVEL_DBG, _T(string), buffer, length)
  475. #else
  476. #define TRC_DATA_DBG(string, buffer, length)
  477. #endif
  478. #ifdef TRC_ENABLE_NRM
  479. #define TRC_DATA_NRM(string, buffer, length) \
  480. TRCX_DATA(TRC_GROUP, TRC_LEVEL_NRM, _T(string), buffer, length)
  481. #else
  482. #define TRC_DATA_NRM(string, buffer, length)
  483. #endif
  484. #ifdef TRC_ENABLE_ALT
  485. #define TRC_DATA_ALT(string, buffer, length) \
  486. TRCX_DATA(TRC_GROUP, TRC_LEVEL_ALT, _T(string), buffer, length)
  487. #else
  488. #define TRC_DATA_ALT(string, buffer, length)
  489. #endif
  490. #ifdef TRC_ENABLE_ERR
  491. #define TRC_DATA_ERR(string, buffer, length) \
  492. TRCX_DATA(TRC_GROUP, TRC_LEVEL_ERR, _T(string), buffer, length)
  493. #else
  494. #define TRC_DATA_ERR(string, buffer, length)
  495. #endif
  496. /****************************************************************************/
  497. /* Network, TDD and Obman trace data macros - these are just normal level */
  498. /* data tracing. */
  499. /****************************************************************************/
  500. #ifdef TRC_ENABLE_NRM
  501. #define TRC_DATA_NET(string, buffer, length) \
  502. TRCX_DATA(TRC_GROUP_NETDATA, TRC_LEVEL_NRM, string, buffer, length)
  503. #define TRC_DATA_TDD(string, buffer, length) \
  504. TRCX_DATA(TRC_GROUP_TDDDATA, TRC_LEVEL_NRM, string, buffer, length)
  505. #define TRC_DATA_OBMAN(string, buffer, length) \
  506. TRCX_DATA(TRC_GROUP_OBMANDATA, TRC_LEVEL_NRM, string, buffer, length)
  507. #else
  508. #define TRC_DATA_NET(string, buffer, length)
  509. #define TRC_DATA_TDD(string, buffer, length)
  510. #define TRC_DATA_OBMAN(string, buffer, length)
  511. #endif
  512. /****************************************************************************/
  513. /* Define the trace data macro. This is used for tracing data blocks. */
  514. /****************************************************************************/
  515. #define TRCX_DATA(group, level, string, buffer, length) \
  516. { \
  517. if (level >= TRC_GetTraceLevel()) \
  518. { \
  519. TRCSaferSprintf(TB, string); \
  520. TRC_TraceData(level, \
  521. group, \
  522. (DCINT)__LINE__, \
  523. trc_fn, \
  524. trc_file, \
  525. (PDCUINT8)buffer, \
  526. length); \
  527. } \
  528. }
  529. /****************************************************************************/
  530. /* */
  531. /* FUNCTION PROTOTYPES */
  532. /* */
  533. /****************************************************************************/
  534. /* */
  535. /* TRC_Initialize */
  536. /* TRC_Terminate */
  537. /* TRC_GetBuffer */
  538. /* TRC_TraceBuffer */
  539. /* TRC_GetConfig */
  540. /* TRC_SetConfig */
  541. /* TRC_TraceData */
  542. /* TRC_GetTraceLevel */
  543. /* TRC_ProfileTraceEnabled */
  544. /* */
  545. /****************************************************************************/
  546. /****************************************************************************/
  547. /* API FUNCTION: TRC_Initialize(...) */
  548. /* */
  549. /* DESCRIPTION: */
  550. /* ============ */
  551. /* This function initializes the tracing for this component. */
  552. /* */
  553. /* PARAMETERS: */
  554. /* =========== */
  555. /* initShared : Boolean indicating whether we should attempt to create */
  556. /* the trace config shared memory or not. */
  557. /* */
  558. /* RETURNS: */
  559. /* ======== */
  560. /* 0 : success. */
  561. /* TRC_RC_XXX : failure. */
  562. /* */
  563. /****************************************************************************/
  564. DCUINT32 DCAPI TRC_Initialize(DCBOOL initShared);
  565. /****************************************************************************/
  566. /* API FUNCTION: TRC_Terminate(...) */
  567. /* */
  568. /* DESCRIPTION: */
  569. /* ============ */
  570. /* This function terminates tracing for this component. */
  571. /* */
  572. /* PARAMETERS: */
  573. /* =========== */
  574. /* termShared : Boolean indicating if shared memory should be released */
  575. /* or not. */
  576. /* */
  577. /* RETURNS: */
  578. /* ======== */
  579. /* Nothing. */
  580. /* */
  581. /****************************************************************************/
  582. DCVOID DCAPI TRC_Terminate(DCBOOL termShared);
  583. /****************************************************************************/
  584. /* API FUNCTION: TRC_GetBuffer(...) */
  585. /* */
  586. /* DESCRIPTION: */
  587. /* ============ */
  588. /* This function grabs the mutex and returns a pointer to the trace */
  589. /* buffer. */
  590. /* */
  591. /* PARAMETERS: */
  592. /* =========== */
  593. /* None. */
  594. /* */
  595. /* RETURNS: */
  596. /* ======== */
  597. /* A pointer to the trace buffer. */
  598. /* */
  599. /****************************************************************************/
  600. PDCTCHAR DCAPI TRC_GetBuffer(DCVOID);
  601. /****************************************************************************/
  602. /* API FUNCTION: TRC_TraceBuffer(...) */
  603. /* */
  604. /* DESCRIPTION: */
  605. /* ============ */
  606. /* This function copies the trace line that is currently in the trace */
  607. /* buffer into the trace file and / or to the debugger. It assumes that the */
  608. /* mutex has already been acquired before it is called and releases the */
  609. /* mutex before returning. */
  610. /* */
  611. /* PARAMETERS: */
  612. /* =========== */
  613. /* traceLevel : the requested trace level. */
  614. /* traceComponent : the component group that the source file is in. */
  615. /* lineNumber : the line number of the source file traced from. */
  616. /* funcName : the function name traced from. */
  617. /* fileName : the file name of the module requesting trace. */
  618. /* */
  619. /* RETURNS: */
  620. /* ======== */
  621. /* Nothing. */
  622. /* */
  623. /****************************************************************************/
  624. DCVOID DCAPI TRC_TraceBuffer(DCUINT traceLevel,
  625. DCUINT traceComponent,
  626. DCUINT lineNumber,
  627. PDCTCHAR funcName,
  628. PDCTCHAR fileName);
  629. /****************************************************************************/
  630. /* API FUNCTION: TRC_GetConfig(...) */
  631. /* */
  632. /* DESCRIPTION: */
  633. /* ============ */
  634. /* This function copies the current trace settings into the buffer pointed */
  635. /* to by pTraceConfig. */
  636. /* */
  637. /* PARAMETERS: */
  638. /* =========== */
  639. /* pTraceConfig : a pointer to a TRC_CONFIG structure. */
  640. /* length : the length of the buffer. */
  641. /* */
  642. /* RETURNS: */
  643. /* ======== */
  644. /* TRUE : success. */
  645. /* FALSE : failure. */
  646. /* */
  647. /****************************************************************************/
  648. DCBOOL DCAPI TRC_GetConfig(PTRC_CONFIG pTraceConfig,
  649. DCUINT length);
  650. /****************************************************************************/
  651. /* API FUNCTION: TRC_SetConfig(...) */
  652. /* */
  653. /* DESCRIPTION: */
  654. /* ============ */
  655. /* This function sets the trace configuration to that specified in the */
  656. /* passed TRC_CONFIG structure. */
  657. /* */
  658. /* PARAMETERS: */
  659. /* =========== */
  660. /* pTraceConfig : a pointer to a TRC_CONFIG structure. */
  661. /* length : the length of the buffer. */
  662. /* */
  663. /* RETURNS: */
  664. /* ======== */
  665. /* TRUE : success. */
  666. /* FALSE : failure. */
  667. /* */
  668. /****************************************************************************/
  669. DCBOOL DCAPI TRC_SetConfig(PTRC_CONFIG pTraceConfig,
  670. DCUINT length);
  671. /****************************************************************************/
  672. /* API FUNCTION: TRC_TraceData(...) */
  673. /* */
  674. /* DESCRIPTION: */
  675. /* ============ */
  676. /* */
  677. /* PARAMETERS: */
  678. /* =========== */
  679. /* traceLevel : the requested trace level. */
  680. /* traceComponent : the component group that the source file is in. */
  681. /* lineNumber : the line number of the source file traced from. */
  682. /* funcName : the function name traced from. */
  683. /* fileName : the file name of the module requesting trace. */
  684. /* buffer : the actual data to be traced. */
  685. /* bufLength : the length of the data. */
  686. /* */
  687. /* RETURNS: */
  688. /* ======== */
  689. /* Nothing. */
  690. /* */
  691. /****************************************************************************/
  692. DCVOID DCAPI TRC_TraceData(DCUINT traceLevel,
  693. DCUINT traceComponent,
  694. DCUINT lineNumber,
  695. PDCTCHAR funcName,
  696. PDCTCHAR fileName,
  697. PDCUINT8 buffer,
  698. DCUINT bufLength);
  699. /****************************************************************************/
  700. /* API FUNCTION: TRC_GetTraceLevel(...) */
  701. /* */
  702. /* DESCRIPTION: */
  703. /* ============ */
  704. /* This function returns the current trace level. */
  705. /* */
  706. /* PARAMETERS: */
  707. /* =========== */
  708. /* None. */
  709. /* */
  710. /* RETURNS: */
  711. /* ======== */
  712. /* The current trace level. */
  713. /* */
  714. /****************************************************************************/
  715. DCUINT DCAPI TRC_GetTraceLevel(DCVOID);
  716. /****************************************************************************/
  717. /* API FUNCTION: TRC_ProfileTraceEnabled(...) */
  718. /* */
  719. /* DESCRIPTION: */
  720. /* ============ */
  721. /* This function returns the function entry/exit trace setting. */
  722. /* */
  723. /* PARAMETERS: */
  724. /* =========== */
  725. /* None. */
  726. /* */
  727. /* RETURNS: */
  728. /* ======== */
  729. /* TRUE / FALSE - is the profile tracing enabled. */
  730. /* */
  731. /****************************************************************************/
  732. DCBOOL DCAPI TRC_ProfileTraceEnabled(DCVOID);
  733. /****************************************************************************/
  734. /* API FUNCTION: TRC_ResetTraceFiles(...) */
  735. /* */
  736. /* DESCRIPTION: */
  737. /* ============ */
  738. /* This function resets the trace files. After checking that trace is */
  739. /* initialized it calls the OS specific internal function. */
  740. /* */
  741. /* PARAMETERS: */
  742. /* =========== */
  743. /* None. */
  744. /* */
  745. /* RETURNS: */
  746. /* ======== */
  747. /* TRUE / FALSE - is the profile tracing enabled. */
  748. /* */
  749. /****************************************************************************/
  750. DCBOOL DCAPI TRC_ResetTraceFiles(DCVOID);
  751. /****************************************************************************/
  752. /* Before including this file the TRC_FILE macro should be defined. This */
  753. /* is much more efficient than relying on __FILE__ to give the correct */
  754. /* filename since it includes unnecessary path info (and extension info). */
  755. /* In addition each use of __FILE__ causes a new constant string to be */
  756. /* placed in the data segment. */
  757. /****************************************************************************/
  758. #if (TRC_CL < TRC_LEVEL_DIS)
  759. /************************************************************************/
  760. /* Define another layer for _T() to work around preprocessor problems */
  761. /************************************************************************/
  762. #define TRC_T(x) _T(x)
  763. #ifdef TRC_FILE
  764. #define _file_name_ (PDCTCHAR)__filename
  765. static const DCTCHAR __filename[] = TRC_T(TRC_FILE);
  766. #endif /* TRC_FILE */
  767. #endif
  768. /****************************************************************************/
  769. /* */
  770. /* OPERATING SYSTEM SPECIFIC INCLUDES */
  771. /* */
  772. /****************************************************************************/
  773. #include <wtrcapi.h>
  774. #ifdef __cplusplus
  775. }
  776. #endif /* __cplusplus */
  777. #endif /* _H_ATRCAPI */