Skip to content

Instantly share code, notes, and snippets.

@SrimantaBarua
Last active August 25, 2017 21:38
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save SrimantaBarua/e216b557aa1ecbcc7c2963cd35827098 to your computer and use it in GitHub Desktop.
Save SrimantaBarua/e216b557aa1ecbcc7c2963cd35827098 to your computer and use it in GitHub Desktop.

GSoC '17 Final submission

Project

Remote debugging with gdbserver [for radare2]

My contribution

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.

  1. Reorganized the existing gdb-specific codebase
  2. Implemented a gdbserver inside radare2. Specifically -
    1. Added support for breakpoints, single-stepping, continue, and register/memory read/write.
    2. Added ability to specify executed file name and offset of text section, to the gdbserver, thus enabling source-level debugging with gdb.
    3. Also added a subcommand to enable protocol debugging, similar to the --remote-debug option in gdbserver.
  3. Fixed issues in radare2's existing gdb client implementation -
    1. Limiting packet size based on capabilities of target. If the target does not report packet-size capabilities, setting sensible, customizable defaults.
    2. Selecting correct pid and tid.
    3. Setting the program counter correctly after breakpoint for x86 (x86_64).
    4. Proper handling of target program termination (signal, exit status, etc.).
  4. Added features to radare2's gdb client -
    1. Reading memory maps with radare2's dm command.
    2. Speed up debugging with support for no-ack mode, and grouping memory reads together into bigger blocks.
    3. pid/tid-specific continue
    4. 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.
    5. Kill signals, monitor commands, and the ability to detach from a remote target without killing it
    6. Reading and parsing XML target descriptions if the gdbserver supports it
    7. Initial compatibility with the gdb protocol implementation in lldb-server
    8. Automatic loading of symbols from binary if locally present, and rebasing of said symbols by the correct offset as reported by the gdbserver

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment