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.
+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.
+
2013-04-19 Pedro Alves <palves@redhat.com>
* ser-base.c (ser_base_write): Change prototype -- take 'void *'
2013-04-19 Pedro Alves <palves@redhat.com>
* ser-base.c (ser_base_write): Change prototype -- take 'void *'
/* Binary mode. Send target system values byte by byte, in
increasing byte addresses. Only escape certain critical
characters. */
/* 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
/* 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
- memaddr);
if (new_nr_bytes != nr_bytes)
payload_length = remote_escape_output (myaddr, new_nr_bytes,
- memaddr);
if (new_nr_bytes != nr_bytes)
payload_length = remote_escape_output (myaddr, new_nr_bytes,
+ (gdb_byte *) p, &nr_bytes,
/* Escape as much data as fits into rs->buf. */
buf_len = remote_escape_output
/* 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
if (putpkt_binary (rs->buf, i + buf_len) < 0
|| getpkt_sane (&rs->buf, &rs->buf_size, 0) < 0
error (_("Remote qXfer reply contained no data."));
/* Got some data. */
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
/* '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
/* Escape as much data as fits into rs->buf. */
escaped_pattern_len =
/* 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. */
&used_pattern_len, max_size);
/* Bail if the pattern is too large. */
remote_buffer_add_int (&p, &left, offset);
remote_buffer_add_string (&p, &left, ",");
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,
get_remote_packet_size () - (p - rs->buf));
return remote_hostio_send_command (p - rs->buf, PACKET_vFile_pwrite,
- 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);
read_buf, len);
if (read_len != ret)
error (_("Read returned %d, but %d bytes."), ret, (int) read_len);
- 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);
if (read_len != len)
error (_("Readlink returned %d, but %d bytes."), len, read_len);
pos = 0;
while (nbytes > pos)
{
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. */
offset + pos, &remote_errno);
if (bytes == 0)
/* Success, but no bytes, means end-of-file. */
if (user)
{
buf += xsnprintf (buf, endbuf - buf, "user:");
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:");
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:");
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++ = ';';
}
buf += 2 * nbytes;
*buf++ = ';';
}
srctype, 0, (int) strlen (src));
if (strlen (buf) + strlen (src) * 2 >= buf_size)
error (_("Source string too long for buffer"));
srctype, 0, (int) strlen (src));
if (strlen (buf) + strlen (src) * 2 >= buf_size)
error (_("Source string too long for buffer"));
- bin2hex (src, buf + strlen (buf), 0);
+ bin2hex ((gdb_byte *) src, buf + strlen (buf), 0);
= (struct tfile_trace_file_writer *) self;
int a;
char *act;
= (struct tfile_trace_file_writer *) self;
int a;
char *act;
- gdb_byte buf[MAX_TRACE_UPLOAD];
+ char buf[MAX_TRACE_UPLOAD];
fprintf (writer->fp, "tp T%x:%s:%c:%x:%x",
utp->number, phex_nz (utp->addr, sizeof (utp->addr)),
fprintf (writer->fp, "tp T%x:%s:%c:%x:%x",
utp->number, phex_nz (utp->addr, sizeof (utp->addr)),
ULONGEST offset = 0;
gdb_byte buf[MAX_TRACE_UPLOAD];
ULONGEST offset = 0;
gdb_byte buf[MAX_TRACE_UPLOAD];
+#define MAX_TRACE_UPLOAD 2000
int written;
enum bfd_endian byte_order = gdbarch_byte_order (target_gdbarch ());
int written;
enum bfd_endian byte_order = gdbarch_byte_order (target_gdbarch ());
int scratch_chan;
char header[TRACE_HEADER_SIZE];
char linebuf[1000]; /* Should be max remote packet size or so. */
int scratch_chan;
char header[TRACE_HEADER_SIZE];
char linebuf[1000]; /* Should be max remote packet size or so. */
int bytes, i;
struct trace_status *ts;
struct uploaded_tp *uploaded_tps = NULL;
int bytes, i;
struct trace_status *ts;
struct uploaded_tp *uploaded_tps = NULL;
else if (p2 != p1)
{
ts->stop_desc = xmalloc (strlen (line));
else if (p2 != p1)
{
ts->stop_desc = xmalloc (strlen (line));
- end = hex2bin (p1, ts->stop_desc, (p2 - p1) / 2);
+ end = hex2bin (p1, (gdb_byte *) ts->stop_desc, (p2 - p1) / 2);
ts->stop_desc[end] = '\0';
}
else
ts->stop_desc[end] = '\0';
}
else
if (p2 != p1)
{
ts->stop_desc = xmalloc ((p2 - p1) / 2 + 1);
if (p2 != p1)
{
ts->stop_desc = xmalloc ((p2 - p1) / 2 + 1);
- end = hex2bin (p1, ts->stop_desc, (p2 - p1) / 2);
+ end = hex2bin (p1, (gdb_byte *) ts->stop_desc, (p2 - p1) / 2);
ts->stop_desc[end] = '\0';
}
else
ts->stop_desc[end] = '\0';
}
else
{
++p1;
ts->user_name = xmalloc (strlen (p) / 2);
{
++p1;
ts->user_name = xmalloc (strlen (p) / 2);
- end = hex2bin (p1, ts->user_name, (p3 - p1) / 2);
+ end = hex2bin (p1, (gdb_byte *) ts->user_name, (p3 - p1) / 2);
ts->user_name[end] = '\0';
p = p3;
}
ts->user_name[end] = '\0';
p = p3;
}
{
++p1;
ts->notes = xmalloc (strlen (p) / 2);
{
++p1;
ts->notes = xmalloc (strlen (p) / 2);
- end = hex2bin (p1, ts->notes, (p3 - p1) / 2);
+ end = hex2bin (p1, (gdb_byte *) ts->notes, (p3 - p1) / 2);
ts->notes[end] = '\0';
p = p3;
}
ts->notes[end] = '\0';
p = p3;
}
unsigned short mlen;
char block_type;
unsigned short mlen;
char block_type;
- tfile_read (&block_type, 1);
+ tfile_read ((gdb_byte *) &block_type, 1);