From: Michael Elizabeth Chastain <mec@shout.net>
To: ezannoni@redhat.com, gdb-patches@sources.redhat.com, jimb@redhat.com
Cc: ac131313@redhat.com
Subject: [rfa/symtab] array bounds, int -> enum
Date: Thu, 21 Aug 2003 22:35:00 -0000 [thread overview]
Message-ID: <200308212234.h7LMYuAF000490@duracef.shout.net> (raw)
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.
next reply other threads:[~2003-08-21 22:35 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2003-08-21 22:35 Michael Elizabeth Chastain [this message]
2003-08-22 3:41 ` Jim Blandy
2003-08-22 5:07 Michael Elizabeth Chastain
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=200308212234.h7LMYuAF000490@duracef.shout.net \
--to=mec@shout.net \
--cc=ac131313@redhat.com \
--cc=ezannoni@redhat.com \
--cc=gdb-patches@sources.redhat.com \
--cc=jimb@redhat.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox