disconnected. */
int disconnected_tracing;
+ /* True if the stub reports support for enabling and disabling
+ tracepoints while a trace experiment is running. */
+ int enable_disable_tracepoints;
+
/* Nonzero if the user has pressed Ctrl-C, but the target hasn't
responded to that. */
int ctrlc_pending_p;
return 1;
}
-static void *
-init_remote_state (struct gdbarch *gdbarch)
+static int
+map_regcache_remote_table (struct gdbarch *gdbarch, struct packet_reg *regs)
{
int regnum, num_remote_regs, offset;
- struct remote_state *rs = get_remote_state_raw ();
- struct remote_arch_state *rsa;
struct packet_reg **remote_regs;
- rsa = GDBARCH_OBSTACK_ZALLOC (gdbarch, struct remote_arch_state);
-
- /* Use the architecture to build a regnum<->pnum table, which will be
- 1:1 unless a feature set specifies otherwise. */
- rsa->regs = GDBARCH_OBSTACK_CALLOC (gdbarch,
- gdbarch_num_regs (gdbarch),
- struct packet_reg);
for (regnum = 0; regnum < gdbarch_num_regs (gdbarch); regnum++)
{
- struct packet_reg *r = &rsa->regs[regnum];
+ struct packet_reg *r = ®s[regnum];
if (register_size (gdbarch, regnum) == 0)
/* Do not try to fetch zero-sized (placeholder) registers. */
number. */
remote_regs = alloca (gdbarch_num_regs (gdbarch)
- * sizeof (struct packet_reg *));
+ * sizeof (struct packet_reg *));
for (num_remote_regs = 0, regnum = 0;
regnum < gdbarch_num_regs (gdbarch);
regnum++)
- if (rsa->regs[regnum].pnum != -1)
- remote_regs[num_remote_regs++] = &rsa->regs[regnum];
+ if (regs[regnum].pnum != -1)
+ remote_regs[num_remote_regs++] = ®s[regnum];
qsort (remote_regs, num_remote_regs, sizeof (struct packet_reg *),
compare_pnums);
offset += register_size (gdbarch, remote_regs[regnum]->regnum);
}
+ return offset;
+}
+
+/* Given the architecture described by GDBARCH, return the remote
+ protocol register's number and the register's offset in the g/G
+ packets of GDB register REGNUM, in PNUM and POFFSET respectively.
+ If the target does not have a mapping for REGNUM, return false,
+ otherwise, return true. */
+
+int
+remote_register_number_and_offset (struct gdbarch *gdbarch, int regnum,
+ int *pnum, int *poffset)
+{
+ int sizeof_g_packet;
+ struct packet_reg *regs;
+ struct cleanup *old_chain;
+
+ gdb_assert (regnum < gdbarch_num_regs (gdbarch));
+
+ regs = xcalloc (gdbarch_num_regs (gdbarch), sizeof (struct packet_reg));
+ old_chain = make_cleanup (xfree, regs);
+
+ sizeof_g_packet = map_regcache_remote_table (gdbarch, regs);
+
+ *pnum = regs[regnum].pnum;
+ *poffset = regs[regnum].offset;
+
+ do_cleanups (old_chain);
+
+ return *pnum != -1;
+}
+
+static void *
+init_remote_state (struct gdbarch *gdbarch)
+{
+ struct remote_state *rs = get_remote_state_raw ();
+ struct remote_arch_state *rsa;
+
+ rsa = GDBARCH_OBSTACK_ZALLOC (gdbarch, struct remote_arch_state);
+
+ /* Use the architecture to build a regnum<->pnum table, which will be
+ 1:1 unless a feature set specifies otherwise. */
+ rsa->regs = GDBARCH_OBSTACK_CALLOC (gdbarch,
+ gdbarch_num_regs (gdbarch),
+ struct packet_reg);
+
/* Record the maximum possible size of the g packet - it may turn out
to be smaller. */
- rsa->sizeof_g_packet = offset;
+ rsa->sizeof_g_packet = map_regcache_remote_table (gdbarch, rsa->regs);
/* Default maximum number of characters in a packet body. Many
remote stubs have a hardwired buffer size of 400 bytes
it can simply pass through to the inferior without reporting. */
static void
-remote_pass_signals (void)
+remote_pass_signals (int numsigs, unsigned char *pass_signals)
{
if (remote_protocol_packets[PACKET_QPassSignals].support != PACKET_DISABLE)
{
char *pass_packet, *p;
- int numsigs = (int) TARGET_SIGNAL_LAST;
int count = 0, i;
gdb_assert (numsigs < 256);
for (i = 0; i < numsigs; i++)
{
- if (signal_stop_state (i) == 0
- && signal_print_state (i) == 0
- && signal_pass_state (i) == 1)
+ if (pass_signals[i])
count++;
}
pass_packet = xmalloc (count * 3 + strlen ("QPassSignals:") + 1);
p = pass_packet + strlen (pass_packet);
for (i = 0; i < numsigs; i++)
{
- if (signal_stop_state (i) == 0
- && signal_print_state (i) == 0
- && signal_pass_state (i) == 1)
+ if (pass_signals[i])
{
if (i >= 16)
*p++ = tohex (i >> 4);
}
}
-static void
-remote_notice_signals (ptid_t ptid)
-{
- /* Update the remote on signals to silently pass, if they've
- changed. */
- remote_pass_signals ();
-}
-
/* If PTID is MAGIC_NULL_PTID, don't set any thread. If PTID is
MINUS_ONE_PTID, set the thread to -1, so the stub returns the
thread. If GEN is set, set the general thread, if not, then set
/* Multi-process ptid. */
pp = unpack_varlen_hex (p + 1, &pid);
if (*pp != '.')
- error (_("invalid remote ptid: %s\n"), p);
+ error (_("invalid remote ptid: %s"), p);
p = pp;
pp = unpack_varlen_hex (p + 1, &tid);
return 0;
}
-/* Stub for catch_exception. */
-
-struct start_remote_args
-{
- int from_tty;
-
- /* The current target. */
- struct target_ops *target;
-
- /* Non-zero if this is an extended-remote target. */
- int extended_p;
-};
-
/* Send interrupt_sequence to remote target. */
static void
-send_interrupt_sequence ()
+send_interrupt_sequence (void)
{
if (interrupt_sequence_mode == interrupt_sequence_control_c)
serial_write (remote_desc, "\x03", 1);
}
static void
-remote_start_remote (struct ui_out *uiout, void *opaque)
+remote_start_remote (int from_tty, struct target_ops *target, int extended_p)
{
- struct start_remote_args *args = opaque;
struct remote_state *rs = get_remote_state ();
struct packet_config *noack_config;
char *wait_status = NULL;
immediate_quit++; /* Allow user to interrupt it. */
- /* Ack any packet which the remote side has already sent. */
- serial_write (remote_desc, "+", 1);
-
if (interrupt_on_connect)
send_interrupt_sequence ();
+ /* Ack any packet which the remote side has already sent. */
+ serial_write (remote_desc, "+", 1);
+
/* The first packet we send to the target is the optional "supported
packets" request. If the target can answer this, it will tell us
which later probes to skip. */
rs->noack_mode = 1;
}
- if (args->extended_p)
+ if (extended_p)
{
/* Tell the remote that we are using the extended protocol. */
putpkt ("!");
/* On OSs where the list of libraries is global to all
processes, we fetch them early. */
if (gdbarch_has_global_solist (target_gdbarch))
- solib_add (NULL, args->from_tty, args->target, auto_solib_add);
+ solib_add (NULL, from_tty, target, auto_solib_add);
if (non_stop)
{
controlling. We default to adding them in the running state.
The '?' query below will then tell us about which threads are
stopped. */
- remote_threads_info (args->target);
+ remote_threads_info (target);
}
else if (rs->non_stop_aware)
{
{
if (rs->buf[0] == 'W' || rs->buf[0] == 'X')
{
- if (!args->extended_p)
+ if (!extended_p)
error (_("The target is not running (try extended-remote?)"));
/* We're connected, but not running. Drop out before we
how to do it some other way, try again. This is not
supported for non-stop; it could be, but it is tricky if
there are no stopped threads when we connect. */
- if (remote_read_description_p (args->target)
+ if (remote_read_description_p (target)
&& gdbarch_target_desc (target_gdbarch) == NULL)
{
target_clear_description ();
rs->cached_wait_status = 1;
immediate_quit--;
- start_remote (args->from_tty); /* Initialize gdb process mechanisms. */
+ start_remote (from_tty); /* Initialize gdb process mechanisms. */
}
else
{
if (thread_count () == 0)
{
- if (!args->extended_p)
+ if (!extended_p)
error (_("The target is not running (try extended-remote?)"));
/* We're connected, but not running. Drop out before we
the stop reply queue. */
gdb_assert (wait_status == NULL);
- /* Update the remote on signals to silently pass, or more
- importantly, which to not ignore, in case a previous session
- had set some different set of signals to be ignored. */
- remote_pass_signals ();
+ /* Report all signals during attach/startup. */
+ remote_pass_signals (0, NULL);
}
/* If we connected to a live target, do some additional setup. */
struct minimal_symbol *sym;
int end;
+ /* The remote side has no concept of inferiors that aren't running
+ yet, it only knows about running processes. If we're connected
+ but our current inferior is not running, we should not invite the
+ remote target to request symbol lookups related to its
+ (unrelated) current process. */
+ if (!target_has_execution)
+ return;
+
if (remote_protocol_packets[PACKET_qSymbol].support == PACKET_DISABLE)
return;
- /* Make sure the remote is pointing at the right process. */
+ /* Make sure the remote is pointing at the right process. Note
+ there's no way to select "no process". */
set_general_process ();
/* Allocate a message buffer. We can't reuse the input buffer in RS,
/* If the target didn't like the packet, warn the user. Do not try
to undo the user's settings, that would just be maddening. */
if (strcmp (rs->buf, "OK") != 0)
- warning ("Remote refused setting permissions with: %s", rs->buf);
+ warning (_("Remote refused setting permissions with: %s"), rs->buf);
}
/* This type describes each known response to the qSupported
rs->disconnected_tracing = (support == PACKET_ENABLE);
}
+static void
+remote_enable_disable_tracepoint_feature (const struct protocol_feature *feature,
+ enum packet_support support,
+ const char *value)
+{
+ struct remote_state *rs = get_remote_state ();
+
+ rs->enable_disable_tracepoints = (support == PACKET_ENABLE);
+}
+
static struct protocol_feature remote_protocol_features[] = {
{ "PacketSize", PACKET_DISABLE, remote_packet_size, -1 },
{ "qXfer:auxv:read", PACKET_DISABLE, remote_supported_packet,
PACKET_TracepointSource },
{ "QAllow", PACKET_DISABLE, remote_supported_packet,
PACKET_QAllow },
+ { "EnableDisableTracepoints", PACKET_DISABLE,
+ remote_enable_disable_tracepoint_feature, -1 },
};
static char *remote_support_xml;
all the ``target ....'' commands to share a common callback
function. See cli-dump.c. */
{
- struct gdb_exception ex;
- struct start_remote_args args;
-
- args.from_tty = from_tty;
- args.target = target;
- args.extended_p = extended_p;
+ volatile struct gdb_exception ex;
- ex = catch_exception (uiout, remote_start_remote, &args, RETURN_MASK_ALL);
+ TRY_CATCH (ex, RETURN_MASK_ALL)
+ {
+ remote_start_remote (from_tty, target, extended_p);
+ }
if (ex.reason < 0)
{
/* Pop the partially set up target - unless something else did
last_sent_signal = siggnal;
last_sent_step = step;
- /* Update the inferior on signals to silently pass, if they've changed. */
- remote_pass_signals ();
-
/* The vCont packet doesn't need to specify threads via Hc. */
/* No reverse support (yet) for vCont. */
if (execution_direction != EXEC_REVERSE)
{
/* We don't pass signals to the target in reverse exec mode. */
if (info_verbose && siggnal != TARGET_SIGNAL_0)
- warning (" - Can't pass signal %d to target in reverse: ignored.\n",
+ warning (_(" - Can't pass signal %d to target in reverse: ignored."),
siggnal);
if (step
return rs->static_tracepoints;
}
+static int
+remote_supports_enable_disable_tracepoint (void)
+{
+ struct remote_state *rs = get_remote_state ();
+
+ return rs->enable_disable_tracepoints;
+}
+
static void
remote_trace_init (void)
{
error (_("Error on target while downloading trace state variable."));
}
+static void
+remote_enable_tracepoint (struct bp_location *location)
+{
+ struct remote_state *rs = get_remote_state ();
+ char addr_buf[40];
+
+ sprintf_vma (addr_buf, location->address);
+ sprintf (rs->buf, "QTEnable:%x:%s", location->owner->number, addr_buf);
+ putpkt (rs->buf);
+ remote_get_noisy_reply (&rs->buf, &rs->buf_size);
+ if (*rs->buf == '\0')
+ error (_("Target does not support enabling tracepoints while a trace run is ongoing."));
+ if (strcmp (rs->buf, "OK") != 0)
+ error (_("Error on target while enabling tracepoint."));
+}
+
+static void
+remote_disable_tracepoint (struct bp_location *location)
+{
+ struct remote_state *rs = get_remote_state ();
+ char addr_buf[40];
+
+ sprintf_vma (addr_buf, location->address);
+ sprintf (rs->buf, "QTDisable:%x:%s", location->owner->number, addr_buf);
+ putpkt (rs->buf);
+ remote_get_noisy_reply (&rs->buf, &rs->buf_size);
+ if (*rs->buf == '\0')
+ error (_("Target does not support disabling tracepoints while a trace run is ongoing."));
+ if (strcmp (rs->buf, "OK") != 0)
+ error (_("Error on target while disabling tracepoint."));
+}
+
static void
remote_trace_set_readonly_regions (void)
{
remote_ops.to_kill = remote_kill;
remote_ops.to_load = generic_load;
remote_ops.to_mourn_inferior = remote_mourn;
- remote_ops.to_notice_signals = remote_notice_signals;
+ remote_ops.to_pass_signals = remote_pass_signals;
remote_ops.to_thread_alive = remote_thread_alive;
remote_ops.to_find_new_threads = remote_threads_info;
remote_ops.to_pid_to_str = remote_pid_to_str;
remote_ops.to_terminal_ours = remote_terminal_ours;
remote_ops.to_supports_non_stop = remote_supports_non_stop;
remote_ops.to_supports_multi_process = remote_supports_multi_process;
+ remote_ops.to_supports_enable_disable_tracepoint = remote_supports_enable_disable_tracepoint;
remote_ops.to_trace_init = remote_trace_init;
remote_ops.to_download_tracepoint = remote_download_tracepoint;
remote_ops.to_download_trace_state_variable
= remote_download_trace_state_variable;
+ remote_ops.to_enable_tracepoint = remote_enable_tracepoint;
+ remote_ops.to_disable_tracepoint = remote_disable_tracepoint;
remote_ops.to_trace_set_readonly_regions = remote_trace_set_readonly_regions;
remote_ops.to_trace_start = remote_trace_start;
remote_ops.to_get_trace_status = remote_get_trace_status;