aboutsummaryrefslogtreecommitdiff
path: root/gdb/remote.c
diff options
context:
space:
mode:
authorPedro Alves <palves@redhat.com>2013-04-19 15:27:06 +0000
committerPedro Alves <palves@redhat.com>2013-04-19 15:27:06 +0000
commitbc20a4afc3fa41cab07aa68571b713ecef0aa675 (patch)
tree241fb2ef1f6c8643a0af164ddf4df0490e9134d9 /gdb/remote.c
parentc628b528e091211bd746e5c9b18b5bc7298d01f3 (diff)
downloadgdb-bc20a4afc3fa41cab07aa68571b713ecef0aa675.zip
gdb-bc20a4afc3fa41cab07aa68571b713ecef0aa675.tar.gz
gdb-bc20a4afc3fa41cab07aa68571b713ecef0aa675.tar.bz2
gdb_byte for binary buffer, char for string: remote.c, tracepoint.c.
While the RSP is largely ASCII based (hence the packet buffer type is char *), at places we pass around 8-bit binary packets in that buffer. Functions like hex2bin or remote_escape_output conceptually are handling binary buffers, so I left them as working with gdb_byte, and added casts where necessary. Whether these are host bytes or target bytes is blurry at present, so this is largely a matter of taste. Switching some of these functions to take "char *" or "void *" would be equally good. gdb/ 2013-04-19 Pedro Alves <palves@redhat.com> * remote.c (remote_write_bytes_aux, compare_sections_command) (remote_read_qxfer) (remote_search_memory, remote_hostio_pwrite, remote_hostio_pread) (remote_hostio_readlink, remote_bfd_iovec_pread) (remote_set_trace_notes): Use gdb_byte when RSP buffer is used as binary buffer, and char when buffer is used as string. * tracepoint.c (encode_source_string, tfile_write_uploaded_tp) (trace_save, tfile_open, traceframe_walk_blocks) (tfile_fetch_registers): Likewise.
Diffstat (limited to 'gdb/remote.c')
-rw-r--r--gdb/remote.c29
1 files changed, 15 insertions, 14 deletions
diff --git a/gdb/remote.c b/gdb/remote.c
index 9f447ba..61fc5e7 100644
--- a/gdb/remote.c
+++ b/gdb/remote.c
@@ -6744,8 +6744,8 @@ remote_write_bytes_aux (const char *header, CORE_ADDR memaddr,
/* Binary mode. Send target system values byte by byte, in
increasing byte addresses. Only escape certain critical
characters. */
- payload_length = remote_escape_output (myaddr, todo, p, &nr_bytes,
- payload_size);
+ payload_length = remote_escape_output (myaddr, todo, (gdb_byte *) p,
+ &nr_bytes, payload_size);
/* If not all TODO bytes fit, then we'll need another packet. Make
a second try to keep the end of the packet aligned. Don't do
@@ -6758,7 +6758,7 @@ remote_write_bytes_aux (const char *header, CORE_ADDR memaddr,
- memaddr);
if (new_nr_bytes != nr_bytes)
payload_length = remote_escape_output (myaddr, new_nr_bytes,
- p, &nr_bytes,
+ (gdb_byte *) p, &nr_bytes,
payload_size);
}
@@ -8575,7 +8575,7 @@ remote_write_qxfer (struct target_ops *ops, const char *object_name,
/* Escape as much data as fits into rs->buf. */
buf_len = remote_escape_output
- (writebuf, len, (rs->buf + i), &max_size, max_size);
+ (writebuf, len, (gdb_byte *) rs->buf + i, &max_size, max_size);
if (putpkt_binary (rs->buf, i + buf_len) < 0
|| getpkt_sane (&rs->buf, &rs->buf_size, 0) < 0
@@ -8654,7 +8654,8 @@ remote_read_qxfer (struct target_ops *ops, const char *object_name,
error (_("Remote qXfer reply contained no data."));
/* Got some data. */
- i = remote_unescape_input (rs->buf + 1, packet_len - 1, readbuf, n);
+ i = remote_unescape_input ((gdb_byte *) rs->buf + 1,
+ packet_len - 1, readbuf, n);
/* 'l' is an EOF marker, possibly including a final block of data,
or possibly empty. If we have the final block of a non-empty
@@ -8935,7 +8936,7 @@ remote_search_memory (struct target_ops* ops,
/* Escape as much data as fits into rs->buf. */
escaped_pattern_len =
- remote_escape_output (pattern, pattern_len, (rs->buf + i),
+ remote_escape_output (pattern, pattern_len, (gdb_byte *) rs->buf + i,
&used_pattern_len, max_size);
/* Bail if the pattern is too large. */
@@ -9709,7 +9710,7 @@ remote_hostio_pwrite (int fd, const gdb_byte *write_buf, int len,
remote_buffer_add_int (&p, &left, offset);
remote_buffer_add_string (&p, &left, ",");
- p += remote_escape_output (write_buf, len, p, &out_len,
+ p += remote_escape_output (write_buf, len, (gdb_byte *) p, &out_len,
get_remote_packet_size () - (p - rs->buf));
return remote_hostio_send_command (p - rs->buf, PACKET_vFile_pwrite,
@@ -9748,7 +9749,7 @@ remote_hostio_pread (int fd, gdb_byte *read_buf, int len,
if (ret < 0)
return ret;
- read_len = remote_unescape_input (attachment, attachment_len,
+ read_len = remote_unescape_input ((gdb_byte *) attachment, attachment_len,
read_buf, len);
if (read_len != ret)
error (_("Read returned %d, but %d bytes."), ret, (int) read_len);
@@ -9822,8 +9823,8 @@ remote_hostio_readlink (const char *filename, int *remote_errno)
ret = xmalloc (len + 1);
- read_len = remote_unescape_input (attachment, attachment_len,
- ret, len);
+ read_len = remote_unescape_input ((gdb_byte *) attachment, attachment_len,
+ (gdb_byte *) ret, len);
if (read_len != len)
error (_("Readlink returned %d, but %d bytes."), len, read_len);
@@ -9952,7 +9953,7 @@ remote_bfd_iovec_pread (struct bfd *abfd, void *stream, void *buf,
pos = 0;
while (nbytes > pos)
{
- bytes = remote_hostio_pread (fd, (char *)buf + pos, nbytes - pos,
+ bytes = remote_hostio_pread (fd, (gdb_byte *) buf + pos, nbytes - pos,
offset + pos, &remote_errno);
if (bytes == 0)
/* Success, but no bytes, means end-of-file. */
@@ -11135,21 +11136,21 @@ remote_set_trace_notes (char *user, char *notes, char *stop_notes)
if (user)
{
buf += xsnprintf (buf, endbuf - buf, "user:");
- nbytes = bin2hex (user, buf, 0);
+ nbytes = bin2hex ((gdb_byte *) user, buf, 0);
buf += 2 * nbytes;
*buf++ = ';';
}
if (notes)
{
buf += xsnprintf (buf, endbuf - buf, "notes:");
- nbytes = bin2hex (notes, buf, 0);
+ nbytes = bin2hex ((gdb_byte *) notes, buf, 0);
buf += 2 * nbytes;
*buf++ = ';';
}
if (stop_notes)
{
buf += xsnprintf (buf, endbuf - buf, "tstop:");
- nbytes = bin2hex (stop_notes, buf, 0);
+ nbytes = bin2hex ((gdb_byte *) stop_notes, buf, 0);
buf += 2 * nbytes;
*buf++ = ';';
}