This was encountered while debugging a cortex m4 board with a Segger J-Link v 6.54. It only supports g/G for reading/writing registers, and it supports an xml register description. The register description includes the GPRs, the exception registers, and the floating point registers. But g only provides the general purpose registers.
lldb accepts a g response that is too large for the expected register context size, but it treats a too-small payload as an error. This change accepts a too-small payload, marking registers not included in the payload as being unavailable for retrieval (so "register read msp" will return the error that the register is unavailable).
The J-Link will accept a G packet (set registers) for the entire register context, so I didn't try to change the write registers path to recognize a register buffer where all the final registers are unavailable, and truncate the payload it sends.
I wrote a small gdb_remote_client test for this.
maybe just m_reg_valid[i] = reginfo->byte_offset + reginfo->byte_size <= buffer_sp->GetByteSize()