This is the mail archive of the
gdb@sourceware.org
mailing list for the GDB project.
remote packet size for memory read
- From: Christian Groessler <chris at groessler dot org>
- To: gdb at sourceware dot org
- Date: Tue, 02 Jul 2013 10:44:23 +0200
- Subject: remote packet size for memory read
- References: <51D29213 dot 2050801 at groessler dot org>
Hi,
our remote stub reports a maximum transfer size of 0x1ff:
Sending packet: $qSupported:multiprocess+;qRelocInsn+#2a...Ack
Packet received: PacketSize=1ff
I have the following definitions in my program:
char mystring253[253] = "253 byte string";
char mystring254[254] = "254 byte string";
Now when I try to print them, I get
(gdb) p mystring253
Sending packet: $m201574c,fd#f9...Ack
Packet received:
323533206279746520737472696e6700000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
$1 = "253 byte string", '\000' <repeats 237 times>
(gdb) p mystring254
Sending packet: $m2015849,fe#d1...Ack
Packet received: E01
Cannot access memory at address 0x2015849
(gdb)
For mystring254 gdb requested 254 data bytes, which, together with the
frame bytes, would exceed
the 0x1ff maximum packet size.
The documentation for "PacketSize" says
‘PacketSize=bytes’
The remote stub can accept packets up to at least bytes in length.
gdb will send packets up to this size for bulk transfers, and will
never send larger packets. This is a limit on the data characters in
the packet, including the frame and checksum. There is no trailing
NUL byte in a remote protocol packet; if the stub stores packets in
a NUL-terminated format, it should allow an extra byte in its buffer
for the NUL. If this stub feature is not supported, gdb guesses
based on the size of the ‘g’ packet response.
I looked at remote.c and for read packets the frame bytes aren't
accounted for. It looks like gdb will request (PacketSize/2) bytes from
the stub, and
the stub should send as much as it can (since we have a 0x1ff bytes
transfer buffer, this would be ((PacketSize - 4)/2).
Correct?
And I think there is a potential problem when parsing the returned data.
remote_read_bytes(remote.c) depends on hex2bin returning
the received length if it encounters a 0 byte. But as far as I could
follow, the receive buffer was only xmalloc'ed and not zero
initialized.
regards,
chris