From patchwork Thu Jul 13 15:32:03 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pedro Alves X-Patchwork-Id: 21601 Received: (qmail 31636 invoked by alias); 13 Jul 2017 15:38:46 -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 31627 invoked by uid 89); 13 Jul 2017 15:38:46 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-26.8 required=5.0 tests=BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, KAM_STOCKGEN, RP_MATCHES_RCVD, SPF_HELO_PASS autolearn=ham version=3.3.2 spammy= X-HELO: mx1.redhat.com Received: from mx1.redhat.com (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Thu, 13 Jul 2017 15:38:45 +0000 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 5FF38120C2 for ; Thu, 13 Jul 2017 15:32:17 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 5FF38120C2 Authentication-Results: ext-mx02.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx02.extmail.prod.ext.phx2.redhat.com; spf=pass smtp.mailfrom=palves@redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com 5FF38120C2 Received: from cascais.lan (ovpn04.gateway.prod.ext.ams2.redhat.com [10.39.146.4]) by smtp.corp.redhat.com (Postfix) with ESMTP id DCE044DA78 for ; Thu, 13 Jul 2017 15:32:16 +0000 (UTC) From: Pedro Alves To: gdb-patches@sourceware.org Subject: [PATCH v2 07/13] evaluate_subexp_standard: Factor out OP_VAR_VALUE handling. Date: Thu, 13 Jul 2017 16:32:03 +0100 Message-Id: <1499959929-29497-8-git-send-email-palves@redhat.com> In-Reply-To: <1499959929-29497-1-git-send-email-palves@redhat.com> References: <1499959929-29497-1-git-send-email-palves@redhat.com> A following patch will want to call the new evaluate_var_value function in another spot. gdb/ChangeLog: yyyy-mm-dd Pedro Alves * eval.c (evaluate_var_value): New function, factored out from ... (evaluate_subexp_standard): ... here. --- gdb/eval.c | 67 +++++++++++++++++++++++++++++++++----------------------------- 1 file changed, 36 insertions(+), 31 deletions(-) diff --git a/gdb/eval.c b/gdb/eval.c index cb41a4a..a97f4a9 100644 --- a/gdb/eval.c +++ b/gdb/eval.c @@ -676,6 +676,39 @@ make_params (int num_types, struct type **param_types) return type; } +/* Helper for evaluating an OP_VAR_VALUE. */ + +static value * +evaluate_var_value (enum noside noside, const block *blk, symbol *var) +{ + /* JYG: We used to just return value_zero of the symbol type if + we're asked to avoid side effects. Otherwise we return + value_of_variable (...). However I'm not sure if + value_of_variable () has any side effect. We need a full value + object returned here for whatis_exp () to call evaluate_type () + and then pass the full value to value_rtti_target_type () if we + are dealing with a pointer or reference to a base class and print + object is on. */ + + struct value *ret = NULL; + + TRY + { + ret = value_of_variable (var, blk); + } + + CATCH (except, RETURN_MASK_ERROR) + { + if (noside != EVAL_AVOID_SIDE_EFFECTS) + throw_exception (except); + + ret = value_zero (SYMBOL_TYPE (var), not_lval); + } + END_CATCH + + return ret; +} + /* Helper for evaluating an OP_VAR_MSYM_VALUE. */ static value * @@ -763,37 +796,9 @@ evaluate_subexp_standard (struct type *expect_type, (*pos) += 3; if (noside == EVAL_SKIP) return eval_skip_value (exp); - - /* JYG: We used to just return value_zero of the symbol type - if we're asked to avoid side effects. Otherwise we return - value_of_variable (...). However I'm not sure if - value_of_variable () has any side effect. - We need a full value object returned here for whatis_exp () - to call evaluate_type () and then pass the full value to - value_rtti_target_type () if we are dealing with a pointer - or reference to a base class and print object is on. */ - - { - struct value *ret = NULL; - - TRY - { - ret = value_of_variable (exp->elts[pc + 2].symbol, - exp->elts[pc + 1].block); - } - - CATCH (except, RETURN_MASK_ERROR) - { - if (noside == EVAL_AVOID_SIDE_EFFECTS) - ret = value_zero (SYMBOL_TYPE (exp->elts[pc + 2].symbol), - not_lval); - else - throw_exception (except); - } - END_CATCH - - return ret; - } + return evaluate_var_value (noside, + exp->elts[pc + 1].block, + exp->elts[pc + 2].symbol); case OP_VAR_MSYM_VALUE: (*pos) += 3; return evaluate_var_msym_value (noside,