]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commitdiff
* dcache.c (dcache_info): Output a cache line's state vector so it
authorJ.T. Conklin <jtc@acorntoolworks.com>
Fri, 1 Sep 2000 00:12:10 +0000 (00:12 +0000)
committerJ.T. Conklin <jtc@acorntoolworks.com>
Fri, 1 Sep 2000 00:12:10 +0000 (00:12 +0000)
lines up under the data vector.

* dcache.c (dcache_read_line): New function.
(dcache_peek_byte): Use it.
(dcache_alloc): Return NULL if write of reclaimed cache line fails.
(dcache_peek_byte, dcache_poke_byte): Return failure if
dcache_alloc() returns a NULL data block pointer.
(dcache_xfer_memory): Don't force writeback unless we were writing.

* monitor.c (monitor_expect): Change places where immediate_quit
is set to 1 or 0 to increments and decrements respectively.  This
allows such changes to nest properly.
* ocd.c (ocd_start_remote): Likewise.
* remote-adapt.c (expect): Likewise.
* remote-array.c (expect): Likewise.
* remote-eb.c (expect): Likewise.
* remote-e7000.c (e7000_start_remote): Likewise.
* remote-mips.c (mips_expect_timeout, mips_getstring): Likewise.
* remote-nrom.c (expect): Likewise.
* remote-os9k.c (expect): Likewise.
* remote-sds.c (sds_start_remote): Likewise.
* remote-st.c (expect): Likewise.
* remote-utils.c (sr_expect): Likewise.
* remote.c (remote_start_remote): Likewise.
* tracepoint.c (read_actions): Likewise.

* remote-mips.c (mips_getstring): Balance changes to immediate_quit.

16 files changed:
gdb/ChangeLog
gdb/dcache.c
gdb/monitor.c
gdb/ocd.c
gdb/remote-adapt.c
gdb/remote-array.c
gdb/remote-e7000.c
gdb/remote-eb.c
gdb/remote-mips.c
gdb/remote-nrom.c
gdb/remote-os9k.c
gdb/remote-sds.c
gdb/remote-st.c
gdb/remote-utils.c
gdb/remote.c
gdb/tracepoint.c

index 8fff846aa44552727f9423f486e5879b764d52d7..1040d557d9003f1325ce3c51f5b7783543f97a38 100644 (file)
@@ -1,3 +1,34 @@
+2000-08-31  J.T. Conklin  <jtc@redback.com>
+
+       * dcache.c (dcache_info): Output a cache line's state vector so it
+       lines up under the data vector.
+
+       * dcache.c (dcache_read_line): New function.
+       (dcache_peek_byte): Use it.
+       (dcache_alloc): Return NULL if write of reclaimed cache line fails.
+       (dcache_peek_byte, dcache_poke_byte): Return failure if
+       dcache_alloc() returns a NULL data block pointer.  
+       (dcache_xfer_memory): Don't force writeback unless we were writing.
+
+       * monitor.c (monitor_expect): Change places where immediate_quit
+       is set to 1 or 0 to increments and decrements respectively.  This
+       allows such changes to nest properly.
+       * ocd.c (ocd_start_remote): Likewise.
+       * remote-adapt.c (expect): Likewise.
+       * remote-array.c (expect): Likewise.
+       * remote-eb.c (expect): Likewise.
+       * remote-e7000.c (e7000_start_remote): Likewise.
+       * remote-mips.c (mips_expect_timeout, mips_getstring): Likewise.
+       * remote-nrom.c (expect): Likewise.
+       * remote-os9k.c (expect): Likewise.
+       * remote-sds.c (sds_start_remote): Likewise.
+       * remote-st.c (expect): Likewise.
+       * remote-utils.c (sr_expect): Likewise.
+       * remote.c (remote_start_remote): Likewise.
+       * tracepoint.c (read_actions): Likewise.
+
+       * remote-mips.c (mips_getstring): Balance changes to immediate_quit.
+
 2000-08-31  David Anderson  <davea@sgi.com>
 
        * MAINTAINERS: Add myself to write-after-approval list.
index a563d8bff979db89aaac3c7695a9f08ce2cafe97..46255d9c7ab3738a49dbeff9219b45b0e0e63621 100644 (file)
@@ -149,17 +149,19 @@ struct dcache_struct
     int cache_has_stuff;
   };
 
