Hi,
Has anyone recently tried to connect lldb-server to GDB (client)?
Please, find the output of my try below.
Target:
$ lldb-server g localhost:1234 ./m
Launched './m' as process 605331...
lldb-server-local_build
Connection established.
lldb-server exiting...
Host:
$ gdb ./m
GNU gdb (GDB) 13.0.50.20221214-git
(gdb) target remote localhost:1234
Remote debugging using localhost:1234
warning: while parsing target description (at line 1): Target description specified unknown architecture "x86_64"
warning: Could not load XML target description; ignoring
Remote register badly formatted: T13thread:93c93;name:m;00:0000000000000000;01:0000000000000000;02:0000000000000000;03:0000000000000000;04:0000000000000000;05:0000000000000000;06:0000000000000000;07:d0d6ffffff7f0000;08:0000000000000000;09:0000000000000000;0a:0000000000000000;0b:0000000000000000;0c:0000000000000000;0d:0000000000000000;0e:0000000000000000;0f:0000000000000000;10:e04fddf7ff7f0000;11:0002000000000000;12:3300000000000000;13:0000000000000000;14:0000000000000000;15:2b00000000000000;16:0000000000000000;17:0000000000000000;reason:signal;
here: 00000000;12:3300000000000000;13:0000000000000000;14:0000000000000000;15:2b00000000000000;16:0000000000000000;17:0000000000000000;reason:signal;
Although both sides comply with GDB Remote Serial Protocol, the session breaks on ‘T’ packet. The actual problem is in General Purpose Register ID numbers (regnum), order and sizes, which are not determined by standard, but LLDB and GDB have different expectations.
Please, find the table below with differences in register info.
Register | GDB | LLDB | ||
---|---|---|---|---|
$rsi | bitsize=64 regnum=4 | bitsize=64 regnum=5 | ||
$rdi | bitsize=64 regnum=5 | bitsize=64 regnum=4 | ||
$eflags ($rflags in LLDB) | bitsize=32 regnum=17 | bitsize=64 regnum=17 | ||
$cs | bitsize=32 regnum=18 | bitsize=64 regnum=18 | ||
$ss | bitsize=32 regnum=19 | bitsize=64 regnum=21 | ||
$ds | bitsize=32 regnum=20 | bitsize=64 regnum=22 | ||
$es | bitsize=32 regnum=21 | bitsize=64 regnum=23 | ||
$fs | bitsize=32 regnum=22 | bitsize=64 regnum=19 | ||
$gs | bitsize=32 regnum=23 | bitsize=64 regnum=20 |
With a workaround in lldb-server, to send registers in ‘T’ packet as GDB expects, I am able to establish communication between GDB and lldb-server, and perform a basic debugging of a simple test case (break, info registers, print vars…). On the other hand, this doesn’t break lldb-server working with lldb (client).
My question is, does anyone know, why those “regnum” and “bitsize” for GPRs are picked (different from GDB) at the first place?
I suppose there are some other incompatibilities that prevent lldb-server and GDB from working together, so does anyone have an idea, how hard it would be to make them fully compatible?
I am sorry if I retriggered already discussed matter or if I missed something, since I don’t have much experience with LLDB.
Thanks,
Nikola