2000-07-03 Christopher Faylor <cgf@cygnus.com>
[deliverable/binutils-gdb.git] / gdb / dcache.c
index 821eb13ceecb296449d390ef1fe4d2264f6b2ef9..1c52cc33b30f348903196c019b00f4e1c665339a 100644 (file)
@@ -1,7 +1,7 @@
 /* Caching code.  Typically used by remote back ends for
    caching remote memory.
 
-   Copyright 1992, 1993, 1995, 1998 Free Software Foundation, Inc.
+   Copyright 1992-1993, 1995, 1998-1999 Free Software Foundation, Inc.
 
    This file is part of GDB.
 
@@ -149,26 +149,23 @@ struct dcache_struct
     int cache_has_stuff;
   };
 
-static int dcache_poke_byte PARAMS ((DCACHE * dcache, CORE_ADDR addr,
-                                    char *ptr));
+static int dcache_poke_byte (DCACHE * dcache, CORE_ADDR addr, char *ptr);
 
-static int dcache_peek_byte PARAMS ((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 PARAMS ((DCACHE * dcache,
-                                               CORE_ADDR addr));
+static struct dcache_block *dcache_hit (DCACHE * dcache, CORE_ADDR addr);
 
-static int dcache_write_line PARAMS ((DCACHE * dcache, struct dcache_block * db));
+static int dcache_write_line (DCACHE * dcache, struct dcache_block *db);
 
-static struct dcache_block *dcache_alloc PARAMS ((DCACHE * dcache));
+static struct dcache_block *dcache_alloc (DCACHE * dcache);
 
-static int dcache_writeback PARAMS ((DCACHE * dcache));
+static int dcache_writeback (DCACHE * dcache);
 
-static void dcache_info PARAMS ((char *exp, int tty));
+static void dcache_info (char *exp, int tty);
 
-void _initialize_dcache PARAMS ((void));
+void _initialize_dcache (void);
 
-int remote_dcache = 0;
+static int dcache_enabled_p = 0;
 
 DCACHE *last_cache;            /* Used by info dcache */
 
@@ -288,7 +285,7 @@ dcache_alloc (dcache)
 {
   register struct dcache_block *db;
 
-  if (remote_dcache == 0)
+  if (dcache_enabled_p == 0)
     abort ();
 
   /* Take something from the free list */
@@ -381,22 +378,6 @@ dcache_writeback (dcache)
 }
 
 
-/* Using the data cache DCACHE return the contents of the word at
-   address ADDR in the remote machine.  */
-int
-dcache_fetch (dcache, addr)
-     DCACHE *dcache;
-     CORE_ADDR addr;
-{
-  int res;
-
-  if (dcache_xfer_memory (dcache, addr, (char *) &res, sizeof res, 0) != sizeof res)
-    memory_error (EIO, addr);
-
-  return res;
-}
-
-
 /* Write the byte at PTR into ADDR in the data cache.
    Return zero on write error.
  */
@@ -422,23 +403,6 @@ dcache_poke_byte (dcache, addr, ptr)
   return 1;
 }
 
-/* Write the word at ADDR both in the data cache and in the remote machine.  
-   Return zero on write error.
- */
-
-int
-dcache_poke (dcache, addr, data)
-     DCACHE *dcache;
-     CORE_ADDR addr;
-     int data;
-{
-  if (dcache_xfer_memory (dcache, addr, (char *) &data, sizeof data, 1) != sizeof data)
-    return 0;
-
-  return dcache_writeback (dcache);
-}
-
-
 /* Initialize the data cache.  */
 DCACHE *
 dcache_init (reading, writing)
@@ -479,9 +443,9 @@ dcache_xfer_memory (dcache, memaddr, myaddr, len, should_write)
 {
   int i;
 
-  if (remote_dcache)
+  if (dcache_enabled_p)
     {
-      int (*xfunc) PARAMS ((DCACHE * dcache, CORE_ADDR addr, char *ptr));
+      int (*xfunc) (DCACHE * dcache, CORE_ADDR addr, char *ptr);
       xfunc = should_write ? dcache_poke_byte : dcache_peek_byte;
 
       for (i = 0; i < len; i++)
@@ -512,7 +476,7 @@ dcache_info (exp, tty)
 {
   struct dcache_block *p;
 
-  if (!remote_dcache)
+  if (!dcache_enabled_p)
     {
       printf_filtered ("Dcache not enabled\n");
       return;
@@ -525,8 +489,8 @@ dcache_info (exp, tty)
   for (p = last_cache->valid_head; p; p = p->p)
     {
       int j;
-      printf_filtered ("Line at %08xd, referenced %d times\n",
-                      p->addr, p->refs);
+      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);
@@ -538,19 +502,26 @@ dcache_info (exp, tty)
     }
 }
 
+/* Turn dcache on or off. */
+void
+set_dcache_state (int what)
+{
+  dcache_enabled_p = !!what;
+}
+
 void
 _initialize_dcache ()
 {
   add_show_from_set
     (add_set_cmd ("remotecache", class_support, var_boolean,
-                 (char *) &remote_dcache,
+                 (char *) &dcache_enabled_p,
                  "\
 Set cache use for remote targets.\n\
 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 on.",
+volatile registers are in use.  By default, this option is off.",
                  &setlist),
      &showlist);
 
This page took 0.02541 seconds and 4 git commands to generate.