-static int dcache_poke_byte (DCACHE * dcache, CORE_ADDR addr, char *ptr);
+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 int dcache_peek_byte (DCACHE *dcache, CORE_ADDR addr, char *ptr);
 
-static struct dcache_block *dcache_hit (DCACHE * dcache, CORE_ADDR addr);
+static struct dcache_block *dcache_hit (DCACHE *dcache, CORE_ADDR addr);
 
-static int dcache_write_line (DCACHE * dcache, struct dcache_block *db);
+static int dcache_write_line (DCACHE *dcache, struct dcache_block *db);
 
-static struct dcache_block *dcache_alloc (DCACHE * dcache, CORE_ADDR addr);
+static int dcache_read_line (DCACHE *dcache, struct dcache_block *db);
 
-static int dcache_writeback (DCACHE * dcache);
+static struct dcache_block *dcache_alloc (DCACHE *dcache, CORE_ADDR addr);
+
+static int dcache_writeback (DCACHE *dcache);
 
 static void dcache_info (char *exp, int tty);
 
@@ -231,7 +233,7 @@ dcache_write_line (DCACHE *dcache, register struct dcache_block *db)
 {
   int s;
   int e;
-  s = 0;
+
   if (db->anydirty)
     {
       for (s = 0; s < LINE_SIZE; s++)
@@ -266,6 +268,44 @@ dcache_write_line (DCACHE *dcache, register struct dcache_block *db)
 }
 
 
+/* Read cache line */
+static int
+dcache_read_line (DCACHE *dcache, struct dcache_block *db)
+{
+  CORE_ADDR memaddr;
+  char *myaddr;
+  int len;
+  int res;
+
+  /* If there are any dirty bytes in the line, it must be written
+     before a new line can be read */
+  if (db->anydirty)
+    {
+      if (!dcache_write_line (dcache, db))
+       return 0;
+    }
+  
+  len = LINE_SIZE;
+  memaddr = db->addr;
+  myaddr  = db->data;
+
+  while (len > 0)
+    {
+      res = (*dcache->read_memory) (memaddr, myaddr, len);
+      if (res == 0)
+       return 0;
+
+      memaddr += res;
+      myaddr  += res;
+      len     -= res;
+    }
+
+  memset (db->state, ENTRY_OK, sizeof (db->data));
+  db->anydirty = 0;
+  
+  return 1;
+}
+
 /* Get a free cache block, put or keep it on the valid list,
    and return its address.  */
 
@@ -287,9 +327,11 @@ dcache_alloc (DCACHE *dcache, CORE_ADDR addr)
     {
       /* Nothing left on free list, so grab one from the valid list */
       db = dcache->valid_head;
-      dcache->valid_head = db->p;
 
-      dcache_write_line (dcache, db);
+      if (!dcache_write_line (dcache, db))
+       return NULL;
+      
+      dcache->valid_head = db->p;
     }
 
   db->addr = MASK(addr);
@@ -308,48 +350,6 @@ dcache_alloc (DCACHE *dcache, CORE_ADDR addr)
   return db;
 }
 
-/* Using the data cache DCACHE return the contents of the byte at
-   address ADDR in the remote machine.  
-
-   Returns 0 on error. */
-
-static int
-dcache_peek_byte (DCACHE *dcache, CORE_ADDR addr, char *ptr)
-{
-  register struct dcache_block *db = dcache_hit (dcache, addr);
-  int ok = 1;
-  int done = 0;
-  if (db == 0
-      || db->state[XFORM (addr)] == ENTRY_BAD)
-    {
-      if (db)
-       {
-         dcache_write_line (dcache, db);
-       }
-      else
-       db = dcache_alloc (dcache, addr);
-
-      immediate_quit++;
-      while (done < LINE_SIZE)
-       {
-         int try =
-         (*dcache->read_memory)
-         (db->addr + done,
-          db->data + done,
-          LINE_SIZE - done);
-         if (try == 0)
-           return 0;
-         done += try;
-       }
-      immediate_quit--;
-
-      memset (db->state, ENTRY_OK, sizeof (db->data));
-      db->anydirty = 0;
-    }
-  *ptr = db->data[XFORM (addr)];
-  return ok;
-}
-
 /* Writeback any dirty lines to the remote. */
 static int
 dcache_writeback (DCACHE *dcache)
