* gas/cfi/cfi-common-6.s: Do not use |.
[deliverable/binutils-gdb.git] / gdb / remote-sds.c
index 507ac5be208a0a8ee8e90403c227bda3439d2bb7..b788792aeabdb01b4da8c827a3416cd9e5ffa891 100644 (file)
@@ -1,6 +1,6 @@
 /* Remote target communications for serial-line targets using SDS' protocol.
 
-   Copyright 1997, 1998, 1999, 2000, 2001, 2002 Free Software
+   Copyright (C) 1997, 1998, 1999, 2000, 2001, 2002, 2004, 2006 Free Software
    Foundation, Inc.
 
    This file is part of GDB.
@@ -17,8 +17,8 @@
 
    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., 59 Temple Place - Suite 330,
-   Boston, MA 02111-1307, USA.  */
+   Foundation, Inc., 51 Franklin Street, Fifth Floor,
+   Boston, MA 02110-1301, USA.  */
 
 /* This interface was written by studying the behavior of the SDS
    monitor on an ADS 821/860 board, and by consulting the
@@ -30,6 +30,7 @@
 #include <fcntl.h>
 #include "frame.h"
 #include "inferior.h"
+#include "exceptions.h"
 #include "bfd.h"
 #include "symfile.h"
 #include "target.h"
 #include "gdbcore.h"
 #include "regcache.h"
 
-#ifdef USG
-#include <sys/types.h>
-#endif
-
 #include <signal.h>
 #include "serial.h"
 
@@ -66,7 +63,7 @@ static void sds_fetch_registers (int);
 
 static void sds_resume (ptid_t, int, enum target_signal);
 
-static int sds_start_remote (PTR);
+static int sds_start_remote (void *);
 
 static void sds_open (char *, int);
 
@@ -76,8 +73,6 @@ static void sds_store_registers (int);
 
 static void sds_mourn (void);
 
-static void sds_create_inferior (char *, char *, char **);
-
 static void sds_load (char *, int);
 
 static int getmessage (unsigned char *, int);
@@ -92,8 +87,6 @@ static ptid_t sds_wait (ptid_t, struct target_waitstatus *);
 
 static void sds_kill (void);
 
-static int tohex (int);
-
 static int fromhex (int);
 
 static void sds_detach (char *, int);
@@ -106,10 +99,6 @@ static void interrupt_query (void);
 
 static int read_frame (char *);
 
-static int sds_insert_breakpoint (CORE_ADDR, char *);
-
-static int sds_remove_breakpoint (CORE_ADDR, char *);
-
 static void init_sds_ops (void);
 
 static void sds_command (char *args, int from_tty);
@@ -148,7 +137,6 @@ static int message_pending;
 
 /* Clean up connection to a remote debugger.  */
 
