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.

371 lines
7.6 KiB

  1. /**
  2. *** Copyright (C) 1996-97 Intel Corporation. All rights reserved.
  3. ***
  4. *** The information and source code contained herein is the exclusive
  5. *** property of Intel Corporation and may not be disclosed, examined
  6. *** or reproduced in whole or in part without explicit written authorization
  7. *** from the company.
  8. **/
  9. // TITLE("Debug Support Functions")
  10. //++
  11. //
  12. // Module Name:
  13. //
  14. // debugstb.s
  15. //
  16. // Abstract:
  17. //
  18. // This module implements functions to support debugging NT. Each
  19. // function executes a break instruction with a special immediate
  20. // value.
  21. //
  22. // Author:
  23. //
  24. // William K. Cheung (wcheung) 17-Jan-1996
  25. //
  26. // Environment:
  27. //
  28. // Any mode.
  29. //
  30. // Revision History:
  31. //
  32. // 08-Feb-1996 Updated to EAS 2.1
  33. //
  34. //--
  35. #include "ksia64.h"
  36. //++
  37. //
  38. // VOID
  39. // DbgBreakPoint()
  40. //
  41. // Routine Description:
  42. //
  43. // This function executes a breakpoint instruction. Useful for entering
  44. // the debugger under program control. This breakpoint will always go to
  45. // the kernel debugger if one is installed, otherwise it will go to the
  46. // debug subsystem.
  47. //
  48. // Arguments:
  49. //
  50. // None.
  51. //
  52. // Return Value:
  53. //
  54. // None.
  55. //
  56. //--
  57. LEAF_ENTRY(DbgBreakPoint)
  58. flushrs
  59. ;;
  60. break.i BREAKPOINT_STOP
  61. br.ret.sptk.clr brp
  62. LEAF_EXIT(DbgBreakPoint)
  63. //++
  64. //
  65. // VOID
  66. // DbgBreakPointWithStatus(
  67. // IN ULONG Status
  68. // )
  69. //
  70. // Routine Description:
  71. //
  72. // This function executes a breakpoint instruction. Useful for entering
  73. // the debugger under program control. This breakpoint will always go to
  74. // the kernel debugger if one is installed, otherwise it will go to the
  75. // debug subsystem. This function is identical to DbgBreakPoint, except
  76. // that it takes an argument which the debugger can see.
  77. //
  78. // Arguments:
  79. //
  80. // A status code.
  81. //
  82. // Return Value:
  83. //
  84. // None.
  85. //
  86. //--
  87. LEAF_ENTRY(DbgBreakPointWithStatus)
  88. ALTERNATE_ENTRY(RtlpBreakWithStatusInstruction)
  89. flushrs
  90. ;;
  91. add t0 = zero, a0
  92. break.i BREAKPOINT_STOP
  93. br.ret.sptk.clr brp
  94. LEAF_EXIT(DbgBreakPointWithStatus)
  95. //++
  96. //
  97. // VOID
  98. // DbgUserBreakPoint()
  99. //
  100. // Routine Description:
  101. //
  102. // This function executes a breakpoint instruction. Useful for entering
  103. // the debug subsystem under program control. The kernel debug will ignore
  104. // this breakpoint since it will not find the instruction address in its
  105. // breakpoint table.
  106. //
  107. // Arguments:
  108. //
  109. // None.
  110. //
  111. // Return Value:
  112. //
  113. // None.
  114. //
  115. //--
  116. LEAF_ENTRY(DbgUserBreakPoint)
  117. flushrs
  118. ;;
  119. break.i BREAKPOINT_STOP
  120. br.ret.sptk.clr brp
  121. LEAF_EXIT(DbgUserBreakPoint)
  122. //++
  123. //
  124. // ULONG
  125. // DebugPrompt(
  126. // IN PSTRING Output,
  127. // IN PSTRING Input
  128. // )
  129. //
  130. // Routine Description:
  131. //
  132. // This function executes a debug prompt breakpoint.
  133. //
  134. // Arguments:
  135. //
  136. // Output (a0) - Supplies a pointer to the output string descriptor.
  137. //
  138. // Input (a1) - Supplies a pointer to the input string descriptor.
  139. //
  140. // Return Value:
  141. //
  142. // The length of the input string is returned as the function value.
  143. //
  144. //--
  145. LEAF_ENTRY(DebugPrompt)
  146. flushrs
  147. add a0 = StrBuffer, a0
  148. add a1 = StrBuffer, a1
  149. ;;
  150. //
  151. // Set the following 4 arguments into scratch registers t0 - t3;
  152. // they are passed to the KiDebugRoutine() via the context record.
  153. //
  154. // t0 - address of output string
  155. // t1 - length of output string
  156. // t2 - address of input string
  157. // t3 - maximumm length of input string
  158. //
  159. LDPTRINC(t0, a0, StrLength - StrBuffer)
  160. LDPTRINC(t2, a1, StrMaximumLength - StrBuffer)
  161. nop.i 0
  162. ;;
  163. ld2.nta t1 = [a0]
  164. ld2.nta t3 = [a1]
  165. break.i BREAKPOINT_PROMPT
  166. nop.m 0
  167. nop.m 0
  168. br.ret.sptk.clr brp
  169. LEAF_EXIT(DebugPrompt)
  170. //++
  171. //
  172. // VOID
  173. // DebugLoadImageSymbols(
  174. // IN PSTRING ImagePathName,
  175. // IN PKD_SYMBOLS_INFO SymbolInfo
  176. // )
  177. //
  178. // Routine Description:
  179. //
  180. // This function calls the kernel debugger to load the symbol
  181. // table for the specified image.
  182. //
  183. // Arguments:
  184. //
  185. // ImagePathName - specifies the fully qualified path name of the image
  186. // file that has been loaded into an NT address space.
  187. //
  188. // SymbolInfo - information captured from header of image file.
  189. //
  190. // Return Value:
  191. //
  192. // None.
  193. //
  194. //--
  195. LEAF_ENTRY(DebugLoadImageSymbols)
  196. //
  197. // Arguments are passed to the KiDebugRoutine via the context record
  198. // in scratch registers t0 and t1.
  199. //
  200. flushrs
  201. add t0 = zero, a0
  202. add t1 = zero, a1
  203. ;;
  204. nop.m 0
  205. break.i BREAKPOINT_LOAD_SYMBOLS
  206. br.ret.sptk.clr brp
  207. LEAF_EXIT(DebugLoadImageSymbols)
  208. //++
  209. //
  210. // VOID
  211. // DebugUnLoadImageSymbols(
  212. // IN PSTRING ImagePathName,
  213. // IN PKD_SYMBOLS_INFO SymbolInfo
  214. // )
  215. //
  216. // Routine Description:
  217. //
  218. // This function calls the kernel debugger to unload the symbol
  219. // table for the specified image.
  220. //
  221. // Arguments:
  222. //
  223. // ImagePathName - specifies the fully qualified path name of the image
  224. // file that has been unloaded from an NT address space.
  225. //
  226. // SymbolInfo - information captured from header of image file.
  227. //
  228. // Return Value:
  229. //
  230. // None.
  231. //
  232. //--
  233. LEAF_ENTRY(DebugUnLoadImageSymbols)
  234. //
  235. // Arguments are passed to the KiDebugRoutine via the context record
  236. // in scratch registers t0 and t1.
  237. //
  238. flushrs
  239. add t0 = zero, a0
  240. add t1 = zero, a1
  241. ;;
  242. nop.m 0
  243. break.i BREAKPOINT_UNLOAD_SYMBOLS
  244. br.ret.sptk.clr brp
  245. LEAF_EXIT(DebugUnLoadImageSymbols)
  246. //++
  247. //
  248. // NTSTATUS
  249. // DebugPrint(
  250. // IN PSTRING Output,
  251. // IN ULONG ComponentId,
  252. // IN ULONG Level
  253. // )
  254. //
  255. // Routine Description:
  256. //
  257. // This function executes a debug print breakpoint.
  258. //
  259. // Arguments:
  260. //
  261. // Output (a0) - Supplies a pointer to the output string descriptor.
  262. //
  263. // ComponentId (a1) - Supplies the Id of the calling component.
  264. //
  265. // Level (a2) - Supplies the output importance level.
  266. //
  267. // Return Value:
  268. //
  269. // Status code. STATUS_SUCCESS if debug print happened.
  270. // STATUS_BREAKPOINT if user typed a Control-C during print.
  271. // STATUS_DEVICE_NOT_CONNECTED if kernel debugger not present.
  272. //
  273. //--
  274. LEAF_ENTRY(DebugPrint)
  275. flushrs
  276. add t5 = StrBuffer, a0
  277. ;;
  278. LDPTRINC(t0, t5, StrLength-StrBuffer) // set address of output string
  279. ;;
  280. ld2.nta t1 = [t5] // set length of output string
  281. add t2 = zero, a1 // set component id
  282. add t3 = zero, a2 // set importance level
  283. break.i BREAKPOINT_PRINT // execute a debug print breakpoint
  284. br.ret.sptk.clr brp
  285. LEAF_EXIT(DebugPrint)
  286. //++
  287. //
  288. // VOID
  289. // DebugCommandString(
  290. // IN PSTRING Name,
  291. // IN PSTRING Command
  292. // )
  293. //
  294. // Routine Description:
  295. //
  296. // This function requests that the kernel debugger execute
  297. // the given command string.
  298. //
  299. // Arguments:
  300. //
  301. // Name - Command name to identify the source of the
  302. // command to the kd user.
  303. //
  304. // Command - Command string.
  305. //
  306. // Return Value:
  307. //
  308. // None.
  309. //
  310. //--
  311. LEAF_ENTRY(DebugCommandString)
  312. //
  313. // Arguments are passed to the KiDebugRoutine via the context record
  314. // in scratch registers t0 and t1.
  315. //
  316. flushrs
  317. add t0 = zero, a0
  318. add t1 = zero, a1
  319. ;;
  320. nop.m 0
  321. break.i BREAKPOINT_COMMAND_STRING
  322. br.ret.sptk.clr brp
  323. LEAF_EXIT(DebugCommandString)
  324.