dbgrcomm.h 55 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729
  1. /*++
  2. Copyright (c) 2012 Minoca Corp. All Rights Reserved
  3. Module Name:
  4. dbgrcomm.h
  5. Abstract:
  6. This header contains definitions for the debugger protocol communication
  7. helper routines.
  8. Author:
  9. Evan Green 3-Jul-2012
  10. --*/
  11. //
  12. // ---------------------------------------------------------------- Definitions
  13. //
  14. #define ARM_INSTRUCTION_LENGTH 4
  15. #define ARM_FUNCTION_PROLOGUE 0xE1A0C00D
  16. #define DEBUGGER_MAX_COMMAND_ARGUMENTS 32
  17. //
  18. // Define the maximum number of call stack elements that can be printed.
  19. //
  20. #define MAX_CALL_STACK 4096
  21. //
  22. // Define debugger flags.
  23. //
  24. //
  25. // This flag is set if the debugger is in the process of exiting the
  26. // application.
  27. //
  28. #define DEBUGGER_FLAG_EXITING 0x00000001
  29. //
  30. // This flag is set if the debugger should echo commands sent to standard in.
  31. //
  32. #define DEBUGGER_FLAG_ECHO_COMMANDS 0x00000002
  33. //
  34. // This flag is set to enable stepping by source line numbers, or cleared to
  35. // step by instruction.
  36. //
  37. #define DEBUGGER_FLAG_SOURCE_LINE_STEPPING 0x00000004
  38. //
  39. // This flag is set if the debugger should print source file and line numbers
  40. // along with each address symbol.
  41. //
  42. #define DEBUGGER_FLAG_PRINT_LINE_NUMBERS 0x00000008
  43. //
  44. // This flag is set if the user would like an initial break-in upon
  45. // connection.
  46. //
  47. #define DEBUGGER_FLAG_INITIAL_BREAK 0x00000010
  48. //
  49. // This flag is set if the user wants to print all attempted source file loads
  50. // (useful when trying to figure out why source display isn't working).
  51. //
  52. #define DEBUGGER_FLAG_PRINT_SOURCE_LOADS 0x00000020
  53. //
  54. // Define debugger target flags.
  55. //
  56. //
  57. // This flag is set if the target is running.
  58. //
  59. #define DEBUGGER_TARGET_RUNNING 0x00000001
  60. //
  61. // x86 Flags.
  62. //
  63. #define IA32_EFLAG_CF 0x00000001
  64. #define IA32_EFLAG_PF 0x00000004
  65. #define IA32_EFLAG_AF 0x00000010
  66. #define IA32_EFLAG_ZF 0x00000040
  67. #define IA32_EFLAG_SF 0x00000080
  68. #define IA32_EFLAG_TF 0x00000100
  69. #define IA32_EFLAG_IF 0x00000200
  70. #define IA32_EFLAG_DF 0x00000400
  71. #define IA32_EFLAG_OF 0x00000800
  72. #define IA32_EFLAG_IOPL_MASK 0x00003000
  73. #define IA32_EFLAG_IOPL_SHIFT 12
  74. #define IA32_EFLAG_NT 0x00004000
  75. #define IA32_EFLAG_RF 0x00010000
  76. #define IA32_EFLAG_VM 0x00020000
  77. #define IA32_EFLAG_AC 0x00040000
  78. #define IA32_EFLAG_VIF 0x00080000
  79. #define IA32_EFLAG_VIP 0x00100000
  80. #define IA32_EFLAG_ID 0x00200000
  81. #define IA32_EFLAG_ALWAYS_0 0xFFC08028
  82. #define IA32_EFLAG_ALWAYS_1 0x00000002
  83. //
  84. // ARM Processor modes.
  85. //
  86. #define ARM_MODE_USER 0x00000010
  87. #define ARM_MODE_FIQ 0x00000011
  88. #define ARM_MODE_IRQ 0x00000012
  89. #define ARM_MODE_SVC 0x00000013
  90. #define ARM_MODE_ABORT 0x00000017
  91. #define ARM_MODE_UNDEF 0x0000001B
  92. #define ARM_MODE_SYSTEM 0x0000001F
  93. #define ARM_MODE_MASK 0x0000001F
  94. //
  95. // ARM Program Status Register flags.
  96. //
  97. #define PSR_FLAG_NEGATIVE 0x80000000
  98. #define PSR_FLAG_ZERO 0x40000000
  99. #define PSR_FLAG_CARRY 0x20000000
  100. #define PSR_FLAG_OVERFLOW 0x10000000
  101. #define PSR_FLAG_SATURATION 0x08000000
  102. #define PSR_FLAG_JAZELLE 0x01000000
  103. #define PSR_FLAG_THUMB 0x00000020
  104. #define PSR_FLAG_IRQ 0x00000080
  105. #define PSR_FLAG_FIQ 0x00000040
  106. //
  107. // ARM Instruction information.
  108. //
  109. #define ARM_BREAK_INSTRUCTION 0xE7F000F3
  110. #define ARM_BREAK_INSTRUCTION_LENGTH ARM_INSTRUCTION_LENGTH
  111. #define THUMB_BREAK_INSTRUCTION 0xDE20
  112. #define THUMB_BREAK_INSTRUCTION_LENGTH 2
  113. #define ARM_THUMB_BIT 0x00000001
  114. #define X86_BREAK_INSTRUCTION 0xCC
  115. #define X86_BREAK_INSTRUCTION_LENGTH 1
  116. //
  117. // ------------------------------------------------------ Data Type Definitions
  118. //
  119. typedef enum _DEBUGGER_BREAK_POINT_TYPE {
  120. BreakpointTypeInvalid,
  121. BreakpointTypeExecution,
  122. BreakpointTypeRead,
  123. BreakpointTypeWrite,
  124. BreakpointTypeReadWrite
  125. } DEBUGGER_BREAK_POINT_TYPE, *PDEBUGGER_BREAK_POINT_TYPE;
  126. /*++
  127. Structure Description:
  128. This structure defines a breakpoint.
  129. Members:
  130. ListEntry - Stores pointers to the next and previous breakpoints in the
  131. global list of breakpoints.
  132. Index - Stores the index of the breakpoint.
  133. Type - Stores the type of breakpoint, whether it be software or some sort of
  134. hardware breakpoint.
  135. Address - Stores the virtual address of the breakpoint.
  136. AccessSize - Stores the access size of the breakpoint if it is a break on
  137. access type of breakpoint.
  138. OriginalValue - Stores the original contents of the instruction stream
  139. before the breakpoint was inserted. This only applies to software
  140. execution breakpoints.
  141. Enabled - Stores a flag indicating whether or not this breakpoint is
  142. currently active in the system.
  143. --*/
  144. typedef struct _DEBUGGER_BREAK_POINT {
  145. LIST_ENTRY ListEntry;
  146. LONG Index;
  147. DEBUGGER_BREAK_POINT_TYPE Type;
  148. ULONGLONG Address;
  149. UCHAR AccessSize;
  150. ULONG OriginalValue;
  151. BOOL Enabled;
  152. } DEBUGGER_BREAK_POINT, *PDEBUGGER_BREAK_POINT;
  153. /*++
  154. Structure Description:
  155. This structure defines parameters for dumping memory.
  156. Members:
  157. Virtual - Stores a boolean indicating if the address is virtual (TRUE) or
  158. physical (FALSE).
  159. PrintCharacters - Stores a boolean indicating if characters should be
  160. printed as well.
  161. NextAddress - Stores the next address to dump.
  162. Columns - Stores the desired number of columns.
  163. TotalValues - Stores the desired total number of values to dump.
  164. --*/
  165. typedef struct _DEBUGGER_DUMP_MEMORY_PARAMETERS {
  166. BOOL Virtual;
  167. BOOL PrintCharacters;
  168. ULONGLONG NextAddress;
  169. ULONG Columns;
  170. ULONG TotalValues;
  171. } DEBUGGER_DUMP_MEMORY_PARAMETERS, *PDEBUGGER_DUMP_MEMORY_PARAMETERS;
  172. /*++
  173. Structure Description:
  174. This structure defines a mutable array of pointer sized elements.
  175. Members:
  176. Elements - Stores the array of pointers.
  177. Size - Stores the number of valid elements in the array.
  178. Capacity - Storse the maximum number of elements that can be put in the
  179. array before the array itself needs to be reallocated.
  180. --*/
  181. typedef struct _POINTER_ARRAY {
  182. PVOID *Elements;
  183. ULONGLONG Size;
  184. ULONGLONG Capacity;
  185. } POINTER_ARRAY, *PPOINTER_ARRAY;
  186. /*++
  187. Structure Description:
  188. This structure defines thread profiling parameters.
  189. Members:
  190. StatisticsListHead - Stores the head of the list of thread statistics data.
  191. StatisticsListLock - Stores a handle to the lock serializing access to the
  192. thread statistics list.
  193. StatisticsLock - Stores a handle to the lock serializing access to the
  194. pointer arrays and other thread profiling data.
  195. ContextSwaps - Stores the array of context swap data.
  196. Processes - Stores the array of process data.
  197. Threads - Stores the array of thread data.
  198. ProcessorCount - Stores the number of processors in the system.
  199. ReferenceTime - Stores the reference time for thread profiling data.
  200. ProcessNameWidth - Stores the width in characters of the process name field.
  201. ThreadNameWidth - Stores the width in characters of the thread name field.
  202. --*/
  203. typedef struct _DEBUGGER_THREAD_PROFILING_DATA {
  204. LIST_ENTRY StatisticsListHead;
  205. HANDLE StatisticsListLock;
  206. HANDLE StatisticsLock;
  207. PPOINTER_ARRAY ContextSwaps;
  208. PPOINTER_ARRAY Processes;
  209. PPOINTER_ARRAY Threads;
  210. ULONG ProcessorCount;
  211. PROFILER_THREAD_TIME_COUNTER ReferenceTime;
  212. ULONG ProcessNameWidth;
  213. ULONG ThreadNameWidth;
  214. } DEBUGGER_THREAD_PROFILING_DATA, *PDEBUGGER_THREAD_PROFILING_DATA;
  215. /*++
  216. Structure Description:
  217. This structure stores profiling information.
  218. Members:
  219. StackListHead - Stores the head of the list of stack sampling data.
  220. StackListLock - Stores a handle to the lock serializing access to the stack
  221. list.
  222. MemoryListHead - Stores the head of the list of memory profiling data.
  223. MemoryListLock - Stores a handle to the lock serializing access to the
  224. memory list.
  225. MemoryCollectionActive - Stores a boolean indicating if memory data is
  226. being collected.
  227. CommandLineStackRoot - Stores the stack profiling root node when running
  228. from the command line.
  229. CommandLinePoolListHead - Stores a pointer to the most recent pool when
  230. running command line commands.
  231. CommandLineBaseListHead - Stores a pointer to the base line memory list
  232. list when running command line commands.
  233. --*/
  234. typedef struct _DEBUGGER_PROFILING_DATA {
  235. LIST_ENTRY StackListHead;
  236. HANDLE StackListLock;
  237. LIST_ENTRY MemoryListHead;
  238. HANDLE MemoryListLock;
  239. BOOL MemoryCollectionActive;
  240. PSTACK_DATA_ENTRY CommandLineStackRoot;
  241. PLIST_ENTRY CommandLinePoolListHead;
  242. PLIST_ENTRY CommandLineBaseListHead;
  243. } DEBUGGER_PROFILING_DATA, *PDEBUGGER_PROFILING_DATA;
  244. /*++
  245. Structure Description:
  246. This structure stores information pertaining to the maintenance of standard
  247. output.
  248. Members:
  249. Lock - Stores the handle to the lock synchronizing access to the console
  250. buffer.
  251. ConsoleBuffer - Stores a pointer to the console buffer.
  252. ConsoleBufferSize - Stores the number of valid bytes in the console
  253. buffer, including the null terminator if there is one.
  254. ConsoleBufferCapacity - Stores the allocation size of the console buffer.
  255. Prompt - Stores the current prompt.
  256. --*/
  257. typedef struct _DEBUGGER_STANDARD_OUT {
  258. HANDLE Lock;
  259. PCHAR ConsoleBuffer;
  260. ULONGLONG ConsoleBufferSize;
  261. ULONGLONG ConsoleBufferCapacity;
  262. PSTR Prompt;
  263. } DEBUGGER_STANDARD_OUT, *PDEBUGGER_STANDARD_OUT;
  264. /*++
  265. Structure Description:
  266. This structure stores information pertaining to the maintenance of standard
  267. input.
  268. Members:
  269. Lock - Stores a lock serializing access to the remote command list.
  270. RemoteCommandList - Stores the head of the list of remote commands waiting
  271. to be executed.
  272. --*/
  273. typedef struct _DEBUGGER_STANDARD_IN {
  274. HANDLE Lock;
  275. LIST_ENTRY RemoteCommandList;
  276. } DEBUGGER_STANDARD_IN, *PDEBUGGER_STANDARD_IN;
  277. /*++
  278. Structure Description:
  279. This structure stores information pertaining to managing a remote debug
  280. server.
  281. Members:
  282. Socket - Stores the socket listening to incoming connections.
  283. Host - Stores the host name or IP the server is listening on.
  284. Port - Stores the port the server is listening on.
  285. ShutDown - Stores a value indicating that the server should be shut down.
  286. ClientList - Stores the list of connected clients.
  287. --*/
  288. typedef struct _DEBUGGER_SERVER_CONTEXT {
  289. int Socket;
  290. char *Host;
  291. int Port;
  292. volatile int ShutDown;
  293. LIST_ENTRY ClientList;
  294. } DEBUGGER_SERVER_CONTEXT, *PDEBUGGER_SERVER_CONTEXT;
  295. /*++
  296. Structure Description:
  297. This structure stores information about the remote connection of the client
  298. (this application) to a remote server.
  299. Members:
  300. Socket - Stores the socket connected to the server.
  301. ShutDown - Stores a value indicating that the client network thread is
  302. finished.
  303. --*/
  304. typedef struct _DEBUGGER_CLIENT_CONTEXT {
  305. volatile int ShutDown;
  306. int Socket;
  307. } DEBUGGER_CLIENT_CONTEXT, *PDEBUGGER_CLIENT_CONTEXT;
  308. /*++
  309. Structure Description:
  310. This structure stores information about the current source line.
  311. Members:
  312. Path - Stores the full path to the source file, as represented in the
  313. debug symbols. This needs to be freed.
  314. ActualPath - Stores the full path to the source file where it was actually
  315. found. This needs to be freed.
  316. Contents - Stores the contents of the source file. This needs to be freed.
  317. Size - Stores the size of the file in bytes.
  318. LineNumber - Stores the currently highlighted line number, or 0 if no line
  319. is highlighted.
  320. --*/
  321. typedef struct _DEBUGGER_SOURCE_FILE {
  322. PSTR Path;
  323. PSTR ActualPath;
  324. PVOID Contents;
  325. ULONGLONG Size;
  326. ULONGLONG LineNumber;
  327. } DEBUGGER_SOURCE_FILE, *PDEBUGGER_SOURCE_FILE;
  328. /*++
  329. Structure Description:
  330. This structure stores information about the current source line.
  331. Members:
  332. ListEntry - Stores pointers to the next and previous source paths.
  333. Prefix - Stores a pointer to the prefix to pull off of the potential
  334. source path. If the source in question does not match, it will be
  335. skipped. An empty prefix matches everything.
  336. PrefixLength - Stores the length of the prefix in characters, not including
  337. the null terminator.
  338. Path - Stores a pointer to the path to search for sources in.
  339. PathLength - Stores the length of the path string in characters, not
  340. including the null terminator.
  341. --*/
  342. typedef struct _DEBUGGER_SOURCE_PATH {
  343. LIST_ENTRY ListEntry;
  344. PSTR Prefix;
  345. UINTN PrefixLength;
  346. PSTR Path;
  347. UINTN PathLength;
  348. } DEBUGGER_SOURCE_PATH, *PDEBUGGER_SOURCE_PATH;
  349. /*++
  350. Structure Description:
  351. This structure defines an instance of the debugger application.
  352. Members:
  353. Flags - Stores a bitfield of global flags, see DEBUGGER_FLAG_* for
  354. definitions.
  355. TargetFlags - Stores a bitfield of flags regarding the target connection.
  356. See DEBUGGER_TARGET_* definitions.
  357. SymbolPath - Stores a pointer to an array of strings containing the symbol
  358. path to search when trying to load symbols.
  359. SymbolPathCount - Stores the number of elements in the symbol path array.
  360. RangeStepValid - Stores a boolean indicating whether the range step
  361. parameters are active.
  362. RangeStepParameters - Stores the parameters for the current range step.
  363. OneTimeBreakValid - Stores a boolean indicating if the one-time breakpoint
  364. (used for "g <addr>") is valid.
  365. OneTimeBreakAddress - Stores the target memory address of the one-time
  366. breakpoint.
  367. OneTimeBreakOriginalValue - Stores the original value at the one-time
  368. break address.
  369. LastMemoryDump - Stores the parameters used in the most recent memory
  370. dump.
  371. BreakpointList - Stores the head of the list of breakpoints.
  372. BreakpointToRestore - Stores a pointer to the breakpoint to reset after
  373. stepping off of it.
  374. PreviousProcess - Stores the process ID of the last debugger event, used to
  375. determine if the symbol list should be reloaded.
  376. BreakInstructionLength - Stores the length of the instruction of the most
  377. recent break.
  378. DisassemblyAddress - Stores the address of the next disassembly command if
  379. no address is provided.
  380. LoadedExtensions - Stores the list head of loaded debugger extensions.
  381. SourceFile - Stores information about the currently displayed source file.
  382. SourcePathList - Stores the head of the list of DEBUGGER_SOURCE_PATHs.
  383. ModuleList - Stores the loaded module list.
  384. RemoteModuleListSignature - Stores the most recent loaded module list
  385. signature.
  386. MachineType - Stores the target machine type.
  387. ThreadProfiling - Stores the thread profiling data.
  388. ProfilingData - Stores generic profiling data.
  389. StandardOut - Stores the standard out information.
  390. StandardIn - Stores the standard in information.
  391. CommandBuffer - Stores the buffer that holds the currently running debugger
  392. command.
  393. CommandBufferSize - Stores the total size of the command buffer in bytes.
  394. CommandHistory - Stores the debugger command history array.
  395. CommandHistorySize - Stores the size of the command history array. Not all
  396. of these elements are necessarily valid.
  397. CommandHistoryNextIndex - Stores the index where the next history entry
  398. will be deposited.
  399. Server - Stores context when this debugger is acting as a remote server.
  400. Client - Stores context when this debugger is acting as a remote client.
  401. CurrentEvent - Stores the current debug event.
  402. ConnectionType - Stores the current debug connection type.
  403. FrameRegisters - Stores the registers as unwound to the currently displayed
  404. stack frame.
  405. CurrentFrame - Stores the current stack frame index.
  406. --*/
  407. struct _DEBUGGER_CONTEXT {
  408. ULONG Flags;
  409. ULONG TargetFlags;
  410. PSTR *SymbolPath;
  411. ULONG SymbolPathCount;
  412. BOOL RangeStepValid;
  413. RANGE_STEP RangeStepParameters;
  414. BOOL OneTimeBreakValid;
  415. ULONGLONG OneTimeBreakAddress;
  416. ULONG OneTimeBreakOriginalValue;
  417. DEBUGGER_DUMP_MEMORY_PARAMETERS LastMemoryDump;
  418. LIST_ENTRY BreakpointList;
  419. PDEBUGGER_BREAK_POINT BreakpointToRestore;
  420. ULONG PreviousProcess;
  421. ULONG BreakInstructionLength;
  422. ULONGLONG DisassemblyAddress;
  423. LIST_ENTRY LoadedExtensions;
  424. DEBUGGER_SOURCE_FILE SourceFile;
  425. LIST_ENTRY SourcePathList;
  426. ULONG HighlightedLineNumber;
  427. DEBUGGER_MODULE_LIST ModuleList;
  428. ULONGLONG RemoteModuleListSignature;
  429. ULONG MachineType;
  430. DEBUGGER_THREAD_PROFILING_DATA ThreadProfiling;
  431. DEBUGGER_PROFILING_DATA ProfilingData;
  432. DEBUGGER_STANDARD_OUT StandardOut;
  433. DEBUGGER_STANDARD_IN StandardIn;
  434. PSTR CommandBuffer;
  435. ULONG CommandBufferSize;
  436. PSTR *CommandHistory;
  437. ULONG CommandHistorySize;
  438. ULONG CommandHistoryNextIndex;
  439. DEBUGGER_SERVER_CONTEXT Server;
  440. DEBUGGER_CLIENT_CONTEXT Client;
  441. DEBUGGER_EVENT CurrentEvent;
  442. DEBUG_CONNECTION_TYPE ConnectionType;
  443. REGISTERS_UNION FrameRegisters;
  444. ULONG CurrentFrame;
  445. };
  446. typedef
  447. INT
  448. (*PDEBUGGER_COMMAND_ROUTINE) (
  449. PDEBUGGER_CONTEXT Context,
  450. PSTR *Arguments,
  451. ULONG ArgumentCount
  452. );
  453. /*++
  454. Routine Description:
  455. This routine implements a registered debugger command.
  456. Arguments:
  457. Context - Supplies a pointer to the application context.
  458. Arguments - Supplies an array of strings containing the arguments. The
  459. first argument is the command itself.
  460. ArgumentCount - Supplies the count of arguments. This is always at least
  461. one.
  462. Return Value:
  463. 0 on success.
  464. Returns an error code on failure.
  465. --*/
  466. /*++
  467. Structure Description:
  468. This structure defines a debugger command registration entry.
  469. Members:
  470. Command - Stores a pointer to a string containing the name of the command
  471. to register.
  472. CommandRoutine - Stores a pointer to the routine to execute when this
  473. command is invoked.
  474. HelpText - Stores a pointer to a one-liner string describing what the
  475. command does.
  476. --*/
  477. typedef struct _DEBUGGER_COMMAND_ENTRY {
  478. PSTR Command;
  479. PDEBUGGER_COMMAND_ROUTINE CommandRoutine;
  480. PSTR HelpText;
  481. } DEBUGGER_COMMAND_ENTRY, *PDEBUGGER_COMMAND_ENTRY;
  482. //
  483. // -------------------------------------------------------------------- Globals
  484. //
  485. //
  486. // ------------------------------------------------------------------ Functions
  487. //
  488. BOOL
  489. DbgrGetCommand (
  490. PDEBUGGER_CONTEXT Context
  491. );
  492. /*++
  493. Routine Description:
  494. This routine retrieves a command from the user or a remote client.
  495. Arguments:
  496. Context - Supplies a pointer to the application context.
  497. Return Value:
  498. Returns TRUE on success, FALSE on failure.
  499. --*/
  500. VOID
  501. DbgrpSetPromptText (
  502. PDEBUGGER_CONTEXT Context,
  503. PSTR Prompt
  504. );
  505. /*++
  506. Routine Description:
  507. This routine sets the command prompt to the given string.
  508. Arguments:
  509. Context - Supplies a pointer to the application context.
  510. Prompt - Supplies a pointer to the null terminated string containing the
  511. prompt to set.
  512. Return Value:
  513. None.
  514. --*/
  515. BOOL
  516. DbgrpSplitCommandArguments (
  517. PSTR Input,
  518. PSTR Arguments[DEBUGGER_MAX_COMMAND_ARGUMENTS],
  519. PULONG ArgumentCount
  520. );
  521. /*++
  522. Routine Description:
  523. This routine splits a command line into its arguments.
  524. Arguments:
  525. Input - Supplies a pointer to the input command line buffer.
  526. Arguments - Supplies a pointer to an array of strings that will receive any
  527. additional arguments.
  528. ArgumentCount - Supplies a pointer where the count of arguments will be
  529. returned.
  530. Return Value:
  531. Returns TRUE on success, FALSE on failure.
  532. --*/
  533. //
  534. // Profiling functions
  535. //
  536. INT
  537. DbgrProfilerInitialize (
  538. PDEBUGGER_CONTEXT Context
  539. );
  540. /*++
  541. Routine Description:
  542. This routine initializes the debugger for profiler data consumption.
  543. Arguments:
  544. Context - Supplies a pointer to the application context.
  545. Return Value:
  546. 0 on success.
  547. Returns an error code on failure.
  548. --*/
  549. VOID
  550. DbgrProfilerDestroy (
  551. PDEBUGGER_CONTEXT Context
  552. );
  553. /*++
  554. Routine Description:
  555. This routine destroys any structures used to consume profiler data.
  556. Arguments:
  557. Context - Supplies a pointer to the application context.
  558. Return Value:
  559. None.
  560. --*/
  561. INT
  562. DbgrDispatchProfilerCommand (
  563. PDEBUGGER_CONTEXT Context,
  564. PSTR *Arguments,
  565. ULONG ArgumentCount
  566. );
  567. /*++
  568. Routine Description:
  569. This routine handles a profiler command.
  570. Arguments:
  571. Context - Supplies a pointer to the application context.
  572. Arguments - Supplies an array of strings containing the arguments.
  573. ArgumentCount - Supplies the number of arguments in the Arguments array.
  574. Return Value:
  575. 0 on success.
  576. Returns an error code on failure.
  577. --*/
  578. VOID
  579. DbgrProcessProfilerNotification (
  580. PDEBUGGER_CONTEXT Context
  581. );
  582. /*++
  583. Routine Description:
  584. This routine processes a profiler notification that the debuggee sends to
  585. the debugger. The routine should collect the profiler data and return as
  586. quickly as possible.
  587. Arguments:
  588. Context - Supplies a pointer to the application context.
  589. Return Value:
  590. None.
  591. --*/
  592. //
  593. // General debugger functions
  594. //
  595. PDEBUGGER_COMMAND_ENTRY
  596. DbgrLookupCommand (
  597. PSTR Command
  598. );
  599. /*++
  600. Routine Description:
  601. This routine attempts to find a debugger command entry.
  602. Arguments:
  603. Command - Supplies a pointer to the null-terminated string containing the
  604. name of the command that was invoked. This command is split on the
  605. period character, and the first segment is looked up.
  606. Return Value:
  607. Returns a pointer to the command entry on success.
  608. NULL if there no such command, or on failure.
  609. --*/
  610. INT
  611. DbgrInitialize (
  612. PDEBUGGER_CONTEXT Context,
  613. DEBUG_CONNECTION_TYPE ConnectionType
  614. );
  615. /*++
  616. Routine Description:
  617. This routine initializes data structures for common debugger functionality.
  618. Arguments:
  619. Context - Supplies a pointer to the application context.
  620. ConnectionType - Supplies the type of debug connection to set the debugger
  621. up in.
  622. Return Value:
  623. 0 on success.
  624. Returns an error number on failure.
  625. --*/
  626. VOID
  627. DbgrDestroy (
  628. PDEBUGGER_CONTEXT Context,
  629. DEBUG_CONNECTION_TYPE ConnectionType
  630. );
  631. /*++
  632. Routine Description:
  633. This routine destroys any data structures used for common debugger
  634. functionality.
  635. Arguments:
  636. Context - Supplies a pointer to the application context.
  637. ConnectionType - Supplies the type of debug connection the debugger was set
  638. up in.
  639. Return Value:
  640. None.
  641. --*/
  642. INT
  643. DbgrConnect (
  644. PDEBUGGER_CONTEXT Context
  645. );
  646. /*++
  647. Routine Description:
  648. This routine establishes a link with the target debuggee. It is assumed that
  649. the underlying communication layer has already been established (COM ports
  650. have been opened and initialized, etc).
  651. Arguments:
  652. Context - Supplies a pointer to the application context.
  653. Return Value:
  654. 0 on success.
  655. Returns an error code on failure.
  656. --*/
  657. INT
  658. DbgrQuit (
  659. PDEBUGGER_CONTEXT Context,
  660. PSTR *Arguments,
  661. ULONG ArgumentCount
  662. );
  663. /*++
  664. Routine Description:
  665. This routine exits the local debugger.
  666. Arguments:
  667. Context - Supplies a pointer to the application context.
  668. Arguments - Supplies an array of strings containing the arguments. The
  669. first argument is the command itself.
  670. ArgumentCount - Supplies the count of arguments. This is always at least
  671. one.
  672. Return Value:
  673. 0 on success.
  674. Returns an error code on failure.
  675. --*/
  676. INT
  677. DbgrGo (
  678. PDEBUGGER_CONTEXT Context,
  679. PSTR *Arguments,
  680. ULONG ArgumentCount
  681. );
  682. /*++
  683. Routine Description:
  684. This routine interprets the "go" command from the user.
  685. Arguments:
  686. Context - Supplies a pointer to the application context.
  687. Arguments - Supplies an array of strings containing the arguments. The
  688. first argument is the command itself.
  689. ArgumentCount - Supplies the count of arguments. This is always at least
  690. one.
  691. Return Value:
  692. 0 on success.
  693. Returns an error code on failure.
  694. --*/
  695. INT
  696. DbgrSingleStep (
  697. PDEBUGGER_CONTEXT Context
  698. );
  699. /*++
  700. Routine Description:
  701. This routine steps the target by a single instruction.
  702. Arguments:
  703. Context - Supplies a pointer to the application context.
  704. Return Value:
  705. 0 on success.
  706. Returns an error code on failure.
  707. --*/
  708. INT
  709. DbgrGetSetRegisters (
  710. PDEBUGGER_CONTEXT Context,
  711. PSTR *Arguments,
  712. ULONG ArgumentCount
  713. );
  714. /*++
  715. Routine Description:
  716. This routine prints or modifies the target machine's registers.
  717. Arguments:
  718. Context - Supplies a pointer to the application context.
  719. Arguments - Supplies an array of strings containing the arguments. The
  720. first argument is the command itself.
  721. ArgumentCount - Supplies the count of arguments. This is always at least
  722. one.
  723. Return Value:
  724. 0 on success.
  725. Returns an error code on failure.
  726. --*/
  727. INT
  728. DbgrGetSetSpecialRegisters (
  729. PDEBUGGER_CONTEXT Context,
  730. PSTR *Arguments,
  731. ULONG ArgumentCount
  732. );
  733. /*++
  734. Routine Description:
  735. This routine prints or modifies the target machine's special registers.
  736. Arguments:
  737. Context - Supplies a pointer to the application context.
  738. Arguments - Supplies an array of strings containing the arguments. The
  739. first argument is the command itself.
  740. ArgumentCount - Supplies the count of arguments. This is always at least
  741. one.
  742. Return Value:
  743. 0 on success.
  744. Returns an error code on failure.
  745. --*/
  746. INT
  747. DbgrPrintCallStack (
  748. PDEBUGGER_CONTEXT Context,
  749. PSTR *Arguments,
  750. ULONG ArgumentCount
  751. );
  752. /*++
  753. Routine Description:
  754. This routine prints the current call stack.
  755. Arguments:
  756. Context - Supplies a pointer to the application context.
  757. Arguments - Supplies an array of strings containing the arguments. The
  758. first argument is the command itself.
  759. ArgumentCount - Supplies the count of arguments. This is always at least
  760. one.
  761. Return Value:
  762. 0 on success.
  763. Returns an error code on failure.
  764. --*/
  765. INT
  766. DbgrSetFrame (
  767. PDEBUGGER_CONTEXT Context,
  768. PSTR *Arguments,
  769. ULONG ArgumentCount
  770. );
  771. /*++
  772. Routine Description:
  773. This routine changes the current stack frame, so that local variables may
  774. come from a different function in the call stack.
  775. Arguments:
  776. Context - Supplies a pointer to the application context.
  777. Arguments - Supplies an array of strings containing the arguments. The
  778. first argument is the command itself.
  779. ArgumentCount - Supplies the count of arguments. This is always at least
  780. one.
  781. Return Value:
  782. 0 on success.
  783. Returns an error code on failure.
  784. --*/
  785. INT
  786. DbgrDisassemble (
  787. PDEBUGGER_CONTEXT Context,
  788. PSTR *Arguments,
  789. ULONG ArgumentCount
  790. );
  791. /*++
  792. Routine Description:
  793. This routine disassembles instructions from the target.
  794. Arguments:
  795. Context - Supplies a pointer to the application context.
  796. Arguments - Supplies an array of strings containing the arguments. The
  797. first argument is the command itself.
  798. ArgumentCount - Supplies the count of arguments. This is always at least
  799. one.
  800. Return Value:
  801. 0 on success.
  802. Returns an error code on failure.
  803. --*/
  804. INT
  805. DbgrWaitForEvent (
  806. PDEBUGGER_CONTEXT Context
  807. );
  808. /*++
  809. Routine Description:
  810. This routine gets an event from the target, such as a break event or other
  811. exception.
  812. Arguments:
  813. Context - Supplies a pointer to the debugger context.
  814. Return Value:
  815. 0 on success,
  816. Returns an error code on failure.
  817. --*/
  818. INT
  819. DbgrSearchSymbols (
  820. PDEBUGGER_CONTEXT Context,
  821. PSTR *Arguments,
  822. ULONG ArgumentCount
  823. );
  824. /*++
  825. Routine Description:
  826. This routine searches for symbols. Wildcards are accepted. If the search
  827. string is preceded by "modulename!" then only that module will be searched.
  828. Arguments:
  829. Context - Supplies a pointer to the application context.
  830. Arguments - Supplies an array of strings containing the arguments. The
  831. first argument is the command itself.
  832. ArgumentCount - Supplies the count of arguments. This is always at least
  833. one.
  834. Return Value:
  835. 0 on success.
  836. Returns an error code on failure.
  837. --*/
  838. INT
  839. DbgrDumpTypeCommand (
  840. PDEBUGGER_CONTEXT Context,
  841. PSTR *Arguments,
  842. ULONG ArgumentCount
  843. );
  844. /*++
  845. Routine Description:
  846. This routine prints information about a type description or value. If only
  847. a type is specified, the type format will be printed. If an address is
  848. passed as a second parameter, then the values will be dumped. If a global
  849. or local variable is passed as the first parameter, the values will also be
  850. dumped.
  851. Arguments:
  852. Context - Supplies a pointer to the application context.
  853. Arguments - Supplies an array of strings containing the arguments. The
  854. first argument is the command itself.
  855. ArgumentCount - Supplies the count of arguments. This is always at least
  856. one.
  857. Return Value:
  858. 0 on success.
  859. Returns an error code on failure.
  860. --*/
  861. INT
  862. DbgrDumpMemory (
  863. PDEBUGGER_CONTEXT Context,
  864. PSTR *Arguments,
  865. ULONG ArgumentCount
  866. );
  867. /*++
  868. Routine Description:
  869. This routine prints the contents of debuggee memory to the screen.
  870. Arguments:
  871. Context - Supplies a pointer to the application context.
  872. Arguments - Supplies an array of strings containing the arguments. The
  873. first argument is the command itself.
  874. ArgumentCount - Supplies the count of arguments. This is always at least
  875. one.
  876. Return Value:
  877. 0 on success.
  878. Returns an error code on failure.
  879. --*/
  880. INT
  881. DbgrDumpList (
  882. PDEBUGGER_CONTEXT Context,
  883. PSTR *Arguments,
  884. ULONG ArgumentCount
  885. );
  886. /*++
  887. Routine Description:
  888. This routine interates over a linked list and prints out the structure
  889. information for each entry. It also performs basic validation on the list,
  890. checking for bad previous pointers.
  891. Arguments:
  892. Context - Supplies a pointer to the application context.
  893. Arguments - Supplies an array of strings containing the arguments. The
  894. first argument is the command itself.
  895. ArgumentCount - Supplies the count of arguments. This is always at least
  896. one.
  897. Return Value:
  898. 0 on success.
  899. Returns an error code on failure.
  900. --*/
  901. INT
  902. DbgrEditMemory (
  903. PDEBUGGER_CONTEXT Context,
  904. PSTR *Arguments,
  905. ULONG ArgumentCount
  906. );
  907. /*++
  908. Routine Description:
  909. This routine writes to the target memory space.
  910. Arguments:
  911. Context - Supplies a pointer to the application context.
  912. Arguments - Supplies an array of strings containing the arguments. The
  913. first argument is the command itself.
  914. ArgumentCount - Supplies the count of arguments. This is always at least
  915. one.
  916. Return Value:
  917. 0 on success.
  918. Returns an error code on failure.
  919. --*/
  920. INT
  921. DbgrEvaluate (
  922. PDEBUGGER_CONTEXT Context,
  923. PSTR *Arguments,
  924. ULONG ArgumentCount
  925. );
  926. /*++
  927. Routine Description:
  928. This routine evaluates a numerical expression and prints it out in both
  929. decimal and hexadecimal.
  930. Arguments:
  931. Context - Supplies a pointer to the application context.
  932. Arguments - Supplies an array of strings containing the arguments. The
  933. first argument is the command itself.
  934. ArgumentCount - Supplies the count of arguments. This is always at least
  935. one.
  936. Return Value:
  937. 0 on success.
  938. Returns an error code on failure.
  939. --*/
  940. INT
  941. DbgrShowSourceAtAddressCommand (
  942. PDEBUGGER_CONTEXT Context,
  943. PSTR *Arguments,
  944. ULONG ArgumentCount
  945. );
  946. /*++
  947. Routine Description:
  948. This routine shows the source file for the provided address and highlights
  949. the specific line associated with the address.
  950. Arguments:
  951. Context - Supplies a pointer to the application context.
  952. Arguments - Supplies an array of strings containing the arguments. The
  953. first argument is the command itself.
  954. ArgumentCount - Supplies the count of arguments. This is always at least
  955. one.
  956. Return Value:
  957. 0 on success.
  958. Returns an error code on failure.
  959. --*/
  960. INT
  961. DbgrPrintLocals (
  962. PDEBUGGER_CONTEXT Context,
  963. PSTR *Arguments,
  964. ULONG ArgumentCount
  965. );
  966. /*++
  967. Routine Description:
  968. This routine prints the values of the local variables inside the currently
  969. selected stack frame.
  970. Arguments:
  971. Context - Supplies a pointer to the application context.
  972. Arguments - Supplies an array of strings containing the arguments. The
  973. first argument is the command itself.
  974. ArgumentCount - Supplies the count of arguments. This is always at least
  975. one.
  976. Return Value:
  977. 0 on success.
  978. Returns an error code on failure.
  979. --*/
  980. VOID
  981. DbgrUnhighlightCurrentLine (
  982. PDEBUGGER_CONTEXT Context
  983. );
  984. /*++
  985. Routine Description:
  986. This routine restores the currently executing line to the normal background
  987. color in the source window.
  988. Arguments:
  989. Context - Supplies a pointer to the application context.
  990. Return Value:
  991. None.
  992. --*/
  993. INT
  994. DbgrListBreakPoints (
  995. PDEBUGGER_CONTEXT Context,
  996. PSTR *Arguments,
  997. ULONG ArgumentCount
  998. );
  999. /*++
  1000. Routine Description:
  1001. This routine lists all valid breakpoints in the target.
  1002. Arguments:
  1003. Context - Supplies a pointer to the application context.
  1004. Arguments - Supplies an array of strings containing the arguments. The
  1005. first argument is the command itself.
  1006. ArgumentCount - Supplies the count of arguments. This is always at least
  1007. one.
  1008. Return Value:
  1009. 0 on success.
  1010. Returns an error code on failure.
  1011. --*/
  1012. INT
  1013. DbgrEnableBreakPoint (
  1014. PDEBUGGER_CONTEXT Context,
  1015. PSTR *Arguments,
  1016. ULONG ArgumentCount
  1017. );
  1018. /*++
  1019. Routine Description:
  1020. This routine lists all valid breakpoints in the target.
  1021. Arguments:
  1022. Context - Supplies a pointer to the application context.
  1023. Arguments - Supplies an array of strings containing the arguments. The
  1024. first argument is the command itself.
  1025. ArgumentCount - Supplies the count of arguments. This is always at least
  1026. one.
  1027. Return Value:
  1028. 0 on success.
  1029. Returns an error code on failure.
  1030. --*/
  1031. INT
  1032. DbgrDeleteBreakPoint (
  1033. PDEBUGGER_CONTEXT Context,
  1034. PSTR *Arguments,
  1035. ULONG ArgumentCount
  1036. );
  1037. /*++
  1038. Routine Description:
  1039. This routine deletes a breakpoint from the target.
  1040. Arguments:
  1041. Context - Supplies a pointer to the application context.
  1042. Arguments - Supplies an array of strings containing the arguments. The
  1043. first argument is the command itself.
  1044. ArgumentCount - Supplies the count of arguments. This is always at least
  1045. one.
  1046. Return Value:
  1047. 0 on success.
  1048. Returns an error code on failure.
  1049. --*/
  1050. INT
  1051. DbgrCreateBreakPoint (
  1052. PDEBUGGER_CONTEXT Context,
  1053. PSTR *Arguments,
  1054. ULONG ArgumentCount
  1055. );
  1056. /*++
  1057. Routine Description:
  1058. This routine creates a new breakpoint in the debuggee.
  1059. Arguments:
  1060. Context - Supplies a pointer to the application context.
  1061. Arguments - Supplies an array of strings containing the arguments. The
  1062. first argument is the command itself.
  1063. ArgumentCount - Supplies the count of arguments. This is always at least
  1064. one.
  1065. Return Value:
  1066. 0 on success.
  1067. Returns an error code on failure.
  1068. --*/
  1069. INT
  1070. DbgrStep (
  1071. PDEBUGGER_CONTEXT Context,
  1072. PSTR *Arguments,
  1073. ULONG ArgumentCount
  1074. );
  1075. /*++
  1076. Routine Description:
  1077. This routine performs a source or assembly line step in the debugger.
  1078. Arguments:
  1079. Context - Supplies a pointer to the application context.
  1080. Arguments - Supplies an array of strings containing the arguments. The
  1081. first argument is the command itself.
  1082. ArgumentCount - Supplies the count of arguments. This is always at least
  1083. one.
  1084. Return Value:
  1085. 0 on success.
  1086. Returns an error code on failure.
  1087. --*/
  1088. INT
  1089. DbgrSetSourceStepping (
  1090. PDEBUGGER_CONTEXT Context,
  1091. PSTR *Arguments,
  1092. ULONG ArgumentCount
  1093. );
  1094. /*++
  1095. Routine Description:
  1096. This routine turns source line stepping on or off.
  1097. Arguments:
  1098. Context - Supplies a pointer to the application context.
  1099. Arguments - Supplies an array of strings containing the arguments. The
  1100. first argument is the command itself.
  1101. ArgumentCount - Supplies the count of arguments. This is always at least
  1102. one.
  1103. Return Value:
  1104. 0 on success.
  1105. Returns an error code on failure.
  1106. --*/
  1107. INT
  1108. DbgrSetSourceLinePrinting (
  1109. PDEBUGGER_CONTEXT Context,
  1110. PSTR *Arguments,
  1111. ULONG ArgumentCount
  1112. );
  1113. /*++
  1114. Routine Description:
  1115. This routine turns on or off the option to print the source file and line
  1116. next to every text address.
  1117. Arguments:
  1118. Context - Supplies a pointer to the application context.
  1119. Arguments - Supplies an array of strings containing the arguments. The
  1120. first argument is the command itself.
  1121. ArgumentCount - Supplies the count of arguments. This is always at least
  1122. one.
  1123. Return Value:
  1124. 0 on success.
  1125. Returns an error code on failure.
  1126. --*/
  1127. INT
  1128. DbgrReturnToCaller (
  1129. PDEBUGGER_CONTEXT Context,
  1130. PSTR *Arguments,
  1131. ULONG ArgumentCount
  1132. );
  1133. /*++
  1134. Routine Description:
  1135. This routine interprets the "go" command from the user.
  1136. Arguments:
  1137. Context - Supplies a pointer to the application context.
  1138. Arguments - Supplies an array of strings containing the arguments. The
  1139. first argument is the command itself.
  1140. ArgumentCount - Supplies the count of arguments. This is always at least
  1141. one.
  1142. Return Value:
  1143. 0 on success.
  1144. Returns an error code on failure.
  1145. --*/
  1146. INT
  1147. DbgrSetSymbolPathCommand (
  1148. PDEBUGGER_CONTEXT Context,
  1149. PSTR *Arguments,
  1150. ULONG ArgumentCount
  1151. );
  1152. /*++
  1153. Routine Description:
  1154. This routine sets or updates the symbol search path.
  1155. Arguments:
  1156. Context - Supplies a pointer to the application context.
  1157. Arguments - Supplies an array of strings containing the arguments. The
  1158. first argument is the command itself.
  1159. ArgumentCount - Supplies the count of arguments. This is always at least
  1160. one.
  1161. Return Value:
  1162. 0 on success.
  1163. Returns an error code on failure.
  1164. --*/
  1165. INT
  1166. DbgrSetSourcePathCommand (
  1167. PDEBUGGER_CONTEXT Context,
  1168. PSTR *Arguments,
  1169. ULONG ArgumentCount
  1170. );
  1171. /*++
  1172. Routine Description:
  1173. This routine sets or updates the source search path.
  1174. Arguments:
  1175. Context - Supplies a pointer to the application context.
  1176. Arguments - Supplies an array of strings containing the arguments. The
  1177. first argument is the command itself.
  1178. ArgumentCount - Supplies the count of arguments. This is always at least
  1179. one.
  1180. Return Value:
  1181. 0 on success.
  1182. Returns an error code on failure.
  1183. --*/
  1184. INT
  1185. DbgrReloadSymbols (
  1186. PDEBUGGER_CONTEXT Context,
  1187. PSTR *Arguments,
  1188. ULONG ArgumentCount
  1189. );
  1190. /*++
  1191. Routine Description:
  1192. This routine unloads and reloads all symbols from the search path.
  1193. Arguments:
  1194. Context - Supplies a pointer to the application context.
  1195. Arguments - Supplies an array of strings containing the arguments. The
  1196. first argument is the command itself.
  1197. ArgumentCount - Supplies the count of arguments. This is always at least
  1198. one.
  1199. Return Value:
  1200. 0 on success.
  1201. Returns an error code on failure.
  1202. --*/
  1203. INT
  1204. DbgrSetSymbolPath (
  1205. PDEBUGGER_CONTEXT Context,
  1206. PSTR Path,
  1207. BOOL Append
  1208. );
  1209. /*++
  1210. Routine Description:
  1211. This routine sets or updates the symbol search path.
  1212. Arguments:
  1213. Context - Supplies a pointer to the application context.
  1214. Path - Supplies a pointer to the new symbol path. This could contain
  1215. multiple symbol paths if separated by semicolons.
  1216. Append - Supplies a boolean indicating whether the new path should replace
  1217. or append the existing path.
  1218. Return Value:
  1219. 0 on success.
  1220. Returns an error code on failure.
  1221. --*/
  1222. INT
  1223. DbgrLoadExtension (
  1224. PDEBUGGER_CONTEXT Context,
  1225. PSTR *Arguments,
  1226. ULONG ArgumentCount
  1227. );
  1228. /*++
  1229. Routine Description:
  1230. This routine loads or unloads a debugger extension.
  1231. Arguments:
  1232. Context - Supplies a pointer to the application context.
  1233. Arguments - Supplies an array of strings containing the arguments. The
  1234. first argument is the command itself.
  1235. ArgumentCount - Supplies the count of arguments. This is always at least
  1236. one.
  1237. Return Value:
  1238. 0 on success.
  1239. Returns an error code on failure.
  1240. --*/
  1241. INT
  1242. DbgrSwitchProcessor (
  1243. PDEBUGGER_CONTEXT Context,
  1244. PSTR *Arguments,
  1245. ULONG ArgumentCount
  1246. );
  1247. /*++
  1248. Routine Description:
  1249. This routine switches the debugger to another processor in kernel mode or
  1250. thread in user mode.
  1251. Arguments:
  1252. Context - Supplies a pointer to the application context.
  1253. Arguments - Supplies an array of strings containing the arguments. The
  1254. first argument is the command itself.
  1255. ArgumentCount - Supplies the count of arguments. This is always at least
  1256. one.
  1257. Return Value:
  1258. 0 on success.
  1259. Returns an error code on failure.
  1260. --*/
  1261. INT
  1262. DbgrPrintProcessorBlock (
  1263. PDEBUGGER_CONTEXT Context,
  1264. PSTR *Arguments,
  1265. ULONG ArgumentCount
  1266. );
  1267. /*++
  1268. Routine Description:
  1269. This routine prints the contents of the current processor block.
  1270. Arguments:
  1271. Context - Supplies a pointer to the application context.
  1272. Arguments - Supplies an array of strings containing the arguments. The
  1273. first argument is the command itself.
  1274. ArgumentCount - Supplies the count of arguments. This is always at least
  1275. one.
  1276. Return Value:
  1277. 0 on success.
  1278. Returns an error code on failure.
  1279. --*/
  1280. INT
  1281. DbgrDumpPointerSymbols (
  1282. PDEBUGGER_CONTEXT Context,
  1283. PSTR *Arguments,
  1284. ULONG ArgumentCount
  1285. );
  1286. /*++
  1287. Routine Description:
  1288. This routine dumps memory at the provided address and attempts to match
  1289. symbols at the dumped memory addresses.
  1290. Arguments:
  1291. Context - Supplies a pointer to the application context.
  1292. Arguments - Supplies an array of strings containing the arguments. The
  1293. first argument is the command itself.
  1294. ArgumentCount - Supplies the count of arguments. This is always at least
  1295. one.
  1296. Return Value:
  1297. 0 on success.
  1298. Returns an error code on failure.
  1299. --*/
  1300. INT
  1301. DbgrProfileCommand (
  1302. PDEBUGGER_CONTEXT Context,
  1303. PSTR *Arguments,
  1304. ULONG ArgumentCount
  1305. );
  1306. /*++
  1307. Routine Description:
  1308. This routine handles the profile command. It essentially just forwards on
  1309. to the profile handler.
  1310. Arguments:
  1311. Context - Supplies a pointer to the application context.
  1312. Arguments - Supplies an array of strings containing the arguments. The
  1313. first argument is the command itself.
  1314. ArgumentCount - Supplies the count of arguments. This is always at least
  1315. one.
  1316. Return Value:
  1317. 0 on success.
  1318. Returns an error code on failure.
  1319. --*/
  1320. INT
  1321. DbgrRebootCommand (
  1322. PDEBUGGER_CONTEXT Context,
  1323. PSTR *Arguments,
  1324. ULONG ArgumentCount
  1325. );
  1326. /*++
  1327. Routine Description:
  1328. This routine handles the profile command. It essentially just forwards on
  1329. to the profile handler.
  1330. Arguments:
  1331. Context - Supplies a pointer to the application context.
  1332. Arguments - Supplies an array of strings containing the arguments. The
  1333. first argument is the command itself.
  1334. ArgumentCount - Supplies the count of arguments. This is always at least
  1335. one.
  1336. Return Value:
  1337. 0 on success.
  1338. Returns an error code on failure.
  1339. --*/
  1340. INT
  1341. DbgrServerCommand (
  1342. PDEBUGGER_CONTEXT Context,
  1343. PSTR *Arguments,
  1344. ULONG ArgumentCount
  1345. );
  1346. /*++
  1347. Routine Description:
  1348. This routine starts or stops a remote server interface.
  1349. Arguments:
  1350. Context - Supplies a pointer to the application context.
  1351. Arguments - Supplies an array of strings containing the arguments. The
  1352. first argument is the command itself.
  1353. ArgumentCount - Supplies the count of arguments. This is always at least
  1354. one.
  1355. Return Value:
  1356. 0 on success.
  1357. Returns an error code on failure.
  1358. --*/
  1359. INT
  1360. DbgrContinue (
  1361. PDEBUGGER_CONTEXT Context,
  1362. BOOL SetOneTimeBreak,
  1363. ULONGLONG Address
  1364. );
  1365. /*++
  1366. Routine Description:
  1367. This routine sends the "go" command to the target, signaling to continue
  1368. execution.
  1369. Arguments:
  1370. Context - Supplies a pointer to the application context.
  1371. SetOneTimeBreak - Supplies a flag indicating whether to go unconditionally
  1372. (FALSE) or with a one-time breakpoint (TRUE).
  1373. Address - Supplies the address of the one-time breakpoint if one was
  1374. specified.
  1375. Return Value:
  1376. 0 on success.
  1377. Returns an error code on failure.
  1378. --*/
  1379. VOID
  1380. DbgrShowSourceAtAddress (
  1381. PDEBUGGER_CONTEXT Context,
  1382. ULONGLONG Address
  1383. );
  1384. /*++
  1385. Routine Description:
  1386. This routine loads the source file and highlights the source line
  1387. corresponding to the given target address.
  1388. Arguments:
  1389. Context - Supplies a pointer to the application context.
  1390. Address - Supplies the target's executing virtual address.
  1391. Return Value:
  1392. None.
  1393. --*/
  1394. INT
  1395. DbgrDumpType (
  1396. PDEBUGGER_CONTEXT Context,
  1397. PSTR *Arguments,
  1398. ULONG ArgumentCount,
  1399. PVOID RawDataStream,
  1400. ULONG RawDataStreamSizeInBytes
  1401. );
  1402. /*++
  1403. Routine Description:
  1404. This routine prints information about a type description or value. If only
  1405. a type is specified, the type format will be printed. If an address is
  1406. passed as a second parameter, then the values will be dumped. If a global
  1407. or local variable is passed as the first parameter, the values will also be
  1408. dumped.
  1409. Arguments:
  1410. Context - Supplies a pointer to the application context.
  1411. Arguments - Supplies a pointer to an array of argument strings.
  1412. ArgumentCount - Supplies the number of arguments in the argument array.
  1413. RawDataStream - Supplies the actual memory to dump in the given type form.
  1414. If this parameter is non-NULL, then the AddressString parameter is
  1415. ignored. The size of this buffer must be non-zero.
  1416. RawDataStreamSizeInBytes - Supplies the size of the raw data stream buffer,
  1417. in bytes.
  1418. Return Value:
  1419. 0 if the information was printed successfully.
  1420. Returns an error code on failure.
  1421. --*/
  1422. INT
  1423. DbgrpHighlightExecutingLine (
  1424. PDEBUGGER_CONTEXT Context,
  1425. ULONGLONG LineNumber
  1426. );
  1427. /*++
  1428. Routine Description:
  1429. This routine highlights the currently executing source line and scrolls to
  1430. it, or removes the highlight.
  1431. Arguments:
  1432. Context - Supplies the application context.
  1433. LineNumber - Supplies the one-based line number to highlight, or 0 to
  1434. disable highlighting.
  1435. Return Value:
  1436. 0 on success.
  1437. Non-zero on failure.
  1438. --*/
  1439. INT
  1440. DbgrpLoadSourceFile (
  1441. PDEBUGGER_CONTEXT Context,
  1442. PSTR Path,
  1443. PSTR *FoundPath,
  1444. PVOID *Contents,
  1445. PULONGLONG Size
  1446. );
  1447. /*++
  1448. Routine Description:
  1449. This routine loads a source file into memory.
  1450. Arguments:
  1451. Context - Supplies a pointer to the application context.
  1452. Path - Supplies a pointer to the path to load.
  1453. FoundPath - Supplies a pointer where a pointer to the path of the actual
  1454. file loaded will be returned. The path may be modified by the source
  1455. path list, so this represents the final found path.
  1456. Contents - Supplies a pointer where a pointer to the loaded file will be
  1457. returned on success. The caller is responsible for freeing this memory.
  1458. Size - Supplies a pointer where the size of the file will be returned on
  1459. success.
  1460. Return Value:
  1461. 0 on success.
  1462. Returns an error code on failure.
  1463. --*/
  1464. INT
  1465. DbgrpAddSourcePath (
  1466. PDEBUGGER_CONTEXT Context,
  1467. PSTR PathString
  1468. );
  1469. /*++
  1470. Routine Description:
  1471. This routine adds a source path entry to the given application context.
  1472. Arguments:
  1473. Context - Supplies a pointer to the application context.
  1474. PathString - Supplies a pointer to the path string, which takes the form
  1475. prefix=path. If there is no equals sign, then the prefix is assumed to
  1476. be empty.
  1477. Return Value:
  1478. 0 on success.
  1479. Returns an error code on failure.
  1480. --*/
  1481. VOID
  1482. DbgrpDestroyAllSourcePaths (
  1483. PDEBUGGER_CONTEXT Context
  1484. );
  1485. /*++
  1486. Routine Description:
  1487. This routine destroys all source path entries in the given application
  1488. context.
  1489. Arguments:
  1490. Context - Supplies a pointer to the application context.
  1491. Return Value:
  1492. 0 on success.
  1493. Returns an error code on failure.
  1494. --*/
  1495. PSTR
  1496. DbgGetAddressSymbol (
  1497. PDEBUGGER_CONTEXT Context,
  1498. ULONGLONG Address
  1499. );
  1500. /*++
  1501. Routine Description:
  1502. This routine gets a descriptive string version of the given address,
  1503. including the module and function name if possible. It is the caller's
  1504. responsibility to free the returned string.
  1505. Arguments:
  1506. Context - Supplies a pointer to the application context.
  1507. Address - Supplies the virtual address of the target to get information
  1508. about.
  1509. Return Value:
  1510. Returns a null-terminated string if successfull, or NULL on failure.
  1511. --*/
  1512. BOOL
  1513. DbgGetDataSymbolTypeInformation (
  1514. PDATA_SYMBOL DataSymbol,
  1515. PTYPE_SYMBOL *TypeSymbol,
  1516. PULONG TypeSize
  1517. );
  1518. /*++
  1519. Routine Description:
  1520. This routine computes the type and type size of the given data symbol.
  1521. Arguments:
  1522. DataSymbol - Supplies a pointer to the data symbol whose type and type size
  1523. are to be calculated.
  1524. TypeSymbol - Supplies a pointer that receives a pointer to the type symbol
  1525. that corresponds to the given data symbol.
  1526. TypeSize - Supplies a pointer that receives the type size of the given
  1527. data symbol.
  1528. Return Value:
  1529. Returns TRUE on success, or FALSE on failure.
  1530. --*/
  1531. INT
  1532. DbgGetDataSymbolAddress (
  1533. PDEBUGGER_CONTEXT Context,
  1534. PDEBUG_SYMBOLS Symbols,
  1535. PDATA_SYMBOL DataSymbol,
  1536. ULONGLONG DebasedPc,
  1537. PULONGLONG Address
  1538. );
  1539. /*++
  1540. Routine Description:
  1541. This routine returns the memory address of the given data symbol.
  1542. Arguments:
  1543. Context - Supplies a pointer to the application context.
  1544. Symbols - Supplies a pointer to the module symbols.
  1545. DataSymbol - Supplies a pointer to the data symbol whose address is to be
  1546. returned.
  1547. DebasedPc - Supplies the program counter value, assuming the image were
  1548. loaded at its preferred base address (that is, actual PC minus the
  1549. loaded base difference of the module).
  1550. Address - Supplies a pointer where the debased memory address of the symbol
  1551. will be returned. That is, the caller needs to add any loaded base
  1552. difference of the module to this value.
  1553. Return Value:
  1554. 0 on success.
  1555. ENOENT if the data symbol is not currently valid.
  1556. ERANGE if the data symbol is not stored in memory.
  1557. Other error codes on other failures.
  1558. --*/
  1559. INT
  1560. DbgGetDataSymbolData (
  1561. PDEBUGGER_CONTEXT Context,
  1562. PDEBUG_SYMBOLS Symbols,
  1563. PDATA_SYMBOL DataSymbol,
  1564. ULONGLONG DebasedPc,
  1565. PVOID DataStream,
  1566. ULONG DataStreamSize,
  1567. PSTR Location,
  1568. ULONG LocationSize
  1569. );
  1570. /*++
  1571. Routine Description:
  1572. This routine returns the data contained by the given data symbol.
  1573. Arguments:
  1574. Context - Supplies a pointer to the application context.
  1575. Symbols - Supplies a pointer to the module symbols.
  1576. DataSymbol - Supplies a pointer to the data symbol whose data is to be
  1577. retrieved.
  1578. DebasedPc - Supplies the program counter value, assuming the image were
  1579. loaded at its preferred base address (that is, actual PC minus the
  1580. loaded base difference of the module).
  1581. DataStream - Supplies a pointer that receives the data from the data symbol.
  1582. DataStreamSize - Supplies the size of the data stream buffer.
  1583. Location - Supplies an optional pointer where a string describing the
  1584. location of the data symbol will be returned on success.
  1585. LocationSize - Supplies the size of the location in bytes.
  1586. Return Value:
  1587. 0 on success.
  1588. ENOENT if the data symbol is not currently active given the current state
  1589. of the machine.
  1590. Returns an error code on failure.
  1591. --*/
  1592. INT
  1593. DbgPrintDataSymbol (
  1594. PDEBUGGER_CONTEXT Context,
  1595. PDEBUG_SYMBOLS Symbols,
  1596. PDATA_SYMBOL DataSymbol,
  1597. ULONGLONG DebasedPc,
  1598. ULONG SpaceLevel,
  1599. ULONG RecursionDepth
  1600. );
  1601. /*++
  1602. Routine Description:
  1603. This routine prints the location and value of a data symbol.
  1604. Arguments:
  1605. Context - Supplies a pointer to the application context.
  1606. Symbols - Supplies a pointer to the module symbols.
  1607. DataSymbol - Supplies a pointer to the data symbol to print.
  1608. DebasedPc - Supplies the program counter value, assuming the image were
  1609. loaded at its preferred base address (that is, actual PC minus the
  1610. loaded base difference of the module).
  1611. SpaceLevel - Supplies the number of spaces to print after every newline.
  1612. Used for nesting types.
  1613. RecursionDepth - Supplies how many times this should recurse on structure
  1614. members. If 0, only the name of the type is printed.
  1615. Return Value:
  1616. 0 on success.
  1617. ENOENT if the data symbol is not currently active given the current state
  1618. of the machine.
  1619. Returns an error code on failure.
  1620. --*/
  1621. INT
  1622. DbgGetRegister (
  1623. PDEBUGGER_CONTEXT Context,
  1624. PREGISTERS_UNION Registers,
  1625. ULONG RegisterNumber,
  1626. PULONGLONG RegisterValue
  1627. );
  1628. /*++
  1629. Routine Description:
  1630. This routine returns the contents of a register given a debug symbol
  1631. register index.
  1632. Arguments:
  1633. Context - Supplies a pointer to the application context.
  1634. Registers - Supplies a pointer to the current machine context.
  1635. RegisterNumber - Supplies the register index to get.
  1636. RegisterValue - Supplies a pointer where the register value will be
  1637. returned on success.
  1638. Return Value:
  1639. 0 on success.
  1640. EINVAL if the register number is invalid.
  1641. Other error codes on other failures.
  1642. --*/
  1643. INT
  1644. DbgSetRegister (
  1645. PDEBUGGER_CONTEXT Context,
  1646. PREGISTERS_UNION Registers,
  1647. ULONG RegisterNumber,
  1648. ULONGLONG Value
  1649. );
  1650. /*++
  1651. Routine Description:
  1652. This routine sets the contents of a register given its register number.
  1653. Arguments:
  1654. Context - Supplies a pointer to the application context.
  1655. Registers - Supplies a pointer to the current machine context. The register
  1656. value will be set in this context.
  1657. RegisterNumber - Supplies the register index to set.
  1658. Value - Supplies the new value to set.
  1659. Return Value:
  1660. 0 on success.
  1661. EINVAL if the register number is invalid.
  1662. Other error codes on other failures.
  1663. --*/
  1664. INT
  1665. DbgPrintTypeByName (
  1666. PDEBUGGER_CONTEXT Context,
  1667. ULONGLONG Address,
  1668. PSTR TypeName,
  1669. ULONG SpaceLevel,
  1670. ULONG RecursionCount
  1671. );
  1672. /*++
  1673. Routine Description:
  1674. This routine prints a structure or value at a specified address, whose type
  1675. is specified by a string.
  1676. Arguments:
  1677. Context - Supplies a pointer to the application context.
  1678. Address - Supplies a target address pointer where the data resides.
  1679. TypeName - Supplies a pointer to a string containing the type name to get.
  1680. This should start with a type name, and can use dot '.' notation to
  1681. specify field members, and array[] notation to specify dereferences.
  1682. SpaceLevel - Supplies the number of spaces worth of indentation to print
  1683. for subsequent lines.
  1684. RecursionCount - Supplies the number of substructures to recurse into.
  1685. Return Value:
  1686. 0 on success.
  1687. Returns an error number on failure.
  1688. --*/
  1689. INT
  1690. DbgPrintType (
  1691. PDEBUGGER_CONTEXT Context,
  1692. PTYPE_SYMBOL Type,
  1693. PVOID Data,
  1694. UINTN DataSize,
  1695. ULONG SpaceLevel,
  1696. ULONG RecursionCount
  1697. );
  1698. /*++
  1699. Routine Description:
  1700. This routine prints the given type to the debugger console.
  1701. Arguments:
  1702. Context - Supplies a pointer to the application context.
  1703. Type - Supplies a pointer to the data type to print.
  1704. Data - Supplies a pointer to the data contents.
  1705. DataSize - Supplies the size of the data buffer in bytes.
  1706. SpaceLevel - Supplies the number of spaces worth of indentation to print
  1707. for subsequent lines.
  1708. RecursionCount - Supplies the number of substructures to recurse into.
  1709. Return Value:
  1710. 0 on success.
  1711. Returns an error number on failure.
  1712. --*/
  1713. VOID
  1714. DbgPrintStringData (
  1715. PSTR String,
  1716. UINTN Size,
  1717. ULONG SpaceDepth
  1718. );
  1719. /*++
  1720. Routine Description:
  1721. This routine prints string data to the debugger console.
  1722. Arguments:
  1723. String - Supplies a pointer to the string data.
  1724. Size - Supplies the number of bytes to print out.
  1725. SpaceDepth - Supplies the indentation to use when breaking up a string into
  1726. multiple lines.
  1727. Return Value:
  1728. None.
  1729. --*/