GDB recently (to my surprise – I thought it already had this) implemented the x
packet, but it’s implementation is different from that of lldb. The only difference is that GDB uses a leading b
character in the response in order to disambiguate errors and successful (possibly truncated) responses that happen to begin with an E
.
This has already caused problems for some clients like RR, which implemented the LLDB version of the packet. GDB maintainers are now in the process of implementing a way to detect which flavour is being used by the server.
Given that we have users which use lldb with servers (e.g., qemu) that primarily (or solely) implement the gdb flavour of the protocol, I think it’s only a matter of time before we run into the same problem – a server which implements the gdb definition stops working with lldb.
I propose that we do not wait for these users to show up, but that we pre-emptively add support for the gdb implementation. I think it’d be best to use the same detection mechanism that gdb is going to use. The two options being discussed are to use a zero-length read to probe the server behavior (lldb uses an OK
response to detect support) and a new qSupported
feature string. Both of these seem fine to me, but the advantage of doing it now is that we may also be able to influence the gdb implementation if needed. If it is necessary, I can act as an intermediary between the two groups.
In addition to that, I propose that we start the (probably, multi-year) process of migration to the gdb definition of the packet. The reasons for that are twofold:
- gdb sort of is the official/reference implementation of the protocol (even we define our packets as additions to that).
- frankly, I think the gdb definition is better
I propose the following process:
- LLDB version X adds client support for the gdb implementation of the packet (detects the flavour being used and acts accordingly). Ideally X would be the current release (20). It’s somewhat tricky, as it’s being branched approximately now, but there may still be enough time to do a cherry pick. If not, it means we wait 6 months for the next step.
- LLDB version X+1 changes servers (lldb-server and debugserver) to use the new implementation of the packet. The previous step ensures that they can still work with a slightly older client. If we can get the first step into the current release, then this could be committed to trunk straight away. Otherwise, we wait 6 months.
- LLDB version X+n removes support for the old lldb implementation of the packet. I’m leaving n unspecified because I don’t know what’s the support window for old servers. Apple probably has the longest support window, so I’d go with whatever @jasonmolenda says. I don’t think the compatibility code will be particularly intrusive, so it can stay for quite some time, but it’d be nice to have a plan to remove it eventually. (I’ll also note that removing compatibility will not completely break the servers – it will just cause us to use less efficient
m
packets instead.)