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.

358 lines
7.5 KiB

  1. //+-------------------------------------------------------------------------
  2. //
  3. // Microsoft Windows
  4. // Copyright (C) Microsoft Corporation, 1992 - 1992.
  5. //
  6. // File: dbgpoint.hxx
  7. //
  8. // Contents: Support for visual debug values
  9. //
  10. // Classes: CDebugBaseClass
  11. // CDebugBreakPoint
  12. // CDebugValue
  13. //
  14. // Functions:
  15. //
  16. // History: 12-Mar-93 KevinRo Created
  17. //
  18. // This module handles debug values, such as breakpoints and settable
  19. // values. By using this module, the values can be examined and changed
  20. // in a debugging window. The debugging window uses its own thread, so
  21. // changes can be effected asynchronously.
  22. //
  23. //--------------------------------------------------------------------------
  24. #ifndef __DBGPOINT_HXX__
  25. #define __DBGPOINT_HXX__
  26. #if defined(__cplusplus)
  27. enum DebugValueType
  28. {
  29. dvtBreakPoint,
  30. dvtInfoLevel,
  31. dvtValue
  32. };
  33. class CDebugBaseClass;
  34. //
  35. // The following routines are exported from commnot.dll
  36. //
  37. extern "C"
  38. EXPORTDEF
  39. void APINOT dbgRegisterGroup(WCHAR const *pwzName,HANDLE *hGroup);
  40. extern "C"
  41. EXPORTDEF
  42. void APINOT dbgRemoveGroup(HANDLE hGroup);
  43. extern "C"
  44. EXPORTDEF
  45. void APINOT dbgRegisterValue(WCHAR const *pwzName,HANDLE hGroup,CDebugBaseClass *pdv);
  46. extern "C"
  47. EXPORTDEF
  48. void APINOT dbgRemoveValue(HANDLE hGroup,CDebugBaseClass *pdv);
  49. extern "C"
  50. EXPORTDEF
  51. void APINOT dbgNotifyChange(HANDLE hGroup,CDebugBaseClass *pdv);
  52. extern "C"
  53. EXPORTDEF
  54. ULONG APINOT dbgGetIniInfoLevel(WCHAR const *pwzName,ULONG ulDefault);
  55. extern "C"
  56. EXPORTDEF
  57. ULONG APINOT dbgBreakDialog(char const *pszFileName,ULONG ulLineNumber,WCHAR const *pwzName,long ulCode);
  58. // The following values may be returned by dbgBreakDialog
  59. #define CDBG_BREAKPOINT_CONTINUE 0x01
  60. #define CDBG_BREAKPOINT_BREAK 0x02
  61. #define CDBG_BREAKPOINT_DISABLE 0x04
  62. //
  63. // The following group is for the Infolevel Group. The group is automatically
  64. // registered when a value is added to it.
  65. //
  66. #define HANDLE_INFOLEVELGROUP ((HANDLE)-1)
  67. //+-------------------------------------------------------------------------
  68. //
  69. // Class: CDebugBaseClass
  70. //
  71. // Purpose: Defines a base class used by visual debug value system
  72. //
  73. // Interface:
  74. //
  75. // History: 12-Mar-93 KevinRo Created
  76. //
  77. // Notes:
  78. //
  79. //--------------------------------------------------------------------------
  80. class CDebugBaseClass
  81. {
  82. public:
  83. CDebugBaseClass(WCHAR const *pwzValueName,
  84. HANDLE hGroupHandle,
  85. DebugValueType dvtType):
  86. _dvtType(dvtType),
  87. _hGroupHandle(hGroupHandle)
  88. {
  89. }
  90. void Register(WCHAR const *pwzValueName)
  91. {
  92. dbgRegisterValue(pwzValueName,_hGroupHandle,this);
  93. }
  94. virtual ~CDebugBaseClass()
  95. {
  96. dbgRemoveValue(_hGroupHandle,this);
  97. }
  98. virtual void NotifyChange()
  99. {
  100. dbgNotifyChange(_hGroupHandle,this);
  101. }
  102. DebugValueType GetValueType() {return _dvtType;}
  103. HANDLE GetGroupHandle() { return _hGroupHandle;}
  104. private:
  105. HANDLE _hGroupHandle;
  106. DebugValueType _dvtType;
  107. };
  108. //+-------------------------------------------------------------------------
  109. //
  110. // Class: CDebugBreakPoint
  111. //
  112. // Purpose: Defines an externally switchable break point. By using the
  113. // visual debug window, you can set or clear this breakpoint
  114. // while a program runs.
  115. //
  116. // Interface:
  117. //
  118. // History: 12-Mar-93 KevinRo Created
  119. //
  120. // Notes:
  121. //
  122. //--------------------------------------------------------------------------
  123. class CDebugBreakPoint : public CDebugBaseClass
  124. {
  125. public:
  126. CDebugBreakPoint(WCHAR const *pwzName,HANDLE hGroup,ULONG fBreakSet):
  127. _fBreakSet(fBreakSet),
  128. _pwzName(pwzName),
  129. CDebugBaseClass(pwzName,hGroup,dvtBreakPoint)
  130. {
  131. Register(pwzName);
  132. }
  133. ~CDebugBreakPoint()
  134. {
  135. }
  136. void ToggleBreakPoint()
  137. {
  138. _fBreakSet = !_fBreakSet;
  139. NotifyChange();
  140. }
  141. ULONG GetBreakPoint()
  142. {
  143. return(_fBreakSet);
  144. }
  145. ULONG SetBreakPoint()
  146. {
  147. register ret = _fBreakSet;
  148. _fBreakSet = TRUE;
  149. NotifyChange();
  150. return(ret);
  151. }
  152. ULONG ClearBreakPoint()
  153. {
  154. register ret = _fBreakSet;
  155. _fBreakSet = FALSE;
  156. NotifyChange();
  157. return(ret);
  158. }
  159. inline BOOL BreakPointTest()
  160. {
  161. return _fBreakSet;
  162. }
  163. inline BOOL BreakPointMessage(char *pszFileName,ULONG ulLineNo,long lCode=0)
  164. {
  165. ULONG rc = dbgBreakDialog(pszFileName,ulLineNo,_pwzName,lCode);
  166. if(rc & CDBG_BREAKPOINT_DISABLE) ClearBreakPoint();
  167. return(rc & CDBG_BREAKPOINT_BREAK);
  168. }
  169. public:
  170. WCHAR const * _pwzName;
  171. BOOL _fBreakSet;
  172. };
  173. //+-------------------------------------------------------------------------
  174. //
  175. // Class: CDebugValue
  176. //
  177. // Purpose: A DebugValue makes a ULONG value visible and settable
  178. // from the debugging window. By accepting a ULONG reference,
  179. // it is possible to expose a ULONG value to the debugging
  180. // window.
  181. //
  182. // Interface:
  183. //
  184. // History: 12-Mar-93 KevinRo Created
  185. //
  186. // Notes:
  187. //
  188. //--------------------------------------------------------------------------
  189. class CDebugValue : public CDebugBaseClass
  190. {
  191. public:
  192. CDebugValue(WCHAR const *pwzName,HANDLE hGroup,ULONG & ulValue):
  193. _ulValue(ulValue),
  194. CDebugBaseClass(pwzName,hGroup,dvtValue)
  195. {
  196. Register(pwzName);
  197. }
  198. ~CDebugValue()
  199. {
  200. }
  201. ULONG GetValue()
  202. {
  203. return(_ulValue);
  204. }
  205. ULONG SetValue(ULONG ulValue)
  206. {
  207. register ret = _ulValue;
  208. _ulValue = ulValue;
  209. NotifyChange();
  210. return(ret);
  211. }
  212. private:
  213. ULONG & _ulValue;
  214. };
  215. //+-------------------------------------------------------------------------
  216. //
  217. // Class: CInfoLevel
  218. //
  219. // Purpose: A CInfoLevel makes an InfoLevel value accessable by the
  220. // debugging window.
  221. //
  222. // Interface:
  223. //
  224. // History: 12-Mar-93 KevinRo Created
  225. //
  226. // Notes:
  227. //
  228. //--------------------------------------------------------------------------
  229. class CInfoLevel : public CDebugBaseClass
  230. {
  231. public:
  232. CInfoLevel(WCHAR const *pwzName,ULONG & ulValue,ULONG deflvl = DEF_INFOLEVEL):
  233. _ulInfoLevel(ulValue),
  234. CDebugBaseClass(pwzName,HANDLE_INFOLEVELGROUP,dvtInfoLevel)
  235. {
  236. _ulInfoLevel = dbgGetIniInfoLevel(pwzName,deflvl);
  237. Register(pwzName);
  238. }
  239. ~CInfoLevel()
  240. {
  241. }
  242. ULONG GetInfoLevel()
  243. {
  244. return(_ulInfoLevel);
  245. }
  246. ULONG SetInfoLevel(ULONG ulValue)
  247. {
  248. register ret = _ulInfoLevel;
  249. _ulInfoLevel = ulValue;
  250. NotifyChange();
  251. return(ret);
  252. }
  253. private:
  254. ULONG & _ulInfoLevel;
  255. };
  256. //+-------------------------------------------------------------------------
  257. //
  258. // Class: CDebugGroupClass
  259. //
  260. // Purpose: Encapsulates a Debug Group
  261. //
  262. // Notes:
  263. //
  264. //--------------------------------------------------------------------------
  265. class CDebugGroupClass
  266. {
  267. public:
  268. CDebugGroupClass(WCHAR *pwzName)
  269. {
  270. dbgRegisterGroup(pwzName,&_hGroup);
  271. }
  272. ~CDebugGroupClass()
  273. {
  274. dbgRemoveGroup(_hGroup);
  275. }
  276. operator HANDLE() { return(_hGroup); }
  277. private:
  278. HANDLE _hGroup;
  279. };
  280. #endif // defined(__cplusplus)
  281. #endif // __DBGPOINT_HXX__