From patchwork Thu Jul 23 02:14:30 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Doug Evans X-Patchwork-Id: 7802 Received: (qmail 98911 invoked by alias); 23 Jul 2015 02:15:26 -0000 Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org Delivered-To: mailing list gdb-patches@sourceware.org Received: (qmail 98895 invoked by uid 89); 23 Jul 2015 02:15:23 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-1.1 required=5.0 tests=AWL, BAYES_00, FREEMAIL_ENVFROM_END_DIGIT, FREEMAIL_FROM, KAM_STOCKGEN, RCVD_IN_DNSWL_LOW, SPF_PASS autolearn=no version=3.3.2 X-HELO: mail-pa0-f43.google.com Received: from mail-pa0-f43.google.com (HELO mail-pa0-f43.google.com) (209.85.220.43) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES128-GCM-SHA256 encrypted) ESMTPS; Thu, 23 Jul 2015 02:15:21 +0000 Received: by padck2 with SMTP id ck2so147674279pad.0 for ; Wed, 22 Jul 2015 19:15:20 -0700 (PDT) X-Received: by 10.66.145.195 with SMTP id sw3mr12913503pab.72.1437617720120; Wed, 22 Jul 2015 19:15:20 -0700 (PDT) Received: from seba.sebabeach.org.gmail.com (173-13-178-53-sfba.hfc.comcastbusiness.net. [173.13.178.53]) by smtp.gmail.com with ESMTPSA id r9sm1323863pdp.5.2015.07.22.19.15.19 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 22 Jul 2015 19:15:19 -0700 (PDT) From: Doug Evans To: gdb-patches@sourceware.org Subject: [PATCH] Remove some hardcoded bitfield sizes Date: Wed, 22 Jul 2015 19:14:30 -0700 Message-ID: MIME-Version: 1.0 X-IsSubscribed: yes Hi. This patch adds some macros to remove some hardcoded bitfield sizes. It also shrinks a few bit fields, freeing up some space for potential improvements. Regression tested on amd64-linux. 2015-07-22 Doug Evans * defs.h (LANGUAGE_BITS): Define. * psympriv.h (partial_symbol) : Use SYMBOL_DOMAIN_BITS. (partial_symbol) : Use SYMBOL_ACLASS_BITS. * symtab.h (general_symbol_info> : Usage LANGUAGE_BITS. (minimal_symbol_type): Add nr_minsym_types. (MINSYM_TYPE_BITS): Define. (minimal_symbol) : Use MINSYM_TYPE_BITS. (domain_enum_tag): Add NR_DOMAINS. (SYMBOL_DOMAIN_BITS): Change from 4 to 3. (SYMBOL_ACLASS_BITS): Define from 6 to 5. diff --git a/gdb/defs.h b/gdb/defs.h index a555da1..f4951ab 100644 --- a/gdb/defs.h +++ b/gdb/defs.h @@ -186,6 +186,11 @@ enum language nr_languages }; +/* The number of bits needed to represent all languages, with enough + padding to allow for reasonable growth. */ +#define LANGUAGE_BITS 5 +gdb_static_assert (nr_languages <= (1 << LANGUAGE_BITS)); + enum precision_type { single_precision, diff --git a/gdb/psympriv.h b/gdb/psympriv.h index ea2454c..d576663 100644 --- a/gdb/psympriv.h +++ b/gdb/psympriv.h @@ -43,14 +43,13 @@ struct partial_symbol /* Name space code. */ - ENUM_BITFIELD(domain_enum_tag) domain : 6; + ENUM_BITFIELD(domain_enum_tag) domain : SYMBOL_DOMAIN_BITS; /* Address class (for info_symbols). Note that we don't allow synthetic "aclass" values here at present, simply because there's no need. */ - ENUM_BITFIELD(address_class) aclass : 6; - + ENUM_BITFIELD(address_class) aclass : SYMBOL_ACLASS_BITS; }; #define PSYMBOL_DOMAIN(psymbol) (psymbol)->domain diff --git a/gdb/symtab.h b/gdb/symtab.h index 6a0b8da..fd8756f 100644 --- a/gdb/symtab.h +++ b/gdb/symtab.h @@ -147,7 +147,7 @@ struct general_symbol_info This is used to select one of the fields from the language specific union above. */ - ENUM_BITFIELD(language) language : 8; + ENUM_BITFIELD(language) language : LANGUAGE_BITS; /* This is only used by Ada. If set, then the 'mangled_lang' field of language_specific is valid. Otherwise, the 'obstack' field is @@ -307,9 +307,15 @@ enum minimal_symbol_type within a given .o file. */ mst_file_text, /* Static version of mst_text */ mst_file_data, /* Static version of mst_data */ - mst_file_bss /* Static version of mst_bss */ + mst_file_bss, /* Static version of mst_bss */ + nr_minsym_types }; +/* The number of enum minimal_symbol_type values, with some padding for + reasonable growth. */ +#define MINSYM_TYPE_BITS 4 +gdb_static_assert (nr_minsym_types <= (1 << MINSYM_TYPE_BITS)); + /* Define a simple structure used to hold some very basic information about all defined global symbols (text, data, bss, abs, etc). The only required information is the general_symbol_info. @@ -343,7 +349,7 @@ struct minimal_symbol /* Classification type for this minimal symbol. */ - ENUM_BITFIELD(minimal_symbol_type) type : 8; + ENUM_BITFIELD(minimal_symbol_type) type : MINSYM_TYPE_BITS; /* Non-zero if this symbol was created by gdb. Such symbols do not appear in the output of "info var|fun". */ @@ -458,12 +464,16 @@ typedef enum domain_enum_tag /* Fortran common blocks. Their naming must be separate from VAR_DOMAIN. They also always use LOC_COMMON_BLOCK. */ - COMMON_BLOCK_DOMAIN + COMMON_BLOCK_DOMAIN, + + /* This must remain last. */ + NR_DOMAINS } domain_enum; /* The number of bits in a symbol used to represent the domain. */ -#define SYMBOL_DOMAIN_BITS 4 +#define SYMBOL_DOMAIN_BITS 3 +gdb_static_assert (NR_DOMAINS <= (1 << SYMBOL_DOMAIN_BITS)); extern const char *domain_name (domain_enum); @@ -593,6 +603,15 @@ enum address_class LOC_FINAL_VALUE }; +/* The number of bits needed for values in enum address_class, with some + padding for reasonable growth, and room for run-time registered address + classes. See symtab.c:MAX_SYMBOL_IMPLS. + This is a #define so that we can have a assertion elsewhere to + verify that we have reserved enough space for synthetic address + classes. */ +#define SYMBOL_ACLASS_BITS 5 +gdb_static_assert (LOC_FINAL_VALUE <= (1 << SYMBOL_ACLASS_BITS)); + /* The methods needed to implement LOC_COMPUTED. These methods can use the symbol's .aux_value for additional per-symbol information. @@ -691,13 +710,6 @@ struct symbol_impl const struct symbol_register_ops *ops_register; }; -/* The number of bits we reserve in a symbol for the aclass index. - This is a #define so that we can have a assertion elsewhere to - verify that we have reserved enough space for synthetic address - classes. */ - -#define SYMBOL_ACLASS_BITS 6 - /* This structure is space critical. See space comments at the top. */ struct symbol