2000-07-03 Christopher Faylor <cgf@cygnus.com>
[deliverable/binutils-gdb.git] / gdb / remote-bug.c
index b97f6bc7a021d999c759497e5aca5e27defcbf4f..e3a5a6778bcb83dcae3dc4e712aa3c23ee11f8c1 100644 (file)
@@ -48,15 +48,13 @@ extern int stop_soon_quietly;       /* for wait_for_inferior */
 extern struct target_ops bug_ops;      /* Forward declaration */
 
 /* Forward function declarations */
-static int bug_clear_breakpoints PARAMS ((void));
+static int bug_clear_breakpoints (void);
 
-static int bug_read_memory PARAMS ((CORE_ADDR memaddr,
-                                   unsigned char *myaddr,
-                                   int len));
+static int bug_read_memory (CORE_ADDR memaddr,
+                           unsigned char *myaddr, int len);
 
-static int bug_write_memory PARAMS ((CORE_ADDR memaddr,
-                                    unsigned char *myaddr,
-                                    int len));
+static int bug_write_memory (CORE_ADDR memaddr,
+                            unsigned char *myaddr, int len);
 
 /* This variable is somewhat arbitrary.  It's here so that it can be
    set from within a running gdb.  */
@@ -577,75 +575,10 @@ bug_xfer_memory (memaddr, myaddr, len, write, target)
      int write;
      struct target_ops *target;        /* ignored */
 {
-  register int i;
+  if (len <= 0)
+    return 0;
 
-  /* Round starting address down to longword boundary.  */
-  register CORE_ADDR addr;
-
-  /* Round ending address up; get number of longwords that makes.  */
-  register int count;
-
-  /* Allocate buffer of that many longwords.  */
-  register int *buffer;
-
-  addr = memaddr & -sizeof (int);
-  count = (((memaddr + len) - addr) + sizeof (int) - 1) / sizeof (int);
-
-  buffer = (int *) alloca (count * sizeof (int));
-
-  if (write)
-    {
-      /* Fill start and end extra bytes of buffer with existing memory data.  */
-
-      if (addr != memaddr || len < (int) sizeof (int))
-       {
-         /* Need part of initial word -- fetch it.  */
-         buffer[0] = gr_fetch_word (addr);
-       }
-
-      if (count > 1)           /* FIXME, avoid if even boundary */
-       {
-         buffer[count - 1]
-           = gr_fetch_word (addr + (count - 1) * sizeof (int));
-       }
-
-      /* Copy data to be written over corresponding part of buffer */
-
-      memcpy ((char *) buffer + (memaddr & (sizeof (int) - 1)), myaddr, len);
-
-      /* Write the entire buffer.  */
-
-      for (i = 0; i < count; i++, addr += sizeof (int))
-       {
-         errno = 0;
-         gr_store_word (addr, buffer[i]);
-         if (errno)
-           {
-
-             return 0;
-           }
-
-       }
-    }
-  else
-    {
-      /* Read all the longwords */
-      for (i = 0; i < count; i++, addr += sizeof (int))
-       {
-         errno = 0;
-         buffer[i] = gr_fetch_word (addr);
-         if (errno)
-           {
-             return 0;
-           }
-         QUIT;
-       }
-
-      /* Copy appropriate bytes out of the buffer.  */
-      memcpy (myaddr, (char *) buffer + (memaddr & (sizeof (int) - 1)), len);
-    }
-
-  return len;
+  return dcache_xfer_memory (gr_get_dcache (), memaddr, myaddr, len, write);
 }
 
 static void
This page took 0.024037 seconds and 4 git commands to generate.