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.

315 lines
5.6 KiB

  1. /*++ BUILD Version: 0006 // Increment this if a change has global effects
  2. Copyright (c) 1989 Microsoft Corporation
  3. Module Name:
  4. kd.h
  5. Abstract:
  6. This module contains the public data structures and procedure
  7. prototypes for the Kernel Debugger sub-component of NTOS.
  8. Author:
  9. Mike O'Leary (mikeol) 29-June-1989
  10. Revision History:
  11. --*/
  12. #ifndef _KD_
  13. #define _KD_
  14. // begin_nthal
  15. //
  16. // Define the number of debugging devices we support
  17. //
  18. #define MAX_DEBUGGING_DEVICES_SUPPORTED 2
  19. //
  20. // Status Constants for reading data from comport
  21. //
  22. #define CP_GET_SUCCESS 0
  23. #define CP_GET_NODATA 1
  24. #define CP_GET_ERROR 2
  25. // end_nthal
  26. //
  27. // Debug constants for FreezeFlag
  28. //
  29. #define FREEZE_BACKUP 0x0001
  30. #define FREEZE_SKIPPED_PROCESSOR 0x0002
  31. #define FREEZE_FROZEN 0x0004
  32. //
  33. // System Initialization procedure for KD subcomponent of NTOS
  34. //
  35. BOOLEAN
  36. KdInitSystem(
  37. IN ULONG Phase,
  38. IN PLOADER_PARAMETER_BLOCK LoaderBlock
  39. );
  40. BOOLEAN
  41. KdEnterDebugger(
  42. IN PKTRAP_FRAME TrapFrame,
  43. IN PKEXCEPTION_FRAME ExceptionFrame
  44. );
  45. VOID
  46. KdExitDebugger(
  47. IN BOOLEAN Enable
  48. );
  49. extern BOOLEAN KdPitchDebugger;
  50. BOOLEAN
  51. KdPollBreakIn (
  52. VOID
  53. );
  54. BOOLEAN
  55. KdIsThisAKdTrap (
  56. IN PEXCEPTION_RECORD ExceptionRecord,
  57. IN PCONTEXT ContextRecord,
  58. IN KPROCESSOR_MODE PreviousMode
  59. );
  60. VOID
  61. KdSetOwedBreakpoints(
  62. VOID
  63. );
  64. VOID
  65. KdDeleteAllBreakpoints(
  66. VOID
  67. );
  68. //
  69. // Data structure for passing information to KdpReportLoadSymbolsStateChange
  70. // function via the debug trap
  71. //
  72. typedef struct _KD_SYMBOLS_INFO {
  73. IN PVOID BaseOfDll;
  74. IN ULONG_PTR ProcessId;
  75. IN ULONG CheckSum;
  76. IN ULONG SizeOfImage;
  77. } KD_SYMBOLS_INFO, *PKD_SYMBOLS_INFO;
  78. // begin_nthal
  79. //
  80. // Defines the debug port parameters for kernel debugger
  81. // CommunicationPort - specify which COM port to use as debugging port
  82. // 0 - use default; N - use COM N.
  83. // BaudRate - the baud rate used to initialize debugging port
  84. // 0 - use default rate.
  85. //
  86. typedef struct _DEBUG_PARAMETERS {
  87. ULONG CommunicationPort;
  88. ULONG BaudRate;
  89. } DEBUG_PARAMETERS, *PDEBUG_PARAMETERS;
  90. // end_nthal
  91. // begin_ntddk begin_wdm begin_nthal begin_ntifs begin_ntosp
  92. //
  93. // Define external data.
  94. // because of indirection for all drivers external to ntoskrnl these are actually ptrs
  95. //
  96. #if defined(_NTDDK_) || defined(_NTIFS_) || defined(_NTHAL_) || defined(_WDMDDK_) || defined(_NTOSP_)
  97. extern PBOOLEAN KdDebuggerNotPresent;
  98. extern PBOOLEAN KdDebuggerEnabled;
  99. #define KD_DEBUGGER_ENABLED *KdDebuggerEnabled
  100. #define KD_DEBUGGER_NOT_PRESENT *KdDebuggerNotPresent
  101. #else
  102. extern BOOLEAN KdDebuggerNotPresent;
  103. extern BOOLEAN KdDebuggerEnabled;
  104. #define KD_DEBUGGER_ENABLED KdDebuggerEnabled
  105. #define KD_DEBUGGER_NOT_PRESENT KdDebuggerNotPresent
  106. #endif
  107. // end_ntddk end_wdm end_nthal end_ntifs end_ntosp
  108. extern DEBUG_PARAMETERS KdDebugParameters;
  109. //
  110. // This event is provided by the time service. The debugger
  111. // signals the event when the system time has slipped due
  112. // to debugger activity.
  113. //
  114. VOID
  115. KdUpdateTimeSlipEvent(
  116. PVOID Event
  117. );
  118. //
  119. // Let PS update data in the KdDebuggerDataBlock
  120. //
  121. VOID KdUpdateDataBlock(VOID);
  122. ULONG_PTR KdGetDataBlock(VOID);
  123. // begin_ntddk begin_wdm begin_nthal begin_ntifs
  124. VOID
  125. KdDisableDebugger(
  126. VOID
  127. );
  128. VOID
  129. KdEnableDebugger(
  130. VOID
  131. );
  132. // end_ntddk end_wdm end_nthal end_ntifs
  133. NTSTATUS
  134. KdPowerTransition(
  135. IN DEVICE_POWER_STATE newDeviceState
  136. );
  137. //
  138. // DbgPrint strings will always be logged to a circular buffer. This
  139. // function may be called directly by the debugger service trap handler
  140. // even when the debugger is not enabled.
  141. //
  142. #if DBG
  143. #define KDPRINTBUFFERSIZE 32768
  144. #else
  145. #define KDPRINTBUFFERSIZE 4096
  146. #endif
  147. VOID
  148. KdLogDbgPrint(
  149. IN PSTRING String
  150. );
  151. __inline
  152. VOID
  153. KdCheckForDebugBreak(
  154. VOID
  155. )
  156. /*++
  157. Routine Description:
  158. If necessary, poll for a request to break-in from the debugger.
  159. This function should be called by routines that run at an IRQL
  160. above clock level that want to be broken in by CTRL-C requests
  161. from the debugger. Crashdump and hiber, for example, run at
  162. HIGH_LEVEL and explicitly need to poll for breaking.
  163. Arguments:
  164. None.
  165. Return Value:
  166. None.
  167. --*/
  168. {
  169. if (KdDebuggerEnabled && KdPollBreakIn()) {
  170. DbgBreakPointWithStatus (DBG_STATUS_CONTROL_C);
  171. }
  172. }
  173. //
  174. // Global debug print filter mask.
  175. //
  176. extern ULONG Kd_WIN2000_Mask;
  177. //
  178. // Allow raw tracing data to be exported to the host
  179. // over the kd protocol.
  180. //
  181. VOID
  182. KdReportTraceData(
  183. IN struct _WMI_BUFFER_HEADER* Buffer,
  184. IN PVOID Context
  185. );
  186. //
  187. // Allow file I/O for files on the kd host machine.
  188. // All pointers must refer to nonpaged memory.
  189. //
  190. NTSTATUS
  191. KdCreateRemoteFile(
  192. OUT PHANDLE Handle,
  193. OUT PULONG64 Length, OPTIONAL
  194. IN PUNICODE_STRING FileName,
  195. IN ACCESS_MASK DesiredAccess,
  196. IN ULONG FileAttributes,
  197. IN ULONG ShareAccess,
  198. IN ULONG CreateDisposition,
  199. IN ULONG CreateOptions
  200. );
  201. NTSTATUS
  202. KdReadRemoteFile(
  203. IN HANDLE Handle,
  204. IN ULONG64 Offset,
  205. OUT PVOID Buffer,
  206. IN ULONG Length,
  207. OUT PULONG Completed
  208. );
  209. NTSTATUS
  210. KdWriteRemoteFile(
  211. IN HANDLE Handle,
  212. IN ULONG64 Offset,
  213. IN PVOID Buffer,
  214. IN ULONG Length,
  215. OUT PULONG Completed
  216. );
  217. NTSTATUS
  218. KdCloseRemoteFile(
  219. IN HANDLE Handle
  220. );
  221. NTSTATUS
  222. KdPullRemoteFile(
  223. IN PUNICODE_STRING FileName,
  224. IN ULONG FileAttributes,
  225. IN ULONG CreateDisposition,
  226. IN ULONG CreateOptions
  227. );
  228. NTSTATUS
  229. KdPushRemoteFile(
  230. IN PUNICODE_STRING FileName,
  231. IN ULONG FileAttributes,
  232. IN ULONG CreateDisposition,
  233. IN ULONG CreateOptions
  234. );
  235. #endif // _KD_