@@ -368,6 +368,34 @@ dcache_writeback (DCACHE *dcache)
 }
 
 
+/* Using the data cache DCACHE return the contents of the byte at
+   address ADDR in the remote machine.  
+
+   Returns 0 on error. */
+
+static int
+dcache_peek_byte (DCACHE *dcache, CORE_ADDR addr, char *ptr)
+{
+  register struct dcache_block *db = dcache_hit (dcache, addr);
+
+  if (!db)
+    {
+      db = dcache_alloc (dcache, addr);
+      if (!db)
+       return 0;
+    }
+  
+  if (db->state[XFORM (addr)] == ENTRY_BAD)
+    {
+      if (!dcache_read_line(dcache, db))
+         return 0;
+    }
+
+  *ptr = db->data[XFORM (addr)];
+  return 1;
+}
+
+
 /* Write the byte at PTR into ADDR in the data cache.
    Return zero on write error.
  */
@@ -380,6 +408,8 @@ dcache_poke_byte (DCACHE *dcache, CORE_ADDR addr, char *ptr)
   if (!db)
     {
       db = dcache_alloc (dcache, addr);
+      if (!db)
+       return 0;
     }
 
   db->data[XFORM (addr)] = *ptr;
@@ -435,7 +465,7 @@ dcache_xfer_memory (DCACHE *dcache, CORE_ADDR memaddr, char *myaddr, int len,
 
   if (dcache_enabled_p)
     {
-      int (*xfunc) (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++)
@@ -443,8 +473,11 @@ dcache_xfer_memory (DCACHE *dcache, CORE_ADDR memaddr, char *myaddr, int len,
          if (!xfunc (dcache, memaddr + i, myaddr + i))
            return 0;
        }
+
+      if (should_write)
+       dcache_writeback (dcache);
+
       dcache->cache_has_stuff = 1;
-      dcache_writeback (dcache);
     }
   else
     {
@@ -487,7 +520,7 @@ dcache_info (char *exp, int tty)
          printf_filtered ("\n");
 
          for (j = 0; j < LINE_SIZE; j++)
-           printf_filtered (" %2x", p->state[j]);
+           printf_filtered ("%2x", p->state[j]);
          printf_filtered ("\n");
        }
     }
index ca7dd3015290b4b5293fbaa28704cf0392552187..c5d6da69ae08a3d62a67c85e9aeb9349aa8919a0 100644 (file)
@@ -521,7 +521,7 @@ monitor_expect (char *string, char *buf, int buflen)
       fprintf_unfiltered (gdb_stdlog, "MON Expecting '%s'\n", safe_string);
     }
 
