2003-05-08 Andrew Cagney <cagney@redhat.com>
authorAndrew Cagney <cagney@redhat.com>
Thu, 8 May 2003 22:33:14 +0000 (22:33 +0000)
committerAndrew Cagney <cagney@redhat.com>
Thu, 8 May 2003 22:33:14 +0000 (22:33 +0000)
* regcache.h (max_register_size): Delete declaration.
* regcache.c (max_register_size): Delete function.
(struct regcache_descr): Delete field "max_register_size".
(init_regcache_descr, init_legacy_regcache_descr): Assert that all
registers fit in MAX_REGISTER_SIZE.
(regcache_save): Replace max_register_size with MAX_REGISTER_SIZE.
(regcache_restore, regcache_xfer_part, regcache_dump): Ditto.
* thread-db.c: Replace max_register_size with MAX_REGISTER_SIZE.
* sh-tdep.c, rom68k-rom.c, remote-sim.c, remote-mips.c: Ditto.
* remote-e7000.c, monitor.c, mipsv4-nat.c, mips-nat.c: Ditto.
* m68klinux-nat.c, lynx-nat.c, irix4-nat.c: Ditto.
* hpux-thread.c, hppah-nat.c, hppab-nat.c, hppa-tdep.c: Ditto.
* dve3900-rom.c, hppa-tdep.c: Ditto.

20 files changed:
gdb/ChangeLog
gdb/dve3900-rom.c
gdb/hppa-tdep.c
gdb/hppab-nat.c
gdb/hppah-nat.c
gdb/hpux-thread.c
gdb/irix4-nat.c
gdb/lynx-nat.c
gdb/m68klinux-nat.c
gdb/mips-nat.c
gdb/mipsv4-nat.c
gdb/monitor.c
gdb/regcache.c
gdb/regcache.h
gdb/remote-e7000.c
gdb/remote-mips.c
gdb/remote-sim.c
gdb/rom68k-rom.c
gdb/sh-tdep.c
gdb/thread-db.c

index 12ec09b..9c58b41 100644 (file)
@@ -1,3 +1,19 @@
+2003-05-08  Andrew Cagney  <cagney@redhat.com>
+
+       * regcache.h (max_register_size): Delete declaration.
+       * regcache.c (max_register_size): Delete function.
+       (struct regcache_descr): Delete field "max_register_size".
+       (init_regcache_descr, init_legacy_regcache_descr): Assert that all
+       registers fit in MAX_REGISTER_SIZE.
+       (regcache_save): Replace max_register_size with MAX_REGISTER_SIZE.
+       (regcache_restore, regcache_xfer_part, regcache_dump): Ditto.
+       * thread-db.c: Replace max_register_size with MAX_REGISTER_SIZE.
+       * sh-tdep.c, rom68k-rom.c, remote-sim.c, remote-mips.c: Ditto.
+       * remote-e7000.c, monitor.c, mipsv4-nat.c, mips-nat.c: Ditto.
+       * m68klinux-nat.c, lynx-nat.c, irix4-nat.c: Ditto.
+       * hpux-thread.c, hppah-nat.c, hppab-nat.c, hppa-tdep.c: Ditto.
+       * dve3900-rom.c, hppa-tdep.c: Ditto.
+
 2003-05-08  David Carlton  <carlton@math.stanford.edu>
 
        * valops.c (push_word): Fix typo.
