This is the mail archive of the gdb-patches@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]

Re: [rfc/rfa] [3/4] SPU enhancements: gdbserver support


On Mon, Jun 04, 2007 at 04:09:56PM -0400, Daniel Jacobowitz wrote:
> On Mon, Jun 04, 2007 at 10:05:01PM +0200, Ulrich Weigand wrote:
> > Fine with me.  I'd appreciate if you could post that code ...
> 
> I'll try to do this tomorrow morning.

There's not as much code for it as I remembered.

Sending such packets from GDB is easy.  In fact, it's easier than the
X packet, because you do not have to patch in the exact length.  I
already added the remote_escape_output helper.  If p is a pointer into
rs->buf just after the packet header, this will add as much data as
can fit from write_buf/len:

  p += remote_escape_output (write_buf, len, p, &out_len,
                             get_remote_packet_size () - (p - rs->buf));


To receive them in gdbserver, I used this:

static int
require_data (char *p, int p_len, char **data, int *data_len)
{
  int input_index, output_index, escaped;

  *data = malloc (p_len);

  output_index = 0;
  escaped = 0;
  for (input_index = 0; input_index < p_len; input_index++)
    {
      char b = p[input_index];

      if (escaped)
	{
	  (*data)[output_index++] = b ^ 0x20;
	  escaped = 0;
	}
      else if (b == '}')
	escaped = 1;
      else
	(*data)[output_index++] = b;
    }

  if (escaped)
    return -1;

  *data_len = output_index;
  return 0;
}


  if (require_data (p, packet_len - (p - own_buf), &data, &len))
    {
      write_enn (own_buf);
      return;
    }

p is after the header in own_buf, packet_len is the total length of
the received packet; I already changed getpkt to return packet_len.

-- 
Daniel Jacobowitz
CodeSourcery


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