/* Generic support for remote debugging interfaces.
- Copyright 1993 Free Software Foundation, Inc.
+ Copyright 1993, 1994 Free Software Foundation, Inc.
This file is part of GDB.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
-Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
+Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
/* This file actually contains two distinct logical "packages". They
are packaged together in this one file because they are typically
* a pass through mode a la kermit or telnet.
* autobaud.
* ask remote to change his baud rate.
- * put generic load here.
-
*/
#include <ctype.h>
#include "defs.h"
+#include "gdb_string.h"
#include "gdbcmd.h"
#include "target.h"
#include "serial.h"
#include "remote-utils.h"
struct _sr_settings sr_settings = {
- 0, /* debug */
- 9600, /* baud */
4, /* timeout:
remote-hms.c had 2
remote-bug.c had "with a timeout of 2, we time out waiting for
struct gr_settings *gr_settings = NULL;
+static void usage PARAMS ((char *, char *));
+static void sr_com PARAMS ((char *, int));
+
static void
usage(proto, junk)
char *proto;
char *junk;
{
if (junk != NULL)
- fprintf(stderr, "Unrecognized arguments: `%s'.\n", junk);
+ fprintf_unfiltered(gdb_stderr, "Unrecognized arguments: `%s'.\n", junk);
- /* FIXME-now: service@host? */
-
- error("Usage: target %s <device <speed <debug>>>\n\
-or target %s <host> <port>\n", proto, proto);
+ error ("Usage: target %s [DEVICE [SPEED [DEBUG]]]\n\
+where DEVICE is the name of a device or HOST:PORT", proto, proto);
return;
}
int n;
char *p, *q;
- extern int strtol();
-
/* if no args, then nothing to do. */
if (args == NULL || *args == '\0')
return;
/* check for missing or empty baud rate. */
CHECKDONE(p, q);
- sr_set_baud_rate(n);
+ baud_rate = n;
/* look for debug value. */
n = strtol(p, &q, 10);
if (sr_get_desc() != NULL)
gr_close (0);
+ /* If no args are specified, then we use the device specified by a
+ previous command or "set remotedevice". But if there is no
+ device, better stop now, not dump core. */
+
+ if (sr_get_device () == NULL)
+ usage (gr->ops->to_shortname, NULL);
+
sr_set_desc(SERIAL_OPEN (sr_get_device()));
if (!sr_get_desc())
perror_with_name((char *) sr_get_device());
- if (SERIAL_SETBAUDRATE(sr_get_desc(), sr_get_baud_rate()) != 0)
+ if (baud_rate != -1)
{
- SERIAL_CLOSE(sr_get_desc());
- perror_with_name(sr_get_device());
+ if (SERIAL_SETBAUDRATE(sr_get_desc(), baud_rate) != 0)
+ {
+ SERIAL_CLOSE(sr_get_desc());
+ perror_with_name(sr_get_device());
+ }
}
SERIAL_RAW (sr_get_desc());
+ /* If there is something sitting in the buffer we might take it as a
+ response to a command, which would be bad. */
+ SERIAL_FLUSH_INPUT (sr_get_desc ());
+
/* default retries */
if (sr_get_retries() == 0)
sr_set_retries(1);
gr_settings->clear_all_breakpoints = remove_breakpoints;
if (from_tty)
- printf_filtered ("Remote debugging using `%s' at baud rate of %d\n",
- sr_get_device(), sr_get_baud_rate());
+ {
+ printf_filtered ("Remote debugging using `%s'", sr_get_device ());
+ if (baud_rate != -1)
+ printf_filtered (" at baud rate of %d",
+ baud_rate);
+ printf_filtered ("\n");
+ }
push_target(gr->ops);
gr_checkin();
error ("Timeout reading from remote system.");
if (sr_get_debug() > 0)
- printf ("%c", buf);
+ printf_unfiltered ("%c", buf);
return buf & 0x7f;
}
buf = 0;
if (sr_get_debug() > 0)
if (buf)
- printf ("%c", buf);
+ printf_unfiltered ("%c", buf);
else
- printf ("<empty character poll>");
+ printf_unfiltered ("<empty character poll>");
return buf & 0x7f;
}
if (sr_get_debug() > 0)
for (i = 0; i < l; i++)
- printf ("%c", a[i]);
+ printf_unfiltered ("%c", a[i]);
return;
}
prompt from the remote is seen.
FIXME: Can't handle commands that take input. */
-void
+static void
sr_com (args, fromtty)
char *args;
int fromtty;
sr_write_cr (args);
sr_write ("\030", 1);
+ registers_changed ();
gr_expect_prompt ();
}
gr_files_info (ops)
struct target_ops *ops;
{
- char *file = "nothing";
-
- if (exec_bfd)
- file = bfd_get_filename (exec_bfd);
-
- if (exec_bfd)
- {
#ifdef __GO32__
- printf_filtered ("\tAttached to DOS asynctsr\n");
+ printf_filtered ("\tAttached to DOS asynctsr\n");
#else
- printf_filtered ("\tAttached to %s at %d baud\n",
- sr_get_device(), sr_get_baud_rate());
+ printf_filtered ("\tAttached to %s", sr_get_device());
+ if (baud_rate != -1)
+ printf_filtered ("at %d baud", baud_rate);
+ printf_filtered ("\n");
#endif
- }
- printf_filtered ("\tand running program %s\n", file);
+ if (exec_bfd)
+ {
+ printf_filtered ("\tand running program %s\n",
+ bfd_get_filename (exec_bfd));
+ }
printf_filtered ("\tusing the %s protocol.\n", ops->to_shortname);
}
swallowed_p = swallowed = alloca(max_length << 1);
/* and a list of pointers to current scan points. */
- plist = alloca(string_count * sizeof(*plist));
+ plist = (char **) alloca (string_count * sizeof(*plist));
/* and initialize */
for (i = 0; i < string_count; ++i)
if (passthrough)
{
for (p = swallowed; p < swallowed_p; ++p)
- putc (*p, stdout);
+ fputc_unfiltered (*p, gdb_stdout);
- putc (ch, stdout);
+ fputc_unfiltered (ch, gdb_stdout);
}
swallowed_p = swallowed;
}
}
-
+#if 0
+ /* Never reached. */
return(-1);
+#endif
}
/* Get ready to modify the registers array. On machines which store
void
_initialize_sr_support ()
{
- add_show_from_set (add_set_cmd ("remotedebug", no_class,
- var_zinteger, (char *)&sr_settings.debug,
- "Set debugging of remote serial I/O.\n\
-When non-zero, each packet sent or received with the remote target\n\
-is displayed. Higher numbers produce more debugging.", &setlist),
- &showlist);
-
-/* FIXME-now: if target is open when baud changes... */
- add_show_from_set (add_set_cmd ("remotebaud", no_class,
- var_zinteger, (char *)&sr_settings.baud_rate,
- "Set baud rate for remote serial I/O.\n\
-This value is used to set the speed of the serial port when debugging\n\
-using remote targets.", &setlist),
- &showlist);
-
/* FIXME-now: if target is open... */
add_show_from_set (add_set_cmd ("remotedevice", no_class,
var_filename, (char *)&sr_settings.device,