This is the mail archive of the
gdb-patches@sources.redhat.com
mailing list for the GDB project.
[commit] MAX_REGISTER_VIRTUAL_SIZE -> MAX_REGISTER_SIZE=16
- From: Andrew Cagney <ac131313 at redhat dot com>
- To: gdb-patches at sources dot redhat dot com
- Date: Thu, 08 May 2003 14:44:35 -0400
- Subject: [commit] MAX_REGISTER_VIRTUAL_SIZE -> MAX_REGISTER_SIZE=16
Ref: stupify MAX_REGISTER_{RAW,VIRTUAL}_SIZE
http://sources.redhat.com/ml/gdb/2003-04/msg00014.html
This introduces a new global constant MAX_REGISTER_SIZE and then uses it
to replace MAX_REGISTER_VIRTUAL_SIZE. If the current constant value
(16) turns out to be too small, then someone can make it bigger.
Follow on changes will involve applying a similar:
s/MAX_REGISTER_RAW_SIZE/MAX_REGISTER_SIZE/
to the core code. The tdep code will likely end up using
DEPRECATED_MAX_REGISTER_RAW_SIZE as I don't trust how targets can,
potentially, be using those "constants".
The really neat thing is that it makes it possible to eliminate so many
of those alloca()s.
committed,
Andrew
2003-05-08 Andrew Cagney <cagney@redhat.com>
* gdbarch.sh: Add comments on MAX_REGISTER_SIZE.
* gdbarch.h: Re-generate.
* defs.h (MAX_REGISTER_VIRTUAL_SIZE): Delete macro.
(legacy_max_register_virtual_size): Delete declaration.
* infcmd.c (default_print_registers_info): Use MAX_REGISTER_SIZE.
* d10v-tdep.c (d10v_print_registers_info): Ditto.
* tracepoint.c (memrange_sortmerge): Ditto.
* sparc-tdep.c (sparc_print_registers): Ditto.
* regcache.c (legacy_max_register_virtual_size): Delete function.
Index: d10v-tdep.c
===================================================================
RCS file: /cvs/src/src/gdb/d10v-tdep.c,v
retrieving revision 1.115
diff -u -r1.115 d10v-tdep.c
--- d10v-tdep.c 7 May 2003 19:21:11 -0000 1.115
+++ d10v-tdep.c 8 May 2003 17:56:33 -0000
@@ -865,7 +865,7 @@
}
{
- char *num = alloca (max_register_size (gdbarch));
+ char num[MAX_REGISTER_SIZE];
int a;
fprintf_filtered (file, "A0-A%d", NR_A_REGS - 1);
for (a = a0_regnum (gdbarch); a < a0_regnum (gdbarch) + NR_A_REGS; a++)
Index: defs.h
===================================================================
RCS file: /cvs/src/src/gdb/defs.h,v
retrieving revision 1.119
diff -u -r1.119 defs.h
--- defs.h 8 May 2003 17:35:21 -0000 1.119
+++ defs.h 8 May 2003 17:56:33 -0000
@@ -1086,6 +1086,11 @@
#include "arch-utils.h"
#endif
+/* Maximum size of a register. Something small, but large enough for
+ all known ISAs. If it turns out to be too small, make it bigger. */
+
+enum { MAX_REGISTER_SIZE = 16 };
+
/* FIXME: cagney/2003-03-01: Hack to prop up old targets while they
migrate to the overhauled register cache.
@@ -1101,13 +1106,6 @@
#endif
extern int legacy_max_register_raw_size (void);
#define MAX_REGISTER_RAW_SIZE legacy_max_register_raw_size ()
-
-#ifdef MAX_REGISTER_VIRTUAL_SIZE
-#error MAX_REGISTER_VIRTUAL_SIZE defined
-#endif
-extern int legacy_max_register_virtual_size (void);
-#define MAX_REGISTER_VIRTUAL_SIZE legacy_max_register_virtual_size ()
-
/* Static target-system-dependent parameters for GDB. */
Index: gdbarch.h
===================================================================
RCS file: /cvs/src/src/gdb/gdbarch.h,v
retrieving revision 1.181
diff -u -r1.181 gdbarch.h
--- gdbarch.h 7 May 2003 19:21:11 -0000 1.181
+++ gdbarch.h 8 May 2003 17:56:34 -0000
@@ -782,10 +782,8 @@
#endif
#endif
-/* The methods REGISTER_VIRTUAL_TYPE, MAX_REGISTER_RAW_SIZE,
- MAX_REGISTER_VIRTUAL_SIZE, MAX_REGISTER_RAW_SIZE,
- REGISTER_VIRTUAL_SIZE and REGISTER_RAW_SIZE are all being replaced
- by REGISTER_TYPE. */
+/* The methods REGISTER_VIRTUAL_TYPE, REGISTER_VIRTUAL_SIZE and
+ REGISTER_RAW_SIZE are all being replaced by REGISTER_TYPE. */
/* Default (function) for non- multi-arch platforms. */
#if (!GDB_MULTI_ARCH) && !defined (REGISTER_RAW_SIZE)
@@ -804,10 +802,9 @@
#endif
#endif
-/* The methods REGISTER_VIRTUAL_TYPE, MAX_REGISTER_RAW_SIZE,
- MAX_REGISTER_VIRTUAL_SIZE, MAX_REGISTER_RAW_SIZE,
- REGISTER_VIRTUAL_SIZE and REGISTER_RAW_SIZE are all being replaced
- by REGISTER_TYPE. */
+/* The methods DEPRECATED_MAX_REGISTER_RAW_SIZE, MAX_REGISTER_RAW_SIZE,
+ DEPRECATED_MAX_REGISTER_VIRTUAL_SIZE, and MAX_REGISTER_VIRTUAL_SIZE
+ are all being replaced by MAX_REGISTER_SIZE (a constant). */
#if defined (DEPRECATED_MAX_REGISTER_RAW_SIZE)
/* Legacy for systems yet to multi-arch DEPRECATED_MAX_REGISTER_RAW_SIZE */
@@ -845,10 +842,8 @@
#endif
#endif
-/* The methods REGISTER_VIRTUAL_TYPE, MAX_REGISTER_RAW_SIZE,
- MAX_REGISTER_VIRTUAL_SIZE, MAX_REGISTER_RAW_SIZE,
- REGISTER_VIRTUAL_SIZE and REGISTER_RAW_SIZE are all being replaced
- by REGISTER_TYPE. */
+/* The methods REGISTER_VIRTUAL_TYPE, REGISTER_VIRTUAL_SIZE and
+ REGISTER_RAW_SIZE are all being replaced by REGISTER_TYPE. */
/* Default (function) for non- multi-arch platforms. */
#if (!GDB_MULTI_ARCH) && !defined (REGISTER_VIRTUAL_SIZE)
@@ -867,10 +862,9 @@
#endif
#endif
-/* The methods REGISTER_VIRTUAL_TYPE, MAX_REGISTER_RAW_SIZE,
- MAX_REGISTER_VIRTUAL_SIZE, MAX_REGISTER_RAW_SIZE,
- REGISTER_VIRTUAL_SIZE and REGISTER_RAW_SIZE are all being replaced
- by REGISTER_TYPE. */
+/* The methods DEPRECATED_MAX_REGISTER_RAW_SIZE, MAX_REGISTER_RAW_SIZE,
+ DEPRECATED_MAX_REGISTER_VIRTUAL_SIZE, and MAX_REGISTER_VIRTUAL_SIZE
+ are all being replaced by MAX_REGISTER_SIZE (a constant). */
#if defined (DEPRECATED_MAX_REGISTER_VIRTUAL_SIZE)
/* Legacy for systems yet to multi-arch DEPRECATED_MAX_REGISTER_VIRTUAL_SIZE */
@@ -908,10 +902,8 @@
#endif
#endif
-/* The methods REGISTER_VIRTUAL_TYPE, MAX_REGISTER_RAW_SIZE,
- MAX_REGISTER_VIRTUAL_SIZE, MAX_REGISTER_RAW_SIZE,
- REGISTER_VIRTUAL_SIZE and REGISTER_RAW_SIZE have all being replaced
- by REGISTER_TYPE. */
+/* The methods REGISTER_VIRTUAL_TYPE, REGISTER_VIRTUAL_SIZE and
+ REGISTER_RAW_SIZE are all being replaced by REGISTER_TYPE. */
#if defined (REGISTER_VIRTUAL_TYPE)
/* Legacy for systems yet to multi-arch REGISTER_VIRTUAL_TYPE */
Index: gdbarch.sh
===================================================================
RCS file: /cvs/src/src/gdb/gdbarch.sh,v
retrieving revision 1.233
diff -u -r1.233 gdbarch.sh
--- gdbarch.sh 7 May 2003 19:21:12 -0000 1.233
+++ gdbarch.sh 8 May 2003 17:56:34 -0000
@@ -480,30 +480,22 @@
# migration process - old code, calling REGISTER_BYTE, doesn't need to
# be modified.
F::REGISTER_BYTE:int:register_byte:int reg_nr:reg_nr::generic_register_byte:generic_register_byte
-# The methods REGISTER_VIRTUAL_TYPE, MAX_REGISTER_RAW_SIZE,
-# MAX_REGISTER_VIRTUAL_SIZE, MAX_REGISTER_RAW_SIZE,
-# REGISTER_VIRTUAL_SIZE and REGISTER_RAW_SIZE are all being replaced
-# by REGISTER_TYPE.
+# The methods REGISTER_VIRTUAL_TYPE, REGISTER_VIRTUAL_SIZE and
+# REGISTER_RAW_SIZE are all being replaced by REGISTER_TYPE.
f:2:REGISTER_RAW_SIZE:int:register_raw_size:int reg_nr:reg_nr::generic_register_size:generic_register_size::0
-# The methods REGISTER_VIRTUAL_TYPE, MAX_REGISTER_RAW_SIZE,
-# MAX_REGISTER_VIRTUAL_SIZE, MAX_REGISTER_RAW_SIZE,
-# REGISTER_VIRTUAL_SIZE and REGISTER_RAW_SIZE are all being replaced
-# by REGISTER_TYPE.
+# The methods DEPRECATED_MAX_REGISTER_RAW_SIZE, MAX_REGISTER_RAW_SIZE,
+# DEPRECATED_MAX_REGISTER_VIRTUAL_SIZE, and MAX_REGISTER_VIRTUAL_SIZE
+# are all being replaced by MAX_REGISTER_SIZE (a constant).
V:2:DEPRECATED_MAX_REGISTER_RAW_SIZE:int:deprecated_max_register_raw_size
-# The methods REGISTER_VIRTUAL_TYPE, MAX_REGISTER_RAW_SIZE,
-# MAX_REGISTER_VIRTUAL_SIZE, MAX_REGISTER_RAW_SIZE,
-# REGISTER_VIRTUAL_SIZE and REGISTER_RAW_SIZE are all being replaced
-# by REGISTER_TYPE.
+# The methods REGISTER_VIRTUAL_TYPE, REGISTER_VIRTUAL_SIZE and
+# REGISTER_RAW_SIZE are all being replaced by REGISTER_TYPE.
f:2:REGISTER_VIRTUAL_SIZE:int:register_virtual_size:int reg_nr:reg_nr::generic_register_size:generic_register_size::0
-# The methods REGISTER_VIRTUAL_TYPE, MAX_REGISTER_RAW_SIZE,
-# MAX_REGISTER_VIRTUAL_SIZE, MAX_REGISTER_RAW_SIZE,
-# REGISTER_VIRTUAL_SIZE and REGISTER_RAW_SIZE are all being replaced
-# by REGISTER_TYPE.
+# The methods DEPRECATED_MAX_REGISTER_RAW_SIZE, MAX_REGISTER_RAW_SIZE,
+# DEPRECATED_MAX_REGISTER_VIRTUAL_SIZE, and MAX_REGISTER_VIRTUAL_SIZE
+# are all being replaced by MAX_REGISTER_SIZE (a constant).
V:2:DEPRECATED_MAX_REGISTER_VIRTUAL_SIZE:int:deprecated_max_register_virtual_size
-# The methods REGISTER_VIRTUAL_TYPE, MAX_REGISTER_RAW_SIZE,
-# MAX_REGISTER_VIRTUAL_SIZE, MAX_REGISTER_RAW_SIZE,
-# REGISTER_VIRTUAL_SIZE and REGISTER_RAW_SIZE have all being replaced
-# by REGISTER_TYPE.
+# The methods REGISTER_VIRTUAL_TYPE, REGISTER_VIRTUAL_SIZE and
+# REGISTER_RAW_SIZE are all being replaced by REGISTER_TYPE.
F:2:REGISTER_VIRTUAL_TYPE:struct type *:register_virtual_type:int reg_nr:reg_nr::0:0
M:2:REGISTER_TYPE:struct type *:register_type:int reg_nr:reg_nr::0:
#
Index: infcmd.c
===================================================================
RCS file: /cvs/src/src/gdb/infcmd.c,v
retrieving revision 1.79
diff -u -r1.79 infcmd.c
--- infcmd.c 21 Apr 2003 16:48:39 -0000 1.79
+++ infcmd.c 8 May 2003 17:56:35 -0000
@@ -1500,8 +1500,8 @@
{
int i;
const int numregs = NUM_REGS + NUM_PSEUDO_REGS;
- char *raw_buffer = alloca (MAX_REGISTER_RAW_SIZE);
- char *virtual_buffer = alloca (MAX_REGISTER_VIRTUAL_SIZE);
+ char raw_buffer[MAX_REGISTER_SIZE];
+ char virtual_buffer[MAX_REGISTER_SIZE];
if (DEPRECATED_DO_REGISTERS_INFO_P ())
{
Index: regcache.c
===================================================================
RCS file: /cvs/src/src/gdb/regcache.c,v
retrieving revision 1.76
diff -u -r1.76 regcache.c
--- regcache.c 4 May 2003 17:34:50 -0000 1.76
+++ regcache.c 8 May 2003 17:56:35 -0000
@@ -306,15 +306,6 @@
}
int
-legacy_max_register_virtual_size (void)
-{
- if (DEPRECATED_MAX_REGISTER_VIRTUAL_SIZE_P ())
- return DEPRECATED_MAX_REGISTER_VIRTUAL_SIZE;
- else
- return max_register_size (current_gdbarch);
-}
-
-int
register_size (struct gdbarch *gdbarch, int regnum)
{
struct regcache_descr *descr = regcache_descr (gdbarch);
Index: sparc-tdep.c
===================================================================
RCS file: /cvs/src/src/gdb/sparc-tdep.c,v
retrieving revision 1.96
diff -u -r1.96 sparc-tdep.c
--- sparc-tdep.c 5 May 2003 17:56:56 -0000 1.96
+++ sparc-tdep.c 8 May 2003 17:56:36 -0000
@@ -2070,8 +2070,8 @@
{
int i;
const int numregs = NUM_REGS + NUM_PSEUDO_REGS;
- char *raw_buffer = alloca (MAX_REGISTER_RAW_SIZE);
- char *virtual_buffer = alloca (MAX_REGISTER_VIRTUAL_SIZE);
+ char raw_buffer[MAX_REGISTER_SIZE];
+ char virtual_buffer[MAX_REGISTER_SIZE];
for (i = 0; i < numregs; i++)
{
Index: tracepoint.c
===================================================================
RCS file: /cvs/src/src/gdb/tracepoint.c,v
retrieving revision 1.49
diff -u -r1.49 tracepoint.c
--- tracepoint.c 25 Feb 2003 21:36:20 -0000 1.49
+++ tracepoint.c 8 May 2003 17:56:37 -0000
@@ -1115,7 +1115,7 @@
{
if (memranges->list[a].type == memranges->list[b].type &&
memranges->list[b].start - memranges->list[a].end <=
- MAX_REGISTER_VIRTUAL_SIZE)
+ MAX_REGISTER_SIZE)
{
/* memrange b starts before memrange a ends; merge them. */
if (memranges->list[b].end > memranges->list[a].end)
Index: mi/ChangeLog
===================================================================
RCS file: /cvs/src/src/gdb/mi/ChangeLog,v
retrieving revision 1.102
diff -u -r1.102 ChangeLog
--- mi/ChangeLog 5 May 2003 17:56:57 -0000 1.102
+++ mi/ChangeLog 8 May 2003 17:56:37 -0000
@@ -1,3 +1,7 @@
+2003-05-08 Andrew Cagney <cagney@redhat.com>
+
+ * mi-main.c (get_register): Use MAX_REGISTER_SIZE.
+
2003-05-05 Andrew Cagney <cagney@redhat.com>
* mi-main.c (mi_cmd_data_write_register_values): Replace
Index: mi/mi-main.c
===================================================================
RCS file: /cvs/src/src/gdb/mi/mi-main.c,v
retrieving revision 1.43
diff -u -r1.43 mi-main.c
--- mi/mi-main.c 5 May 2003 17:56:57 -0000 1.43
+++ mi/mi-main.c 8 May 2003 17:56:38 -0000
@@ -511,8 +511,8 @@
static int
get_register (int regnum, int format)
{
- char *raw_buffer = alloca (MAX_REGISTER_RAW_SIZE);
- char *virtual_buffer = alloca (MAX_REGISTER_VIRTUAL_SIZE);
+ char raw_buffer[MAX_REGISTER_SIZE];
+ char virtual_buffer[MAX_REGISTER_SIZE];
int optim;
int realnum;
CORE_ADDR addr;