Move construction of IA-32 vector types to i386-tdep.c.
[deliverable/binutils-gdb.git] / gdb / dcache.c
index 7973b998ea179a7556db7278786da5bae6dbd692..bff7e9fccab74bce2d7629aca73e5dd410a41b32 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 1992, 1993, 1995, 1996, 1998, 1999, 2000, 2001, 2003 Free
+   Software Foundation, Inc.
 
    This file is part of GDB.
 
@@ -179,6 +181,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 +225,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,7 +247,7 @@ 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;
@@ -277,20 +286,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 +313,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;
            }
        }
@@ -377,7 +391,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;
@@ -438,7 +452,7 @@ dcache_writeback (DCACHE *dcache)
 static int
 dcache_peek_byte (DCACHE *dcache, CORE_ADDR addr, char *ptr)
 {
-  register struct dcache_block *db = dcache_hit (dcache, addr);
+  struct dcache_block *db = dcache_hit (dcache, addr);
 
   if (!db)
     {
@@ -465,7 +479,7 @@ dcache_peek_byte (DCACHE *dcache, CORE_ADDR addr, char *ptr)
 static int
 dcache_poke_byte (DCACHE *dcache, CORE_ADDR addr, char *ptr)
 {
-  register struct dcache_block *db = dcache_hit (dcache, addr);
+  struct dcache_block *db = dcache_hit (dcache, addr);
 
   if (!db)
     {
@@ -551,22 +565,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 +592,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.058375 seconds and 4 git commands to generate.