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.

195 lines
7.4 KiB

  1. //-----------------------------------------------------------------------------
  2. //
  3. // File: Icecap.h
  4. // Copyright (C) 1997-1998 Microsoft Corporation
  5. // All rights reserved.
  6. //
  7. // This header file is part of IceCAP {{rmj}}.{{rmm}}.{{rup}}. It is
  8. // MICROSOFT CONFIDENTIAL, and should not be distributed except under NDA.
  9. //
  10. //-----------------------------------------------------------------------------
  11. // ICECAP.H
  12. // interface to the Datalocality APIs
  13. #ifndef __ICECAP_H__
  14. #define __ICECAP_H__
  15. #ifndef DONTUSEICECAPLIB
  16. #pragma comment(lib, "IceCAP.lib")
  17. #endif // USEICECAPLIB
  18. #ifdef __cplusplus
  19. extern "C" {
  20. #endif
  21. // Defines for Levels and Id's
  22. #define PROFILE_GLOBALLEVEL 1
  23. #define PROFILE_PROCESSLEVEL 2
  24. #define PROFILE_THREADLEVEL 3
  25. #define PROFILE_FIBERLEVEL 4
  26. #define PROFILE_CURRENTID ((unsigned long)0xFFFFFFFF)
  27. // Start/Stop Api's
  28. int _declspec(dllimport) _stdcall StopProfile(int nLevel, unsigned long dwId);
  29. int _declspec(dllimport) _stdcall StartProfile(int nLevel, unsigned long dwId);
  30. // Suspend/Resume Api's
  31. int _declspec(dllimport) _stdcall SuspendProfile(int nLevel, unsigned long dwId);
  32. int _declspec(dllimport) _stdcall ResumeProfile(int nLevel, unsigned long dwId);
  33. // Mark Api's
  34. int _declspec(dllimport) _stdcall MarkProfile(long lMarker);
  35. int _declspec(dllimport) _stdcall CommentMarkProfile(long lMarker, const char *szComment);
  36. int _declspec(dllimport) _stdcall CommentMarkAtProfile(__int64 dnTimestamp, long lMarker, const char *szComment);
  37. int _declspec(dllimport) _stdcall DlpMarkProfile(long lMarker0, long lMarker1);
  38. // Named Profiling Elements Api's
  39. int _declspec(dllimport) _stdcall NameProfile(const char *pszName, int nLevel, unsigned long dwId);
  40. // Security Api's
  41. // NOTE: please contact ICAPSUP before using this function
  42. int _declspec(dllimport) _stdcall ClearProcessSecurityAcl(int fImpersonatingUser);
  43. // xxxProfile return codes
  44. #define PROFILE_OK 0 // xxxProfile call successful
  45. #define PROFILE_ERROR_NOT_YET_IMPLEMENTED 1 // api or level,id combination not supported yet
  46. #define PROFILE_ERROR_MODE_NEVER 2 // mode was never when called
  47. #define PROFILE_ERROR_LEVEL_NOEXIST 3 // level doesn't exist
  48. #define PROFILE_ERROR_ID_NOEXIST 4 // id doesn't exist
  49. #define PROFILE_ERROR_NO_WMI_UPDATE 5 // failed to update the WMI (pagefault collection) state
  50. // MarkProfile return codes
  51. #define MARK_OK 0 // Mark was taken successfully
  52. #define MARK_ERROR_MODE_NEVER 1 // Profiling was never when MarkProfile called
  53. #define MARK_ERROR_MODE_OFF 2 // Profiling was off when MarkProfile called
  54. #define MARK_ERROR_MARKER_RESERVED 3 // Mark value passed is a reserved value
  55. #define MARK_TEXTTOOLONG 4 // Comment text was truncated
  56. #define MARK_ERROR_OUTOFMEMORY 6 // no memory was available in which to record the event
  57. // NameProfile return codes
  58. #define NAME_OK 0 // Name was registered sucessfullly
  59. #define NAME_ERROR_TEXTTRUNCATED 1 // The name text was too long and was therefore truncated
  60. #define NAME_ERROR_REDEFINITION 2 // The given profile element has already been named
  61. #define NAME_ERROR_LEVEL_NOEXIST 3 // level doesn't exist
  62. #define NAME_ERROR_ID_NOEXIST 4 // id doesn't exist
  63. #define NAME_ERROR_INVALID_NAME 5 // name does not meet the specification's requirements
  64. #define NAME_ERROR_OUTOFMEMORY 6 // no memory was available in which to record the event
  65. #define NAME_ERROR_NO_SUPPORT 7 // the given operation is not supported
  66. // Icecap 3.x Compatibility defines
  67. #define StartCAP() StartProfile(PROFILE_THREADLEVEL, PROFILE_CURRENTID)
  68. #define StopCAP() StopProfile(PROFILE_THREADLEVEL, PROFILE_CURRENTID)
  69. #define SuspendCAP() SuspendProfile(PROFILE_THREADLEVEL, PROFILE_CURRENTID)
  70. #define ResumeCAP() ResumeProfile(PROFILE_THREADLEVEL, PROFILE_CURRENTID)
  71. #define StartCAPAll() StartProfile(PROFILE_PROCESSLEVEL, PROFILE_CURRENTID)
  72. #define StopCAPAll() StopProfile(PROFILE_PROCESSLEVEL, PROFILE_CURRENTID)
  73. #define SuspendCAPAll() SuspendProfile(PROFILE_PROCESSLEVEL, PROFILE_CURRENTID)
  74. #define ResumeCAPAll() ResumeProfile(PROFILE_PROCESSLEVEL, PROFILE_CURRENTID)
  75. #define MarkCAP(mark) MarkProfile(mark)
  76. #define AllowCAP()
  77. // DataLocality 1.x Compatibility defines
  78. #define StartDLP() StartCAP()
  79. #define StopDLP() StopCAP()
  80. #define MarkDLP(mark) MarkCAP(mark)
  81. //
  82. // USER DEFINED COUNTER HELPERS AND TYPES
  83. //
  84. // COUNTER_FUNCTION_PROLOGE and EPILOGE
  85. //
  86. // These functions are supplied to protect the state of registers
  87. // that the IceCAP collection probes rely on. We did everything we
  88. // could to eliminate instructions during collection. Your mission,
  89. // if you choose to accept it, is the same.
  90. //
  91. #define COUNTER_FUNCTION_PROLOGE _asm push ecx _asm push ebx _asm push ebp
  92. #define COUNTER_FUNCTION_EPILOGE _asm pop ebp _asm pop ebx _asm pop ecx _asm ret
  93. #ifndef USER_COUNTER_INFO_DEFINED
  94. #define USER_COUNTER_INFO_DEFINED
  95. // CONSTS AND ENUMS
  96. //
  97. // UserCounterType
  98. //
  99. // These enumerations describe how the counter works.
  100. //
  101. // MonotonicallyIncreasing -- This describes a counter that will increment
  102. // by one each time some 'event' occurs. An
  103. // example would be a counter that tracks the
  104. // number of memory allocations. Each allocation
  105. // increments the number by one.
  106. //
  107. // MonotonicallyDecreasint -- This describes a counter that will decrement
  108. // by one each time some 'event' occurs. An
  109. // example would be a counter that tracks a limited
  110. // resource. Each use of the resource decrements
  111. // the number by one.
  112. //
  113. // RandomIncreasing -- This describes a counter that will increase for
  114. // each 'event' that occurs, but by an undetermined
  115. // amount. An example would be the total memory
  116. // allocated. Each allocation would add it's size
  117. // to the counter, but each allocation being potentially
  118. // different, causes the counter to go up by a random
  119. // amount each time.
  120. //
  121. // RandomDecreasing -- This describes a coutner that will decrease for
  122. // each 'event' that occurs, but by an undetermined
  123. // amount. An example would be a limited resource
  124. // that can be used in bunches. Each use fo the
  125. // the resource would cause the number to descrease
  126. // by a random amount.
  127. //
  128. // Random -- This number can either go up, or go down. An
  129. // example would be the total amount of available
  130. // memory, which can either go up (as memory is
  131. // free'd), or go down (as memory is allocated).
  132. //
  133. enum UserCounterType
  134. {
  135. MonotonicallyIncreasing,
  136. MonotonicallyDecreasing,
  137. RandomIncreasing,
  138. RandomDecreasing,
  139. Random
  140. };
  141. // TYPEDEFS
  142. //
  143. typedef signed __int64 COUNTER, *PCOUNTER;
  144. ///////////////////////////////////////////////////////////////
  145. // USERCOUNTERINFO
  146. //
  147. // This structure descibes a user defined counter so that
  148. // IceCAP can use it during profiling runs.
  149. //
  150. // History: 9-21-98 BarryNo Created
  151. //
  152. ///////////////////////////////////////////////////////////////
  153. typedef struct _USERCOUNTERINFO
  154. {
  155. unsigned long dwSize; // Size of this structure (for version control)
  156. char szCounterFuncName[32]; // Name of the function
  157. enum UserCounterType ct; // Describes the type of number we will be collecting
  158. char szName[32]; // Name of user counter
  159. int bSynchronized; // Is this counter synchronized
  160. } USERCOUNTERINFO, *PUSERCOUNTERINFO;
  161. #endif // USER_COUNTER_INFO_DEFINED
  162. #ifdef __cplusplus
  163. }
  164. #endif
  165. #endif // __ICECAP_H__