From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 29452 invoked by alias); 7 Feb 2013 18:24:26 -0000 Received: (qmail 29409 invoked by uid 22791); 7 Feb 2013 18:24:23 -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,TW_DL 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; Thu, 07 Feb 2013 18:24:12 +0000 Received: from int-mx10.intmail.prod.int.phx2.redhat.com (int-mx10.intmail.prod.int.phx2.redhat.com [10.5.11.23]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id r17IOCKR029894 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Thu, 7 Feb 2013 13:24:12 -0500 Received: from host2.jankratochvil.net (ovpn-116-18.ams2.redhat.com [10.36.116.18]) by int-mx10.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id r17IO6pB009202 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES128-SHA bits=128 verify=NO); Thu, 7 Feb 2013 13:24:09 -0500 Date: Thu, 07 Feb 2013 18:24: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: <20130207182405.GA23912@host2.jankratochvil.net> References: <8738y1hzzz.fsf@fleche.redhat.com> <20130203090618.GC16948@host2.jankratochvil.net> <87obfxxxh9.fsf@fleche.redhat.com> <20130206155235.GA16785@host2.jankratochvil.net> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20130206155235.GA16785@host2.jankratochvil.net> 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/msg00187.txt.bz2 On Wed, 06 Feb 2013 16:52:35 +0100, Jan Kratochvil wrote: > FYI I am just working on a patch to remove that &dwarf2_loclist_funcs > comparison ugliness. BTW here it is. Not sure how clean it is, without the full virtualization it is never too clean. No regressions on {x86_64,x86_64-m32,i686}-fedora19pre-linux-gnu. Thanks, Jan gdb/ 2013-02-07 Jan Kratochvil * dwarf2loc.c (dwarf_expr_frame_base_1): Call find_location_expr method. Drop internal_error, fall back to the error call. (locexpr_find_location_expr): New function. (dwarf2_locexpr_funcs): Install it, new field has_loclist. (loclist_find_location_expr): New function. (dwarf2_loclist_funcs): Install it, new field has_loclist. * dwarf2loc.h (dwarf2_locexpr_block_index, dwarf2_loclist_block_index): Remove the declarations. * dwarf2read.c (dwarf2_locexpr_block_index, dwarf2_loclist_block_index): Make them static. (var_decode_location): Use has_loclist. (_initialize_dwarf2_read): Replace register_symbol_alias_impl by register_symbol_computed_impl. * symtab.c (register_symbol_computed_impl): Update the comment. Allow also LOC_BLOCK. (register_symbol_alias_impl): Remove. * symtab.h (struct symbol_computed_ops): New fields has_loclist and find_location_expr. (struct symbol_impl): Update comment for ops_computed. (register_symbol_alias_impl): Remove. diff --git a/gdb/dwarf2loc.c b/gdb/dwarf2loc.c index 6047f09..f90a9c4 100644 --- a/gdb/dwarf2loc.c +++ b/gdb/dwarf2loc.c @@ -361,30 +361,13 @@ static void dwarf_expr_frame_base_1 (struct symbol *framefunc, CORE_ADDR pc, const gdb_byte **start, size_t *length) { - if (SYMBOL_LOCATION_BATON (framefunc) == NULL) - *length = 0; - 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 if (SYMBOL_ACLASS_INDEX (framefunc) == dwarf2_locexpr_block_index) - { - struct dwarf2_locexpr_baton *symbaton; + const struct symbol_computed_ops *ops_computed; - symbaton = SYMBOL_LOCATION_BATON (framefunc); - if (symbaton != NULL) - { - *length = symbaton->size; - *start = symbaton->data; - } - else - *length = 0; - } + ops_computed = SYMBOL_COMPUTED_OPS (framefunc); + if (ops_computed != NULL) + ops_computed->find_location_expr (framefunc, pc, start, length); else - internal_error (__FILE__, __LINE__, _("invalid function aclass index")); + *length = 0; if (*length == 0) error (_("Could not find the frame base for \"%s\"."), @@ -3971,6 +3954,18 @@ locexpr_tracepoint_var_ref (struct symbol *symbol, struct gdbarch *gdbarch, dlbaton->per_cu); } +/* Implement find_location_expr method for dwarf2_locexpr_baton. */ + +static void +locexpr_find_location_expr (struct symbol *sym, CORE_ADDR pc, + const gdb_byte **start, size_t *length) +{ + struct dwarf2_locexpr_baton *symbaton = SYMBOL_LOCATION_BATON (sym); + + *length = symbaton->size; + *start = symbaton->data; +} + /* The set of location functions used with the DWARF-2 expression evaluator. */ const struct symbol_computed_ops dwarf2_locexpr_funcs = { @@ -3978,6 +3973,8 @@ const struct symbol_computed_ops dwarf2_locexpr_funcs = { locexpr_read_variable_at_entry, locexpr_read_needs_frame, locexpr_describe_location, + 0, /* has_loclist */ + locexpr_find_location_expr, locexpr_tracepoint_var_ref }; @@ -4149,6 +4146,17 @@ loclist_tracepoint_var_ref (struct symbol *symbol, struct gdbarch *gdbarch, dlbaton->per_cu); } +/* Implement find_location_expr method for dwarf2_loclist_baton. */ + +static void +loclist_find_location_expr (struct symbol *sym, CORE_ADDR pc, + const gdb_byte **start, size_t *length) +{ + struct dwarf2_loclist_baton *symbaton = SYMBOL_LOCATION_BATON (sym); + + *start = dwarf2_find_location_expression (symbaton, length, pc); +} + /* The set of location functions used with the DWARF-2 expression evaluator and location lists. */ const struct symbol_computed_ops dwarf2_loclist_funcs = { @@ -4156,6 +4164,8 @@ const struct symbol_computed_ops dwarf2_loclist_funcs = { loclist_read_variable_at_entry, loclist_read_needs_frame, loclist_describe_location, + 1, /* has_loclist */ + loclist_find_location_expr, loclist_tracepoint_var_ref }; diff --git a/gdb/dwarf2loc.h b/gdb/dwarf2loc.h index 9060a65..36641b3 100644 --- a/gdb/dwarf2loc.h +++ b/gdb/dwarf2loc.h @@ -133,10 +133,6 @@ 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 bf068e8..bc0067e 100644 --- a/gdb/dwarf2read.c +++ b/gdb/dwarf2read.c @@ -96,8 +96,8 @@ static const struct objfile_data *dwarf2_objfile_data_key; static int dwarf2_locexpr_index; static int dwarf2_loclist_index; -int dwarf2_locexpr_block_index; -int dwarf2_loclist_block_index; +static int dwarf2_locexpr_block_index; +static int dwarf2_loclist_block_index; struct dwarf2_section_info { @@ -15757,7 +15757,7 @@ var_decode_location (struct attribute *attr, struct symbol *sym, dwarf2_symbol_mark_computed (attr, sym, cu, 0); - if (SYMBOL_COMPUTED_OPS (sym) == &dwarf2_loclist_funcs) + if (SYMBOL_COMPUTED_OPS (sym)->has_loclist) cu->has_loclist = 1; } @@ -20718,6 +20718,9 @@ Usage: save gdb-index DIRECTORY"), dwarf2_loclist_index = register_symbol_computed_impl (LOC_COMPUTED, &dwarf2_loclist_funcs); - dwarf2_locexpr_block_index = register_symbol_alias_impl (LOC_BLOCK); - dwarf2_loclist_block_index = register_symbol_alias_impl (LOC_BLOCK); + dwarf2_locexpr_block_index = register_symbol_computed_impl (LOC_BLOCK, + &dwarf2_locexpr_funcs); + + dwarf2_loclist_block_index = register_symbol_computed_impl (LOC_BLOCK, + &dwarf2_loclist_funcs); } diff --git a/gdb/symtab.c b/gdb/symtab.c index 50096fa..7ed5738 100644 --- a/gdb/symtab.c +++ b/gdb/symtab.c @@ -5063,10 +5063,10 @@ const struct symbol_impl *symbol_impls = &symbol_impl[0]; gdb_static_assert (MAX_SYMBOL_IMPLS <= (1 << SYMBOL_ACLASS_BITS)); -/* Register a computed symbol type. ACLASS must be LOC_COMPUTED. OPS - is the ops vector associated with this index. This returns the new - index, which should be used as the aclass_index field for symbols - of this type. */ +/* Register a computed symbol type. ACLASS must be LOC_COMPUTED or LOC_BLOCK. + OPS is the ops vector associated with this index. This returns the new + index, which should be used as the aclass_index field for symbols of this + type. */ int register_symbol_computed_impl (enum address_class aclass, @@ -5074,7 +5074,7 @@ register_symbol_computed_impl (enum address_class aclass, { int result = next_aclass_value++; - gdb_assert (aclass == LOC_COMPUTED); + gdb_assert (aclass == LOC_COMPUTED || aclass == LOC_BLOCK); gdb_assert (result < MAX_SYMBOL_IMPLS); symbol_impl[result].aclass = aclass; symbol_impl[result].ops_computed = ops; @@ -5082,21 +5082,6 @@ register_symbol_computed_impl (enum address_class aclass, return result; } -/* 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_alias_impl (enum address_class aclass) -{ - int result = next_aclass_value++; - - gdb_assert (result < MAX_SYMBOL_IMPLS); - symbol_impl[result].aclass = aclass; - - return result; -} - /* Register a register symbol type. ACLASS must be LOC_REGISTER or LOC_REGPARM_ADDR. OPS is the register ops vector associated with this index. This returns the new index, which should be used as diff --git a/gdb/symtab.h b/gdb/symtab.h index 293c443..4ec0f08 100644 --- a/gdb/symtab.h +++ b/gdb/symtab.h @@ -575,6 +575,15 @@ struct symbol_computed_ops void (*describe_location) (struct symbol * symbol, CORE_ADDR addr, struct ui_file * stream); + /* Non-zero if this symbol is dependent on PC. */ + unsigned char has_loclist; + + /* Fill in *START and *LENGTH with DWARF block data of symbol SYM valid for + inferior context address PC. Set *LENGTH to zero if such location is not + valid for PC (*START is left uninitialized in such case). */ + void (*find_location_expr) (struct symbol *sym, CORE_ADDR pc, + const gdb_byte **start, size_t *length); + /* Tracepoint support. Append bytecodes to the tracepoint agent expression AX that push the address of the object SYMBOL. Set VALUE appropriately. Note --- for objects in registers, this @@ -600,7 +609,7 @@ struct symbol_impl { enum address_class aclass; - /* Used with LOC_COMPUTED. */ + /* Used with LOC_COMPUTED or LOC_BLOCK (for LOC_BLOCK it may be NULL). */ const struct symbol_computed_ops *ops_computed; /* Used with LOC_REGISTER and LOC_REGPARM_ADDR. */ @@ -703,8 +712,6 @@ extern const struct symbol_impl *symbol_impls; extern int register_symbol_computed_impl (enum address_class, const struct symbol_computed_ops *); -extern int register_symbol_alias_impl (enum address_class); - extern int register_symbol_register_impl (enum address_class, const struct symbol_register_ops *);