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
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 *
{
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. */
/* 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"
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"
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 ();
/* 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;
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).");
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);
}