* remote-utils.c (remote_escape_output, remote_unescape_input): New.

(putpkt_binary): Renamed from putpkt and adjusted for binary
	data.
	(putpkt): New wrapper for putpkt_binary.
	(readchar): Don't mask off the high bit.
	(decode_X_packet): New function.
	* server.c (main): Call putpkt_binary if a handler sets the packet
	length.  Save the length of the incoming packet.  Handle 'X'.
	* server.h (gdb_byte, remote_escape_output, decode_X_packet): New.
This commit is contained in:
Daniel Jacobowitz
2006-06-22 15:20:47 +00:00
parent 3994f87e99
commit 01f9e8fab8
4 changed files with 167 additions and 9 deletions

View File

@@ -440,9 +440,16 @@ main (int argc, char *argv[])
restart:
setjmp (toplevel);
while (getpkt (own_buf) > 0)
while (1)
{
unsigned char sig;
int packet_len;
int new_packet_len = -1;
packet_len = getpkt (own_buf);
if (packet_len <= 0)
break;
i = 0;
ch = own_buf[i++];
switch (ch)
@@ -547,6 +554,14 @@ main (int argc, char *argv[])
else
write_enn (own_buf);
break;
case 'X':
if (decode_X_packet (&own_buf[1], packet_len - 1,
&mem_addr, &len, mem_buf) < 0
|| write_inferior_memory (mem_addr, mem_buf, len) != 0)
write_enn (own_buf);
else
write_ok (own_buf);
break;
case 'C':
convert_ascii_to_int (own_buf + 1, &sig, 1);
if (target_signal_to_host_p (sig))
@@ -714,7 +729,10 @@ main (int argc, char *argv[])
break;
}
putpkt (own_buf);
if (new_packet_len != -1)
putpkt_binary (own_buf, new_packet_len);
else
putpkt (own_buf);
if (status == 'W')
fprintf (stderr,