-
-
Notifications
You must be signed in to change notification settings - Fork 64
Description
This is a meta-issue to discuss + track gdbstub's LLDB compatibility story.
Overview
LLDB uses the GDB Remote Serial Protocol for remote debugging, and for the most part, LLDB works "out of the box" with GDB server implementations. Unfortunately, there are some differences between how LLDB and GDB implement the Remote Serial Protocol, resulting in potential issues when mixing and matching servers/clients.
In some cases, LLDB has added new protocol extensions that are disjoint from (and therefore backwards compatible with) the base GDB protocol. The de-facto documentation for these LLDB specific extensions can be found here:
- https://github.com/llvm/llvm-project/blob/main/lldb/docs/lldb-gdb-remote.txt
- https://github.com/llvm/llvm-project/blob/main/lldb/docs/lldb-platform-packets.txt
Unfortunately, there are some cases where LLDB happened to implement certain packets differently from GDB, resulting in breaking incompatibilities. The most pertinent example of this is wrt how LLDB handles vFile packets. This blog post does a good job providing an overview of the various LLDB-GDB RSP compatibility hazards: https://www.moritz.systems/blog/improving-gdb-protocol-compatibility-in-lldb/
Moreover, as mentioned in the blog post above, LLDB has actually made breaking changes to its RSP between versions! Unlike GDB, using a newer LLDB client with an older LLDB server is not supported!
Supporting LLDB clients in gdbstub
With these challenges in mind, what would be the best way to support LLDB clients in gdbstub?
For the most part, it should be pretty straightforward to support arbitrary LLDB extensions in gdbstub. After all, adding support for any particular LLDB packet should be no different from adding support for a new GDB packet.
Indeed, the bulk of the complexity in supporting LLDB clients is figuring out how to handle the inconsistencies between the LLDB and GDB RSPs.
- Should
gdbstubinclude some kind of configuration to target a specific LLDB protocol version? - Would it be feasible to somehow support all LLDB clients via some kind of version-detection mechanism?
- Should LLDB extensions "bleed into" the existing APIs, or should LLDB extensions be clearly marked as "separate" from the main GDB protocol?
- e.g: should the existing vFile:open API be updated to include LLDB-specific vFile:open flags?
- Older versions of LLDB used a custom
qRegisterInfopacket to fetch a target's register description, though newer versions of LLDB support parsingtarget.xmldata. Shouldgdbstubattempt to "unify"qRegisterInfowithtarget.xmlvia theArchtrait, thereby enabling transparent support across all GDB and LLDB clients?
These are open questions, and ones that I don't have answers to just yet. I suspect the only way to answer these questions will be by someone putting in the legwork to try some ideas out, and seeing how the things look.