* Makefile.in (objfiles.o, symfile.o): Update.
[deliverable/binutils-gdb.git] / gdb / dcache.c
index 7973b998ea179a7556db7278786da5bae6dbd692..43640b0e48e38f9e1bcb9f35ddb87a3027b5756c 100644 (file)
@@ -1,5 +1,7 @@
-/* Caching code.
-   Copyright 1992-1993, 1995, 1998-1999, 2000, 2001 Free Software Foundation, Inc.
+/* Caching code for GDB, the GNU debugger.
+
+   Copyright (C) 1992, 1993, 1995, 1996, 1998, 1999, 2000, 2001, 2003 Free
+   Software Foundation, Inc.
 
    This file is part of GDB.
 
@@ -15,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.  */
 
 #include "defs.h"
 #include "dcache.h"
@@ -122,7 +124,7 @@ struct dcache_block
   {
     struct dcache_block *p;    /* next in list */
     CORE_ADDR addr;            /* Address for which data is recorded.  */
-    char data[LINE_SIZE];      /* bytes at given address */
+    gdb_byte data[LINE_SIZE];  /* bytes at given address */
     unsigned char state[LINE_SIZE];    /* what state the data is in */
 
     /* whether anything in state is dirty - used to speed up the 
@@ -160,10 +162,6 @@ struct dcache_struct
     struct dcache_block *the_cache;
   };
 
-static int dcache_poke_byte (DCACHE *dcache, CORE_ADDR addr, char *ptr);
-
-static int dcache_peek_byte (DCACHE *dcache, CORE_ADDR addr, char *ptr);
-
 static struct dcache_block *dcache_hit (DCACHE *dcache, CORE_ADDR addr);
 
 static int dcache_write_line (DCACHE *dcache, struct dcache_block *db);
@@ -179,6 +177,13 @@ static void dcache_info (char *exp, int tty);
 void _initialize_dcache (void);
 
 static int dcache_enabled_p = 0;
+static void
+show_dcache_enabled_p (struct ui_file *file, int from_tty,
+                      struct cmd_list_element *c, const char *value)
+{
+  fprintf_filtered (file, _("Cache use for remote targets is %s.\n"), value);
+}
+
 
 DCACHE *last_cache;            /* Used by info dcache */
 
@@ -216,7 +221,7 @@ dcache_invalidate (DCACHE *dcache)
 static struct dcache_block *
 dcache_hit (DCACHE *dcache, CORE_ADDR addr)
 {
-  register struct dcache_block *db;
+  struct dcache_block *db;
 
   /* Search all cache blocks for one that is at this address.  */
   db = dcache->valid_head;
@@ -238,10 +243,10 @@ dcache_hit (DCACHE *dcache, CORE_ADDR addr)
    be written is. */
 
 static int
-dcache_write_line (DCACHE *dcache, register struct dcache_block *db)
+dcache_write_line (DCACHE *dcache, struct dcache_block *db)
 {
   CORE_ADDR memaddr;
-  char *myaddr;
+  gdb_byte *myaddr;
   int len;
   int res;
   int reg_len;
@@ -277,20 +282,24 @@ dcache_write_line (DCACHE *dcache, register struct dcache_block *db)
       while (reg_len > 0)
        {
          s = XFORM(memaddr);
-         do {
+         while (reg_len > 0) {
            if (db->state[s] == ENTRY_DIRTY)
              break;
            s++;
            reg_len--;
-         } while (reg_len > 0);
+
+           memaddr++;
+           myaddr++;
+           len--;
+         }
 
          e = s;
-         do {
+         while (reg_len > 0) {
            if (db->state[e] != ENTRY_DIRTY)
              break;
            e++;
            reg_len--;
-         } while (reg_len > 0);
+         }
 
          dirty_len = e - s;
          while (dirty_len > 0)
@@ -300,9 +309,10 @@ dcache_write_line (DCACHE *dcache, register struct dcache_block *db)
              if (res <= 0)
                return 0;
 
-             memset (db->state[XFORM(memaddr)], ENTRY_OK, res);
+             memset (&db->state[XFORM(memaddr)], ENTRY_OK, res);
              memaddr   += res;
              myaddr    += res;
+             len       -= res;
              dirty_len -= res;
            }
        }
@@ -317,7 +327,7 @@ static int
 dcache_read_line (DCACHE *dcache, struct dcache_block *db)
 {
   CORE_ADDR memaddr;
-  char *myaddr;
+  gdb_byte *myaddr;
   int len;
   int res;
   int reg_len;
@@ -377,7 +387,7 @@ dcache_read_line (DCACHE *dcache, struct dcache_block *db)
 static struct dcache_block *
 dcache_alloc (DCACHE *dcache, CORE_ADDR addr)
 {
-  register struct dcache_block *db;
+  struct dcache_block *db;
 
   /* Take something from the free list */
   db = dcache->free_head;
@@ -436,9 +446,9 @@ dcache_writeback (DCACHE *dcache)
    Returns 0 on error. */
 
 static int
-dcache_peek_byte (DCACHE *dcache, CORE_ADDR addr, char *ptr)
+dcache_peek_byte (DCACHE *dcache, CORE_ADDR addr, gdb_byte *ptr)
 {
-  register struct dcache_block *db = dcache_hit (dcache, addr);
+  struct dcache_block *db = dcache_hit (dcache, addr);
 
   if (!db)
     {
@@ -463,9 +473,9 @@ dcache_peek_byte (DCACHE *dcache, CORE_ADDR addr, char *ptr)
  */
 
 static int
-dcache_poke_byte (DCACHE *dcache, CORE_ADDR addr, char *ptr)
+dcache_poke_byte (DCACHE *dcache, CORE_ADDR addr, gdb_byte *ptr)
 {
-  register struct dcache_block *db = dcache_hit (dcache, addr);
+  struct dcache_block *db = dcache_hit (dcache, addr);
 
   if (!db)
     {
@@ -518,11 +528,11 @@ dcache_free (DCACHE *dcache)
    This routine is indended to be called by remote_xfer_ functions. */
 
 int
-dcache_xfer_memory (DCACHE *dcache, CORE_ADDR memaddr, char *myaddr, int len,
-                   int should_write)
+dcache_xfer_memory (DCACHE *dcache, CORE_ADDR memaddr, gdb_byte *myaddr,
+                   int len, int should_write)
 {
   int i;
-  int (*xfunc) (DCACHE *dcache, CORE_ADDR addr, char *ptr);
+  int (*xfunc) (DCACHE *dcache, CORE_ADDR addr, gdb_byte *ptr);
   xfunc = should_write ? dcache_poke_byte : dcache_peek_byte;
 
   for (i = 0; i < len; i++)
@@ -551,22 +561,22 @@ dcache_info (char *exp, int tty)
 {
   struct dcache_block *p;
 
-  printf_filtered ("Dcache line width %d, depth %d\n",
+  printf_filtered (_("Dcache line width %d, depth %d\n"),
                   LINE_SIZE, DCACHE_SIZE);
 
   if (last_cache)
     {
-      printf_filtered ("Cache state:\n");
+      printf_filtered (_("Cache state:\n"));
 
       for (p = last_cache->valid_head; p; p = p->p)
        {
          int j;
-         printf_filtered ("Line at %s, referenced %d times\n",
+         printf_filtered (_("Line at %s, referenced %d times\n"),
                           paddr (p->addr), p->refs);
 
          for (j = 0; j < LINE_SIZE; j++)
            printf_filtered ("%02x", p->data[j] & 0xFF);
-         printf_filtered ("\n");
+         printf_filtered (("\n"));
 
          for (j = 0; j < LINE_SIZE; j++)
            printf_filtered ("%2x", p->state[j]);
@@ -578,20 +588,20 @@ dcache_info (char *exp, int tty)
 void
 _initialize_dcache (void)
 {
-  add_show_from_set
-    (add_set_cmd ("remotecache", class_support, var_boolean,
-                 (char *) &dcache_enabled_p,
-                 "\
-Set cache use for remote targets.\n\
+  add_setshow_boolean_cmd ("remotecache", class_support,
+                          &dcache_enabled_p, _("\
+Set cache use for remote targets."), _("\
+Show cache use for remote targets."), _("\
 When on, use data caching for remote targets.  For many remote targets\n\
 this option can offer better throughput for reading target memory.\n\
 Unfortunately, gdb does not currently know anything about volatile\n\
 registers and thus data caching will produce incorrect results with\n\
-volatile registers are in use.  By default, this option is off.",
-                 &setlist),
-     &showlist);
+volatile registers are in use.  By default, this option is off."),
+                          NULL,
+                          show_dcache_enabled_p,
+                          &setlist, &showlist);
 
   add_info ("dcache", dcache_info,
-           "Print information on the dcache performance.");
+           _("Print information on the dcache performance."));
 
 }
This page took 0.026667 seconds and 4 git commands to generate.