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.

251 lines
6.1 KiB

  1. title "Debug Support Functions"
  2. ;++
  3. ;
  4. ; Copyright (c) 2000 Microsoft Corporation
  5. ;
  6. ; Module Name:
  7. ;
  8. ; debugstb.asm
  9. ;
  10. ; Abstract:
  11. ;
  12. ; This module implements functions to support debugging NT.
  13. ;
  14. ; Author:
  15. ;
  16. ; David N. Cutler (davec) 26-Jun-2000
  17. ;
  18. ; Environment:
  19. ;
  20. ; Any mode.
  21. ;
  22. ;--
  23. include ksamd64.inc
  24. subttl "Break Point"
  25. ;++
  26. ;
  27. ; VOID
  28. ; DbgBreakPoint (
  29. ; VOID
  30. ; )
  31. ;
  32. ; Routine Description:
  33. ;
  34. ; This function executes a breakpoint instruction. Useful for entering
  35. ; the debugger under program control. This breakpoint will always go to
  36. ; the kernel debugger if one is installed, otherwise it will go to the
  37. ; debug subsystem.
  38. ;
  39. ; Arguments:
  40. ;
  41. ; None.
  42. ;
  43. ; Return Value:
  44. ;
  45. ; None.
  46. ;
  47. ;--
  48. LEAF_ENTRY DbgBreakPoint, _TEXT$00
  49. int 3 ; break into debugger
  50. ret ; return
  51. LEAF_END DbgBreakPoint, _TEXT$00
  52. subttl "User Break Point"
  53. ;++
  54. ;
  55. ; VOID
  56. ; DbgUserBreakPoint()
  57. ;
  58. ; Routine Description:
  59. ;
  60. ; This function executes a breakpoint instruction. Useful for entering
  61. ; the debug subsystem under program control. The kernel debugger will
  62. ; ignore this breakpoint since it will not find the instruction address
  63. ; its breakpoint table.
  64. ;
  65. ; Arguments:
  66. ;
  67. ; None.
  68. ;
  69. ; Return Value:
  70. ;
  71. ; None.
  72. ;
  73. ;--
  74. LEAF_ENTRY DbgUserBreakPoint, _TEXT$00
  75. int 3 ; break into debugger
  76. ret ; return
  77. LEAF_END DbgUserBreakPoint, _TEXT$00
  78. subttl "Break Point With Status"
  79. ;++
  80. ;
  81. ; VOID
  82. ; DbgBreakPointWithStatus(
  83. ; IN ULONG Status
  84. ; )
  85. ;
  86. ; Routine Description:
  87. ;
  88. ; This function executes a breakpoint instruction. Useful for entering
  89. ; the debugger under program control. This breakpoint will always go to
  90. ; the kernel debugger if one is installed, otherwise it will go to the
  91. ; debug subsystem. This function is identical to DbgBreakPoint, except
  92. ; that it takes an argument which the debugger can see.
  93. ;
  94. ; Note: The debugger checks the address of the breakpoint instruction
  95. ; against the address RtlpBreakWithStatusInstruction. If it matches,
  96. ; we have a breakpoint with status. A breakpoint is normally issued
  97. ; with the break_debug_stop macro which generates two instructions.
  98. ; We can't use the macro here because of the "label on the breakpoint"
  99. ; requirement.
  100. ;
  101. ; Arguments:
  102. ;
  103. ; Status (ecx) - Supplies the break point status code.
  104. ;
  105. ; Return Value:
  106. ;
  107. ; None.
  108. ;
  109. ;--
  110. altentry RtlpBreakWithStatusInstruction
  111. LEAF_ENTRY DbgBreakPointWithStatus, _TEXT$00
  112. ALTERNATE_ENTRY RtlpBreakWithStatusInstruction
  113. int 3 ; break into debugger
  114. ret ; return
  115. LEAF_END DbgBreakPointWithStatus, _TEXT$00
  116. subttl "Debug Print"
  117. ;++
  118. ;
  119. ; NTSTATUS
  120. ; DebugPrint(
  121. ; IN PSTRING Output,
  122. ; IN ULONG ComponentId,
  123. ; IN ULONG Level
  124. ; )
  125. ;
  126. ; Routine Description:
  127. ;
  128. ; This function executes a debug print breakpoint.
  129. ;
  130. ; Arguments:
  131. ;
  132. ; Output (rcx) - Supplies a pointer to the output string descriptor.
  133. ;
  134. ; ComponentId (edx) - Supplies the Id of the calling component.
  135. ;
  136. ; Level (r8d) - Supplies the output importance level.
  137. ;
  138. ; Return Value:
  139. ;
  140. ; STATUS_SUCCESS is returned if the debug print was completed successfully.
  141. ;
  142. ; STATUS_BREAKPOINT is returned if user typed a Control-C during print.
  143. ;
  144. ; STATUS_DEVICE_NOT_CONNECTED is returned if kernel debugger not present.
  145. ;
  146. ;--
  147. LEAF_ENTRY DebugPrint, _TEXT$00
  148. mov r9d, r8d ; set importance level
  149. mov r8d, edx ; set component id
  150. mov dx, StrLength[rcx] ; set length of output string
  151. mov rcx, StrBuffer[rcx] ; set address of output string
  152. mov eax, BREAKPOINT_PRINT ; set debug service type
  153. int 2dh ; call debug service
  154. int 3 ; required - do not remove
  155. ret ; return
  156. LEAF_END DebugPrint, _TEXT$00
  157. subttl "Debug Prompt"
  158. ;++
  159. ;
  160. ; ULONG
  161. ; DebugPrompt(
  162. ; IN PSTRING Output,
  163. ; IN PSTRING Input
  164. ; )
  165. ;
  166. ; Routine Description:
  167. ;
  168. ; This function executes a debug prompt breakpoint.
  169. ;
  170. ; Arguments:
  171. ;
  172. ; Output (rcx) - Supplies a pointer to the output string descriptor.
  173. ;
  174. ; Input (rdx) - Supplies a pointer to the input string descriptor.
  175. ;
  176. ; Return Value:
  177. ;
  178. ; The length of the input string is returned as the function value.
  179. ;
  180. ;--
  181. LEAF_ENTRY DebugPrompt, _TEXT$00
  182. mov r9w, StrMaximumLength[rdx] ; set maximum length of input string
  183. mov r8, StrBuffer[rdx] ; set address of input string
  184. mov dx, StrLength[rcx] ; set length of output string
  185. mov rcx, StrBuffer[rcx] ; set address of output string
  186. mov eax, BREAKPOINT_PROMPT ; set debug service type
  187. int 2dh ; call debug service
  188. int 3 ; required - do not remove
  189. ret ; return
  190. LEAF_END DebugPrompt, _TEXT$00
  191. ;++
  192. ;
  193. ; VOID
  194. ; DebugService2(
  195. ; IN PVOID Param1,
  196. ; IN PVOID Param2,
  197. ; IN ULONG Service
  198. ; )
  199. ;
  200. ; Routine Description:
  201. ;
  202. ; This function calls the kernel debugger to execute a command string.
  203. ;
  204. ; Arguments:
  205. ;
  206. ; Param1 (rcx) - Supplies the first parameter to the KD fault handler
  207. ;
  208. ; Param2 (rdx) - Supplies the second parameter to the KD fault handler
  209. ;
  210. ; Service (r8d) - Supplies a pointer to the command string.
  211. ;
  212. ; Return Value:
  213. ;
  214. ; None.
  215. ;
  216. ;--
  217. LEAF_ENTRY DebugService2, _TEXT$00
  218. mov eax, r8d ; set debug service type
  219. int 2dh ; call debug service
  220. int 3 ; required - do not remove
  221. ret ; return
  222. LEAF_END DebugService2, _TEXT$00
  223. end