index e7329f8..02a273c 100644 (file)
@@ -455,7 +455,7 @@ static void
 fetch_bitmapped_register (int regno, struct bit_field *bf)
 {
   unsigned long val;
-  unsigned char *regbuf = alloca (max_register_size (current_gdbarch));
+  unsigned char regbuf[MAX_REGISTER_SIZE];
   char *regname = NULL;
 
   if (regno >= sizeof (r3900_regnames) / sizeof (r3900_regnames[0]))
index db8d510..d524bae 100644 (file)
@@ -2630,7 +2630,7 @@ pa_register_look_aside (char *raw_regs, int regnum, long *raw_val)
   int start;
 
 
-  char *buf = alloca (max_register_size (current_gdbarch));
+  char buf[MAX_REGISTER_SIZE];
   long long reg_val;
 
   if (!know_which)
@@ -2827,8 +2827,8 @@ pa_strcat_registers (char *raw_regs, int regnum, int fpregs,
 static void
 pa_print_fp_reg (int i)
 {
-  char *raw_buffer = alloca (max_register_size (current_gdbarch));
-  char *virtual_buffer = alloca (max_register_size (current_gdbarch));
+  char raw_buffer[MAX_REGISTER_SIZE];
+  char virtual_buffer[MAX_REGISTER_SIZE];
 
   /* Get 32bits of data.  */
   frame_register_read (deprecated_selected_frame, i, raw_buffer);
@@ -2870,8 +2870,8 @@ pa_print_fp_reg (int i)
 static void
 pa_strcat_fp_reg (int i, struct ui_file *stream, enum precision_type precision)
 {
-  char *raw_buffer = alloca (max_register_size (current_gdbarch));
-  char *virtual_buffer = alloca (max_register_size (current_gdbarch));
+  char raw_buffer[MAX_REGISTER_SIZE];
+  char virtual_buffer[MAX_REGISTER_SIZE];
 
   fputs_filtered (REGISTER_NAME (i), stream);
   print_spaces_filtered (8 - strlen (REGISTER_NAME (i)), stream);
@@ -2885,7 +2885,7 @@ pa_strcat_fp_reg (int i, struct ui_file *stream, enum precision_type precision)
   if (precision == double_precision && (i % 2) == 0)
     {
 
-      char *raw_buf = alloca (max_register_size (current_gdbarch));
+      char raw_buf[MAX_REGISTER_SIZE];
 
       /* Get the data in raw format for the 2nd half.  */
       frame_register_read (deprecated_selected_frame, i + 1, raw_buf);
index 3ec3a57..dc3e6b6 100644 (file)
@@ -55,7 +55,7 @@ static void
 fetch_register (int regno)
 {
   register unsigned int regaddr;
-  char *buf = alloca (max_register_size (current_gdbarch));
+  char buf[MAX_REGISTER_SIZE];
   register int i;
 
   /* Offset of registers within the u area.  */
index b953d25..0b8b04f 100644 (file)
@@ -190,7 +190,7 @@ store_inferior_registers (int regno)
 static void
 fetch_register (int regno)
 {
-  char *buf = alloca (max_register_size (current_gdbarch));
+  char buf[MAX_REGISTER_SIZE];
   unsigned int addr, len, offset;
   int i;
 
index b585ca5..7a7b741 100644 (file)
@@ -285,7 +285,7 @@ hpux_thread_fetch_registers (int regno)
        child_ops.to_fetch_registers (regno);
       else
        {
-         unsigned char *buf = alloca (max_register_size (current_gdbarch));
+         unsigned char buf[MAX_REGISTER_SIZE];
          CORE_ADDR sp;
 
          sp = (CORE_ADDR) tcb_ptr->static_ctx.sp - 160;
@@ -347,7 +347,7 @@ hpux_thread_store_registers (int regno)
        child_ops.to_store_registers (regno);
       else
        {
-         unsigned char *buf = alloca (max_register_size (current_gdbarch));
+         unsigned char buf[MAX_REGISTER_SIZE];
          CORE_ADDR sp;
 
          sp = (CORE_ADDR) tcb_ptr->static_ctx.sp - 160;
index b44c5bb..63ca71e 100644 (file)
@@ -51,8 +51,8 @@ supply_gregset (gregset_t *gregsetp)
 {
   register int regi;
   register greg_t *regp = (greg_t *) (gregsetp->gp_regs);
-  char *zerobuf = alloca (max_register_size (current_gdbarch));
-  memset (zerobuf, 0, max_register_size (current_gdbarch));
+  char zerobuf[MAX_REGISTER_SIZE];
+  memset (zerobuf, 0, MAX_REGISTER_SIZE);
 
   /* FIXME: somewhere, there should be a #define for the meaning
      of this magic number 32; we should use that. */
@@ -104,8 +104,8 @@ void
 supply_fpregset (fpregset_t *fpregsetp)
 {
   register int regi;
-  char *zerobuf = alloca (max_register_size (current_gdbarch));
-  memset (zerobuf, 0, max_register_size (current_gdbarch));
+  char zerobuf[MAX_REGISTER_SIZE];
+  memset (zerobuf, 0, MAX_REGISTER_SIZE);
 
   for (regi = 0; regi < 32; regi++)
     supply_register (FP0_REGNUM + regi,
index 4be7fb8..f425cb9 100644 (file)
@@ -283,7 +283,7 @@ fetch_inferior_registers (int regno)
   if (whatregs & WHATREGS_GEN)
     {
       struct econtext ec;      /* general regs */
-      char *buf = alloca (max_register_size (current_gdbarch));
+      char buf[MAX_REGISTER_SIZE];
       int retval;
       int i;
 
@@ -512,7 +512,7 @@ fetch_inferior_registers (int regno)
   ecp = registers_addr (PIDGET (inferior_ptid));
 
   {
-    char *buf = alloca (max_register_size (current_gdbarch));
+    char buf[MAX_REGISTER_SIZE];
     for (regno = reglo; regno <= reghi; regno++)
       {
        int ptrace_fun = PTRACE_PEEKTHREAD;
index 0cf82fb..e077dea 100644 (file)
@@ -135,7 +135,7 @@ fetch_register (int regno)
   char mess[128];              /* For messages */
   register int i;
   unsigned int offset;         /* Offset of registers within the u area.  */
-  char *buf = alloca (max_register_size (current_gdbarch));
+  char buf[MAX_REGISTER_SIZE];
   int tid;
 
   if (CANNOT_FETCH_REGISTER (regno))
index 3aaaa91..1a29c3e 100644 (file)
@@ -70,10 +70,10 @@ void
 fetch_inferior_registers (int regno)
 {
   register unsigned int regaddr;
-  char *buf = alloca (max_register_size (current_gdbarch));
+  char buf[MAX_REGISTER_SIZE];
   register int i;
-  char *zerobuf = alloca (max_register_size (current_gdbarch));
-  memset (zerobuf, 0, max_register_size (current_gdbarch));
+  char zerobuf[MAX_REGISTER_SIZE];
+  memset (zerobuf, 0, MAX_REGISTER_SIZE);
 
   deprecated_registers_fetched ();
 
@@ -174,8 +174,8 @@ fetch_core_registers (char *core_reg_sect, unsigned core_reg_size, int which,
   int bad_reg = -1;
   register reg_ptr = -reg_addr;        /* Original u.u_ar0 is -reg_addr. */
 
-  char *zerobuf = alloca (max_register_size (current_gdbarch));
-  memset (zerobuf, 0, max_register_size (current_gdbarch));
+  char zerobuf[MAX_REGISTER_SIZE];
+  memset (zerobuf, 0, MAX_REGISTER_SIZE);
 
 
   /* If u.u_ar0 was an absolute address in the core file, relativize it now,
index 874bef4..65ffa0d 100644 (file)
@@ -47,8 +47,8 @@ supply_gregset (gregset_t *gregsetp)
 {
   register int regi;
   register greg_t *regp = &(*gregsetp)[0];
-  char *zerobuf = alloca (max_register_size (current_gdbarch));
-  memset (zerobuf, 0, max_register_size (current_gdbarch));
+  char zerobuf[MAX_REGISTER_SIZE];
+  memset (zerobuf, 0, MAX_REGISTER_SIZE);
 
   for (regi = 0; regi <= CXT_RA; regi++)
     supply_register (regi, (char *) (regp + regi));
@@ -102,8 +102,8 @@ void
 supply_fpregset (fpregset_t *fpregsetp)
 {
   register int regi;
-  char *zerobuf = alloca (max_register_size (current_gdbarch));
-  memset (zerobuf, 0, max_register_size (current_gdbarch));
+  char zerobuf[MAX_REGISTER_SIZE];
+  memset (zerobuf, 0, MAX_REGISTER_SIZE);
 
   for (regi = 0; regi < 32; regi++)
     supply_register (FP0_REGNUM + regi,
index 20c89f8..ede61bb 100644 (file)
@@ -896,7 +896,7 @@ char *
 monitor_supply_register (int regno, char *valstr)
 {
   ULONGEST val;
-  unsigned char *regbuf = alloca (max_register_size (current_gdbarch));
+  unsigned char regbuf[MAX_REGISTER_SIZE];
   char *p;
 
   val = 0;
index ec60d97..acf3044 100644 (file)
@@ -78,9 +78,6 @@ struct regcache_descr
   long *register_offset;
   long *sizeof_register;
 
-  /* Useful constant.  Largest of all the registers.  */
-  long max_register_size;
-
   /* Cached table containing the type of each register.  */
   struct type **register_type;
 };
@@ -109,7 +106,6 @@ init_legacy_regcache_descr (struct gdbarch *gdbarch,
      read_register_bytes() and write_register_bytes() registers.  */
   descr->sizeof_register = XCALLOC (descr->nr_cooked_registers, long);
   descr->register_offset = XCALLOC (descr->nr_cooked_registers, long);
-  descr->max_register_size = 0;
   for (i = 0; i < descr->nr_cooked_registers; i++)
     {
       /* FIXME: cagney/2001-12-04: This code shouldn't need to use
@@ -119,10 +115,8 @@ init_legacy_regcache_descr (struct gdbarch *gdbarch,
          entirely avoid this uglyness.  */
       descr->register_offset[i] = REGISTER_BYTE (i);
       descr->sizeof_register[i] = REGISTER_RAW_SIZE (i);
-      if (descr->max_register_size < REGISTER_RAW_SIZE (i))
-       descr->max_register_size = REGISTER_RAW_SIZE (i);
-      if (descr->max_register_size < REGISTER_VIRTUAL_SIZE (i))
-       descr->max_register_size = REGISTER_VIRTUAL_SIZE (i);
+      gdb_assert (MAX_REGISTER_SIZE >= REGISTER_RAW_SIZE (i));
+      gdb_assert (MAX_REGISTER_SIZE >= REGISTER_VIRTUAL_SIZE (i));
     }
 
   /* Compute the real size of the register buffer.  Start out by
@@ -219,14 +213,12 @@ init_regcache_descr (struct gdbarch *gdbarch)
     long offset = 0;
     descr->sizeof_register = XCALLOC (descr->nr_cooked_registers, long);
     descr->register_offset = XCALLOC (descr->nr_cooked_registers, long);
-    descr->max_register_size = 0;
     for (i = 0; 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];
-       if (descr->max_register_size < descr->sizeof_register[i])
-         descr->max_register_size = descr->sizeof_register[i];
+       gdb_assert (MAX_REGISTER_SIZE >= descr->sizeof_register[i]);
       }
     /* Set the real size of the register cache buffer.  */
     descr->sizeof_cooked_registers = offset;
@@ -290,13 +282,6 @@ register_type (struct gdbarch *gdbarch, int regnum)
    the regcache descr.  */
 
 int
-max_register_size (struct gdbarch *gdbarch)
-{
-  struct regcache_descr *descr = regcache_descr (gdbarch);
-  return descr->max_register_size;
-}
-
-int
 register_size (struct gdbarch *gdbarch, int regnum)
 {
   struct regcache_descr *descr = regcache_descr (gdbarch);
@@ -379,7 +364,7 @@ regcache_save (struct regcache *dst, regcache_cooked_read_ftype *cooked_read,
               void *src)
 {
   struct gdbarch *gdbarch = dst->descr->gdbarch;
-  void *buf = alloca (max_register_size (gdbarch));
+  char buf[MAX_REGISTER_SIZE];
   int regnum;
   /* The DST should be `read-only', if it wasn't then the save would
      end up trying to write the register values back out to the
@@ -413,7 +398,7 @@ regcache_restore (struct regcache *dst,
                  void *src)
 {
   struct gdbarch *gdbarch = dst->descr->gdbarch;
-  void *buf = alloca (max_register_size (gdbarch));
+  char buf[MAX_REGISTER_SIZE];
   int regnum;
   /* The dst had better not be read-only.  If it is, the `restore'
      doesn't make much sense.  */
@@ -1090,7 +1075,7 @@ regcache_xfer_part (struct regcache *regcache, int regnum,
                    regcache_read_ftype *read, regcache_write_ftype *write)
 {
   struct regcache_descr *descr = regcache->descr;
-  bfd_byte *reg = alloca (descr->max_register_size);
+  bfd_byte reg[MAX_REGISTER_SIZE];
   gdb_assert (offset >= 0 && offset <= descr->sizeof_register[regnum]);
   gdb_assert (len >= 0 && offset + len <= descr->sizeof_register[regnum]);
   /* Something to do?  */
@@ -1480,7 +1465,7 @@ regcache_dump (struct regcache *regcache, struct ui_file *file,
   int footnote_register_offset = 0;
   int footnote_register_type_name_null = 0;
   long register_offset = 0;
-  unsigned char *buf = alloca (regcache->descr->max_register_size);
+  unsigned char buf[MAX_REGISTER_SIZE];
 
 #if 0
   fprintf_unfiltered (file, "legacy_p %d\n", regcache->descr->legacy_p);
@@ -1492,8 +1477,6 @@ regcache_dump (struct regcache *regcache, struct ui_file *file,
                      regcache->descr->sizeof_raw_registers);
   fprintf_unfiltered (file, "sizeof_raw_register_valid_p %ld\n",
                      regcache->descr->sizeof_raw_register_valid_p);
-  fprintf_unfiltered (file, "max_register_size %ld\n",
-                     regcache->descr->max_register_size);
   fprintf_unfiltered (file, "NUM_REGS %d\n", NUM_REGS);
   fprintf_unfiltered (file, "NUM_PSEUDO_REGS %d\n", NUM_PSEUDO_REGS);
 #endif
index 2368cf0..5d77095 100644 (file)
@@ -127,12 +127,6 @@ extern int register_offset_hack (struct gdbarch *gdbarch, int regnum);
 extern struct type *register_type (struct gdbarch *gdbarch, int regnum);
 
 
-/* Return the size of the largest register.  Used when allocating
-   space for an aribtrary register value.  */
-
-extern int max_register_size (struct gdbarch *gdbarch);
-
-
 /* Return the size of register REGNUM.  All registers should have only
    one size.
 
index 3b9a941..643c6b6 100644 (file)
@@ -785,7 +785,7 @@ void
 fetch_regs_from_dump (int (*nextchar) (), char *want)
 {
   int regno;
-  char *buf = alloca (max_register_size (current_gdbarch));
+  char buf[MAX_REGISTER_SIZE];
 
   int thischar = nextchar ();
 
index 17994f9..d1e3705 100644 (file)
@@ -1791,7 +1791,7 @@ mips_wait (ptid_t ptid, struct target_waitstatus *status)
                    &rpc, &rfp, &rsp, flags);
   if (nfields >= 3)
     {
-      char *buf = alloca (max_register_size (current_gdbarch));
+      char buf[MAX_REGISTER_SIZE];
 
       store_unsigned_integer (buf, REGISTER_RAW_SIZE (PC_REGNUM), rpc);
       supply_register (PC_REGNUM, buf);
@@ -1972,7 +1972,7 @@ mips_fetch_registers (int regno)
     }
 
   {
-    char *buf = alloca (max_register_size (current_gdbarch));
+    char buf[MAX_REGISTER_SIZE];
 
     /* We got the number the register holds, but gdb expects to see a
        value in the target byte ordering.  */
index da4a96c..f7b9e89 100644 (file)
@@ -359,7 +359,7 @@ gdbsim_store_register (int regno)
     }
   else if (REGISTER_SIM_REGNO (regno) >= 0)
     {
-      char *tmp = alloca (max_register_size (current_gdbarch));
+      char tmp[MAX_REGISTER_SIZE];
       int nr_bytes;
       deprecated_read_register_gen (regno, tmp);
       nr_bytes = sim_store_register (gdbsim_desc,
index 57c0a18..6b0926b 100644 (file)
@@ -88,7 +88,7 @@ static char *
 rom68k_supply_one_register (int regno, unsigned char *hex)
 {
   ULONGEST value;
-  unsigned char *regbuf = alloca (max_register_size (current_gdbarch));
+  unsigned char regbuf[MAX_REGISTER_SIZE];
 
   value = 0;
   while (*hex != '\0')
index e70d74f..0ef65de 100644 (file)
@@ -4087,7 +4087,7 @@ sh64_do_pseudo_register (int regnum)
 static void
 sh_do_register (int regnum)
 {
-  char *raw_buffer = alloca (max_register_size (current_gdbarch));
+  char raw_buffer[MAX_REGISTER_SIZE];
 
   fputs_filtered (REGISTER_NAME (regnum), gdb_stdout);
   print_spaces_filtered (15 - strlen (REGISTER_NAME (regnum)), gdb_stdout);
index bac4641..0a6138b 100644 (file)
@@ -945,7 +945,7 @@ thread_db_store_registers (int regno)
 
   if (regno != -1)
     {
-      char *raw = alloca (max_register_size (current_gdbarch));
+      char raw[MAX_REGISTER_SIZE];
 
       deprecated_read_register_gen (regno, raw);
       thread_db_fetch_registers (-1);