1### Description 2 3<!-- Please include a brief description of what is being added/changed --> 4 5e.g: This PR implements the `foobar` extension, based off the GDB documentation [here](https://sourceware.org/gdb/onlinedocs/gdb/Remote-Protocol.html). 6 7Closes #(issue number) <!-- if appropriate --> 8 9### API Stability 10 11- [ ] This PR does not require a breaking API change 12 13<!-- If it does require making a breaking API change, please elaborate why --> 14 15### Checklist 16 17<!-- CI takes care of a lot of things, but there are some things that have yet to be automated --> 18 19- Documentation 20 - [ ] Ensured any public-facing `rustdoc` formatting looks good (via `cargo doc`) 21 - [ ] (if appropriate) Added feature to "Debugging Features" in README.md 22- Validation 23 - [ ] Included output of running `examples/armv4t` with `RUST_LOG=trace` + any relevant GDB output under the "Validation" section below 24 - [ ] Included output of running `./example_no_std/check_size.sh` before/after changes under the "Validation" section below 25- _If implementing a new protocol extension IDET_ 26 - [ ] Included a basic sample implementation in `examples/armv4t` 27 - [ ] IDET can be optimized out (confirmed via `./example_no_std/check_size.sh`) 28 - [ ] **OR** implementation requires introducing non-optional binary bloat (please elaborate under "Description") 29- _If upstreaming an `Arch` implementation_ 30 - [ ] I have tested this code in my project, and to the best of my knowledge, it is working as intended. 31 32<!-- Oh, and if you're integrating `gdbstub` in an open-source project, do consider updating the README.md's "Real World Examples" section to link back to your project! --> 33 34### Validation 35 36<!-- example output, from https://github.com/daniel5151/gdbstub/pull/54 --> 37 38<details> 39<summary>GDB output</summary> 40 41``` 42!!!!! EXAMPLE OUTPUT !!!!! 43 44(gdb) info mem 45Using memory regions provided by the target. 46Num Enb Low Addr High Addr Attrs 470 y 0x00000000 0x100000000 rw nocache 48``` 49 50</details> 51 52<details> 53<summary>armv4t output</summary> 54 55``` 56!!!!! EXAMPLE OUTPUT !!!!! 57 58 Finished dev [unoptimized + debuginfo] target(s) in 0.01s 59 Running `target/debug/examples/armv4t` 60loading section ".text" into memory from [0x55550000..0x55550078] 61Setting PC to 0x55550000 62Waiting for a GDB connection on "127.0.0.1:9001"... 63Debugger connected from 127.0.0.1:37142 64 TRACE gdbstub::gdbstub_impl > <-- + 65 TRACE gdbstub::gdbstub_impl > <-- $qSupported:multiprocess+;swbreak+;hwbreak+;qRelocInsn+;fork-events+;vfork-events+;exec-events+;vContSupported+;QThreadEvents+;no-resumed+;xmlRegisters=i386#6a 66 TRACE gdbstub::protocol::response_writer > --> $PacketSize=1000;vContSupported+;multiprocess+;QStartNoAckMode+;ReverseContinue+;ReverseStep+;QDisableRandomization+;QEnvironmentHexEncoded+;QEnvironmentUnset+;QEnvironmentReset+;QStartupWithShell+;QSetWorkingDir+;swbreak+;hwbreak+;qXfer:features:read+;qXfer:memory-map:read+#e4 67 TRACE gdbstub::gdbstub_impl > <-- + 68 TRACE gdbstub::gdbstub_impl > <-- $vMustReplyEmpty#3a 69 INFO gdbstub::gdbstub_impl > Unknown command: vMustReplyEmpty 70 TRACE gdbstub::protocol::response_writer > --> $#00 71 TRACE gdbstub::gdbstub_impl > <-- + 72 TRACE gdbstub::gdbstub_impl > <-- $QStartNoAckMode#b0 73 TRACE gdbstub::protocol::response_writer > --> $OK#9a 74 TRACE gdbstub::gdbstub_impl > <-- + 75 TRACE gdbstub::gdbstub_impl > <-- $Hgp0.0#ad 76 TRACE gdbstub::protocol::response_writer > --> $OK#9a 77 TRACE gdbstub::gdbstub_impl > <-- $qXfer:features:read:target.xml:0,ffb#79 78 TRACE gdbstub::protocol::response_writer > --> $l<target version="1.0"><!-- custom override string --><architecture>armv4t</architecture></target>#bb 79 TRACE gdbstub::gdbstub_impl > <-- $qTStatus#49 80 INFO gdbstub::gdbstub_impl > Unknown command: qTStatus 81 TRACE gdbstub::protocol::response_writer > --> $#00 82 TRACE gdbstub::gdbstub_impl > <-- $?#3f 83 TRACE gdbstub::protocol::response_writer > --> $S05#b8 84 TRACE gdbstub::gdbstub_impl > <-- $qfThreadInfo#bb 85 TRACE gdbstub::protocol::response_writer > --> $mp01.01#cd 86 TRACE gdbstub::gdbstub_impl > <-- $qsThreadInfo#c8 87 TRACE gdbstub::protocol::response_writer > --> $l#6c 88 TRACE gdbstub::gdbstub_impl > <-- $qAttached:1#fa 89GDB queried if it was attached to a process with PID 1 90 TRACE gdbstub::protocol::response_writer > --> $1#31 91 TRACE gdbstub::gdbstub_impl > <-- $Hc-1#09 92 TRACE gdbstub::protocol::response_writer > --> $OK#9a 93 TRACE gdbstub::gdbstub_impl > <-- $qC#b4 94 INFO gdbstub::gdbstub_impl > Unknown command: qC 95 TRACE gdbstub::protocol::response_writer > --> $#00 96 TRACE gdbstub::gdbstub_impl > <-- $g#67 97 TRACE gdbstub::protocol::response_writer > --> $00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000107856341200005555xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx10000000#66 98 TRACE gdbstub::gdbstub_impl > <-- $qfThreadInfo#bb 99 TRACE gdbstub::protocol::response_writer > --> $mp01.01#cd 100 TRACE gdbstub::gdbstub_impl > <-- $qsThreadInfo#c8 101 TRACE gdbstub::protocol::response_writer > --> $l#6c 102 TRACE gdbstub::gdbstub_impl > <-- $qXfer:memory-map:read::0,ffb#18 103 TRACE gdbstub::protocol::response_writer > --> $l<?xml version="1.0"?> 104<!DOCTYPE memory-map 105 PUBLIC "+//IDN gnu.org//DTD GDB Memory Map V1.0//EN" 106 "http://sourceware.org/gdb/gdb-memory-map.dtd"> 107<memory-map> 108 <memory type="ram" start="0x0" length="0x100000000"/> 109</memory-map>#75 110 TRACE gdbstub::gdbstub_impl > <-- $m55550000,4#61 111 TRACE gdbstub::protocol::response_writer > --> $04b02de5#26 112 TRACE gdbstub::gdbstub_impl > <-- $m5554fffc,4#35 113 TRACE gdbstub::protocol::response_writer > --> $00000000#7e 114 TRACE gdbstub::gdbstub_impl > <-- $m55550000,4#61 115 TRACE gdbstub::protocol::response_writer > --> $04b02de5#26 116 TRACE gdbstub::gdbstub_impl > <-- $m5554fffc,4#35 117 TRACE gdbstub::protocol::response_writer > --> $00000000#7e 118 TRACE gdbstub::gdbstub_impl > <-- $m55550000,2#5f 119 TRACE gdbstub::protocol::response_writer > --> $04b0#f6 120 TRACE gdbstub::gdbstub_impl > <-- $m5554fffe,2#35 121 TRACE gdbstub::protocol::response_writer > --> $0000#7a 122 TRACE gdbstub::gdbstub_impl > <-- $m5554fffc,2#33 123 TRACE gdbstub::protocol::response_writer > --> $0000#7a 124 TRACE gdbstub::gdbstub_impl > <-- $m55550000,2#5f 125 TRACE gdbstub::protocol::response_writer > --> $04b0#f6 126 TRACE gdbstub::gdbstub_impl > <-- $m5554fffe,2#35 127 TRACE gdbstub::protocol::response_writer > --> $0000#7a 128 TRACE gdbstub::gdbstub_impl > <-- $m5554fffc,2#33 129 TRACE gdbstub::protocol::response_writer > --> $0000#7a 130 TRACE gdbstub::gdbstub_impl > <-- $m55550000,4#61 131 TRACE gdbstub::protocol::response_writer > --> $04b02de5#26 132 TRACE gdbstub::gdbstub_impl > <-- $m5554fffc,4#35 133 TRACE gdbstub::protocol::response_writer > --> $00000000#7e 134 TRACE gdbstub::gdbstub_impl > <-- $m55550000,4#61 135 TRACE gdbstub::protocol::response_writer > --> $04b02de5#26 136 TRACE gdbstub::gdbstub_impl > <-- $m5554fffc,4#35 137 TRACE gdbstub::protocol::response_writer > --> $00000000#7e 138 TRACE gdbstub::gdbstub_impl > <-- $m55550000,4#61 139 TRACE gdbstub::protocol::response_writer > --> $04b02de5#26 140 TRACE gdbstub::gdbstub_impl > <-- $m55550000,4#61 141 TRACE gdbstub::protocol::response_writer > --> $04b02de5#26 142 TRACE gdbstub::gdbstub_impl > <-- $m55550000,4#61 143 TRACE gdbstub::protocol::response_writer > --> $04b02de5#26 144 TRACE gdbstub::gdbstub_impl > <-- $m0,4#fd 145 TRACE gdbstub::protocol::response_writer > --> $00000000#7e 146``` 147</details> 148 149<details> 150<summary>Before/After `./example_no_std/check_size.sh` output</summary> 151 152### Before 153 154``` 155!!!!! EXAMPLE OUTPUT !!!!! 156 157target/release/gdbstub-nostd : 158section size addr 159.interp 28 680 160.note.gnu.build-id 36 708 161.note.ABI-tag 32 744 162.gnu.hash 36 776 163.dynsym 360 816 164.dynstr 193 1176 165.gnu.version 30 1370 166.gnu.version_r 48 1400 167.rela.dyn 408 1448 168.init 27 4096 169.plt 16 4128 170.plt.got 8 4144 171.text 15253 4160 172.fini 13 19416 173.rodata 906 20480 174.eh_frame_hdr 284 21388 175.eh_frame 1432 21672 176.init_array 8 28072 177.fini_array 8 28080 178.dynamic 448 28088 179.got 136 28536 180.data 8 28672 181.bss 8 28680 182.comment 43 0 183Total 19769 184``` 185 186### After 187 188``` 189!!!!! EXAMPLE OUTPUT !!!!! 190 191target/release/gdbstub-nostd : 192section size addr 193.interp 28 680 194.note.gnu.build-id 36 708 195.note.ABI-tag 32 744 196.gnu.hash 36 776 197.dynsym 360 816 198.dynstr 193 1176 199.gnu.version 30 1370 200.gnu.version_r 48 1400 201.rela.dyn 408 1448 202.init 27 4096 203.plt 16 4128 204.plt.got 8 4144 205.text 15253 4160 206.fini 13 19416 207.rodata 906 20480 208.eh_frame_hdr 284 21388 209.eh_frame 1432 21672 210.init_array 8 28072 211.fini_array 8 28080 212.dynamic 448 28088 213.got 136 28536 214.data 8 28672 215.bss 8 28680 216.comment 43 0 217Total 19769 218``` 219 220</details> 221