This is the mail archive of the gdb-patches@sources.redhat.com mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[patch/rfc] max_register_size() instead of MAX_REGISTER RAW/VIRTUALSIZE


Hello,

This patch adds a max_register_size() function to regcache.[hc]. The function returns a per-architecture upper bound on the size of a register.

A follow on patch can remove MAX_REGISTER_RAW_SIZE and MAX_REGISTER_VIRTUAL_SIZE. But that is post 5.3 branch.

I'll look to commit in a few days,

enjoy,
Andrew
2002-08-17  Andrew Cagney  <ac131313@redhat.com>

	* regcache.c (max_register_size): New function.
	(init_legacy_regcache_descr): Ensure that max_register_size is
	large enough for REGISTER_VIRTUAL_SIZE.
	* regcache.h (max_register_size): Declare.

Index: regcache.c
===================================================================
RCS file: /cvs/src/src/gdb/regcache.c,v
retrieving revision 1.53
diff -u -r1.53 regcache.c
--- regcache.c	13 Aug 2002 23:06:40 -0000	1.53
+++ regcache.c	18 Aug 2002 02:41:30 -0000
@@ -112,6 +112,8 @@
       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);
     }
 
   /* Come up with the real size of the registers buffer.  */
@@ -237,6 +239,16 @@
   descr->register_offset = NULL;
   descr->sizeof_register = NULL;
   xfree (descr);
+}
+
+/* Utility functions returning useful register attributes stored in
+   the regcache descr.  */
+
+int
+max_register_size (struct gdbarch *gdbarch)
+{
+  struct regcache_descr *descr = regcache_descr (gdbarch);
+  return descr->max_register_size;
 }
 
 /* The register cache for storing raw register values.  */
Index: regcache.h
===================================================================
RCS file: /cvs/src/src/gdb/regcache.h,v
retrieving revision 1.14
diff -u -r1.14 regcache.h
--- regcache.h	13 Aug 2002 14:32:28 -0000	1.14
+++ regcache.h	18 Aug 2002 02:41:30 -0000
@@ -71,6 +71,12 @@
 extern void regcache_collect (int regnum, void *buf);
 
 
+/* Return the size of the largest register.  Used when allocating
+   space for an aribtrary register value.  */
+
+extern int max_register_size (struct gdbarch *gdbarch);
+
+
 /* DEPRECATED: Character array containing an image of the inferior
    programs' registers for the most recently referenced thread. */
 

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]