Windows NT 4.0 source code leak
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.

154 lines
3.7 KiB

4 years ago
  1. /* --------------------------------------------------------------------
  2. Microsoft OS/2 LAN Manager
  3. Copyright(c) Microsoft Corp., 1990
  4. -------------------------------------------------------------------- */
  5. /* --------------------------------------------------------------------
  6. File: rpcdebug.hxx
  7. Description:
  8. This file describes the interface to the runtime trace facility. These
  9. entry points are for internal use by the runtime only.
  10. -------------------------------------------------------------------- */
  11. #ifndef __RPCDEBUG_HXX__
  12. #define __RPCDEBUG_HXX__
  13. #ifdef TIMERPC
  14. #include "threads.hxx"
  15. #include "osfpcket.hxx"
  16. #endif // TIMERPC
  17. START_C_EXTERN
  18. extern int DebugApiFlag;
  19. END_C_EXTERN
  20. // Upon entry to each API, this routine should be called. If the
  21. // appropriate debug level has been set, it will send a message to the
  22. // RPC trace facility. The API parameter specifies a string name for
  23. // the API.
  24. #ifdef DEBUGRPC
  25. #define DebugApiEntry(API) \
  26. if (DebugApiFlag) \
  27. PrintToDebugger("%s (entry)\n",API)
  28. #else
  29. #define DebugApiEntry(API)
  30. #endif
  31. // Upon exit from each API, this routine should be called. Note that
  32. // the Status parameter is just returned from DebugAPIExit. This allows
  33. // code to be written in the following style:
  34. //
  35. // :
  36. // return(DebugAPIExit("RpcAPI",retval));
  37. // }
  38. #ifdef DEBUGRPC
  39. #define DebugApiExit(API,Status) \
  40. (DebugApiFlag \
  41. ? (PrintToDebugger("%s (exit) [%08lx]\n",API,Status),Status) \
  42. : Status)
  43. #else
  44. #define DebugApiExit(API,Status) Status
  45. #endif
  46. // When an internal error occurs in the RPC system, this routine will be
  47. // called. This will result in a panic message being sent to the RPC trace
  48. // facility.
  49. #ifdef DEBUGRPC
  50. #define DebugPanic(Panic) PrintToDebugger(Panic)
  51. #else
  52. #define DebugPanic(Panic)
  53. #endif
  54. #ifdef DEBUGRPC
  55. #define DebugInternal(Msg) PrintToDebugger(Msg)
  56. #else
  57. #define DebugInternal(Msg)
  58. #endif
  59. #endif /* __RPCDEBUG_HXX__ */
  60. // Following are functions to time the performace of the runtime.
  61. #ifdef TIMERPC
  62. void RPC_ENTRY _StartTimeApi(unsigned long *CurrentApiTime);
  63. void RPC_ENTRY _DoneTimeApi(char *Name, unsigned long *CurrentApiTime);
  64. extern char fTimeYield;
  65. #define StartTimeApi() \
  66. unsigned long CurrentApiTime[TIME_MAX]; \
  67. _StartTimeApi(CurrentApiTime);
  68. inline void ChargeTime(TIME_SLOT Account)
  69. {
  70. ThreadSelf()->ChargeTime(Account);
  71. }
  72. inline void ResetTimeAux()
  73. {
  74. ThreadSelf()->ResetTimeAux();
  75. }
  76. inline void StampTimeUsed(void PAPI *pBuff)
  77. {
  78. THREAD *pThread = ThreadSelf();
  79. pThread->ChargeTime(TIME_RUNTIME);
  80. ((rpcconn_common *)pBuff)->UserTime =
  81. pThread->GetTime()[TIME_RUNTIME] +
  82. pThread->GetTime()[TIME_STUB] +
  83. pThread->GetTime()[TIME_USER] ;
  84. ((rpcconn_common *)pBuff)->ElapseTime = pThread->ReadTimeAux();
  85. }
  86. inline void AccountTimeTrans(void PAPI *pBuff)
  87. {
  88. THREAD * pThread = ThreadSelf();
  89. pThread->ChargeTime(TIME_TRANSPORT);
  90. // pThread->GetTime()[TIME_USER] = pThread->GetTime()[TIME_TRANSPORT];
  91. // pThread->GetTime()[TIME_TRANSPORT] = ((rpcconn_common *)pBuff)->ElapseTime;
  92. pThread->GetTime()[TIME_TRANSPORT] -= ((rpcconn_common *)pBuff)->ElapseTime;
  93. pThread->GetTime()[TIME_USER] += ((rpcconn_common *)pBuff)->UserTime;
  94. pThread->ResetTimeAux();
  95. }
  96. inline void AccountWriteTime()
  97. {
  98. THREAD * pThread = ThreadSelf();
  99. #ifdef NTENV
  100. if (fTimeYield)
  101. PauseExecution(1L);
  102. #endif // NTENV
  103. pThread->ChargeTime(TIME_TRANSPORT);
  104. pThread->ResetTimeAux();
  105. }
  106. #define DoneTimeApi(Name) \
  107. _DoneTimeApi(Name, CurrentApiTime);
  108. #else
  109. #define StartTimeApi()
  110. #define DoneTimeApi(Name)
  111. #define ChargeTime(Account)
  112. #define ResetTimeAux()
  113. #define StampTimeUsed(pBuff)
  114. #define AccountTimeTrans(pBuff)
  115. #define AccountWriteTime()
  116. #endif