/* Remote target communications for serial-line targets in custom GDB protocol
- Copyright 1988, 1989, 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997,
- 1998, 1999, 2000, 2001 Free Software Foundation, Inc.
+
+ Copyright 1988, 1989, 1990, 1991, 1992, 1993, 1994, 1995, 1996,
+ 1997, 1998, 1999, 2000, 2001, 2002 Free Software Foundation, Inc.
This file is part of GDB.
enum target_signal siggnal);
static void remote_async_resume (ptid_t ptid, int step,
enum target_signal siggnal);
-static int remote_start_remote (PTR);
+static int remote_start_remote (struct ui_out *uiout, void *dummy);
static void remote_open (char *name, int from_tty);
static void remote_async_open (char *name, int from_tty);
void _initialize_remote (void);
-/* Description of the remote protocol. Strictly speeking, when the
+/* Description of the remote protocol. Strictly speaking, when the
target is open()ed, remote.c should create a per-target description
of the remote protocol using that target's architecture.
Unfortunatly, the target stack doesn't include local state. For
the moment keep the information in the target's architecture
object. Sigh.. */
+struct packet_reg
+{
+ long offset; /* Offset into G packet. */
+ long regnum; /* GDB's internal register number. */
+ LONGEST pnum; /* Remote protocol register number. */
+ int in_g_packet; /* Always part of G packet. */
+ /* long size in bytes; == REGISTER_RAW_SIZE (regnum); at present. */
+ /* char *name; == REGISTER_NAME (regnum); at present. */
+};
+
struct remote_state
{
+ /* Description of the remote protocol registers. */
+ long sizeof_g_packet;
+
+ /* Description of the remote protocol registers indexed by REGNUM
+ (making an array of NUM_REGS + NUM_PSEUDO_REGS in size). */
+ struct packet_reg *regs;
+
/* This is the size (in chars) of the first response to the ``g''
packet. It is used as a heuristic when determining the maximum
size of memory-read and memory-write packets. A target will
static struct remote_state *
get_remote_state ()
{
- return gdbarch_data (remote_gdbarch_data_handle);
+ return gdbarch_data (current_gdbarch, remote_gdbarch_data_handle);
}
static void *
int regnum;
struct remote_state *rs = xmalloc (sizeof (struct remote_state));
+ /* Start out by having the remote protocol mimic the existing
+ behavour - just copy in the description of the register cache. */
+ rs->sizeof_g_packet = REGISTER_BYTES; /* OK use. */
+
+ /* Assume a 1:1 regnum<->pnum table. */
+ rs->regs = xcalloc (NUM_REGS + NUM_PSEUDO_REGS, sizeof (struct packet_reg));
+ for (regnum = 0; regnum < NUM_REGS + NUM_PSEUDO_REGS; regnum++)
+ {
+ struct packet_reg *r = &rs->regs[regnum];
+ r->pnum = regnum;
+ r->regnum = regnum;
+ r->offset = REGISTER_BYTE (regnum);
+ r->in_g_packet = (regnum < NUM_REGS);
+ /* ...size = REGISTER_RAW_SIZE (regnum); */
+ /* ...name = REGISTER_NAME (regnum); */
+ }
+
/* Default maximum number of characters in a packet body. Many
remote stubs have a hardwired buffer size of 400 bytes
(c.f. BUFMAX in m68k-stub.c and i386-stub.c). BUFMAX-1 is used
already a full buffer (As of 1999-12-04 that was most stubs. */
rs->remote_packet_size = 400 - 1;
- /* Should REGISTER_BYTES needs more space than the default, adjust
- the size accordingly. Remember that each byte is encoded as two
- characters. 32 is the overhead for the packet header /
- footer. NOTE: cagney/1999-10-26: I suspect that 8
+ /* Should rs->sizeof_g_packet needs more space than the
+ default, adjust the size accordingly. Remember that each byte is
+ encoded as two characters. 32 is the overhead for the packet
+ header / footer. NOTE: cagney/1999-10-26: I suspect that 8
(``$NN:G...#NN'') is a better guess, the below has been padded a
little. */
- if (REGISTER_BYTES > ((rs->remote_packet_size - 32) / 2))
- rs->remote_packet_size = (REGISTER_BYTES * 2 + 32);
+ if (rs->sizeof_g_packet > ((rs->remote_packet_size - 32) / 2))
+ rs->remote_packet_size = (rs->sizeof_g_packet * 2 + 32);
/* This one is filled in when a ``g'' packet is received. */
rs->actual_register_packet_size = 0;
static void
free_remote_state (struct gdbarch *gdbarch, void *pointer)
{
- struct remote_state *state = pointer;
- xfree (state);
+ struct remote_state *data = pointer;
+ xfree (data->regs);
+ xfree (data);
+}
+
+static struct packet_reg *
+packet_reg_from_regnum (struct remote_state *rs, long regnum)
+{
+ if (regnum < 0 && regnum >= NUM_REGS + NUM_PSEUDO_REGS)
+ return NULL;
+ else
+ {
+ struct packet_reg *r = &rs->regs[regnum];
+ gdb_assert (r->regnum == regnum);
+ return r;
+ }
+}
+
+static struct packet_reg *
+packet_reg_from_pnum (struct remote_state *rs, LONGEST pnum)
+{
+ int i;
+ for (i = 0; i < NUM_REGS + NUM_PSEUDO_REGS; i++)
+ {
+ struct packet_reg *r = &rs->regs[i];
+ if (r->pnum == pnum)
+ return r;
+ }
+ return NULL;
}
/* */
\f
/* User configurable variables for the number of characters in a
- memory read/write packet. MIN ((rs->remote_packet_size), g-packet-size) is the
- default. Some targets need smaller values (fifo overruns, et.al.)
- and some users need larger values (speed up transfers). The
- variables ``preferred_*'' (the user request), ``current_*'' (what
- was actually set) and ``forced_*'' (Positive - a soft limit,
- negative - a hard limit). */
+ memory read/write packet. MIN ((rs->remote_packet_size),
+ rs->sizeof_g_packet) is the default. Some targets need smaller
+ values (fifo overruns, et.al.) and some users need larger values
+ (speed up transfers). The variables ``preferred_*'' (the user
+ request), ``current_*'' (what was actually set) and ``forced_*''
+ (Positive - a soft limit, negative - a hard limit). */
struct memory_packet_config
{
{
char *name;
char *title;
- enum cmd_auto_boolean detect;
+ enum auto_boolean detect;
enum packet_support support;
};
{
switch (config->detect)
{
- case CMD_AUTO_BOOLEAN_TRUE:
+ case AUTO_BOOLEAN_TRUE:
config->support = PACKET_ENABLE;
break;
- case CMD_AUTO_BOOLEAN_FALSE:
+ case AUTO_BOOLEAN_FALSE:
config->support = PACKET_DISABLE;
break;
- case CMD_AUTO_BOOLEAN_AUTO:
+ case AUTO_BOOLEAN_AUTO:
config->support = PACKET_SUPPORT_UNKNOWN;
break;
}
}
switch (config->detect)
{
- case CMD_AUTO_BOOLEAN_AUTO:
+ case AUTO_BOOLEAN_AUTO:
printf_filtered ("Support for remote protocol `%s' (%s) packet is auto-detected, currently %s.\n",
config->name, config->title, support);
break;
- case CMD_AUTO_BOOLEAN_TRUE:
- case CMD_AUTO_BOOLEAN_FALSE:
+ case AUTO_BOOLEAN_TRUE:
+ case AUTO_BOOLEAN_FALSE:
printf_filtered ("Support for remote protocol `%s' (%s) packet is currently %s.\n",
config->name, config->title, support);
break;
add_packet_config_cmd (struct packet_config *config,
char *name,
char *title,
- void (*set_func) (char *args, int from_tty,
- struct cmd_list_element *
- c),
- void (*show_func) (char *name,
- int from_tty),
+ cmd_sfunc_ftype *set_func,
+ cmd_sfunc_ftype *show_func,
struct cmd_list_element **set_remote_list,
struct cmd_list_element **show_remote_list,
int legacy)
char *cmd_name;
config->name = name;
config->title = title;
- config->detect = CMD_AUTO_BOOLEAN_AUTO;
+ config->detect = AUTO_BOOLEAN_AUTO;
config->support = PACKET_SUPPORT_UNKNOWN;
xasprintf (&set_doc, "Set use of remote protocol `%s' (%s) packet",
name, title);
name, title);
/* set/show TITLE-packet {auto,on,off} */
xasprintf (&cmd_name, "%s-packet", title);
- set_cmd = add_set_auto_boolean_cmd (cmd_name, class_obscure,
- &config->detect, set_doc,
- set_remote_list);
- set_cmd->function.sfunc = set_func;
- show_cmd = add_cmd (cmd_name, class_obscure, show_func, show_doc,
- show_remote_list);
+ add_setshow_auto_boolean_cmd (cmd_name, class_obscure,
+ &config->detect, set_doc, show_doc,
+ set_func, show_func,
+ set_remote_list, show_remote_list);
/* set/show remote NAME-packet {auto,on,off} -- legacy */
if (legacy)
{
switch (config->support)
{
case PACKET_ENABLE:
- if (config->detect == CMD_AUTO_BOOLEAN_AUTO)
+ if (config->detect == AUTO_BOOLEAN_AUTO)
/* If the stub previously indicated that the packet was
supported then there is a protocol error.. */
error ("Protocol error: %s (%s) conflicting enabled responses.",
}
static void
-show_remote_protocol_qSymbol_packet_cmd (char *args, int from_tty)
+show_remote_protocol_qSymbol_packet_cmd (char *args, int from_tty,
+ struct cmd_list_element *c)
{
show_packet_config_cmd (&remote_protocol_qSymbol);
}
}
static void
-show_remote_protocol_e_packet_cmd (char *args, int from_tty)
+show_remote_protocol_e_packet_cmd (char *args, int from_tty,
+ struct cmd_list_element *c)
{
show_packet_config_cmd (&remote_protocol_e);
}
}
static void
-show_remote_protocol_E_packet_cmd (char *args, int from_tty)
+show_remote_protocol_E_packet_cmd (char *args, int from_tty,
+ struct cmd_list_element *c)
{
show_packet_config_cmd (&remote_protocol_E);
}
}
static void
-show_remote_protocol_P_packet_cmd (char *args, int from_tty)
+show_remote_protocol_P_packet_cmd (char *args, int from_tty,
+ struct cmd_list_element *c)
{
show_packet_config_cmd (&remote_protocol_P);
}
}
static void
-show_remote_protocol_Z_software_bp_packet_cmd (char *args, int from_tty)
+show_remote_protocol_Z_software_bp_packet_cmd (char *args, int from_tty,
+ struct cmd_list_element *c)
{
show_packet_config_cmd (&remote_protocol_Z[Z_PACKET_SOFTWARE_BP]);
}
}
static void
-show_remote_protocol_Z_hardware_bp_packet_cmd (char *args, int from_tty)
+show_remote_protocol_Z_hardware_bp_packet_cmd (char *args, int from_tty,
+ struct cmd_list_element *c)
{
show_packet_config_cmd (&remote_protocol_Z[Z_PACKET_HARDWARE_BP]);
}
}
static void
-show_remote_protocol_Z_write_wp_packet_cmd (char *args, int from_tty)
+show_remote_protocol_Z_write_wp_packet_cmd (char *args, int from_tty,
+ struct cmd_list_element *c)
{
show_packet_config_cmd (&remote_protocol_Z[Z_PACKET_WRITE_WP]);
}
}
static void
-show_remote_protocol_Z_read_wp_packet_cmd (char *args, int from_tty)
+show_remote_protocol_Z_read_wp_packet_cmd (char *args, int from_tty,
+ struct cmd_list_element *c)
{
show_packet_config_cmd (&remote_protocol_Z[Z_PACKET_READ_WP]);
}
}
static void
-show_remote_protocol_Z_access_wp_packet_cmd (char *args, int from_tty)
+show_remote_protocol_Z_access_wp_packet_cmd (char *args, int from_tty,
+ struct cmd_list_element *c)
{
show_packet_config_cmd (&remote_protocol_Z[Z_PACKET_ACCESS_WP]);
}
/* For compatibility with older distributions. Provide a ``set remote
Z-packet ...'' command that updates all the Z packet types. */
-static enum cmd_auto_boolean remote_Z_packet_detect;
+static enum auto_boolean remote_Z_packet_detect;
static void
set_remote_protocol_Z_packet_cmd (char *args, int from_tty,
}
static void
-show_remote_protocol_Z_packet_cmd (char *args, int from_tty)
+show_remote_protocol_Z_packet_cmd (char *args, int from_tty,
+ struct cmd_list_element *c)
{
int i;
for (i = 0; i < NR_Z_PACKET_TYPES; i++)
}
static void
-show_remote_protocol_binary_download_cmd (char *args,
- int from_tty)
+show_remote_protocol_binary_download_cmd (char *args, int from_tty,
+ struct cmd_list_element *c)
{
show_packet_config_cmd (&remote_protocol_binary_download);
}
/* Tokens for use by the asynchronous signal handlers for SIGINT */
-PTR sigint_remote_twice_token;
-PTR sigint_remote_token;
+static void *sigint_remote_twice_token;
+static void *sigint_remote_token;
/* These are pointers to hook functions that may be set in order to
modify resume/wait behavior for a particular architecture. */
if (!in_thread_list (pid_to_ptid (currthread)))
{
add_thread (pid_to_ptid (currthread));
-#ifdef UI_OUT
ui_out_text (uiout, "[New ");
ui_out_text (uiout, target_pid_to_str (pid_to_ptid (currthread)));
ui_out_text (uiout, "]\n");
-#else
- printf_filtered ("[New %s]\n",
- target_pid_to_str (pid_to_ptid (currthread)));
-#endif
}
}
/* Stub for catch_errors. */
static int
-remote_start_remote_dummy (void *dummy)
+remote_start_remote_dummy (struct ui_out *uiout, void *dummy)
{
start_remote (); /* Initialize gdb process mechanisms */
+ /* NOTE: Return something >=0. A -ve value is reserved for
+ catch_exceptions. */
return 1;
}
static int
-remote_start_remote (PTR dummy)
+remote_start_remote (struct ui_out *uiout, void *dummy)
{
immediate_quit++; /* Allow user to interrupt it */
putpkt ("?"); /* initiate a query from remote machine */
immediate_quit--;
- return remote_start_remote_dummy (dummy);
+ /* NOTE: See comment above in remote_start_remote_dummy(). This
+ function returns something >=0. */
+ return remote_start_remote_dummy (uiout, dummy);
}
/* Open a connection to a remote debugger.
}
}
+static struct serial *
+remote_serial_open (char *name)
+{
+ static int udp_warning = 0;
+
+ /* FIXME: Parsing NAME here is a hack. But we want to warn here instead
+ of in ser-tcp.c, because it is the remote protocol assuming that the
+ serial connection is reliable and not the serial connection promising
+ to be. */
+ if (!udp_warning && strncmp (name, "udp:", 4) == 0)
+ {
+ warning ("The remote protocol may be unreliable over UDP.");
+ warning ("Some events may be lost, rendering further debugging "
+ "impossible.");
+ udp_warning = 1;
+ }
+
+ return serial_open (name);
+}
+
static void
remote_open_1 (char *name, int from_tty, struct target_ops *target,
int extended_p)
{
+ int ex;
struct remote_state *rs = get_remote_state ();
if (name == 0)
- error ("To open a remote debug connection, you need to specify what\n\
-serial device is attached to the remote system\n\
-(e.g. /dev/ttyS0, /dev/ttya, COM1, etc.).");
+ error ("To open a remote debug connection, you need to specify what\n"
+ "serial device is attached to the remote system\n"
+ "(e.g. /dev/ttyS0, /dev/ttya, COM1, etc.).");
/* See FIXME above */
wait_forever_enabled_p = 1;
unpush_target (target);
- remote_desc = serial_open (name);
+ remote_desc = remote_serial_open (name);
if (!remote_desc)
perror_with_name (name);
no_shared_libraries (NULL, 0);
#endif
- /* Start the remote connection; if error (0), discard this target.
- In particular, if the user quits, be sure to discard it
- (we'd be in an inconsistent state otherwise). */
- if (!catch_errors (remote_start_remote, NULL,
- "Couldn't establish connection to remote target\n",
- RETURN_MASK_ALL))
+ /* Start the remote connection. If error() or QUIT, discard this
+ target (we'd otherwise be in an inconsistent state) and then
+ propogate the error on up the exception chain. This ensures that
+ the caller doesn't stumble along blindly assuming that the
+ function succeeded. The CLI doesn't have this problem but other
+ UI's, such as MI do.
+
+ FIXME: cagney/2002-05-19: Instead of re-throwing the exception,
+ this function should return an error indication letting the
+ caller restore the previous state. Unfortunatly the command
+ ``target remote'' is directly wired to this function making that
+ impossible. On a positive note, the CLI side of this problem has
+ been fixed - the function set_cmd_context() makes it possible for
+ all the ``target ....'' commands to share a common callback
+ function. See cli-dump.c. */
+ ex = catch_exceptions (uiout,
+ remote_start_remote, NULL,
+ "Couldn't establish connection to remote"
+ " target\n",
+ RETURN_MASK_ALL);
+ if (ex < 0)
{
pop_target ();
- return;
+ throw_exception (ex);
}
if (extended_p)
remote_async_open_1 (char *name, int from_tty, struct target_ops *target,
int extended_p)
{
+ int ex;
struct remote_state *rs = get_remote_state ();
if (name == 0)
- error ("To open a remote debug connection, you need to specify what\n\
-serial device is attached to the remote system\n\
-(e.g. /dev/ttyS0, /dev/ttya, COM1, etc.).");
+ error ("To open a remote debug connection, you need to specify what\n"
+ "serial device is attached to the remote system\n"
+ "(e.g. /dev/ttyS0, /dev/ttya, COM1, etc.).");
target_preopen (from_tty);
unpush_target (target);
- remote_desc = serial_open (name);
+ remote_desc = remote_serial_open (name);
if (!remote_desc)
perror_with_name (name);
no_shared_libraries (NULL, 0);
#endif
- /* Start the remote connection; if error (0), discard this target.
- In particular, if the user quits, be sure to discard it
- (we'd be in an inconsistent state otherwise). */
- if (!catch_errors (remote_start_remote, NULL,
- "Couldn't establish connection to remote target\n",
- RETURN_MASK_ALL))
+ /* Start the remote connection; if error, discard this target. See
+ the comments in remote_open_1() for further details such as the
+ need to re-throw the exception. */
+ ex = catch_exceptions (uiout,
+ remote_start_remote, NULL,
+ "Couldn't establish connection to remote"
+ " target\n",
+ RETURN_MASK_ALL);
+ if (ex < 0)
{
pop_target ();
wait_forever_enabled_p = 1;
- return;
+ throw_exception (ex);
}
wait_forever_enabled_p = 1;
Give up (and stop debugging it)? "))
{
target_mourn_inferior ();
- return_to_top_level (RETURN_QUIT);
+ throw_exception (RETURN_QUIT);
}
target_terminal_inferior ();
case 'T': /* Status with PC, SP, FP, ... */
{
int i;
- long regno;
char* regs = (char*) alloca (MAX_REGISTER_RAW_SIZE);
/* Expedited reply, containing Signal, {regno, reg} repeat */
char *p_temp;
int fieldsize;
- /* Read the register number */
- regno = strtol ((const char *) p, &p_temp, 16);
+ /* Read the ``P'' register number. */
+ LONGEST pnum = strtol ((const char *) p, &p_temp, 16);
p1 = (unsigned char *) p_temp;
if (p1 == p) /* No register number present here */
}
else
{
+ struct packet_reg *reg = packet_reg_from_pnum (rs, pnum);
p = p1;
if (*p++ != ':')
Packet: '%s'\n",
p, buf);
- if (regno >= NUM_REGS)
- warning ("Remote sent bad register number %ld: %s\n\
+ if (reg == NULL)
+ warning ("Remote sent bad register number %s: %s\n\
Packet: '%s'\n",
- regno, p, buf);
+ phex_nz (pnum, 0), p, buf);
- fieldsize = hex2bin (p, regs, REGISTER_RAW_SIZE (regno));
+ fieldsize = hex2bin (p, regs, REGISTER_RAW_SIZE (reg->regnum));
p += 2 * fieldsize;
- if (fieldsize < REGISTER_RAW_SIZE (regno))
+ if (fieldsize < REGISTER_RAW_SIZE (reg->regnum))
warning ("Remote reply is too short: %s", buf);
- supply_register (regno, regs);
+ supply_register (reg->regnum, regs);
}
if (*p++ != ';')
case 'T': /* Status with PC, SP, FP, ... */
{
int i;
- long regno;
char* regs = (char*) alloca (MAX_REGISTER_RAW_SIZE);
/* Expedited reply, containing Signal, {regno, reg} repeat */
int fieldsize;
/* Read the register number */
- regno = strtol ((const char *) p, &p_temp, 16);
+ long pnum = strtol ((const char *) p, &p_temp, 16);
p1 = (unsigned char *) p_temp;
if (p1 == p) /* No register number present here */
}
else
{
+ struct packet_reg *reg = packet_reg_from_pnum (rs, pnum);
p = p1;
-
if (*p++ != ':')
warning ("Malformed packet(b) (missing colon): %s\n\
Packet: '%s'\n",
p, buf);
- if (regno >= NUM_REGS)
+ if (reg == NULL)
warning ("Remote sent bad register number %ld: %s\n\
Packet: '%s'\n",
- regno, p, buf);
+ pnum, p, buf);
- fieldsize = hex2bin (p, regs, REGISTER_RAW_SIZE (regno));
+ fieldsize = hex2bin (p, regs, REGISTER_RAW_SIZE (reg->regnum));
p += 2 * fieldsize;
- if (fieldsize < REGISTER_RAW_SIZE (regno))
+ if (fieldsize < REGISTER_RAW_SIZE (reg->regnum))
warning ("Remote reply is too short: %s", buf);
- supply_register (regno, regs);
+ supply_register (reg->regnum, regs);
}
if (*p++ != ';')
static int register_bytes_found;
/* Read the remote registers into the block REGS. */
-/* Currently we just read all the registers, so we don't use regno. */
+/* Currently we just read all the registers, so we don't use regnum. */
/* ARGSUSED */
static void
-remote_fetch_registers (int regno)
+remote_fetch_registers (int regnum)
{
struct remote_state *rs = get_remote_state ();
char *buf = alloca (rs->remote_packet_size);
int i;
char *p;
- char *regs = alloca (REGISTER_BYTES);
+ char *regs = alloca (rs->sizeof_g_packet);
set_thread (PIDGET (inferior_ptid), 1);
+ if (regnum >= 0)
+ {
+ struct packet_reg *reg = packet_reg_from_regnum (rs, regnum);
+ gdb_assert (reg != NULL);
+ if (!reg->in_g_packet)
+ internal_error (__FILE__, __LINE__,
+ "Attempt to fetch a non G-packet register when this "
+ "remote.c does not support the p-packet.");
+ }
+
sprintf (buf, "g");
remote_send (buf, (rs->remote_packet_size));
(rs->actual_register_packet_size) = strlen (buf);
/* Unimplemented registers read as all bits zero. */
- memset (regs, 0, REGISTER_BYTES);
+ memset (regs, 0, rs->sizeof_g_packet);
/* We can get out of synch in various cases. If the first character
in the buffer is not a hex character, assume that has happened
register cacheing/storage mechanism. */
p = buf;
- for (i = 0; i < REGISTER_BYTES; i++)
+ for (i = 0; i < rs->sizeof_g_packet; i++)
{
if (p[0] == 0)
break;
warning ("Remote reply is too short: %s", buf);
}
-supply_them:
- for (i = 0; i < NUM_REGS; i++)
- {
- supply_register (i, ®s[REGISTER_BYTE (i)]);
- if (buf[REGISTER_BYTE (i) * 2] == 'x')
- set_register_cached (i, -1);
- }
+ supply_them:
+ {
+ int i;
+ for (i = 0; i < NUM_REGS + NUM_PSEUDO_REGS; i++)
+ {
+ struct packet_reg *r = &rs->regs[i];
+ if (r->in_g_packet)
+ {
+ supply_register (r->regnum, regs + r->offset);
+ if (buf[r->offset * 2] == 'x')
+ set_register_cached (i, -1);
+ }
+ }
+ }
}
/* Prepare to store registers. Since we may send them all (using a
{
case PACKET_DISABLE:
case PACKET_SUPPORT_UNKNOWN:
- read_register_bytes (0, (char *) NULL, REGISTER_BYTES);
+ /* NOTE: This isn't rs->sizeof_g_packet because here, we are
+ forcing the register cache to read its and not the target
+ registers. */
+ read_register_bytes (0, (char *) NULL, REGISTER_BYTES); /* OK use. */
break;
case PACKET_ENABLE:
break;
}
}
-/* Helper: Attempt to store REGNO using the P packet. Return fail IFF
+/* Helper: Attempt to store REGNUM using the P packet. Return fail IFF
packet was not recognized. */
static int
-store_register_using_P (int regno)
+store_register_using_P (int regnum)
{
struct remote_state *rs = get_remote_state ();
+ struct packet_reg *reg = packet_reg_from_regnum (rs, regnum);
/* Try storing a single register. */
char *buf = alloca (rs->remote_packet_size);
char *regp = alloca (MAX_REGISTER_RAW_SIZE);
char *p;
int i;
- sprintf (buf, "P%x=", regno);
+ sprintf (buf, "P%s=", phex_nz (reg->pnum, 0));
p = buf + strlen (buf);
- regcache_collect (regno, regp);
- bin2hex (regp, p, REGISTER_RAW_SIZE (regno));
- remote_send (buf, (rs->remote_packet_size));
+ regcache_collect (reg->regnum, regp);
+ bin2hex (regp, p, REGISTER_RAW_SIZE (reg->regnum));
+ remote_send (buf, rs->remote_packet_size);
return buf[0] != '\0';
}
-/* Store register REGNO, or all registers if REGNO == -1, from the contents
+/* Store register REGNUM, or all registers if REGNUM == -1, from the contents
of the register cache buffer. FIXME: ignores errors. */
static void
-remote_store_registers (int regno)
+remote_store_registers (int regnum)
{
struct remote_state *rs = get_remote_state ();
char *buf;
set_thread (PIDGET (inferior_ptid), 1);
- if (regno >= 0)
+ if (regnum >= 0)
{
switch (remote_protocol_P.support)
{
case PACKET_DISABLE:
break;
case PACKET_ENABLE:
- if (store_register_using_P (regno))
+ if (store_register_using_P (regnum))
return;
else
error ("Protocol error: P packet not recognized by stub");
case PACKET_SUPPORT_UNKNOWN:
- if (store_register_using_P (regno))
+ if (store_register_using_P (regnum))
{
/* The stub recognized the 'P' packet. Remember this. */
remote_protocol_P.support = PACKET_ENABLE;
local buffer. */
{
int i;
- regs = alloca (REGISTER_BYTES);
- memset (regs, REGISTER_BYTES, 0);
- for (i = 0; i < NUM_REGS; i++)
+ regs = alloca (rs->sizeof_g_packet);
+ memset (regs, rs->sizeof_g_packet, 0);
+ for (i = 0; i < NUM_REGS + NUM_PSEUDO_REGS; i++)
{
- regcache_collect (i, regs + REGISTER_BYTE (i));
+ struct packet_reg *r = &rs->regs[i];
+ if (r->in_g_packet)
+ regcache_collect (r->regnum, regs + r->offset);
}
}
/* ARGSUSED */
static int
remote_xfer_memory (CORE_ADDR mem_addr, char *buffer, int mem_len,
- int should_write,
- struct mem_attrib *attrib ATTRIBUTE_UNUSED,
+ int should_write, struct mem_attrib *attrib,
struct target_ops *target)
{
CORE_ADDR targ_addr;
if (val == 0)
{
- if (TARGET_BYTE_ORDER == BIG_ENDIAN)
+ if (TARGET_BYTE_ORDER == BFD_ENDIAN_BIG)
val = target_write_memory (addr, (char *) big_break_insn,
sizeof big_break_insn);
else
getpkt (buf, (rs->remote_packet_size), 0);
if (buf[0] == 'E')
- error ("target memory fault, section %s, range 0x%08x -- 0x%08x",
- sectname, lma, lma + size);
+ error ("target memory fault, section %s, range 0x%s -- 0x%s",
+ sectname, paddr (lma), paddr (lma + size));
if (buf[0] != 'C')
error ("remote target does not support this operation");
static void
remote_cisco_open (char *name, int from_tty)
{
+ int ex;
if (name == 0)
- error (
- "To open a remote debug connection, you need to specify what \n\
-device is attached to the remote system (e.g. host:port).");
+ error ("To open a remote debug connection, you need to specify what \n"
+ "device is attached to the remote system (e.g. host:port).");
/* See FIXME above */
wait_forever_enabled_p = 1;
unpush_target (&remote_cisco_ops);
- remote_desc = serial_open (name);
+ remote_desc = remote_serial_open (name);
if (!remote_desc)
perror_with_name (name);
someday have a notion of debugging several processes. */
inferior_ptid = pid_to_ptid (MAGIC_NULL_PID);
- /* Start the remote connection; if error (0), discard this target. */
-
- if (!catch_errors (remote_start_remote_dummy, (char *) 0,
- "Couldn't establish connection to remote target\n",
- RETURN_MASK_ALL))
+ /* Start the remote connection; if error, discard this target. See
+ the comments in remote_open_1() for further details such as the
+ need to re-throw the exception. */
+ ex = catch_exceptions (uiout,
+ remote_start_remote_dummy, NULL,
+ "Couldn't establish connection to remote"
+ " target\n",
+ RETURN_MASK_ALL);
+ if (ex < 0)
{
pop_target ();
- return;
+ throw_exception (ex);
}
}
if (query ("Interrupt GDB? "))
{
printf_filtered ("Interrupted by user.\n");
- return_to_top_level (RETURN_QUIT);
+ throw_exception (RETURN_QUIT);
}
quit_count = 0;
}
static void
show_remote_cmd (char *args, int from_tty)
{
-
- show_remote_protocol_Z_packet_cmd (args, from_tty);
- show_remote_protocol_e_packet_cmd (args, from_tty);
- show_remote_protocol_E_packet_cmd (args, from_tty);
- show_remote_protocol_P_packet_cmd (args, from_tty);
- show_remote_protocol_qSymbol_packet_cmd (args, from_tty);
- show_remote_protocol_binary_download_cmd (args, from_tty);
+ /* FIXME: cagney/2002-06-15: This function should iterate over
+ remote_show_cmdlist for a list of sub commands to show. */
+ show_remote_protocol_Z_packet_cmd (args, from_tty, NULL);
+ show_remote_protocol_e_packet_cmd (args, from_tty, NULL);
+ show_remote_protocol_E_packet_cmd (args, from_tty, NULL);
+ show_remote_protocol_P_packet_cmd (args, from_tty, NULL);
+ show_remote_protocol_qSymbol_packet_cmd (args, from_tty, NULL);
+ show_remote_protocol_binary_download_cmd (args, from_tty, NULL);
}
static void
terminating `#' character and checksum.",
&maintenancelist);
- add_show_from_set
- (add_set_boolean_cmd ("remotebreak", no_class, &remote_break,
- "Set whether to send break if interrupted.\n",
- &setlist),
- &showlist);
+ add_setshow_boolean_cmd ("remotebreak", no_class, &remote_break,
+ "Set whether to send break if interrupted.\n",
+ "Show whether to send break if interrupted.\n",
+ NULL, NULL,
+ &setlist, &showlist);
/* Install commands for configuring memory read/write packets. */
show_remote_protocol_e_packet_cmd,
&remote_set_cmdlist, &remote_show_cmdlist,
0);
+ /* Disable by default. The ``e'' packet has nasty interactions with
+ the threading code - it relies on global state. */
+ remote_protocol_e.detect = AUTO_BOOLEAN_FALSE;
+ update_packet_config (&remote_protocol_e);
add_packet_config_cmd (&remote_protocol_E,
"E", "step-over-range-w-signal",
show_remote_protocol_E_packet_cmd,
&remote_set_cmdlist, &remote_show_cmdlist,
0);
+ /* Disable by default. The ``e'' packet has nasty interactions with
+ the threading code - it relies on global state. */
+ remote_protocol_E.detect = AUTO_BOOLEAN_FALSE;
+ update_packet_config (&remote_protocol_E);
add_packet_config_cmd (&remote_protocol_P,
"P", "set-register",
0);
/* Keep the old ``set remote Z-packet ...'' working. */
- tmpcmd = add_set_auto_boolean_cmd ("Z-packet", class_obscure,
- &remote_Z_packet_detect,
- "\
-Set use of remote protocol `Z' packets", &remote_set_cmdlist);
- tmpcmd->function.sfunc = set_remote_protocol_Z_packet_cmd;
- add_cmd ("Z-packet", class_obscure, show_remote_protocol_Z_packet_cmd,
- "Show use of remote protocol `Z' packets ",
- &remote_show_cmdlist);
+ add_setshow_auto_boolean_cmd ("Z-packet", class_obscure,
+ &remote_Z_packet_detect, "\
+Set use of remote protocol `Z' packets",
+ "Show use of remote protocol `Z' packets ",
+ set_remote_protocol_Z_packet_cmd,
+ show_remote_protocol_Z_packet_cmd,
+ &remote_set_cmdlist, &remote_show_cmdlist);
}