2005-02-11 Andrew Cagney <cagney@gnu.org>
[deliverable/binutils-gdb.git] / gdb / remote-utils.c
index 1b9ae39970eb1c8e1e01647f1fb65b99abe71fbe..d4775ad631e0016819503e920ee17c9638e161e3 100644 (file)
@@ -1,6 +1,7 @@
 /* Generic support for remote debugging interfaces.
 
-   Copyright 1993, 1994, 1998 Free Software Foundation, Inc.
+   Copyright 1993, 1994, 1995, 1996, 1998, 2000, 2001
+   Free Software Foundation, Inc.
 
    This file is part of GDB.
 
 #include "gdbcore.h"           /* for exec_bfd */
 #include "inferior.h"          /* for generic_mourn_inferior */
 #include "remote-utils.h"
+#include "regcache.h"
 
 
-void _initialize_sr_support PARAMS ((void));
+void _initialize_sr_support (void);
 
 struct _sr_settings sr_settings =
 {
@@ -74,19 +76,17 @@ struct _sr_settings sr_settings =
 
 struct gr_settings *gr_settings = NULL;
 
-static void usage PARAMS ((char *, char *));
-static void sr_com PARAMS ((char *, int));
+static void usage (char *, char *);
+static void sr_com (char *, int);
 
 static void
-usage (proto, junk)
-     char *proto;
-     char *junk;
+usage (char *proto, char *junk)
 {
   if (junk != NULL)
     fprintf_unfiltered (gdb_stderr, "Unrecognized arguments: `%s'.\n", junk);
 
-  error ("Usage: target %s [DEVICE [SPEED [DEBUG]]]\n\
-where DEVICE is the name of a device or HOST:PORT", proto, proto);
+  error (_("Usage: target %s [DEVICE [SPEED [DEBUG]]]\n\
+where DEVICE is the name of a device or HOST:PORT"), proto);
 
   return;
 }
@@ -103,9 +103,7 @@ where DEVICE is the name of a device or HOST:PORT", proto, proto);
 }
 
 void
-sr_scan_args (proto, args)
-     char *proto;
-     char *args;
+sr_scan_args (char *proto, char *args)
 {
   int n;
   char *p, *q;
@@ -149,17 +147,14 @@ sr_scan_args (proto, args)
 }
 
 void
-gr_generic_checkin ()
+gr_generic_checkin (void)
 {
   sr_write_cr ("");
   gr_expect_prompt ();
 }
 
 void
-gr_open (args, from_tty, gr)
-     char *args;
-     int from_tty;
-     struct gr_settings *gr;
+gr_open (char *args, int from_tty, struct gr_settings *gr)
 {
   target_preopen (from_tty);
   sr_scan_args (gr->ops->to_shortname, args);
@@ -167,8 +162,6 @@ gr_open (args, from_tty, gr)
 
   gr_settings = gr;
 
-  gr_set_dcache (dcache_init (gr->readfunc, gr->writefunc));
-
   if (sr_get_desc () != NULL)
     gr_close (0);
 
@@ -179,24 +172,24 @@ gr_open (args, from_tty, gr)
   if (sr_get_device () == NULL)
     usage (gr->ops->to_shortname, NULL);
 
-  sr_set_desc (SERIAL_OPEN (sr_get_device ()));
+  sr_set_desc (serial_open (sr_get_device ()));
   if (!sr_get_desc ())
     perror_with_name ((char *) sr_get_device ());
 
   if (baud_rate != -1)
     {
-      if (SERIAL_SETBAUDRATE (sr_get_desc (), baud_rate) != 0)
+      if (serial_setbaudrate (sr_get_desc (), baud_rate) != 0)
        {
-         SERIAL_CLOSE (sr_get_desc ());
+         serial_close (sr_get_desc ());
          perror_with_name (sr_get_device ());
        }
     }
 
-  SERIAL_RAW (sr_get_desc ());
+  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 ());
+  serial_flush_input (sr_get_desc ());
 
   /* default retries */
   if (sr_get_retries () == 0)
@@ -225,14 +218,14 @@ gr_open (args, from_tty, gr)
    and doing all the fancy timeout stuff.  */
 
 int
