dbgtrace.h
上传用户:dzyhzl
上传日期:2019-04-29
资源大小:56270k
文件大小:35k
源码类别:

模拟服务器

开发平台:

C/C++

  1. /*
  2.  * dbgtrace.h
  3.  *    Definitions for async tracing routines for Host Integration Server/SNA Server
  4.  *
  5.  * Copyright (c) Microsoft Corporation.  All rights reserved.
  6.  * All Rights Reserved.
  7.  */
  8. #ifdef __cplusplus
  9. extern "C" {
  10. #endif
  11. #if !defined(_DBGTRACE_H_)
  12. #define _DBGTRACE_H_
  13. /* The following definitions are used to manipulate the handle coding  */
  14. #define FILETYPES 0x0000000f
  15. #define APIFILE 0x00000001
  16. #define MESSAGEFILE 0x00000002
  17. #define INTFILE 0x00000004
  18. #define APPC_FLAG 0x00000010
  19. #define CPIC_FLAG 0x00000020
  20. #define LUA_FLAG 0x00000040
  21. #define CSV_FLAG 0x00000080
  22. #define API_FLAGS 0x000000f0
  23. #define IsAPIFile(x)   ( ((x & FILETYPES) & APIFILE) != 0 )
  24. #define IsMessageFile(x)  ( ((x & FILETYPES) & MESSAGEFILE) != 0 )
  25. #define IsAPPCTrace(x)    ( ((x & API_FLAGS) & APPC_FLAG) != 0 )
  26. #define IsCPICTrace(x)    ( ((x & API_FLAGS) & CPIC_FLAG) != 0 )
  27. #define IsLUATrace(x)    ( ((x & API_FLAGS) & LUA_FLAG) != 0 )
  28. #define IsCSVTrace(x)    ( ((x & API_FLAGS) & CSV_FLAG) != 0 )
  29. #define SetAPIFile(x)     x  = (ULONG)APIFILE
  30. #define SetMessageFile(x)   x  = (ULONG)MESSAGEFILE
  31. #define SetAPPCTrace(x)     x  = (ULONG)(APIFILE|APPC_FLAG)
  32. #define SetCPICTrace(x)     x  = (ULONG)(APIFILE|CPIC_FLAG)
  33. #define SetLUATrace(x)      x  = (ULONG)(APIFILE|LUA_FLAG)
  34. #define SetCSVTrace(x)      x  = (ULONG)(APIFILE|CSV_FLAG)
  35. #define INTERNAL_FLAG 0x000000010
  36. #define SNA3270_FLAG 0x000000020
  37. #define LU62_FLAG 0x000000040
  38. #define DLC_FLAG 0x000000080
  39. #define LEVEL2_FLAG 0x000000100
  40. #define SNA_FLAG 0x000000200
  41. #define DPL_HEADER_FLAGS 0x000000400
  42. #define BRIEF_LU62_FLAGS 0x000000800
  43. #define CONNECT_INFO_FLAG   0x000001000
  44. #define NETWORK_DS_FLAG 0x000002000
  45. #define MESSAGE_FLAGS 0x000003ff0
  46. #define IsInternalTrace(x)    ( ((x & MESSAGE_FLAGS) & INTERNAL_FLAG) != 0 )
  47. #define Is3270Trace(x)   ( ((x & MESSAGE_FLAGS) & SNA3270_FLAG) != 0 )
  48. #define IsLU62Trace(x)   ( ((x & MESSAGE_FLAGS) & LU62_FLAG) != 0 )
  49. #define IsDLCTrace(x)   ( ((x & MESSAGE_FLAGS) & DLC_FLAG) != 0 )
  50. #define IsLevel2Trace(x)      ( ((x & MESSAGE_FLAGS) & LEVEL2_FLAG) != 0 )
  51. #define IsSNATrace(x)   ( ((x & MESSAGE_FLAGS) & SNA_FLAG) != 0 )
  52. #define IsDPLHeaderTrace(x)   ( ((x & MESSAGE_FLAGS) & DPL_HEADER_FLAGS) != 0)
  53. #define IsBriefLU62Trace(x)   ( ((x & MESSAGE_FLAGS) & BRIEF_LU62_FLAGS) != 0)
  54. #define IsConnectInfoTrace(x) ( ((x & MESSAGE_FLAGS) & CONNECT_INFO_FLAG) != 0)
  55. #define IsNetworkDSTrace(x)   ( ((x & MESSAGE_FLAGS) & NETWORK_DS_FLAG) != 0)
  56. #define SetInternalTrace(x)   x  = (ULONG)(MESSAGEFILE|INTERNAL_FLAG)
  57. #define Set3270Trace(x)   x  = (ULONG)(MESSAGEFILE|SNA3270_FLAG)
  58. #define SetLU62Trace(x)   x  = (ULONG)(MESSAGEFILE|LU62_FLAG)
  59. #define SetDLCTrace(x)   x  = (ULONG)(MESSAGEFILE|DLC_FLAG)
  60. #define SetLevel2Trace(x)     x  = (ULONG)(MESSAGEFILE|LEVEL2_FLAG)
  61. #define SetSNATrace(x)   x  = (ULONG)(MESSAGEFILE|SNA_FLAG)
  62. #define SetMessageTrace(x)    x  =  (ULONG)(MESSAGEFILE|MESSAGE_FLAGS)
  63. #define SetDPLHeaderTrace(x)  x  =  (ULONG)(MESSAGEFILE|DPL_HEADER_FLAGS)
  64. #define SetBriefLU62Trace(x)  x  =  (ULONG)(MESSAGEFILE|BRIEF_LU62_FLAGS)
  65. #define SetConnectInfoTrace(x)  x  =  (ULONG)(MESSAGEFILE|CONNECT_INFO_FLAG)
  66. #define SetNetworkDSTrace(x)  x  =  (ULONG)(MESSAGEFILE|NETWORK_DS_FLAG)
  67. /* end of the handle encoding definitions */
  68. #if defined( DISABLE_TRACING )
  69. #define FLUSHASYNCTRACE /* for _ASSERT below  */
  70. #define FatalTrace  1 ? (void)0 : PreAsyncTrace
  71. #define ErrorTrace  1 ? (void)0 : PreAsyncTrace
  72. #define DebugTrace  1 ? (void)0 : PreAsyncTrace
  73. #define StateTrace  1 ? (void)0 : PreAsyncTrace
  74. #define FunctTrace  1 ? (void)0 : PreAsyncTrace
  75. #define ErrorTraceX 1 ? (void)0 : PreAsyncTrace
  76. #define DebugTraceX 1 ? (void)0 : PreAsyncTrace
  77. #define CustomTrace 1 ? (void)0 : PreAsyncTrace
  78. #define CMTIInternalPlanEnter 1?(void)0:PreAsyncTrace
  79. #define CMTIInternalPlanExit 1?(void)0:PreAsyncTrace
  80. #define FatalTraceEx 1 ? (void)0 : PreAsyncTraceEx
  81. #define ErrorTraceEx 1 ? (void)0 : PreAsyncTraceEx
  82. #define DebugTraceEx 1 ? (void)0 : PreAsyncTraceEx
  83. #define StateTraceEx 1 ? (void)0 : PreAsyncTraceEx
  84. #define FunctTraceEx 1 ? (void)0 : PreAsyncTraceEx
  85. #define CustomTraceEx 1 ? (void)0 : PreAsyncTraceEx
  86. #define InternalMessageTrace 1 ? (void)0 : PreMessageTrace
  87. #define SNA3270MessageTrace 1 ? (void)0 : PreMessageTrace
  88. #define LU62MessageTrace 1 ? (void)0 : PreMessageTrace
  89. #define DLCMessageTrace 1 ? (void)0 : PreMessageTrace
  90. #define LEVEL2MessageTrace 1 ? (void)0 : PreMessageTrace
  91. #define SNAMessageTrace 1 ? (void)0 : PreMessageTrace
  92. #define DPLHeaderMessageTrace   1 ? (void)0 : PreMessageTrace
  93. #define BriefLU62MessageTrace   1 ? (void)0 : PreMessageTrace
  94. #define ConnectInfoMessageTrace 1 ? (void)0 : PreMessageTrace
  95. #define NetworkDSMessageTrace   1 ? (void)0 : PreMessageTrace
  96. #define AllMessageTrace 1 ? (void)0 : PreMessageTrace
  97. /* COMTI API Trace  */
  98. #define CMTIAPIComtiProxy 1 ? (void)0 : PreAPITrace
  99. #define CMTIAPIPipeline 1 ? (void)0 : PreAPITrace
  100. #define CMTIAPIBlackBoard 1 ? (void)0 : PreAPITrace
  101. #define CMTIAPIGeneralServices 1 ? (void)0 : PreAPITrace
  102. #define CMTIAPIRepository 1 ? (void)0 : PreAPITrace
  103. #define CMTIAPIDataTransit 1 ? (void)0 : PreAPITrace
  104. #define CMTIAPIConvert 1 ? (void)0 : PreAPITrace
  105. #define CMTIAPITransport 1 ? (void)0 : PreAPITrace
  106. #define CMTIAPIRegistrar 1 ? (void)0 : PreAPITrace
  107. #define CMTIAPIScripting 1 ? (void)0 : PreAPITrace
  108. #define CMTIAPISessMgr 1 ? (void)0 : PreAPITrace
  109. #define CMTIAPIDataLayout 1 ? (void)0 : PreAPITrace
  110. #define CMTIAPITerminalService 1 ? (void)0 : PreAPITrace
  111. #define APPCAPITrace 1 ? (void)0 : PreAPITrace
  112. #define CPICAPITrace 1 ? (void)0 : PreAPITrace
  113. #define LUAAPITrace 1 ? (void)0 : PreAPITrace
  114. #define CSVAPITrace 1 ? (void)0 : PreAPITrace
  115. #define OLEDBAPITrace 1 ? (void)0 : PreAPITrace
  116. #define ODBCAPITrace 1 ? (void)0 : PreAPITrace
  117. #define NetworkAPITrace 1 ? (void)0 : PreAPITrace
  118. #define MessageTrace( lParam, pbData, cbData )
  119. #define BinaryTrace( lParam, pbData, cbData )
  120. #define UserTrace( lParam, dwUserType, pbData, cbData )
  121. #define BinaryInternalTrace( lParam, pbData, cbData )
  122. #define Binary3270Trace( lParam, pbData, cbData )
  123. #define BinaryLU62Trace( lParam, pbData, cbData )
  124. #define BinaryDLCTrace( lParam, pbData, cbData )
  125. #define BinaryLevel2Trace( lParam, pbData, cbData )
  126. #define BinarySNATrace( lParam, pbData, cbData )
  127. #define BinaryAllMsgTrace(lParam, pbData, cbData )
  128. #define BinaryAPPCTrace( lParam, pbData, cbData )
  129. #define BinaryCPICTrace( lParam, pbData, cbData )
  130. #define BinaryLUATrace( lParam, pbData, cbData )
  131. #define BinaryCSVTrace( lParam, pbData, cbData )
  132. #define TraceFunctEnter( sz )
  133. #define TraceFunctLeave()
  134. #define InitAsyncTraceEx(X)
  135. __inline int PreAsyncTrace( LONG_PTR lParam, LPCSTR szFormat, ... )
  136. {
  137.         return( 1);
  138. }
  139. __inline int PreAsyncTraceEx( LPCSTR szFormat, ... )
  140. {
  141.         return( 1);
  142. }
  143. #define TraceQuietEnter( sz )
  144. #else /* NOTRACE */
  145. #define FLUSHASYNCTRACE FlushAsyncTrace(),  /* for _ASSERT below */
  146. #define FatalTrace  !(__dwEnabledTraces & FATAL_TRACE_MASK) ?   
  147.                     (void)0 :                                   
  148.                     SetAsyncTraceParams( THIS_FILE, __LINE__, ___pszFunctionName, FATAL_TRACE_MASK ) &&     
  149.                     PreAsyncTrace
  150. #define ErrorTrace  !(__dwEnabledTraces & ERROR_TRACE_MASK) ?   
  151.                     (void)0 :                                   
  152.                     SetAsyncTraceParams( THIS_FILE, __LINE__, ___pszFunctionName, ERROR_TRACE_MASK ) &&     
  153.                     PreAsyncTrace
  154. #define DebugTrace  !(__dwEnabledTraces & DEBUG_TRACE_MASK) ?   
  155.                     (void)0 :                                   
  156.                     SetAsyncTraceParams( THIS_FILE, __LINE__, ___pszFunctionName, DEBUG_TRACE_MASK ) &&     
  157.                     PreAsyncTrace
  158. #define StateTrace  !(__dwEnabledTraces & STATE_TRACE_MASK) ?   
  159.                     (void)0 :                                   
  160.                     SetAsyncTraceParams( THIS_FILE, __LINE__, ___pszFunctionName, STATE_TRACE_MASK ) &&     
  161.                     PreAsyncTrace
  162. #define FunctTrace  !(__dwEnabledTraces & FUNCT_TRACE_MASK) ?   
  163.                     (void)0 :                                   
  164.                     SetAsyncTraceParams( THIS_FILE, __LINE__, ___pszFunctionName, FUNCT_TRACE_MASK ) &&     
  165.                     PreAsyncTrace
  166. #define CustomTrace  !(__dwEnabledTraces & CUSTOM_TRACE_MASK) ?   
  167.                     (void)0 :                                   
  168.                     SetAsyncTraceParams( THIS_FILE, __LINE__, ___pszFunctionName, CUSTOM_TRACE_MASK ) &&     
  169.                     PreAsyncTrace
  170. #define CMTIInternalPlanEnter !(__dwEnabledTraces & PLAN_ENTER_EXIT_MASK) ?   
  171.                 (void)0 :                                   
  172.                     SetAsyncTraceParams( THIS_FILE, __LINE__, ___pszFunctionName, CUSTOM_TRACE_MASK ) &&     
  173.                     PreAsyncTrace
  174. #define CMTIInternalPlanExit !(__dwEnabledTraces & PLAN_ENTER_EXIT_MASK) ?   
  175.                 (void)0 :                                   
  176.                     SetAsyncTraceParams( THIS_FILE, __LINE__, ___pszFunctionName, CUSTOM_TRACE_MASK ) &&     
  177.                     PreAsyncTrace
  178. /*
  179.  * Support for unspecified function names
  180.  */
  181. #define ErrorTraceX  !(__dwEnabledTraces & ERROR_TRACE_MASK) ?   
  182.                     (void)0 :                                   
  183.                     SetAsyncTraceParams( THIS_FILE, __LINE__, "Fn", ERROR_TRACE_MASK ) &&     
  184.                     PreAsyncTrace
  185. #define DebugTraceX  !(__dwEnabledTraces & DEBUG_TRACE_MASK) ?   
  186.                     (void)0 :                                   
  187.                     SetAsyncTraceParams( THIS_FILE, __LINE__, "Fn", DEBUG_TRACE_MASK ) &&     
  188.                     PreAsyncTrace
  189. /* Trace Macros that do not require the first parameter, i.e user data  */
  190. #define FatalTraceEx !(__dwEnabledTraces & FATAL_TRACE_MASK) ?   
  191. (void)0 :                                   
  192. SetAsyncTraceParams( THIS_FILE, __LINE__, ___pszFunctionName, FATAL_TRACE_MASK ) &&     
  193. PreAsyncTraceEx
  194. #define ErrorTraceEx !(__dwEnabledTraces & ERROR_TRACE_MASK) ?   
  195. (void)0 :                                   
  196. SetAsyncTraceParams( THIS_FILE, __LINE__, ___pszFunctionName, ERROR_TRACE_MASK ) &&     
  197. PreAsyncTraceEx
  198. #define DebugTraceEx !(__dwEnabledTraces & DEBUG_TRACE_MASK) ?   
  199. (void)0 :                                   
  200. SetAsyncTraceParams( THIS_FILE, __LINE__, ___pszFunctionName, DEBUG_TRACE_MASK ) &&     
  201. PreAsyncTraceEx
  202. #define StateTraceEx !(__dwEnabledTraces & STATE_TRACE_MASK) ?   
  203. (void)0 :                                   
  204. SetAsyncTraceParams( THIS_FILE, __LINE__, ___pszFunctionName, STATE_TRACE_MASK ) &&     
  205. PreAsyncTraceEx
  206. #define FunctTraceEx !(__dwEnabledTraces & FUNCT_TRACE_MASK) ?   
  207. (void)0 :                                   
  208. SetAsyncTraceParams( THIS_FILE, __LINE__, ___pszFunctionName, FUNCT_TRACE_MASK ) &&     
  209. PreAsyncTraceEx
  210. #define CustomTraceEx !(__dwEnabledTraces & CUSTOM_TRACE_MASK) ?   
  211. (void)0 :                                   
  212. SetAsyncTraceParams( THIS_FILE, __LINE__, ___pszFunctionName, CUSTOM_TRACE_MASK ) &&     
  213. PreAsyncTraceEx
  214. /*
  215.  * Support for SNA Server Message Trace 
  216.  */
  217. #define InternalMessageTrace !(__dwMessageTraces & INTERNAL_MESSAGE_MASK) ?   
  218. (void)0 :                                   
  219. SetMessageTraceParams( THIS_FILE, __LINE__, ___pszFunctionName, INTERNAL_MESSAGE_MASK ) &&     
  220. PreMessageTrace
  221. #define SNA3270MessageTrace !(__dwMessageTraces & SNA3270_MESSAGE_MASK) ?   
  222. (void)0 :                                   
  223. SetMessageTraceParams( THIS_FILE, __LINE__, ___pszFunctionName, SNA3270_MESSAGE_MASK ) &&     
  224. PreMessageTrace
  225. #define LU62MessageTrace !(__dwMessageTraces & LU62_MESSAGE_MASK) ?   
  226. (void)0 :                                   
  227. SetMessageTraceParams( THIS_FILE, __LINE__, ___pszFunctionName, LU62_MESSAGE_MASK ) &&     
  228. PreMessageTrace
  229. #define DLCMessageTrace     !(__dwMessageTraces & DLC_MESSAGE_MASK) ?   
  230.                     (void)0 :                                   
  231.         SetMessageTraceParams( THIS_FILE, __LINE__, ___pszFunctionName, DLC_MESSAGE_MASK ) &&     
  232. PreMessageTrace
  233. #define LEVEL2MessageTrace     !(__dwMessageTraces & LEVEL2_MESSAGE_MASK) ?   
  234. (void)0 :                                   
  235. SetMessageTraceParams( THIS_FILE, __LINE__, ___pszFunctionName, LEVEL2_MESSAGE_MASK ) &&     
  236. PreMessageTrace
  237. #define SNAMessageTrace !(__dwMessageTraces & SNA_MESSAGE_MASK) ?   
  238. (void)0 :                                   
  239. SetMessageTraceParams( THIS_FILE, __LINE__, ___pszFunctionName, SNA_MESSAGE_MASK ) &&     
  240. PreMessageTrace
  241. #define DPLHeaderMessageTrace   !(__dwMessageTraces & DPL_HEADER_MESSAGE_MASK) ? 
  242. (void)0:  
  243. SetMessageTraceParams( THIS_FILE, __LINE__, ___pszFunctionName, DPL_HEADER_MESSAGE_MASK) && 
  244. PreMessageTrace
  245. #define BriefLU62MessageTrace   !(__dwMessageTraces & BRIEF_LU62_MESSAGE_MASK)? 
  246. (void)0:
  247. SetMessageTraceParams( THIS_FILE, __LINE__, ___pszFunctionName, BRIEF_LU62_MESSAGE_MASK) && 
  248. PreMessageTrace
  249. #define ConnectInfoMessageTrace !(__dwMessageTraces & CONNECTION_INFO_MASK)? 
  250. (void)0:
  251. SetMessageTraceParams( THIS_FILE, __LINE__, ___pszFunctionName, CONNECTION_INFO_MASK) && 
  252. PreMessageTrace
  253. #define NetworkDSMessageTrace   !(__dwMessageTraces & NETWORK_DS_MASK)? 
  254. (void)0:
  255. SetMessageTraceParams( THIS_FILE, __LINE__, ___pszFunctionName, NETWORK_DS_MASK) && 
  256. PreMessageTrace
  257. #define AllMessageTrace SetMessageTraceParams( THIS_FILE, __LINE__, ___pszFunctionName, SNA_MESSAGE_MASK ) &&     
  258. PreMessageTrace
  259. #define APPCAPITrace !(__dwAPITraces & APPC_MESSAGE_MASK) ?   
  260. (void)0 :                                   
  261. SetAPITraceParams( THIS_FILE, __LINE__, ___pszFunctionName, APPC_MESSAGE_MASK ) &&     
  262. PreAPITrace
  263. #define CPICAPITrace !(__dwAPITraces & CPIC_MESSAGE_MASK) ?   
  264. (void)0 :                                   
  265. SetAPITraceParams( THIS_FILE, __LINE__, ___pszFunctionName, CPIC_MESSAGE_MASK ) &&     
  266. PreAPITrace
  267. #define LUAAPITrace     !(__dwAPITraces & LUA_MESSAGE_MASK) ?   
  268. (void)0 :                                   
  269. SetAPITraceParams( THIS_FILE, __LINE__, ___pszFunctionName, LUA_MESSAGE_MASK ) &&     
  270. PreAPITrace
  271. #define CSVAPITrace !(__dwAPITraces & CSV_MESSAGE_MASK) ?   
  272. (void)0 :                                   
  273. SetAPITraceParams( THIS_FILE, __LINE__, ___pszFunctionName, CSV_MESSAGE_MASK ) &&     
  274. PreAPITrace
  275. /* COMTI API Trace Macros */
  276. #define CMTIAPIComtiProxy !(__dwAPITraces & COMTI_PROXY_MASK) ?   
  277. (void)0 :                                   
  278. SetAPITraceParams( THIS_FILE, __LINE__, ___pszFunctionName, APPC_MESSAGE_MASK ) &&     
  279. PreAPITrace
  280. #define CMTIAPIPipeline !(__dwAPITraces & COMTI_PIPELINE_MASK) ?   
  281. (void)0 :                                   
  282. SetAPITraceParams( THIS_FILE, __LINE__, ___pszFunctionName, APPC_MESSAGE_MASK ) &&     
  283. PreAPITrace
  284. #define CMTIAPIBlackBoard !(__dwAPITraces & COMTI_BB_MASK) ?   
  285. (void)0 :                                   
  286. SetAPITraceParams( THIS_FILE, __LINE__, ___pszFunctionName, APPC_MESSAGE_MASK ) &&     
  287. PreAPITrace
  288. #define CMTIAPIGeneralServices !(__dwAPITraces & COMTI_SVC_MASK) ?   
  289. (void)0 :                                   
  290. SetAPITraceParams( THIS_FILE, __LINE__, ___pszFunctionName, APPC_MESSAGE_MASK ) &&     
  291. PreAPITrace
  292. #define CMTIAPIRepository !(__dwAPITraces & COMTI_REPO_MASK) ?   
  293. (void)0 :                                   
  294. SetAPITraceParams( THIS_FILE, __LINE__, ___pszFunctionName, APPC_MESSAGE_MASK ) &&     
  295. PreAPITrace
  296. #define CMTIAPIDataTransit !(__dwAPITraces & COMTI_DT_MASK) ?   
  297. (void)0 :                                   
  298. SetAPITraceParams( THIS_FILE, __LINE__, ___pszFunctionName, APPC_MESSAGE_MASK ) &&     
  299. PreAPITrace
  300. #define CMTIAPIConvert !(__dwAPITraces & COMTI_CONV_MASK) ?   
  301. (void)0 :                                   
  302. SetAPITraceParams( THIS_FILE, __LINE__, ___pszFunctionName, APPC_MESSAGE_MASK ) &&     
  303. PreAPITrace
  304. #define CMTIAPITransport !(__dwAPITraces & COMTI_TRANS_MASK) ?   
  305. (void)0 :                                   
  306. SetAPITraceParams( THIS_FILE, __LINE__, ___pszFunctionName, APPC_MESSAGE_MASK ) &&     
  307. PreAPITrace
  308. #define CMTIAPIRegistrar !(__dwAPITraces & COMTI_REGISTRAR_MASK) ?   
  309. (void)0 :                                   
  310. SetAPITraceParams( THIS_FILE, __LINE__, ___pszFunctionName, APPC_MESSAGE_MASK ) &&     
  311. PreAPITrace
  312. #define CMTIAPIScripting !(__dwAPITraces & COMTI_SCRIPTING_MASK) ?   
  313. (void)0 :                                   
  314. SetAPITraceParams( THIS_FILE, __LINE__, ___pszFunctionName, APPC_MESSAGE_MASK ) &&     
  315. PreAPITrace
  316. #define CMTIAPISessMgr !(__dwAPITraces & COMTI_SESSMGR_MASK) ?   
  317. (void)0 :                                   
  318. SetAPITraceParams( THIS_FILE, __LINE__, ___pszFunctionName, APPC_MESSAGE_MASK ) &&     
  319. PreAPITrace
  320. #define CMTIAPIDataLayout !(__dwAPITraces & COMTI_DL_MASK) ?   
  321. (void)0 :                                   
  322. SetAPITraceParams( THIS_FILE, __LINE__, ___pszFunctionName, APPC_MESSAGE_MASK ) &&     
  323. PreAPITrace
  324. #define CMTIAPITerminalService !(__dwAPITraces & COMTI_TERMSERV_MASK) ?   
  325. (void)0 :                                   
  326. SetAPITraceParams( THIS_FILE, __LINE__, ___pszFunctionName, APPC_MESSAGE_MASK ) &&     
  327. PreAPITrace
  328. #define OLEDBAPITrace !(__dwAPITraces & OLEDB_API_MASK) ?   
  329. (void)0 :                                   
  330. SetAPITraceParams( THIS_FILE, __LINE__, ___pszFunctionName, OLEDB_API_MASK ) &&     
  331. PreAPITrace
  332. #define ODBCAPITrace !(__dwAPITraces & OLEDB_API_MASK) ?   
  333. (void)0 :                                   
  334. SetAPITraceParams( THIS_FILE, __LINE__, ___pszFunctionName, ODBC_API_MASK ) &&     
  335. PreAPITrace
  336. #define NetworkAPITrace !(__dwAPITraces & NETWORK_API_MASK) ?   
  337. (void)0 :                                   
  338. SetAPITraceParams( THIS_FILE, __LINE__, ___pszFunctionName, NETWORK_API_MASK ) &&     
  339. PreAPITrace
  340. /* Check the Message Trace Flag */
  341. #define IsInternalMessageTraceOn  ( (__dwMessageTraces & INTERNAL_MESSAGE_MASK) != 0 )
  342. #define IsSNA3270MessageTraceOn (  (__dwMessageTraces & SNA3270_MESSAGE_MASK) != 0 )
  343. #define IsLU62MessageTraceOn ( (__dwMessageTraces & LU62_MESSAGE_MASK) != 0 )
  344. #define IsDLCMessageTraceOn     ( (__dwMessageTraces & DLC_MESSAGE_MASK) != 0 )
  345. #define IsLEVEL2MessageTraceOn     ( (__dwMessageTraces & LEVEL2_MESSAGE_MASK) != 0 )
  346. #define IsSNAMessageTraceOn ( (__dwMessageTraces & SNA_MESSAGE_MASK) != 0 )
  347. #define GetMessageFlags (__dwMessageTraces | __dwAPITraces)
  348. #define IsAPPCAPITraceOn ( (__dwAPITraces & APPC_MESSAGE_MASK) != 0 )
  349. #define IsCPICAPITraceOn     ( (__dwAPITraces & CPIC_MESSAGE_MASK) != 0 )
  350. #define IsLUAAPITraceOn ( (__dwAPITraces & LUA_MESSAGE_MASK) != 0 )
  351. #define IsCSVAPITraceOn ( (__dwAPITraces & CSV_MESSAGE_MASK) != 0 )
  352. #define IsAPITraceOn ( __dwAPITraces != 0 )
  353. #define IsInternalTraceOn           ((__dwEnabledTraces & INTERNAL_TRACE_MASK) != 0)
  354. /*  Macro to check for COMTI API Trace state */
  355. #define IsCOMTIAPITraceOn ( (__dwAPITraces & COMTI_ALL_API_MASK) != 0 )
  356. #define IsCOMTIProxyTraceOn ( (__dwAPITraces & COMTI_PROXY_MASK) != 0 )
  357. #define IsCOMTIPipelineTraceOn ( (__dwAPITraces & COMTI_PIPELINE_MASK) != 0 )
  358. #define IsCOMTIBlackBoardTraceOn ( (__dwAPITraces & COMTI_BB_MASK) != 0 )
  359. #define IsCOMTIGeneralServicesTraceOn ( (__dwAPITraces & COMTI_SVC_MASK) != 0 )
  360. #define IsCOMTIRepositoryTraceOn ( (__dwAPITraces & COMTI_REPO_MASK) != 0 )
  361. #define IsCOMTIDataTransitTraceOn ( (__dwAPITraces & COMTI_DT_MASK) != 0 )
  362. #define IsCOMTIConvertTraceOn ( (__dwAPITraces & COMTI_DL_MASK) != 0 )
  363. #define IsCOMTITransportTraceOn ( (__dwAPITraces & COMTI_TRANS_MASK) != 0 )
  364. #define IsCOMTIRegistrarTraceOn ( (__dwAPITraces & COMTI_REGISTRAR_MASK) != 0 )
  365. #define IsCOMTIScriptingTraceOn ( (__dwAPITraces & COMTI_SCRIPTING_MASK) != 0 )
  366. #define IsCOMTISessMgrTraceOn ( (__dwAPITraces & COMTI_SESSMGR_MASK) != 0 )
  367. #define IsCOMTIDataLayoutTraceOn ( (__dwAPITraces & COMTI_DL_MASK) != 0 )
  368. #define IsCOMTITerminalServiceTraceOn ( (__dwAPITraces & COMTI_TERMSERV_MASK) != 0 )
  369. /* Macro to check for COMTI Message Trace state */
  370. #define IsCOMTIMsgTraceOn ( (__dwMessageTraces & COMTI_ALL_MSG_MASK) != 0 )
  371. #define IsCOMTIInternalTraceOn ( (__dwMessageTraces & INTERNAL_MESSAGE_MASK) != 0 )
  372. #define IsCOMTIDPLHeaderTraceOn ( (__dwMessageTraces & DPL_HEADER_MESSAGE_MASK) != 0 )
  373. #define IsCOMTIFullLU62TraceOn ( (__dwMessageTraces & LU62_MESSAGE_MASK) != 0 )
  374. #define IsCOMTIBriefLU62TraceOn ( (__dwMessageTraces & BRIEF_LU62_MESSAGE_MASK) != 0 )
  375. #define BinaryInternalTrace( lParam, pbData, cbData )
  376. !(__dwMessageTraces & INTERNAL_MESSAGE_MASK) ?   
  377. (void)0 :                                   
  378. SetMessageTraceParams( THIS_FILE, __LINE__, ___pszFunctionName, INTERNAL_MESSAGE_MASK ) &&     
  379. MessageBinaryTrace( lParam, TRACE_BINARY, pbData, cbData )
  380. #define Binary3270Trace( lParam, pbData, cbData )
  381. !(__dwMessageTraces & SNA3270_MESSAGE_MASK) ?   
  382. (void)0 :                                   
  383. SetMessageTraceParams( THIS_FILE, __LINE__, ___pszFunctionName, SNA3270_MESSAGE_MASK ) &&     
  384. MessageBinaryTrace( lParam, TRACE_BINARY, pbData, cbData )
  385. #define BinaryLU62Trace( lParam, pbData, cbData )
  386. !(__dwMessageTraces & LU62_MESSAGE_MASK) ?   
  387. (void)0 :                                   
  388. SetMessageTraceParams( THIS_FILE, __LINE__, ___pszFunctionName, LU62_MESSAGE_MASK ) &&     
  389. MessageBinaryTrace( lParam, TRACE_BINARY, pbData, cbData )
  390. #define BinaryDLCTrace( lParam, pbData, cbData )
  391. !(__dwMessageTraces & DLC_MESSAGE_MASK) ?   
  392.                     (void)0 :                                   
  393.         SetMessageTraceParams( THIS_FILE, __LINE__, ___pszFunctionName, DLC_MESSAGE_MASK ) &&     
  394. MessageBinaryTrace( lParam, TRACE_BINARY, pbData, cbData )
  395. #define BinaryLevel2Trace( lParam, pbData, cbData )
  396. !(__dwMessageTraces & LEVEL2_MESSAGE_MASK) ?   
  397. (void)0 :                                   
  398. SetMessageTraceParams( THIS_FILE, __LINE__, ___pszFunctionName, LEVEL2_MESSAGE_MASK ) &&     
  399.     MessageBinaryTrace( lParam, TRACE_BINARY, pbData, cbData )
  400. #define BinarySNATrace( lParam, pbData, cbData )
  401. !(__dwMessageTraces & SNA_MESSAGE_MASK) ?   
  402. (void)0 :                                   
  403. SetMessageTraceParams( THIS_FILE, __LINE__, ___pszFunctionName, SNA_MESSAGE_MASK ) &&     
  404. MessageBinaryTrace( lParam, TRACE_BINARY, pbData, cbData )
  405. #define BinaryAllMsgTrace( lParam, pbData, cbData )
  406. SetMessageTraceParams( THIS_FILE, __LINE__, ___pszFunctionName, SNA_MESSAGE_MASK ) &&     
  407. MessageBinaryTrace( lParam, TRACE_BINARY, pbData, cbData )
  408. #define BinaryAPPCTrace( lParam, pbData, cbData )
  409.         !(__dwAPITraces & APPC_MESSAGE_MASK) ?
  410.         (void)0 :
  411.         SetAsyncTraceParams( THIS_FILE, __LINE__, ___pszFunctionName, MESSAGE_TRACE_MASK ) &&       
  412.         APIBinaryTrace( lParam, TRACE_BINARY, pbData, cbData )
  413. #define BinaryCPICTrace( lParam, pbData, cbData )
  414.         !(__dwAPITraces & CPIC_MESSAGE_MASK) ?
  415.         (void)0 :
  416.         SetAsyncTraceParams( THIS_FILE, __LINE__, ___pszFunctionName, MESSAGE_TRACE_MASK ) &&       
  417.         APIBinaryTrace( lParam, TRACE_BINARY, pbData, cbData )
  418. #define BinaryLUATrace( lParam, pbData, cbData )                   
  419.         !(__dwAPITraces & LUA_MESSAGE_MASK) ?             
  420.         (void)0 :                                               
  421.         SetAsyncTraceParams( THIS_FILE, __LINE__, ___pszFunctionName, MESSAGE_TRACE_MASK ) &&       
  422.         APIBinaryTrace( lParam, TRACE_BINARY, pbData, cbData )
  423. #define BinaryCSVTrace( lParam, pbData, cbData )                   
  424.         !(__dwAPITraces & CSV_MESSAGE_MASK) ?             
  425.         (void)0 :                                               
  426.         SetAsyncTraceParams( THIS_FILE, __LINE__, ___pszFunctionName, MESSAGE_TRACE_MASK ) &&       
  427.         APIBinaryTrace( lParam, TRACE_BINARY, pbData, cbData )
  428. #define TraceFunctEnter( sz )                   
  429.         char    *___pszFunctionName = sz;   
  430.         FunctTrace( 0, "Entering %s", sz )
  431. #define TraceFunctLeave()                       
  432.         FunctTrace( 0, "Leaving %s", ___pszFunctionName )
  433. #define TraceFunctEnterEx( lParam, sz )                   
  434.         char    *___pszFunctionName = sz;   
  435.         FunctTrace( lParam, "Entering %s", sz )
  436. #define TraceFunctLeaveEx( lParam )                       
  437.         FunctTrace( lParam, "Leaving %s", ___pszFunctionName )
  438. #define TraceQuietEnter( sz )                   
  439.         char    *___pszFunctionName = sz
  440. /*
  441.  * fixed number of parameters for Binary trace macros
  442.  */
  443. #define MessageTrace( lParam, pbData, cbData )                  
  444.         !(__dwEnabledTraces & MESSAGE_TRACE_MASK) ?             
  445.         (void)0 :                                               
  446.         SetAsyncTraceParams( THIS_FILE, __LINE__, ___pszFunctionName, MESSAGE_TRACE_MASK ) &&       
  447.         AsyncBinaryTrace( lParam, TRACE_MESSAGE, pbData, cbData )
  448. #define BinaryTrace( lParam, pbData, cbData )                   
  449.         !(__dwEnabledTraces & MESSAGE_TRACE_MASK) ?             
  450.         (void)0 :                                               
  451.         SetAsyncTraceParams( THIS_FILE, __LINE__, ___pszFunctionName, MESSAGE_TRACE_MASK ) &&       
  452.         AsyncBinaryTrace( lParam, TRACE_BINARY, pbData, cbData )
  453. #define UserTrace( lParam, dwUserType, pbData, cbData )         
  454.         !(__dwEnabledTraces & MESSAGE_TRACE_MASK) ?             
  455.         (void)0 :                                               
  456.         SetAsyncTraceParams( THIS_FILE, __LINE__, ___pszFunctionName, MESSAGE_TRACE_MASK ) &&       
  457.         AsyncBinaryTrace( lParam, dwUserType, pbData, cbData )
  458. #ifndef THIS_FILE
  459. #define THIS_FILE   __FILE__
  460. #endif
  461. #if !defined(DllExport)
  462.     #define DllExport __declspec( dllexport )
  463. #endif
  464. #if !defined(DllImport)
  465.     #define DllImport __declspec( dllimport )
  466. #endif
  467. #if !defined(_DBGTRACE_DLL_DEFINED)
  468.     #define _DBGTRACE_DLL_DEFINED
  469.     #if defined(WIN32)
  470.         #if defined(_DBGTRACE_DLL_IMPLEMENTATION)
  471.     #define DbgTraceDLL DllExport
  472.         #else
  473.     #define DbgTraceDLL DllImport
  474.         #endif
  475.     #else
  476.         #define DbgTraceDLL
  477.     #endif
  478. #endif
  479. /*
  480.  * imported trace flag used by trace macros to determine if the trace
  481.  * statement should be executed
  482.  */
  483. extern DWORD DbgTraceDLL    __dwEnabledTraces;
  484. extern DWORD DbgTraceDLL __dwMessageTraces;
  485. extern DWORD DbgTraceDLL __dwAPITraces;
  486. /*
  487.  * import functions from DBGTRACE.DLL
  488.  */
  489. extern DbgTraceDLL BOOL WINAPI InitAsyncTrace( void );
  490. extern DbgTraceDLL BOOL WINAPI GetTraceCtrlBlock(VOID **pptrc);
  491. extern DbgTraceDLL BOOL WINAPI InitAsyncTraceEx( LPSTR pszName );
  492. /*  *************************** WARNING *********************************
  493.  *
  494.  * Don't call TermAsyncTrace at DLL_PROCESS_DETACH, it will hang the process when it waits for the thread to terminate
  495.  *
  496.  *  *************************** WARNING *********************************
  497.  */
  498. extern DbgTraceDLL BOOL WINAPI TermAsyncTrace( void );
  499. extern DbgTraceDLL BOOL WINAPI HardTermAsyncTrace(void);
  500. extern DbgTraceDLL BOOL WINAPI FlushAsyncTrace( void );
  501. extern DbgTraceDLL int WINAPI AsyncStringTrace( LONG_PTR  lParam,
  502.                                                 LPCSTR  szFormat,
  503.                                                 va_list marker );
  504. extern DbgTraceDLL int WINAPI AsyncBinaryTrace( LONG_PTR  lParam,
  505.                                                 DWORD   dwBinaryType,
  506.                                                 LPBYTE  pbData,
  507.                                                 DWORD   cbData );
  508. extern DbgTraceDLL int WINAPI APIBinaryTrace( LONG_PTR  lParam,
  509.                                                 DWORD   dwBinaryType,
  510.                                                 LPBYTE  pbData,
  511.                                                 DWORD   cbData );
  512. extern DbgTraceDLL int WINAPI MessageBinaryTrace( LONG_PTR  lParam,
  513.                                                 DWORD   dwBinaryType,
  514.                                                 LPBYTE  pbData,
  515.                                                 DWORD   cbData );
  516. extern DbgTraceDLL int WINAPI SetAsyncTraceParams(  LPSTR   pszFile,
  517.                                                     int     iLine,
  518.                                                     LPSTR   szFunction,
  519.                                                     DWORD   dwTraceMask );
  520. extern DbgTraceDLL int WINAPI SetMessageTraceParams(  LPSTR   pszFile,
  521.                                                     int     iLine,
  522.                                                     LPSTR   szFunction,
  523.                                                     DWORD   dwTraceMask );
  524. extern DbgTraceDLL int WINAPI SetAPITraceParams(  LPSTR   pszFile,
  525.                                                     int     iLine,
  526.                                                     LPSTR   szFunction,
  527.                                                     DWORD   dwTraceMask );
  528. extern DbgTraceDLL int WINAPI AsyncMessageTrace( LPARAM lParam,
  529.  LPCSTR szFormat,
  530.  va_list marker );
  531. extern DbgTraceDLL int WINAPI AsyncAPITrace( LPARAM lParam,
  532.  LPCSTR szFormat,
  533.  va_list marker );
  534. /*
  535.  * Trace flag constants
  536.  */
  537. #define FATAL_TRACE_MASK 0x00000001
  538. #define ERROR_TRACE_MASK 0x00000002
  539. #define DEBUG_TRACE_MASK 0x00000004
  540. #define STATE_TRACE_MASK 0x00000008
  541. #define FUNCT_TRACE_MASK 0x00000010
  542. #define MESSAGE_TRACE_MASK 0x00000020
  543. #define CUSTOM_TRACE_MASK 0x00000040
  544. #define PLAN_ENTER_EXIT_MASK 0x00000080
  545. #define INTERNAL_TRACE_MASK         0x000000DF
  546. #define ALL_TRACE_MASK 0xFFFFFFFF
  547. #define NUM_TRACE_TYPES      8
  548. /*
  549.  *  SNA Server Message Trace Flags, same as define in comw32.h
  550.  */
  551. #define DLC_MESSAGE_MASK 0x00000001
  552. #define LU62_MESSAGE_MASK 0x00000002
  553. #define SNA3270_MESSAGE_MASK 0x00000004
  554. #define INTERNAL_MESSAGE_MASK 0x00000008
  555. #define SNA_MESSAGE_MASK 0x00000010
  556. #define DPL_HEADER_MESSAGE_MASK 0x00000020
  557. #define BRIEF_LU62_MESSAGE_MASK 0x00000040
  558. #define LEVEL2_MESSAGE_MASK 0x00001000
  559. #define COMTI_ALL_MSG_MASK 0x00000069
  560. /* DDM and DB2 message trace */
  561. #define CONNECTION_INFO_MASK 0x00002000
  562. #define NETWORK_DS_MASK 0x00004000
  563. #define ALL_MSG_MASK 0x0000707f
  564. #define NUM_MESSAGE_TRACE_TYPES 8
  565. /*
  566.  * API Message Trace Flags
  567.  */
  568. #define APPC_MESSAGE_MASK 0x00000800
  569. #define CPIC_MESSAGE_MASK 0x00000040
  570. #define LUA_MESSAGE_MASK 0x00000080
  571. #define CSV_MESSAGE_MASK 0x00000400
  572. /* COMTI message trace */
  573. #define COMTI_PROXY_MASK 0x00001000
  574. #define COMTI_PIPELINE_MASK 0x00002000
  575. #define COMTI_BB_MASK 0x00004000
  576. #define COMTI_SVC_MASK 0x00008000
  577. #define COMTI_REPO_MASK 0x00010000
  578. #define COMTI_DT_MASK 0x00020000
  579. #define COMTI_DL_MASK 0x00040000
  580. #define COMTI_CONV_MASK 0x00080000
  581. #define COMTI_TRANS_MASK 0x00100000
  582. #define COMTI_REGISTRAR_MASK 0x00200000
  583. #define COMTI_SCRIPTING_MASK 0x00400000
  584. #define COMTI_SESSMGR_MASK 0x00800000
  585. #define COMTI_TERMSERV_MASK 0x01000000
  586. #define COMTI_ALL_API_MASK 0x01fff000
  587. /* DDM and DB2 API Trace */
  588. #define OLEDB_API_MASK 0x02000000
  589. #define ODBC_API_MASK 0x04000000
  590. #define NETWORK_API_MASK 0x08000000
  591. #define NUM_API_TRACE_TYPES 4
  592. /*
  593.  * Output trace types. used by tools to modify the
  594.  * registry to change the output target
  595.  */
  596. enum tagTraceOutputTypes {
  597.     TRACE_OUTPUT_DISABLED = 0,
  598.     TRACE_OUTPUT_FILE = 1,
  599.     TRACE_OUTPUT_DEBUG = 2,
  600.     TRACE_OUTPUT_DISCARD = 4        /* used to find race windows */
  601. };
  602. #define TRACE_OUTPUT_INVALID    
  603.         ~(TRACE_OUTPUT_FILE|TRACE_OUTPUT_DEBUG|TRACE_OUTPUT_DISCARD)
  604. #define IsTraceFile(x)      ((x) & TRACE_OUTPUT_FILE)
  605. #define IsTraceDebug(x)     ((x) & TRACE_OUTPUT_DEBUG)
  606. #define IsTraceDiscard(x)   ((x) & TRACE_OUTPUT_DISCARD)
  607. /*
  608.  * predefined types of binary trace types.  User defined
  609.  * types must be greater than 0x8000
  610.  */
  611. enum tagBinaryTypes {
  612.     TRACE_STRING = 0,
  613.     TRACE_BINARY,
  614.     TRACE_MESSAGE,
  615.     TRACE_USER = 0x8000
  616. };
  617. #include <stdarg.h>
  618. /*
  619.  * use __inline to ensure grab __LINE__ and __FILE__
  620.  */
  621. __inline int WINAPIV PreAsyncTrace( LONG_PTR lParam, LPCSTR szFormat, ... )
  622. {
  623.     va_list marker;
  624.     int     iLength;
  625.     va_start( marker, szFormat );
  626.     iLength = AsyncStringTrace( lParam, szFormat, marker );
  627.     va_end( marker );
  628.     return  iLength;
  629. }
  630. /*
  631.  * extended from PreAsyncTrace, but eliminate the first argument
  632.  */
  633. __inline int WINAPIV PreAsyncTraceEx( LPCSTR szFormat, ... )
  634. {
  635.     va_list marker;
  636.     int     iLength;
  637.     va_start( marker, szFormat );
  638.     iLength = AsyncStringTrace( (LONG_PTR)NULL, szFormat, marker );
  639.     va_end( marker );
  640.     return  iLength;
  641. }
  642. /*
  643.  * use __inline to ensure grab __LINE__ and __FILE__
  644.  */
  645. __inline int WINAPIV PreMessageTrace( LONG_PTR lParam, LPCSTR szFormat, ... )
  646. {
  647.     va_list marker;
  648.     int     iLength;
  649.     va_start( marker, szFormat );
  650.     iLength = AsyncMessageTrace( lParam, szFormat, marker );
  651.     va_end( marker );
  652.     return  iLength;
  653. }
  654. /*
  655.  * use __inline to ensure grab __LINE__ and __FILE__
  656.  */
  657. __inline int WINAPIV PreAPITrace( LONG_PTR lParam, LPCSTR szFormat, ... )
  658. {
  659.     va_list marker;
  660.     int     iLength;
  661.     va_start( marker, szFormat );
  662.     iLength = AsyncAPITrace( lParam, szFormat, marker );
  663.     va_end( marker );
  664.     return  iLength;
  665. }
  666. #endif /* !defined(NOTRACE)  */
  667. /* Asserts are independent of tracing
  668.  * (with the exception of flushing the trace buffer).
  669.  *
  670.  * For now enable ASSERT defines only if debugging is enabled
  671.  */
  672. #ifdef  _DEBUG
  673.  /*
  674.   * Macros added for doing asserts and verifies.  basic clones
  675.   * of the MFC macros with a prepended _ symbol
  676.   */
  677.  #define ASYNC_ASSERT(f) !(f) ? FLUSHASYNCTRACE DebugBreak() : ((void)0)
  678.  #define ASYNC_VERIFY(f)         ASYNC_ASSERT(f)
  679. #else
  680.  #define ASYNC_ASSERT(f) ((void)0)
  681.  #define ASYNC_VERIFY(f)        ((void)(f))
  682. #endif
  683. #endif /* !defined(_DBGTRACE_H_) */
  684. #ifdef __cplusplus
  685. }
  686. #endif