2001-04-03 David Mosberger <davidm@hpl.hp.com>
[deliverable/binutils-gdb.git] / gdb / remote-bug.c
index e3a5a6778bcb83dcae3dc4e712aa3c23ee11f8c1..96c24913a731cacb5a1e0be594c2cdb197c812d4 100644 (file)
@@ -1,7 +1,8 @@
 /* Remote debugging interface for Motorola's MVME187BUG monitor, an embedded
    monitor for the m88k.
 
-   Copyright 1992, 1993 Free Software Foundation, Inc.
+   Copyright 1992, 1993, 1994, 1995, 1996, 1998, 1999, 2000, 2001
+   Free Software Foundation, Inc.
    Contributed by Cygnus Support.  Written by K. Richard Pixley.
 
    This file is part of GDB.
 
 #include "defs.h"
 #include "inferior.h"
-#include "gdb_wait.h"
-
 #include "gdb_string.h"
+#include "regcache.h"
 #include <ctype.h>
 #include <fcntl.h>
-#include <signal.h>
 #include <setjmp.h>
 #include <errno.h>
 
@@ -38,9 +37,6 @@
 
 #include "remote-utils.h"
 
-
-extern int sleep ();
-
 /* External data declarations */
 extern int stop_soon_quietly;  /* for wait_for_inferior */
 
@@ -111,9 +107,7 @@ static int need_artificial_trap = 0;
  */
 
 static void
-bug_load (args, fromtty)
-     char *args;
-     int fromtty;
+bug_load (char *args, int fromtty)
 {
   bfd *abfd;
   asection *s;
@@ -121,7 +115,6 @@ bug_load (args, fromtty)
 
   sr_check_open ();
 
-  dcache_flush (gr_get_dcache ());
   inferior_pid = 0;
   abfd = bfd_openr (args, 0);
   if (!abfd)
@@ -146,7 +139,7 @@ bug_load (args, fromtty)
 
          char *buffer = xmalloc (srec_frame);
 
-         printf_filtered ("%s\t: 0x%4x .. 0x%4x  ", s->name, s->vma, s->vma + s->_raw_size);
+         printf_filtered ("%s\t: 0x%4lx .. 0x%4lx  ", s->name, s->vma, s->vma + s->_raw_size);
          gdb_flush (gdb_stdout);
          for (i = 0; i < s->_raw_size; i += srec_frame)
            {
@@ -159,7 +152,7 @@ bug_load (args, fromtty)
              gdb_flush (gdb_stdout);
            }
          printf_filtered ("\n");
-         free (buffer);
+         xfree (buffer);
        }
       s = s->next;
     }
@@ -170,8 +163,7 @@ bug_load (args, fromtty)
 
 #if 0
 static char *
-get_word (p)
-     char **p;
+get_word (char **p)
 {
   char *s = *p;
   char *word;
@@ -201,12 +193,9 @@ get_word (p)
 
 static struct gr_settings bug_settings =
 {
-  NULL,                                /* dcache */
   "Bug>",                      /* prompt */
   &bug_ops,                    /* ops */
   bug_clear_breakpoints,       /* clear_all_breakpoints */
-  bug_read_memory,             /* readfunc */
-  bug_write_memory,            /* writefunc */
   gr_generic_checkin,          /* checkin */
 };
 
@@ -217,9 +206,7 @@ static char *cpu_check_strings[] =
 };
 
 static void
-bug_open (args, from_tty)
-     char *args;
-     int from_tty;
+bug_open (char *args, int from_tty)
 {
   if (args == NULL)
     args = "";
@@ -238,19 +225,15 @@ bug_open (args, from_tty)
       target_is_m88110 = 1;
       break;
     default:
-      abort ();
+      internal_error (__FILE__, __LINE__, "failed internal consistency check");
     }
 }
 
 /* Tell the remote machine to resume.  */
 
 void
