* regcache.c (struct regcache_descr): Remove outdated comment.
authorPedro Alves <palves@redhat.com>
Tue, 25 Jan 2011 12:13:20 +0000 (12:13 +0000)
committerPedro Alves <palves@redhat.com>
Tue, 25 Jan 2011 12:13:20 +0000 (12:13 +0000)
(init_regcache_descr): Remove sizeof_raw_register_valid_p
overallocate hack.
(regcache_xmalloc): Rename to ...
(regcache_xmalloc_1): ... this.  Add `readonly_p' parameter.
Allocate the regcache type accordingly.
(regcache_xmalloc): New as wrapper around regcache_xmalloc_1.
(regcache_xfree): Asser the source is also readonly.  Copy sizeof
cooked registers, not raw.
(regcache_dup_no_passthrough): Delete.
(get_thread_arch_regcache): Use regcache_xmalloc_1.
* h8300-tdep.c (h8300_push_dummy_call): Tweak comment to not
mention obsolete write_register_bytes.
* regcache.h (regcache_dup_no_passthrough): Delete declaration.

gdb/ChangeLog
gdb/h8300-tdep.c
gdb/regcache.c
gdb/regcache.h

index ecb1724f48e728479b76e88ad66d93eaa21d8aeb..0aeb5b78061dc29d1b013a0f0f5539718475bc9c 100644 (file)
@@ -1,3 +1,20 @@
+2011-01-25  Pedro Alves  <pedro@codesourcery.com>
+
+       * regcache.c (struct regcache_descr): Remove outdated comment.
+       (init_regcache_descr): Remove sizeof_raw_register_valid_p
+       overallocate hack.
+       (regcache_xmalloc): Rename to ...
+       (regcache_xmalloc_1): ... this.  Add `readonly_p' parameter.
+       Allocate the regcache type accordingly.
+       (regcache_xmalloc): New as wrapper around regcache_xmalloc_1.
+       (regcache_xfree): Asser the source is also readonly.  Copy sizeof
+       cooked registers, not raw.
+       (regcache_dup_no_passthrough): Delete.
+       (get_thread_arch_regcache): Use regcache_xmalloc_1.
+       * h8300-tdep.c (h8300_push_dummy_call): Tweak comment to not
+       mention obsolete write_register_bytes.
+       * regcache.h (regcache_dup_no_passthrough): Delete declaration.
+
 2011-01-25  Pedro Alves  <pedro@codesourcery.com>
 
        Stop remote_read_bytes from handling partial reads itself.
index 9ff077e7d411c3e5ecea285019da2915b74a9384..cfcd9740e637fb6f31c86e45fc254a59d812d39d 100644 (file)
@@ -698,9 +698,8 @@ h8300_push_dummy_call (struct gdbarch *gdbarch, struct value *function,
          else
            {
              /* Heavens to Betsy --- it's really going in registers!
-                It would be nice if we could use write_register_bytes
-                here, but on the h8/300s, there are gaps between
-                the registers in the register file.  */
+                Note that on the h8/300s, there are gaps between the
+                registers in the register file.  */
              int offset;
 
              for (offset = 0; offset < padded_len; offset += wordsize)
index 3ca300831ab7b2f7a35d2bab8e17f799e384b2a0..c9c973ec0dcccd5b661c14ff2b5f45608887ad2c 100644 (file)
@@ -67,10 +67,8 @@ struct regcache_descr
 
   /* Offset and size (in 8 bit bytes), of reach register in the
      register cache.  All registers (including those in the range
-     [NR_RAW_REGISTERS .. NR_COOKED_REGISTERS) are given an offset.
-     Assigning all registers an offset makes it possible to keep
-     legacy code, such as that found in read_register_bytes() and
-     write_register_bytes() working.  */
+     [NR_RAW_REGISTERS .. NR_COOKED_REGISTERS) are given an
+     offset.  */
   long *register_offset;
   long *sizeof_register;
 
@@ -108,12 +106,7 @@ init_regcache_descr (struct gdbarch *gdbarch)
   /* Construct a strictly RAW register cache.  Don't allow pseudo's
      into the register cache.  */
   descr->nr_raw_registers = gdbarch_num_regs (gdbarch);
-
-  /* FIXME: cagney/2002-08-13: Overallocate the register_valid_p
-     array.  This pretects GDB from erant code that accesses elements
-     of the global register_valid_p[] array in the range 
-     [gdbarch_num_regs .. gdbarch_num_regs + gdbarch_num_pseudo_regs).  */
-  descr->sizeof_raw_register_valid_p = descr->sizeof_cooked_register_valid_p;
+  descr->sizeof_raw_register_valid_p = gdbarch_num_regs (gdbarch);
 
   /* Lay out the register cache.
 
@@ -129,24 +122,27 @@ init_regcache_descr (struct gdbarch *gdbarch)
       = GDBARCH_OBSTACK_CALLOC (gdbarch, descr->nr_cooked_registers, long);
     descr->register_offset
       = GDBARCH_OBSTACK_CALLOC (gdbarch, descr->nr_cooked_registers, long);
-    for (i = 0; i < descr->nr_cooked_registers; i++)
+    for (i = 0; i < descr->nr_raw_registers; i++)
+      {
+       descr->sizeof_register[i] = TYPE_LENGTH (descr->register_type[i]);
+       descr->register_offset[i] = offset;
+       offset += descr->sizeof_register[i];
+       gdb_assert (MAX_REGISTER_SIZE >= descr->sizeof_register[i]);
+      }
+    /* Set the real size of the raw register cache buffer.  */
+    descr->sizeof_raw_registers = offset;
+
+    for (; i < descr->nr_cooked_registers; i++)
       {
        descr->sizeof_register[i] = TYPE_LENGTH (descr->register_type[i]);
        descr->register_offset[i] = offset;
        offset += descr->sizeof_register[i];
        gdb_assert (MAX_REGISTER_SIZE >= descr->sizeof_register[i]);
       }
-    /* Set the real size of the register cache buffer.  */
+    /* Set the real size of the readonly register cache buffer.  */
     descr->sizeof_cooked_registers = offset;
   }
 
-  /* FIXME: cagney/2002-05-22: Should only need to allocate space for
-     the raw registers.  Unfortunately some code still accesses the
-     register array directly using the global registers[].  Until that
-     code has been purged, play safe and over allocating the register
-     buffer.  Ulgh!  */
-  descr->sizeof_raw_registers = descr->sizeof_cooked_registers;
-
   return descr;
 }
 
