This is the mail archive of the
gdb-patches@sources.redhat.com
mailing list for the GDB project.
[commit] max_register_size() -> MAX_REGISTER_SIZE
- From: Andrew Cagney <ac131313 at redhat dot com>
- To: gdb-patches at sources dot redhat dot com,David Carlton <carlton at math dot stanford dot edu>
- Date: Thu, 08 May 2003 18:37:02 -0400
- Subject: [commit] max_register_size() -> MAX_REGISTER_SIZE
Similar to the previous ones, this replaces the function
max_register_size() with the constant MAX_REGISTER_SIZE.
Committed (but this time hopefully the correct source tree - David
thanks for fixing that botch).
I wonder if the elimination of all these calls makes gdb run faster :-^
Andrew
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.
Index: dve3900-rom.c
===================================================================
RCS file: /cvs/src/src/gdb/dve3900-rom.c,v
retrieving revision 1.11
diff -u -r1.11 dve3900-rom.c
--- dve3900-rom.c 2 Feb 2003 05:46:14 -0000 1.11
+++ dve3900-rom.c 8 May 2003 22:31:49 -0000
@@ -455,7 +455,7 @@
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: hppa-tdep.c
===================================================================
RCS file: /cvs/src/src/gdb/hppa-tdep.c,v
retrieving revision 1.74
diff -u -r1.74 hppa-tdep.c
--- hppa-tdep.c 5 May 2003 17:56:55 -0000 1.74
+++ hppa-tdep.c 8 May 2003 22:31:50 -0000
@@ -2630,7 +2630,7 @@
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 @@
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 @@
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 @@
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: hppab-nat.c
===================================================================
RCS file: /cvs/src/src/gdb/hppab-nat.c,v
retrieving revision 1.8
diff -u -r1.8 hppab-nat.c
--- hppab-nat.c 2 Feb 2003 05:46:14 -0000 1.8
+++ hppab-nat.c 8 May 2003 22:31:50 -0000
@@ -55,7 +55,7 @@
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: hppah-nat.c
===================================================================
RCS file: /cvs/src/src/gdb/hppah-nat.c,v
retrieving revision 1.23
diff -u -r1.23 hppah-nat.c
--- hppah-nat.c 29 Mar 2003 23:29:47 -0000 1.23
+++ hppah-nat.c 8 May 2003 22:31:50 -0000
@@ -190,7 +190,7 @@
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: hpux-thread.c
===================================================================
RCS file: /cvs/src/src/gdb/hpux-thread.c,v
retrieving revision 1.15
diff -u -r1.15 hpux-thread.c
--- hpux-thread.c 7 Feb 2003 05:33:45 -0000 1.15
+++ hpux-thread.c 8 May 2003 22:31:51 -0000
@@ -285,7 +285,7 @@
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 @@
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: irix4-nat.c
===================================================================
RCS file: /cvs/src/src/gdb/irix4-nat.c,v
retrieving revision 1.10
diff -u -r1.10 irix4-nat.c
--- irix4-nat.c 2 Feb 2003 05:46:14 -0000 1.10
+++ irix4-nat.c 8 May 2003 22:31:51 -0000
@@ -51,8 +51,8 @@
{
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 @@
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: lynx-nat.c
===================================================================
RCS file: /cvs/src/src/gdb/lynx-nat.c,v
retrieving revision 1.13
diff -u -r1.13 lynx-nat.c
--- lynx-nat.c 7 Feb 2003 04:49:34 -0000 1.13
+++ lynx-nat.c 8 May 2003 22:31:51 -0000
@@ -283,7 +283,7 @@
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 @@
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: m68klinux-nat.c
===================================================================
RCS file: /cvs/src/src/gdb/m68klinux-nat.c,v
retrieving revision 1.17
diff -u -r1.17 m68klinux-nat.c
--- m68klinux-nat.c 8 May 2003 20:52:47 -0000 1.17
+++ m68klinux-nat.c 8 May 2003 22:31:51 -0000
@@ -135,7 +135,7 @@
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: mips-nat.c
===================================================================
RCS file: /cvs/src/src/gdb/mips-nat.c,v
retrieving revision 1.10
diff -u -r1.10 mips-nat.c
--- mips-nat.c 29 Apr 2003 01:49:47 -0000 1.10
+++ mips-nat.c 8 May 2003 22:31:51 -0000
@@ -70,10 +70,10 @@
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 @@
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: mipsv4-nat.c
===================================================================
RCS file: /cvs/src/src/gdb/mipsv4-nat.c,v
retrieving revision 1.9
diff -u -r1.9 mipsv4-nat.c
--- mipsv4-nat.c 29 Apr 2003 01:49:47 -0000 1.9
+++ mipsv4-nat.c 8 May 2003 22:31:51 -0000
@@ -47,8 +47,8 @@
{
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 @@
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: monitor.c
===================================================================
RCS file: /cvs/src/src/gdb/monitor.c,v
retrieving revision 1.39
diff -u -r1.39 monitor.c
--- monitor.c 8 May 2003 20:52:48 -0000 1.39
+++ monitor.c 8 May 2003 22:31:51 -0000
@@ -896,7 +896,7 @@
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: regcache.c
===================================================================
RCS file: /cvs/src/src/gdb/regcache.c,v
retrieving revision 1.79
diff -u -r1.79 regcache.c
--- regcache.c 8 May 2003 20:52:48 -0000 1.79
+++ regcache.c 8 May 2003 22:31:52 -0000
@@ -78,9 +78,6 @@
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 @@
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 @@
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 @@
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 @@
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 @@
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 @@
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_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 @@
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->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: regcache.h
===================================================================
RCS file: /cvs/src/src/gdb/regcache.h,v
retrieving revision 1.33
diff -u -r1.33 regcache.h
--- regcache.h 8 May 2003 20:38:07 -0000 1.33
+++ regcache.h 8 May 2003 22:31:52 -0000
@@ -127,12 +127,6 @@
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: remote-e7000.c
===================================================================
RCS file: /cvs/src/src/gdb/remote-e7000.c,v
retrieving revision 1.34
diff -u -r1.34 remote-e7000.c
--- remote-e7000.c 29 Apr 2003 01:49:47 -0000 1.34
+++ remote-e7000.c 8 May 2003 22:31:52 -0000
@@ -785,7 +785,7 @@
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: remote-mips.c
===================================================================
RCS file: /cvs/src/src/gdb/remote-mips.c,v
retrieving revision 1.33
diff -u -r1.33 remote-mips.c
--- remote-mips.c 29 Apr 2003 01:49:47 -0000 1.33
+++ remote-mips.c 8 May 2003 22:31:53 -0000
@@ -1791,7 +1791,7 @@
&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 @@
}
{
- 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: remote-sim.c
===================================================================
RCS file: /cvs/src/src/gdb/remote-sim.c,v
retrieving revision 1.29
diff -u -r1.29 remote-sim.c
--- remote-sim.c 8 May 2003 20:52:48 -0000 1.29
+++ remote-sim.c 8 May 2003 22:31:54 -0000
@@ -359,7 +359,7 @@
}
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: rom68k-rom.c
===================================================================
RCS file: /cvs/src/src/gdb/rom68k-rom.c,v
retrieving revision 1.10
diff -u -r1.10 rom68k-rom.c
--- rom68k-rom.c 2 Feb 2003 05:46:14 -0000 1.10
+++ rom68k-rom.c 8 May 2003 22:31:54 -0000
@@ -88,7 +88,7 @@
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: sh-tdep.c
===================================================================
RCS file: /cvs/src/src/gdb/sh-tdep.c,v
retrieving revision 1.121
diff -u -r1.121 sh-tdep.c
--- sh-tdep.c 8 May 2003 20:52:48 -0000 1.121
+++ sh-tdep.c 8 May 2003 22:31:54 -0000
@@ -4087,7 +4087,7 @@
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: thread-db.c
===================================================================
RCS file: /cvs/src/src/gdb/thread-db.c,v
retrieving revision 1.30
diff -u -r1.30 thread-db.c
--- thread-db.c 17 Apr 2003 17:30:02 -0000 1.30
+++ thread-db.c 8 May 2003 22:31:54 -0000
@@ -945,7 +945,7 @@
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);