This is the mail archive of the gdb@sourceware.org mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

remote packet size for memory read


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




Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]