From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from simark.ca by simark.ca with LMTP id 4D/WCXyY71/2TAAAWB0awg (envelope-from ) for ; Fri, 01 Jan 2021 16:47:40 -0500 Received: by simark.ca (Postfix, from userid 112) id DF35A1F0B7; Fri, 1 Jan 2021 16:47:39 -0500 (EST) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on simark.ca X-Spam-Level: * X-Spam-Status: No, score=1.6 required=5.0 tests=DKIM_SIGNED,MAILING_LIST_MULTI, RCVD_IN_BL_SPAMCOP_NET,RDNS_NONE,T_DKIM_INVALID,URIBL_BLOCKED autolearn=no autolearn_force=no version=3.4.2 Received: from sourceware.org (unknown [8.43.85.97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by simark.ca (Postfix) with ESMTPS id 29BD81E590 for ; Fri, 1 Jan 2021 16:47:36 -0500 (EST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id B7572386EC66; Fri, 1 Jan 2021 21:47:35 +0000 (GMT) Received: from gateway33.websitewelcome.com (gateway33.websitewelcome.com [192.185.146.130]) by sourceware.org (Postfix) with ESMTPS id D3DA9384388B for ; Fri, 1 Jan 2021 21:47:31 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org D3DA9384388B Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=tromey.com Authentication-Results: sourceware.org; spf=fail smtp.mailfrom=tom@tromey.com Received: from cm13.websitewelcome.com (cm13.websitewelcome.com [100.42.49.6]) by gateway33.websitewelcome.com (Postfix) with ESMTP id 7F652A6E326 for ; Fri, 1 Jan 2021 15:47:31 -0600 (CST) Received: from box5379.bluehost.com ([162.241.216.53]) by cmsmtp with SMTP id vSGhkZEQ4oE4DvSGhkuGq0; Fri, 01 Jan 2021 15:47:31 -0600 X-Authority-Reason: nr=8 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=tromey.com; s=default; h=Content-Transfer-Encoding:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:To:From:Sender:Reply-To:Cc:Content-Type:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Id:List-Help:List-Unsubscribe:List-Subscribe: List-Post:List-Owner:List-Archive; bh=vBBjWAiwuDBn2iWVIr+ytO/pnmc1p4mWMknMSR5h5jU=; b=DL0FX/8JLPLxc3a6wymBVyi98Y xJ1sEGAhciDBnRYu87wx8wkJ1zFPq3Ln0BpKqWqga3gxrFtp0CAkvp/cdEl+59gNwAo+St4LorILx l+dcr749tpNIg8P54vdHmnsk3; Received: from 97-122-81-39.hlrn.qwest.net ([97.122.81.39]:60374 helo=localhost.localdomain) by box5379.bluehost.com with esmtpsa (TLS1.2) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.93) (envelope-from ) id 1kvSGh-00292J-9M for gdb-patches@sourceware.org; Fri, 01 Jan 2021 14:47:31 -0700 From: Tom Tromey To: gdb-patches@sourceware.org Subject: [PATCH 012/203] Split out eval_op_structop_ptr Date: Fri, 1 Jan 2021 14:44:12 -0700 Message-Id: <20210101214723.1784144-13-tom@tromey.com> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20210101214723.1784144-1-tom@tromey.com> References: <20210101214723.1784144-1-tom@tromey.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-AntiAbuse: This header was added to track abuse, please include it with any abuse report X-AntiAbuse: Primary Hostname - box5379.bluehost.com X-AntiAbuse: Original Domain - sourceware.org X-AntiAbuse: Originator/Caller UID/GID - [47 12] / [47 12] X-AntiAbuse: Sender Address Domain - tromey.com X-BWhitelist: no X-Source-IP: 97.122.81.39 X-Source-L: No X-Exim-ID: 1kvSGh-00292J-9M X-Source: X-Source-Args: X-Source-Dir: X-Source-Sender: 97-122-81-39.hlrn.qwest.net (localhost.localdomain) [97.122.81.39]:60374 X-Source-Auth: tom+tromey.com X-Email-Count: 13 X-Source-Cap: ZWx5bnJvYmk7ZWx5bnJvYmk7Ym94NTM3OS5ibHVlaG9zdC5jb20= X-Local-Domain: yes 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: , Errors-To: gdb-patches-bounces@sourceware.org Sender: "Gdb-patches" This splits STRUCTOP_PTR into a new function for future use. gdb/ChangeLog 2021-01-01 Tom Tromey * eval.c (eval_op_structop_ptr): New function. (evaluate_subexp_standard): Use it. --- gdb/ChangeLog | 5 +++ gdb/eval.c | 111 +++++++++++++++++++++++++++----------------------- 2 files changed, 66 insertions(+), 50 deletions(-) diff --git a/gdb/eval.c b/gdb/eval.c index b815f16ee1c..8164f2f4e3a 100644 --- a/gdb/eval.c +++ b/gdb/eval.c @@ -1339,6 +1339,65 @@ eval_op_structop_struct (struct type *expect_type, struct expression *exp, return arg3; } +/* A helper function for STRUCTOP_PTR. */ + +static struct value * +eval_op_structop_ptr (struct type *expect_type, struct expression *exp, + enum noside noside, enum exp_opcode op, + struct value *arg1, const char *string) +{ + if (noside == EVAL_SKIP) + return eval_skip_value (exp); + + /* Check to see if operator '->' has been overloaded. If so replace + arg1 with the value returned by evaluating operator->(). */ + while (unop_user_defined_p (op, arg1)) + { + struct value *value = NULL; + try + { + value = value_x_unop (arg1, op, noside); + } + + catch (const gdb_exception_error &except) + { + if (except.error == NOT_FOUND_ERROR) + break; + else + throw; + } + + arg1 = value; + } + + /* JYG: if print object is on we need to replace the base type + with rtti type in order to continue on with successful + lookup of member / method only available in the rtti type. */ + { + struct type *arg_type = value_type (arg1); + struct type *real_type; + int full, using_enc; + LONGEST top; + struct value_print_options opts; + + get_user_print_options (&opts); + if (opts.objectprint && TYPE_TARGET_TYPE (arg_type) + && (TYPE_TARGET_TYPE (arg_type)->code () == TYPE_CODE_STRUCT)) + { + real_type = value_rtti_indirect_type (arg1, &full, &top, + &using_enc); + if (real_type) + arg1 = value_cast (real_type, arg1); + } + } + + struct value *arg3 = value_struct_elt (&arg1, NULL, string, + NULL, "structure pointer"); + if (noside == EVAL_AVOID_SIDE_EFFECTS) + arg3 = value_zero (value_type (arg3), VALUE_LVAL (arg3)); + return arg3; +} + struct value * evaluate_subexp_standard (struct type *expect_type, struct expression *exp, int *pos, @@ -1937,56 +1996,8 @@ evaluate_subexp_standard (struct type *expect_type, tem = longest_to_int (exp->elts[pc + 1].longconst); (*pos) += 3 + BYTES_TO_EXP_ELEM (tem + 1); arg1 = evaluate_subexp (nullptr, exp, pos, noside); - if (noside == EVAL_SKIP) - return eval_skip_value (exp); - - /* Check to see if operator '->' has been overloaded. If so replace - arg1 with the value returned by evaluating operator->(). */ - while (unop_user_defined_p (op, arg1)) - { - struct value *value = NULL; - try - { - value = value_x_unop (arg1, op, noside); - } - - catch (const gdb_exception_error &except) - { - if (except.error == NOT_FOUND_ERROR) - break; - else - throw; - } - - arg1 = value; - } - - /* JYG: if print object is on we need to replace the base type - with rtti type in order to continue on with successful - lookup of member / method only available in the rtti type. */ - { - struct type *arg_type = value_type (arg1); - struct type *real_type; - int full, using_enc; - LONGEST top; - struct value_print_options opts; - - get_user_print_options (&opts); - if (opts.objectprint && TYPE_TARGET_TYPE (arg_type) - && (TYPE_TARGET_TYPE (arg_type)->code () == TYPE_CODE_STRUCT)) - { - real_type = value_rtti_indirect_type (arg1, &full, &top, - &using_enc); - if (real_type) - arg1 = value_cast (real_type, arg1); - } - } - - arg3 = value_struct_elt (&arg1, NULL, &exp->elts[pc + 2].string, - NULL, "structure pointer"); - if (noside == EVAL_AVOID_SIDE_EFFECTS) - arg3 = value_zero (value_type (arg3), VALUE_LVAL (arg3)); - return arg3; + return eval_op_structop_ptr (expect_type, exp, noside, op, arg1, + &exp->elts[pc + 2].string); case STRUCTOP_MEMBER: case STRUCTOP_MPTR: -- 2.26.2