Skip to content
  • Pedro Franco de Carvalho's avatar
    Use get_remote_packet_size in download_tracepoint · 3df3a985
    Pedro Franco de Carvalho authored
    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.
    3df3a985