-sr_readchar ()
+sr_readchar (void)
 {
   int buf;
 
-  buf = SERIAL_READCHAR (sr_get_desc (), sr_get_timeout ());
+  buf = serial_readchar (sr_get_desc (), sr_get_timeout ());
 
   if (buf == SERIAL_TIMEOUT)
-    error ("Timeout reading from remote system.");
+    error (_("Timeout reading from remote system."));
 
   if (sr_get_debug () > 0)
     printf_unfiltered ("%c", buf);
@@ -241,11 +234,11 @@ sr_readchar ()
 }
 
 int
-sr_pollchar ()
+sr_pollchar (void)
 {
   int buf;
 
-  buf = SERIAL_READCHAR (sr_get_desc (), 0);
+  buf = serial_readchar (sr_get_desc (), 0);
   if (buf == SERIAL_TIMEOUT)
     buf = 0;
   if (sr_get_debug () > 0)
@@ -262,12 +255,11 @@ sr_pollchar ()
 /* Keep discarding input from the remote system, until STRING is found.
    Let the user break out immediately.  */
 void
-sr_expect (string)
-     char *string;
+sr_expect (char *string)
 {
   char *p = string;
 
-  immediate_quit = 1;
+  immediate_quit++;
   while (1)
     {
       if (sr_readchar () == *p)
@@ -275,7 +267,7 @@ sr_expect (string)
          p++;
          if (*p == '\0')
            {
-             immediate_quit = 0;
+             immediate_quit--;
              return;
            }
        }
@@ -285,14 +277,12 @@ sr_expect (string)
 }
 
 void
-sr_write (a, l)
-     char *a;
-     int l;
+sr_write (char *a, int l)
 {
   int i;
 
-  if (SERIAL_WRITE (sr_get_desc (), a, l) != 0)
-    perror_with_name ("sr_write: Error writing to remote");
+  if (serial_write (sr_get_desc (), a, l) != 0)
+    perror_with_name (_("sr_write: Error writing to remote"));
 
   if (sr_get_debug () > 0)
     for (i = 0; i < l; i++)
@@ -302,8 +292,7 @@ sr_write (a, l)
 }
 
 void
-sr_write_cr (s)
-     char *s;
+sr_write_cr (char *s)
 {
   sr_write (s, strlen (s));
   sr_write ("\r", 1);
@@ -311,9 +300,7 @@ sr_write_cr (s)
 }
 
 int
-sr_timed_read (buf, n)
-     char *buf;
-     int n;
+sr_timed_read (char *buf, int n)
 {
   int i;
   char c;
@@ -336,8 +323,7 @@ sr_timed_read (buf, n)
    ignore_space is nonzero, ignore spaces (not newline, tab, etc).  */
 
 int
-sr_get_hex_digit (ignore_space)
-     int ignore_space;
+sr_get_hex_digit (int ignore_space)
 {
   int ch;
 
@@ -353,7 +339,7 @@ sr_get_hex_digit (ignore_space)
       else if (ch != ' ' || !ignore_space)
        {
          gr_expect_prompt ();
-         error ("Invalid hex digit from remote system.");
+         error (_("Invalid hex digit from remote system."));
        }
     }
 }
@@ -361,8 +347,7 @@ sr_get_hex_digit (ignore_space)
 /* Get a byte from the remote and put it in *BYT.  Accept any number
    leading spaces.  */
 void
-sr_get_hex_byte (byt)
-     char *byt;
+sr_get_hex_byte (char *byt)
 {
   int val;
 
@@ -373,7 +358,7 @@ sr_get_hex_byte (byt)
 
 /* Read a 32-bit hex word from the remote, preceded by a space  */
 long
-sr_get_hex_word ()
+sr_get_hex_word (void)
 {
   long val;
   int j;
@@ -391,9 +376,7 @@ sr_get_hex_word ()
    FIXME: Can't handle commands that take input.  */
 
 static void
-sr_com (args, fromtty)
-     char *args;
-     int fromtty;
+sr_com (char *args, int fromtty)
 {
   sr_check_open ();
 
@@ -409,14 +392,13 @@ sr_com (args, fromtty)
 }
 
 void
-gr_close (quitting)
-     int quitting;
+gr_close (int quitting)
 {
   gr_clear_all_breakpoints ();
 
   if (sr_is_open ())
     {
-      SERIAL_CLOSE (sr_get_desc ());
+      serial_close (sr_get_desc ());
       sr_set_desc (NULL);
     }
 
@@ -432,12 +414,10 @@ gr_close (quitting)
    with your gdb.  */
 
 void
-gr_detach (args, from_tty)
-     char *args;
-     int from_tty;
+gr_detach (char *args, int from_tty)
 {
   if (args)
-    error ("Argument given to \"detach\" when remotely debugging.");
+    error (_("Argument given to \"detach\" when remotely debugging."));
 
   if (sr_is_open ())
     gr_clear_all_breakpoints ();
@@ -450,8 +430,7 @@ gr_detach (args, from_tty)
 }
 
 void
-gr_files_info (ops)
-     struct target_ops *ops;
+gr_files_info (struct target_ops *ops)
 {
 #ifdef __GO32__
   printf_filtered ("\tAttached to DOS asynctsr\n");
@@ -471,7 +450,7 @@ gr_files_info (ops)
 }
 
 void
-gr_mourn ()
+gr_mourn (void)
 {
   gr_clear_all_breakpoints ();
   unpush_target (gr_get_ops ());
@@ -479,7 +458,7 @@ gr_mourn ()
 }
 
 void
-gr_kill ()
+gr_kill (void)
 {
   return;
 }
@@ -487,18 +466,15 @@ gr_kill ()
 /* This is called not only when we first attach, but also when the
    user types "run" after having attached.  */
 void
-gr_create_inferior (execfile, args, env)
-     char *execfile;
-     char *args;
-     char **env;
+gr_create_inferior (char *execfile, char *args, char **env)
 {
   int entry_pt;
 
   if (args && *args)
-    error ("Can't pass arguments to remote process.");
+    error (_("Can't pass arguments to remote process."));
 
   if (execfile == 0 || exec_bfd == 0)
-    error ("No executable file specified");
+    error (_("No executable file specified"));
 
   entry_pt = (int) bfd_get_start_address (exec_bfd);
   sr_check_open ();
@@ -521,9 +497,7 @@ gr_create_inferior (execfile, args, env)
    pass non-matching data on.  */
 
 int
-gr_multi_scan (list, passthrough)
-     char *list[];
-     int passthrough;
+gr_multi_scan (char *list[], int passthrough)
 {
   char *swallowed = NULL;      /* holding area */
   char *swallowed_p = swallowed;       /* Current position in swallowed.  */
@@ -613,42 +587,22 @@ gr_multi_scan (list, passthrough)
    debugged.  */
 
 void
-gr_prepare_to_store ()
+gr_prepare_to_store (void)
 {
   /* Do nothing, since we assume we can store individual regs */
 }
 
-/* Read a word from remote address ADDR and return it.
- * This goes through the data cache.
- */
-int
-gr_fetch_word (addr)
-     CORE_ADDR addr;
-{
-  return dcache_fetch (gr_get_dcache (), addr);
-}
-
-/* Write a word WORD into remote address ADDR.
-   This goes through the data cache.  */
-
-void
-gr_store_word (addr, word)
-     CORE_ADDR addr;
-     int word;
-{
-  dcache_poke (gr_get_dcache (), addr, word);
-}
-
 void
-_initialize_sr_support ()
+_initialize_sr_support (void)
 {
 /* FIXME-now: if target is open... */
-  add_show_from_set (add_set_cmd ("remotedevice", no_class,
-                                 var_filename, (char *) &sr_settings.device,
-                                 "Set device for remote serial I/O.\n\
+  deprecated_add_show_from_set
+    (add_set_cmd ("remotedevice", no_class,
+                 var_filename, (char *) &sr_settings.device,
+                 "Set device for remote serial I/O.\n\
 This device is used as the serial port when debugging using remote\n\
 targets.", &setlist),
-                    &showlist);
+     &showlist);
 
   add_com ("remote <command>", class_obscure, sr_com,
           "Send a command to the remote monitor.");
This page took 0.030461 seconds and 4 git commands to generate.