Greg Clayton | 1167c4e | 2011-11-28 23:30:42 +0000 | [diff] [blame] | 1 | LLDB has added new GDB server packets to better support multi-threaded and |
| 2 | remote debugging. Why? Normally you need to start the correct GDB and the |
| 3 | correct GDB server when debugging. If you have mismatch, then things go wrong |
| 4 | very quickly. LLDB makes extensive use of the GDB remote protocol and we |
| 5 | wanted to make sure that the experience was a bit more dynamic where we can |
| 6 | discover information about a remote target with having to know anything up |
| 7 | front. We also ran into performance issues with the existing GDB remote |
| 8 | protocol that can be overcome when using a reliable communications layer. |
| 9 | Some packets improve performance, others allow for remote process launching |
| 10 | (if you have an OS), and others allow us to dynamically figure out what |
| 11 | registers a thread might have. Again with GDB, both sides pre-agree on how the |
| 12 | registers will look (how many, their register number,name and offsets). We |
Colin Riley | 4442546 | 2013-11-20 12:35:52 +0000 | [diff] [blame] | 13 | prefer to be able to dynamically determine what kind of architecture, OS and |
Greg Clayton | 1167c4e | 2011-11-28 23:30:42 +0000 | [diff] [blame] | 14 | vendor we are debugging, as well as how things are laid out when it comes to |
| 15 | the thread register contexts. Below are the details on the new packets we have |
| 16 | added above and beyond the standard GDB remote protocol packets. |
| 17 | |
| 18 | //---------------------------------------------------------------------- |
| 19 | // "QStartNoAckMode" |
| 20 | // |
Greg Clayton | bda72b8 | 2011-11-29 01:44:07 +0000 | [diff] [blame] | 21 | // BRIEF |
| 22 | // Try to enable no ACK mode to skip sending ACKs and NACKs. |
| 23 | // |
| 24 | // PRIORITY TO IMPLEMENT |
| 25 | // High. Any GDB remote server that can implement this should if the |
| 26 | // connection is reliable. This improves packet throughput and increases |
| 27 | // the performance of the connection. |
Greg Clayton | 1167c4e | 2011-11-28 23:30:42 +0000 | [diff] [blame] | 28 | //---------------------------------------------------------------------- |
| 29 | Having to send an ACK/NACK after every packet slows things down a bit, so we |
Daniel Malea | 4d3c008 | 2013-02-12 20:01:49 +0000 | [diff] [blame] | 30 | have a way to disable ACK packets to minimize the traffic for reliable |
Greg Clayton | 1167c4e | 2011-11-28 23:30:42 +0000 | [diff] [blame] | 31 | communication interfaces (like sockets). Below GDB or LLDB will send this |
| 32 | packet to try and disable ACKs. All lines that start with "send packet: " are |
| 33 | from GDB/LLDB, and all lines that start with "read packet: " are from the GDB |
| 34 | remote server: |
| 35 | |
| 36 | send packet: $QStartNoAckMode#b0 |
| 37 | read packet: + |
| 38 | read packet: $OK#9a |
| 39 | send packet: + |
| 40 | |
| 41 | |
| 42 | |
| 43 | //---------------------------------------------------------------------- |
| 44 | // "A" - launch args packet |
| 45 | // |
Greg Clayton | bda72b8 | 2011-11-29 01:44:07 +0000 | [diff] [blame] | 46 | // BRIEF |
| 47 | // Launch a program using the supplied arguments |
| 48 | // |
| 49 | // PRIORITY TO IMPLEMENT |
| 50 | // Low. Only needed if the remote target wants to launch a target after |
| 51 | // making a connection to a GDB server that isn't already connected to |
| 52 | // an inferior process. |
Greg Clayton | 1167c4e | 2011-11-28 23:30:42 +0000 | [diff] [blame] | 53 | //---------------------------------------------------------------------- |
| 54 | |
| 55 | We have added support for the "set program arguments" packet where we can |
Aidan Dodds | c9c3d22 | 2015-04-17 16:12:58 +0000 | [diff] [blame] | 56 | start a connection to a remote server and then later supply the path to the |
Greg Clayton | 1167c4e | 2011-11-28 23:30:42 +0000 | [diff] [blame] | 57 | executable and the arguments to use when executing: |
| 58 | |
| 59 | GDB remote docs for this: |
| 60 | |
Greg Clayton | bda72b8 | 2011-11-29 01:44:07 +0000 | [diff] [blame] | 61 | set program arguments(reserved) Aarglen,argnum,arg,... |
Greg Clayton | 1167c4e | 2011-11-28 23:30:42 +0000 | [diff] [blame] | 62 | |
| 63 | Where A is followed by the length in bytes of the hex encoded argument, |
| 64 | followed by an argument integer, and followed by the ASCII characters |
| 65 | converted into hex bytes foreach arg |
| 66 | |
| 67 | send packet: $A98,0,2f566f6c756d65732f776f726b2f67636c6179746f6e2f446f63756d656e74732f7372632f6174746163682f612e6f7574#00 |
| 68 | read packet: $OK#00 |
| 69 | |
| 70 | The above packet helps when you have remote debugging abilities where you |
| 71 | could launch a process on a remote host, this isn't needed for bare board |
| 72 | debugging. |
| 73 | |
| 74 | //---------------------------------------------------------------------- |
| 75 | // "QEnvironment:NAME=VALUE" |
| 76 | // |
Greg Clayton | bda72b8 | 2011-11-29 01:44:07 +0000 | [diff] [blame] | 77 | // BRIEF |
| 78 | // Setup the environment up for a new child process that will soon be |
| 79 | // launched using the "A" packet. |
| 80 | // |
Jason Molenda | e65c0fe | 2013-10-10 22:02:09 +0000 | [diff] [blame] | 81 | // NB: key/value pairs are sent as-is so gdb-remote protocol meta characters |
| 82 | // (e.g. '#' or '$') are not acceptable. If any non-printable or |
| 83 | // metacharacters are present in the strings, QEnvironmentHexEncoded |
| 84 | // should be used instead if it is available. If you don't want to |
| 85 | // scan the environment strings before sending, prefer |
| 86 | // the QEnvironmentHexEncoded packet over QEnvironment, if it is |
| 87 | // available. |
| 88 | // |
Greg Clayton | bda72b8 | 2011-11-29 01:44:07 +0000 | [diff] [blame] | 89 | // PRIORITY TO IMPLEMENT |
| 90 | // Low. Only needed if the remote target wants to launch a target after |
| 91 | // making a connection to a GDB server that isn't already connected to |
| 92 | // an inferior process. |
Greg Clayton | 1167c4e | 2011-11-28 23:30:42 +0000 | [diff] [blame] | 93 | //---------------------------------------------------------------------- |
| 94 | |
| 95 | Both GDB and LLDB support passing down environment variables. Is it ok to |
| 96 | respond with a "$#00" (unimplemented): |
| 97 | |
| 98 | send packet: $QEnvironment:ACK_COLOR_FILENAME=bold yellow#00 |
| 99 | read packet: $OK#00 |
| 100 | |
| 101 | This packet can be sent one or more times _prior_ to sending a "A" packet. |
| 102 | |
| 103 | //---------------------------------------------------------------------- |
Jason Molenda | e65c0fe | 2013-10-10 22:02:09 +0000 | [diff] [blame] | 104 | // "QEnvironmentHexEncoded:HEX-ENCODING(NAME=VALUE)" |
| 105 | // |
| 106 | // BRIEF |
| 107 | // Setup the environment up for a new child process that will soon be |
| 108 | // launched using the "A" packet. |
| 109 | // |
| 110 | // The only difference between this packet and QEnvironment is that the |
| 111 | // environment key-value pair is ascii hex encoded for transmission. |
| 112 | // This allows values with gdb-remote metacharacters like '#' to be sent. |
| 113 | // |
| 114 | // PRIORITY TO IMPLEMENT |
| 115 | // Low. Only needed if the remote target wants to launch a target after |
| 116 | // making a connection to a GDB server that isn't already connected to |
| 117 | // an inferior process. |
| 118 | //---------------------------------------------------------------------- |
| 119 | |
| 120 | Both GDB and LLDB support passing down environment variables. Is it ok to |
| 121 | respond with a "$#00" (unimplemented): |
| 122 | |
| 123 | send packet: $QEnvironment:41434b5f434f4c4f525f46494c454e414d453d626f6c642379656c6c6f77#00 |
| 124 | read packet: $OK#00 |
| 125 | |
| 126 | This packet can be sent one or more times _prior_ to sending a "A" packet. |
| 127 | |
| 128 | //---------------------------------------------------------------------- |
Greg Clayton | 1167c4e | 2011-11-28 23:30:42 +0000 | [diff] [blame] | 129 | // "QSetSTDIN:<ascii-hex-path>" |
| 130 | // "QSetSTDOUT:<ascii-hex-path>" |
| 131 | // "QSetSTDERR:<ascii-hex-path>" |
| 132 | // |
Greg Clayton | bda72b8 | 2011-11-29 01:44:07 +0000 | [diff] [blame] | 133 | // BRIEF |
| 134 | // Setup where STDIN, STDOUT, and STDERR go prior to sending an "A" |
| 135 | // packet. |
| 136 | // |
| 137 | // PRIORITY TO IMPLEMENT |
| 138 | // Low. Only needed if the remote target wants to launch a target after |
| 139 | // making a connection to a GDB server that isn't already connected to |
| 140 | // an inferior process. |
Greg Clayton | 1167c4e | 2011-11-28 23:30:42 +0000 | [diff] [blame] | 141 | //---------------------------------------------------------------------- |
| 142 | |
| 143 | When launching a program through the GDB remote protocol with the "A" packet, |
| 144 | you might also want to specify where stdin/out/err go: |
| 145 | |
| 146 | QSetSTDIN:<ascii-hex-path> |
| 147 | QSetSTDOUT:<ascii-hex-path> |
| 148 | QSetSTDERR:<ascii-hex-path> |
| 149 | |
| 150 | These packets must be sent _prior_ to sending a "A" packet. |
| 151 | |
| 152 | //---------------------------------------------------------------------- |
| 153 | // "QSetWorkingDir:<ascii-hex-path>" |
| 154 | // |
Greg Clayton | bda72b8 | 2011-11-29 01:44:07 +0000 | [diff] [blame] | 155 | // BRIEF |
| 156 | // Set the working directory prior to sending an "A" packet. |
| 157 | // |
| 158 | // PRIORITY TO IMPLEMENT |
| 159 | // Low. Only needed if the remote target wants to launch a target after |
| 160 | // making a connection to a GDB server that isn't already connected to |
| 161 | // an inferior process. |
Greg Clayton | 1167c4e | 2011-11-28 23:30:42 +0000 | [diff] [blame] | 162 | //---------------------------------------------------------------------- |
| 163 | |
| 164 | Or specify the working directory: |
| 165 | |
| 166 | QSetWorkingDir:<ascii-hex-path> |
| 167 | |
| 168 | This packet must be sent _prior_ to sending a "A" packet. |
| 169 | |
| 170 | //---------------------------------------------------------------------- |
| 171 | // "QSetDisableASLR:<bool>" |
| 172 | // |
Greg Clayton | bda72b8 | 2011-11-29 01:44:07 +0000 | [diff] [blame] | 173 | // BRIEF |
| 174 | // Enable or disable ASLR on the next "A" packet. |
| 175 | // |
| 176 | // PRIORITY TO IMPLEMENT |
| 177 | // Low. Only needed if the remote target wants to launch a target after |
| 178 | // making a connection to a GDB server that isn't already connected to |
| 179 | // an inferior process and if the target supports disabling ASLR |
| 180 | // (Address space layout randomization). |
Greg Clayton | 1167c4e | 2011-11-28 23:30:42 +0000 | [diff] [blame] | 181 | //---------------------------------------------------------------------- |
| 182 | |
| 183 | Or control if ASLR is enabled/disabled: |
| 184 | |
| 185 | send packet: QSetDisableASLR:1 |
| 186 | read packet: OK |
| 187 | |
| 188 | send packet: QSetDisableASLR:0 |
| 189 | read packet: OK |
| 190 | |
| 191 | This packet must be sent _prior_ to sending a "A" packet. |
| 192 | |
| 193 | //---------------------------------------------------------------------- |
| 194 | // "qRegisterInfo<hex-reg-id>" |
| 195 | // |
Greg Clayton | bda72b8 | 2011-11-29 01:44:07 +0000 | [diff] [blame] | 196 | // BRIEF |
| 197 | // Discover register information from the remote GDB server. |
| 198 | // |
| 199 | // PRIORITY TO IMPLEMENT |
| 200 | // High. Any target that can self describe its registers, should do so. |
| 201 | // This means if new registers are ever added to a remote target, they |
| 202 | // will get picked up automatically, and allows registers to change |
| 203 | // depending on the actual CPU type that is used. |
Greg Clayton | 1167c4e | 2011-11-28 23:30:42 +0000 | [diff] [blame] | 204 | //---------------------------------------------------------------------- |
| 205 | |
Jason Molenda | de111a4 | 2013-10-01 05:08:22 +0000 | [diff] [blame] | 206 | With LLDB, for register information, remote GDB servers can add |
| 207 | support for the "qRegisterInfoN" packet where "N" is a zero based |
| 208 | base16 register number that must start at zero and increase by one |
| 209 | for each register that is supported. The response is done in typical |
Todd Fiala | af245d1 | 2014-06-30 21:05:18 +0000 | [diff] [blame] | 210 | GDB remote fashion where a series of "KEY:VALUE;" pairs are returned. |
Jason Molenda | de111a4 | 2013-10-01 05:08:22 +0000 | [diff] [blame] | 211 | An example for the x86_64 registers is included below: |
Greg Clayton | 1167c4e | 2011-11-28 23:30:42 +0000 | [diff] [blame] | 212 | |
| 213 | send packet: $qRegisterInfo0#00 |
| 214 | read packet: $name:rax;bitsize:64;offset:0;encoding:uint;format:hex;set:General Purpose Registers;gcc:0;dwarf:0;#00 |
| 215 | send packet: $qRegisterInfo1#00 |
| 216 | read packet: $name:rbx;bitsize:64;offset:8;encoding:uint;format:hex;set:General Purpose Registers;gcc:3;dwarf:3;#00 |
| 217 | send packet: $qRegisterInfo2#00 |
| 218 | read packet: $name:rcx;bitsize:64;offset:16;encoding:uint;format:hex;set:General Purpose Registers;gcc:2;dwarf:2;#00 |
| 219 | send packet: $qRegisterInfo3#00 |
| 220 | read packet: $name:rdx;bitsize:64;offset:24;encoding:uint;format:hex;set:General Purpose Registers;gcc:1;dwarf:1;#00 |
| 221 | send packet: $qRegisterInfo4#00 |
| 222 | read packet: $name:rdi;bitsize:64;offset:32;encoding:uint;format:hex;set:General Purpose Registers;gcc:5;dwarf:5;#00 |
| 223 | send packet: $qRegisterInfo5#00 |
| 224 | read packet: $name:rsi;bitsize:64;offset:40;encoding:uint;format:hex;set:General Purpose Registers;gcc:4;dwarf:4;#00 |
| 225 | send packet: $qRegisterInfo6#00 |
| 226 | read packet: $name:rbp;alt-name:fp;bitsize:64;offset:48;encoding:uint;format:hex;set:General Purpose Registers;gcc:6;dwarf:6;generic:fp;#00 |
| 227 | send packet: $qRegisterInfo7#00 |
| 228 | read packet: $name:rsp;alt-name:sp;bitsize:64;offset:56;encoding:uint;format:hex;set:General Purpose Registers;gcc:7;dwarf:7;generic:sp;#00 |
| 229 | send packet: $qRegisterInfo8#00 |
| 230 | read packet: $name:r8;bitsize:64;offset:64;encoding:uint;format:hex;set:General Purpose Registers;gcc:8;dwarf:8;#00 |
| 231 | send packet: $qRegisterInfo9#00 |
| 232 | read packet: $name:r9;bitsize:64;offset:72;encoding:uint;format:hex;set:General Purpose Registers;gcc:9;dwarf:9;#00 |
| 233 | send packet: $qRegisterInfoa#00 |
| 234 | read packet: $name:r10;bitsize:64;offset:80;encoding:uint;format:hex;set:General Purpose Registers;gcc:10;dwarf:10;#00 |
| 235 | send packet: $qRegisterInfob#00 |
| 236 | read packet: $name:r11;bitsize:64;offset:88;encoding:uint;format:hex;set:General Purpose Registers;gcc:11;dwarf:11;#00 |
| 237 | send packet: $qRegisterInfoc#00 |
| 238 | read packet: $name:r12;bitsize:64;offset:96;encoding:uint;format:hex;set:General Purpose Registers;gcc:12;dwarf:12;#00 |
| 239 | send packet: $qRegisterInfod#00 |
| 240 | read packet: $name:r13;bitsize:64;offset:104;encoding:uint;format:hex;set:General Purpose Registers;gcc:13;dwarf:13;#00 |
| 241 | send packet: $qRegisterInfoe#00 |
| 242 | read packet: $name:r14;bitsize:64;offset:112;encoding:uint;format:hex;set:General Purpose Registers;gcc:14;dwarf:14;#00 |
| 243 | send packet: $qRegisterInfof#00 |
| 244 | read packet: $name:r15;bitsize:64;offset:120;encoding:uint;format:hex;set:General Purpose Registers;gcc:15;dwarf:15;#00 |
| 245 | send packet: $qRegisterInfo10#00 |
| 246 | read packet: $name:rip;alt-name:pc;bitsize:64;offset:128;encoding:uint;format:hex;set:General Purpose Registers;gcc:16;dwarf:16;generic:pc;#00 |
| 247 | send packet: $qRegisterInfo11#00 |
| 248 | read packet: $name:rflags;alt-name:flags;bitsize:64;offset:136;encoding:uint;format:hex;set:General Purpose Registers;#00 |
| 249 | send packet: $qRegisterInfo12#00 |
| 250 | read packet: $name:cs;bitsize:64;offset:144;encoding:uint;format:hex;set:General Purpose Registers;#00 |
| 251 | send packet: $qRegisterInfo13#00 |
| 252 | read packet: $name:fs;bitsize:64;offset:152;encoding:uint;format:hex;set:General Purpose Registers;#00 |
| 253 | send packet: $qRegisterInfo14#00 |
| 254 | read packet: $name:gs;bitsize:64;offset:160;encoding:uint;format:hex;set:General Purpose Registers;#00 |
| 255 | send packet: $qRegisterInfo15#00 |
| 256 | read packet: $name:fctrl;bitsize:16;offset:176;encoding:uint;format:hex;set:Floating Point Registers;#00 |
| 257 | send packet: $qRegisterInfo16#00 |
| 258 | read packet: $name:fstat;bitsize:16;offset:178;encoding:uint;format:hex;set:Floating Point Registers;#00 |
| 259 | send packet: $qRegisterInfo17#00 |
| 260 | read packet: $name:ftag;bitsize:8;offset:180;encoding:uint;format:hex;set:Floating Point Registers;#00 |
| 261 | send packet: $qRegisterInfo18#00 |
| 262 | read packet: $name:fop;bitsize:16;offset:182;encoding:uint;format:hex;set:Floating Point Registers;#00 |
| 263 | send packet: $qRegisterInfo19#00 |
| 264 | read packet: $name:fioff;bitsize:32;offset:184;encoding:uint;format:hex;set:Floating Point Registers;#00 |
| 265 | send packet: $qRegisterInfo1a#00 |
| 266 | read packet: $name:fiseg;bitsize:16;offset:188;encoding:uint;format:hex;set:Floating Point Registers;#00 |
| 267 | send packet: $qRegisterInfo1b#00 |
| 268 | read packet: $name:fooff;bitsize:32;offset:192;encoding:uint;format:hex;set:Floating Point Registers;#00 |
| 269 | send packet: $qRegisterInfo1c#00 |
| 270 | read packet: $name:foseg;bitsize:16;offset:196;encoding:uint;format:hex;set:Floating Point Registers;#00 |
| 271 | send packet: $qRegisterInfo1d#00 |
| 272 | read packet: $name:mxcsr;bitsize:32;offset:200;encoding:uint;format:hex;set:Floating Point Registers;#00 |
| 273 | send packet: $qRegisterInfo1e#00 |
| 274 | read packet: $name:mxcsrmask;bitsize:32;offset:204;encoding:uint;format:hex;set:Floating Point Registers;#00 |
| 275 | send packet: $qRegisterInfo1f#00 |
| 276 | read packet: $name:stmm0;bitsize:80;offset:208;encoding:vector;format:vector-uint8;set:Floating Point Registers;gcc:33;dwarf:33;#00 |
| 277 | send packet: $qRegisterInfo20#00 |
| 278 | read packet: $name:stmm1;bitsize:80;offset:224;encoding:vector;format:vector-uint8;set:Floating Point Registers;gcc:34;dwarf:34;#00 |
| 279 | send packet: $qRegisterInfo21#00 |
| 280 | read packet: $name:stmm2;bitsize:80;offset:240;encoding:vector;format:vector-uint8;set:Floating Point Registers;gcc:35;dwarf:35;#00 |
| 281 | send packet: $qRegisterInfo22#00 |
| 282 | read packet: $name:stmm3;bitsize:80;offset:256;encoding:vector;format:vector-uint8;set:Floating Point Registers;gcc:36;dwarf:36;#00 |
| 283 | send packet: $qRegisterInfo23#00 |
| 284 | read packet: $name:stmm4;bitsize:80;offset:272;encoding:vector;format:vector-uint8;set:Floating Point Registers;gcc:37;dwarf:37;#00 |
| 285 | send packet: $qRegisterInfo24#00 |
| 286 | read packet: $name:stmm5;bitsize:80;offset:288;encoding:vector;format:vector-uint8;set:Floating Point Registers;gcc:38;dwarf:38;#00 |
| 287 | send packet: $qRegisterInfo25#00 |
| 288 | read packet: $name:stmm6;bitsize:80;offset:304;encoding:vector;format:vector-uint8;set:Floating Point Registers;gcc:39;dwarf:39;#00 |
| 289 | send packet: $qRegisterInfo26#00 |
| 290 | read packet: $name:stmm7;bitsize:80;offset:320;encoding:vector;format:vector-uint8;set:Floating Point Registers;gcc:40;dwarf:40;#00 |
| 291 | send packet: $qRegisterInfo27#00 |
| 292 | read packet: $name:xmm0;bitsize:128;offset:336;encoding:vector;format:vector-uint8;set:Floating Point Registers;gcc:17;dwarf:17;#00 |
| 293 | send packet: $qRegisterInfo28#00 |
| 294 | read packet: $name:xmm1;bitsize:128;offset:352;encoding:vector;format:vector-uint8;set:Floating Point Registers;gcc:18;dwarf:18;#00 |
| 295 | send packet: $qRegisterInfo29#00 |
| 296 | read packet: $name:xmm2;bitsize:128;offset:368;encoding:vector;format:vector-uint8;set:Floating Point Registers;gcc:19;dwarf:19;#00 |
| 297 | send packet: $qRegisterInfo2a#00 |
| 298 | read packet: $name:xmm3;bitsize:128;offset:384;encoding:vector;format:vector-uint8;set:Floating Point Registers;gcc:20;dwarf:20;#00 |
| 299 | send packet: $qRegisterInfo2b#00 |
| 300 | read packet: $name:xmm4;bitsize:128;offset:400;encoding:vector;format:vector-uint8;set:Floating Point Registers;gcc:21;dwarf:21;#00 |
| 301 | send packet: $qRegisterInfo2c#00 |
| 302 | read packet: $name:xmm5;bitsize:128;offset:416;encoding:vector;format:vector-uint8;set:Floating Point Registers;gcc:22;dwarf:22;#00 |
| 303 | send packet: $qRegisterInfo2d#00 |
| 304 | read packet: $name:xmm6;bitsize:128;offset:432;encoding:vector;format:vector-uint8;set:Floating Point Registers;gcc:23;dwarf:23;#00 |
| 305 | send packet: $qRegisterInfo2e#00 |
| 306 | read packet: $name:xmm7;bitsize:128;offset:448;encoding:vector;format:vector-uint8;set:Floating Point Registers;gcc:24;dwarf:24;#00 |
| 307 | send packet: $qRegisterInfo2f#00 |
| 308 | read packet: $name:xmm8;bitsize:128;offset:464;encoding:vector;format:vector-uint8;set:Floating Point Registers;gcc:25;dwarf:25;#00 |
| 309 | send packet: $qRegisterInfo30#00 |
| 310 | read packet: $name:xmm9;bitsize:128;offset:480;encoding:vector;format:vector-uint8;set:Floating Point Registers;gcc:26;dwarf:26;#00 |
| 311 | send packet: $qRegisterInfo31#00 |
| 312 | read packet: $name:xmm10;bitsize:128;offset:496;encoding:vector;format:vector-uint8;set:Floating Point Registers;gcc:27;dwarf:27;#00 |
| 313 | send packet: $qRegisterInfo32#00 |
| 314 | read packet: $name:xmm11;bitsize:128;offset:512;encoding:vector;format:vector-uint8;set:Floating Point Registers;gcc:28;dwarf:28;#00 |
| 315 | send packet: $qRegisterInfo33#00 |
| 316 | read packet: $name:xmm12;bitsize:128;offset:528;encoding:vector;format:vector-uint8;set:Floating Point Registers;gcc:29;dwarf:29;#00 |
| 317 | send packet: $qRegisterInfo34#00 |
| 318 | read packet: $name:xmm13;bitsize:128;offset:544;encoding:vector;format:vector-uint8;set:Floating Point Registers;gcc:30;dwarf:30;#00 |
| 319 | send packet: $qRegisterInfo35#00 |
| 320 | read packet: $name:xmm14;bitsize:128;offset:560;encoding:vector;format:vector-uint8;set:Floating Point Registers;gcc:31;dwarf:31;#00 |
| 321 | send packet: $qRegisterInfo36#00 |
| 322 | read packet: $name:xmm15;bitsize:128;offset:576;encoding:vector;format:vector-uint8;set:Floating Point Registers;gcc:32;dwarf:32;#00 |
| 323 | send packet: $qRegisterInfo37#00 |
| 324 | read packet: $name:trapno;bitsize:32;offset:696;encoding:uint;format:hex;set:Exception State Registers;#00 |
| 325 | send packet: $qRegisterInfo38#00 |
| 326 | read packet: $name:err;bitsize:32;offset:700;encoding:uint;format:hex;set:Exception State Registers;#00 |
| 327 | send packet: $qRegisterInfo39#00 |
| 328 | read packet: $name:faultvaddr;bitsize:64;offset:704;encoding:uint;format:hex;set:Exception State Registers;#00 |
| 329 | send packet: $qRegisterInfo3a#00 |
| 330 | read packet: $E45#00 |
| 331 | |
| 332 | As we see above we keep making subsequent calls to the remote server to |
| 333 | discover all registers by increasing the number appended to qRegisterInfo and |
Jason Molenda | de111a4 | 2013-10-01 05:08:22 +0000 | [diff] [blame] | 334 | we get a response back that is a series of "key=value;" strings. |
| 335 | |
Jason Molenda | 9e4a006 | 2013-10-08 02:42:39 +0000 | [diff] [blame] | 336 | The offset: fields should not leave a gap anywhere in the g/G packet -- the |
| 337 | register values should be appended one after another. For instance, if the |
| 338 | register context for a thread looks like |
| 339 | |
| 340 | struct rctx { |
| 341 | uint32_t gpr1; // offset 0 |
| 342 | uint32_t gpr2; // offset 4 |
| 343 | uint32_t gpr3; // offset 8 |
| 344 | uint64_t fp1; // offset 16 |
| 345 | }; |
| 346 | |
| 347 | You may end up with a 4-byte gap between gpr3 and fp1 on architectures |
| 348 | that align values like this. The correct offset: value for fp1 is 12 - |
| 349 | in the g/G packet fp1 will immediately follow gpr3, even though the |
| 350 | in-memory thread structure has an empty 4 bytes for alignment between |
| 351 | these two registers. |
Jason Molenda | de111a4 | 2013-10-01 05:08:22 +0000 | [diff] [blame] | 352 | |
| 353 | The keys and values are detailed below: |
Greg Clayton | 1167c4e | 2011-11-28 23:30:42 +0000 | [diff] [blame] | 354 | |
| 355 | Key Value |
| 356 | ========== ================================================================ |
| 357 | name The primary register name as a string ("rbp" for example) |
| 358 | |
| 359 | alt-name An alternate name for a register as a string ("fp" for example for |
| 360 | the above "rbp") |
| 361 | |
Jason Molenda | de111a4 | 2013-10-01 05:08:22 +0000 | [diff] [blame] | 362 | bitsize Size in bits of a register (32, 64, etc). Base 10. |
Greg Clayton | 1167c4e | 2011-11-28 23:30:42 +0000 | [diff] [blame] | 363 | |
| 364 | offset The offset within the "g" and "G" packet of the register data for |
Jason Molenda | de111a4 | 2013-10-01 05:08:22 +0000 | [diff] [blame] | 365 | this register. This is the byte offset once the data has been |
| 366 | transformed into binary, not the character offset into the g/G |
| 367 | packet. Base 10. |
Greg Clayton | 1167c4e | 2011-11-28 23:30:42 +0000 | [diff] [blame] | 368 | |
| 369 | encoding The encoding type of the register which must be one of: |
| 370 | |
Greg Clayton | bda72b8 | 2011-11-29 01:44:07 +0000 | [diff] [blame] | 371 | uint (unsigned integer) |
| 372 | sint (signed integer) |
| 373 | ieee754 (IEEE 754 float) |
Bruce Mitchener | 6a7f333 | 2014-06-27 02:42:12 +0000 | [diff] [blame] | 374 | vector (vector register) |
Greg Clayton | 1167c4e | 2011-11-28 23:30:42 +0000 | [diff] [blame] | 375 | |
Greg Clayton | bda72b8 | 2011-11-29 01:44:07 +0000 | [diff] [blame] | 376 | format The preferred format for display of this register. The value must |
| 377 | be one of: |
Greg Clayton | 1167c4e | 2011-11-28 23:30:42 +0000 | [diff] [blame] | 378 | |
Greg Clayton | bda72b8 | 2011-11-29 01:44:07 +0000 | [diff] [blame] | 379 | binary |
| 380 | decimal |
| 381 | hex |
| 382 | float |
| 383 | vector-sint8 |
| 384 | vector-uint8 |
| 385 | vector-sint16 |
| 386 | vector-uint16 |
| 387 | vector-sint32 |
| 388 | vector-uint32 |
| 389 | vector-float32 |
| 390 | vector-uint128 |
Greg Clayton | 1167c4e | 2011-11-28 23:30:42 +0000 | [diff] [blame] | 391 | |
Daniel Malea | 4d3c008 | 2013-02-12 20:01:49 +0000 | [diff] [blame] | 392 | set The register set name as a string that this register belongs to. |
Greg Clayton | 1167c4e | 2011-11-28 23:30:42 +0000 | [diff] [blame] | 393 | |
Greg Clayton | bda72b8 | 2011-11-29 01:44:07 +0000 | [diff] [blame] | 394 | gcc The GCC compiler registers number for this register (used for |
| 395 | EH frame and other compiler information that is encoded in the |
Greg Clayton | 0b0ceb6 | 2013-03-12 00:14:38 +0000 | [diff] [blame] | 396 | executable files). The supplied number will be decoded like a |
| 397 | string passed to strtoul() with a base of zero, so the number |
| 398 | can be decimal, or hex if it is prefixed with "0x". |
Greg Clayton | 1167c4e | 2011-11-28 23:30:42 +0000 | [diff] [blame] | 399 | |
Greg Clayton | bda72b8 | 2011-11-29 01:44:07 +0000 | [diff] [blame] | 400 | NOTE: If the compiler doesn't have a register number for this |
| 401 | register, this key/value pair should be omitted. |
Greg Clayton | 1167c4e | 2011-11-28 23:30:42 +0000 | [diff] [blame] | 402 | |
Greg Clayton | bda72b8 | 2011-11-29 01:44:07 +0000 | [diff] [blame] | 403 | dwarf The DWARF register number for this register that is used for this |
Greg Clayton | 0b0ceb6 | 2013-03-12 00:14:38 +0000 | [diff] [blame] | 404 | register in the debug information. The supplied number will be decoded |
| 405 | like a string passed to strtoul() with a base of zero, so the number |
| 406 | can be decimal, or hex if it is prefixed with "0x". |
Greg Clayton | 1167c4e | 2011-11-28 23:30:42 +0000 | [diff] [blame] | 407 | |
Greg Clayton | bda72b8 | 2011-11-29 01:44:07 +0000 | [diff] [blame] | 408 | NOTE: If the compiler doesn't have a register number for this |
| 409 | register, this key/value pair should be omitted. |
Greg Clayton | 1167c4e | 2011-11-28 23:30:42 +0000 | [diff] [blame] | 410 | |
Greg Clayton | bda72b8 | 2011-11-29 01:44:07 +0000 | [diff] [blame] | 411 | generic If the register is a generic register that most CPUs have, classify |
| 412 | it correctly so the debugger knows. Valid values are one of: |
| 413 | pc (a program counter register. for example "name=eip;" (i386), |
| 414 | "name=rip;" (x86_64), "name=r15;" (32 bit arm) would |
| 415 | include a "generic=pc;" key value pair) |
| 416 | sp (a stack pointer register. for example "name=esp;" (i386), |
| 417 | "name=rsp;" (x86_64), "name=r13;" (32 bit arm) would |
| 418 | include a "generic=sp;" key value pair) |
| 419 | fp (a frame pointer register. for example "name=ebp;" (i386), |
| 420 | "name=rbp;" (x86_64), "name=r7;" (32 bit arm with macosx |
| 421 | ABI) would include a "generic=fp;" key value pair) |
| 422 | ra (a return address register. for example "name=lr;" (32 bit ARM) |
| 423 | would include a "generic=ra;" key value pair) |
| 424 | fp (a CPU flags register. for example "name=eflags;" (i386), |
| 425 | "name=rflags;" (x86_64), "name=cpsr;" (32 bit ARM) |
| 426 | would include a "generic=flags;" key value pair) |
| 427 | arg1 - arg8 (specified for registers that contain function |
| 428 | arguments when the argument fits into a register) |
Greg Clayton | 1167c4e | 2011-11-28 23:30:42 +0000 | [diff] [blame] | 429 | |
Greg Clayton | 16ed261 | 2013-01-21 23:18:28 +0000 | [diff] [blame] | 430 | container-regs |
Greg Clayton | 0b0ceb6 | 2013-03-12 00:14:38 +0000 | [diff] [blame] | 431 | The value for this key is a comma separated list of raw hex (optional |
Jason Molenda | fa85ca5 | 2013-01-23 04:38:32 +0000 | [diff] [blame] | 432 | leading "0x") register numbers. |
Greg Clayton | 16ed261 | 2013-01-21 23:18:28 +0000 | [diff] [blame] | 433 | |
Jason Molenda | fa85ca5 | 2013-01-23 04:38:32 +0000 | [diff] [blame] | 434 | This specifies that this register is contained in other concrete |
| 435 | register values. For example "eax" is in the lower 32 bits of the |
| 436 | "rax" register value for x86_64, so "eax" could specify that it is |
| 437 | contained in "rax" by specifying the register number for "rax" (whose |
| 438 | register number is 0x00) |
| 439 | |
| 440 | "container-regs:00;" |
| 441 | |
| 442 | If a register is comprised of one or more registers, like "d0" is ARM |
| 443 | which is a 64 bit register, it might be made up of "s0" and "s1". If |
| 444 | the register number for "s0" is 0x20, and the register number of "s1" |
| 445 | is "0x21", the "container-regs" key/value pair would be: |
| 446 | |
| 447 | "container-regs:20,21;" |
| 448 | |
| 449 | This is handy for defining what GDB used to call "pseudo" registers. |
| 450 | These registers are never requested by LLDB via the register read |
| 451 | or write packets, the container registers will be requested on behalf |
| 452 | of this register. |
| 453 | |
Greg Clayton | 16ed261 | 2013-01-21 23:18:28 +0000 | [diff] [blame] | 454 | invalidate-regs |
Greg Clayton | 0b0ceb6 | 2013-03-12 00:14:38 +0000 | [diff] [blame] | 455 | The value for this key is a comma separated list of raw hex (optional |
Jason Molenda | fa85ca5 | 2013-01-23 04:38:32 +0000 | [diff] [blame] | 456 | leading "0x") register numbers. |
| 457 | |
| 458 | This specifies which register values should be invalidated when this |
| 459 | register is modified. For example if modifying "eax" would cause "rax", |
| 460 | "eax", "ax", "ah", and "al" to be modified where rax is 0x0, eax is 0x15, |
| 461 | ax is 0x25, ah is 0x35, and al is 0x39, the "invalidate-regs" key/value |
| 462 | pair would be: |
Greg Clayton | 16ed261 | 2013-01-21 23:18:28 +0000 | [diff] [blame] | 463 | |
Jason Molenda | fa85ca5 | 2013-01-23 04:38:32 +0000 | [diff] [blame] | 464 | "invalidate-regs:0,15,25,35,39;" |
| 465 | |
| 466 | If there is a single register that gets invalidated, then omit the comma |
| 467 | and just list a single register: |
| 468 | |
| 469 | "invalidate-regs:0;" |
| 470 | |
| 471 | This is handy when modifying a specific register can cause other |
| 472 | register values to change. For example, when debugging an ARM target, |
| 473 | modifying the CPSR register can cause the r8 - r14 and cpsr value to |
| 474 | change depending on if the mode has changed. |
Greg Clayton | 16ed261 | 2013-01-21 23:18:28 +0000 | [diff] [blame] | 475 | |
Greg Clayton | 1167c4e | 2011-11-28 23:30:42 +0000 | [diff] [blame] | 476 | //---------------------------------------------------------------------- |
Chaoren Lin | effd27a | 2015-05-11 19:48:37 +0000 | [diff] [blame] | 477 | // "qPlatform_shell" |
Daniel Malea | e0f8f57 | 2013-08-26 23:57:52 +0000 | [diff] [blame] | 478 | // |
| 479 | // BRIEF |
| 480 | // Run a command in a shell on the connected remote machine. |
| 481 | // |
| 482 | // PRIORITY TO IMPLEMENT |
Daniel Malea | 726df17 | 2013-08-27 15:48:54 +0000 | [diff] [blame] | 483 | // High. This command allows LLDB clients to run arbitrary shell |
| 484 | // commands on a remote host. |
| 485 | // |
| 486 | /---------------------------------------------------------------------- |
Daniel Malea | e0f8f57 | 2013-08-26 23:57:52 +0000 | [diff] [blame] | 487 | |
Daniel Malea | 726df17 | 2013-08-27 15:48:54 +0000 | [diff] [blame] | 488 | The request consists of the command to be executed encoded in ASCII characters |
| 489 | converted into hex bytes. |
Daniel Malea | e0f8f57 | 2013-08-26 23:57:52 +0000 | [diff] [blame] | 490 | |
Daniel Malea | 726df17 | 2013-08-27 15:48:54 +0000 | [diff] [blame] | 491 | The response to this packet consists of the letter F followed by the return code, |
| 492 | followed by the signal number (or 0 if no signal was delivered), and escaped bytes |
| 493 | of captured program output. |
| 494 | |
| 495 | Below is an example communication from a client sending an "ls -la" command: |
| 496 | |
Chaoren Lin | effd27a | 2015-05-11 19:48:37 +0000 | [diff] [blame] | 497 | send packet: $qPlatform_shell:6c73202d6c61,00000002#ec |
Daniel Malea | 726df17 | 2013-08-27 15:48:54 +0000 | [diff] [blame] | 498 | read packet: $F,00000000,00000000,total 4736 |
| 499 | drwxrwxr-x 16 username groupname 4096 Aug 15 21:36 . |
| 500 | drwxr-xr-x 17 username groupname 4096 Aug 10 16:39 .. |
| 501 | -rw-rw-r-- 1 username groupname 73875 Aug 12 16:46 notes.txt |
| 502 | drwxrwxr-x 5 username groupname 4096 Aug 15 21:36 source.cpp |
| 503 | -rw-r--r-- 1 username groupname 2792 Aug 12 16:46 a.out |
| 504 | -rw-r--r-- 1 username groupname 3190 Aug 12 16:46 Makefile |
Daniel Malea | e0f8f57 | 2013-08-26 23:57:52 +0000 | [diff] [blame] | 505 | |
| 506 | //---------------------------------------------------------------------- |
Tamas Berghammer | 0f86b74 | 2015-02-23 11:03:08 +0000 | [diff] [blame] | 507 | // "qPlatform_mkdir" |
| 508 | // |
| 509 | // BRIEF |
| 510 | // Creates a new directory on the connected remote machine. |
| 511 | // |
| 512 | // PRIORITY TO IMPLEMENT |
| 513 | // Low. This command allows LLDB clients to create new directories on |
| 514 | // a remote host. |
| 515 | // |
| 516 | /---------------------------------------------------------------------- |
| 517 | |
| 518 | Request: |
| 519 | qPlatform_mkdir:<hex-file-mode>,<ascii-hex-path> |
| 520 | |
| 521 | Reply: |
| 522 | F<mkdir-return-code> |
| 523 | mkdir called successfully and returned with the given return code |
| 524 | Exx |
| 525 | An error occurred |
| 526 | |
| 527 | //---------------------------------------------------------------------- |
| 528 | // "qPlatform_chmod" |
| 529 | // |
| 530 | // BRIEF |
Chaoren Lin | 0901325 | 2015-04-04 19:09:18 +0000 | [diff] [blame] | 531 | // Change the permissions of a file on the connected remote machine. |
Tamas Berghammer | 0f86b74 | 2015-02-23 11:03:08 +0000 | [diff] [blame] | 532 | // |
| 533 | // PRIORITY TO IMPLEMENT |
| 534 | // Low. This command allows LLDB clients to change the permissions of |
| 535 | // a file on the remote host. |
| 536 | // |
| 537 | /---------------------------------------------------------------------- |
| 538 | |
| 539 | Request: |
| 540 | qPlatform_chmod:<hex-file-mode>,<ascii-hex-path> |
| 541 | |
| 542 | Reply: |
| 543 | F<chmod-return-code> |
| 544 | chmod called successfully and returned with the given return code |
| 545 | Exx |
| 546 | An error occurred |
| 547 | |
| 548 | //---------------------------------------------------------------------- |
Greg Clayton | 1167c4e | 2011-11-28 23:30:42 +0000 | [diff] [blame] | 549 | // "qHostInfo" |
| 550 | // |
Greg Clayton | bda72b8 | 2011-11-29 01:44:07 +0000 | [diff] [blame] | 551 | // BRIEF |
| 552 | // Get information about the host we are remotely connected to. |
| 553 | // |
| 554 | // PRIORITY TO IMPLEMENT |
| 555 | // High. This packet is usually very easy to implement and can help |
| 556 | // LLDB select the correct plug-ins for the job based on the target |
Bruce Mitchener | 6a7f333 | 2014-06-27 02:42:12 +0000 | [diff] [blame] | 557 | // triple information that is supplied. |
Greg Clayton | 1167c4e | 2011-11-28 23:30:42 +0000 | [diff] [blame] | 558 | //---------------------------------------------------------------------- |
| 559 | |
| 560 | LLDB supports a host info call that gets all sorts of details of the system |
| 561 | that is being debugged: |
| 562 | |
| 563 | send packet: $qHostInfo#00 |
| 564 | read packet: $cputype:16777223;cpusubtype:3;ostype:darwin;vendor:apple;endian:little;ptrsize:8;#00 |
| 565 | |
| 566 | Key value pairs are one of: |
| 567 | |
Jason Molenda | 4411528 | 2014-01-25 04:44:34 +0000 | [diff] [blame] | 568 | cputype: is a number that is the mach-o CPU type that is being debugged (base 10) |
| 569 | cpusubtype: is a number that is the mach-o CPU subtype type that is being debugged (base 10) |
Greg Clayton | bac3ff1 | 2013-10-25 18:22:24 +0000 | [diff] [blame] | 570 | triple: a string for the target triple (x86_64-apple-macosx) that can be used to specify arch + vendor + os in one entry |
| 571 | vendor: a string for the vendor (apple), not needed if "triple" is specified |
| 572 | ostype: a string for the OS being debugged (darwin, linux, freebsd), not needed if "triple" is specified |
Greg Clayton | 1167c4e | 2011-11-28 23:30:42 +0000 | [diff] [blame] | 573 | endian: is one of "little", "big", or "pdp" |
Greg Clayton | bac3ff1 | 2013-10-25 18:22:24 +0000 | [diff] [blame] | 574 | ptrsize: an unsigned number that represents how big pointers are in bytes on the debug target |
| 575 | hostname: the hostname of the host that is running the GDB server if available |
| 576 | os_build: a string for the the OS build for the remote host as a string value |
| 577 | os_kernel: a string describing the kernel version |
| 578 | os_version: a version string that represents the current OS version (10.8.2) |
| 579 | watchpoint_exceptions_received: one of "before" or "after" to specify if a watchpoint is triggered before or after the pc when it stops |
| 580 | default_packet_timeout: an unsigned number that specifies the default timeout in seconds |
Todd Fiala | a9ddb0e | 2014-01-18 03:02:39 +0000 | [diff] [blame] | 581 | distribution_id: optional. For linux, specifies distribution id (e.g. ubuntu, fedora, etc.) |
Greg Clayton | 1167c4e | 2011-11-28 23:30:42 +0000 | [diff] [blame] | 582 | |
| 583 | //---------------------------------------------------------------------- |
Jason Molenda | de111a4 | 2013-10-01 05:08:22 +0000 | [diff] [blame] | 584 | // "qGDBServerVersion" |
| 585 | // |
| 586 | // BRIEF |
| 587 | // Get version information about this implementation of the gdb-remote |
| 588 | // protocol. |
| 589 | // |
| 590 | // PRIORITY TO IMPLEMENT |
| 591 | // High. This packet is usually very easy to implement and can help |
| 592 | // LLDB to work around bugs in a server's implementation when they |
| 593 | // are found. |
| 594 | //---------------------------------------------------------------------- |
| 595 | |
| 596 | The goal of this packet is to provide enough information about an |
| 597 | implementation of the gdb-remote-protocol server that lldb can |
| 598 | work around implementation problems that are discovered after the |
| 599 | version has been released/deployed. The name and version number |
| 600 | should be sufficiently unique that lldb can unambiguously identify |
| 601 | the origin of the program (for instance, debugserver from lldb) and |
| 602 | the version/submission number/patch level of the program - whatever |
| 603 | is appropriate for your server implementation. |
| 604 | |
| 605 | The packet follows the key-value pair model, semicolon separated. |
| 606 | |
| 607 | send packet: $qGDBServerVersion#00 |
| 608 | read packet: $name:debugserver;version:310.2;#00 |
| 609 | |
| 610 | Other clients may find other key-value pairs to be useful for identifying |
| 611 | a gdb stub. Patch level, release name, build number may all be keys that |
| 612 | better describe your implementation's version. |
| 613 | Suggested key names: |
| 614 | |
| 615 | name : the name of your remote server - "debugserver" is the lldb standard |
| 616 | implementation |
| 617 | |
| 618 | version : identifies the version number of this server |
| 619 | |
| 620 | patch_level : the patch level of this server |
| 621 | |
| 622 | release_name : the name of this release, if your project uses names |
| 623 | |
| 624 | build_number : if you use a build system with increasing build numbers, |
| 625 | this may be the right key name for your server |
| 626 | |
| 627 | major_version : major version number |
| 628 | minor_version : minor version number |
| 629 | |
| 630 | //---------------------------------------------------------------------- |
Jason Molenda | fca9c6b | 2012-12-18 04:39:43 +0000 | [diff] [blame] | 631 | // "qProcessInfo" |
| 632 | // |
| 633 | // BRIEF |
| 634 | // Get information about the process we are currently debugging. |
| 635 | // |
| 636 | // PRIORITY TO IMPLEMENT |
| 637 | // Medium. On systems which can launch multiple different architecture processes, |
| 638 | // the qHostInfo may not disambiguate sufficiently to know what kind of |
| 639 | // process is being debugged. |
Jason Molenda | f17b5ac | 2012-12-19 02:54:03 +0000 | [diff] [blame] | 640 | // e.g. on a 64-bit x86 Mac system both 32-bit and 64-bit user processes are possible, |
Daniel Malea | 4d3c008 | 2013-02-12 20:01:49 +0000 | [diff] [blame] | 641 | // and with Mach-O universal files, the executable file may contain both 32- and |
Jason Molenda | fca9c6b | 2012-12-18 04:39:43 +0000 | [diff] [blame] | 642 | // 64-bit slices so it may be impossible to know until you're attached to a real |
| 643 | // process to know what you're working with. |
Jason Molenda | f17b5ac | 2012-12-19 02:54:03 +0000 | [diff] [blame] | 644 | // |
| 645 | // All numeric fields return base-16 numbers without any "0x" prefix. |
Jason Molenda | fca9c6b | 2012-12-18 04:39:43 +0000 | [diff] [blame] | 646 | //---------------------------------------------------------------------- |
| 647 | |
Jason Molenda | f17b5ac | 2012-12-19 02:54:03 +0000 | [diff] [blame] | 648 | An i386 process: |
| 649 | |
Jason Molenda | fca9c6b | 2012-12-18 04:39:43 +0000 | [diff] [blame] | 650 | send packet: $qProcessInfo#00 |
Jason Molenda | f17b5ac | 2012-12-19 02:54:03 +0000 | [diff] [blame] | 651 | read packet: $pid:42a8;parent-pid:42bf;real-uid:ecf;real-gid:b;effective-uid:ecf;effective-gid:b;cputype:7;cpusubtype:3;ostype:macosx;vendor:apple;endian:little;ptrsize:4;#00 |
| 652 | |
| 653 | An x86_64 process: |
| 654 | |
| 655 | send packet: $qProcessInfo#00 |
| 656 | read packet: $pid:d22c;parent-pid:d34d;real-uid:ecf;real-gid:b;effective-uid:ecf;effective-gid:b;cputype:1000007;cpusubtype:3;ostype:macosx;vendor:apple;endian:little;ptrsize:8;#00 |
Jason Molenda | fca9c6b | 2012-12-18 04:39:43 +0000 | [diff] [blame] | 657 | |
| 658 | Key value pairs include: |
| 659 | |
| 660 | pid: the process id |
| 661 | parent-pid: the process of the parent process (often debugserver will become the parent when attaching) |
| 662 | real-uid: the real user id of the process |
| 663 | real-gid: the real group id of the process |
| 664 | effective-uid: the effective user id of the process |
| 665 | effective-gid: the effective group id of the process |
Jason Molenda | 4411528 | 2014-01-25 04:44:34 +0000 | [diff] [blame] | 666 | cputype: the Mach-O CPU type of the process (base 16) |
| 667 | cpusubtype: the Mach-O CPU subtype of the process (base 16) |
Daniel Malea | 4d3c008 | 2013-02-12 20:01:49 +0000 | [diff] [blame] | 668 | ostype: is a string the represents the OS being debugged (darwin, linux, freebsd) |
Jason Molenda | f17b5ac | 2012-12-19 02:54:03 +0000 | [diff] [blame] | 669 | vendor: is a string that represents the vendor (apple) |
| 670 | endian: is one of "little", "big", or "pdp" |
Jason Molenda | fca9c6b | 2012-12-18 04:39:43 +0000 | [diff] [blame] | 671 | ptrsize: is a number that represents how big pointers are in bytes |
| 672 | |
| 673 | |
| 674 | //---------------------------------------------------------------------- |
Greg Clayton | 1167c4e | 2011-11-28 23:30:42 +0000 | [diff] [blame] | 675 | // "qShlibInfoAddr" |
| 676 | // |
Greg Clayton | bda72b8 | 2011-11-29 01:44:07 +0000 | [diff] [blame] | 677 | // BRIEF |
| 678 | // Get an address where the dynamic linker stores information about |
| 679 | // where shared libraries are loaded. |
| 680 | // |
| 681 | // PRIORITY TO IMPLEMENT |
| 682 | // High if you have a dynamic loader plug-in in LLDB for your target |
| 683 | // triple (see the "qHostInfo" packet) that can use this information. |
| 684 | // Many times address load randomization can make it hard to detect |
| 685 | // where the dynamic loader binary and data structures are located and |
| 686 | // some platforms know, or can find out where this information is. |
| 687 | // |
| 688 | // Low if you have a debug target where all object and symbol files |
| 689 | // contain static load addresses. |
Greg Clayton | 1167c4e | 2011-11-28 23:30:42 +0000 | [diff] [blame] | 690 | //---------------------------------------------------------------------- |
| 691 | |
| 692 | LLDB and GDB both support the "qShlibInfoAddr" packet which is a hint to each |
| 693 | debugger as to where to find the dynamic loader information. For darwin |
Daniel Malea | 4d3c008 | 2013-02-12 20:01:49 +0000 | [diff] [blame] | 694 | binaries that run in user land this is the address of the "all_image_infos" |
| 695 | structure in the "/usr/lib/dyld" executable, or the result of a TASK_DYLD_INFO |
Greg Clayton | 1167c4e | 2011-11-28 23:30:42 +0000 | [diff] [blame] | 696 | call. The result is returned as big endian hex bytes that are the address |
| 697 | value: |
| 698 | |
| 699 | send packet: $qShlibInfoAddr#00 |
| 700 | read packet: $7fff5fc40040#00 |
| 701 | |
| 702 | |
| 703 | |
| 704 | //---------------------------------------------------------------------- |
| 705 | // "qThreadStopInfo<tid>" |
| 706 | // |
Greg Clayton | bda72b8 | 2011-11-29 01:44:07 +0000 | [diff] [blame] | 707 | // BRIEF |
| 708 | // Get information about why a thread, whose ID is "<tid>", is stopped. |
| 709 | // |
| 710 | // PRIORITY TO IMPLEMENT |
| 711 | // High if you need to support multi-threaded or multi-core debugging. |
| 712 | // Many times one thread will hit a breakpoint and while the debugger |
| 713 | // is in the process of suspending the other threads, other threads |
| 714 | // will also hit a breakpoint. This packet allows LLDB to know why all |
| 715 | // threads (live system debug) / cores (JTAG) in your program have |
| 716 | // stopped and allows LLDB to display and control your program |
| 717 | // correctly. |
Greg Clayton | 1167c4e | 2011-11-28 23:30:42 +0000 | [diff] [blame] | 718 | //---------------------------------------------------------------------- |
Greg Clayton | bda72b8 | 2011-11-29 01:44:07 +0000 | [diff] [blame] | 719 | |
Greg Clayton | 1167c4e | 2011-11-28 23:30:42 +0000 | [diff] [blame] | 720 | LLDB tries to use the "qThreadStopInfo" packet which is formatted as |
| 721 | "qThreadStopInfo%x" where %x is the hex thread ID. This requests information |
| 722 | about why a thread is stopped. The response is the same as the stop reply |
| 723 | packets and tells us what happened to the other threads. The standard GDB |
| 724 | remote packets love to think that there is only _one_ reason that _one_ thread |
| 725 | stops at a time. This allows us to see why all threads stopped and allows us |
| 726 | to implement better multi-threaded debugging support. |
| 727 | |
| 728 | //---------------------------------------------------------------------- |
| 729 | // "QThreadSuffixSupported" |
| 730 | // |
Greg Clayton | bda72b8 | 2011-11-29 01:44:07 +0000 | [diff] [blame] | 731 | // BRIEF |
| 732 | // Try to enable thread suffix support for the 'g', 'G', 'p', and 'P' |
| 733 | // packets. |
| 734 | // |
| 735 | // PRIORITY TO IMPLEMENT |
| 736 | // High. Adding a thread suffix allows us to read and write registers |
| 737 | // more efficiently and stops us from having to select a thread with |
| 738 | // one packet and then read registers with a second packet. It also |
| 739 | // makes sure that no errors can occur where the debugger thinks it |
| 740 | // already has a thread selected (see the "Hg" packet from the standard |
| 741 | // GDB remote protocol documentation) yet the remote GDB server actually |
| 742 | // has another thread selected. |
Greg Clayton | 1167c4e | 2011-11-28 23:30:42 +0000 | [diff] [blame] | 743 | //---------------------------------------------------------------------- |
| 744 | |
| 745 | When reading thread registers, you currently need to set the current |
Daniel Malea | 4d3c008 | 2013-02-12 20:01:49 +0000 | [diff] [blame] | 746 | thread, then read the registers. This is kind of cumbersome, so we added the |
Greg Clayton | 1167c4e | 2011-11-28 23:30:42 +0000 | [diff] [blame] | 747 | ability to query if the remote GDB server supports adding a "thread:<tid>;" |
| 748 | suffix to all packets that request information for a thread. To test if the |
| 749 | remote GDB server supports this feature: |
| 750 | |
| 751 | send packet: $QThreadSuffixSupported#00 |
| 752 | read packet: OK |
| 753 | |
| 754 | If "OK" is returned, then the 'g', 'G', 'p' and 'P' packets can accept a |
| 755 | thread suffix. So to send a 'g' packet (read all register values): |
| 756 | |
| 757 | send packet: $g;thread:<tid>;#00 |
| 758 | read packet: .... |
| 759 | |
| 760 | send packet: $G;thread:<tid>;#00 |
| 761 | read packet: .... |
| 762 | |
| 763 | send packet: $p1a;thread:<tid>;#00 |
| 764 | read packet: .... |
| 765 | |
| 766 | send packet: $P1a=1234abcd;thread:<tid>;#00 |
| 767 | read packet: .... |
| 768 | |
| 769 | |
| 770 | otherwise, without this you would need to always send two packets: |
| 771 | |
| 772 | send packet: $Hg<tid>#00 |
| 773 | read packet: .... |
| 774 | send packet: $g#00 |
| 775 | read packet: .... |
| 776 | |
| 777 | We also added support for allocating and deallocating memory. We use this to |
| 778 | allocate memory so we can run JITed code. |
| 779 | |
| 780 | //---------------------------------------------------------------------- |
| 781 | // "_M<size>,<permissions>" |
| 782 | // |
Greg Clayton | bda72b8 | 2011-11-29 01:44:07 +0000 | [diff] [blame] | 783 | // BRIEF |
| 784 | // Allocate memory on the remote target with the specified size and |
| 785 | // permissions. |
| 786 | // |
| 787 | // PRIORITY TO IMPLEMENT |
| 788 | // High if you want LLDB to be able to JIT code and run that code. JIT |
| 789 | // code also needs data which is also allocated and tracked. |
| 790 | // |
| 791 | // Low if you don't support running JIT'ed code. |
Greg Clayton | 1167c4e | 2011-11-28 23:30:42 +0000 | [diff] [blame] | 792 | //---------------------------------------------------------------------- |
| 793 | |
| 794 | The allocate memory packet starts with "_M<size>,<permissions>". It returns a |
| 795 | raw big endian address value, or "" for unimplemented, or "EXX" for an error |
| 796 | code. The packet is formatted as: |
| 797 | |
| 798 | char packet[256]; |
| 799 | int packet_len; |
| 800 | packet_len = ::snprintf ( |
Greg Clayton | bda72b8 | 2011-11-29 01:44:07 +0000 | [diff] [blame] | 801 | packet, |
| 802 | sizeof(packet), |
| 803 | "_M%zx,%s%s%s", |
| 804 | (size_t)size, |
| 805 | permissions & lldb::ePermissionsReadable ? "r" : "", |
| 806 | permissions & lldb::ePermissionsWritable ? "w" : "", |
| 807 | permissions & lldb::ePermissionsExecutable ? "x" : ""); |
Greg Clayton | 1167c4e | 2011-11-28 23:30:42 +0000 | [diff] [blame] | 808 | |
| 809 | You request a size and give the permissions. This packet does NOT need to be |
| 810 | implemented if you don't want to support running JITed code. The return value |
| 811 | is just the address of the newly allocated memory as raw big endian hex bytes. |
| 812 | |
| 813 | //---------------------------------------------------------------------- |
| 814 | // "_m<addr>" |
| 815 | // |
Greg Clayton | bda72b8 | 2011-11-29 01:44:07 +0000 | [diff] [blame] | 816 | // BRIEF |
| 817 | // Deallocate memory that was previously allocated using an allocate |
| 818 | // memory pack. |
| 819 | // |
| 820 | // PRIORITY TO IMPLEMENT |
| 821 | // High if you want LLDB to be able to JIT code and run that code. JIT |
| 822 | // code also needs data which is also allocated and tracked. |
| 823 | // |
| 824 | // Low if you don't support running JIT'ed code. |
Greg Clayton | 1167c4e | 2011-11-28 23:30:42 +0000 | [diff] [blame] | 825 | //---------------------------------------------------------------------- |
| 826 | |
| 827 | The deallocate memory packet is "_m<addr>" where you pass in the address you |
| 828 | got back from a previous call to the allocate memory packet. It returns "OK" |
| 829 | if the memory was successfully deallocated, or "EXX" for an error, or "" if |
| 830 | not supported. |
| 831 | |
| 832 | //---------------------------------------------------------------------- |
| 833 | // "qMemoryRegionInfo:<addr>" |
| 834 | // |
Greg Clayton | bda72b8 | 2011-11-29 01:44:07 +0000 | [diff] [blame] | 835 | // BRIEF |
Todd Fiala | 20f834b | 2014-06-04 05:07:40 +0000 | [diff] [blame] | 836 | // Get information about the address range that contains "<addr>" |
Greg Clayton | bda72b8 | 2011-11-29 01:44:07 +0000 | [diff] [blame] | 837 | // |
| 838 | // PRIORITY TO IMPLEMENT |
| 839 | // Medium. This is nice to have, but it isn't necessary. It helps LLDB |
| 840 | // do stack unwinding when we branch into memory that isn't executable. |
| 841 | // If we can detect that the code we are stopped in isn't executable, |
| 842 | // then we can recover registers for stack frames above the current |
| 843 | // frame. Otherwise we must assume we are in some JIT'ed code (not JIT |
| 844 | // code that LLDB has made) and assume that no registers are available |
| 845 | // in higher stack frames. |
Greg Clayton | 1167c4e | 2011-11-28 23:30:42 +0000 | [diff] [blame] | 846 | //---------------------------------------------------------------------- |
| 847 | |
| 848 | We added a way to get information for a memory region. The packet is: |
| 849 | |
Greg Clayton | bda72b8 | 2011-11-29 01:44:07 +0000 | [diff] [blame] | 850 | qMemoryRegionInfo:<addr> |
| 851 | |
Greg Clayton | 1167c4e | 2011-11-28 23:30:42 +0000 | [diff] [blame] | 852 | Where <addr> is a big endian hex address. The response is returned in a series |
| 853 | of tuples like the data returned in a stop reply packet. The currently valid |
Todd Fiala | 20f834b | 2014-06-04 05:07:40 +0000 | [diff] [blame] | 854 | tuples to return are: |
Greg Clayton | 1167c4e | 2011-11-28 23:30:42 +0000 | [diff] [blame] | 855 | |
Greg Clayton | bda72b8 | 2011-11-29 01:44:07 +0000 | [diff] [blame] | 856 | start:<start-addr>; // <start-addr> is a big endian hex address that is |
| 857 | // the start address of the range that contains <addr> |
| 858 | |
| 859 | size:<size>; // <size> is a big endian hex byte size of the address |
| 860 | // of the range that contains <addr> |
| 861 | |
| 862 | permissions:<permissions>; // <permissions> is a string that contains one |
| 863 | // or more of the characters from "rwx" |
| 864 | |
| 865 | error:<ascii-byte-error-string>; // where <ascii-byte-error-string> is |
| 866 | // a hex encoded string value that |
| 867 | // contains an error string |
| 868 | |
Jason Molenda | cb349ee | 2011-12-13 05:39:38 +0000 | [diff] [blame] | 869 | If the address requested is not in a mapped region (e.g. we've jumped through |
| 870 | a NULL pointer and are at 0x0) currently lldb expects to get back the size |
| 871 | of the unmapped region -- that is, the distance to the next valid region. |
| 872 | For instance, with a Mac OS X process which has nothing mapped in the first |
| 873 | 4GB of its address space, if we're asking about address 0x2, |
| 874 | |
| 875 | qMemoryRegionInfo:2 |
| 876 | start:2;size:fffffffe; |
| 877 | |
| 878 | The lack of 'permissions:' indicates that none of read/write/execute are valid |
| 879 | for this region. |
| 880 | |
Greg Clayton | bda72b8 | 2011-11-29 01:44:07 +0000 | [diff] [blame] | 881 | //---------------------------------------------------------------------- |
Jason Molenda | 060ca75 | 2014-05-13 22:21:34 +0000 | [diff] [blame] | 882 | // "x" - Binary memory read |
Jason Molenda | 018ff31 | 2014-05-06 02:53:43 +0000 | [diff] [blame] | 883 | // |
| 884 | // Like the 'm' (read) and 'M' (write) packets, this is a partner to the |
| 885 | // 'X' (write binary data) packet, 'x'. |
| 886 | // |
| 887 | // It is called like |
| 888 | // |
| 889 | // xADDRESS,LENGTH |
| 890 | // |
| 891 | // where both ADDRESS and LENGTH are big-endian base 16 values. |
| 892 | // |
| 893 | // To test if this packet is available, send a addr/len of 0: |
| 894 | // |
| 895 | // x0,0 |
| 896 | // |
| 897 | // and you will get an "OK" response. |
| 898 | // |
| 899 | // The reply will be the data requested in 8-bit binary data format. |
| 900 | // The standard quoting is applied to the payload -- characters |
| 901 | // } # $ * |
| 902 | // will all be escaped with '}' (0x7d) character and then XOR'ed with 0x20. |
| 903 | // |
| 904 | // A typical use to read 512 bytes at 0x1000 would look like |
| 905 | // |
| 906 | // x0x1000,0x200 |
| 907 | // |
| 908 | // The "0x" prefixes are optional - like most of the gdb-remote packets, |
| 909 | // omitting them will work fine; these numbers are always base 16. |
| 910 | // |
| 911 | // The length of the payload is not provided. A reliable, 8-bit clean, |
| 912 | // transport layer is assumed. |
| 913 | //---------------------------------------------------------------------- |
| 914 | |
| 915 | //---------------------------------------------------------------------- |
Jim Ingham | 679f6b7 | 2013-06-07 00:22:49 +0000 | [diff] [blame] | 916 | // Detach and stay stopped: |
| 917 | // |
| 918 | // We extended the "D" packet to specify that the monitor should keep the |
| 919 | // target suspended on detach. The normal behavior is to resume execution |
| 920 | // on detach. We will send: |
| 921 | // |
| 922 | // qSupportsDetachAndStayStopped: |
| 923 | // |
| 924 | // to query whether the monitor supports the extended detach, and if it does, |
| 925 | // when we want the monitor to detach but not resume the target, we will |
| 926 | // send: |
| 927 | // |
| 928 | // D1 |
| 929 | // |
| 930 | // In any case, if we want the normal detach behavior we will just send: |
| 931 | // |
| 932 | // D |
| 933 | //---------------------------------------------------------------------- |
| 934 | |
| 935 | //---------------------------------------------------------------------- |
Greg Clayton | 5d719f2 | 2013-11-13 23:55:36 +0000 | [diff] [blame] | 936 | // QSaveRegisterState |
| 937 | // QSaveRegisterState;thread:XXXX; |
| 938 | // |
| 939 | // BRIEF |
| 940 | // The QSaveRegisterState packet tells the remote debugserver to save |
| 941 | // all registers and return a non-zero unique integer ID that |
| 942 | // represents these save registers. If thread suffixes are enabled the |
| 943 | // second form of this packet is used, otherwise the first form is |
| 944 | // used. This packet is called prior to executing an expression, so |
| 945 | // the remote GDB server should do anything it needs to in order to |
| 946 | // ensure the registers that are saved are correct. On MacOSX this |
| 947 | // involves calling "thread_abort_safely(mach_port_t thread)" to |
| 948 | // ensure we get the correct registers for a thread in case it is |
| 949 | // currently having code run on its behalf in the kernel. |
| 950 | // |
| 951 | // RESPONSE |
| 952 | // unsigned - The save_id result is a non-zero unsigned integer value |
| 953 | // that can be passed back to the GDB server using a |
| 954 | // QRestoreRegisterState packet to restore the registers |
| 955 | // one time. |
| 956 | // "EXX" - or an error code in the form of EXX where XX is a |
| 957 | // hex error code. |
| 958 | // |
| 959 | // PRIORITY TO IMPLEMENT |
| 960 | // Low, this is mostly a convenience packet to avoid having to send all |
| 961 | // registers via a g packet. It should only be implemented if support |
| 962 | // for the QRestoreRegisterState is added. |
| 963 | //---------------------------------------------------------------------- |
| 964 | |
| 965 | //---------------------------------------------------------------------- |
| 966 | // QRestoreRegisterState:<save_id> |
| 967 | // QRestoreRegisterState:<save_id>;thread:XXXX; |
| 968 | // |
| 969 | // BRIEF |
| 970 | // The QRestoreRegisterState packet tells the remote debugserver to |
| 971 | // restore all registers using the "save_id" which is an unsigned |
| 972 | // integer that was returned from a previous call to |
| 973 | // QSaveRegisterState. The restoration process can only be done once |
| 974 | // as the data backing the register state will be freed upon the |
| 975 | // completion of the QRestoreRegisterState command. |
| 976 | // |
| 977 | // If thread suffixes are enabled the second form of this packet is |
| 978 | // used, otherwise the first form is used. |
| 979 | // |
| 980 | // RESPONSE |
| 981 | // "OK" - if all registers were successfully restored |
| 982 | // "EXX" - for any errors |
| 983 | // |
| 984 | // PRIORITY TO IMPLEMENT |
| 985 | // Low, this is mostly a convenience packet to avoid having to send all |
| 986 | // registers via a g packet. It should only be implemented if support |
| 987 | // for the QSaveRegisterState is added. |
| 988 | //---------------------------------------------------------------------- |
| 989 | |
| 990 | //---------------------------------------------------------------------- |
Oleksiy Vyalov | 6801be3 | 2015-02-25 22:15:44 +0000 | [diff] [blame] | 991 | // qModuleInfo:<module_path>;<arch triple> |
| 992 | // |
| 993 | // BRIEF |
| 994 | // Get information for a module by given module path and architecture. |
| 995 | // |
| 996 | // RESPONSE |
| 997 | // "(uuid|md5):...;triple:...;file_offset:...;file_size...;" |
| 998 | // "EXX" - for any errors |
| 999 | // |
| 1000 | // PRIORITY TO IMPLEMENT |
| 1001 | // Optional, required if dynamic loader cannot fetch module's information like |
| 1002 | // UUID directly from inferior's memory. |
| 1003 | //---------------------------------------------------------------------- |
| 1004 | |
| 1005 | //---------------------------------------------------------------------- |
Greg Clayton | bda72b8 | 2011-11-29 01:44:07 +0000 | [diff] [blame] | 1006 | // Stop reply packet extensions |
| 1007 | // |
| 1008 | // BRIEF |
| 1009 | // This section describes some of the additional information you can |
| 1010 | // specify in stop reply packets that help LLDB to know more detailed |
| 1011 | // information about your threads. |
| 1012 | // |
| 1013 | // DESCRIPTION |
| 1014 | // Standard GDB remote stop reply packets are reply packets sent in |
| 1015 | // response to a packet that made the program run. They come in the |
| 1016 | // following forms: |
| 1017 | // |
| 1018 | // "SAA" |
| 1019 | // "S" means signal and "AA" is a hex signal number that describes why |
| 1020 | // the thread or stopped. It doesn't specify which thread, so the "T" |
| 1021 | // packet is recommended to use instead of the "S" packet. |
| 1022 | // |
| 1023 | // "TAAkey1:value1;key2:value2;..." |
| 1024 | // "T" means a thread stopped due to a unix signal where "AA" is a hex |
| 1025 | // signal number that describes why the program stopped. This is |
| 1026 | // followed by a series of key/value pairs: |
| 1027 | // - If key is a hex number, it is a register number and value is |
| 1028 | // the hex value of the register in debuggee endian byte order. |
| 1029 | // - If key == "thread", then the value is the big endian hex |
| 1030 | // thread-id of the stopped thread. |
Daniel Malea | 4d3c008 | 2013-02-12 20:01:49 +0000 | [diff] [blame] | 1031 | // - If key == "core", then value is a hex number of the core on |
Greg Clayton | bda72b8 | 2011-11-29 01:44:07 +0000 | [diff] [blame] | 1032 | // which the stop was detected. |
| 1033 | // - If key == "watch" or key == "rwatch" or key == "awatch", then |
| 1034 | // value is the data address in big endian hex |
| 1035 | // - If key == "library", then value is ignore and "qXfer:libraries:read" |
| 1036 | // packets should be used to detect any newly loaded shared libraries |
| 1037 | // |
| 1038 | // "WAA" |
| 1039 | // "W" means the process exited and "AA" is the exit status. |
| 1040 | // |
| 1041 | // "XAA" |
| 1042 | // "X" means the process exited and "AA" is signal that caused the program |
| 1043 | // to exit. |
| 1044 | // |
| 1045 | // "O<ascii-hex-string>" |
| 1046 | // "O" means STDOUT has data that was written to its console and is |
| 1047 | // being delivered to the debugger. This packet happens asynchronously |
Stephane Sezer | e5f27de | 2014-11-20 18:50:16 +0000 | [diff] [blame] | 1048 | // and the debugger is expected to continue to wait for another stop reply |
Greg Clayton | bda72b8 | 2011-11-29 01:44:07 +0000 | [diff] [blame] | 1049 | // packet. |
| 1050 | // |
| 1051 | // LLDB EXTENSIONS |
| 1052 | // |
| 1053 | // We have extended the "T" packet to be able to also understand the |
| 1054 | // following keys and values: |
| 1055 | // |
| 1056 | // KEY VALUE DESCRIPTION |
| 1057 | // =========== ======== ================================================ |
| 1058 | // "metype" unsigned mach exception type (the value of the EXC_XXX enumerations) |
| 1059 | // as an unsigned integer. For targets with mach |
| 1060 | // kernels only. |
| 1061 | // |
| 1062 | // "mecount" unsigned mach exception data count as an unsigned integer |
| 1063 | // For targets with mach kernels only. |
| 1064 | // |
| 1065 | // "medata" unsigned There should be "mecount" of these and it is the data |
| 1066 | // that goes along with a mach exception (as an unsigned |
| 1067 | // integer). For targets with mach kernels only. |
| 1068 | // |
| 1069 | // "name" string The name of the thread as a plain string. The string |
| 1070 | // must not contain an special packet characters or |
| 1071 | // contain a ':' or a ';'. Use "hexname" if the thread |
| 1072 | // name has special characters. |
| 1073 | // |
| 1074 | // "hexname" ascii-hex An ASCII hex string that contains the name of the thread |
| 1075 | // |
| 1076 | // "qaddr" hex Big endian hex value that contains the libdispatch |
| 1077 | // queue address for the queue of the thread. |
| 1078 | // |
| 1079 | // "reason" enum The enumeration must be one of: |
| 1080 | // "trace" the program stopped after a single instruction |
| 1081 | // was executed on a core. Usually done when single |
| 1082 | // stepping past a breakpoint |
| 1083 | // "breakpoint" a breakpoint set using a 'z' packet was hit. |
| 1084 | // "trap" stopped due to user interruption |
| 1085 | // "signal" stopped due to an actual unix signal, not |
| 1086 | // just the debugger using a unix signal to keep |
| 1087 | // the GDB remote client happy. |
| 1088 | // "watchpoint". Should be used in conjunction with |
| 1089 | // the "watch"/"rwatch"/"awatch" key value pairs. |
| 1090 | // "exception" an exception stop reason. Use with |
| 1091 | // the "description" key/value pair to describe the |
| 1092 | // exceptional event the user should see as the stop |
| 1093 | // reason. |
| 1094 | // "description" ascii-hex An ASCII hex string that contains a more descriptive |
| 1095 | // reason that the thread stopped. This is only needed |
| 1096 | // if none of the key/value pairs are enough to |
| 1097 | // describe why something stopped. |
| 1098 | // |
| 1099 | // BEST PRACTICES: |
| 1100 | // Since register values can be supplied with this packet, it is often useful |
Daniel Malea | 4d3c008 | 2013-02-12 20:01:49 +0000 | [diff] [blame] | 1101 | // to return the PC, SP, FP, LR (if any), and FLAGS registers so that separate |
Greg Clayton | bda72b8 | 2011-11-29 01:44:07 +0000 | [diff] [blame] | 1102 | // packets don't need to be sent to read each of these registers from each |
| 1103 | // thread. |
| 1104 | // |
| 1105 | // If a thread is stopped for no reason (like just because another thread |
| 1106 | // stopped, or because when one core stops all cores should stop), use a |
| 1107 | // "T" packet with "00" as the signal number and fill in as many key values |
| 1108 | // and registers as possible. |
| 1109 | // |
Daniel Malea | 4d3c008 | 2013-02-12 20:01:49 +0000 | [diff] [blame] | 1110 | // LLDB likes to know why a thread stopped since many thread control |
Greg Clayton | bda72b8 | 2011-11-29 01:44:07 +0000 | [diff] [blame] | 1111 | // operations like stepping over a source line, actually are implemented |
| 1112 | // by running the process multiple times. If a breakpoint is hit while |
| 1113 | // trying to step over a source line and LLDB finds out that a breakpoint |
| 1114 | // is hit in the "reason", we will know to stop trying to do the step |
| 1115 | // over because something happened that should stop us from trying to |
| 1116 | // do the step. If we are at a breakpoint and we disable the breakpoint |
| 1117 | // at the current PC and do an instruction single step, knowing that |
| 1118 | // we stopped due to a "trace" helps us know that we can continue |
| 1119 | // running versus stopping due to a "breakpoint" (if we have two |
Daniel Malea | 4d3c008 | 2013-02-12 20:01:49 +0000 | [diff] [blame] | 1120 | // breakpoint instruction on consecutive instructions). So the more info |
Greg Clayton | bda72b8 | 2011-11-29 01:44:07 +0000 | [diff] [blame] | 1121 | // we can get about the reason a thread stops, the better job LLDB can |
| 1122 | // do when controlling your process. A typical GDB server behavior is |
| 1123 | // to send a SIGTRAP for breakpoints _and_ also when instruction single |
| 1124 | // stepping, in this case the debugger doesn't really know why we |
| 1125 | // stopped and it can make it hard for the debugger to control your |
| 1126 | // program correctly. What if a real SIGTRAP was delivered to a thread |
Daniel Malea | 4d3c008 | 2013-02-12 20:01:49 +0000 | [diff] [blame] | 1127 | // while we were trying to single step? We wouldn't know the difference |
Greg Clayton | bda72b8 | 2011-11-29 01:44:07 +0000 | [diff] [blame] | 1128 | // with a standard GDB remote server and we could do the wrong thing. |
| 1129 | // |
| 1130 | // PRIORITY TO IMPLEMENT |
| 1131 | // High. Having the extra information in your stop reply packets makes |
| 1132 | // your debug session more reliable and informative. |
| 1133 | //---------------------------------------------------------------------- |
| 1134 | |
Daniel Malea | e0f8f57 | 2013-08-26 23:57:52 +0000 | [diff] [blame] | 1135 | |
| 1136 | //---------------------------------------------------------------------- |
| 1137 | // PLATFORM EXTENSION - for use as a GDB remote platform |
| 1138 | //---------------------------------------------------------------------- |
| 1139 | // "qfProcessInfo" |
| 1140 | // "qsProcessInfo" |
| 1141 | // |
| 1142 | // BRIEF |
Bruce Mitchener | d93c4a3 | 2014-07-01 21:22:11 +0000 | [diff] [blame] | 1143 | // Get the first process info (qfProcessInfo) or subsequent process |
Daniel Malea | e0f8f57 | 2013-08-26 23:57:52 +0000 | [diff] [blame] | 1144 | // info (qsProcessInfo) for one or more processes on the remote |
| 1145 | // platform. The first call gets the first match and subsequent calls |
| 1146 | // to qsProcessInfo gets the subsequent matches. Return an error EXX, |
| 1147 | // where XX are two hex digits, when no more matches are available. |
| 1148 | // |
| 1149 | // PRIORITY TO IMPLEMENT |
| 1150 | // Required. The qfProcessInfo packet can be followed by a ':' and |
| 1151 | // some key value pairs. The key value pairs in the command are: |
| 1152 | // |
| 1153 | // KEY VALUE DESCRIPTION |
| 1154 | // =========== ======== ================================================ |
| 1155 | // "name" ascii-hex An ASCII hex string that contains the name of |
| 1156 | // the process that will be matched. |
| 1157 | // "name_match" enum One of: "equals", "starts_with", "ends_with", |
| 1158 | // "contains" or "regex" |
| 1159 | // "pid" integer A string value containing the decimal process ID |
| 1160 | // "parent_pid" integer A string value containing the decimal parent |
| 1161 | // process ID |
| 1162 | // "uid" integer A string value containing the decimal user ID |
| 1163 | // "gid" integer A string value containing the decimal group ID |
| 1164 | // "euid" integer A string value containing the decimal effective user ID |
| 1165 | // "egid" integer A string value containing the decimal effective group ID |
| 1166 | // "all_users" bool A boolean value that specifies if processes should |
| 1167 | // be listed for all users, not just the user that the |
| 1168 | // platform is running as |
Matthew Gardiner | f39ebbe | 2014-08-01 05:12:23 +0000 | [diff] [blame] | 1169 | // "triple" string An ASCII triple string ("x86_64", |
Daniel Malea | e0f8f57 | 2013-08-26 23:57:52 +0000 | [diff] [blame] | 1170 | // "x86_64-apple-macosx", "armv7-apple-ios") |
| 1171 | // |
| 1172 | // The response consists of key/value pairs where the key is separated from the |
| 1173 | // values with colons and each pair is terminated with a semi colon. For a list |
| 1174 | // of the key/value pairs in the response see the "qProcessInfoPID" packet |
| 1175 | // documentation. |
| 1176 | // |
| 1177 | // Sample packet/response: |
| 1178 | // send packet: $qfProcessInfo#00 |
Matthew Gardiner | f39ebbe | 2014-08-01 05:12:23 +0000 | [diff] [blame] | 1179 | // read packet: $pid:60001;ppid:59948;uid:7746;gid:11;euid:7746;egid:11;name:6c6c6462;triple:x86_64-apple-macosx;#00 |
Daniel Malea | e0f8f57 | 2013-08-26 23:57:52 +0000 | [diff] [blame] | 1180 | // send packet: $qsProcessInfo#00 |
Matthew Gardiner | f39ebbe | 2014-08-01 05:12:23 +0000 | [diff] [blame] | 1181 | // read packet: $pid:59992;ppid:192;uid:7746;gid:11;euid:7746;egid:11;name:6d64776f726b6572;triple:x86_64-apple-macosx;#00 |
Daniel Malea | e0f8f57 | 2013-08-26 23:57:52 +0000 | [diff] [blame] | 1182 | // send packet: $qsProcessInfo#00 |
| 1183 | // read packet: $E04#00 |
| 1184 | //---------------------------------------------------------------------- |
| 1185 | |
| 1186 | |
| 1187 | //---------------------------------------------------------------------- |
| 1188 | // PLATFORM EXTENSION - for use as a GDB remote platform |
| 1189 | //---------------------------------------------------------------------- |
| 1190 | // "qLaunchGDBServer" |
| 1191 | // |
| 1192 | // BRIEF |
| 1193 | // Have the remote platform launch a GDB server. |
| 1194 | // |
| 1195 | // PRIORITY TO IMPLEMENT |
| 1196 | // Required. The qLaunchGDBServer packet must be followed by a ':' and |
| 1197 | // some key value pairs. The key value pairs in the command are: |
| 1198 | // |
| 1199 | // KEY VALUE DESCRIPTION |
| 1200 | // =========== ======== ================================================ |
| 1201 | // "port" integer A string value containing the decimal port ID or |
| 1202 | // zero if the port should be bound and returned |
| 1203 | // |
| 1204 | // "host" integer The host that connections should be limited to |
| 1205 | // when the GDB server is connected to. |
| 1206 | // |
| 1207 | // The response consists of key/value pairs where the key is separated from the |
| 1208 | // values with colons and each pair is terminated with a semi colon. |
| 1209 | // |
| 1210 | // Sample packet/response: |
| 1211 | // send packet: $qLaunchGDBServer:port:0;host:lldb.apple.com;#00 |
| 1212 | // read packet: $pid:60025;port:50776;#00 |
| 1213 | // |
| 1214 | // The "pid" key/value pair is only specified if the remote platform launched |
| 1215 | // a separate process for the GDB remote server and can be omitted if no |
| 1216 | // process was separately launched. |
| 1217 | // |
| 1218 | // The "port" key/value pair in the response lets clients know what port number |
| 1219 | // to attach to in case zero was specified as the "port" in the sent command. |
| 1220 | //---------------------------------------------------------------------- |
| 1221 | |
| 1222 | |
| 1223 | //---------------------------------------------------------------------- |
| 1224 | // PLATFORM EXTENSION - for use as a GDB remote platform |
| 1225 | //---------------------------------------------------------------------- |
| 1226 | // "qProcessInfoPID:PID" |
| 1227 | // |
| 1228 | // BRIEF |
| 1229 | // Have the remote platform get detailed information on a process by |
| 1230 | // ID. PID is specified as a decimal integer. |
| 1231 | // |
| 1232 | // PRIORITY TO IMPLEMENT |
| 1233 | // Optional. |
| 1234 | // |
| 1235 | // The response consists of key/value pairs where the key is separated from the |
| 1236 | // values with colons and each pair is terminated with a semi colon. |
| 1237 | // |
| 1238 | // The key value pairs in the response are: |
| 1239 | // |
| 1240 | // KEY VALUE DESCRIPTION |
| 1241 | // =========== ======== ================================================ |
| 1242 | // "pid" integer Process ID as a decimal integer string |
| 1243 | // "ppid" integer Parent process ID as a decimal integer string |
| 1244 | // "uid" integer A string value containing the decimal user ID |
| 1245 | // "gid" integer A string value containing the decimal group ID |
| 1246 | // "euid" integer A string value containing the decimal effective user ID |
| 1247 | // "egid" integer A string value containing the decimal effective group ID |
| 1248 | // "name" ascii-hex An ASCII hex string that contains the name of the process |
Matthew Gardiner | f39ebbe | 2014-08-01 05:12:23 +0000 | [diff] [blame] | 1249 | // "triple" string A target triple ("x86_64-apple-macosx", "armv7-apple-ios") |
Daniel Malea | e0f8f57 | 2013-08-26 23:57:52 +0000 | [diff] [blame] | 1250 | // |
| 1251 | // Sample packet/response: |
| 1252 | // send packet: $qProcessInfoPID:60050#00 |
Matthew Gardiner | f39ebbe | 2014-08-01 05:12:23 +0000 | [diff] [blame] | 1253 | // read packet: $pid:60050;ppid:59948;uid:7746;gid:11;euid:7746;egid:11;name:6c6c6462;triple:x86_64-apple-macosx;#00 |
Daniel Malea | e0f8f57 | 2013-08-26 23:57:52 +0000 | [diff] [blame] | 1254 | //---------------------------------------------------------------------- |
Jim Ingham | 7b11300 | 2014-05-09 16:17:24 +0000 | [diff] [blame] | 1255 | |
| 1256 | //---------------------------------------------------------------------- |
| 1257 | // "vAttachName" |
| 1258 | // |
| 1259 | // BRIEF |
| 1260 | // Same as vAttach, except instead of a "pid" you send a process name. |
| 1261 | // |
| 1262 | // PRIORITY TO IMPLEMENT |
| 1263 | // Low. Only needed for "process attach -n". If the packet isn't supported |
| 1264 | // then "process attach -n" will fail gracefully. So you need only to support |
| 1265 | // it if attaching to a process by name makes sense for your environment. |
| 1266 | //---------------------------------------------------------------------- |
| 1267 | |
| 1268 | //---------------------------------------------------------------------- |
| 1269 | // "vAttachWait" |
| 1270 | // |
| 1271 | // BRIEF |
| 1272 | // Same as vAttachName, except that the stub should wait for the next instance |
| 1273 | // of a process by that name to be launched and attach to that. |
| 1274 | // |
| 1275 | // PRIORITY TO IMPLEMENT |
| 1276 | // Low. Only needed to support "process attach -w -n" which will fail |
| 1277 | // gracefully if the packet is not supported. |
| 1278 | //---------------------------------------------------------------------- |
| 1279 | |
| 1280 | //---------------------------------------------------------------------- |
| 1281 | // "qAttachOrWaitSupported" |
| 1282 | // |
| 1283 | // BRIEF |
| 1284 | // This is a binary "is it supported" query. Return OK if you support |
| 1285 | // vAttachOrWait |
| 1286 | // |
| 1287 | // PRIORITY TO IMPLEMENT |
| 1288 | // Low. This is required if you support vAttachOrWait, otherwise no support |
| 1289 | // is needed since the standard "I don't recognize this packet" response |
| 1290 | // will do the right thing. |
| 1291 | //---------------------------------------------------------------------- |
| 1292 | |
| 1293 | //---------------------------------------------------------------------- |
| 1294 | // "vAttachOrWait" |
| 1295 | // |
| 1296 | // BRIEF |
| 1297 | // Same as vAttachWait, except that the stub will attach to a process |
| 1298 | // by name if it exists, and if it does not, it will wait for a process |
| 1299 | // of that name to appear and attach to it. |
| 1300 | // |
| 1301 | // PRIORITY TO IMPLEMENT |
| 1302 | // Low. Only needed to implement "process attach -w -i false -n". If |
| 1303 | // you don't implement it but do implement -n AND lldb can somehow get |
| 1304 | // a process list from your device, it will fall back on scanning the |
| 1305 | // process list, and sending vAttach or vAttachWait depending on |
| 1306 | // whether the requested process exists already. This is racy, |
| 1307 | // however, so if you want to support this behavior it is better to |
| 1308 | // support this packet. |
| 1309 | //---------------------------------------------------------------------- |
Jason Molenda | 821a21e | 2014-06-13 22:40:47 +0000 | [diff] [blame] | 1310 | |
| 1311 | //---------------------------------------------------------------------- |
| 1312 | // "jThreadExtendedInfo" |
| 1313 | // |
| 1314 | // BRIEF |
| 1315 | // This packet, which takes its arguments as JSON and sends its reply as |
| 1316 | // JSON, allows the gdb remote stub to provide additional information |
| 1317 | // about a given thread. |
| 1318 | // |
| 1319 | // PRIORITY TO IMPLEMENT |
| 1320 | // Low. This packet is only needed if the gdb remote stub wants to |
| 1321 | // provide interesting additional information about a thread for the |
| 1322 | // user. |
| 1323 | // |
| 1324 | // This packet takes its arguments in JSON form ( http://www.json.org ). |
| 1325 | // At a minimum, a thread must be specified, for example: |
| 1326 | // |
| 1327 | // jThreadExtendedInfo:{"thread":612910} |
| 1328 | // |
| 1329 | // Because this is a JSON string, the thread number is provided in base10. |
| 1330 | // Additional key-value pairs may be provided by lldb to the gdb remote |
| 1331 | // stub. For instance, on some versions of Mac OS X, lldb can read offset |
| 1332 | // information out of the system libraries. Using those offsets, debugserver |
| 1333 | // is able to find the Thread Specific Address (TSD) for a thread and include |
| 1334 | // that in the return information. So lldb will send these additional fields |
| 1335 | // like so: |
| 1336 | // |
| 1337 | // jThreadExtendedInfo:{"plo_pthread_tsd_base_address_offset":0,"plo_pthread_tsd_base_offset":224,"plo_pthread_tsd_entry_size":8,"thread":612910} |
| 1338 | // |
| 1339 | // There are no requirements for what is included in the response. A simple |
| 1340 | // reply on a Mac OS X Yosemite / iOS 8 may include the pthread_t value, the |
| 1341 | // Thread Specific Data (TSD) address, the dispatch_queue_t value if the thread |
| 1342 | // is associated with a GCD queue, and the requested Quality of Service (QoS) |
| 1343 | // information about that thread. For instance, a reply may look like: |
| 1344 | // |
| 1345 | // {"tsd_address":4371349728,"requested_qos":{"enum_value":33,"constant_name":"QOS_CLASS_USER_INTERACTIVE","printable_name":"User Interactive"},"pthread_t":4371349504,"dispatch_queue_t":140735087127872} |
| 1346 | // |
| 1347 | // tsd_address, pthread_t, and dispatch_queue_t are all simple key-value pairs. |
| 1348 | // The JSON standard requires that numbers be expressed in base 10 - so all of |
| 1349 | // these are. requested_qos is a dictionary with three key-value pairs in it - |
| 1350 | // so the UI layer may choose the form most appropriate for displaying to the user. |
| 1351 | // |
| 1352 | // Sending JSON over gdb-remote protocol introduces some problems. We may be |
| 1353 | // sending strings with arbitrary contents in them, including the '#', '$', and '*' |
| 1354 | // characters that have special meaning in gdb-remote protocol and cannot occur |
| 1355 | // in the middle of the string. The standard solution for this would be to require |
Bruce Mitchener | d93c4a3 | 2014-07-01 21:22:11 +0000 | [diff] [blame] | 1356 | // ascii-hex encoding of all strings, or ascii-hex encode the entire JSON payload. |
Jason Molenda | 821a21e | 2014-06-13 22:40:47 +0000 | [diff] [blame] | 1357 | // |
| 1358 | // Instead, the binary escaping convention is used for JSON data. This convention |
| 1359 | // (e.g. used for the X packet) says that if '#', '$', '*', or '}' are to occur in |
| 1360 | // the payload, the character '}' (0x7d) is emitted, then the metacharacter is emitted |
| 1361 | // xor'ed by 0x20. The '}' character occurs in every JSON payload at least once, and |
| 1362 | // '}' ^ 0x20 happens to be ']' so the raw packet characters for a request will look |
| 1363 | // like |
| 1364 | // |
| 1365 | // jThreadExtendedInfo:{"thread":612910}] |
| 1366 | // |
| 1367 | // on the wire. |
| 1368 | //---------------------------------------------------------------------- |