* remote.c (remote_write_bytes): Add default case to switch
[deliverable/binutils-gdb.git] / gdb / regcache.c
index fec8b3dec8c06a6f537a5e347aff274260c5a931..104bff7b179d2e7938572bbe18058f27a48a2f8b 100644 (file)
@@ -24,6 +24,7 @@
 #include "inferior.h"
 #include "target.h"
 #include "gdbarch.h"
+#include "gdbcmd.h"
 
 /*
  * DATA STRUCTURE
@@ -68,6 +69,15 @@ register_cached (int regnum)
   return register_valid[regnum];
 }
 
+/* REGISTER_CHANGED
+
+   invalidate a single register REGNUM in the cache */
+void
+register_changed (int regnum)
+{
+  register_valid[regnum] = 0;
+}
+
 /* FIND_SAVED_REGISTER ()
 
    Return the address in which frame FRAME's value of register REGNUM
@@ -381,7 +391,14 @@ read_register_bytes (int inregbyte, char *myaddr, int inlen)
        FETCH_PSEUDO_REGISTER (regno);
 
       if (!register_valid[regno])
-       error ("read_register_bytes:  Couldn't update register %d.", regno);
+       {
+         /* Sometimes pseudoregs are never marked valid, so that they 
+            will be fetched every time (it can be complicated to know
+            if a pseudoreg is valid, while "fetching" them can be cheap). 
+            */
+         if (regno < NUM_REGS)
+           error ("read_register_bytes:  Couldn't update register %d.", regno);
+       }
     }
 
   if (myaddr != NULL)
@@ -707,7 +724,7 @@ supply_register (int regno, char *val)
    Ditto for write_pc.
 
    1999-06-08: The following were re-written so that it assumes the
-   existance of a TARGET_READ_PC et.al. macro.  A default generic
+   existence of a TARGET_READ_PC et.al. macro.  A default generic
    version of that macro is made available where needed.
 
    Since the ``TARGET_READ_PC'' et.al. macro is going to be controlled
@@ -858,6 +875,17 @@ write_fp (CORE_ADDR val)
   TARGET_WRITE_FP (val);
 }
 
+/* ARGSUSED */
+static void
+reg_flush_command (char *command, int from_tty)
+{
+  /* Force-flush the register cache.  */
+  registers_changed ();
+  if (from_tty)
+    printf_filtered ("Register cache flushed.\n");
+}
+
+
 static void
 build_regcache (void)
 {
@@ -880,4 +908,7 @@ _initialize_regcache (void)
   register_gdbarch_swap (&registers, sizeof (registers), NULL);
   register_gdbarch_swap (&register_valid, sizeof (register_valid), NULL);
   register_gdbarch_swap (NULL, 0, build_regcache);
+
+  add_com ("flushregs", class_maintenance, reg_flush_command,
+          "Force gdb to flush its register cache (maintainer command)");
 }
This page took 0.023707 seconds and 4 git commands to generate.