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]

[rfa/symtab] array bounds, int -> enum


This patch changes the "array bound type" from an int to an explicit
enum.  This is a little bit safer in case someone adds more array bound
types.  They are stored in a small bitfield, and gcc will warn if an
enum bitfield is not wide enough to contain all the values in an enum.

It's also more accurate to use an 'enum' for this.  And it means
that you can see names instead of little numbers while debugging.

The original #define names are not documented, so I did not document the
new enum values.  Also, four of the six names are never set (all the
BOUND_BY_* names), but I did not touch that.  I want to limit how much I
get stuck to this tar baby!

I removed the FIXME because it is a bad idea.  Code in valops.c and
varobj.c, among other places, check the bound type (although they do it
trivially).  I don't see any language specifier in main_type; the
language is over in the symbol code, not in the type code.  So it would
be difficult, and probably useless, to make all code that looks at array
bound types check whether the type is a "FORTRAN type" or not before
looking at the array bounds.  Just use appropriate bound types for all
array symbols in all languages and be done with it.

Testing: the usual drill, native i686-pc-linux-gnu, gcc v2 and v3,
dwarf-2 and stabs+.

Okay to apply?

Michael C

2003-08-21  Michael Chastain  <mec@shout.net>

	* gdbtypes.h: Change array bound type from an int to enum.

Index: gdbtypes.h
===================================================================
RCS file: /cvs/src/src/gdb/gdbtypes.h,v
retrieving revision 1.49
diff -c -3 -p -r1.49 gdbtypes.h
*** gdbtypes.h	20 Aug 2003 23:00:06 -0000	1.49
--- gdbtypes.h	21 Aug 2003 20:12:11 -0000
*************** enum type_code
*** 272,277 ****
--- 272,288 ----
  #define TYPE_ADDRESS_CLASS_ALL(t) (TYPE_INSTANCE_FLAGS(t) \
  				   & TYPE_FLAG_ADDRESS_CLASS_ALL)
  
+ /*  Array bound type.  */
+ enum array_bound_type
+ {
+   BOUND_SIMPLE = 0,
+   BOUND_BY_VALUE_IN_REG,
+   BOUND_BY_REF_IN_REG,
+   BOUND_BY_VALUE_ON_STACK,
+   BOUND_BY_REF_ON_STACK,
+   BOUND_CANNOT_BE_DETERMINED
+ };
+ 
  /* This structure is space-critical.
     Its layout has been tweaked to reduce the space used.  */
  
*************** struct main_type
*** 281,297 ****
  
    ENUM_BITFIELD(type_code) code : 8;
  
!   /* These fields appear at this location because they pack nicely here.  */
!   /* FIXME, these should probably be restricted to a Fortran-specific
!      field in some fashion.  */
! #define BOUND_CANNOT_BE_DETERMINED   5
! #define BOUND_BY_REF_ON_STACK        4
! #define BOUND_BY_VALUE_ON_STACK      3
! #define BOUND_BY_REF_IN_REG          2
! #define BOUND_BY_VALUE_IN_REG        1
! #define BOUND_SIMPLE                 0
!   int upper_bound_type : 4;
!   int lower_bound_type : 4;
  
    /* Name of this type, or NULL if none.
  
--- 292,302 ----
  
    ENUM_BITFIELD(type_code) code : 8;
  
!   /* Array bounds.  These fields appear at this location because
!      they pack nicely here.  */
! 
!   ENUM_BITFIELD(array_bound_type) upper_bound_type : 4;
!   ENUM_BITFIELD(array_bound_type) lower_bound_type : 4;
  
    /* Name of this type, or NULL if none.
  


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