-/* ARGSUSED */
 static void
 sds_close (int quitting)
 {
@@ -160,8 +148,9 @@ sds_close (int quitting)
 /* Stub for catch_errors.  */
 
 static int
-sds_start_remote (PTR dummy)
+sds_start_remote (void *from_tty_p)
 {
+  int from_tty = * (int *) from_tty;
   int c;
   unsigned char buf[200];
 
@@ -185,7 +174,7 @@ sds_start_remote (PTR dummy)
 
   immediate_quit--;
 
-  start_remote ();             /* Initialize gdb process mechanisms */
+  start_remote (from_tty);     /* Initialize gdb process mechanisms */
   return 1;
 }
 
@@ -236,7 +225,7 @@ device is attached to the remote system (e.g. /dev/ttya).");
   /* 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 (sds_start_remote, NULL,
+  if (!catch_errors (sds_start_remote, &from_tty,
                     "Couldn't establish connection to remote target\n",
                     RETURN_MASK_ALL))
     pop_target ();
@@ -279,17 +268,6 @@ fromhex (int a)
     error ("Reply contains invalid hex digit %d", a);
 }
 
-/* Convert number NIB to a hex digit.  */
-
-static int
-tohex (int nib)
-{
-  if (nib < 10)
-    return '0' + nib;
-  else
-    return 'a' + nib - 10;
-}
-
 static int
 tob64 (unsigned char *inbuf, char *outbuf, int len)
 {
@@ -405,7 +383,7 @@ interrupt_query (void)
 Give up (and stop debugging it)? "))
     {
       target_mourn_inferior ();
-      throw_exception (RETURN_QUIT);
+      deprecated_throw_reason (RETURN_QUIT);
     }
 
   target_terminal_inferior ();
@@ -467,16 +445,15 @@ static unsigned char sprs[16];
 /* Read the remote registers into the block REGS.  */
 /* Currently we just read all the registers, so we don't use regno.  */
 
-/* ARGSUSED */
 static void
 sds_fetch_registers (int regno)
 {
   unsigned char buf[PBUFSIZ];
   int i, retlen;
-  char regs[REGISTER_BYTES];
+  char *regs = alloca (deprecated_register_bytes ());
 
   /* Unimplemented registers read as all bits zero.  */
-  memset (regs, 0, REGISTER_BYTES);
+  memset (regs, 0, deprecated_register_bytes ());
 
   buf[0] = 18;
   buf[1] = 1;
@@ -499,7 +476,8 @@ sds_fetch_registers (int regno)
   /* (should warn about reply too short) */
 
   for (i = 0; i < NUM_REGS; i++)
-    supply_register (i, &regs[REGISTER_BYTE (i)]);
+    regcache_raw_supply (current_regcache, i,
+                        &regs[DEPRECATED_REGISTER_BYTE (i)]);
 }
 
 /* Prepare to store registers.  Since we may send them all, we have to
@@ -509,7 +487,7 @@ static void
 sds_prepare_to_store (void)
 {
   /* Make sure the entire registers array is valid.  */
-  read_register_bytes (0, (char *) NULL, REGISTER_BYTES);
+  deprecated_read_register_bytes (0, (char *) NULL, deprecated_register_bytes ());
 }
 
 /* Store register REGNO, or all registers if REGNO == -1, from the contents
@@ -528,7 +506,7 @@ sds_store_registers (int regno)
   *p++ = 0;
   *p++ = 0;
   for (i = 0; i < 4 * 6; i++)
-    *p++ = registers[i + 4 * 32 + 8 * 32];
+    *p++ = deprecated_registers[i + 4 * 32 + 8 * 32];
   for (i = 0; i < 4 * 1; i++)
     *p++ = 0;
   for (i = 0; i < 4 * 4; i++)
@@ -543,7 +521,7 @@ sds_store_registers (int regno)
   *p++ = 0;
   *p++ = 0;
   for (i = 0; i < 4 * 32; i++)
-    *p++ = registers[i];
+    *p++ = deprecated_registers[i];
 
   sds_send (buf, p - buf);
 
@@ -657,7 +635,6 @@ sds_read_bytes (CORE_ADDR memaddr, char *myaddr, int len)
    if SHOULD_WRITE is nonzero.  Returns length of data written or
    read; 0 for error.  TARGET is unused.  */
 
-/* ARGSUSED */
 static int
 sds_xfer_memory (CORE_ADDR memaddr, char *myaddr, int len, int should_write,
                 struct mem_attrib *attrib, struct target_ops *target)
@@ -748,7 +725,7 @@ putmessage (unsigned char *buf, int len)
      and giving it a checksum.  */
 
   if (len > 170)               /* Prosanity check */
-    internal_error (__FILE__, __LINE__, "failed internal consistency check");
+    internal_error (__FILE__, __LINE__, _("failed internal consistency check"));
 
   if (remote_debug)
     {
@@ -978,6 +955,7 @@ getmessage (unsigned char *buf, int forever)
       /* Try the whole thing again.  */
     retry:
       /* need to do something here */
+      ;
     }
 
   /* We have tried hard enough, and just can't receive the packet.  Give up. */
@@ -1000,15 +978,14 @@ sds_mourn (void)
 }
 
 static void
