I’ve been adding support for the qXfer:features:read:target.xml message for our tools at $WORK and have run into a couple hiccups to puzzle over.
First off, the request message as defined at https://sourceware.org/gdb/onlinedocs/gdb/General-Query-Packets.html#qXfer%20target%20description%20read is in the form qXfer:features:read:annex:offset,size. When talking to GDB it works to respond with a ‘l’ or ‘m’ message smaller than size, then GDB proceeds to request the next chunk, and so on until the debug server says there is no more data. I believe there is a bug in lldb’s handling of this message in that if the response is shorter than ‘size’ while also being incomplete, lldb requests the next chunk with a giant offset. This patch fixes the behavior: