From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 17061 invoked by alias); 3 Feb 2013 09:06:35 -0000 Received: (qmail 17041 invoked by uid 22791); 3 Feb 2013 09:06:34 -0000 X-SWARE-Spam-Status: No, hits=-5.4 required=5.0 tests=AWL,BAYES_00,KAM_STOCKGEN,KHOP_RCVD_UNTRUST,KHOP_SPAMHAUS_DROP,RCVD_IN_DNSWL_HI,RCVD_IN_HOSTKARMA_W,RP_MATCHES_RCVD,SPF_HELO_PASS,TW_BJ X-Spam-Check-By: sourceware.org Received: from mx1.redhat.com (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Sun, 03 Feb 2013 09:06:25 +0000 Received: from int-mx11.intmail.prod.int.phx2.redhat.com (int-mx11.intmail.prod.int.phx2.redhat.com [10.5.11.24]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id r1396Px5020510 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Sun, 3 Feb 2013 04:06:25 -0500 Received: from host2.jankratochvil.net ([10.3.113.16]) by int-mx11.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id r1396JNN020213 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES128-SHA bits=128 verify=NO); Sun, 3 Feb 2013 04:06:22 -0500 Date: Sun, 03 Feb 2013 09:06:00 -0000 From: Jan Kratochvil To: Tom Tromey Cc: gdb-patches@sourceware.org Subject: Re: [2/3] RFC: merge symbol "ops" and "aclass" fields Message-ID: <20130203090618.GC16948@host2.jankratochvil.net> References: <8738y1hzzz.fsf@fleche.redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <8738y1hzzz.fsf@fleche.redhat.com> User-Agent: Mutt/1.5.21 (2010-09-15) X-IsSubscribed: yes Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org X-SW-Source: 2013-02/txt/msg00052.txt.bz2 Hi Tom, that *datum* support I find overengineered, isn't enough the simplification below? Included is also unrelated substitution: +#define SYMBOL_IMPL(symbol) (symbol_impls[(symbol)->aclass_index]) Thanks, Jan diff --git a/gdb/dwarf2loc.c b/gdb/dwarf2loc.c index 0e4e490..6047f09 100644 --- a/gdb/dwarf2loc.c +++ b/gdb/dwarf2loc.c @@ -363,14 +363,14 @@ dwarf_expr_frame_base_1 (struct symbol *framefunc, CORE_ADDR pc, { if (SYMBOL_LOCATION_BATON (framefunc) == NULL) *length = 0; - else if (SYMBOL_READER_DATUM (framefunc) == &dwarf2_loclist_funcs) + else if (SYMBOL_ACLASS_INDEX (framefunc) == dwarf2_loclist_block_index) { struct dwarf2_loclist_baton *symbaton; symbaton = SYMBOL_LOCATION_BATON (framefunc); *start = dwarf2_find_location_expression (symbaton, length, pc); } - else + else if (SYMBOL_ACLASS_INDEX (framefunc) == dwarf2_locexpr_block_index) { struct dwarf2_locexpr_baton *symbaton; @@ -383,6 +383,8 @@ dwarf_expr_frame_base_1 (struct symbol *framefunc, CORE_ADDR pc, else *length = 0; } + else + internal_error (__FILE__, __LINE__, _("invalid function aclass index")); if (*length == 0) error (_("Could not find the frame base for \"%s\"."), diff --git a/gdb/dwarf2loc.h b/gdb/dwarf2loc.h index 36641b3..9060a65 100644 --- a/gdb/dwarf2loc.h +++ b/gdb/dwarf2loc.h @@ -133,6 +133,10 @@ struct dwarf2_loclist_baton extern const struct symbol_computed_ops dwarf2_locexpr_funcs; extern const struct symbol_computed_ops dwarf2_loclist_funcs; +/* Two variables from dwarf2read.c. */ +extern int dwarf2_locexpr_block_index; +extern int dwarf2_loclist_block_index; + /* Compile a DWARF location expression to an agent expression. EXPR is the agent expression we are building. diff --git a/gdb/dwarf2read.c b/gdb/dwarf2read.c index 387060e..a442e58 100644 --- a/gdb/dwarf2read.c +++ b/gdb/dwarf2read.c @@ -95,8 +95,8 @@ static const struct objfile_data *dwarf2_objfile_data_key; static int dwarf2_locexpr_index; static int dwarf2_loclist_index; -static int dwarf2_locexpr_block_index; -static int dwarf2_loclist_block_index; +int dwarf2_locexpr_block_index; +int dwarf2_loclist_block_index; struct dwarf2_section_info { @@ -20704,10 +20704,6 @@ Usage: save gdb-index DIRECTORY"), dwarf2_loclist_index = register_symbol_computed_impl (LOC_COMPUTED, &dwarf2_loclist_funcs); - /* In these two calls, the _funcs vectors aren't actually used; they - are just sentinels for other checks. */ - dwarf2_locexpr_block_index - = register_symbol_datum_impl (LOC_BLOCK, &dwarf2_locexpr_funcs); - dwarf2_loclist_block_index - = register_symbol_datum_impl (LOC_BLOCK, &dwarf2_loclist_funcs); + dwarf2_locexpr_block_index = register_symbol_alias_impl (LOC_BLOCK); + dwarf2_loclist_block_index = register_symbol_alias_impl (LOC_BLOCK); } diff --git a/gdb/symtab.c b/gdb/symtab.c index 56fb52d..ade5576 100644 --- a/gdb/symtab.c +++ b/gdb/symtab.c @@ -5095,20 +5095,17 @@ register_symbol_computed_impl (enum address_class aclass, return result; } -/* Register a "datum" symbol type. ACLASS can be anything. DATUM is - a bit of per-symbol-reader data to store with this index. This - returns the new index, which should be used as the aclass_index - field for symbols of this type. */ +/* Register a symbol type to be recognized by its index. ACLASS can be + anything. This returns the new index, which should be used as the + aclass_index field for symbols of this type. */ int -register_symbol_datum_impl (enum address_class aclass, const void *datum) +register_symbol_alias_impl (enum address_class aclass) { int result = next_aclass_value++; - gdb_assert (aclass >= 0 && aclass < LOC_FINAL_VALUE); gdb_assert (result < MAX_SYMBOL_IMPLS); symbol_impl[result].aclass = aclass; - symbol_impl[result].reader_datum = datum; return result; } diff --git a/gdb/symtab.h b/gdb/symtab.h index f8ab97b..2ded0fc 100644 --- a/gdb/symtab.h +++ b/gdb/symtab.h @@ -605,9 +605,6 @@ struct symbol_impl /* Used with LOC_REGISTER and LOC_REGPARM_ADDR. */ const struct symbol_register_ops *ops_register; - - /* Used to store a per-symbol-reader datum. */ - const void *reader_datum; }; /* The number of bits we reserve in a symbol for the aclass index. @@ -689,8 +686,9 @@ struct symbol extern const struct symbol_impl *symbol_impls; #define SYMBOL_DOMAIN(symbol) (symbol)->domain +#define SYMBOL_IMPL(symbol) (symbol_impls[(symbol)->aclass_index]) #define SYMBOL_ACLASS_INDEX(symbol) (symbol)->aclass_index -#define SYMBOL_CLASS(symbol) ((symbol_impls[(symbol)->aclass_index]).aclass) +#define SYMBOL_CLASS(symbol) (SYMBOL_IMPL (symbol).aclass) #define SYMBOL_IS_ARGUMENT(symbol) (symbol)->is_argument #define SYMBOL_INLINED(symbol) (symbol)->is_inlined #define SYMBOL_IS_CPLUS_TEMPLATE_FUNCTION(symbol) \ @@ -698,18 +696,14 @@ extern const struct symbol_impl *symbol_impls; #define SYMBOL_TYPE(symbol) (symbol)->type #define SYMBOL_LINE(symbol) (symbol)->line #define SYMBOL_SYMTAB(symbol) (symbol)->symtab -#define SYMBOL_COMPUTED_OPS(symbol) \ - ((symbol_impls[(symbol)->aclass_index]).ops_computed) -#define SYMBOL_REGISTER_OPS(symbol) \ - ((symbol_impls[(symbol)->aclass_index]).ops_register) -#define SYMBOL_READER_DATUM(symbol) \ - ((symbol_impls[(symbol)->aclass_index]).reader_datum) +#define SYMBOL_COMPUTED_OPS(symbol) (SYMBOL_IMPL (symbol).ops_computed) +#define SYMBOL_REGISTER_OPS(symbol) (SYMBOL_IMPL (symbol).ops_register) #define SYMBOL_LOCATION_BATON(symbol) (symbol)->aux_value extern int register_symbol_computed_impl (enum address_class, const struct symbol_computed_ops *); -extern int register_symbol_datum_impl (enum address_class, const void *); +extern int register_symbol_alias_impl (enum address_class); extern int register_symbol_register_impl (enum address_class, const struct symbol_register_ops *);