#include "environ.h"
#include "common/byte-vector.h"
-/* Temp hacks for tracepoint encoding migration. */
-static char *target_buf;
-static long target_buf_size;
-
/* Per-program-space data key. */
static const struct program_space_data *remote_pspace_data;
static void remote_unpush_and_throw (void);
+static struct remote_state *get_remote_state (void);
+
/* For "remote". */
static struct cmd_list_element *remote_cmdlist;
}
/* Utility: wait for reply from stub, while accepting "O" packets. */
+
static char *
-remote_get_noisy_reply (char **buf_p,
- long *sizeof_buf)
+remote_get_noisy_reply ()
{
+ struct remote_state *rs = get_remote_state ();
+
do /* Loop on reply from remote stub. */
{
char *buf;
QUIT; /* Allow user to bail out with ^C. */
- getpkt (buf_p, sizeof_buf, 0);
- buf = *buf_p;
+ getpkt (&rs->buf, &rs->buf_size, 0);
+ buf = rs->buf;
if (buf[0] == 'E')
trace_error (buf);
else if (startswith (buf, "qRelocInsn:"))
{
adjusted_size = to - org_to;
- xsnprintf (buf, *sizeof_buf, "qRelocInsn:%x", adjusted_size);
+ xsnprintf (buf, rs->buf_size, "qRelocInsn:%x", adjusted_size);
putpkt (buf);
}
}
xsnprintf (rs->buf, get_remote_packet_size (), "QDisableRandomization:%x",
val);
putpkt (rs->buf);
- reply = remote_get_noisy_reply (&target_buf, &target_buf_size);
+ reply = remote_get_noisy_reply ();
if (*reply == '\0')
error (_("Target does not support QDisableRandomization."));
if (strcmp (reply, "OK") != 0)
static void
remote_trace_init (struct target_ops *self)
{
+ struct remote_state *rs = get_remote_state ();
+
putpkt ("QTinit");
- remote_get_noisy_reply (&target_buf, &target_buf_size);
- if (strcmp (target_buf, "OK") != 0)
+ remote_get_noisy_reply ();
+ if (strcmp (rs->buf, "OK") != 0)
error (_("Target does not support this command."));
}
rs->buf + strlen (rs->buf),
rs->buf_size - strlen (rs->buf));
putpkt (rs->buf);
- remote_get_noisy_reply (&target_buf, &target_buf_size);
- if (strcmp (target_buf, "OK"))
+ remote_get_noisy_reply ();
+ if (strcmp (rs->buf, "OK"))
warning (_("Target does not support source download."));
if (cmd->control_type == while_control
rs->buf + strlen (rs->buf),
rs->buf_size - strlen (rs->buf));
putpkt (rs->buf);
- remote_get_noisy_reply (&target_buf, &target_buf_size);
- if (strcmp (target_buf, "OK"))
+ remote_get_noisy_reply ();
+ if (strcmp (rs->buf, "OK"))
warning (_("Target does not support source download."));
}
}
char *pkt;
struct breakpoint *b = loc->owner;
struct tracepoint *t = (struct tracepoint *) b;
+ struct remote_state *rs = get_remote_state ();
encode_actions_rsp (loc, &tdp_actions, &stepping_actions);
old_chain = make_cleanup (free_actions_list_cleanup_wrapper,
if (b->commands || *default_collect)
strcat (buf, "-");
putpkt (buf);
- remote_get_noisy_reply (&target_buf, &target_buf_size);
- if (strcmp (target_buf, "OK"))
+ remote_get_noisy_reply ();
+ if (strcmp (rs->buf, "OK"))
error (_("Target does not support tracepoints."));
/* do_single_steps (t); */
((tdp_actions[ndx + 1] || stepping_actions)
? '-' : 0));
putpkt (buf);
- remote_get_noisy_reply (&target_buf,
- &target_buf_size);
- if (strcmp (target_buf, "OK"))
+ remote_get_noisy_reply ();
+ if (strcmp (rs->buf, "OK"))
error (_("Error on target while setting tracepoints."));
}
}
stepping_actions[ndx],
(stepping_actions[ndx + 1] ? "-" : ""));
putpkt (buf);
- remote_get_noisy_reply (&target_buf,
- &target_buf_size);
- if (strcmp (target_buf, "OK"))
+ remote_get_noisy_reply ();
+ if (strcmp (rs->buf, "OK"))
error (_("Error on target while setting tracepoints."));
}
}
event_location_to_string (b->location.get ()),
buf + strlen (buf), 2048 - strlen (buf));
putpkt (buf);
- remote_get_noisy_reply (&target_buf, &target_buf_size);
- if (strcmp (target_buf, "OK"))
+ remote_get_noisy_reply ();
+ if (strcmp (rs->buf, "OK"))
warning (_("Target does not support source download."));
}
if (b->cond_string)
"cond", b->cond_string, buf + strlen (buf),
2048 - strlen (buf));
putpkt (buf);
- remote_get_noisy_reply (&target_buf, &target_buf_size);
- if (strcmp (target_buf, "OK"))
+ remote_get_noisy_reply ();
+ if (strcmp (rs->buf, "OK"))
warning (_("Target does not support source download."));
}
remote_download_command_source (b->number, loc->address,
p += 2 * bin2hex ((gdb_byte *) (tsv->name), p, strlen (tsv->name));
*p++ = '\0';
putpkt (rs->buf);
- remote_get_noisy_reply (&target_buf, &target_buf_size);
- if (*target_buf == '\0')
+ remote_get_noisy_reply ();
+ if (*rs->buf == '\0')
error (_("Target does not support this command."));
- if (strcmp (target_buf, "OK") != 0)
+ if (strcmp (rs->buf, "OK") != 0)
error (_("Error on target while downloading trace state variable."));
}
xsnprintf (rs->buf, get_remote_packet_size (), "QTEnable:%x:%s",
location->owner->number, addr_buf);
putpkt (rs->buf);
- remote_get_noisy_reply (&rs->buf, &rs->buf_size);
+ remote_get_noisy_reply ();
if (*rs->buf == '\0')
error (_("Target does not support enabling tracepoints while a trace run is ongoing."));
if (strcmp (rs->buf, "OK") != 0)
xsnprintf (rs->buf, get_remote_packet_size (), "QTDisable:%x:%s",
location->owner->number, addr_buf);
putpkt (rs->buf);
- remote_get_noisy_reply (&rs->buf, &rs->buf_size);
+ remote_get_noisy_reply ();
if (*rs->buf == '\0')
error (_("Target does not support disabling tracepoints while a trace run is ongoing."));
if (strcmp (rs->buf, "OK") != 0)
if (!exec_bfd)
return; /* No information to give. */
- strcpy (target_buf, "QTro");
- offset = strlen (target_buf);
+ struct remote_state *rs = get_remote_state ();
+
+ strcpy (rs->buf, "QTro");
+ offset = strlen (rs->buf);
for (s = exec_bfd->sections; s; s = s->next)
{
char tmp1[40], tmp2[40];
sprintf_vma (tmp1, vma);
sprintf_vma (tmp2, vma + size);
sec_length = 1 + strlen (tmp1) + 1 + strlen (tmp2);
- if (offset + sec_length + 1 > target_buf_size)
+ if (offset + sec_length + 1 > rs->buf_size)
{
if (packet_support (PACKET_qXfer_traceframe_info) != PACKET_ENABLE)
warning (_("\
Too many sections for read-only sections definition packet."));
break;
}
- xsnprintf (target_buf + offset, target_buf_size - offset, ":%s,%s",
+ xsnprintf (rs->buf + offset, rs->buf_size - offset, ":%s,%s",
tmp1, tmp2);
offset += sec_length;
}
if (anysecs)
{
- putpkt (target_buf);
- getpkt (&target_buf, &target_buf_size, 0);
+ putpkt (rs->buf);
+ getpkt (&rs->buf, &rs->buf_size, 0);
}
}
static void
remote_trace_start (struct target_ops *self)
{
+ struct remote_state *rs = get_remote_state ();
+
putpkt ("QTStart");
- remote_get_noisy_reply (&target_buf, &target_buf_size);
- if (*target_buf == '\0')
+ remote_get_noisy_reply ();
+ if (*rs->buf == '\0')
error (_("Target does not support this command."));
- if (strcmp (target_buf, "OK") != 0)
- error (_("Bogus reply from target: %s"), target_buf);
+ if (strcmp (rs->buf, "OK") != 0)
+ error (_("Bogus reply from target: %s"), rs->buf);
}
static int
/* FIXME we need to get register block size some other way. */
extern int trace_regblock_size;
enum packet_result result;
+ struct remote_state *rs = get_remote_state ();
if (packet_support (PACKET_qTStatus) == PACKET_DISABLE)
return -1;
TRY
{
- p = remote_get_noisy_reply (&target_buf, &target_buf_size);
+ p = remote_get_noisy_reply ();
}
CATCH (ex, RETURN_MASK_ERROR)
{
ts->filename = NULL;
if (*p++ != 'T')
- error (_("Bogus trace status reply from target: %s"), target_buf);
+ error (_("Bogus trace status reply from target: %s"), rs->buf);
/* Function 'parse_trace_status' sets default value of each field of
'ts' at first, so we don't have to do it here. */
xsnprintf (rs->buf, size, "qTP:%x:%s", tp->number_on_target,
phex_nz (loc->address, 0));
putpkt (rs->buf);
- reply = remote_get_noisy_reply (&target_buf, &target_buf_size);
+ reply = remote_get_noisy_reply ();
if (reply && *reply)
{
if (*reply == 'V')
xsnprintf (rs->buf, size, "qTP:%x:%s", utp->number,
phex_nz (utp->addr, 0));
putpkt (rs->buf);
- reply = remote_get_noisy_reply (&target_buf, &target_buf_size);
+ reply = remote_get_noisy_reply ();
if (reply && *reply)
{
if (*reply == 'V')
static void
remote_trace_stop (struct target_ops *self)
{
+ struct remote_state *rs = get_remote_state ();
+
putpkt ("QTStop");
- remote_get_noisy_reply (&target_buf, &target_buf_size);
- if (*target_buf == '\0')
+ remote_get_noisy_reply ();
+ if (*rs->buf == '\0')
error (_("Target does not support this command."));
- if (strcmp (target_buf, "OK") != 0)
- error (_("Bogus reply from target: %s"), target_buf);
+ if (strcmp (rs->buf, "OK") != 0)
+ error (_("Bogus reply from target: %s"), rs->buf);
}
static int
}
putpkt (rs->buf);
- reply = remote_get_noisy_reply (&(rs->buf), &rs->buf_size);
+ reply = remote_get_noisy_reply ();
if (*reply == '\0')
error (_("Target does not support this command."));
xsnprintf (rs->buf, get_remote_packet_size (), "qTV:%x", tsvnum);
putpkt (rs->buf);
- reply = remote_get_noisy_reply (&target_buf, &target_buf_size);
+ reply = remote_get_noisy_reply ();
if (reply && *reply)
{
if (*reply == 'V')
p += 2 * bin2hex ((gdb_byte *) filename, p, strlen (filename));
*p++ = '\0';
putpkt (rs->buf);
- reply = remote_get_noisy_reply (&target_buf, &target_buf_size);
+ reply = remote_get_noisy_reply ();
if (*reply == '\0')
error (_("Target does not support this command."));
if (strcmp (reply, "OK") != 0)
*p++ = '\0';
putpkt (rs->buf);
- reply = remote_get_noisy_reply (&target_buf, &target_buf_size);
+ reply = remote_get_noisy_reply ();
if (reply && *reply)
{
/* 'l' by itself means we're at the end of the buffer and
what was returned in the packet; if the target is
unexpectedly generous and gives us a bigger reply than we
asked for, we don't want to crash. */
- rslt = hex2bin (target_buf, buf, len);
+ rslt = hex2bin (reply, buf, len);
return rslt;
}
xsnprintf (rs->buf, get_remote_packet_size (), "QTDisconnected:%x", val);
putpkt (rs->buf);
- reply = remote_get_noisy_reply (&target_buf, &target_buf_size);
+ reply = remote_get_noisy_reply ();
if (*reply == '\0')
error (_("Target does not support this command."));
if (strcmp (reply, "OK") != 0)
xsnprintf (rs->buf, get_remote_packet_size (), "QTBuffer:circular:%x", val);
putpkt (rs->buf);
- reply = remote_get_noisy_reply (&target_buf, &target_buf_size);
+ reply = remote_get_noisy_reply ();
if (*reply == '\0')
error (_("Target does not support this command."));
if (strcmp (reply, "OK") != 0)
xsnprintf (rs->buf, get_remote_packet_size (), "qTMinFTPILen");
putpkt (rs->buf);
- reply = remote_get_noisy_reply (&target_buf, &target_buf_size);
+ reply = remote_get_noisy_reply ();
if (*reply == '\0')
return -1;
else
buf += hexnumstr (buf, (ULONGEST) val);
putpkt (rs->buf);
- remote_get_noisy_reply (&rs->buf, &rs->buf_size);
+ remote_get_noisy_reply ();
result = packet_ok (rs->buf,
&remote_protocol_packets[PACKET_QTBuffer_size]);
*buf = '\0';
putpkt (rs->buf);
- reply = remote_get_noisy_reply (&target_buf, &target_buf_size);
+ reply = remote_get_noisy_reply ();
if (*reply == '\0')
return 0;
magic_null_ptid = ptid_build (42000, -1, 1);
not_sent_ptid = ptid_build (42000, -2, 1);
any_thread_ptid = ptid_build (42000, 0, 1);
-
- target_buf_size = 2048;
- target_buf = (char *) xmalloc (target_buf_size);
}
-