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
/* 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;
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
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
all the ``target ....'' commands to share a common callback
function. See cli-dump.c. */
{
- struct gdb_exception ex;
- struct start_remote_args args;
+ volatile struct gdb_exception ex;
- args.from_tty = from_tty;
- args.target = target;
- args.extended_p = extended_p;
-
- 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
{
/* 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
case '-':
if (remote_debug)
fprintf_unfiltered (gdb_stdlog, "Nak\n");
+ /* FALLTHROUGH */
case SERIAL_TIMEOUT:
tcount++;
if (tcount > 3)