[lldb-dev] [RFC] Improving protocol-level compatibility between LLDB and GDB

Michał Górny via lldb-dev lldb-dev at lists.llvm.org
Mon Apr 19 00:59:36 PDT 2021


Hi, everyone.

I'm considering running some effort to improve protocol-level
compatibility between LLDB and GDB.  I'd like to hear if there's
interest in such patches being accepted into LLDB.

My goal would be to make it possible to use LLDB to connect to gdbserver
(and other servers implementing the same protocol), and to be able to
use full set of debugger's features while doing that.  Ideally, also
connecting to lldb-server from GDB would be supported too.

I think the first blocker towards this project are existing
implementation bugs in LLDB. For example, the vFile implementation is
documented as using incorrect data encoding and open flags. This is not
something that can be trivially fixed without breaking compatibility
between different versions of LLDB.

My current idea would be to add some logic to distinguish the current
(i.e. 'old') versions of LLDB from GDB, and to have new versions of LLDB
indicate GDB protocol fixes via qSupported.

For example, unless I'm mistaken 'QThreadSuffixSupported' is purely
an LLDB extension. Let's say we implement GDB-compatible vFile packets
as 'gdb-compat:vFile' feature.

The client would:

1. Send 'gdb-compat:vFile' in qSupported to indicate that it's ready to
use correct GDB-style packets.

2. Check for server's qSupported response. Now:

- if it contains 'gdb-compat:vFile+', then we're dealing with new
version of lldb-server and we use gdb-style vFile packets,

- otherwise, if it contains 'QThreadSuffixSupported+', then we're
dealing with old version of lldb-server and we use lldb-style vFile
packets,

- otherwise, we assume we're dealing with real GDB, and we use gdb-style
packets.

On the server-side, we would similarly check for 'gdb-compat:vFile+' in
client's qSupported, and for the call to 'QThreadSuffixSupported' to
determine whether we're dealing with GDB or LLDB client.

What do you think?

-- 
Best regards,
Michał Górny





More information about the lldb-dev mailing list