From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from rock.gnat.com (rock.gnat.com [205.232.38.15]) by sourceware.org (Postfix) with ESMTP id EA253388702C for ; Wed, 8 Apr 2020 17:54:54 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org EA253388702C Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=adacore.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=tromey@adacore.com Received: from localhost (localhost.localdomain [127.0.0.1]) by filtered-rock.gnat.com (Postfix) with ESMTP id C3C31117F80; Wed, 8 Apr 2020 13:54:54 -0400 (EDT) X-Virus-Scanned: Debian amavisd-new at gnat.com Received: from rock.gnat.com ([127.0.0.1]) by localhost (rock.gnat.com [127.0.0.1]) (amavisd-new, port 10024) with LMTP id phUwILJrlZZB; Wed, 8 Apr 2020 13:54:54 -0400 (EDT) Received: from murgatroyd.Home (174-16-110-145.hlrn.qwest.net [174.16.110.145]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by rock.gnat.com (Postfix) with ESMTPSA id 809CD117CFA; Wed, 8 Apr 2020 13:54:54 -0400 (EDT) From: Tom Tromey To: gdb-patches@sourceware.org Cc: Tom Tromey Subject: [PATCH 03/11] Allow DWARF expression to push the initial address Date: Wed, 8 Apr 2020 11:54:44 -0600 Message-Id: <20200408175452.30637-4-tromey@adacore.com> X-Mailer: git-send-email 2.21.1 In-Reply-To: <20200408175452.30637-1-tromey@adacore.com> References: <20200408175452.30637-1-tromey@adacore.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-22.7 required=5.0 tests=BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, JMQ_SPF_NEUTRAL, KAM_DMARC_STATUS, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on server2.sourceware.org X-BeenThere: gdb-patches@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gdb-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 08 Apr 2020 17:54:56 -0000 Some DWARF expressions must be evaluated by first pushing the object address onto the evaluation stack. This patch adds this ability. This functionality is not used yet, but it will be used in a later patch. This is split out for easier review and also because it improved the patch series ordering. gdb/ChangeLog 2020-04-08 Tom Tromey * dwarf2/loc.c (dwarf2_locexpr_baton_eval): Add "push_initial_value" parameter. (dwarf2_evaluate_property): Likewise. * dwarf2/loc.h (dwarf2_evaluate_property): Update. --- gdb/ChangeLog | 7 +++++++ gdb/dwarf2/loc.c | 15 +++++++++++---- gdb/dwarf2/loc.h | 8 ++++++-- 3 files changed, 24 insertions(+), 6 deletions(-) diff --git a/gdb/dwarf2/loc.c b/gdb/dwarf2/loc.c index 2ec4626b17c..957a2029798 100644 --- a/gdb/dwarf2/loc.c +++ b/gdb/dwarf2/loc.c @@ -2388,13 +2388,16 @@ dwarf2_evaluate_loc_desc (struct type *type, struct frame_info *frame, that the dwarf expression only produces a single CORE_ADDR. FRAME is the frame in which the expression is evaluated. ADDR is a context (location of a variable) and might be needed to evaluate the location expression. - Returns 1 on success, 0 otherwise. */ + PUSH_INITIAL_VALUE is true if ADDR should be pushed on the stack + before evaluating the expression; this is required by certain + forms of DWARF expression. Returns 1 on success, 0 otherwise. */ static int dwarf2_locexpr_baton_eval (const struct dwarf2_locexpr_baton *dlbaton, struct frame_info *frame, CORE_ADDR addr, - CORE_ADDR *valp) + CORE_ADDR *valp, + bool push_initial_value) { struct objfile *objfile; @@ -2414,6 +2417,9 @@ dwarf2_locexpr_baton_eval (const struct dwarf2_locexpr_baton *dlbaton, ctx.ref_addr_size = dlbaton->per_cu->ref_addr_size (); ctx.offset = dlbaton->per_cu->text_offset (); + if (push_initial_value) + ctx.push_address (addr, false); + try { ctx.eval (dlbaton->data, dlbaton->size); @@ -2462,7 +2468,8 @@ bool dwarf2_evaluate_property (const struct dynamic_prop *prop, struct frame_info *frame, const struct property_addr_info *addr_stack, - CORE_ADDR *value) + CORE_ADDR *value, + bool push_initial_value) { if (prop == NULL) return false; @@ -2480,7 +2487,7 @@ dwarf2_evaluate_property (const struct dynamic_prop *prop, if (dwarf2_locexpr_baton_eval (&baton->locexpr, frame, addr_stack ? addr_stack->addr : 0, - value)) + value, push_initial_value)) { if (baton->locexpr.is_reference) { diff --git a/gdb/dwarf2/loc.h b/gdb/dwarf2/loc.h index a59d3f998fd..6ff9b79dc03 100644 --- a/gdb/dwarf2/loc.h +++ b/gdb/dwarf2/loc.h @@ -92,12 +92,16 @@ struct property_addr_info be NULL. Returns true if PROP could be converted and the static value is passed - back into VALUE, otherwise returns false. */ + back into VALUE, otherwise returns false. + + If PUSH_INITIAL_VALUE is true, then the top value of ADDR_STACK + will be pushed before evaluating a location expression. */ bool dwarf2_evaluate_property (const struct dynamic_prop *prop, struct frame_info *frame, const struct property_addr_info *addr_stack, - CORE_ADDR *value); + CORE_ADDR *value, + bool push_initial_value = false); /* A helper for the compiler interface that compiles a single dynamic property to C code. -- 2.21.1