-bug_resume (pid, step, sig)
-     int pid, step;
-     enum target_signal sig;
+bug_resume (int pid, int step, enum target_signal sig)
 {
-  dcache_flush (gr_get_dcache ());
-
   if (step)
     {
       sr_write_cr ("t");
@@ -279,9 +262,7 @@ static char *wait_strings[] =
 };
 
 int
-bug_wait (pid, status)
-     int pid;
-     struct target_waitstatus *status;
+bug_wait (int pid, struct target_waitstatus *status)
 {
   int old_timeout = sr_get_timeout ();
   int old_immediate_quit = immediate_quit;
@@ -352,8 +333,7 @@ bug_wait (pid, status)
 
    Returns a pointer to a static buffer containing the answer.  */
 static char *
-get_reg_name (regno)
-     int regno;
+get_reg_name (int regno)
 {
   static char *rn[] =
   {
@@ -386,8 +366,7 @@ get_reg_name (regno)
    success, -1 on failure.  */
 
 static int
-bug_scan (s)
-     char *s;
+bug_scan (char *s)
 {
   int c;
 
@@ -407,8 +386,7 @@ bug_scan (s)
 #endif /* never */
 
 static int
-bug_srec_write_cr (s)
-     char *s;
+bug_srec_write_cr (char *s)
 {
   char *p = s;
 
@@ -434,8 +412,7 @@ bug_srec_write_cr (s)
 /* Store register REGNO, or all if REGNO == -1. */
 
 static void
-bug_fetch_register (regno)
-     int regno;
+bug_fetch_register (int regno)
 {
   sr_check_open ();
 
@@ -513,8 +490,7 @@ bug_fetch_register (regno)
 /* Store register REGNO, or all if REGNO == -1. */
 
 static void
-bug_store_register (regno)
-     int regno;
+bug_store_register (int regno)
 {
   char buffer[1024];
   sr_check_open ();
@@ -535,9 +511,9 @@ bug_store_register (regno)
       if (target_is_m88110 && regno == SFIP_REGNUM)
        return;
       else if (regno < XFP_REGNUM)
-       sprintf (buffer, "rs %s %08x",
+       sprintf (buffer, "rs %s %08lx",
                 regname,
-                read_register (regno));
+                (long) read_register (regno));
       else
        {
          unsigned char *fpreg_buf =
@@ -567,22 +543,32 @@ bug_store_register (regno)
   return;
 }
 
+/* Transfer LEN bytes between GDB address MYADDR and target address
+   MEMADDR.  If WRITE is non-zero, transfer them to the target,
+   otherwise transfer them from the target.  TARGET is unused.
+
+   Returns the number of bytes transferred. */
+
 int
-bug_xfer_memory (memaddr, myaddr, len, write, target)
-     CORE_ADDR memaddr;
-     char *myaddr;
-     int len;
-     int write;
-     struct target_ops *target;        /* ignored */
+bug_xfer_memory (CORE_ADDR memaddr, char *myaddr, int len, int write,
+                struct mem_attrib *attrib ATTRIBUTE_UNUSED,
+                struct target_ops *target ATTRIBUTE_UNUSED)
 {
+  int res;
+
   if (len <= 0)
     return 0;
 
-  return dcache_xfer_memory (gr_get_dcache (), memaddr, myaddr, len, write);
+  if (write)
+    res = bug_write_memory (memaddr, myaddr, len);
+  else
+    res = bug_read_memory (memaddr, myaddr, len);
+
+  return res;
 }
 
 static void
-start_load ()
+start_load (void)
 {
   char *command;
 
@@ -616,10 +602,7 @@ static char *srecord_strings[] =
 };
 
 static int
-bug_write_memory (memaddr, myaddr, len)
-     CORE_ADDR memaddr;
-     unsigned char *myaddr;
-     int len;
+bug_write_memory (CORE_ADDR memaddr, unsigned char *myaddr, int len)
 {
   int done;
   int checksum;
@@ -664,7 +647,7 @@ bug_write_memory (memaddr, myaddr, len)
            thisgo = srec_bytes;
 
          address = memaddr + done;
-         sprintf (buf, "S3%02X%08X", thisgo + 4 + 1, address);
+         sprintf (buf, "S3%02X%08lX", thisgo + 4 + 1, (long) address);
          buf += 12;
 
          checksum += (thisgo + 4 + 1
@@ -743,10 +726,7 @@ bug_write_memory (memaddr, myaddr, len)
 /* Read LEN bytes from inferior memory at MEMADDR.  Put the result
    at debugger address MYADDR.  Returns errno value.  */
 static int
-bug_read_memory (memaddr, myaddr, len)
-     CORE_ADDR memaddr;
-     unsigned char *myaddr;
-     int len;
+bug_read_memory (CORE_ADDR memaddr, unsigned char *myaddr, int len)
 {
   char request[100];
   char *buffer;
@@ -757,7 +737,7 @@ bug_read_memory (memaddr, myaddr, len)
   unsigned int inaddr;
   unsigned int checksum;
 
-  sprintf (request, "du 0 %x:&%d", memaddr, len);
+  sprintf (request, "du 0 %lx:&%d", (long) memaddr, len);
   sr_write_cr (request);
 
   p = buffer = alloca (len);
@@ -843,10 +823,14 @@ done:
 
 #define MAX_BREAKS     16
 static int num_brkpts = 0;
+
+/* Insert a breakpoint at ADDR.  SAVE is normally the address of the
+   pattern buffer where the instruction that the breakpoint overwrites
+   is saved.  It is unused here since the bug is responsible for
+   saving/restoring the original instruction. */
+
 static int
-bug_insert_breakpoint (addr, save)
-     CORE_ADDR addr;
-     char *save;               /* Throw away, let bug save instructions */
+bug_insert_breakpoint (CORE_ADDR addr, char *save)
 {
   sr_check_open ();
 
@@ -855,7 +839,7 @@ bug_insert_breakpoint (addr, save)
       char buffer[100];
 
       num_brkpts++;
-      sprintf (buffer, "br %x", addr);
+      sprintf (buffer, "br %lx", (long) addr);
       sr_write_cr (buffer);
       gr_expect_prompt ();
       return (0);
@@ -868,17 +852,20 @@ bug_insert_breakpoint (addr, save)
     }
 
 }
+
+/* Remove a breakpoint at ADDR.  SAVE is normally the previously
+   saved pattern, but is unused here since the bug is responsible
+   for saving/restoring instructions. */
+
 static int
-bug_remove_breakpoint (addr, save)
-     CORE_ADDR addr;
-     char *save;               /* Throw away, let bug save instructions */
+bug_remove_breakpoint (CORE_ADDR addr, char *save)
 {
   if (num_brkpts > 0)
     {
       char buffer[100];
 
       num_brkpts--;
-      sprintf (buffer, "nobr %x", addr);
+      sprintf (buffer, "nobr %lx", (long) addr);
       sr_write_cr (buffer);
       gr_expect_prompt ();
 
@@ -888,7 +875,7 @@ bug_remove_breakpoint (addr, save)
 
 /* Clear the bugs notion of what the break points are */
 static int
-bug_clear_breakpoints ()
+bug_clear_breakpoints (void)
 {
 
   if (sr_is_open ())
@@ -973,7 +960,7 @@ init_bug_ops (void)
 }                              /* init_bug_ops */
 
 void
-_initialize_remote_bug ()
+_initialize_remote_bug (void)
 {
   init_bug_ops ();
   add_target (&bug_ops);
This page took 0.027238 seconds and 4 git commands to generate.