GDB - hardware server

Simon Marchi
Mon May 3 14:35:52 GMT 2021

On 2021-05-03 2:19 a.m., Mahesh Bodapati wrote:
> Thank You.
> It looks like I didn't frame my problem correctly.
> server is sending the target descriptions but I have the problem when there is a mismatch between the "expected number of bytes" and "got number of bytes"
> for instance,
> gdb has been built for 32 bit abi by default then 
> case 1:
> if server send 32 bit target description then we didn't see any error
> case 2 :
> if server send 64 bit target descriptions then it results an error saying mismatch between  "expected number of bytes" and "got number of bytes"

Does this "wrong number of bytes" happens when parsing a g packet (read
registers packet)?  This is typically what I've seen.

When you return a target description, that describes all the registers
that are going to be included in the g packets.  So if GDB is saying
this, I would first verify that the registers you return in the g packet
really match what you are describing in the target description.

After connecting to your target, you could use some GDB commands to
determine what GDB expects the expected layout of the g register to be.
>From memory, I think this is "maintenance print registers".  You can
also use "maintenance print xml-tdesc" to make GDB print in XML what it
thinks the target description for the current inferior is.

> and my question is "how can we support 2nd case ? "
> can we switch the ABI when we receive 64 bit target description from server ? if yes, how can we do that?
> or do we need to build a different gdb for 64 bit ABI?

No, in theory it's all supposed to work, as long as you've included the
support for all the architectures you're going to use in the GDB builds.
I didn't work a lot on target descriptions, so there may be some other
important details I'm not aware of.


More information about the Gdb mailing list