-sds_create_inferior (char *exec_file, char *args, char **env)
+sds_create_inferior (char *exec_file, char *args, char **env, int from_tty)
 {
   inferior_ptid = pid_to_ptid (42000);
 
   /* Clean up from the last time we were running.  */
   clear_proceed_status ();
 
-  /* Let the remote process run.  */
-  proceed (bfd_get_start_address (exec_bfd), TARGET_SIGNAL_0, 0);
+  write_pc (bfd_get_start_address (exec_bfd));
 }
 
 static void
@@ -1024,8 +1001,9 @@ sds_load (char *filename, int from_tty)
    replaced instruction back to the debugger.  */
 
 static int
-sds_insert_breakpoint (CORE_ADDR addr, char *contents_cache)
+sds_insert_breakpoint (struct bp_target_info *bp_tgt)
 {
+  CORE_ADDR addr = bp_tgt->placed_address;
   int i, retlen;
   unsigned char *p, buf[PBUFSIZ];
 
@@ -1040,14 +1018,15 @@ sds_insert_breakpoint (CORE_ADDR addr, char *contents_cache)
   retlen = sds_send (buf, p - buf);
 
   for (i = 0; i < 4; ++i)
-    contents_cache[i] = buf[i + 2];
+    bp_tgt->shadow_contents[i] = buf[i + 2];
 
   return 0;
 }
 
 static int
-sds_remove_breakpoint (CORE_ADDR addr, char *contents_cache)
+sds_remove_breakpoint (struct bp_target_info *bp_tgt)
 {
+  CORE_ADDR addr = bp_tgt->placed_address;
   int i, retlen;
   unsigned char *p, buf[PBUFSIZ];
 
@@ -1059,7 +1038,7 @@ sds_remove_breakpoint (CORE_ADDR addr, char *contents_cache)
   *p++ = (int) (addr >> 8) & 0xff;
   *p++ = (int) (addr) & 0xff;
   for (i = 0; i < 4; ++i)
-    *p++ = contents_cache[i];
+    *p++ = bp_tgt->shadow_contents[i];
 
   retlen = sds_send (buf, p - buf);
 
@@ -1081,7 +1060,7 @@ Specify the serial device it is connected to (e.g. /dev/ttya).";
   sds_ops.to_fetch_registers = sds_fetch_registers;
   sds_ops.to_store_registers = sds_store_registers;
   sds_ops.to_prepare_to_store = sds_prepare_to_store;
-  sds_ops.to_xfer_memory = sds_xfer_memory;
+  sds_ops.deprecated_xfer_memory = sds_xfer_memory;
   sds_ops.to_files_info = sds_files_info;
   sds_ops.to_insert_breakpoint = sds_insert_breakpoint;
   sds_ops.to_remove_breakpoint = sds_remove_breakpoint;
@@ -1135,11 +1114,13 @@ _initialize_remote_sds (void)
   init_sds_ops ();
   add_target (&sds_ops);
 
-  add_show_from_set (add_set_cmd ("sdstimeout", no_class,
-                                 var_integer, (char *) &sds_timeout,
-                            "Set timeout value for sds read.\n", &setlist),
-                    &showlist);
+  add_setshow_integer_cmd ("sdstimeout", no_class, &sds_timeout, _("\
+Set timeout value for sds read."), _("\
+Show timeout value for sds read."), NULL,
+                          NULL,
+                          NULL, /* FIXME: i18n: */
+                          &setlist, &showlist);
 
   add_com ("sds", class_obscure, sds_command,
-          "Send a command to the SDS monitor.");
+          _("Send a command to the SDS monitor."));
 }
This page took 0.031867 seconds and 4 git commands to generate.