Use get_remote_packet_size in download_tracepoint
authorPedro Franco de Carvalho <pedromfc@linux.ibm.com>
Mon, 6 Aug 2018 19:24:55 +0000 (16:24 -0300)
committerPedro Franco de Carvalho <pedromfc@linux.ibm.com>
Mon, 6 Aug 2018 19:34:02 +0000 (16:34 -0300)
commit3df3a985a475db004706d64f83d9085f99053611
tree8d8deacf37b3584fe8c01b0494f35f279459550f
parentaa6f3694ce867884e43d1c0406c64df08ea24bd3
Use get_remote_packet_size in download_tracepoint

This patch changes the remote target to use the remote packet size to
build QTDP packets, and to check if there is enough room for the
packet.

I changed the function to raise an error if the packet is too small,
instead of aborting gdb (through xsnprintf).  It isn't clear if gdb
will be in a consistent state with respect to the stub after this,
since it's possible that some packets will be sent but not others, and
there could be an incomplete tracepoint on the stub.

The char array used to build the packets is changed to a
gdb::char_vector and sized with the result from
get_remote_packet_size.

When checking if the buffer is large enough to hold the tracepoint
condition agent expression, the length of the expression is multiplied
by two, since it is encoded with two hex digits per expression
byte.  For simplicity, I assume that the result won't overflow, which
can happen for very long condition expressions.

gdb/ChangeLog:
2018-08-06  Pedro Franco de Carvalho  <pedromfc@linux.ibm.com>

* remote.c (remote_target::download_tracepoint): Remove BUF_SIZE.
Replace array buf with gdb::char_vector buf, of size
get_remote_packet_size ().  Replace references to buf and
BUF_SIZE to buf.data () and buf.size ().  Replace strcpy, strcat
and xsnprintf with snprintf.  Raise errors if the buffer is too
small.
gdb/ChangeLog
gdb/remote.c
This page took 0.034766 seconds and 4 git commands to generate.