From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 25758 invoked by alias); 21 Aug 2003 22:35:07 -0000 Mailing-List: contact gdb-patches-help@sources.redhat.com; run by ezmlm Precedence: bulk List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sources.redhat.com Received: (qmail 25737 invoked from network); 21 Aug 2003 22:35:06 -0000 Received: from unknown (HELO concert.shout.net) (204.253.184.25) by sources.redhat.com with SMTP; 21 Aug 2003 22:35:06 -0000 Received: from duracef.shout.net (duracef.shout.net [204.253.184.12]) by concert.shout.net (8.12.9/8.12.9) with ESMTP id h7LMYuWn019987; Thu, 21 Aug 2003 17:34:57 -0500 Received: from duracef.shout.net (localhost [127.0.0.1]) by duracef.shout.net (8.12.9/8.12.9) with ESMTP id h7LMYuHK000491; Thu, 21 Aug 2003 17:34:56 -0500 Received: (from mec@localhost) by duracef.shout.net (8.12.9/8.12.9/Submit) id h7LMYuAF000490; Thu, 21 Aug 2003 18:34:56 -0400 Date: Thu, 21 Aug 2003 22:35:00 -0000 From: Michael Elizabeth Chastain Message-Id: <200308212234.h7LMYuAF000490@duracef.shout.net> To: ezannoni@redhat.com, gdb-patches@sources.redhat.com, jimb@redhat.com Subject: [rfa/symtab] array bounds, int -> enum Cc: ac131313@redhat.com X-SW-Source: 2003-08/txt/msg00381.txt.bz2 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 * 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.