SirCmpwn

Socket Debugging Protocol

Apr 27th, 2012
54
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 7.23 KB | None | 0 0
  1. ===Socket Debugging Protocol===
  2.  
  3. Protocol Version: 1
  4.  
  5. Goal: To provide a debugging protocol that allows for programatic interaction without regard to language or OS.
  6.  
  7. The TCP-based debugger listens to port 22348 for connections by default. The byte ordering is big endian.
  8.  
  9. The following data types are used:
  10. syyp
  11. [bool]: An 8-bit unsigned integer, whose value is 1 for true and 0 for false.
  12. [uint8]: An 8-bit unsigned integer.
  13. [uint16]: A 16-bit unsigned integer.
  14. [uint32]: A 32-bit unsigned integer.
  15. [string]: A string of ASCII characters, length-prefixed by a uint16.
  16. [array]: An array of uint16s, length-prefixed by a uint16.
  17.  
  18. The generic packet structure is as follow
  19.  
  20. [uint8] Identifier
  21. [int32] Length of contents
  22. [...] Contents
  23.  
  24. The packet available are as follows:
  25.  
  26. ---Emulator Information (0x00)
  27. [uint8] Protocol Version (1)
  28. [string] Emulator Name
  29. [string] Emulator Version
  30.  
  31. ---Get Machine State (0x01)
  32. Retrieves the state of the DCPU.
  33. Client->Server:
  34. (no contents)
  35.  
  36. Server->Client:
  37. [bool] Is Running
  38. [uint16] Register A
  39. [uint16] Register B
  40. [uint16] Register C
  41. [uint16] Register X
  42. [uint16] Register Y
  43. [uint16] Register Z
  44. [uint16] Register I
  45. [uint16] Register J
  46. [uint16] Register PC
  47. [uint16] Register SP
  48. [uint16] Register EX
  49. [uint16] Register IA
  50. [uint16] Clock Speed
  51. [uint32] Cycles Executed Since Reset
  52. [uint8] Queued Interrupts (0xFF if interrupt queueing is disabled)
  53.  
  54. ---Set Machine State (0x02)
  55. Sets the state of the DCPU.
  56. Client->Server
  57. [bool] Is Running
  58. [uint16] Register A
  59. [uint16] Register B
  60. [uint16] Register C
  61. [uint16] Register X
  62. [uint16] Register Y
  63. [uint16] Register Z
  64. [uint16] Register I
  65. [uint16] Register J
  66. [uint16] Register PC
  67. [uint16] Register SP
  68. [uint16] Register EX
  69. [uint16] Register IA
  70. [uint16] Clock Speed
  71.  
  72. Server->Client
  73. (Request Confirmation)
  74.  
  75. ---Get Connected Devices (0x03)
  76. Gets a list of connected devices.
  77. Client->Server
  78. (no contents)
  79.  
  80. Server->Client
  81. [uint16] Number of connected devices
  82.  
  83. This is followed by an array of data. The structre of each entry is as follows:
  84. [uint32] Hardware ID
  85. [uint16] Hardware Version
  86. [uint32] Hardware Manufacturer
  87.  
  88. ---Get Device State (0x04)
  89. Gets the state of an individual device.
  90. Client->Server
  91. [uint16] Device Number
  92.  
  93. Server->Client
  94. [bool] Supported (if false, the remainder of the packet is unsent)
  95. (varies by device)
  96.  
  97. ---Set Device State (0x05)
  98. Sets the state of an individual device.
  99. Client->Server
  100. [uint16] Device Number
  101. [...] Varies by device
  102.  
  103. Server->Client
  104. (Request Confirmation)
  105.  
  106. ---Get Memory Sector (0x06)
  107. Retrieves a number of words of memory.
  108. Client->Server
  109. [uint16] Starting address
  110. [uint16] Length
  111.  
  112. Server->Client
  113. [array] The requested memory data.
  114.  
  115. ---Set Memory Sector (0x07)
  116. Sets a number of words of memory.
  117. Client->Server
  118. [uint16] Starting address
  119. [array] The data to write.
  120.  
  121. Server->Client
  122. (Request Confirmation)
  123.  
  124. ---Enable Memory Broadcast (0x08)
  125. Enables the debugger to broadcast changes in the requested range of memory whenever they occur.
  126. Client->Server
  127. [uint16] Address
  128. [uint16] Length
  129.  
  130. Server->Client
  131. The server replies with a request confirmation packet (0x20). Over time, it may send the following packet as well:
  132. [uint16] Address
  133. [array] The memory that has changed. This should be the same size as the original sector length.
  134.  
  135. ---Disable Memory Brodcast (0x09)
  136. Allows the client to disable a memory broadcast for a specified range of memory.
  137. Client->Server
  138. [uint16] Address
  139. [uint16] Length
  140.  
  141. Server->Client
  142. (Request Confirmation)
  143.  
  144. ---Set Emulation State (0x0A)
  145. Allows the client to chage the emulation state easily.
  146. Client->Server
  147. [byte] State: 0 for paused, 1 for running, and 2 to cause a reset.
  148.  
  149. Server->Client
  150. (Request Confirmation)
  151.  
  152. ---Breakpoint (0x0B)
  153. Allows the client to set breakpoints and the server to notify the client.
  154. Client->Server
  155. [uint16] Address
  156.  
  157. Server->Client
  158. The server does not reply to a client request, but it will send packets with an ID of 0x0A when a breakpoint is hit:
  159. [uint16] Address
  160. The server will automatically pause when it hits a breakpoint.
  161.  
  162. ---Watchpoint (0x0C)
  163. Allows the client to set watchpoints and the server to notify the client.
  164. Client->Server
  165. [uint16] Address
  166. [byte] Type: 0 for read, 1 for write, 2 for both
  167.  
  168. Server->Client
  169. The server does not reply to a client request, but it will send packets with an ID of 0x0B when a watchpoint is hit:
  170. [uint16] Address
  171. The server will automatically pause when it hits a breakpoint.
  172.  
  173. ---Step Into (0x0D)
  174. Allows the client to request the emulator to step forward one instruction.
  175. Client->Server
  176. (no contents)
  177.  
  178. Server->Client
  179. [uint16] Register PC
  180.  
  181. ---Step Over (0x0E)
  182. Allows the client to request the emulator to "step over", or exucute one instruction, or a series of branches, or a complete JSR.
  183. Client->Server
  184. [uint16] Maximum intructions to execute
  185.  
  186. Server->Client
  187. [bool] Success
  188. [uint16] Register PC
  189.  
  190. It is possible that a JSR may never return. If the emulation exceeds the maximum instructions, it will reply with Success set to false.
  191. When the emulator completes a step over, it must resume its prior state with regard to emulation being paused or running.
  192.  
  193. ---Trigger Interrupt (0x0F)
  194. Triggers an interrupt on demand.
  195. Client->Server
  196. [uint16] Interrupt message
  197.  
  198. Server->Client
  199. (Request Confirmation)
  200.  
  201. ---Request Confirmation (0x20)
  202. Sent by the server to confirm a request.
  203. Client->Server
  204. (non-appliciable)
  205.  
  206. Server->Client
  207. (no contents)
  208.  
  209. ---Error Processing Request (0xFF)
  210. Sent by the server in leu of a Request Confirmation if an error occured.
  211. Client->Server
  212. (non-appliciable)
  213.  
  214. Server->Client
  215. [string] Error message
  216.  
  217. === Supported Devices
  218. Device status is sent via 0x04 and modified via 0x05. The supported devices and their status formats are as follows:
  219.  
  220. ---LEM1802 Screen
  221. Hardware ID: 0x7349f615
  222. Version: 0x1802
  223. Manufacturer: 0x1c6c8b36
  224. Packet Contents:
  225. Server->Client & Client->Server
  226. [uint16] Screen Mapping
  227. [uint16] Font Mapping
  228. [uint16] Palette Mapping
  229. [uint16] Border Color Mapping
  230.  
  231. ---Generic Clock
  232. Hardware ID: 0x12d0b402
  233. Version: 0x0001
  234. Manufacturer: ????
  235. Packet Contents:
  236. Server->Client & Client->Server
  237. [uint16] Clock speed modifier
  238. [uint16] Ticks elapsed
  239. [uint16] Interrupt message (or zero)
  240.  
  241. ---Generic Keyboard
  242. Hardware ID: 0x30cf7406
  243. Version: 0x0001
  244. Manufacturer: ????
  245. Packet Contents:
  246. Server->Client
  247. [array] Keyboard buffer (a uint16-length-prefixed array of uint16s)
  248. [uint16] Interrupt message (or zero)
  249.  
  250. Client->Server
  251. [array] Keyboard buffer (a uint16-length-prefixed array of key numbers to add to the buffer)
  252. [uint16] Interrupt message (or zero)
  253. [array] Pressed keys (a uint16-length-prefixed array of uint16 key numbers)
  254.  
  255. ---Suspension Chamber 2000
  256. Hardware ID: 0x40e41d9d
  257. Version: 0x005e
  258. Manufacturer: 0x1c6c8b36
  259. Packet Contents:
  260. Server->Client
  261. [uint16] Current status
  262. [uint16] Unit to skip
  263. [uint16] Skip unit
  264.  
  265. Client->Server
  266. [uint16] Current status
  267. [uint16] Unit to skip
  268. [uint16] Skip unit
  269. [bool] Trigger device
Advertisement
Add Comment
Please, Sign In to add comment