From patchwork Mon Oct 31 02:48:34 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tom Tromey X-Patchwork-Id: 17028 Received: (qmail 66536 invoked by alias); 31 Oct 2016 02:48:57 -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 66343 invoked by uid 89); 31 Oct 2016 02:48:51 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-1.2 required=5.0 tests=AWL, BAYES_00, KAM_STOCKGEN, RCVD_IN_DNSWL_NONE, RCVD_IN_SORBS_SPAM, SPF_PASS autolearn=no version=3.3.2 spammy=H*r:4.86_1, H*F:U*tom, Meanwhile, eval X-HELO: gproxy7-pub.mail.unifiedlayer.com Received: from gproxy7-pub.mail.unifiedlayer.com (HELO gproxy7-pub.mail.unifiedlayer.com) (70.40.196.235) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with SMTP; Mon, 31 Oct 2016 02:48:41 +0000 Received: (qmail 24223 invoked by uid 0); 31 Oct 2016 02:48:39 -0000 Received: from unknown (HELO cmgw4) (10.0.90.85) by gproxy7.mail.unifiedlayer.com with SMTP; 31 Oct 2016 02:48:39 -0000 Received: from box522.bluehost.com ([74.220.219.122]) by cmgw4 with id 22ob1u00j2f2jeq012oed3; Sun, 30 Oct 2016 20:48:39 -0600 X-Authority-Analysis: v=2.1 cv=IecUBwaa c=1 sm=1 tr=0 a=GsOEXm/OWkKvwdLVJsfwcA==:117 a=GsOEXm/OWkKvwdLVJsfwcA==:17 a=L9H7d07YOLsA:10 a=9cW_t1CCXrUA:10 a=s5jvgZ67dGcA:10 a=CH0kA5CcgfcA:10 a=20KFwNOVAAAA:8 a=CCpqsmhAAAAA:8 a=zstS-IiYAAAA:8 a=Vbkv8xu94ip9bdYg_SIA:9 a=-dn1fYWSw5-Q7noR:21 a=Lg4x6cfbqKEMudsy:21 a=fWb5yoan69AA:10 a=e_O65bzb51kRm2y5VmPK:22 a=ul9cdbp4aOFLsgKbc677:22 a=4G6NA9xxw8l3yy4pmD5M:22 Received: from 174-16-143-211.hlrn.qwest.net ([174.16.143.211]:60832 helo=bapiya) by box522.bluehost.com with esmtpsa (TLSv1.2:ECDHE-RSA-AES256-GCM-SHA384:256) (Exim 4.86_1) (envelope-from ) id 1c12eJ-0006vK-Io; Sun, 30 Oct 2016 20:48:35 -0600 From: Tom Tromey To: Pedro Alves Cc: Tom Tromey , gdb-patches@sourceware.org Subject: Re: [RFA v2 16/17] Convert dwarf_expr_context_funcs to methods References: <1476393012-29987-1-git-send-email-tom@tromey.com> <1476393012-29987-17-git-send-email-tom@tromey.com> <94f5892b-e4d2-f903-36e2-513e37f3947b@redhat.com> <878ttmid6e.fsf@tromey.com> <87a8dyhetz.fsf@tromey.com> Date: Sun, 30 Oct 2016 20:48:34 -0600 In-Reply-To: (Pedro Alves's message of "Fri, 28 Oct 2016 14:35:54 +0100") Message-ID: <878tt5w7wd.fsf@tromey.com> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/25.1.50 (gnu/linux) MIME-Version: 1.0 X-BWhitelist: no X-Exim-ID: 1c12eJ-0006vK-Io X-Source-Sender: 174-16-143-211.hlrn.qwest.net (bapiya) [174.16.143.211]:60832 X-Source-Auth: tom+tromey.com X-Email-Count: 2 X-Source-Cap: ZWx5bnJvYmk7ZWx5bnJvYmk7Ym94NTIyLmJsdWVob3N0LmNvbQ== >>>>> "Pedro" == Pedro Alves writes: Pedro> Unfortunately, this caused regressions: Pedro> https://sourceware.org/ml/gdb-testers/2016-q4/msg01382.html Sorry about this. Something must be wrong with regression testing here, because I see these failures when I run the tests individually, but I never saw them when comparing against the baseline. I'll set up to use the try builder tomorrow and then rely on that instead. Meanwhile here's the patch I'll be testing. Tom commit 0b88198c29a9773741b8450f79e4fe1ee535efac Author: Tom Tromey Date: Sun Oct 30 20:45:08 2016 -0600 Fix dwarf_expr_context method regressions This fixes some regressions found in the patch to convert dwarf_expr_context to use methods. Specifically: * get_base_type could erroneously throw; this was rewritten to move the size checks into the only spot needing them. * Previously the "symbol needs frame" implementation reused th "cfa" function for the get_frame_pc slot; this reimplements it under the correct name. * Not enough members were saved and restored in one implementation of push_dwarf_reg_entry_value; this patch fixes this oversight and also takes the opportunity to remove an extraneous structure definition. 2016-10-30 Tom Tromey * dwarf2loc.c (dwarf_evaluate_loc_desc::get_base_type): Rename from impl_get_base_type. Rewrite. (struct dwarf_expr_baton): Remove. (dwarf_evaluate_loc_desc::push_dwarf_reg_entry_value): Save and restore more fields. (symbol_needs_eval_context::get_frame_pc): New method. * dwarf2expr.h (dwarf_expr_context::get_base_type): Now public, virtual. (dwarf_expr_context::impl_get_base_type): Remove. * dwarf2expr.c (dwarf_expr_context::get_base_type): Remove. diff --git a/gdb/ChangeLog b/gdb/ChangeLog index c38c65c..ac5b0ce 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,3 +1,16 @@ +2016-10-30 Tom Tromey + + * dwarf2loc.c (dwarf_evaluate_loc_desc::get_base_type): Rename + from impl_get_base_type. Rewrite. + (struct dwarf_expr_baton): Remove. + (dwarf_evaluate_loc_desc::push_dwarf_reg_entry_value): Save and + restore more fields. + (symbol_needs_eval_context::get_frame_pc): New method. + * dwarf2expr.h (dwarf_expr_context::get_base_type): Now public, + virtual. + (dwarf_expr_context::impl_get_base_type): Remove. + * dwarf2expr.c (dwarf_expr_context::get_base_type): Remove. + 2016-10-29 Pedro Alves * NEWS: Clarify C++ requirement. diff --git a/gdb/dwarf2expr.c b/gdb/dwarf2expr.c index a01d6d8..398ca0e 100644 --- a/gdb/dwarf2expr.c +++ b/gdb/dwarf2expr.c @@ -406,22 +406,6 @@ base_types_equal_p (struct type *t1, struct type *t2) return TYPE_LENGTH (t1) == TYPE_LENGTH (t2); } -/* A convenience function to call get_base_type and return the result. - DIE is the DIE whose type we need. SIZE is non-zero if this - function should verify that the resulting type has the correct - size. */ - -struct type * -dwarf_expr_context::get_base_type (cu_offset die, int size) -{ - struct type *result = this->impl_get_base_type (die); - if (result == NULL) - error (_("Could not find type for DW_OP_GNU_const_type")); - if (size != 0 && TYPE_LENGTH (result) != size) - error (_("DW_OP_GNU_const_type has different sizes for type and data")); - return result; -} - /* If gdbarch)->builtin_int; @@ -210,7 +209,6 @@ private: void push (struct value *value, int in_stack_memory); int stack_empty_p () const; void add_piece (ULONGEST size, ULONGEST offset); - struct type *get_base_type (cu_offset die, int size); void execute_stack_op (const gdb_byte *op_ptr, const gdb_byte *op_end); void pop (); }; diff --git a/gdb/dwarf2loc.c b/gdb/dwarf2loc.c index 6f25314..93aec1f 100644 --- a/gdb/dwarf2loc.c +++ b/gdb/dwarf2loc.c @@ -515,10 +515,14 @@ class dwarf_evaluate_loc_desc : public dwarf_expr_context per_cu_dwarf_call (this, die_offset, per_cu); } - /* Callback function for dwarf2_evaluate_loc_desc. */ - struct type *impl_get_base_type (cu_offset die_offset) OVERRIDE + struct type *get_base_type (cu_offset die_offset, int size) OVERRIDE { - return dwarf2_get_die_type (die_offset, per_cu); + struct type *result = dwarf2_get_die_type (die_offset, per_cu); + if (result == NULL) + error (_("Could not find type for DW_OP_GNU_const_type")); + if (size != 0 && TYPE_LENGTH (result) != size) + error (_("DW_OP_GNU_const_type has different sizes for type and data")); + return result; } /* Callback function for dwarf2_evaluate_loc_desc. @@ -553,7 +557,6 @@ class dwarf_evaluate_loc_desc : public dwarf_expr_context { struct frame_info *caller_frame; struct dwarf2_per_cu_data *caller_per_cu; - struct dwarf_expr_baton baton_local; struct call_site_parameter *parameter; const gdb_byte *data_src; size_t size; @@ -570,17 +573,20 @@ class dwarf_evaluate_loc_desc : public dwarf_expr_context throw_error (NO_ENTRY_VALUE_ERROR, _("Cannot resolve DW_AT_GNU_call_site_data_value")); - baton_local.frame = caller_frame; - baton_local.per_cu = caller_per_cu; - baton_local.obj_address = 0; + scoped_restore save_frame = make_scoped_restore (&this->frame, + caller_frame); + scoped_restore save_per_cu = make_scoped_restore (&this->per_cu, + caller_per_cu); + scoped_restore save_obj_addr = make_scoped_restore (&this->obj_address, + (CORE_ADDR) 0); scoped_restore save_arch = make_scoped_restore (&this->gdbarch); this->gdbarch - = get_objfile_arch (dwarf2_per_cu_objfile (baton_local.per_cu)); + = get_objfile_arch (dwarf2_per_cu_objfile (per_cu)); scoped_restore save_addr_size = make_scoped_restore (&this->addr_size); - this->addr_size = dwarf2_per_cu_addr_size (baton_local.per_cu); + this->addr_size = dwarf2_per_cu_addr_size (per_cu); scoped_restore save_offset = make_scoped_restore (&this->offset); - this->offset = dwarf2_per_cu_text_offset (baton_local.per_cu); + this->offset = dwarf2_per_cu_text_offset (per_cu); this->eval (data_src, size); } @@ -2707,6 +2713,12 @@ class symbol_needs_eval_context : public dwarf_expr_context return 1; } + CORE_ADDR get_frame_pc () OVERRIDE + { + needs = SYMBOL_NEEDS_FRAME; + return 1; + } + /* Thread-local accesses require registers, but not a frame. */ CORE_ADDR get_tls_address (CORE_ADDR offset) OVERRIDE {