Remote debugging with gdbserver [for radare2]
My commits to the main radare2 repository can be found here.
Note: The original plan for the project was a gdbserver implementation. However, adapting to the requirements of the radare2 community, the actual work done during GSoC focused more on radare2's internal gdb client.
- Reorganized the existing gdb-specific codebase
- Implemented a gdbserver inside radare2. Specifically -
- Added support for breakpoints, single-stepping, continue, and register/memory read/write.
- Added ability to specify executed file name and offset of text section, to the gdbserver, thus enabling source-level debugging with gdb.
- Also added a subcommand to enable protocol debugging, similar to the
--remote-debug
option in gdbserver.
- Fixed issues in radare2's existing gdb client implementation -
- Limiting packet size based on capabilities of target. If the target does not report packet-size capabilities, setting sensible, customizable defaults.
- Selecting correct pid and tid.
- Setting the program counter correctly after breakpoint for x86 (x86_64).
- Proper handling of target program termination (signal, exit status, etc.).
- Added features to radare2's gdb client -
- Reading memory maps with radare2's
dm
command. - Speed up debugging with support for no-ack mode, and grouping memory reads together into bigger blocks.
- pid/tid-specific continue
- Getting information on target threads and switching the currently active thread. Also switch to the thread which caused the target to stop in case of a breakpoint.
- Kill signals, monitor commands, and the ability to detach from a remote target without killing it
- Reading and parsing XML target descriptions if the gdbserver supports it
- Initial compatibility with the gdb protocol implementation in lldb-server
- Automatic loading of symbols from binary if locally present, and rebasing of said symbols by the correct offset as reported by the gdbserver
- Reading memory maps with radare2's
In addition to my work for GSoC, I added IPv6 support to the pcap plugin I'd written for the radare2-extras repository, and also added it to radare2's package manager.