@@ -215,8 +211,9 @@ struct regcache
   ptid_t ptid;
 };
 
-struct regcache *
-regcache_xmalloc (struct gdbarch *gdbarch, struct address_space *aspace)
+static struct regcache *
+regcache_xmalloc_1 (struct gdbarch *gdbarch, struct address_space *aspace,
+                   int readonly_p)
 {
   struct regcache_descr *descr;
   struct regcache *regcache;
@@ -225,16 +222,32 @@ regcache_xmalloc (struct gdbarch *gdbarch, struct address_space *aspace)
   descr = regcache_descr (gdbarch);
   regcache = XMALLOC (struct regcache);
   regcache->descr = descr;
-  regcache->registers
-    = XCALLOC (descr->sizeof_raw_registers, gdb_byte);
-  regcache->register_valid_p
-    = XCALLOC (descr->sizeof_raw_register_valid_p, gdb_byte);
+  regcache->readonly_p = readonly_p;
+  if (readonly_p)
+    {
+      regcache->registers
+       = XCALLOC (descr->sizeof_cooked_registers, gdb_byte);
+      regcache->register_valid_p
+       = XCALLOC (descr->sizeof_cooked_register_valid_p, gdb_byte);
+    }
+  else
+    {
+      regcache->registers
+       = XCALLOC (descr->sizeof_raw_registers, gdb_byte);
+      regcache->register_valid_p
+       = XCALLOC (descr->sizeof_raw_register_valid_p, gdb_byte);
+    }
   regcache->aspace = aspace;
-  regcache->readonly_p = 1;
   regcache->ptid = minus_one_ptid;
   return regcache;
 }
 
+struct regcache *
+regcache_xmalloc (struct gdbarch *gdbarch, struct address_space *aspace)
+{
+  return regcache_xmalloc_1 (gdbarch, aspace, 1);
+}
+
 void
 regcache_xfree (struct regcache *regcache)
 {
@@ -382,11 +395,12 @@ regcache_cpy_no_passthrough (struct regcache *dst, struct regcache *src)
   /* NOTE: cagney/2002-05-17: Don't let the caller do a no-passthrough
      move of data into the current regcache.  Doing this would be
      silly - it would mean that valid_p would be completely invalid.  */
-  gdb_assert (dst->readonly_p);
+  gdb_assert (dst->readonly_p && src->readonly_p);
 
-  memcpy (dst->registers, src->registers, dst->descr->sizeof_raw_registers);
+  memcpy (dst->registers, src->registers,
+         dst->descr->sizeof_cooked_registers);
   memcpy (dst->register_valid_p, src->register_valid_p,
-         dst->descr->sizeof_raw_register_valid_p);
+         dst->descr->sizeof_cooked_register_valid_p);
 }
 
 struct regcache *
@@ -399,16 +413,6 @@ regcache_dup (struct regcache *src)
   return newbuf;
 }
 
-struct regcache *
-regcache_dup_no_passthrough (struct regcache *src)
-{
-  struct regcache *newbuf;
-
-  newbuf = regcache_xmalloc (src->descr->gdbarch, get_regcache_aspace (src));
-  regcache_cpy_no_passthrough (newbuf, src);
-  return newbuf;
-}
-
 int
 regcache_valid_p (const struct regcache *regcache, int regnum)
 {
@@ -459,9 +463,8 @@ get_thread_arch_regcache (ptid_t ptid, struct gdbarch *gdbarch)
        && get_regcache_arch (list->regcache) == gdbarch)
       return list->regcache;
 
-  new_regcache = regcache_xmalloc (gdbarch,
-                                  target_thread_address_space (ptid));
-  new_regcache->readonly_p = 0;
+  new_regcache = regcache_xmalloc_1 (gdbarch,
+                                    target_thread_address_space (ptid), 0);
   new_regcache->ptid = ptid;
   gdb_assert (new_regcache->aspace != NULL);
 
index 99bb322b60106bc0d3f9e57898cdb9208cc24eb3..e5ec1cc6b63a6eb136b71066a07665f455225c31 100644 (file)
@@ -154,7 +154,6 @@ extern void regcache_restore (struct regcache *dst,
    only transfer values already in the cache.  */
 
 extern struct regcache *regcache_dup (struct regcache *regcache);
-extern struct regcache *regcache_dup_no_passthrough (struct regcache *);
 extern void regcache_cpy (struct regcache *dest, struct regcache *src);
 extern void regcache_cpy_no_passthrough (struct regcache *dest,
                                         struct regcache *src);
This page took 0.031823 seconds and 4 git commands to generate.