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.

839 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_BEEP_ON_ERROR | \
  276. TRC_OPT_DEBUGGER_OUTPUT | \
  277. TRC_OPT_FILE_OUTPUT | \
  278. TRC_OPT_PROCESS_ID | \
  279. TRC_OPT_THREAD_ID | \
  280. TRC_OPT_TIME_STAMP )
  281. #endif // OS_WINCE
  282. #else ifdef OS_WIN16
  283. #define TRC_DEFAULT_FLAGS (TRC_OPT_BEEP_ON_ERROR | \
  284. TRC_OPT_DEBUGGER_OUTPUT | \
  285. TRC_OPT_FILE_OUTPUT )
  286. #endif
  287. #define TRC_DEFAULT_TRACE_LEVEL (TRC_LEVEL_ALT)
  288. #define TRC_DEFAULT_FILE_NAME0 (_T("TRC1.TXT"))
  289. #define TRC_DEFAULT_FILE_NAME1 (_T("TRC2.TXT"))
  290. /****************************************************************************/
  291. /* */
  292. /* TYPEDEFS */
  293. /* */
  294. /****************************************************************************/
  295. /****************************************************************************/
  296. /* TRC_CONFIG */
  297. /* ========== */
  298. /* This structure stores information about the current trace configuration. */
  299. /* */
  300. /* traceLevel : the current trace level. */
  301. /* components : currently enabled component groups. */
  302. /* maxFileSize : the maximum trace file size. */
  303. /* dataTruncSize : the amount of data that can be traced at a time. */
  304. /* flags : trace flags. */
  305. /* funcNameLength : number of characters of the function name traced to */
  306. /* the output file. */
  307. /* prefixList : a list of prefixes. */
  308. /* fileNames : the name of the trace files. */
  309. /* */
  310. /****************************************************************************/
  311. typedef struct tagTRC_CONFIG
  312. {
  313. DCUINT32 traceLevel;
  314. DCUINT32 dataTruncSize;
  315. DCUINT32 funcNameLength;
  316. DCUINT32 components;
  317. DCUINT32 maxFileSize;
  318. DCUINT32 flags;
  319. DCTCHAR prefixList[TRC_PREFIX_LIST_SIZE];
  320. DCTCHAR fileNames[TRC_NUM_FILES][TRC_FILE_NAME_SIZE];
  321. } TRC_CONFIG;
  322. typedef TRC_CONFIG DCPTR PTRC_CONFIG;
  323. /****************************************************************************/
  324. /* */
  325. /* MACROS */
  326. /* */
  327. /****************************************************************************/
  328. /****************************************************************************/
  329. /* STANDARD TRACING AND ASSERTION MACROS */
  330. /* */
  331. /* TRC_ASSERT is for internal assertions and traces an error before popping */
  332. /* up a message box and then terminating. It is not NLS enabled and should */
  333. /* only be used for calls from one DC component to another. External APIs */
  334. /* must not use TRC_ASSERT. */
  335. /* */
  336. /* TRC_ABORT is used on logically unreachable paths (for example */
  337. /* the default brach of a switch which should cover all cases already). */
  338. /* */
  339. /* A typical trace statement will have the form: */
  340. /* */
  341. /* TRC_NRM((TB, _T("Hello world: %hu"), worldNumber)); */
  342. /* */
  343. /* The following macros either expand this to: */
  344. /* */
  345. /* TRCX(TRC_LEVEL_NRM, (TB, _T("Hello world: %hu"), worldNumber)); */
  346. /* */
  347. /* if normal level tracing is enabled or ignore it if normal level tracing */
  348. /* is disabled. */
  349. /* */
  350. /****************************************************************************/
  351. #ifdef TRC_ENABLE_DBG
  352. #define TRC_DBG(string) TRCX(TRC_LEVEL_DBG, string)
  353. #else
  354. #define TRC_DBG(string)
  355. #endif
  356. #ifdef TRC_ENABLE_NRM
  357. #define TRC_NRM(string) TRCX(TRC_LEVEL_NRM, string)
  358. #else
  359. #define TRC_NRM(string)
  360. #endif
  361. #ifdef TRC_ENABLE_ALT
  362. #define TRC_ALT(string) TRCX(TRC_LEVEL_ALT, string)
  363. #else
  364. #define TRC_ALT(string)
  365. #endif
  366. #ifdef TRC_ENABLE_ERR
  367. #define TRC_ERR(string) TRCX(TRC_LEVEL_ERR, string)
  368. #else
  369. #define TRC_ERR(string)
  370. #endif
  371. #ifdef TRC_ENABLE_ASSERT
  372. #define TRC_ASSERT(condition, string) \
  373. if (!(condition)) TRCX(TRC_LEVEL_ASSERT, string)
  374. #define TRC_ABORT(string) TRCX(TRC_LEVEL_ASSERT, string)
  375. #else
  376. #define TRC_ASSERT(condition, string)
  377. #define TRC_ABORT(string)
  378. #endif
  379. /****************************************************************************/
  380. /* Function profile (entry/exit) tracing. */
  381. /****************************************************************************/
  382. #ifdef TRC_ENABLE_PRF
  383. #define TRC_PRF(string) TRCP(string)
  384. #else
  385. #define TRC_PRF(string)
  386. #endif
  387. VOID TRCSaferSprintf(PDCTCHAR outBuf, UINT cchLen, const PDCTCHAR format,...);
  388. /****************************************************************************/
  389. /* Now define the actual tracing macro, TRCX. This macro compares the */
  390. /* tracer's level against the global trace level. If the tracer's level is */
  391. /* the same or higher than the global trace level then we: */
  392. /* */
  393. /* - print the 'string' which is in the form: */
  394. /* (TB, _T("Hello world %hu"), worldNumber) which expands to */
  395. /* (TRC_BufferGet(), "Hello world %hu", worldNumber) */
  396. /* - call TRC_BufferTrace to actually trace the line out. */
  397. /* */
  398. /* Note that TRC_BufferGet() also grabs the mutex to prevent other threads */
  399. /* from pre-empting us while we are tracing and that TRC_BufferTrace() will */
  400. /* free the mutex for us once the trace line has been written. */
  401. /****************************************************************************/
  402. /****************************************************************************/
  403. /* Use the comma operator to make sure that TRCX macros to an Lvalue. */
  404. /* The innermost trc_fn is simply there to ensure that the whole expression */
  405. /* is assignable. It can be replaced by any other variable, if need be. */
  406. /****************************************************************************/
  407. #if !defined(TRC_CONVERTOANSI)
  408. #define TRCX(level, string) \
  409. ( \
  410. (level >= TRC_GetTraceLevel()) ? \
  411. ( \
  412. (TRCSaferSprintf string, \
  413. TRC_TraceBuffer(level, TRC_GROUP, (DCUINT)__LINE__, trc_fn, trc_file),\
  414. trc_fn) \
  415. ) \
  416. : \
  417. 0 \
  418. )
  419. #define TRCP(string) \
  420. { \
  421. if (TRC_ProfileTraceEnabled()) \
  422. { \
  423. TRCSaferSprintf string, \
  424. TRC_TraceBuffer(TRC_PROFILE_TRACE, \
  425. TRC_GROUP, \
  426. (DCUINT)__LINE__, \
  427. trc_fn, \
  428. trc_file); \
  429. } \
  430. }
  431. #else
  432. #define TRCX(level, string) \
  433. ( \
  434. (level >= TRC_GetTraceLevel()) ? \
  435. ( \
  436. ( \
  437. TRC_ConvertAndSprintf string, \
  438. TRC_TraceBuffer(level, TRC_GROUP, (DCUINT)__LINE__, trc_fn, trc_file),\
  439. trc_fn) \
  440. ) \
  441. : \
  442. 0 \
  443. )
  444. #define TRCP(string) \
  445. { \
  446. if (TRC_ProfileTraceEnabled()) \
  447. { \
  448. TRC_ConvertAndSprintf string; \
  449. TRC_TraceBuffer(TRC_PROFILE_TRACE, \
  450. TRC_GROUP, \
  451. (DCUINT)__LINE__, \
  452. trc_fn, \
  453. trc_file); \
  454. } \
  455. }
  456. #endif
  457. /****************************************************************************/
  458. /* TRACE DATA MACROS */
  459. /* */
  460. /* These are very similar to the standard tracing macros defined above */
  461. /* except that they do not accept a variable number of parameters. */
  462. /* */
  463. /* A typical ObMan data trace line will have the form: */
  464. /* */
  465. /* TRC_DATA_NRM("Some data", pData, sizeof(SOME_DATA)); */
  466. /* */
  467. /* If the appropriate level of tracing is enabled (normal in this case) */
  468. /* then this line will be expanded by the following macros to: */
  469. /* */
  470. /* TRCX_DATA(TRC_GROUP_OBMAN, TRC_LEVEL_NRM, "Some data", pData, size); */
  471. /* */
  472. /****************************************************************************/
  473. #ifdef TRC_ENABLE_DBG
  474. #define TRC_DATA_DBG(string, buffer, length) \
  475. TRCX_DATA(TRC_GROUP, TRC_LEVEL_DBG, _T(string), buffer, length)
  476. #else
  477. #define TRC_DATA_DBG(string, buffer, length)
  478. #endif
  479. #ifdef TRC_ENABLE_NRM
  480. #define TRC_DATA_NRM(string, buffer, length) \
  481. TRCX_DATA(TRC_GROUP, TRC_LEVEL_NRM, _T(string), buffer, length)
  482. #else
  483. #define TRC_DATA_NRM(string, buffer, length)
  484. #endif
  485. #ifdef TRC_ENABLE_ALT
  486. #define TRC_DATA_ALT(string, buffer, length) \
  487. TRCX_DATA(TRC_GROUP, TRC_LEVEL_ALT, _T(string), buffer, length)
  488. #else
  489. #define TRC_DATA_ALT(string, buffer, length)
  490. #endif
  491. #ifdef TRC_ENABLE_ERR
  492. #define TRC_DATA_ERR(string, buffer, length) \
  493. TRCX_DATA(TRC_GROUP, TRC_LEVEL_ERR, _T(string), buffer, length)
  494. #else
  495. #define TRC_DATA_ERR(string, buffer, length)
  496. #endif
  497. /****************************************************************************/
  498. /* Network, TDD and Obman trace data macros - these are just normal level */
  499. /* data tracing. */
  500. /****************************************************************************/
  501. #ifdef TRC_ENABLE_NRM
  502. #define TRC_DATA_NET(string, buffer, length) \
  503. TRCX_DATA(TRC_GROUP_NETDATA, TRC_LEVEL_NRM, string, buffer, length)
  504. #define TRC_DATA_TDD(string, buffer, length) \
  505. TRCX_DATA(TRC_GROUP_TDDDATA, TRC_LEVEL_NRM, string, buffer, length)
  506. #define TRC_DATA_OBMAN(string, buffer, length) \
  507. TRCX_DATA(TRC_GROUP_OBMANDATA, TRC_LEVEL_NRM, string, buffer, length)
  508. #else
  509. #define TRC_DATA_NET(string, buffer, length)
  510. #define TRC_DATA_TDD(string, buffer, length)
  511. #define TRC_DATA_OBMAN(string, buffer, length)
  512. #endif
  513. /****************************************************************************/
  514. /* Define the trace data macro. This is used for tracing data blocks. */
  515. /****************************************************************************/
  516. #define TRCX_DATA(group, level, string, buffer, length) \
  517. { \
  518. if (level >= TRC_GetTraceLevel()) \
  519. { \
  520. TRCSaferSprintf(TB, string); \
  521. TRC_TraceData(level, \
  522. group, \
  523. (DCINT)__LINE__, \
  524. trc_fn, \
  525. trc_file, \
  526. (PDCUINT8)buffer, \
  527. length); \
  528. } \
  529. }
  530. /****************************************************************************/
  531. /* */
  532. /* FUNCTION PROTOTYPES */
  533. /* */
  534. /****************************************************************************/
  535. /* */
  536. /* TRC_Initialize */
  537. /* TRC_Terminate */
  538. /* TRC_GetBuffer */
  539. /* TRC_TraceBuffer */
  540. /* TRC_GetConfig */
  541. /* TRC_SetConfig */
  542. /* TRC_TraceData */
  543. /* TRC_GetTraceLevel */
  544. /* TRC_ProfileTraceEnabled */
  545. /* */
  546. /****************************************************************************/
  547. /****************************************************************************/
  548. /* API FUNCTION: TRC_Initialize(...) */
  549. /* */
  550. /* DESCRIPTION: */
  551. /* ============ */
  552. /* This function initializes the tracing for this component. */
  553. /* */
  554. /* PARAMETERS: */
  555. /* =========== */
  556. /* initShared : Boolean indicating whether we should attempt to create */
  557. /* the trace config shared memory or not. */
  558. /* */
  559. /* RETURNS: */
  560. /* ======== */
  561. /* 0 : success. */
  562. /* TRC_RC_XXX : failure. */
  563. /* */
  564. /****************************************************************************/
  565. DCUINT32 DCAPI TRC_Initialize(DCBOOL initShared);
  566. /****************************************************************************/
  567. /* API FUNCTION: TRC_Terminate(...) */
  568. /* */
  569. /* DESCRIPTION: */
  570. /* ============ */
  571. /* This function terminates tracing for this component. */
  572. /* */
  573. /* PARAMETERS: */
  574. /* =========== */
  575. /* termShared : Boolean indicating if shared memory should be released */
  576. /* or not. */
  577. /* */
  578. /* RETURNS: */
  579. /* ======== */
  580. /* Nothing. */
  581. /* */
  582. /****************************************************************************/
  583. DCVOID DCAPI TRC_Terminate(DCBOOL termShared);
  584. /****************************************************************************/
  585. /* API FUNCTION: TRC_GetBuffer(...) */
  586. /* */
  587. /* DESCRIPTION: */
  588. /* ============ */
  589. /* This function grabs the mutex and returns a pointer to the trace */
  590. /* buffer. */
  591. /* */
  592. /* PARAMETERS: */
  593. /* =========== */
  594. /* None. */
  595. /* */
  596. /* RETURNS: */
  597. /* ======== */
  598. /* A pointer to the trace buffer. */
  599. /* */
  600. /****************************************************************************/
  601. PDCTCHAR DCAPI TRC_GetBuffer(DCVOID);
  602. /****************************************************************************/
  603. /* API FUNCTION: TRC_TraceBuffer(...) */
  604. /* */
  605. /* DESCRIPTION: */
  606. /* ============ */
  607. /* This function copies the trace line that is currently in the trace */
  608. /* buffer into the trace file and / or to the debugger. It assumes that the */
  609. /* mutex has already been acquired before it is called and releases the */
  610. /* mutex before returning. */
  611. /* */
  612. /* PARAMETERS: */
  613. /* =========== */
  614. /* traceLevel : the requested trace level. */
  615. /* traceComponent : the component group that the source file is in. */
  616. /* lineNumber : the line number of the source file traced from. */
  617. /* funcName : the function name traced from. */
  618. /* fileName : the file name of the module requesting trace. */
  619. /* */
  620. /* RETURNS: */
  621. /* ======== */
  622. /* Nothing. */
  623. /* */
  624. /****************************************************************************/
  625. DCVOID DCAPI TRC_TraceBuffer(DCUINT traceLevel,
  626. DCUINT traceComponent,
  627. DCUINT lineNumber,
  628. PDCTCHAR funcName,
  629. PDCTCHAR fileName);
  630. /****************************************************************************/
  631. /* API FUNCTION: TRC_GetConfig(...) */
  632. /* */
  633. /* DESCRIPTION: */
  634. /* ============ */
  635. /* This function copies the current trace settings into the buffer pointed */
  636. /* to by pTraceConfig. */
  637. /* */
  638. /* PARAMETERS: */
  639. /* =========== */
  640. /* pTraceConfig : a pointer to a TRC_CONFIG structure. */
  641. /* length : the length of the buffer. */
  642. /* */
  643. /* RETURNS: */
  644. /* ======== */
  645. /* TRUE : success. */
  646. /* FALSE : failure. */
  647. /* */
  648. /****************************************************************************/
  649. DCBOOL DCAPI TRC_GetConfig(PTRC_CONFIG pTraceConfig,
  650. DCUINT length);
  651. /****************************************************************************/
  652. /* API FUNCTION: TRC_SetConfig(...) */
  653. /* */
  654. /* DESCRIPTION: */
  655. /* ============ */
  656. /* This function sets the trace configuration to that specified in the */
  657. /* passed TRC_CONFIG structure. */
  658. /* */
  659. /* PARAMETERS: */
  660. /* =========== */
  661. /* pTraceConfig : a pointer to a TRC_CONFIG structure. */
  662. /* length : the length of the buffer. */
  663. /* */
  664. /* RETURNS: */
  665. /* ======== */
  666. /* TRUE : success. */
  667. /* FALSE : failure. */
  668. /* */
  669. /****************************************************************************/
  670. DCBOOL DCAPI TRC_SetConfig(PTRC_CONFIG pTraceConfig,
  671. DCUINT length);
  672. /****************************************************************************/
  673. /* API FUNCTION: TRC_TraceData(...) */
  674. /* */
  675. /* DESCRIPTION: */
  676. /* ============ */
  677. /* */
  678. /* PARAMETERS: */
  679. /* =========== */
  680. /* traceLevel : the requested trace level. */
  681. /* traceComponent : the component group that the source file is in. */
  682. /* lineNumber : the line number of the source file traced from. */
  683. /* funcName : the function name traced from. */
  684. /* fileName : the file name of the module requesting trace. */
  685. /* buffer : the actual data to be traced. */
  686. /* bufLength : the length of the data. */
  687. /* */
  688. /* RETURNS: */
  689. /* ======== */
  690. /* Nothing. */
  691. /* */
  692. /****************************************************************************/
  693. DCVOID DCAPI TRC_TraceData(DCUINT traceLevel,
  694. DCUINT traceComponent,
  695. DCUINT lineNumber,
  696. PDCTCHAR funcName,
  697. PDCTCHAR fileName,
  698. PDCUINT8 buffer,
  699. DCUINT bufLength);
  700. /****************************************************************************/
  701. /* API FUNCTION: TRC_GetTraceLevel(...) */
  702. /* */
  703. /* DESCRIPTION: */
  704. /* ============ */
  705. /* This function returns the current trace level. */
  706. /* */
  707. /* PARAMETERS: */
  708. /* =========== */
  709. /* None. */
  710. /* */
  711. /* RETURNS: */
  712. /* ======== */
  713. /* The current trace level. */
  714. /* */
  715. /****************************************************************************/
  716. DCUINT DCAPI TRC_GetTraceLevel(DCVOID);
  717. /****************************************************************************/
  718. /* API FUNCTION: TRC_ProfileTraceEnabled(...) */
  719. /* */
  720. /* DESCRIPTION: */
  721. /* ============ */
  722. /* This function returns the function entry/exit trace setting. */
  723. /* */
  724. /* PARAMETERS: */
  725. /* =========== */
  726. /* None. */
  727. /* */
  728. /* RETURNS: */
  729. /* ======== */
  730. /* TRUE / FALSE - is the profile tracing enabled. */
  731. /* */
  732. /****************************************************************************/
  733. DCBOOL DCAPI TRC_ProfileTraceEnabled(DCVOID);
  734. /****************************************************************************/
  735. /* API FUNCTION: TRC_ResetTraceFiles(...) */
  736. /* */
  737. /* DESCRIPTION: */
  738. /* ============ */
  739. /* This function resets the trace files. After checking that trace is */
  740. /* initialized it calls the OS specific internal function. */
  741. /* */
  742. /* PARAMETERS: */
  743. /* =========== */
  744. /* None. */
  745. /* */
  746. /* RETURNS: */
  747. /* ======== */
  748. /* TRUE / FALSE - is the profile tracing enabled. */
  749. /* */
  750. /****************************************************************************/
  751. DCBOOL DCAPI TRC_ResetTraceFiles(DCVOID);
  752. /****************************************************************************/
  753. /* Before including this file the TRC_FILE macro should be defined. This */
  754. /* is much more efficient than relying on __FILE__ to give the correct */
  755. /* filename since it includes unnecessary path info (and extension info). */
  756. /* In addition each use of __FILE__ causes a new constant string to be */
  757. /* placed in the data segment. */
  758. /****************************************************************************/
  759. #if (TRC_CL < TRC_LEVEL_DIS)
  760. /************************************************************************/
  761. /* Define another layer for _T() to work around preprocessor problems */
  762. /************************************************************************/
  763. #define TRC_T(x) _T(x)
  764. #ifdef TRC_FILE
  765. #define _file_name_ (PDCTCHAR)__filename
  766. static const DCTCHAR __filename[] = TRC_T(TRC_FILE);
  767. #endif /* TRC_FILE */
  768. #endif
  769. /****************************************************************************/
  770. /* */
  771. /* OPERATING SYSTEM SPECIFIC INCLUDES */
  772. /* */
  773. /****************************************************************************/
  774. #include <wtrcapi.h>
  775. #ifdef __cplusplus
  776. }
  777. #endif /* __cplusplus */
  778. #endif /* _H_ATRCAPI */