-  immediate_quit = 1;
+  immediate_quit++;
   while (1)
     {
       if (buf)
@@ -529,7 +529,7 @@ monitor_expect (char *string, char *buf, int buflen)
          if (buflen < 2)
            {
              *buf = '\000';
-             immediate_quit = 0;
+             immediate_quit--;
              return -1;
            }
 
@@ -549,7 +549,7 @@ monitor_expect (char *string, char *buf, int buflen)
          p++;
          if (*p == '\0')
            {
-             immediate_quit = 0;
+             immediate_quit--;
 
              if (buf)
                {
index 6dd601e5da17664e7548b05a57558e82419dc8db..eb809488024dc97c99dd2b118f08519f84287d49 100644 (file)
--- a/gdb/ocd.c
+++ b/gdb/ocd.c
@@ -181,7 +181,7 @@ ocd_start_remote (PTR dummy)
 
   target_type = *(enum ocd_target_type *) dummy;
 
-  immediate_quit = 1;          /* Allow user to interrupt it */
+  immediate_quit++;            /* Allow user to interrupt it */
 
   SERIAL_SEND_BREAK (ocd_desc);        /* Wake up the wiggler */
 
@@ -243,7 +243,7 @@ ocd_start_remote (PTR dummy)
     ocd_error ("OCD_SET_CTL_FLAGS:", error_code);
 #endif
 
-  immediate_quit = 0;
+  immediate_quit--;
 
 /* This is really the job of start_remote however, that makes an assumption
    that the target is about to print out a status message of some sort.  That
index 4e6b70b25db52acc011eb6f8fce46c93ec74bb74..f5cc1234d2b2d8d1f010a5f412de23609977f5ac 100644 (file)
@@ -201,7 +201,7 @@ expect (char *string)
   char *p = string;
 
   fflush (adapt_stream);
-  immediate_quit = 1;
+  immediate_quit++;
   while (1)
     {
       if (readchar () == *p)
@@ -209,7 +209,7 @@ expect (char *string)
          p++;
          if (*p == '\0')
            {
-             immediate_quit = 0;
+             immediate_quit--;
              return;
            }
        }
index 47d2833dae05974652c62833d4c7e19c99298921..9c3a9d79cef5fc493c91b2f36bf976f589440d15 100644 (file)
@@ -363,7 +363,7 @@ expect (char *string, int discard)
 
   debuglogs (1, "Expecting \"%s\".", string);
 
-  immediate_quit = 1;
+  immediate_quit++;
   while (1)
     {
       c = readchar (timeout);
@@ -373,7 +373,7 @@ expect (char *string, int discard)
        {
          if (*p == '\0')
            {
-             immediate_quit = 0;
+             immediate_quit--;
              debuglogs (4, "Matched");
              return;
            }
index 35ce227e44ecb75aa831f19d9ca283214d6019bd..ae89e829d2ee00b61bc09197668a3b075af35e1d 100644 (file)
@@ -569,7 +569,7 @@ e7000_start_remote (void *dummy)
   int try;
   int quit_trying;
 
-  immediate_quit = 1;          /* Allow user to interrupt it */
+  immediate_quit++;            /* Allow user to interrupt it */
 
   /* Hello?  Are you there?  */
   sync = 0;
@@ -635,7 +635,7 @@ e7000_start_remote (void *dummy)
   puts_e7000debug ("b -\r");   /* Clear breakpoints */
   expect_prompt ();
 
-  immediate_quit = 0;
+  immediate_quit--;
 
 /* This is really the job of start_remote however, that makes an assumption
    that the target is about to print out a status message of some sort.  That
index c5c33a7c4e869a4d6f98e07cf975fcf388e6e15e..302e87ef6776753d324b7c46efccb7bcdca689ed 100644 (file)
@@ -100,7 +100,7 @@ expect (char *string)
 {
   char *p = string;
 
-  immediate_quit = 1;
+  immediate_quit++;
   while (1)
     {
       if (readchar () == *p)
@@ -108,7 +108,7 @@ expect (char *string)
          p++;
          if (*p == '\0')
            {
-             immediate_quit = 0;
+             immediate_quit--;
              return;
            }
        }
index 4366fb8a0196d458df167b431fdcea370de28151..e2faeacc5211dc513a2752b267431e244c098418 100644 (file)
@@ -551,7 +551,7 @@ mips_expect_timeout (const char *string, int timeout)
       fprintf_unfiltered (gdb_stdlog, "\", got \"");
     }
 
-  immediate_quit = 1;
+  immediate_quit++;
   while (1)
     {
       int c;
@@ -575,7 +575,7 @@ mips_expect_timeout (const char *string, int timeout)
        {
          if (*p == '\0')
            {
-             immediate_quit = 0;
+             immediate_quit--;
              if (remote_debug)
                fprintf_unfiltered (gdb_stdlog, "\": OK\n");
              return 1;
@@ -609,7 +609,7 @@ mips_getstring (char *string, int n)
   char *p = string;
   int c;
 
-  immediate_quit = 1;
+  immediate_quit++;
   while (n > 0)
     {
       c = SERIAL_READCHAR (mips_desc, 2);
@@ -618,6 +618,7 @@ mips_getstring (char *string, int n)
        {
          fprintf_unfiltered (gdb_stderr,
                 "Failed to read %d characters from target (TIMEOUT)\n", n);
+         immediate_quit--;
          return 0;
        }
 
@@ -625,6 +626,7 @@ mips_getstring (char *string, int n)
       n--;
     }
 
+  immediate_quit--;
   return 1;
 }
 
index 49e51c39e4e2818b21d67882a65300f4db5b7ae2..86a0718c6748bdb1566d6a725ff44fe515fc7520 100644 (file)
@@ -66,7 +66,7 @@ expect (char *string)
   char *p = string;
   int c;
 
-  immediate_quit = 1;
+  immediate_quit++;
 
   while (1)
     {
@@ -76,8 +76,7 @@ expect (char *string)
        {
          if (*p == '\0')
            {
-             immediate_quit = 0;
-
+             immediate_quit--;
              return 0;
            }
        }
index 53ca13d2762da73d034b3a99998fd241ea2c160e..343c75d0d329a21787d47708e97e7c1262a4dc7b 100644 (file)
@@ -143,7 +143,7 @@ expect (char *string, int discard)
   if (sr_get_debug ())
     printf ("Expecting \"%s\"\n", string);
 
-  immediate_quit = 1;
+  immediate_quit++;
   while (1)
     {
       c = readchar (timeout);
@@ -153,7 +153,7 @@ expect (char *string, int discard)
        {
          if (*p == '\0')
            {
-             immediate_quit = 0;
+             immediate_quit--;
              if (sr_get_debug ())
                printf ("\nMatched\n");
              return;
index 582d46b31c34822496b90276609122193d321591..f7fbf00fae1bd52214a5016830258b6bf95675ce 100644 (file)
@@ -163,7 +163,7 @@ sds_start_remote (PTR dummy)
   char c;
   unsigned char buf[200];
 
-  immediate_quit = 1;          /* Allow user to interrupt it */
+  immediate_quit++;            /* Allow user to interrupt it */
 
   /* Ack any packet which the remote side has already sent.  */
   SERIAL_WRITE (sds_desc, "{#*\r\n", 5);
@@ -181,7 +181,7 @@ sds_start_remote (PTR dummy)
   buf[0] = 0;
   sds_send (buf, 1);
 
-  immediate_quit = 0;
+  immediate_quit--;
 
   start_remote ();             /* Initialize gdb process mechanisms */
   return 1;
index 485f9414493858d9260e8e9b42956f9c56289a4d..aa00e8fa2e563f220900f5d1b5aa007af8b4431f 100644 (file)
@@ -117,7 +117,7 @@ expect (char *string, int discard)
   char *p = string;
   int c;
 
-  immediate_quit = 1;
+  immediate_quit++;
   while (1)
     {
       c = readchar (timeout);
@@ -125,7 +125,7 @@ expect (char *string, int discard)
        {
          if (*p == '\0')
            {
-             immediate_quit = 0;
+             immediate_quit--;
              return;
            }
        }
index 236a0ec1423dd03df47afc6eeb72443f029ef61c..207761299f29d931ffb971ff72ff8a60b8713c9b 100644 (file)
@@ -264,7 +264,7 @@ sr_expect (char *string)
 {
   char *p = string;
 
-  immediate_quit = 1;
+  immediate_quit++;
   while (1)
     {
       if (sr_readchar () == *p)
@@ -272,7 +272,7 @@ sr_expect (char *string)
          p++;
          if (*p == '\0')
            {
-             immediate_quit = 0;
+             immediate_quit--;
              return;
            }
        }
index 9a6e2f93c052676be7c910fa2a4fb3ef609f98f1..b58911ce58acc635af721338f84f14dd8582e1f5 100644 (file)
@@ -1975,7 +1975,7 @@ remote_start_remote_dummy (void *dummy)
 static int
 remote_start_remote (PTR dummy)
 {
-  immediate_quit = 1;          /* Allow user to interrupt it */
+  immediate_quit++;            /* Allow user to interrupt it */
 
   /* Ack any packet which the remote side has already sent.  */
   SERIAL_WRITE (remote_desc, "+", 1);
@@ -1988,7 +1988,7 @@ remote_start_remote (PTR dummy)
   get_offsets ();              /* Get text, data & bss offsets */
 
   putpkt ("?");                        /* initiate a query from remote machine */
-  immediate_quit = 0;
+  immediate_quit--;
 
   return remote_start_remote_dummy (dummy);
 }
index 7d8a631458bef3d5ebf66aee7171386a45a3451a..02cf5f8d5007e02a5a723651c12e590e24d91c5b 100644 (file)
@@ -889,7 +889,7 @@ read_actions (struct tracepoint *t)
   if (job_control)
     signal (STOP_SIGNAL, SIG_DFL);
 #endif
-  immediate_quit = 0;
+  immediate_quit--;
   discard_cleanups (old_chain);
 }