From patchwork Thu Feb 9 21:38:51 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tom Tromey X-Patchwork-Id: 64601 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 2078238493E0 for ; Thu, 9 Feb 2023 23:37:23 +0000 (GMT) X-Original-To: gdb-patches@sourceware.org Delivered-To: gdb-patches@sourceware.org Received: from alt-proxy28.mail.unifiedlayer.com (alt-proxy28.mail.unifiedlayer.com [74.220.216.123]) by sourceware.org (Postfix) with ESMTPS id ED95C385B501 for ; Thu, 9 Feb 2023 23:36:37 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org ED95C385B501 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=tromey.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=tromey.com Received: from cmgw12.mail.unifiedlayer.com (unknown [10.0.90.127]) by progateway1.mail.pro1.eigbox.com (Postfix) with ESMTP id 5F18A10040611 for ; Thu, 9 Feb 2023 23:36:37 +0000 (UTC) Received: from box5379.bluehost.com ([162.241.216.53]) by cmsmtp with ESMTP id QGSzp0VqvP796QGSzpy8HR; Thu, 09 Feb 2023 23:36:37 +0000 X-Authority-Reason: nr=8 X-Authority-Analysis: v=2.4 cv=MJClJOVl c=1 sm=1 tr=0 ts=63e58385 a=ApxJNpeYhEAb1aAlGBBbmA==:117 a=ApxJNpeYhEAb1aAlGBBbmA==:17 a=dLZJa+xiwSxG16/P+YVxDGlgEgI=:19 a=IkcTkHD0fZMA:10:nop_charset_1 a=m04uMKEZRckA:10:nop_rcvd_month_year a=Qbun_eYptAEA:10:endurance_base64_authed_username_1 a=wkmQqQHD6Dkg1njgS7oA:9 a=QEXdDO2ut3YA:10:nop_charset_2 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=tromey.com; s=default; h=To:In-Reply-To:References:Message-Id:Content-Transfer-Encoding: Content-Type:MIME-Version:Subject:Date:From:Sender:Reply-To:Cc: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=NDWLyBRB8m1wOlg7BuCX1Mm85Dq2dUt6U7f0IrpfP/k=; b=wejf7X3BUx2tbEPSrEaJ5YtxCm +NbBr/nDNhsFv7qM/MB4FyEsuT+S/5XzE+CIh8EaZxaRrcHRbbb6KefX8V1GHuklzV1aI/qIgxAWm nDLQbQiPJaNEB0J8nDKggUTGL; Received: from 75-166-130-93.hlrn.qwest.net ([75.166.130.93]:52822 helo=[192.168.0.21]) by box5379.bluehost.com with esmtpsa (TLS1.2) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.95) (envelope-from ) id 1pQEct-001ZcE-Pp for gdb-patches@sourceware.org; Thu, 09 Feb 2023 14:38:43 -0700 From: Tom Tromey Date: Thu, 09 Feb 2023 14:38:51 -0700 Subject: [PATCH 30/47] Turn value_bits_synthetic_pointer into a method MIME-Version: 1.0 Message-Id: <20230209-submit-value-fixups-2023-v1-30-55dc2794dbb9@tromey.com> References: <20230209-submit-value-fixups-2023-v1-0-55dc2794dbb9@tromey.com> In-Reply-To: <20230209-submit-value-fixups-2023-v1-0-55dc2794dbb9@tromey.com> To: gdb-patches@sourceware.org X-Mailer: b4 0.12.0 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: 75.166.130.93 X-Source-L: No X-Exim-ID: 1pQEct-001ZcE-Pp X-Source: X-Source-Args: X-Source-Dir: X-Source-Sender: 75-166-130-93.hlrn.qwest.net ([192.168.0.21]) [75.166.130.93]:52822 X-Source-Auth: tom+tromey.com X-Email-Count: 9 X-Source-Cap: ZWx5bnJvYmk7ZWx5bnJvYmk7Ym94NTM3OS5ibHVlaG9zdC5jb20= X-Local-Domain: yes X-Spam-Status: No, score=-3027.6 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, GIT_PATCH_0, JMQ_SPF_NEUTRAL, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) 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: , Errors-To: gdb-patches-bounces+patchwork=sourceware.org@sourceware.org Sender: "Gdb-patches" This changes value_bits_synthetic_pointer to be a method of value. --- gdb/cp-valprint.c | 6 +++--- gdb/dwarf2/expr.c | 4 ++-- gdb/opencl-lang.c | 5 ++--- gdb/p-valprint.c | 6 +++--- gdb/valops.c | 4 ++-- gdb/valprint.c | 9 ++++----- gdb/value.c | 12 +++++------- gdb/value.h | 11 +++++------ 8 files changed, 26 insertions(+), 31 deletions(-) diff --git a/gdb/cp-valprint.c b/gdb/cp-valprint.c index dd396825798..5f18d372aa3 100644 --- a/gdb/cp-valprint.c +++ b/gdb/cp-valprint.c @@ -270,9 +270,9 @@ cp_print_value_fields (struct value *val, struct ui_file *stream, fputs_styled ("", metadata_style.style (), stream); } - else if (value_bits_synthetic_pointer - (val, type->field (i).loc_bitpos (), - TYPE_FIELD_BITSIZE (type, i))) + else if (val->bits_synthetic_pointer + (type->field (i).loc_bitpos (), + TYPE_FIELD_BITSIZE (type, i))) { fputs_styled (_(""), metadata_style.style (), stream); diff --git a/gdb/dwarf2/expr.c b/gdb/dwarf2/expr.c index e08dca01a67..ef93b89aaa9 100644 --- a/gdb/dwarf2/expr.c +++ b/gdb/dwarf2/expr.c @@ -576,8 +576,8 @@ coerce_pieced_ref (const value *value) { struct type *type = check_typedef (value->type ()); - if (value_bits_synthetic_pointer (value, value->embedded_offset (), - TARGET_CHAR_BIT * type->length ())) + if (value->bits_synthetic_pointer (value->embedded_offset (), + TARGET_CHAR_BIT * type->length ())) { const piece_closure *closure = (piece_closure *) value->computed_closure (); diff --git a/gdb/opencl-lang.c b/gdb/opencl-lang.c index 8bc727cdfdf..e4a88a23d49 100644 --- a/gdb/opencl-lang.c +++ b/gdb/opencl-lang.c @@ -215,9 +215,8 @@ lval_func_check_synthetic_pointer (const struct value *v, int comp_offset = (i == start) ? startrest : 0; int comp_length = (i == end) ? endrest : elsize; - if (!value_bits_synthetic_pointer (c->val, - c->indices[i] * elsize + comp_offset, - comp_length)) + if (!c->val->bits_synthetic_pointer (c->indices[i] * elsize + comp_offset, + comp_length)) return 0; } diff --git a/gdb/p-valprint.c b/gdb/p-valprint.c index c6b9b5571dd..4b84ec1c43f 100644 --- a/gdb/p-valprint.c +++ b/gdb/p-valprint.c @@ -609,9 +609,9 @@ pascal_object_print_value_fields (struct value *val, struct ui_file *stream, fputs_styled ("", metadata_style.style (), stream); } - else if (value_bits_synthetic_pointer - (val, type->field (i).loc_bitpos (), - TYPE_FIELD_BITSIZE (type, i))) + else if (val->bits_synthetic_pointer + (type->field (i).loc_bitpos (), + TYPE_FIELD_BITSIZE (type, i))) { fputs_styled (_(""), metadata_style.style (), stream); diff --git a/gdb/valops.c b/gdb/valops.c index ceec461c483..d2249d79b15 100644 --- a/gdb/valops.c +++ b/gdb/valops.c @@ -1556,8 +1556,8 @@ value_addr (struct value *arg1) if (TYPE_IS_REFERENCE (type)) { - if (value_bits_synthetic_pointer (arg1, arg1->embedded_offset (), - TARGET_CHAR_BIT * type->length ())) + if (arg1->bits_synthetic_pointer (arg1->embedded_offset (), + TARGET_CHAR_BIT * type->length ())) arg1 = coerce_ref (arg1); else { diff --git a/gdb/valprint.c b/gdb/valprint.c index decaaa2710c..d94121edd29 100644 --- a/gdb/valprint.c +++ b/gdb/valprint.c @@ -381,8 +381,8 @@ valprint_check_validity (struct ui_file *stream, return 0; } - if (value_bits_synthetic_pointer (val, TARGET_CHAR_BIT * embedded_offset, - TARGET_CHAR_BIT * type->length ())) + if (val->bits_synthetic_pointer (TARGET_CHAR_BIT * embedded_offset, + TARGET_CHAR_BIT * type->length ())) { const int is_ref = type->code () == TYPE_CODE_REF; int ref_is_addressable = 0; @@ -568,9 +568,8 @@ generic_val_print_ref (struct type *type, struct type *elttype = check_typedef (type->target_type ()); struct value *deref_val = NULL; const int value_is_synthetic - = value_bits_synthetic_pointer (original_value, - TARGET_CHAR_BIT * embedded_offset, - TARGET_CHAR_BIT * type->length ()); + = original_value->bits_synthetic_pointer (TARGET_CHAR_BIT * embedded_offset, + TARGET_CHAR_BIT * type->length ()); const int must_coerce_ref = ((options->addressprint && value_is_synthetic) || options->deref_ref); const int type_is_defined = elttype->code () != TYPE_CODE_UNDEF; diff --git a/gdb/value.c b/gdb/value.c index 342f7edb034..1b304e07204 100644 --- a/gdb/value.c +++ b/gdb/value.c @@ -1237,15 +1237,13 @@ mark_value_bits_optimized_out (struct value *value, } int -value_bits_synthetic_pointer (const struct value *value, - LONGEST offset, LONGEST length) +value::bits_synthetic_pointer (LONGEST offset, LONGEST length) const { - if (value->m_lval != lval_computed - || !value->m_location.computed.funcs->check_synthetic_pointer) + if (m_lval != lval_computed + || !m_location.computed.funcs->check_synthetic_pointer) return 0; - return value->m_location.computed.funcs->check_synthetic_pointer (value, - offset, - length); + return m_location.computed.funcs->check_synthetic_pointer (this, offset, + length); } const struct lval_funcs * diff --git a/gdb/value.h b/gdb/value.h index 2253784aedb..bf5effccfa9 100644 --- a/gdb/value.h +++ b/gdb/value.h @@ -456,6 +456,11 @@ struct value values. */ bool contents_eq (const struct value *val2) const; + /* Given a value, determine whether the bits starting at OFFSET and + extending for LENGTH bits are a synthetic pointer. */ + + int bits_synthetic_pointer (LONGEST offset, LONGEST length) const; + /* Type of value; either not an lval, or one of the various different possible kinds of lval. */ @@ -828,12 +833,6 @@ extern struct value *coerce_ref (struct value *value); extern struct value *coerce_array (struct value *value); -/* Given a value, determine whether the bits starting at OFFSET and - extending for LENGTH bits are a synthetic pointer. */ - -extern int value_bits_synthetic_pointer (const struct value *value, - LONGEST offset, LONGEST length); - /* Given a value, determine whether the contents bytes starting at OFFSET and extending for LENGTH bytes are available. This returns nonzero if all bytes in the given range are available, zero if any