From patchwork Thu Feb 9 21:38:22 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tom Tromey X-Patchwork-Id: 64559 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 95198384F011 for ; Thu, 9 Feb 2023 21:39:27 +0000 (GMT) X-Original-To: gdb-patches@sourceware.org Delivered-To: gdb-patches@sourceware.org Received: from outbound-ss-820.bluehost.com (outbound-ss-820.bluehost.com [69.89.24.241]) by sourceware.org (Postfix) with ESMTPS id 912453858C5F for ; Thu, 9 Feb 2023 21:38:40 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 912453858C5F 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 progateway2.mail.pro1.eigbox.com (Postfix) with ESMTP id E29FF10047F90 for ; Thu, 9 Feb 2023 21:38:39 +0000 (UTC) Received: from box5379.bluehost.com ([162.241.216.53]) by cmsmtp with ESMTP id QEcppzBNYP796QEcppwoV5; Thu, 09 Feb 2023 21:38:39 +0000 X-Authority-Reason: nr=8 X-Authority-Analysis: v=2.4 cv=MJClJOVl c=1 sm=1 tr=0 ts=63e567df 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=_wBDaLaCibmPkRHvG1wA: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=oIBDPpBQsNigcHEF6NUiGGWNbR9+91iYWIO2FQvZrhM=; b=XDPaW6fSWbkgO3AlDcLJft/cWB ycvdk9ul5rTMfQ2S1gl5F/EWUe03bGLsECyaK3V88yeDXHHNL2aXjiw1t7kV+OgA8BTiQ4QiHSBNP 3aO/cE1ojSLqF07lUQoITlhUq; 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 1pQEcp-001ZcE-MP for gdb-patches@sourceware.org; Thu, 09 Feb 2023 14:38:39 -0700 From: Tom Tromey Date: Thu, 09 Feb 2023 14:38:22 -0700 Subject: [PATCH 01/47] Rename all fields of struct value MIME-Version: 1.0 Message-Id: <20230209-submit-value-fixups-2023-v1-1-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: 1pQEcp-001ZcE-MP 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: 2 X-Source-Cap: ZWx5bnJvYmk7ZWx5bnJvYmk7Ym94NTM3OS5ibHVlaG9zdC5jb20= X-Local-Domain: yes X-Spam-Status: No, score=-3027.3 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 renames all the fields of struct value, in preparation for the coming changes. --- gdb/value.c | 372 ++++++++++++++++++++++++++++++------------------------------ 1 file changed, 186 insertions(+), 186 deletions(-) diff --git a/gdb/value.c b/gdb/value.c index e3f60e7e989..c998a516a0f 100644 --- a/gdb/value.c +++ b/gdb/value.c @@ -180,13 +180,13 @@ static struct cmd_list_element *functionlist; struct value { explicit value (struct type *type_) - : modifiable (1), - lazy (1), - initialized (1), - stack (0), - is_zero (false), - type (type_), - enclosing_type (type_) + : m_modifiable (1), + m_lazy (1), + m_initialized (1), + m_stack (0), + m_is_zero (false), + m_type (type_), + m_enclosing_type (type_) { } @@ -194,23 +194,23 @@ struct value { if (VALUE_LVAL (this) == lval_computed) { - const struct lval_funcs *funcs = location.computed.funcs; + const struct lval_funcs *funcs = m_location.computed.funcs; if (funcs->free_closure) funcs->free_closure (this); } else if (VALUE_LVAL (this) == lval_xcallable) - delete location.xm_worker; + delete m_location.xm_worker; } DISABLE_COPY_AND_ASSIGN (value); /* Type of value; either not an lval, or one of the various different possible kinds of lval. */ - enum lval_type lval = not_lval; + enum lval_type m_lval = not_lval; /* Is it modifiable? Only relevant if lval != not_lval. */ - unsigned int modifiable : 1; + unsigned int m_modifiable : 1; /* If zero, contents of this value are in the contents field. If nonzero, contents are in inferior. If the lval field is lval_memory, @@ -226,18 +226,18 @@ struct value or array when the user wants to watch a single struct member or array element. If you ever change the way lazy flag is set and reset, be sure to consider this use as well! */ - unsigned int lazy : 1; + unsigned int m_lazy : 1; /* If value is a variable, is it initialized or not. */ - unsigned int initialized : 1; + unsigned int m_initialized : 1; /* If value is from the stack. If this is set, read_stack will be used instead of read_memory to enable extra caching. */ - unsigned int stack : 1; + unsigned int m_stack : 1; /* True if this is a zero value, created by 'value_zero'; false otherwise. */ - bool is_zero : 1; + bool m_is_zero : 1; /* Location of value (if lval). */ union @@ -273,35 +273,35 @@ struct value /* Closure for those functions to use. */ void *closure; } computed; - } location {}; + } m_location {}; /* Describes offset of a value within lval of a structure in target addressable memory units. Note also the member embedded_offset below. */ - LONGEST offset = 0; + LONGEST m_offset = 0; /* Only used for bitfields; number of bits contained in them. */ - LONGEST bitsize = 0; + LONGEST m_bitsize = 0; /* Only used for bitfields; position of start of field. For little-endian targets, it is the position of the LSB. For big-endian targets, it is the position of the MSB. */ - LONGEST bitpos = 0; + LONGEST m_bitpos = 0; /* The number of references to this value. When a value is created, the value chain holds a reference, so REFERENCE_COUNT is 1. If release_value is called, this value is removed from the chain but the caller of release_value now has a reference to this value. The caller must arrange for a call to value_free later. */ - int reference_count = 1; + int m_reference_count = 1; /* Only used for bitfields; the containing value. This allows a single read from the target when displaying multiple bitfields. */ - value_ref_ptr parent; + value_ref_ptr m_parent; /* Type of the value. */ - struct type *type; + struct type *m_type; /* If a value represents a C++ object, then the `type' field gives the object's compile-time type. If the object actually belongs @@ -343,15 +343,15 @@ struct value If we're not doing anything fancy, `enclosing_type' is equal to `type', and `embedded_offset' is zero, so everything works normally. */ - struct type *enclosing_type; - LONGEST embedded_offset = 0; - LONGEST pointed_to_offset = 0; + struct type *m_enclosing_type; + LONGEST m_embedded_offset = 0; + LONGEST m_pointed_to_offset = 0; /* Actual contents of the value. Target byte-order. May be nullptr if the value is lazy or is entirely optimized out. Guaranteed to be non-nullptr otherwise. */ - gdb::unique_xmalloc_ptr contents; + gdb::unique_xmalloc_ptr m_contents; /* Unavailable ranges in CONTENTS. We mark unavailable ranges, rather than available, since the common and default case is for a @@ -359,7 +359,7 @@ struct value The unavailable ranges are tracked in bits. Note that a contents bit that has been optimized out doesn't really exist in the program, so it can't be marked unavailable either. */ - std::vector unavailable; + std::vector m_unavailable; /* Likewise, but for optimized out contents (a chunk of the value of a variable that does not actually exist in the program). If LVAL @@ -368,7 +368,7 @@ struct value saved registers and optimized-out program variables values are treated pretty much the same, except not-saved registers have a different string representation and related error strings. */ - std::vector optimized_out; + std::vector m_optimized_out; }; /* See value.h. */ @@ -382,9 +382,9 @@ get_value_arch (const struct value *value) int value_bits_available (const struct value *value, LONGEST offset, LONGEST length) { - gdb_assert (!value->lazy); + gdb_assert (!value->m_lazy); - return !ranges_contain (value->unavailable, offset, length); + return !ranges_contain (value->m_unavailable, offset, length); } int @@ -399,9 +399,9 @@ value_bytes_available (const struct value *value, int value_bits_any_optimized_out (const struct value *value, int bit_offset, int bit_length) { - gdb_assert (!value->lazy); + gdb_assert (!value->m_lazy); - return ranges_contain (value->optimized_out, bit_offset, bit_length); + return ranges_contain (value->m_optimized_out, bit_offset, bit_length); } int @@ -409,10 +409,10 @@ value_entirely_available (struct value *value) { /* We can only tell whether the whole value is available when we try to read it. */ - if (value->lazy) + if (value->m_lazy) value_fetch_lazy (value); - if (value->unavailable.empty ()) + if (value->m_unavailable.empty ()) return 1; return 0; } @@ -427,7 +427,7 @@ value_entirely_covered_by_range_vector (struct value *value, { /* We can only tell whether the whole value is optimized out / unavailable when we try to read it. */ - if (value->lazy) + if (value->m_lazy) value_fetch_lazy (value); if (ranges.size () == 1) @@ -446,13 +446,13 @@ value_entirely_covered_by_range_vector (struct value *value, int value_entirely_unavailable (struct value *value) { - return value_entirely_covered_by_range_vector (value, value->unavailable); + return value_entirely_covered_by_range_vector (value, value->m_unavailable); } int value_entirely_optimized_out (struct value *value) { - return value_entirely_covered_by_range_vector (value, value->optimized_out); + return value_entirely_covered_by_range_vector (value, value->m_optimized_out); } /* Insert into the vector pointed to by VECTORP the bit range starting of @@ -628,7 +628,7 @@ void mark_value_bits_unavailable (struct value *value, LONGEST offset, LONGEST length) { - insert_into_bit_range_vector (&value->unavailable, offset, length); + insert_into_bit_range_vector (&value->m_unavailable, offset, length); } void @@ -854,20 +854,20 @@ value_contents_bits_eq (const struct value *val1, int offset1, struct ranges_and_idx rp1[2], rp2[2]; /* See function description in value.h. */ - gdb_assert (!val1->lazy && !val2->lazy); + gdb_assert (!val1->m_lazy && !val2->m_lazy); /* We shouldn't be trying to compare past the end of the values. */ gdb_assert (offset1 + length - <= val1->enclosing_type->length () * TARGET_CHAR_BIT); + <= val1->m_enclosing_type->length () * TARGET_CHAR_BIT); gdb_assert (offset2 + length - <= val2->enclosing_type->length () * TARGET_CHAR_BIT); + <= val2->m_enclosing_type->length () * TARGET_CHAR_BIT); memset (&rp1, 0, sizeof (rp1)); memset (&rp2, 0, sizeof (rp2)); - rp1[0].ranges = &val1->unavailable; - rp2[0].ranges = &val2->unavailable; - rp1[1].ranges = &val1->optimized_out; - rp2[1].ranges = &val2->optimized_out; + rp1[0].ranges = &val1->m_unavailable; + rp2[0].ranges = &val2->m_unavailable; + rp1[1].ranges = &val1->m_optimized_out; + rp2[1].ranges = &val2->m_optimized_out; while (length > 0) { @@ -894,8 +894,8 @@ value_contents_bits_eq (const struct value *val1, int offset1, } /* Compare the available/valid contents. */ - if (memcmp_with_bit_offsets (val1->contents.get (), offset1, - val2->contents.get (), offset2, l) != 0) + if (memcmp_with_bit_offsets (val1->m_contents.get (), offset1, + val2->m_contents.get (), offset2, l) != 0) return false; length -= h; @@ -1039,11 +1039,11 @@ check_type_length_before_alloc (const struct type *type) static void allocate_value_contents (struct value *val) { - if (!val->contents) + if (!val->m_contents) { - check_type_length_before_alloc (val->enclosing_type); - val->contents.reset - ((gdb_byte *) xzalloc (val->enclosing_type->length ())); + check_type_length_before_alloc (val->m_enclosing_type); + val->m_contents.reset + ((gdb_byte *) xzalloc (val->m_enclosing_type->length ())); } } @@ -1055,7 +1055,7 @@ allocate_value (struct type *type) struct value *val = allocate_value_lazy (type); allocate_value_contents (val); - val->lazy = 0; + val->m_lazy = 0; return val; } @@ -1085,8 +1085,8 @@ allocate_computed_value (struct type *type, struct value *v = allocate_value_lazy (type); VALUE_LVAL (v) = lval_computed; - v->location.computed.funcs = funcs; - v->location.computed.closure = closure; + v->m_location.computed.funcs = funcs; + v->m_location.computed.closure = closure; return v; } @@ -1108,51 +1108,51 @@ allocate_optimized_out_value (struct type *type) struct type * value_type (const struct value *value) { - return value->type; + return value->m_type; } void deprecated_set_value_type (struct value *value, struct type *type) { - value->type = type; + value->m_type = type; } LONGEST value_offset (const struct value *value) { - return value->offset; + return value->m_offset; } void set_value_offset (struct value *value, LONGEST offset) { - value->offset = offset; + value->m_offset = offset; } LONGEST value_bitpos (const struct value *value) { - return value->bitpos; + return value->m_bitpos; } void set_value_bitpos (struct value *value, LONGEST bit) { - value->bitpos = bit; + value->m_bitpos = bit; } LONGEST value_bitsize (const struct value *value) { - return value->bitsize; + return value->m_bitsize; } void set_value_bitsize (struct value *value, LONGEST bit) { - value->bitsize = bit; + value->m_bitsize = bit; } struct value * value_parent (const struct value *value) { - return value->parent.get (); + return value->m_parent.get (); } /* See value.h. */ @@ -1160,7 +1160,7 @@ value_parent (const struct value *value) void set_value_parent (struct value *value, struct value *parent) { - value->parent = value_ref_ptr::new_reference (parent); + value->m_parent = value_ref_ptr::new_reference (parent); } gdb::array_view @@ -1173,7 +1173,7 @@ value_contents_raw (struct value *value) ULONGEST length = value_type (value)->length (); return gdb::make_array_view - (value->contents.get () + value->embedded_offset * unit_size, length); + (value->m_contents.get () + value->m_embedded_offset * unit_size, length); } gdb::array_view @@ -1182,13 +1182,13 @@ value_contents_all_raw (struct value *value) allocate_value_contents (value); ULONGEST length = value_enclosing_type (value)->length (); - return gdb::make_array_view (value->contents.get (), length); + return gdb::make_array_view (value->m_contents.get (), length); } struct type * value_enclosing_type (const struct value *value) { - return value->enclosing_type; + return value->m_enclosing_type; } /* Look at value.h for description. */ @@ -1244,9 +1244,9 @@ error_value_optimized_out (void) static void require_not_optimized_out (const struct value *value) { - if (!value->optimized_out.empty ()) + if (!value->m_optimized_out.empty ()) { - if (value->lval == lval_register) + if (value->m_lval == lval_register) throw_error (OPTIMIZED_OUT_ERROR, _("register has not been saved in frame")); else @@ -1257,27 +1257,27 @@ require_not_optimized_out (const struct value *value) static void require_available (const struct value *value) { - if (!value->unavailable.empty ()) + if (!value->m_unavailable.empty ()) throw_error (NOT_AVAILABLE_ERROR, _("value is not available")); } gdb::array_view value_contents_for_printing (struct value *value) { - if (value->lazy) + if (value->m_lazy) value_fetch_lazy (value); ULONGEST length = value_enclosing_type (value)->length (); - return gdb::make_array_view (value->contents.get (), length); + return gdb::make_array_view (value->m_contents.get (), length); } gdb::array_view value_contents_for_printing_const (const struct value *value) { - gdb_assert (!value->lazy); + gdb_assert (!value->m_lazy); ULONGEST length = value_enclosing_type (value)->length (); - return gdb::make_array_view (value->contents.get (), length); + return gdb::make_array_view (value->m_contents.get (), length); } gdb::array_view @@ -1320,11 +1320,11 @@ value_ranges_copy_adjusted (struct value *dst, int dst_bit_offset, const struct value *src, int src_bit_offset, int bit_length) { - ranges_copy_adjusted (&dst->unavailable, dst_bit_offset, - src->unavailable, src_bit_offset, + ranges_copy_adjusted (&dst->m_unavailable, dst_bit_offset, + src->m_unavailable, src_bit_offset, bit_length); - ranges_copy_adjusted (&dst->optimized_out, dst_bit_offset, - src->optimized_out, src_bit_offset, + ranges_copy_adjusted (&dst->m_optimized_out, dst_bit_offset, + src->m_optimized_out, src_bit_offset, bit_length); } @@ -1350,7 +1350,7 @@ value_contents_copy_raw (struct value *dst, LONGEST dst_offset, soon as DST's contents were un-lazied (by a later value_contents call, say), the contents would be overwritten. A lazy SRC would mean we'd be copying garbage. */ - gdb_assert (!dst->lazy && !src->lazy); + gdb_assert (!dst->m_lazy && !src->m_lazy); /* The overwritten DST range gets unavailability ORed in, not replaced. Make sure to remember to implement replacing if it @@ -1391,7 +1391,7 @@ value_contents_copy_raw_bitwise (struct value *dst, LONGEST dst_bit_offset, soon as DST's contents were un-lazied (by a later value_contents call, say), the contents would be overwritten. A lazy SRC would mean we'd be copying garbage. */ - gdb_assert (!dst->lazy && !src->lazy); + gdb_assert (!dst->m_lazy && !src->m_lazy); /* The overwritten DST range gets unavailability ORed in, not replaced. Make sure to remember to implement replacing if it @@ -1430,7 +1430,7 @@ void value_contents_copy (struct value *dst, LONGEST dst_offset, struct value *src, LONGEST src_offset, LONGEST length) { - if (src->lazy) + if (src->m_lazy) value_fetch_lazy (src); value_contents_copy_raw (dst, dst_offset, src, src_offset, length); @@ -1439,25 +1439,25 @@ value_contents_copy (struct value *dst, LONGEST dst_offset, int value_lazy (const struct value *value) { - return value->lazy; + return value->m_lazy; } void set_value_lazy (struct value *value, int val) { - value->lazy = val; + value->m_lazy = val; } int value_stack (const struct value *value) { - return value->stack; + return value->m_stack; } void set_value_stack (struct value *value, int val) { - value->stack = val; + value->m_stack = val; } gdb::array_view @@ -1472,7 +1472,7 @@ value_contents (struct value *value) gdb::array_view value_contents_writeable (struct value *value) { - if (value->lazy) + if (value->m_lazy) value_fetch_lazy (value); return value_contents_raw (value); } @@ -1480,7 +1480,7 @@ value_contents_writeable (struct value *value) int value_optimized_out (struct value *value) { - if (value->lazy) + if (value->m_lazy) { /* See if we can compute the result without fetching the value. */ @@ -1488,7 +1488,7 @@ value_optimized_out (struct value *value) return false; else if (VALUE_LVAL (value) == lval_computed) { - const struct lval_funcs *funcs = value->location.computed.funcs; + const struct lval_funcs *funcs = value->m_location.computed.funcs; if (funcs->is_optimized_out != nullptr) return funcs->is_optimized_out (value); @@ -1516,7 +1516,7 @@ value_optimized_out (struct value *value) } } - return !value->optimized_out.empty (); + return !value->m_optimized_out.empty (); } /* Mark contents of VALUE as optimized out, starting at OFFSET bytes, and @@ -1536,17 +1536,17 @@ void mark_value_bits_optimized_out (struct value *value, LONGEST offset, LONGEST length) { - insert_into_bit_range_vector (&value->optimized_out, offset, length); + insert_into_bit_range_vector (&value->m_optimized_out, offset, length); } int value_bits_synthetic_pointer (const struct value *value, LONGEST offset, LONGEST length) { - if (value->lval != lval_computed - || !value->location.computed.funcs->check_synthetic_pointer) + if (value->m_lval != lval_computed + || !value->m_location.computed.funcs->check_synthetic_pointer) return 0; - return value->location.computed.funcs->check_synthetic_pointer (value, + return value->m_location.computed.funcs->check_synthetic_pointer (value, offset, length); } @@ -1554,25 +1554,25 @@ value_bits_synthetic_pointer (const struct value *value, LONGEST value_embedded_offset (const struct value *value) { - return value->embedded_offset; + return value->m_embedded_offset; } void set_value_embedded_offset (struct value *value, LONGEST val) { - value->embedded_offset = val; + value->m_embedded_offset = val; } LONGEST value_pointed_to_offset (const struct value *value) { - return value->pointed_to_offset; + return value->m_pointed_to_offset; } void set_value_pointed_to_offset (struct value *value, LONGEST val) { - value->pointed_to_offset = val; + value->m_pointed_to_offset = val; } const struct lval_funcs * @@ -1580,84 +1580,84 @@ value_computed_funcs (const struct value *v) { gdb_assert (value_lval_const (v) == lval_computed); - return v->location.computed.funcs; + return v->m_location.computed.funcs; } void * value_computed_closure (const struct value *v) { - gdb_assert (v->lval == lval_computed); + gdb_assert (v->m_lval == lval_computed); - return v->location.computed.closure; + return v->m_location.computed.closure; } enum lval_type * deprecated_value_lval_hack (struct value *value) { - return &value->lval; + return &value->m_lval; } enum lval_type value_lval_const (const struct value *value) { - return value->lval; + return value->m_lval; } CORE_ADDR value_address (const struct value *value) { - if (value->lval != lval_memory) + if (value->m_lval != lval_memory) return 0; - if (value->parent != NULL) - return value_address (value->parent.get ()) + value->offset; + if (value->m_parent != NULL) + return value_address (value->m_parent.get ()) + value->m_offset; if (NULL != TYPE_DATA_LOCATION (value_type (value))) { gdb_assert (PROP_CONST == TYPE_DATA_LOCATION_KIND (value_type (value))); return TYPE_DATA_LOCATION_ADDR (value_type (value)); } - return value->location.address + value->offset; + return value->m_location.address + value->m_offset; } CORE_ADDR value_raw_address (const struct value *value) { - if (value->lval != lval_memory) + if (value->m_lval != lval_memory) return 0; - return value->location.address; + return value->m_location.address; } void set_value_address (struct value *value, CORE_ADDR addr) { - gdb_assert (value->lval == lval_memory); - value->location.address = addr; + gdb_assert (value->m_lval == lval_memory); + value->m_location.address = addr; } struct internalvar ** deprecated_value_internalvar_hack (struct value *value) { - return &value->location.internalvar; + return &value->m_location.internalvar; } struct frame_id * deprecated_value_next_frame_id_hack (struct value *value) { - gdb_assert (value->lval == lval_register); - return &value->location.reg.next_frame_id; + gdb_assert (value->m_lval == lval_register); + return &value->m_location.reg.next_frame_id; } int * deprecated_value_regnum_hack (struct value *value) { - gdb_assert (value->lval == lval_register); - return &value->location.reg.regnum; + gdb_assert (value->m_lval == lval_register); + return &value->m_location.reg.regnum; } int deprecated_value_modifiable (const struct value *value) { - return value->modifiable; + return value->m_modifiable; } /* Return a mark in the value chain. All values allocated after the @@ -1676,7 +1676,7 @@ value_mark (void) void value_incref (struct value *val) { - val->reference_count++; + val->m_reference_count++; } /* Release a reference to VAL, which was acquired with value_incref. @@ -1688,9 +1688,9 @@ value_decref (struct value *val) { if (val != nullptr) { - gdb_assert (val->reference_count > 0); - val->reference_count--; - if (val->reference_count == 0) + gdb_assert (val->m_reference_count > 0); + val->m_reference_count--; + if (val->m_reference_count == 0) delete val; } } @@ -1766,38 +1766,38 @@ value_copy (const value *arg) val = allocate_value_lazy (encl_type); else val = allocate_value (encl_type); - val->type = arg->type; - VALUE_LVAL (val) = arg->lval; - val->location = arg->location; - val->offset = arg->offset; - val->bitpos = arg->bitpos; - val->bitsize = arg->bitsize; - val->lazy = arg->lazy; - val->embedded_offset = value_embedded_offset (arg); - val->pointed_to_offset = arg->pointed_to_offset; - val->modifiable = arg->modifiable; - val->stack = arg->stack; - val->is_zero = arg->is_zero; - val->initialized = arg->initialized; - val->unavailable = arg->unavailable; - val->optimized_out = arg->optimized_out; + val->m_type = arg->m_type; + VALUE_LVAL (val) = arg->m_lval; + val->m_location = arg->m_location; + val->m_offset = arg->m_offset; + val->m_bitpos = arg->m_bitpos; + val->m_bitsize = arg->m_bitsize; + val->m_lazy = arg->m_lazy; + val->m_embedded_offset = value_embedded_offset (arg); + val->m_pointed_to_offset = arg->m_pointed_to_offset; + val->m_modifiable = arg->m_modifiable; + val->m_stack = arg->m_stack; + val->m_is_zero = arg->m_is_zero; + val->m_initialized = arg->m_initialized; + val->m_unavailable = arg->m_unavailable; + val->m_optimized_out = arg->m_optimized_out; if (!value_lazy (val) && !value_entirely_optimized_out (val)) { - gdb_assert (arg->contents != nullptr); + gdb_assert (arg->m_contents != nullptr); ULONGEST length = value_enclosing_type (arg)->length (); const auto &arg_view - = gdb::make_array_view (arg->contents.get (), length); + = gdb::make_array_view (arg->m_contents.get (), length); copy (arg_view, value_contents_all_raw (val)); } - val->parent = arg->parent; + val->m_parent = arg->m_parent; if (VALUE_LVAL (val) == lval_computed) { - const struct lval_funcs *funcs = val->location.computed.funcs; + const struct lval_funcs *funcs = val->m_location.computed.funcs; if (funcs->copy_closure) - val->location.computed.closure = funcs->copy_closure (val); + val->m_location.computed.closure = funcs->copy_closure (val); } return val; } @@ -1812,13 +1812,13 @@ struct value * make_cv_value (int cnst, int voltl, struct value *v) { struct type *val_type = value_type (v); - struct type *enclosing_type = value_enclosing_type (v); + struct type *m_enclosing_type = value_enclosing_type (v); struct value *cv_val = value_copy (v); deprecated_set_value_type (cv_val, make_cv_type (cnst, voltl, val_type, NULL)); set_value_enclosing_type (cv_val, - make_cv_type (cnst, voltl, enclosing_type, NULL)); + make_cv_type (cnst, voltl, m_enclosing_type, NULL)); return cv_val; } @@ -1834,7 +1834,7 @@ value_non_lval (struct value *arg) struct value *val = allocate_value (enc_type); copy (value_contents_all (arg), value_contents_all_raw (val)); - val->type = arg->type; + val->m_type = arg->m_type; set_value_embedded_offset (val, value_embedded_offset (arg)); set_value_pointed_to_offset (val, value_pointed_to_offset (arg)); return val; @@ -1850,8 +1850,8 @@ value_force_lval (struct value *v, CORE_ADDR addr) gdb_assert (VALUE_LVAL (v) == not_lval); write_memory (addr, value_contents_raw (v).data (), value_type (v)->length ()); - v->lval = lval_memory; - v->location.address = addr; + v->m_lval = lval_memory; + v->m_location.address = addr; } void @@ -1860,20 +1860,20 @@ set_value_component_location (struct value *component, { struct type *type; - gdb_assert (whole->lval != lval_xcallable); + gdb_assert (whole->m_lval != lval_xcallable); - if (whole->lval == lval_internalvar) + if (whole->m_lval == lval_internalvar) VALUE_LVAL (component) = lval_internalvar_component; else - VALUE_LVAL (component) = whole->lval; + VALUE_LVAL (component) = whole->m_lval; - component->location = whole->location; - if (whole->lval == lval_computed) + component->m_location = whole->m_location; + if (whole->m_lval == lval_computed) { - const struct lval_funcs *funcs = whole->location.computed.funcs; + const struct lval_funcs *funcs = whole->m_location.computed.funcs; if (funcs->copy_closure) - component->location.computed.closure = funcs->copy_closure (whole); + component->m_location.computed.closure = funcs->copy_closure (whole); } /* If the WHOLE value has a dynamically resolved location property then @@ -1934,7 +1934,7 @@ record_latest_value (struct value *val) /* We preserve VALUE_LVAL so that the user can find out where it was fetched from. This is a bit dubious, because then *&$1 does not just return $1 but the current contents of that location. c'est la vie... */ - val->modifiable = 0; + val->m_modifiable = 0; value_history.push_back (release_value (val)); @@ -2323,7 +2323,7 @@ value_of_internalvar (struct gdbarch *gdbarch, struct internalvar *var) want. */ if (var->kind != INTERNALVAR_MAKE_VALUE - && val->lval != lval_computed) + && val->m_lval != lval_computed) { VALUE_LVAL (val) = lval_internalvar; VALUE_INTERNALVAR (val) = var; @@ -2427,7 +2427,7 @@ set_internalvar (struct internalvar *var, struct value *val) default: new_kind = INTERNALVAR_VALUE; struct value *copy = value_copy (val); - copy->modifiable = 1; + copy->m_modifiable = 1; /* Force the value to be fetched from the target now, to avoid problems later when this internalvar is referenced and the target is gone or @@ -2618,11 +2618,11 @@ void preserve_one_value (struct value *value, struct objfile *objfile, htab_t copied_types) { - if (value->type->objfile_owner () == objfile) - value->type = copy_type_recursive (value->type, copied_types); + if (value->m_type->objfile_owner () == objfile) + value->m_type = copy_type_recursive (value->m_type, copied_types); - if (value->enclosing_type->objfile_owner () == objfile) - value->enclosing_type = copy_type_recursive (value->enclosing_type, + if (value->m_enclosing_type->objfile_owner () == objfile) + value->m_enclosing_type = copy_type_recursive (value->m_enclosing_type, copied_types); } @@ -2753,9 +2753,9 @@ value_from_xmethod (xmethod_worker_up &&worker) struct value *v; v = allocate_value (builtin_type (target_gdbarch ())->xmethod); - v->lval = lval_xcallable; - v->location.xm_worker = worker.release (); - v->modifiable = 0; + v->m_lval = lval_xcallable; + v->m_location.xm_worker = worker.release (); + v->m_modifiable = 0; return v; } @@ -2766,9 +2766,9 @@ struct type * result_type_of_xmethod (struct value *method, gdb::array_view argv) { gdb_assert (value_type (method)->code () == TYPE_CODE_XMETHOD - && method->lval == lval_xcallable && !argv.empty ()); + && method->m_lval == lval_xcallable && !argv.empty ()); - return method->location.xm_worker->get_result_type (argv[0], argv.slice (1)); + return method->m_location.xm_worker->get_result_type (argv[0], argv.slice (1)); } /* Call the xmethod corresponding to the TYPE_CODE_XMETHOD value METHOD. */ @@ -2777,9 +2777,9 @@ struct value * call_xmethod (struct value *method, gdb::array_view argv) { gdb_assert (value_type (method)->code () == TYPE_CODE_XMETHOD - && method->lval == lval_xcallable && !argv.empty ()); + && method->m_lval == lval_xcallable && !argv.empty ()); - return method->location.xm_worker->invoke (argv[0], argv.slice (1)); + return method->m_location.xm_worker->invoke (argv[0], argv.slice (1)); } /* Extract a value as a C number (either long or double). @@ -3088,12 +3088,12 @@ set_value_enclosing_type (struct value *val, struct type *new_encl_type) if (new_encl_type->length () > value_enclosing_type (val)->length ()) { check_type_length_before_alloc (new_encl_type); - val->contents - .reset ((gdb_byte *) xrealloc (val->contents.release (), + val->m_contents + .reset ((gdb_byte *) xrealloc (val->m_contents.release (), new_encl_type->length ())); } - val->enclosing_type = new_encl_type; + val->m_enclosing_type = new_encl_type; } /* Given a value ARG1 (offset by OFFSET bytes) @@ -3136,15 +3136,15 @@ value_primitive_field (struct value *arg1, LONGEST offset, LONGEST container_bitsize = type->length () * 8; v = allocate_value_lazy (type); - v->bitsize = TYPE_FIELD_BITSIZE (arg_type, fieldno); - if ((bitpos % container_bitsize) + v->bitsize <= container_bitsize + v->m_bitsize = TYPE_FIELD_BITSIZE (arg_type, fieldno); + if ((bitpos % container_bitsize) + v->m_bitsize <= container_bitsize && type->length () <= (int) sizeof (LONGEST)) - v->bitpos = bitpos % container_bitsize; + v->m_bitpos = bitpos % container_bitsize; else - v->bitpos = bitpos % 8; - v->offset = (value_embedded_offset (arg1) + v->m_bitpos = bitpos % 8; + v->m_offset = (value_embedded_offset (arg1) + offset - + (bitpos - v->bitpos) / 8); + + (bitpos - v->m_bitpos) / 8); set_value_parent (v, arg1); if (!value_lazy (arg1)) value_fetch_lazy (v); @@ -3180,9 +3180,9 @@ value_primitive_field (struct value *arg1, LONGEST offset, value_contents_copy_raw (v, 0, arg1, 0, value_enclosing_type (arg1)->length ()); } - v->type = type; - v->offset = value_offset (arg1); - v->embedded_offset = offset + value_embedded_offset (arg1) + boffset; + v->m_type = type; + v->m_offset = value_offset (arg1); + v->m_embedded_offset = offset + value_embedded_offset (arg1) + boffset; } else if (NULL != TYPE_DATA_LOCATION (type)) { @@ -3214,7 +3214,7 @@ value_primitive_field (struct value *arg1, LONGEST offset, arg1, value_embedded_offset (arg1) + offset, type_length_units (type)); } - v->offset = (value_offset (arg1) + offset + v->m_offset = (value_offset (arg1) + offset + value_embedded_offset (arg1)); } set_value_component_location (v, arg1); @@ -3615,7 +3615,7 @@ value_zero (struct type *type, enum lval_type lv) struct value *val = allocate_value_lazy (type); VALUE_LVAL (val) = (lv == lval_computed ? not_lval : lv); - val->is_zero = true; + val->m_is_zero = true; return val; } @@ -3816,7 +3816,7 @@ value_from_component (struct value *whole, struct type *type, LONGEST offset) whole, value_embedded_offset (whole) + offset, type_length_units (type)); } - v->offset = value_offset (whole) + offset + value_embedded_offset (whole); + v->m_offset = value_offset (whole) + offset + value_embedded_offset (whole); set_value_component_location (v, whole); return v; @@ -3983,7 +3983,7 @@ using_struct_return (struct gdbarch *gdbarch, void set_value_initialized (struct value *val, int status) { - val->initialized = status; + val->m_initialized = status; } /* Return the initialized field in a value struct. */ @@ -3991,7 +3991,7 @@ set_value_initialized (struct value *val, int status) int value_initialized (const struct value *val) { - return val->initialized; + return val->m_initialized; } /* Helper for value_fetch_lazy when the value is a bitfield. */ @@ -4166,9 +4166,9 @@ value_fetch_lazy (struct value *val) /* A value is either lazy, or fully fetched. The availability/validity is only established as we try to fetch a value. */ - gdb_assert (val->optimized_out.empty ()); - gdb_assert (val->unavailable.empty ()); - if (val->is_zero) + gdb_assert (val->m_optimized_out.empty ()); + gdb_assert (val->m_unavailable.empty ()); + if (val->m_is_zero) { /* Nothing. */ } From patchwork Thu Feb 9 21:38:23 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tom Tromey X-Patchwork-Id: 64555 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 2327138493C9 for ; Thu, 9 Feb 2023 21:38:57 +0000 (GMT) X-Original-To: gdb-patches@sourceware.org Delivered-To: gdb-patches@sourceware.org Received: from gproxy3-pub.mail.unifiedlayer.com (gproxy3-pub.mail.unifiedlayer.com [69.89.30.42]) by sourceware.org (Postfix) with ESMTPS id A036D3858C62 for ; Thu, 9 Feb 2023 21:38:40 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org A036D3858C62 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 cmgw13.mail.unifiedlayer.com (unknown [10.0.90.128]) by progateway5.mail.pro1.eigbox.com (Postfix) with ESMTP id 0F1FF1007382B for ; Thu, 9 Feb 2023 21:38:40 +0000 (UTC) Received: from box5379.bluehost.com ([162.241.216.53]) by cmsmtp with ESMTP id QEcqpHubRNX2aQEcqp2uAp; Thu, 09 Feb 2023 21:38:40 +0000 X-Authority-Reason: nr=8 X-Authority-Analysis: v=2.4 cv=NMAQR22g c=1 sm=1 tr=0 ts=63e567e0 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=colIY8sBCCN7oWIv2nYA: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=vMqq6CCZjRreEo1KW3Ohn+JV5ydlIr8jaOplFuE2E4E=; b=QyJ9zTnMxZZwOsDmZ1y30AiddV tlho9Abg6qredGE6kejM+7tFAksOWidIT1+pdGL1HRByYLP23zGPRwpUB9MqvZMJ/wgWd0EjgkyvH 0b/b8QwOpCUl1BH6IfvtlByx5; 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 1pQEcp-001ZcE-S4 for gdb-patches@sourceware.org; Thu, 09 Feb 2023 14:38:39 -0700 From: Tom Tromey Date: Thu, 09 Feb 2023 14:38:23 -0700 Subject: [PATCH 02/47] Move ~value body out-of-line MIME-Version: 1.0 Message-Id: <20230209-submit-value-fixups-2023-v1-2-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: 1pQEcp-001ZcE-S4 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: 3 X-Source-Cap: ZWx5bnJvYmk7ZWx5bnJvYmk7Ym94NTM3OS5ibHVlaG9zdC5jb20= X-Local-Domain: yes X-Spam-Status: No, score=-3027.2 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" struct value is going to move to value.h, but to avoid having excessive code there, first move the destructor body out-of-line. --- gdb/value.c | 26 ++++++++++++++------------ 1 file changed, 14 insertions(+), 12 deletions(-) diff --git a/gdb/value.c b/gdb/value.c index c998a516a0f..b5e5a46573d 100644 --- a/gdb/value.c +++ b/gdb/value.c @@ -190,18 +190,7 @@ struct value { } - ~value () - { - if (VALUE_LVAL (this) == lval_computed) - { - const struct lval_funcs *funcs = m_location.computed.funcs; - - if (funcs->free_closure) - funcs->free_closure (this); - } - else if (VALUE_LVAL (this) == lval_xcallable) - delete m_location.xm_worker; - } + ~value (); DISABLE_COPY_AND_ASSIGN (value); @@ -371,6 +360,19 @@ struct value std::vector m_optimized_out; }; +value::~value () +{ + if (VALUE_LVAL (this) == lval_computed) + { + const struct lval_funcs *funcs = m_location.computed.funcs; + + if (funcs->free_closure) + funcs->free_closure (this); + } + else if (VALUE_LVAL (this) == lval_xcallable) + delete m_location.xm_worker; +} + /* See value.h. */ struct gdbarch * From patchwork Thu Feb 9 21:38:24 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tom Tromey X-Patchwork-Id: 64583 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 E51B13888C7C for ; Thu, 9 Feb 2023 21:43:03 +0000 (GMT) X-Original-To: gdb-patches@sourceware.org Delivered-To: gdb-patches@sourceware.org Received: from qproxy6-pub.mail.unifiedlayer.com (qproxy6-pub.mail.unifiedlayer.com [69.89.23.12]) by sourceware.org (Postfix) with ESMTPS id 48F6F384B02A for ; Thu, 9 Feb 2023 21:39:12 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 48F6F384B02A 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 gproxy1-pub.mail.unifiedlayer.com (unknown [69.89.25.95]) by qproxy6.mail.unifiedlayer.com (Postfix) with ESMTP id 5DE2C803428D for ; Thu, 9 Feb 2023 21:39:10 +0000 (UTC) Received: from cmgw10.mail.unifiedlayer.com (unknown [10.0.90.125]) by progateway3.mail.pro1.eigbox.com (Postfix) with ESMTP id 51F9A10046FD8 for ; Thu, 9 Feb 2023 21:38:40 +0000 (UTC) Received: from box5379.bluehost.com ([162.241.216.53]) by cmsmtp with ESMTP id QEcqpwJueOscKQEcqpW9DL; Thu, 09 Feb 2023 21:38:40 +0000 X-Authority-Reason: nr=8 X-Authority-Analysis: v=2.4 cv=Y5c9DjSN c=1 sm=1 tr=0 ts=63e567e0 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=aQERtVHYdmW6PhkYK8UA:9 a=8eK45udfRx268ukT:21 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=B3eUXeQguPe8hUk6K1v+lfsgUadPpveayuOL0cGMIUI=; b=pqu1GTtoxX7m+sC0Ud7uR1fGs9 oIT2tCL4P8K1g/9lkZSQ3HNC3AVfpDpQ572yNTtEl1BugKdUvTEYAXqkma4dg+JgxTvEVgQGoJuLX OGMNk2XV3pV5xEH9ifRRqHrKd; 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 1pQEcq-001ZcE-0J for gdb-patches@sourceware.org; Thu, 09 Feb 2023 14:38:40 -0700 From: Tom Tromey Date: Thu, 09 Feb 2023 14:38:24 -0700 Subject: [PATCH 03/47] Move struct value to value.h MIME-Version: 1.0 Message-Id: <20230209-submit-value-fixups-2023-v1-3-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: 1pQEcq-001ZcE-0J 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: 4 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 moves struct value to value.h. For now, all members remain public, but this is a temporary state -- by the end of the series we'll add 'private'. --- gdb/value.c | 213 ----------------------------------------------------------- gdb/value.h | 216 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++-- 2 files changed, 211 insertions(+), 218 deletions(-) diff --git a/gdb/value.c b/gdb/value.c index b5e5a46573d..7ba46e20e7b 100644 --- a/gdb/value.c +++ b/gdb/value.c @@ -66,33 +66,6 @@ struct internal_function void *cookie; }; -/* Defines an [OFFSET, OFFSET + LENGTH) range. */ - -struct range -{ - /* Lowest offset in the range. */ - LONGEST offset; - - /* Length of the range. */ - LONGEST length; - - /* Returns true if THIS is strictly less than OTHER, useful for - searching. We keep ranges sorted by offset and coalesce - overlapping and contiguous ranges, so this just compares the - starting offset. */ - - bool operator< (const range &other) const - { - return offset < other.offset; - } - - /* Returns true if THIS is equal to OTHER. */ - bool operator== (const range &other) const - { - return offset == other.offset && length == other.length; - } -}; - /* Returns true if the ranges defined by [offset1, offset1+len1) and [offset2, offset2+len2) overlap. */ @@ -174,192 +147,6 @@ ranges_contain (const std::vector &ranges, LONGEST offset, static struct cmd_list_element *functionlist; -/* Note that the fields in this structure are arranged to save a bit - of memory. */ - -struct value -{ - explicit value (struct type *type_) - : m_modifiable (1), - m_lazy (1), - m_initialized (1), - m_stack (0), - m_is_zero (false), - m_type (type_), - m_enclosing_type (type_) - { - } - - ~value (); - - DISABLE_COPY_AND_ASSIGN (value); - - /* Type of value; either not an lval, or one of the various - different possible kinds of lval. */ - enum lval_type m_lval = not_lval; - - /* Is it modifiable? Only relevant if lval != not_lval. */ - unsigned int m_modifiable : 1; - - /* If zero, contents of this value are in the contents field. If - nonzero, contents are in inferior. If the lval field is lval_memory, - the contents are in inferior memory at location.address plus offset. - The lval field may also be lval_register. - - WARNING: This field is used by the code which handles watchpoints - (see breakpoint.c) to decide whether a particular value can be - watched by hardware watchpoints. If the lazy flag is set for - some member of a value chain, it is assumed that this member of - the chain doesn't need to be watched as part of watching the - value itself. This is how GDB avoids watching the entire struct - or array when the user wants to watch a single struct member or - array element. If you ever change the way lazy flag is set and - reset, be sure to consider this use as well! */ - unsigned int m_lazy : 1; - - /* If value is a variable, is it initialized or not. */ - unsigned int m_initialized : 1; - - /* If value is from the stack. If this is set, read_stack will be - used instead of read_memory to enable extra caching. */ - unsigned int m_stack : 1; - - /* True if this is a zero value, created by 'value_zero'; false - otherwise. */ - bool m_is_zero : 1; - - /* Location of value (if lval). */ - union - { - /* If lval == lval_memory, this is the address in the inferior */ - CORE_ADDR address; - - /*If lval == lval_register, the value is from a register. */ - struct - { - /* Register number. */ - int regnum; - /* Frame ID of "next" frame to which a register value is relative. - If the register value is found relative to frame F, then the - frame id of F->next will be stored in next_frame_id. */ - struct frame_id next_frame_id; - } reg; - - /* Pointer to internal variable. */ - struct internalvar *internalvar; - - /* Pointer to xmethod worker. */ - struct xmethod_worker *xm_worker; - - /* If lval == lval_computed, this is a set of function pointers - to use to access and describe the value, and a closure pointer - for them to use. */ - struct - { - /* Functions to call. */ - const struct lval_funcs *funcs; - - /* Closure for those functions to use. */ - void *closure; - } computed; - } m_location {}; - - /* Describes offset of a value within lval of a structure in target - addressable memory units. Note also the member embedded_offset - below. */ - LONGEST m_offset = 0; - - /* Only used for bitfields; number of bits contained in them. */ - LONGEST m_bitsize = 0; - - /* Only used for bitfields; position of start of field. For - little-endian targets, it is the position of the LSB. For - big-endian targets, it is the position of the MSB. */ - LONGEST m_bitpos = 0; - - /* The number of references to this value. When a value is created, - the value chain holds a reference, so REFERENCE_COUNT is 1. If - release_value is called, this value is removed from the chain but - the caller of release_value now has a reference to this value. - The caller must arrange for a call to value_free later. */ - int m_reference_count = 1; - - /* Only used for bitfields; the containing value. This allows a - single read from the target when displaying multiple - bitfields. */ - value_ref_ptr m_parent; - - /* Type of the value. */ - struct type *m_type; - - /* If a value represents a C++ object, then the `type' field gives - the object's compile-time type. If the object actually belongs - to some class derived from `type', perhaps with other base - classes and additional members, then `type' is just a subobject - of the real thing, and the full object is probably larger than - `type' would suggest. - - If `type' is a dynamic class (i.e. one with a vtable), then GDB - can actually determine the object's run-time type by looking at - the run-time type information in the vtable. When this - information is available, we may elect to read in the entire - object, for several reasons: - - - When printing the value, the user would probably rather see the - full object, not just the limited portion apparent from the - compile-time type. - - - If `type' has virtual base classes, then even printing `type' - alone may require reaching outside the `type' portion of the - object to wherever the virtual base class has been stored. - - When we store the entire object, `enclosing_type' is the run-time - type -- the complete object -- and `embedded_offset' is the - offset of `type' within that larger type, in target addressable memory - units. The value_contents() macro takes `embedded_offset' into account, - so most GDB code continues to see the `type' portion of the value, just - as the inferior would. - - If `type' is a pointer to an object, then `enclosing_type' is a - pointer to the object's run-time type, and `pointed_to_offset' is - the offset in target addressable memory units from the full object - to the pointed-to object -- that is, the value `embedded_offset' would - have if we followed the pointer and fetched the complete object. - (I don't really see the point. Why not just determine the - run-time type when you indirect, and avoid the special case? The - contents don't matter until you indirect anyway.) - - If we're not doing anything fancy, `enclosing_type' is equal to - `type', and `embedded_offset' is zero, so everything works - normally. */ - struct type *m_enclosing_type; - LONGEST m_embedded_offset = 0; - LONGEST m_pointed_to_offset = 0; - - /* Actual contents of the value. Target byte-order. - - May be nullptr if the value is lazy or is entirely optimized out. - Guaranteed to be non-nullptr otherwise. */ - gdb::unique_xmalloc_ptr m_contents; - - /* Unavailable ranges in CONTENTS. We mark unavailable ranges, - rather than available, since the common and default case is for a - value to be available. This is filled in at value read time. - The unavailable ranges are tracked in bits. Note that a contents - bit that has been optimized out doesn't really exist in the - program, so it can't be marked unavailable either. */ - std::vector m_unavailable; - - /* Likewise, but for optimized out contents (a chunk of the value of - a variable that does not actually exist in the program). If LVAL - is lval_register, this is a register ($pc, $sp, etc., never a - program variable) that has not been saved in the frame. Not - saved registers and optimized-out program variables values are - treated pretty much the same, except not-saved registers have a - different string representation and related error strings. */ - std::vector m_optimized_out; -}; - value::~value () { if (VALUE_LVAL (this) == lval_computed) diff --git a/gdb/value.h b/gdb/value.h index f022510ded1..ea549a8cb81 100644 --- a/gdb/value.h +++ b/gdb/value.h @@ -84,12 +84,32 @@ struct value_print_options; extern bool overload_resolution; -/* The structure which defines the type of a value. It should never - be possible for a program lval value to survive over a call to the - inferior (i.e. to be put into the history list or an internal - variable). */ +/* Defines an [OFFSET, OFFSET + LENGTH) range. */ -struct value; +struct range +{ + /* Lowest offset in the range. */ + LONGEST offset; + + /* Length of the range. */ + LONGEST length; + + /* Returns true if THIS is strictly less than OTHER, useful for + searching. We keep ranges sorted by offset and coalesce + overlapping and contiguous ranges, so this just compares the + starting offset. */ + + bool operator< (const range &other) const + { + return offset < other.offset; + } + + /* Returns true if THIS is equal to OTHER. */ + bool operator== (const range &other) const + { + return offset == other.offset && length == other.length; + } +}; /* Increase VAL's reference count. */ @@ -119,6 +139,192 @@ struct value_ref_policy typedef gdb::ref_ptr value_ref_ptr; +/* Note that the fields in this structure are arranged to save a bit + of memory. */ + +struct value +{ + explicit value (struct type *type_) + : m_modifiable (1), + m_lazy (1), + m_initialized (1), + m_stack (0), + m_is_zero (false), + m_type (type_), + m_enclosing_type (type_) + { + } + + ~value (); + + DISABLE_COPY_AND_ASSIGN (value); + + /* Type of value; either not an lval, or one of the various + different possible kinds of lval. */ + enum lval_type m_lval = not_lval; + + /* Is it modifiable? Only relevant if lval != not_lval. */ + unsigned int m_modifiable : 1; + + /* If zero, contents of this value are in the contents field. If + nonzero, contents are in inferior. If the lval field is lval_memory, + the contents are in inferior memory at location.address plus offset. + The lval field may also be lval_register. + + WARNING: This field is used by the code which handles watchpoints + (see breakpoint.c) to decide whether a particular value can be + watched by hardware watchpoints. If the lazy flag is set for + some member of a value chain, it is assumed that this member of + the chain doesn't need to be watched as part of watching the + value itself. This is how GDB avoids watching the entire struct + or array when the user wants to watch a single struct member or + array element. If you ever change the way lazy flag is set and + reset, be sure to consider this use as well! */ + unsigned int m_lazy : 1; + + /* If value is a variable, is it initialized or not. */ + unsigned int m_initialized : 1; + + /* If value is from the stack. If this is set, read_stack will be + used instead of read_memory to enable extra caching. */ + unsigned int m_stack : 1; + + /* True if this is a zero value, created by 'value_zero'; false + otherwise. */ + bool m_is_zero : 1; + + /* Location of value (if lval). */ + union + { + /* If lval == lval_memory, this is the address in the inferior */ + CORE_ADDR address; + + /*If lval == lval_register, the value is from a register. */ + struct + { + /* Register number. */ + int regnum; + /* Frame ID of "next" frame to which a register value is relative. + If the register value is found relative to frame F, then the + frame id of F->next will be stored in next_frame_id. */ + struct frame_id next_frame_id; + } reg; + + /* Pointer to internal variable. */ + struct internalvar *internalvar; + + /* Pointer to xmethod worker. */ + struct xmethod_worker *xm_worker; + + /* If lval == lval_computed, this is a set of function pointers + to use to access and describe the value, and a closure pointer + for them to use. */ + struct + { + /* Functions to call. */ + const struct lval_funcs *funcs; + + /* Closure for those functions to use. */ + void *closure; + } computed; + } m_location {}; + + /* Describes offset of a value within lval of a structure in target + addressable memory units. Note also the member embedded_offset + below. */ + LONGEST m_offset = 0; + + /* Only used for bitfields; number of bits contained in them. */ + LONGEST m_bitsize = 0; + + /* Only used for bitfields; position of start of field. For + little-endian targets, it is the position of the LSB. For + big-endian targets, it is the position of the MSB. */ + LONGEST m_bitpos = 0; + + /* The number of references to this value. When a value is created, + the value chain holds a reference, so REFERENCE_COUNT is 1. If + release_value is called, this value is removed from the chain but + the caller of release_value now has a reference to this value. + The caller must arrange for a call to value_free later. */ + int m_reference_count = 1; + + /* Only used for bitfields; the containing value. This allows a + single read from the target when displaying multiple + bitfields. */ + value_ref_ptr m_parent; + + /* Type of the value. */ + struct type *m_type; + + /* If a value represents a C++ object, then the `type' field gives + the object's compile-time type. If the object actually belongs + to some class derived from `type', perhaps with other base + classes and additional members, then `type' is just a subobject + of the real thing, and the full object is probably larger than + `type' would suggest. + + If `type' is a dynamic class (i.e. one with a vtable), then GDB + can actually determine the object's run-time type by looking at + the run-time type information in the vtable. When this + information is available, we may elect to read in the entire + object, for several reasons: + + - When printing the value, the user would probably rather see the + full object, not just the limited portion apparent from the + compile-time type. + + - If `type' has virtual base classes, then even printing `type' + alone may require reaching outside the `type' portion of the + object to wherever the virtual base class has been stored. + + When we store the entire object, `enclosing_type' is the run-time + type -- the complete object -- and `embedded_offset' is the + offset of `type' within that larger type, in target addressable memory + units. The value_contents() macro takes `embedded_offset' into account, + so most GDB code continues to see the `type' portion of the value, just + as the inferior would. + + If `type' is a pointer to an object, then `enclosing_type' is a + pointer to the object's run-time type, and `pointed_to_offset' is + the offset in target addressable memory units from the full object + to the pointed-to object -- that is, the value `embedded_offset' would + have if we followed the pointer and fetched the complete object. + (I don't really see the point. Why not just determine the + run-time type when you indirect, and avoid the special case? The + contents don't matter until you indirect anyway.) + + If we're not doing anything fancy, `enclosing_type' is equal to + `type', and `embedded_offset' is zero, so everything works + normally. */ + struct type *m_enclosing_type; + LONGEST m_embedded_offset = 0; + LONGEST m_pointed_to_offset = 0; + + /* Actual contents of the value. Target byte-order. + + May be nullptr if the value is lazy or is entirely optimized out. + Guaranteed to be non-nullptr otherwise. */ + gdb::unique_xmalloc_ptr m_contents; + + /* Unavailable ranges in CONTENTS. We mark unavailable ranges, + rather than available, since the common and default case is for a + value to be available. This is filled in at value read time. + The unavailable ranges are tracked in bits. Note that a contents + bit that has been optimized out doesn't really exist in the + program, so it can't be marked unavailable either. */ + std::vector m_unavailable; + + /* Likewise, but for optimized out contents (a chunk of the value of + a variable that does not actually exist in the program). If LVAL + is lval_register, this is a register ($pc, $sp, etc., never a + program variable) that has not been saved in the frame. Not + saved registers and optimized-out program variables values are + treated pretty much the same, except not-saved registers have a + different string representation and related error strings. */ + std::vector m_optimized_out; +}; + /* Type of the value. */ extern struct type *value_type (const struct value *); From patchwork Thu Feb 9 21:38:25 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tom Tromey X-Patchwork-Id: 64574 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 0356538A8144 for ; Thu, 9 Feb 2023 21:41:33 +0000 (GMT) X-Original-To: gdb-patches@sourceware.org Delivered-To: gdb-patches@sourceware.org Received: from gproxy2-pub.mail.unifiedlayer.com (gproxy2-pub.mail.unifiedlayer.com [69.89.18.3]) by sourceware.org (Postfix) with ESMTPS id 691CA3858409 for ; Thu, 9 Feb 2023 21:38:41 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 691CA3858409 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 progateway4.mail.pro1.eigbox.com (Postfix) with ESMTP id C389A10047E17 for ; Thu, 9 Feb 2023 21:38:40 +0000 (UTC) Received: from box5379.bluehost.com ([162.241.216.53]) by cmsmtp with ESMTP id QEcqpzBNvP796QEcqpwoVS; Thu, 09 Feb 2023 21:38:40 +0000 X-Authority-Reason: nr=8 X-Authority-Analysis: v=2.4 cv=MJClJOVl c=1 sm=1 tr=0 ts=63e567e0 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=dm5Ik-oYWhz3xSF40sgA:9 a=40xwrXXj49O_YKHv:21 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=LKh/0s4Kyowcj6KrajKW4vuSfaYAbgIjrK12IYk3TAg=; b=VomBOjuxlVLoMISrx95wXXe8gm 7fzzKZARZfLer5vW2dfJjP+J/O7tqKgbs67cxyTBP66d8JCwKSZbTWNY28nHOOlnO+xcmRhIk9hT2 lAqVemf7TYtBkTT8RnjTod+iS; 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 1pQEcq-001ZcE-4p for gdb-patches@sourceware.org; Thu, 09 Feb 2023 14:38:40 -0700 From: Tom Tromey Date: Thu, 09 Feb 2023 14:38:25 -0700 Subject: [PATCH 04/47] Turn value_type into method MIME-Version: 1.0 Message-Id: <20230209-submit-value-fixups-2023-v1-4-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: 1pQEcq-001ZcE-4p 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: 5 X-Source-Cap: ZWx5bnJvYmk7ZWx5bnJvYmk7Ym94NTM3OS5ibHVlaG9zdC5jb20= X-Local-Domain: yes X-Spam-Status: No, score=-3025.5 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, GIT_PATCH_0, JMQ_SPF_NEUTRAL, RCVD_IN_BL_SPAMCOP_NET, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2, SPF_HELO_NONE, SPF_PASS, TXREP, T_FILL_THIS_FORM_SHORT 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_type to be a method of value. Much of this patch was written by script. --- gdb/aarch64-tdep.c | 6 +- gdb/ada-exp.h | 4 +- gdb/ada-exp.y | 4 +- gdb/ada-lang.c | 302 +++++++++++++++++++++---------------------- gdb/ada-tasks.c | 4 +- gdb/ada-valprint.c | 34 ++--- gdb/ada-varobj.c | 12 +- gdb/alpha-tdep.c | 2 +- gdb/amd64-tdep.c | 10 +- gdb/amd64-windows-tdep.c | 10 +- gdb/arc-tdep.c | 4 +- gdb/arm-tdep.c | 6 +- gdb/avr-tdep.c | 2 +- gdb/ax-gdb.c | 8 +- gdb/breakpoint.c | 14 +- gdb/c-exp.h | 2 +- gdb/c-lang.c | 2 +- gdb/c-valprint.c | 18 +-- gdb/c-varobj.c | 2 +- gdb/cli/cli-cmds.c | 2 +- gdb/cli/cli-dump.c | 4 +- gdb/cli/cli-utils.c | 4 +- gdb/cp-abi.c | 2 +- gdb/cp-valprint.c | 6 +- gdb/cris-tdep.c | 2 +- gdb/csky-tdep.c | 2 +- gdb/d-valprint.c | 4 +- gdb/darwin-nat-info.c | 2 +- gdb/dtrace-probe.c | 2 +- gdb/dwarf2/expr.c | 76 +++++------ gdb/dwarf2/loc.c | 2 +- gdb/eval.c | 138 ++++++++++---------- gdb/expop.h | 12 +- gdb/f-lang.c | 114 ++++++++-------- gdb/f-valprint.c | 2 +- gdb/findcmd.c | 2 +- gdb/findvar.c | 4 +- gdb/frame.c | 4 +- gdb/frv-tdep.c | 4 +- gdb/gdbtypes.c | 6 +- gdb/gdbtypes.h | 2 +- gdb/gnu-v2-abi.c | 12 +- gdb/gnu-v3-abi.c | 26 ++-- gdb/go-valprint.c | 2 +- gdb/guile/scm-math.c | 10 +- gdb/guile/scm-pretty-print.c | 2 +- gdb/guile/scm-value.c | 22 ++-- gdb/h8300-tdep.c | 4 +- gdb/hppa-tdep.c | 4 +- gdb/i386-tdep.c | 6 +- gdb/i386-windows-tdep.c | 2 +- gdb/ia64-tdep.c | 4 +- gdb/infcall.c | 6 +- gdb/infcmd.c | 4 +- gdb/infrun.c | 8 +- gdb/iq2000-tdep.c | 4 +- gdb/linespec.c | 2 +- gdb/lm32-tdep.c | 2 +- gdb/loongarch-tdep.c | 4 +- gdb/m2-lang.c | 10 +- gdb/m2-valprint.c | 6 +- gdb/m32c-tdep.c | 4 +- gdb/m32r-tdep.c | 4 +- gdb/m68hc11-tdep.c | 4 +- gdb/mep-tdep.c | 6 +- gdb/mi/mi-cmd-stack.c | 4 +- gdb/mi/mi-main.c | 4 +- gdb/mips-tdep.c | 16 +-- gdb/mn10300-tdep.c | 8 +- gdb/msp430-tdep.c | 4 +- gdb/nds32-tdep.c | 6 +- gdb/nios2-tdep.c | 4 +- gdb/opencl-lang.c | 50 +++---- gdb/or1k-tdep.c | 8 +- gdb/p-exp.y | 6 +- gdb/p-valprint.c | 14 +- gdb/ppc-linux-nat.c | 4 +- gdb/ppc-sysv-tdep.c | 16 +-- gdb/printcmd.c | 44 +++---- gdb/python/py-framefilter.c | 8 +- gdb/python/py-inferior.c | 2 +- gdb/python/py-prettyprint.c | 2 +- gdb/python/py-unwind.c | 8 +- gdb/python/py-value.c | 34 ++--- gdb/python/py-xmethods.c | 4 +- gdb/regcache.c | 2 +- gdb/riscv-tdep.c | 8 +- gdb/rs6000-aix-tdep.c | 6 +- gdb/rs6000-lynx178-tdep.c | 6 +- gdb/rust-lang.c | 56 ++++---- gdb/rx-tdep.c | 4 +- gdb/s390-tdep.c | 4 +- gdb/sh-tdep.c | 14 +- gdb/sparc-tdep.c | 4 +- gdb/sparc64-tdep.c | 4 +- gdb/stack.c | 12 +- gdb/tic6x-tdep.c | 6 +- gdb/typeprint.c | 6 +- gdb/v850-tdep.c | 10 +- gdb/valarith.c | 96 +++++++------- gdb/valops.c | 126 +++++++++--------- gdb/valprint.c | 30 ++--- gdb/value.c | 85 ++++++------ gdb/value.h | 9 +- gdb/varobj.c | 12 +- gdb/windows-tdep.c | 2 +- gdb/xtensa-tdep.c | 4 +- 107 files changed, 874 insertions(+), 878 deletions(-) diff --git a/gdb/aarch64-tdep.c b/gdb/aarch64-tdep.c index ea93e9ad0d2..058d5bfce85 100644 --- a/gdb/aarch64-tdep.c +++ b/gdb/aarch64-tdep.c @@ -1800,7 +1800,7 @@ pass_in_v_vfp_candidate (struct gdbarch *gdbarch, struct regcache *regcache, continue; struct value *field = value_primitive_field (arg, 0, i, arg_type); - struct type *field_type = check_typedef (value_type (field)); + struct type *field_type = check_typedef (field->type ()); if (!pass_in_v_vfp_candidate (gdbarch, regcache, info, field_type, field)) @@ -1875,7 +1875,7 @@ aarch64_push_dummy_call (struct gdbarch *gdbarch, struct value *function, struct type *arg_type, *fundamental_type; int len, elements; - arg_type = check_typedef (value_type (arg)); + arg_type = check_typedef (arg->type ()); len = arg_type->length (); /* If arg can be passed in v registers as per the AAPCS64, then do so if @@ -2767,7 +2767,7 @@ aarch64_pseudo_read_value_1 (struct gdbarch *gdbarch, if (regcache->raw_read (v_regnum, reg_buf) != REG_VALID) mark_value_bytes_unavailable (result_value, 0, - value_type (result_value)->length ()); + result_value->type ()->length ()); else memcpy (value_contents_raw (result_value).data (), reg_buf, regsize); diff --git a/gdb/ada-exp.h b/gdb/ada-exp.h index 36ac3aaddb7..7e59267192a 100644 --- a/gdb/ada-exp.h +++ b/gdb/ada-exp.h @@ -249,7 +249,7 @@ class ada_binop_equal_operation enum noside noside) override { value *arg1 = std::get<1> (m_storage)->evaluate (nullptr, exp, noside); - value *arg2 = std::get<2> (m_storage)->evaluate (value_type (arg1), + value *arg2 = std::get<2> (m_storage)->evaluate (arg1->type (), exp, noside); return ada_equal_binop (expect_type, exp, noside, std::get<0> (m_storage), arg1, arg2); @@ -275,7 +275,7 @@ class ada_bitwise_operation value *lhs = std::get<0> (m_storage)->evaluate (nullptr, exp, noside); value *rhs = std::get<1> (m_storage)->evaluate (nullptr, exp, noside); value *result = eval_op_binary (expect_type, exp, noside, OP, lhs, rhs); - return value_cast (value_type (lhs), result); + return value_cast (lhs->type (), result); } enum exp_opcode opcode () const override diff --git a/gdb/ada-exp.y b/gdb/ada-exp.y index 2f466e4de0a..5436585b73b 100644 --- a/gdb/ada-exp.y +++ b/gdb/ada-exp.y @@ -303,7 +303,7 @@ ada_funcall (int nargs) struct value *callee_v = callee->evaluate (nullptr, pstate->expout.get (), EVAL_AVOID_SIDE_EFFECTS); - callee_t = ada_check_typedef (value_type (callee_v)); + callee_t = ada_check_typedef (callee_v->type ()); array_arity = ada_array_arity (callee_t); } @@ -503,7 +503,7 @@ exp1 : exp = lhs->evaluate (nullptr, pstate->expout.get (), EVAL_AVOID_SIDE_EFFECTS); rhs = resolve (std::move (rhs), true, - value_type (lhs_val)); + lhs_val->type ()); pstate->push_new (std::move (lhs), std::move (rhs)); } diff --git a/gdb/ada-lang.c b/gdb/ada-lang.c index 3cd6f73f36f..da49149c56d 100644 --- a/gdb/ada-lang.c +++ b/gdb/ada-lang.c @@ -549,7 +549,7 @@ static struct value * coerce_unspec_val_to_type (struct value *val, struct type *type) { type = ada_check_typedef (type); - if (value_type (val) == type) + if (val->type () == type) return val; else { @@ -560,7 +560,7 @@ coerce_unspec_val_to_type (struct value *val, struct type *type) else if (value_lazy (val) /* Be careful not to make a lazy not_lval value. */ || (VALUE_LVAL (val) != not_lval - && type->length () > value_type (val)->length ())) + && type->length () > val->type ()->length ())) result = allocate_value_lazy (type); else { @@ -754,7 +754,7 @@ get_base_type (struct type *type) struct value * ada_get_decoded_value (struct value *value) { - struct type *type = ada_check_typedef (value_type (value)); + struct type *type = ada_check_typedef (value->type ()); if (ada_is_array_descriptor_type (type) || (ada_is_constrained_packed_array_type (type) @@ -1756,7 +1756,7 @@ thin_descriptor_type (struct type *type) static struct value * thin_data_pntr (struct value *val) { - struct type *type = ada_check_typedef (value_type (val)); + struct type *type = ada_check_typedef (val->type ()); struct type *data_type = desc_data_target_type (thin_descriptor_type (type)); data_type = lookup_pointer_type (data_type); @@ -1813,7 +1813,7 @@ desc_bounds_type (struct type *type) static struct value * desc_bounds (struct value *arr) { - struct type *type = ada_check_typedef (value_type (arr)); + struct type *type = ada_check_typedef (arr->type ()); if (is_thin_pntr (type)) { @@ -1841,7 +1841,7 @@ desc_bounds (struct value *arr) { struct value *p_bounds = value_struct_elt (&arr, {}, "P_BOUNDS", NULL, _("Bad GNAT array descriptor")); - struct type *p_bounds_type = value_type (p_bounds); + struct type *p_bounds_type = p_bounds->type (); if (p_bounds_type && p_bounds_type->code () == TYPE_CODE_PTR) @@ -1916,7 +1916,7 @@ desc_data_target_type (struct type *type) static struct value * desc_data (struct value *arr) { - struct type *type = value_type (arr); + struct type *type = arr->type (); if (is_thin_pntr (type)) return thin_data_pntr (arr); @@ -2105,20 +2105,20 @@ ada_is_bogus_array_descriptor (struct type *type) static struct type * ada_type_of_array (struct value *arr, int bounds) { - if (ada_is_constrained_packed_array_type (value_type (arr))) - return decode_constrained_packed_array_type (value_type (arr)); + if (ada_is_constrained_packed_array_type (arr->type ())) + return decode_constrained_packed_array_type (arr->type ()); - if (!ada_is_array_descriptor_type (value_type (arr))) - return value_type (arr); + if (!ada_is_array_descriptor_type (arr->type ())) + return arr->type (); if (!bounds) { struct type *array_type = - ada_check_typedef (desc_data_target_type (value_type (arr))); + ada_check_typedef (desc_data_target_type (arr->type ())); - if (ada_is_unconstrained_packed_array_type (value_type (arr))) + if (ada_is_unconstrained_packed_array_type (arr->type ())) TYPE_FIELD_BITSIZE (array_type, 0) = - decode_packed_array_bitsize (value_type (arr)); + decode_packed_array_bitsize (arr->type ()); return array_type; } @@ -2128,29 +2128,29 @@ ada_type_of_array (struct value *arr, int bounds) int arity; struct value *descriptor; - elt_type = ada_array_element_type (value_type (arr), -1); - arity = ada_array_arity (value_type (arr)); + elt_type = ada_array_element_type (arr->type (), -1); + arity = ada_array_arity (arr->type ()); if (elt_type == NULL || arity == 0) - return ada_check_typedef (value_type (arr)); + return ada_check_typedef (arr->type ()); descriptor = desc_bounds (arr); if (value_as_long (descriptor) == 0) return NULL; while (arity > 0) { - struct type *range_type = alloc_type_copy (value_type (arr)); - struct type *array_type = alloc_type_copy (value_type (arr)); + struct type *range_type = alloc_type_copy (arr->type ()); + struct type *array_type = alloc_type_copy (arr->type ()); struct value *low = desc_one_bound (descriptor, arity, 0); struct value *high = desc_one_bound (descriptor, arity, 1); arity -= 1; - create_static_range_type (range_type, value_type (low), + create_static_range_type (range_type, low->type (), longest_to_int (value_as_long (low)), longest_to_int (value_as_long (high))); elt_type = create_array_type (array_type, elt_type, range_type); - if (ada_is_unconstrained_packed_array_type (value_type (arr))) + if (ada_is_unconstrained_packed_array_type (arr->type ())) { /* We need to store the element packed bitsize, as well as recompute the array size, because it was previously @@ -2159,7 +2159,7 @@ ada_type_of_array (struct value *arr, int bounds) LONGEST hi = value_as_long (high); TYPE_FIELD_BITSIZE (elt_type, 0) = - decode_packed_array_bitsize (value_type (arr)); + decode_packed_array_bitsize (arr->type ()); /* If the array has no element, then the size is already zero, and does not need to be recomputed. */ if (lo < hi) @@ -2184,7 +2184,7 @@ ada_type_of_array (struct value *arr, int bounds) struct value * ada_coerce_to_simple_array_ptr (struct value *arr) { - if (ada_is_array_descriptor_type (value_type (arr))) + if (ada_is_array_descriptor_type (arr->type ())) { struct type *arrType = ada_type_of_array (arr, 1); @@ -2192,7 +2192,7 @@ ada_coerce_to_simple_array_ptr (struct value *arr) return NULL; return value_cast (arrType, value_copy (desc_data (arr))); } - else if (ada_is_constrained_packed_array_type (value_type (arr))) + else if (ada_is_constrained_packed_array_type (arr->type ())) return decode_constrained_packed_array (arr); else return arr; @@ -2205,7 +2205,7 @@ ada_coerce_to_simple_array_ptr (struct value *arr) struct value * ada_coerce_to_simple_array (struct value *arr) { - if (ada_is_array_descriptor_type (value_type (arr))) + if (ada_is_array_descriptor_type (arr->type ())) { struct value *arrVal = ada_coerce_to_simple_array_ptr (arr); @@ -2213,7 +2213,7 @@ ada_coerce_to_simple_array (struct value *arr) error (_("Bounds unavailable for null array pointer.")); return value_ind (arrVal); } - else if (ada_is_constrained_packed_array_type (value_type (arr))) + else if (ada_is_constrained_packed_array_type (arr->type ())) return decode_constrained_packed_array (arr); else return arr; @@ -2501,10 +2501,10 @@ decode_constrained_packed_array (struct value *arr) and "value_ind" routines to perform the dereferencing, as opposed to using "ada_coerce_ref" or "ada_value_ind". */ arr = coerce_ref (arr); - if (ada_check_typedef (value_type (arr))->code () == TYPE_CODE_PTR) + if (ada_check_typedef (arr->type ())->code () == TYPE_CODE_PTR) arr = value_ind (arr); - type = decode_constrained_packed_array_type (value_type (arr)); + type = decode_constrained_packed_array_type (arr->type ()); if (type == NULL) { error (_("can't unpack array")); @@ -2523,8 +2523,8 @@ decode_constrained_packed_array (struct value *arr) type = resolve_dynamic_type (type, view, address); recursively_update_array_bitsize (type); - if (type_byte_order (value_type (arr)) == BFD_ENDIAN_BIG - && ada_is_modular_type (value_type (arr))) + if (type_byte_order (arr->type ()) == BFD_ENDIAN_BIG + && ada_is_modular_type (arr->type ())) { /* This is a (right-justified) modular type representing a packed array with no wrapper. In order to interpret the value through @@ -2533,14 +2533,14 @@ decode_constrained_packed_array (struct value *arr) int bit_size, bit_pos; ULONGEST mod; - mod = ada_modulus (value_type (arr)) - 1; + mod = ada_modulus (arr->type ()) - 1; bit_size = 0; while (mod > 0) { bit_size += 1; mod >>= 1; } - bit_pos = HOST_CHAR_BIT * value_type (arr)->length () - bit_size; + bit_pos = HOST_CHAR_BIT * arr->type ()->length () - bit_size; arr = ada_value_primitive_packed_val (arr, NULL, bit_pos / HOST_CHAR_BIT, bit_pos % HOST_CHAR_BIT, @@ -2566,7 +2566,7 @@ value_subscript_packed (struct value *arr, int arity, struct value **ind) bits = 0; elt_total_bit_offset = 0; - elt_type = ada_check_typedef (value_type (arr)); + elt_type = ada_check_typedef (arr->type ()); for (i = 0; i < arity; i += 1) { if (elt_type->code () != TYPE_CODE_ARRAY @@ -2877,15 +2877,15 @@ ada_value_primitive_packed_val (struct value *obj, const gdb_byte *valaddr, static struct value * ada_value_assign (struct value *toval, struct value *fromval) { - struct type *type = value_type (toval); + struct type *type = toval->type (); int bits = value_bitsize (toval); toval = ada_coerce_ref (toval); fromval = ada_coerce_ref (fromval); - if (ada_is_direct_array_type (value_type (toval))) + if (ada_is_direct_array_type (toval->type ())) toval = ada_coerce_to_simple_array (toval); - if (ada_is_direct_array_type (value_type (fromval))) + if (ada_is_direct_array_type (fromval->type ())) fromval = ada_coerce_to_simple_array (fromval); if (!deprecated_value_modifiable (toval)) @@ -2909,11 +2909,11 @@ ada_value_assign (struct value *toval, struct value *fromval) read_memory (to_addr, buffer, len); from_size = value_bitsize (fromval); if (from_size == 0) - from_size = value_type (fromval)->length () * TARGET_CHAR_BIT; + from_size = fromval->type ()->length () * TARGET_CHAR_BIT; const int is_big_endian = type_byte_order (type) == BFD_ENDIAN_BIG; ULONGEST from_offset = 0; - if (is_big_endian && is_scalar_type (value_type (fromval))) + if (is_big_endian && is_scalar_type (fromval->type ())) from_offset = from_size - bits; copy_bitwise (buffer, value_bitpos (toval), value_contents (fromval).data (), from_offset, @@ -2954,20 +2954,20 @@ value_assign_to_component (struct value *container, struct value *component, value_bitpos (component) - value_bitpos (container); int bits; - val = value_cast (value_type (component), val); + val = value_cast (component->type (), val); if (value_bitsize (component) == 0) - bits = TARGET_CHAR_BIT * value_type (component)->length (); + bits = TARGET_CHAR_BIT * component->type ()->length (); else bits = value_bitsize (component); - if (type_byte_order (value_type (container)) == BFD_ENDIAN_BIG) + if (type_byte_order (container->type ()) == BFD_ENDIAN_BIG) { int src_offset; - if (is_scalar_type (check_typedef (value_type (component)))) + if (is_scalar_type (check_typedef (component->type ()))) src_offset - = value_type (component)->length () * TARGET_CHAR_BIT - bits; + = component->type ()->length () * TARGET_CHAR_BIT - bits; else src_offset = 0; copy_bitwise ((value_contents_writeable (container).data () @@ -3004,7 +3004,7 @@ ada_value_subscript (struct value *arr, int arity, struct value **ind) elt = ada_coerce_to_simple_array (arr); - elt_type = ada_check_typedef (value_type (elt)); + elt_type = ada_check_typedef (elt->type ()); if (elt_type->code () == TYPE_CODE_ARRAY && TYPE_FIELD_BITSIZE (elt_type, 0) > 0) return value_subscript_packed (elt, arity, ind); @@ -3019,7 +3019,7 @@ ada_value_subscript (struct value *arr, int arity, struct value **ind) elt = value_subscript (elt, pos_atr (ind[k])); if (ada_is_access_to_unconstrained_array (saved_elt_type) - && value_type (elt)->code () != TYPE_CODE_TYPEDEF) + && elt->type ()->code () != TYPE_CODE_TYPEDEF) { /* The element is a typedef to an unconstrained array, except that the value_subscript call stripped the @@ -3036,7 +3036,7 @@ ada_value_subscript (struct value *arr, int arity, struct value **ind) deprecated_set_value_type (elt, saved_elt_type); } - elt_type = ada_check_typedef (value_type (elt)); + elt_type = ada_check_typedef (elt->type ()); } return elt; @@ -3124,7 +3124,7 @@ ada_value_slice_from_ptr (struct value *array_ptr, struct type *type, static struct value * ada_value_slice (struct value *array, int low, int high) { - struct type *type = ada_check_typedef (value_type (array)); + struct type *type = ada_check_typedef (array->type ()); struct type *base_index_type = type->index_type ()->target_type (); struct type *index_type = create_static_range_type (NULL, type->index_type (), low, high); @@ -3332,7 +3332,7 @@ ada_array_bound (struct value *arr, int n, int which) { struct type *arr_type; - if (check_typedef (value_type (arr))->code () == TYPE_CODE_PTR) + if (check_typedef (arr->type ())->code () == TYPE_CODE_PTR) arr = value_ind (arr); arr_type = value_enclosing_type (arr); @@ -3356,7 +3356,7 @@ ada_array_length (struct value *arr, int n) struct type *arr_type, *index_type; int low, high; - if (check_typedef (value_type (arr))->code () == TYPE_CODE_PTR) + if (check_typedef (arr->type ())->code () == TYPE_CODE_PTR) arr = value_ind (arr); arr_type = value_enclosing_type (arr); @@ -3984,7 +3984,7 @@ ada_args_match (struct symbol *func, struct value **actuals, int n_actuals) else { struct type *ftype = ada_check_typedef (func_type->field (i).type ()); - struct type *atype = ada_check_typedef (value_type (actuals[i])); + struct type *atype = ada_check_typedef (actuals[i]->type ()); if (!ada_type_match (ftype, atype)) return 0; @@ -4185,9 +4185,9 @@ static int possible_user_operator_p (enum exp_opcode op, struct value *args[]) { struct type *type0 = - (args[0] == NULL) ? NULL : ada_check_typedef (value_type (args[0])); + (args[0] == NULL) ? NULL : ada_check_typedef (args[0]->type ()); struct type *type1 = - (args[1] == NULL) ? NULL : ada_check_typedef (value_type (args[1])); + (args[1] == NULL) ? NULL : ada_check_typedef (args[1]->type ()); if (type0 == NULL) return 0; @@ -4352,7 +4352,7 @@ ensure_lval (struct value *val) if (VALUE_LVAL (val) == not_lval || VALUE_LVAL (val) == lval_internalvar) { - int len = ada_check_typedef (value_type (val))->length (); + int len = ada_check_typedef (val->type ())->length (); const CORE_ADDR addr = value_as_long (value_allocate_space_in_inferior (len)); @@ -4384,7 +4384,7 @@ ada_value_struct_elt (struct value *arg, const char *name, int no_err) int check_tag; v = NULL; - t1 = t = ada_check_typedef (value_type (arg)); + t1 = t = ada_check_typedef (arg->type ()); if (t->code () == TYPE_CODE_REF) { t1 = t->target_type (); @@ -4459,7 +4459,7 @@ ada_value_struct_elt (struct value *arg, const char *name, int no_err) /* Resolve the dynamic type as well. */ arg = value_from_contents_and_address (t1, nullptr, address); - t1 = value_type (arg); + t1 = arg->type (); if (find_struct_field (name, t1, 0, &field_type, &byte_offset, &bit_offset, @@ -4501,7 +4501,7 @@ ada_value_struct_elt (struct value *arg, const char *name, int no_err) struct value * ada_convert_actual (struct value *actual, struct type *formal_type0) { - struct type *actual_type = ada_check_typedef (value_type (actual)); + struct type *actual_type = ada_check_typedef (actual->type ()); struct type *formal_type = ada_check_typedef (formal_type0); struct type *formal_target = formal_type->code () == TYPE_CODE_PTR @@ -4527,7 +4527,7 @@ ada_convert_actual (struct value *actual, struct type *formal_type0) { struct value *val; - actual_type = ada_check_typedef (value_type (actual)); + actual_type = ada_check_typedef (actual->type ()); val = allocate_value (actual_type); copy (value_contents (actual), value_contents_raw (val)); actual = ensure_lval (val); @@ -4588,15 +4588,15 @@ make_array_descriptor (struct type *type, struct value *arr) struct value *bounds = allocate_value (bounds_type); int i; - for (i = ada_array_arity (ada_check_typedef (value_type (arr))); + for (i = ada_array_arity (ada_check_typedef (arr->type ())); i > 0; i -= 1) { - modify_field (value_type (bounds), + modify_field (bounds->type (), value_contents_writeable (bounds).data (), ada_array_bound (arr, i, 0), desc_bound_bitpos (bounds_type, i, 0), desc_bound_bitsize (bounds_type, i, 0)); - modify_field (value_type (bounds), + modify_field (bounds->type (), value_contents_writeable (bounds).data (), ada_array_bound (arr, i, 1), desc_bound_bitpos (bounds_type, i, 1), @@ -4605,14 +4605,14 @@ make_array_descriptor (struct type *type, struct value *arr) bounds = ensure_lval (bounds); - modify_field (value_type (descriptor), + modify_field (descriptor->type (), value_contents_writeable (descriptor).data (), value_pointer (ensure_lval (arr), desc_type->field (0).type ()), fat_pntr_data_bitpos (desc_type), fat_pntr_data_bitsize (desc_type)); - modify_field (value_type (descriptor), + modify_field (descriptor->type (), value_contents_writeable (descriptor).data (), value_pointer (bounds, desc_type->field (1).type ()), @@ -6361,7 +6361,7 @@ ada_is_tag_type (struct type *type) static struct type * ada_tag_type (struct value *val) { - return ada_lookup_struct_elt_type (value_type (val), "_tag", 1, 0); + return ada_lookup_struct_elt_type (val->type (), "_tag", 1, 0); } /* Return 1 if TAG follows the old scheme for Ada tags (used for Ada 95, @@ -6435,7 +6435,7 @@ ada_tag_value_at_base_address (struct value *obj) struct value *tag; CORE_ADDR base_address; - obj_type = value_type (obj); + obj_type = obj->type (); /* It is the responsability of the caller to deref pointers. */ @@ -6618,7 +6618,7 @@ ada_tag_name (struct value *tag) { gdb::unique_xmalloc_ptr name; - if (!ada_is_tag_type (value_type (tag))) + if (!ada_is_tag_type (tag->type ())) return NULL; /* It is perfectly possible that an exception be raised while trying @@ -7513,7 +7513,7 @@ ada_value_ind (struct value *val0) { struct value *val = value_ind (val0); - if (ada_is_tagged_type (value_type (val), 0)) + if (ada_is_tagged_type (val->type (), 0)) val = ada_tag_value_at_base_address (val); return ada_to_fixed_value (val); @@ -7525,13 +7525,13 @@ ada_value_ind (struct value *val0) static struct value * ada_coerce_ref (struct value *val0) { - if (value_type (val0)->code () == TYPE_CODE_REF) + if (val0->type ()->code () == TYPE_CODE_REF) { struct value *val = val0; val = coerce_ref (val); - if (ada_is_tagged_type (value_type (val), 0)) + if (ada_is_tagged_type (val->type (), 0)) val = ada_tag_value_at_base_address (val); return ada_to_fixed_value (val); @@ -7832,7 +7832,7 @@ empty_record (struct type *templ) the value of type TYPE at VALADDR or ADDRESS (see comments at the beginning of this section) VAL according to GNAT conventions. DVAL0 should describe the (portion of a) record that contains any - necessary discriminants. It should be NULL if value_type (VAL) is + necessary discriminants. It should be NULL if VAL->type () is an outer-level type (i.e., as opposed to a branch of a variant.) A variant field (unless unchecked) is replaced by a particular branch of the variant. @@ -7915,7 +7915,7 @@ ada_template_to_fixed_record_type_1 (struct type *type, dval = value_from_contents_and_address_unresolved (rtype, valaddr, address); - rtype = value_type (dval); + rtype = dval->type (); } else dval = dval0; @@ -8014,7 +8014,7 @@ ada_template_to_fixed_record_type_1 (struct type *type, that is currently being constructed. */ dval = value_from_contents_and_address_unresolved (rtype, valaddr, address); - rtype = value_type (dval); + rtype = dval->type (); } else dval = dval0; @@ -8175,7 +8175,7 @@ to_record_with_fixed_variant_part (struct type *type, const gdb_byte *valaddr, if (dval0 == NULL) { dval = value_from_contents_and_address (type, valaddr, address); - type = value_type (dval); + type = dval->type (); } else dval = dval0; @@ -8296,7 +8296,7 @@ to_fixed_variant_branch_type (struct type *var_type0, const gdb_byte *valaddr, if (templ_type != NULL) var_type = templ_type; - if (is_unchecked_variant (var_type, value_type (dval))) + if (is_unchecked_variant (var_type, dval->type ())) return var_type0; which = ada_which_variant_applies (var_type, dval); @@ -8587,7 +8587,7 @@ ada_to_fixed_type_1 (struct type *type, const gdb_byte *valaddr, value_from_contents_and_address (fixed_record_type, valaddr, address); - fixed_record_type = value_type (obj); + fixed_record_type = obj->type (); if (real_type != NULL) return to_fixed_record_type (real_type, NULL, @@ -8860,7 +8860,7 @@ struct value * ada_to_fixed_value (struct value *val) { val = unwrap_value (val); - val = ada_to_fixed_value_create (value_type (val), value_address (val), val); + val = ada_to_fixed_value_create (val->type (), value_address (val), val); return val; } @@ -8902,7 +8902,7 @@ static LONGEST pos_atr (struct value *arg) { struct value *val = coerce_ref (arg); - struct type *type = value_type (val); + struct type *type = val->type (); if (!discrete_type_p (type)) error (_("'POS only defined on discrete types")); @@ -8951,7 +8951,7 @@ ada_val_atr (enum noside noside, struct type *type, struct value *arg) if (!discrete_type_p (type)) error (_("'VAL only defined on discrete types")); - if (!integer_type_p (value_type (arg))) + if (!integer_type_p (arg->type ())) error (_("'VAL requires integral argument")); return val_atr (type, value_as_long (arg)); @@ -9199,12 +9199,12 @@ ada_enum_name (const char *name) static struct value * unwrap_value (struct value *val) { - struct type *type = ada_check_typedef (value_type (val)); + struct type *type = ada_check_typedef (val->type ()); if (ada_is_aligner_type (type)) { struct value *v = ada_value_struct_elt (val, "F", 0); - struct type *val_type = ada_check_typedef (value_type (v)); + struct type *val_type = ada_check_typedef (v->type ()); if (ada_type_name (val_type) == NULL) val_type->set_name (ada_type_name (type)); @@ -9273,10 +9273,10 @@ ada_promote_array_of_integrals (struct type *type, struct value *val) of type's element. */ gdb_assert (type->code () == TYPE_CODE_ARRAY); gdb_assert (is_integral_type (type->target_type ())); - gdb_assert (value_type (val)->code () == TYPE_CODE_ARRAY); - gdb_assert (is_integral_type (value_type (val)->target_type ())); + gdb_assert (val->type ()->code () == TYPE_CODE_ARRAY); + gdb_assert (is_integral_type (val->type ()->target_type ())); gdb_assert (type->target_type ()->length () - > value_type (val)->target_type ()->length ()); + > val->type ()->target_type ()->length ()); if (!get_array_bounds (type, &lo, &hi)) error (_("unable to determine array bounds")); @@ -9302,7 +9302,7 @@ ada_promote_array_of_integrals (struct type *type, struct value *val) static struct value * coerce_for_assign (struct type *type, struct value *val) { - struct type *type2 = value_type (val); + struct type *type2 = val->type (); if (type == type2) return val; @@ -9314,7 +9314,7 @@ coerce_for_assign (struct type *type, struct value *val) && type->code () == TYPE_CODE_ARRAY) { val = ada_value_ind (val); - type2 = value_type (val); + type2 = val->type (); } if (type2->code () == TYPE_CODE_ARRAY @@ -9348,8 +9348,8 @@ ada_value_binop (struct value *arg1, struct value *arg2, enum exp_opcode op) arg1 = coerce_ref (arg1); arg2 = coerce_ref (arg2); - type1 = get_base_type (ada_check_typedef (value_type (arg1))); - type2 = get_base_type (ada_check_typedef (value_type (arg2))); + type1 = get_base_type (ada_check_typedef (arg1->type ())); + type2 = get_base_type (ada_check_typedef (arg2->type ())); if (type1->code () != TYPE_CODE_INT || type2->code () != TYPE_CODE_INT) @@ -9405,7 +9405,7 @@ ada_value_binop (struct value *arg1, struct value *arg2, enum exp_opcode op) val = allocate_value (type1); store_unsigned_integer (value_contents_raw (val).data (), - value_type (val)->length (), + val->type ()->length (), type_byte_order (type1), v); return val; } @@ -9413,8 +9413,8 @@ ada_value_binop (struct value *arg1, struct value *arg2, enum exp_opcode op) static int ada_value_equal (struct value *arg1, struct value *arg2) { - if (ada_is_direct_array_type (value_type (arg1)) - || ada_is_direct_array_type (value_type (arg2))) + if (ada_is_direct_array_type (arg1->type ()) + || ada_is_direct_array_type (arg2->type ())) { struct type *arg1_type, *arg2_type; @@ -9426,8 +9426,8 @@ ada_value_equal (struct value *arg1, struct value *arg2) arg1 = ada_coerce_to_simple_array (arg1); arg2 = ada_coerce_to_simple_array (arg2); - arg1_type = ada_check_typedef (value_type (arg1)); - arg2_type = ada_check_typedef (value_type (arg2)); + arg1_type = ada_check_typedef (arg1->type ()); + arg2_type = ada_check_typedef (arg2->type ()); if (arg1_type->code () != TYPE_CODE_ARRAY || arg2_type->code () != TYPE_CODE_ARRAY) @@ -9465,7 +9465,7 @@ assign_component (struct value *container, struct value *lhs, LONGEST index, scoped_value_mark mark; struct value *elt; - struct type *lhs_type = check_typedef (value_type (lhs)); + struct type *lhs_type = check_typedef (lhs->type ()); if (lhs_type->code () == TYPE_CODE_ARRAY) { @@ -9476,7 +9476,7 @@ assign_component (struct value *container, struct value *lhs, LONGEST index, } else { - elt = ada_index_struct_field (index, lhs, 0, value_type (lhs)); + elt = ada_index_struct_field (index, lhs, 0, lhs->type ()); elt = ada_to_fixed_value (elt); } @@ -9528,17 +9528,17 @@ ada_aggregate_operation::assign_aggregate (struct value *container, LONGEST low_index, high_index; container = ada_coerce_ref (container); - if (ada_is_direct_array_type (value_type (container))) + if (ada_is_direct_array_type (container->type ())) container = ada_coerce_to_simple_array (container); lhs = ada_coerce_ref (lhs); if (!deprecated_value_modifiable (lhs)) error (_("Left operand of assignment is not a modifiable lvalue.")); - lhs_type = check_typedef (value_type (lhs)); + lhs_type = check_typedef (lhs->type ()); if (ada_is_direct_array_type (lhs_type)) { lhs = ada_coerce_to_simple_array (lhs); - lhs_type = check_typedef (value_type (lhs)); + lhs_type = check_typedef (lhs->type ()); low_index = lhs_type->bounds ()->low.const_val (); high_index = lhs_type->bounds ()->high.const_val (); } @@ -9654,7 +9654,7 @@ ada_name_association::assign (struct value *container, { int index; - if (ada_is_direct_array_type (value_type (lhs))) + if (ada_is_direct_array_type (lhs->type ())) index = longest_to_int (value_as_long (m_val->evaluate (nullptr, exp, EVAL_NORMAL))); else @@ -9675,7 +9675,7 @@ ada_name_association::assign (struct value *container, } index = 0; - if (! find_struct_field (name, value_type (lhs), 0, + if (! find_struct_field (name, lhs->type (), 0, NULL, NULL, NULL, NULL, &index)) error (_("Unknown component name: %s."), name); } @@ -9770,7 +9770,7 @@ ada_assign_operation::evaluate (struct type *expect_type, except if the lhs of our assignment is a convenience variable. In the case of assigning to a convenience variable, the lhs should be exactly the result of the evaluation of the rhs. */ - struct type *type = value_type (arg1); + struct type *type = arg1->type (); if (VALUE_LVAL (arg1) == lval_internalvar) type = NULL; value *arg2 = std::get<1> (m_storage)->evaluate (type, exp, noside); @@ -9781,7 +9781,7 @@ ada_assign_operation::evaluate (struct type *expect_type, /* Nothing. */ } else - arg2 = coerce_for_assign (value_type (arg1), arg2); + arg2 = coerce_for_assign (arg1->type (), arg2); return ada_value_assign (arg1, arg2); } @@ -9831,7 +9831,7 @@ add_component_interval (LONGEST low, LONGEST high, static struct value * ada_value_cast (struct type *type, struct value *arg2) { - if (type == ada_check_typedef (value_type (arg2))) + if (type == ada_check_typedef (arg2->type ())) return arg2; return value_cast (type, arg2); @@ -10177,7 +10177,7 @@ ada_atr_size (struct type *expect_type, enum noside noside, enum exp_opcode op, struct value *arg1) { - struct type *type = value_type (arg1); + struct type *type = arg1->type (); /* If the argument is a reference, then dereference its type, since the user is really asking for the size of the actual object, @@ -10201,7 +10201,7 @@ ada_abs (struct type *expect_type, struct value *arg1) { unop_promote (exp->language_defn, exp->gdbarch, &arg1); - if (value_less (arg1, value_zero (value_type (arg1), not_lval))) + if (value_less (arg1, value_zero (arg1->type (), not_lval))) return value_neg (arg1); else return arg1; @@ -10218,7 +10218,7 @@ ada_mult_binop (struct type *expect_type, if (noside == EVAL_AVOID_SIDE_EFFECTS) { binop_promote (exp->language_defn, exp->gdbarch, &arg1, &arg2); - return value_zero (value_type (arg1), not_lval); + return value_zero (arg1->type (), not_lval); } else { @@ -10267,24 +10267,24 @@ ada_ternop_slice (struct expression *exp, /* If this is a reference to an aligner type, then remove all the aligners. */ - if (value_type (array)->code () == TYPE_CODE_REF - && ada_is_aligner_type (value_type (array)->target_type ())) - value_type (array)->set_target_type - (ada_aligned_type (value_type (array)->target_type ())); + if (array->type ()->code () == TYPE_CODE_REF + && ada_is_aligner_type (array->type ()->target_type ())) + array->type ()->set_target_type + (ada_aligned_type (array->type ()->target_type ())); - if (ada_is_any_packed_array_type (value_type (array))) + if (ada_is_any_packed_array_type (array->type ())) error (_("cannot slice a packed array")); /* If this is a reference to an array or an array lvalue, convert to a pointer. */ - if (value_type (array)->code () == TYPE_CODE_REF - || (value_type (array)->code () == TYPE_CODE_ARRAY + if (array->type ()->code () == TYPE_CODE_REF + || (array->type ()->code () == TYPE_CODE_ARRAY && VALUE_LVAL (array) == lval_memory)) array = value_addr (array); if (noside == EVAL_AVOID_SIDE_EFFECTS && ada_is_array_descriptor_type (ada_check_typedef - (value_type (array)))) + (array->type ()))) return empty_array (ada_type_of_array (array, 0), low_bound, high_bound); @@ -10292,8 +10292,8 @@ ada_ternop_slice (struct expression *exp, /* If we have more than one level of pointer indirection, dereference the value until we get only one level. */ - while (value_type (array)->code () == TYPE_CODE_PTR - && (value_type (array)->target_type ()->code () + while (array->type ()->code () == TYPE_CODE_PTR + && (array->type ()->target_type ()->code () == TYPE_CODE_PTR)) array = value_ind (array); @@ -10301,13 +10301,13 @@ ada_ternop_slice (struct expression *exp, to avoid a SEGV when trying to get the index type or the target type later down the road if the debug info generated by the compiler is incorrect or incomplete. */ - if (!ada_is_simple_array_type (value_type (array))) + if (!ada_is_simple_array_type (array->type ())) error (_("cannot take slice of non-array")); - if (ada_check_typedef (value_type (array))->code () + if (ada_check_typedef (array->type ())->code () == TYPE_CODE_PTR) { - struct type *type0 = ada_check_typedef (value_type (array)); + struct type *type0 = ada_check_typedef (array->type ()); if (high_bound < low_bound || noside == EVAL_AVOID_SIDE_EFFECTS) return empty_array (type0->target_type (), low_bound, high_bound); @@ -10324,7 +10324,7 @@ ada_ternop_slice (struct expression *exp, else if (noside == EVAL_AVOID_SIDE_EFFECTS) return array; else if (high_bound < low_bound) - return empty_array (value_type (array), low_bound, high_bound); + return empty_array (array->type (), low_bound, high_bound); else return ada_value_slice (array, longest_to_int (low_bound), longest_to_int (high_bound)); @@ -10343,9 +10343,9 @@ ada_binop_in_bounds (struct expression *exp, enum noside noside, return value_zero (type, not_lval); } - struct type *type = ada_index_type (value_type (arg2), n, "range"); + struct type *type = ada_index_type (arg2->type (), n, "range"); if (!type) - type = value_type (arg1); + type = arg1->type (); value *arg3 = value_from_longest (type, ada_array_bound (arg2, n, 1)); arg2 = value_from_longest (type, ada_array_bound (arg2, n, 0)); @@ -10369,7 +10369,7 @@ ada_unop_atr (struct expression *exp, enum noside noside, enum exp_opcode op, if (noside == EVAL_AVOID_SIDE_EFFECTS) { if (type_arg == NULL) - type_arg = value_type (arg1); + type_arg = arg1->type (); if (ada_is_constrained_packed_array_type (type_arg)) type_arg = decode_constrained_packed_array_type (type_arg); @@ -10397,7 +10397,7 @@ ada_unop_atr (struct expression *exp, enum noside noside, enum exp_opcode op, { arg1 = ada_coerce_ref (arg1); - if (ada_is_constrained_packed_array_type (value_type (arg1))) + if (ada_is_constrained_packed_array_type (arg1->type ())) arg1 = ada_coerce_to_simple_array (arg1); struct type *type; @@ -10405,7 +10405,7 @@ ada_unop_atr (struct expression *exp, enum noside noside, enum exp_opcode op, type = builtin_type (exp->gdbarch)->builtin_int; else { - type = ada_index_type (value_type (arg1), tem, + type = ada_index_type (arg1->type (), tem, ada_attribute_name (op)); if (type == NULL) type = builtin_type (exp->gdbarch)->builtin_int; @@ -10496,7 +10496,7 @@ ada_binop_minmax (struct type *expect_type, struct value *arg1, struct value *arg2) { if (noside == EVAL_AVOID_SIDE_EFFECTS) - return value_zero (value_type (arg1), not_lval); + return value_zero (arg1->type (), not_lval); else { binop_promote (exp->language_defn, exp->gdbarch, &arg1, &arg2); @@ -10513,12 +10513,12 @@ ada_binop_exp (struct type *expect_type, struct value *arg1, struct value *arg2) { if (noside == EVAL_AVOID_SIDE_EFFECTS) - return value_zero (value_type (arg1), not_lval); + return value_zero (arg1->type (), not_lval); else { /* For integer exponentiation operations, only promote the first argument. */ - if (is_integral_type (value_type (arg2))) + if (is_integral_type (arg2->type ())) unop_promote (exp->language_defn, exp->gdbarch, &arg1); else binop_promote (exp->language_defn, exp->gdbarch, &arg1, &arg2); @@ -10723,12 +10723,12 @@ ada_concat_operation::evaluate (struct type *expect_type, if (dynamic_cast (lhs_expr.get ()) != nullptr) { rhs = rhs_expr->evaluate (nullptr, exp, noside); - lhs = lhs_expr->evaluate (value_type (rhs), exp, noside); + lhs = lhs_expr->evaluate (rhs->type (), exp, noside); } else if (dynamic_cast (lhs_expr.get ()) != nullptr) { rhs = rhs_expr->evaluate (nullptr, exp, noside); - struct type *rhs_type = check_typedef (value_type (rhs)); + struct type *rhs_type = check_typedef (rhs->type ()); struct type *elt_type = nullptr; if (rhs_type->code () == TYPE_CODE_ARRAY) elt_type = rhs_type->target_type (); @@ -10737,12 +10737,12 @@ ada_concat_operation::evaluate (struct type *expect_type, else if (dynamic_cast (rhs_expr.get ()) != nullptr) { lhs = lhs_expr->evaluate (nullptr, exp, noside); - rhs = rhs_expr->evaluate (value_type (lhs), exp, noside); + rhs = rhs_expr->evaluate (lhs->type (), exp, noside); } else if (dynamic_cast (rhs_expr.get ()) != nullptr) { lhs = lhs_expr->evaluate (nullptr, exp, noside); - struct type *lhs_type = check_typedef (value_type (lhs)); + struct type *lhs_type = check_typedef (lhs->type ()); struct type *elt_type = nullptr; if (lhs_type->code () == TYPE_CODE_ARRAY) elt_type = lhs_type->target_type (); @@ -10789,18 +10789,18 @@ ada_binop_addsub_operation::evaluate (struct type *expect_type, return x - y; }; - if (value_type (arg1)->code () == TYPE_CODE_PTR) + if (arg1->type ()->code () == TYPE_CODE_PTR) return (value_from_longest - (value_type (arg1), + (arg1->type (), do_op (value_as_long (arg1), value_as_long (arg2)))); - if (value_type (arg2)->code () == TYPE_CODE_PTR) + if (arg2->type ()->code () == TYPE_CODE_PTR) return (value_from_longest - (value_type (arg2), + (arg2->type (), do_op (value_as_long (arg1), value_as_long (arg2)))); /* Preserve the original type for use by the range case below. We cannot cast the result to a reference type, so if ARG1 is a reference type, find its underlying type. */ - struct type *type = value_type (arg1); + struct type *type = arg1->type (); while (type->code () == TYPE_CODE_REF) type = type->target_type (); binop_promote (exp->language_defn, exp->gdbarch, &arg1, &arg2); @@ -10826,7 +10826,7 @@ ada_unop_atr_operation::evaluate (struct type *expect_type, { value *tem = std::get<0> (m_storage)->evaluate (nullptr, exp, EVAL_AVOID_SIDE_EFFECTS); - type_arg = value_type (tem); + type_arg = tem->type (); } else val = std::get<0> (m_storage)->evaluate (nullptr, exp, noside); @@ -11011,7 +11011,7 @@ ada_unop_ind_operation::evaluate (struct type *expect_type, { value *arg1 = std::get<0> (m_storage)->evaluate (expect_type, exp, noside); - struct type *type = ada_check_typedef (value_type (arg1)); + struct type *type = ada_check_typedef (arg1->type ()); if (noside == EVAL_AVOID_SIDE_EFFECTS) { if (ada_is_array_descriptor_type (type)) @@ -11039,7 +11039,7 @@ ada_unop_ind_operation::evaluate (struct type *expect_type, { arg1 = std::get<0> (m_storage)->evaluate (nullptr, exp, EVAL_NORMAL); - type = value_type (ada_value_ind (arg1)); + type = ada_value_ind (arg1)->type (); } else { @@ -11066,7 +11066,7 @@ ada_unop_ind_operation::evaluate (struct type *expect_type, error (_("Attempt to take contents of a non-pointer value.")); } arg1 = ada_coerce_ref (arg1); /* FIXME: What is this for?? */ - type = ada_check_typedef (value_type (arg1)); + type = ada_check_typedef (arg1->type ()); if (type->code () == TYPE_CODE_INT) /* GDB allows dereferencing an int. If we were given @@ -11098,7 +11098,7 @@ ada_structop_operation::evaluate (struct type *expect_type, if (noside == EVAL_AVOID_SIDE_EFFECTS) { struct type *type; - struct type *type1 = value_type (arg1); + struct type *type1 = arg1->type (); if (ada_is_tagged_type (type1, 1)) { @@ -11114,7 +11114,7 @@ ada_structop_operation::evaluate (struct type *expect_type, EVAL_NORMAL); arg1 = ada_value_struct_elt (arg1, str, 0); arg1 = unwrap_value (arg1); - type = value_type (ada_to_fixed_value (arg1)); + type = ada_to_fixed_value (arg1)->type (); } } else @@ -11152,15 +11152,15 @@ ada_funcall_operation::evaluate (struct type *expect_type, argvec[i] = args_up[i]->evaluate (nullptr, exp, noside); if (ada_is_constrained_packed_array_type - (desc_base_type (value_type (callee)))) + (desc_base_type (callee->type ()))) callee = ada_coerce_to_simple_array (callee); - else if (value_type (callee)->code () == TYPE_CODE_ARRAY - && TYPE_FIELD_BITSIZE (value_type (callee), 0) != 0) + else if (callee->type ()->code () == TYPE_CODE_ARRAY + && TYPE_FIELD_BITSIZE (callee->type (), 0) != 0) /* This is a packed array that has already been fixed, and therefore already coerced to a simple array. Nothing further to do. */ ; - else if (value_type (callee)->code () == TYPE_CODE_REF) + else if (callee->type ()->code () == TYPE_CODE_REF) { /* Make sure we dereference references so that all the code below feels like it's really handling the referenced value. Wrapping @@ -11168,11 +11168,11 @@ ada_funcall_operation::evaluate (struct type *expect_type, well. */ callee = ada_to_fixed_value (coerce_ref (callee)); } - else if (value_type (callee)->code () == TYPE_CODE_ARRAY + else if (callee->type ()->code () == TYPE_CODE_ARRAY && VALUE_LVAL (callee) == lval_memory) callee = value_addr (callee); - struct type *type = ada_check_typedef (value_type (callee)); + struct type *type = ada_check_typedef (callee->type ()); /* Ada allows us to implicitly dereference arrays when subscripting them. So, if this is an array typedef (encoding use for array @@ -11196,7 +11196,7 @@ ada_funcall_operation::evaluate (struct type *expect_type, break; default: error (_("cannot subscript or call something of type `%s'"), - ada_type_name (value_type (callee))); + ada_type_name (callee->type ())); break; } } @@ -11320,7 +11320,7 @@ ada_ternop_slice_operation::resolve (struct expression *exp, continue that here. */ value *v = std::get<0> (m_storage)->evaluate (context_type, exp, EVAL_AVOID_SIDE_EFFECTS); - if (ada_is_any_packed_array_type (value_type (v))) + if (ada_is_any_packed_array_type (v->type ())) error (_("cannot slice a packed array")); return false; } @@ -11375,7 +11375,7 @@ scan_discrim_bound (const char *str, int k, struct value *dval, LONGEST * px, k = pend - str; } - bound_val = ada_search_struct_field (bound, dval, 0, value_type (dval)); + bound_val = ada_search_struct_field (bound, dval, 0, dval->type ()); if (bound_val == NULL) return 0; @@ -12025,7 +12025,7 @@ ada_exception_message_1 (void) e_msg_val = ada_coerce_to_simple_array (e_msg_val); gdb_assert (e_msg_val != NULL); - e_msg_len = value_type (e_msg_val)->length (); + e_msg_len = e_msg_val->type ()->length (); /* If the message string is empty, then treat it as if there was no exception message. */ diff --git a/gdb/ada-tasks.c b/gdb/ada-tasks.c index a3a28063daa..979d64a54ad 100644 --- a/gdb/ada-tasks.c +++ b/gdb/ada-tasks.c @@ -457,7 +457,7 @@ read_fat_string_value (char *dest, struct value *val, int max_len) to extract the string from the fat string. */ if (initialize_fieldnos) { - struct type *type = value_type (val); + struct type *type = val->type (); struct type *bounds_type; array_fieldno = ada_get_field_index (type, "P_ARRAY", 0); @@ -784,7 +784,7 @@ read_atcb (CORE_ADDR task_id, struct ada_task_info *task_info) value_subscript (entry_calls_value, value_as_long (atc_nesting_level_value)); called_task_fieldno = - ada_get_field_index (value_type (entry_calls_value_element), + ada_get_field_index (entry_calls_value_element->type (), "called_task", 0); task_info->called_task = value_as_address (value_field (entry_calls_value_element, diff --git a/gdb/ada-valprint.c b/gdb/ada-valprint.c index 10d3b0a41bf..1f22ab61ce2 100644 --- a/gdb/ada-valprint.c +++ b/gdb/ada-valprint.c @@ -196,12 +196,12 @@ val_print_packed_array_elements (struct type *type, const gdb_byte *valaddr, (i * bitsize) / HOST_CHAR_BIT, (i * bitsize) % HOST_CHAR_BIT, bitsize, elttype); - if (check_typedef (value_type (v0))->length () - != check_typedef (value_type (v1))->length ()) + if (check_typedef (v0->type ())->length () + != check_typedef (v1->type ())->length ()) break; if (!value_contents_eq (v0, value_embedded_offset (v0), v1, value_embedded_offset (v1), - check_typedef (value_type (v0))->length ())) + check_typedef (v0->type ())->length ())) break; } @@ -552,7 +552,7 @@ print_variant_part (struct value *value, int field_num, int comma_needed, const struct language_defn *language) { - struct type *type = value_type (value); + struct type *type = value->type (); struct type *var_type = type->field (field_num).type (); int which = ada_which_variant_applies (var_type, outer_value); @@ -588,7 +588,7 @@ print_field_values (struct value *value, struct value *outer_value, { int i, len; - struct type *type = value_type (value); + struct type *type = value->type (); len = type->num_fields (); for (i = 0; i < len; i += 1) @@ -732,8 +732,8 @@ ada_value_print_ptr (struct value *val, const struct value_print_options *options) { if (!options->format - && value_type (val)->target_type ()->code () == TYPE_CODE_INT - && value_type (val)->target_type ()->length () == 0) + && val->type ()->target_type ()->code () == TYPE_CODE_INT + && val->type ()->target_type ()->length () == 0) { gdb_puts ("null", stream); return; @@ -741,7 +741,7 @@ ada_value_print_ptr (struct value *val, common_val_print (val, stream, recurse, options, language_def (language_c)); - struct type *type = ada_check_typedef (value_type (val)); + struct type *type = ada_check_typedef (val->type ()); if (ada_is_tag_type (type)) { gdb::unique_xmalloc_ptr name = ada_tag_name (val); @@ -758,7 +758,7 @@ static void ada_value_print_num (struct value *val, struct ui_file *stream, int recurse, const struct value_print_options *options) { - struct type *type = ada_check_typedef (value_type (val)); + struct type *type = ada_check_typedef (val->type ()); const gdb_byte *valaddr = value_contents_for_printing (val).data (); if (type->code () == TYPE_CODE_RANGE @@ -838,7 +838,7 @@ ada_val_print_enum (struct value *value, struct ui_file *stream, int recurse, return; } - struct type *type = ada_check_typedef (value_type (value)); + struct type *type = ada_check_typedef (value->type ()); const gdb_byte *valaddr = value_contents_for_printing (value).data (); int offset_aligned = ada_aligned_value_addr (type, valaddr) - valaddr; @@ -875,7 +875,7 @@ ada_val_print_struct_union (struct value *value, int recurse, const struct value_print_options *options) { - if (ada_is_bogus_array_descriptor (value_type (value))) + if (ada_is_bogus_array_descriptor (value->type ())) { gdb_printf (stream, "(...?)"); return; @@ -901,7 +901,7 @@ static void ada_value_print_array (struct value *val, struct ui_file *stream, int recurse, const struct value_print_options *options) { - struct type *type = ada_check_typedef (value_type (val)); + struct type *type = ada_check_typedef (val->type ()); /* For an array of characters, print with string syntax. */ if (ada_is_string_type (type) @@ -961,7 +961,7 @@ ada_val_print_ref (struct type *type, const gdb_byte *valaddr, deref_val = coerce_ref_if_computed (original_value); if (deref_val) { - if (ada_is_tagged_type (value_type (deref_val), 1)) + if (ada_is_tagged_type (deref_val->type (), 1)) deref_val = ada_tag_value_at_base_address (deref_val); common_val_print (deref_val, stream, recurse + 1, options, @@ -979,7 +979,7 @@ ada_val_print_ref (struct type *type, const gdb_byte *valaddr, deref_val = ada_value_ind (value_from_pointer (lookup_pointer_type (elttype), deref_val_int)); - if (ada_is_tagged_type (value_type (deref_val), 1)) + if (ada_is_tagged_type (deref_val->type (), 1)) deref_val = ada_tag_value_at_base_address (deref_val); if (value_lazy (deref_val)) @@ -997,7 +997,7 @@ void ada_value_print_inner (struct value *val, struct ui_file *stream, int recurse, const struct value_print_options *options) { - struct type *type = ada_check_typedef (value_type (val)); + struct type *type = ada_check_typedef (val->type ()); if (ada_is_array_descriptor_type (type) || (ada_is_constrained_packed_array_type (type) @@ -1018,7 +1018,7 @@ ada_value_print_inner (struct value *val, struct ui_file *stream, int recurse, else val = ada_to_fixed_value (val); - type = value_type (val); + type = val->type (); struct type *saved_type = type; const gdb_byte *valaddr = value_contents_for_printing (val).data (); @@ -1088,7 +1088,7 @@ ada_value_print (struct value *val0, struct ui_file *stream, const struct value_print_options *options) { struct value *val = ada_to_fixed_value (val0); - struct type *type = ada_check_typedef (value_type (val)); + struct type *type = ada_check_typedef (val->type ()); struct value_print_options opts; /* If it is a pointer, indicate what it points to; but not for diff --git a/gdb/ada-varobj.c b/gdb/ada-varobj.c index 6b92b76f092..63e851e7ae5 100644 --- a/gdb/ada-varobj.c +++ b/gdb/ada-varobj.c @@ -66,7 +66,7 @@ ada_varobj_decode_var (struct value **value_ptr, struct type **type_ptr) *value_ptr = ada_get_decoded_value (*value_ptr); if (*value_ptr != nullptr) - *type_ptr = ada_check_typedef (value_type (*value_ptr)); + *type_ptr = ada_check_typedef ((*value_ptr)->type ()); else *type_ptr = ada_get_decoded_type (*type_ptr); } @@ -102,7 +102,7 @@ ada_varobj_struct_elt (struct value *parent_value, if (parent_value) { value = value_field (parent_value, fieldno); - type = value_type (value); + type = value->type (); } else type = parent_type->field (fieldno).type (); @@ -150,7 +150,7 @@ ada_varobj_ind (struct value *parent_value, if (parent_value) { value = ada_value_ind (parent_value); - type = value_type (value); + type = value->type (); } else type = parent_type->target_type (); @@ -181,7 +181,7 @@ ada_varobj_simple_array_elt (struct value *parent_value, value_from_longest (parent_type->index_type (), elt_index); value = ada_value_subscript (parent_value, 1, &index_value); - type = value_type (value); + type = value->type (); } else type = parent_type->target_type (); @@ -221,7 +221,7 @@ ada_varobj_adjust_for_child_access (struct value **value, if (*value != NULL && ada_is_tagged_type (*type, 1)) { *value = ada_tag_value_at_base_address (*value); - *type = value_type (*value); + *type = (*value)->type (); } } @@ -943,7 +943,7 @@ static bool ada_value_is_changeable_p (const struct varobj *var) { struct type *type = (var->value != nullptr - ? value_type (var->value.get ()) : var->type); + ? var->value.get ()->type () : var->type); if (type->code () == TYPE_CODE_REF) type = type->target_type (); diff --git a/gdb/alpha-tdep.c b/gdb/alpha-tdep.c index 14f5a0492d3..5edde7abcae 100644 --- a/gdb/alpha-tdep.c +++ b/gdb/alpha-tdep.c @@ -319,7 +319,7 @@ alpha_push_dummy_call (struct gdbarch *gdbarch, struct value *function, for (i = 0, m_arg = alpha_args; i < nargs; i++, m_arg++) { struct value *arg = args[i]; - struct type *arg_type = check_typedef (value_type (arg)); + struct type *arg_type = check_typedef (arg->type ()); /* Cast argument to long if necessary as the compiler does it too. */ switch (arg_type->code ()) diff --git a/gdb/amd64-tdep.c b/gdb/amd64-tdep.c index 328e001f5bb..5e098b1ce79 100644 --- a/gdb/amd64-tdep.c +++ b/gdb/amd64-tdep.c @@ -376,7 +376,7 @@ amd64_pseudo_register_read_value (struct gdbarch *gdbarch, memcpy (buf, raw_buf + 1, 1); else mark_value_bytes_unavailable (result_value, 0, - value_type (result_value)->length ()); + result_value->type ()->length ()); } else { @@ -386,7 +386,7 @@ amd64_pseudo_register_read_value (struct gdbarch *gdbarch, memcpy (buf, raw_buf, 1); else mark_value_bytes_unavailable (result_value, 0, - value_type (result_value)->length ()); + result_value->type ()->length ()); } } else if (i386_dword_regnum_p (gdbarch, regnum)) @@ -399,7 +399,7 @@ amd64_pseudo_register_read_value (struct gdbarch *gdbarch, memcpy (buf, raw_buf, 4); else mark_value_bytes_unavailable (result_value, 0, - value_type (result_value)->length ()); + result_value->type ()->length ()); } else i386_pseudo_register_read_into_value (gdbarch, regcache, regnum, @@ -962,7 +962,7 @@ if (return_method == return_method_struct) for (i = 0; i < nargs; i++) { - struct type *type = value_type (args[i]); + struct type *type = args[i]->type (); int len = type->length (); enum amd64_reg_class theclass[2]; int needed_integer_regs = 0; @@ -1046,7 +1046,7 @@ if (return_method == return_method_struct) /* Write out the arguments to the stack. */ for (i = 0; i < num_stack_args; i++) { - struct type *type = value_type (stack_args[i]); + struct type *type = stack_args[i]->type (); const gdb_byte *valbuf = value_contents (stack_args[i]).data (); int len = type->length (); diff --git a/gdb/amd64-windows-tdep.c b/gdb/amd64-windows-tdep.c index 411a6204a90..5c779cbb118 100644 --- a/gdb/amd64-windows-tdep.c +++ b/gdb/amd64-windows-tdep.c @@ -176,9 +176,9 @@ amd64_windows_adjust_args_passed_by_pointer (struct value **args, int i; for (i = 0; i < nargs; i++) - if (amd64_windows_passed_by_pointer (value_type (args[i]))) + if (amd64_windows_passed_by_pointer (args[i]->type ())) { - struct type *type = value_type (args[i]); + struct type *type = args[i]->type (); const gdb_byte *valbuf = value_contents (args[i]).data (); const int len = type->length (); @@ -204,7 +204,7 @@ static void amd64_windows_store_arg_in_reg (struct regcache *regcache, struct value *arg, int regno) { - struct type *type = value_type (arg); + struct type *type = arg->type (); const gdb_byte *valbuf = value_contents (arg).data (); gdb_byte buf[8]; @@ -251,7 +251,7 @@ amd64_windows_push_arguments (struct regcache *regcache, int nargs, for (i = 0; i < nargs; i++) { - struct type *type = value_type (args[i]); + struct type *type = args[i]->type (); int len = type->length (); int on_stack_p = 1; @@ -294,7 +294,7 @@ amd64_windows_push_arguments (struct regcache *regcache, int nargs, /* Write out the arguments to the stack. */ for (i = 0; i < num_stack_args; i++) { - struct type *type = value_type (stack_args[i]); + struct type *type = stack_args[i]->type (); const gdb_byte *valbuf = value_contents (stack_args[i]).data (); write_memory (sp + element * 8, valbuf, type->length ()); diff --git a/gdb/arc-tdep.c b/gdb/arc-tdep.c index c232eb98432..f42abc2ec42 100644 --- a/gdb/arc-tdep.c +++ b/gdb/arc-tdep.c @@ -761,7 +761,7 @@ arc_push_dummy_call (struct gdbarch *gdbarch, struct value *function, argument's size up to an integral number of words. */ for (int i = 0; i < nargs; i++) { - unsigned int len = value_type (args[i])->length (); + unsigned int len = args[i]->type ()->length (); unsigned int space = align_up (len, 4); total_space += space; @@ -776,7 +776,7 @@ arc_push_dummy_call (struct gdbarch *gdbarch, struct value *function, gdb_byte *data = memory_image; for (int i = 0; i < nargs; i++) { - unsigned int len = value_type (args[i])->length (); + unsigned int len = args[i]->type ()->length (); unsigned int space = align_up (len, 4); memcpy (data, value_contents (args[i]).data (), (size_t) len); diff --git a/gdb/arm-tdep.c b/gdb/arm-tdep.c index 347f3e6b307..a21f7120ab4 100644 --- a/gdb/arm-tdep.c +++ b/gdb/arm-tdep.c @@ -4635,7 +4635,7 @@ arm_push_dummy_call (struct gdbarch *gdbarch, struct value *function, /* Determine the type of this function and whether the VFP ABI applies. */ - ftype = check_typedef (value_type (function)); + ftype = check_typedef (function->type ()); if (ftype->code () == TYPE_CODE_PTR) ftype = check_typedef (ftype->target_type ()); use_vfp_abi = arm_vfp_abi_for_function (gdbarch, ftype); @@ -4678,7 +4678,7 @@ arm_push_dummy_call (struct gdbarch *gdbarch, struct value *function, int vfp_base_count; int may_use_core_reg = 1; - arg_type = check_typedef (value_type (args[argnum])); + arg_type = check_typedef (args[argnum]->type ()); len = arg_type->length (); target_type = arg_type->target_type (); typecode = arg_type->code (); @@ -9178,7 +9178,7 @@ arm_return_value (struct gdbarch *gdbarch, struct value *function, struct value **read_value, const gdb_byte *writebuf) { arm_gdbarch_tdep *tdep = gdbarch_tdep (gdbarch); - struct type *func_type = function ? value_type (function) : NULL; + struct type *func_type = function ? function->type () : NULL; enum arm_vfp_cprc_base_type vfp_base_type; int vfp_base_count; diff --git a/gdb/avr-tdep.c b/gdb/avr-tdep.c index fa76a3d24da..023ebc37efb 100644 --- a/gdb/avr-tdep.c +++ b/gdb/avr-tdep.c @@ -1298,7 +1298,7 @@ avr_push_dummy_call (struct gdbarch *gdbarch, struct value *function, int last_regnum; int j; struct value *arg = args[i]; - struct type *type = check_typedef (value_type (arg)); + struct type *type = check_typedef (arg->type ()); const bfd_byte *contents = value_contents (arg).data (); int len = type->length (); diff --git a/gdb/ax-gdb.c b/gdb/ax-gdb.c index fc214e7dfe1..3cfe99718a5 100644 --- a/gdb/ax-gdb.c +++ b/gdb/ax-gdb.c @@ -1585,7 +1585,7 @@ operation::generate_ax (struct expression *exp, struct value *v = evaluate (nullptr, exp, EVAL_AVOID_SIDE_EFFECTS); ax_const_l (ax, value_as_long (v)); value->kind = axs_rvalue; - value->type = check_typedef (value_type (v)); + value->type = check_typedef (v->type ()); } else { @@ -1745,7 +1745,7 @@ repeat_operation::do_generate_ax (struct expression *exp, struct value *v = std::get<1> (m_storage)->evaluate (nullptr, exp, EVAL_AVOID_SIDE_EFFECTS); - if (value_type (v)->code () != TYPE_CODE_INT) + if (v->type ()->code () != TYPE_CODE_INT) error (_("Right operand of `@' must be an integer.")); int length = value_as_long (v); if (length <= 0) @@ -1862,7 +1862,7 @@ unop_memval_type_operation::do_generate_ax (struct expression *exp, struct value *val = std::get<0> (m_storage)->evaluate (nullptr, exp, EVAL_AVOID_SIDE_EFFECTS); - struct type *type = value_type (val); + struct type *type = val->type (); std::get<1> (m_storage)->generate_ax (exp, ax, value); @@ -1980,7 +1980,7 @@ unop_cast_type_operation::do_generate_ax (struct expression *exp, struct value *val = std::get<0> (m_storage)->evaluate (nullptr, exp, EVAL_AVOID_SIDE_EFFECTS); - std::get<1> (m_storage)->generate_ax (exp, ax, value, value_type (val)); + std::get<1> (m_storage)->generate_ax (exp, ax, value, val->type ()); } void diff --git a/gdb/breakpoint.c b/gdb/breakpoint.c index 1c7ae58a23b..3c099d185f3 100644 --- a/gdb/breakpoint.c +++ b/gdb/breakpoint.c @@ -1856,7 +1856,7 @@ extract_bitfield_from_watchpoint_value (struct watchpoint *w, struct value *val) if (val == NULL) return NULL; - bit_val = allocate_value (value_type (val)); + bit_val = allocate_value (val->type ()); unpack_value_bitfield (bit_val, w->val_bitpos, @@ -2070,7 +2070,7 @@ update_watchpoint (struct watchpoint *b, bool reparse) if (VALUE_LVAL (v) == lval_memory && (v == val_chain[0] || ! value_lazy (v))) { - struct type *vtype = check_typedef (value_type (v)); + struct type *vtype = check_typedef (v->type ()); /* We only watch structs and arrays if user asked for it explicitly, never if they just happen to @@ -2117,7 +2117,7 @@ update_watchpoint (struct watchpoint *b, bool reparse) for (tmp = &(b->loc); *tmp != NULL; tmp = &((*tmp)->next)) ; *tmp = loc; - loc->gdbarch = value_type (v)->arch (); + loc->gdbarch = v->type ()->arch (); loc->pspace = frame_pspace; loc->address @@ -2129,7 +2129,7 @@ update_watchpoint (struct watchpoint *b, bool reparse) loc->length = ((bitpos % 8) + bitsize + 7) / 8; } else - loc->length = value_type (v)->length (); + loc->length = v->type ()->length (); loc->watchpoint_type = type; } @@ -10286,7 +10286,7 @@ watch_command_1 (const char *arg, int accessflag, int from_tty, w->cond_exp_valid_block = cond_exp_valid_block; if (just_location) { - struct type *t = value_type (val.get ()); + struct type *t = val.get ()->type (); CORE_ADDR addr = value_as_address (val.get ()); w->exp_string_reparse @@ -10395,7 +10395,7 @@ can_use_hardware_watchpoint (const std::vector &vals) { /* Ahh, memory we actually used! Check if we can cover it with hardware watchpoints. */ - struct type *vtype = check_typedef (value_type (v)); + struct type *vtype = check_typedef (v->type ()); /* We only watch structs and arrays if user asked for it explicitly, never if they just happen to appear in a @@ -10410,7 +10410,7 @@ can_use_hardware_watchpoint (const std::vector &vals) len = (target_exact_watchpoints && is_scalar_type_recursive (vtype))? - 1 : value_type (v)->length (); + 1 : v->type ()->length (); num_regs = target_region_ok_for_hw_watchpoint (vaddr, len); if (!num_regs) diff --git a/gdb/c-exp.h b/gdb/c-exp.h index 20eeaca9a89..51e2d26eb2e 100644 --- a/gdb/c-exp.h +++ b/gdb/c-exp.h @@ -138,7 +138,7 @@ class opencl_binop_operation value *lhs = std::get<0> (this->m_storage)->evaluate (nullptr, exp, noside); value *rhs - = std::get<1> (this->m_storage)->evaluate (value_type (lhs), exp, + = std::get<1> (this->m_storage)->evaluate (lhs->type (), exp, noside); return FUNC (expect_type, exp, noside, OP, lhs, rhs); } diff --git a/gdb/c-lang.c b/gdb/c-lang.c index a6d912a7be7..c2c763154c7 100644 --- a/gdb/c-lang.c +++ b/gdb/c-lang.c @@ -245,7 +245,7 @@ c_get_string (struct value *value, gdb::unique_xmalloc_ptr *buffer, { int err, width; unsigned int fetchlimit; - struct type *type = check_typedef (value_type (value)); + struct type *type = check_typedef (value->type ()); struct type *element_type = type->target_type (); int req_length = *length; enum bfd_endian byte_order diff --git a/gdb/c-valprint.c b/gdb/c-valprint.c index 69aa91d1ec3..8d28c45cbfc 100644 --- a/gdb/c-valprint.c +++ b/gdb/c-valprint.c @@ -235,7 +235,7 @@ c_value_print_array (struct value *val, struct ui_file *stream, int recurse, const struct value_print_options *options) { - struct type *type = check_typedef (value_type (val)); + struct type *type = check_typedef (val->type ()); CORE_ADDR address = value_address (val); const gdb_byte *valaddr = value_contents_for_printing (val).data (); struct type *unresolved_elttype = type->target_type (); @@ -333,7 +333,7 @@ c_value_print_ptr (struct value *val, struct ui_file *stream, int recurse, return; } - struct type *type = check_typedef (value_type (val)); + struct type *type = check_typedef (val->type ()); const gdb_byte *valaddr = value_contents_for_printing (val).data (); if (options->vtblprint && cp_is_vtbl_ptr_type (type)) @@ -363,7 +363,7 @@ static void c_value_print_struct (struct value *val, struct ui_file *stream, int recurse, const struct value_print_options *options) { - struct type *type = check_typedef (value_type (val)); + struct type *type = check_typedef (val->type ()); if (type->code () == TYPE_CODE_UNION && recurse && !options->unionprint) gdb_printf (stream, "{...}"); @@ -405,7 +405,7 @@ c_value_print_int (struct value *val, struct ui_file *stream, instead. Since we don't know whether the value is really intended to be used as an integer or a character, print the character equivalent as well. */ - struct type *type = value_type (val); + struct type *type = val->type (); const gdb_byte *valaddr = value_contents_for_printing (val).data (); if (c_textual_element_type (type, options->format)) { @@ -422,7 +422,7 @@ void c_value_print_inner (struct value *val, struct ui_file *stream, int recurse, const struct value_print_options *options) { - struct type *type = value_type (val); + struct type *type = val->type (); type = check_typedef (type); switch (type->code ()) @@ -486,11 +486,11 @@ c_value_print (struct value *val, struct ui_file *stream, C++: if it is a member pointer, we will take care of that when we print it. */ - type = check_typedef (value_type (val)); + type = check_typedef (val->type ()); if (type->is_pointer_or_reference ()) { - struct type *original_type = value_type (val); + struct type *original_type = val->type (); /* Hack: remove (char *) for char strings. Their type is indicated by the quoted string anyway. @@ -541,7 +541,7 @@ c_value_print (struct value *val, struct ui_file *stream, if (is_ref) val = value_ref (value_ind (val), refcode); - type = value_type (val); + type = val->type (); type_print (type, "", stream, -1); gdb_printf (stream, ") "); } @@ -549,7 +549,7 @@ c_value_print (struct value *val, struct ui_file *stream, { /* normal case */ gdb_printf (stream, "("); - type_print (value_type (val), "", stream, -1); + type_print (val->type (), "", stream, -1); gdb_printf (stream, ") "); } } diff --git a/gdb/c-varobj.c b/gdb/c-varobj.c index a6b3306d22b..d517c798a6a 100644 --- a/gdb/c-varobj.c +++ b/gdb/c-varobj.c @@ -245,7 +245,7 @@ static struct value * value_struct_element_index (struct value *value, int type_index) { struct value *result = NULL; - struct type *type = value_type (value); + struct type *type = value->type (); type = check_typedef (type); diff --git a/gdb/cli/cli-cmds.c b/gdb/cli/cli-cmds.c index 6c0d780face..7267d607916 100644 --- a/gdb/cli/cli-cmds.c +++ b/gdb/cli/cli-cmds.c @@ -2190,7 +2190,7 @@ setting_cmd (const char *fnname, struct cmd_list_element *showlist, if (argc != 1) error (_("You can only provide one argument to %s"), fnname); - struct type *type0 = check_typedef (value_type (argv[0])); + struct type *type0 = check_typedef (argv[0]->type ()); if (type0->code () != TYPE_CODE_ARRAY && type0->code () != TYPE_CODE_STRING) diff --git a/gdb/cli/cli-dump.c b/gdb/cli/cli-dump.c index a8811c4b4d7..e1d40c0e0ce 100644 --- a/gdb/cli/cli-dump.c +++ b/gdb/cli/cli-dump.c @@ -225,7 +225,7 @@ dump_value_to_file (const char *cmd, const char *mode, const char *file_format) /* Have everything. Open/write the data. */ if (file_format == NULL || strcmp (file_format, "binary") == 0) dump_binary_file (filename.get (), mode, value_contents (val).data (), - value_type (val)->length ()); + val->type ()->length ()); else { CORE_ADDR vaddr; @@ -242,7 +242,7 @@ dump_value_to_file (const char *cmd, const char *mode, const char *file_format) dump_bfd_file (filename.get (), mode, file_format, vaddr, value_contents (val).data (), - value_type (val)->length ()); + val->type ()->length ()); } } diff --git a/gdb/cli/cli-utils.c b/gdb/cli/cli-utils.c index 81c3c728dc6..b78568e3cc6 100644 --- a/gdb/cli/cli-utils.c +++ b/gdb/cli/cli-utils.c @@ -37,7 +37,7 @@ get_ulongest (const char **pp, int trailer) if (val != NULL) /* Value history reference */ { - if (value_type (val)->code () == TYPE_CODE_INT) + if (val->type ()->code () == TYPE_CODE_INT) retval = value_as_long (val); else error (_("History value must have integer type.")); @@ -96,7 +96,7 @@ get_number_trailer (const char **pp, int trailer) if (val) /* Value history reference */ { - if (value_type (val)->code () == TYPE_CODE_INT) + if (val->type ()->code () == TYPE_CODE_INT) retval = value_as_long (val); else { diff --git a/gdb/cp-abi.c b/gdb/cp-abi.c index 87a3b5c0a96..538d314efda 100644 --- a/gdb/cp-abi.c +++ b/gdb/cp-abi.c @@ -111,7 +111,7 @@ value_rtti_type (struct value *v, int *full, struct type *ret = NULL; if ((current_cp_abi.rtti_type) == NULL - || !HAVE_CPLUS_STRUCT (check_typedef (value_type (v)))) + || !HAVE_CPLUS_STRUCT (check_typedef (v->type ()))) return NULL; try { diff --git a/gdb/cp-valprint.c b/gdb/cp-valprint.c index ca73882a0ce..33ff17b8d2b 100644 --- a/gdb/cp-valprint.c +++ b/gdb/cp-valprint.c @@ -129,7 +129,7 @@ cp_print_value_fields (struct value *val, struct ui_file *stream, int fields_seen = 0; static int last_set_recurse = -1; - struct type *type = check_typedef (value_type (val)); + struct type *type = check_typedef (val->type ()); if (recurse == 0) { @@ -389,7 +389,7 @@ cp_print_value (struct value *val, struct ui_file *stream, int recurse, const struct value_print_options *options, struct type **dont_print_vb) { - struct type *type = check_typedef (value_type (val)); + struct type *type = check_typedef (val->type ()); CORE_ADDR address = value_address (val); struct type **last_dont_print = (struct type **) obstack_next_free (&dont_print_vb_obstack); @@ -461,7 +461,7 @@ cp_print_value (struct value *val, struct ui_file *stream, base_val = value_from_contents_and_address (baseclass, buf.data (), address + boffset); - baseclass = value_type (base_val); + baseclass = base_val->type (); boffset = 0; } else diff --git a/gdb/cris-tdep.c b/gdb/cris-tdep.c index edf4e74715c..cc8d7634c9d 100644 --- a/gdb/cris-tdep.c +++ b/gdb/cris-tdep.c @@ -821,7 +821,7 @@ cris_push_dummy_call (struct gdbarch *gdbarch, struct value *function, int reg_demand; int i; - len = value_type (args[argnum])->length (); + len = args[argnum]->type ()->length (); val = value_contents (args[argnum]).data (); /* How may registers worth of storage do we need for this argument? */ diff --git a/gdb/csky-tdep.c b/gdb/csky-tdep.c index df9520fe37d..9fa1fb37154 100644 --- a/gdb/csky-tdep.c +++ b/gdb/csky-tdep.c @@ -806,7 +806,7 @@ csky_push_dummy_call (struct gdbarch *gdbarch, struct value *function, struct type *arg_type; const gdb_byte *val; - arg_type = check_typedef (value_type (args[argnum])); + arg_type = check_typedef (args[argnum]->type ()); len = arg_type->length (); val = value_contents (args[argnum]).data (); diff --git a/gdb/d-valprint.c b/gdb/d-valprint.c index 18697545ce8..6c7748efa4c 100644 --- a/gdb/d-valprint.c +++ b/gdb/d-valprint.c @@ -61,7 +61,7 @@ dynamic_array_type (struct type *type, true_type = lookup_array_range_type (true_type, 0, length - 1); ival = value_at (true_type, addr); - true_type = value_type (ival); + true_type = ival->type (); d_value_print_inner (ival, stream, recurse + 1, options); return 0; @@ -77,7 +77,7 @@ d_value_print_inner (struct value *val, struct ui_file *stream, int recurse, { int ret; - struct type *type = check_typedef (value_type (val)); + struct type *type = check_typedef (val->type ()); switch (type->code ()) { case TYPE_CODE_STRUCT: diff --git a/gdb/darwin-nat-info.c b/gdb/darwin-nat-info.c index d4dba555b6a..9e562074cf8 100644 --- a/gdb/darwin-nat-info.c +++ b/gdb/darwin-nat-info.c @@ -724,7 +724,7 @@ info_mach_region_command (const char *exp, int from_tty) expression_up expr = parse_expression (exp); val = evaluate_expression (expr.get ()); - if (TYPE_IS_REFERENCE (value_type (val))) + if (TYPE_IS_REFERENCE (val->type ())) { val = value_ind (val); } diff --git a/gdb/dtrace-probe.c b/gdb/dtrace-probe.c index 9805b8a8e78..70fa1a9413e 100644 --- a/gdb/dtrace-probe.c +++ b/gdb/dtrace-probe.c @@ -494,7 +494,7 @@ dtrace_process_dof_probe (struct objfile *objfile, } if (expr != NULL && expr->first_opcode () == OP_TYPE) - type = value_type (evaluate_type (expr.get ())); + type = evaluate_type (expr.get ())->type (); args.emplace_back (type, std::move (type_str), std::move (expr)); } diff --git a/gdb/dwarf2/expr.c b/gdb/dwarf2/expr.c index eecd18f59c9..7310295db4d 100644 --- a/gdb/dwarf2/expr.c +++ b/gdb/dwarf2/expr.c @@ -151,7 +151,7 @@ rw_pieced_value (value *v, value *from, bool check_optimized) piece_closure *c = (piece_closure *) value_computed_closure (v); gdb::byte_vector buffer; - bool bits_big_endian = type_byte_order (value_type (v)) == BFD_ENDIAN_BIG; + bool bits_big_endian = type_byte_order (v->type ()) == BFD_ENDIAN_BIG; gdb_assert (!check_optimized || from == nullptr); if (from != nullptr) @@ -174,18 +174,18 @@ rw_pieced_value (value *v, value *from, bool check_optimized) bits_to_skip += (8 * value_offset (value_parent (v)) + value_bitpos (v)); if (from != nullptr - && (type_byte_order (value_type (from)) + && (type_byte_order (from->type ()) == BFD_ENDIAN_BIG)) { /* Use the least significant bits of FROM. */ - max_offset = 8 * value_type (from)->length (); + max_offset = 8 * from->type ()->length (); offset = max_offset - value_bitsize (v); } else max_offset = value_bitsize (v); } else - max_offset = 8 * value_type (v)->length (); + max_offset = 8 * v->type ()->length (); /* Advance to the first non-skipped piece. */ for (i = 0; i < c->pieces.size () && bits_to_skip >= c->pieces[i].size; i++) @@ -364,7 +364,7 @@ rw_pieced_value (value *v, value *from, bool check_optimized) gdbarch *objfile_gdbarch = c->per_objfile->objfile->arch (); ULONGEST stack_value_size_bits - = 8 * value_type (p->v.value)->length (); + = 8 * p->v.value->type ()->length (); /* Use zeroes if piece reaches beyond stack value. */ if (p->offset + p->size > stack_value_size_bits) @@ -507,7 +507,7 @@ indirect_pieced_value (value *value) int i; dwarf_expr_piece *piece = NULL; - struct type *type = check_typedef (value_type (value)); + struct type *type = check_typedef (value->type ()); if (type->code () != TYPE_CODE_PTR) return NULL; @@ -574,7 +574,7 @@ indirect_pieced_value (value *value) static value * coerce_pieced_ref (const value *value) { - struct type *type = check_typedef (value_type (value)); + struct type *type = check_typedef (value->type ()); if (value_bits_synthetic_pointer (value, value_embedded_offset (value), TARGET_CHAR_BIT * type->length ())) @@ -1012,7 +1012,7 @@ dwarf_expr_context::fetch_result (struct type *type, struct type *subobj_type, case DWARF_VALUE_STACK: { value *val = this->fetch (0); - size_t n = value_type (val)->length (); + size_t n = val->type ()->length (); size_t len = subobj_type->length (); size_t max = type->length (); @@ -1144,7 +1144,7 @@ dwarf_expr_context::fetch_address (int n) bfd_endian byte_order = gdbarch_byte_order (arch); ULONGEST result; - dwarf_require_integral (value_type (result_val)); + dwarf_require_integral (result_val->type ()); result = extract_unsigned_integer (value_contents (result_val), byte_order); /* For most architectures, calling extract_unsigned_integer() alone @@ -1157,7 +1157,7 @@ dwarf_expr_context::fetch_address (int n) { gdb_byte *buf = (gdb_byte *) alloca (this->m_addr_size); type *int_type = get_unsigned_type (arch, - value_type (result_val)); + result_val->type ()); store_unsigned_integer (buf, this->m_addr_size, byte_order, result); return gdbarch_integer_to_address (arch, int_type, buf); @@ -1929,18 +1929,18 @@ dwarf_expr_context::execute_stack_op (const gdb_byte *op_ptr, { case DW_OP_abs: if (value_less (result_val, - value_zero (value_type (result_val), not_lval))) + value_zero (result_val->type (), not_lval))) result_val = value_neg (result_val); break; case DW_OP_neg: result_val = value_neg (result_val); break; case DW_OP_not: - dwarf_require_integral (value_type (result_val)); + dwarf_require_integral (result_val->type ()); result_val = value_complement (result_val); break; case DW_OP_plus_uconst: - dwarf_require_integral (value_type (result_val)); + dwarf_require_integral (result_val->type ()); result = value_as_long (result_val); op_ptr = safe_read_uleb128 (op_ptr, op_end, ®); result += reg; @@ -1977,14 +1977,14 @@ dwarf_expr_context::execute_stack_op (const gdb_byte *op_ptr, first = fetch (0); pop (); - if (! base_types_equal_p (value_type (first), value_type (second))) + if (! base_types_equal_p (first->type (), second->type ())) error (_("Incompatible types on DWARF stack")); switch (op) { case DW_OP_and: - dwarf_require_integral (value_type (first)); - dwarf_require_integral (value_type (second)); + dwarf_require_integral (first->type ()); + dwarf_require_integral (second->type ()); result_val = value_binop (first, second, BINOP_BITWISE_AND); break; case DW_OP_div: @@ -1996,7 +1996,7 @@ dwarf_expr_context::execute_stack_op (const gdb_byte *op_ptr, case DW_OP_mod: { int cast_back = 0; - struct type *orig_type = value_type (first); + struct type *orig_type = first->type (); /* We have to special-case "old-style" untyped values -- these must have mod computed using unsigned @@ -2020,25 +2020,25 @@ dwarf_expr_context::execute_stack_op (const gdb_byte *op_ptr, result_val = value_binop (first, second, BINOP_MUL); break; case DW_OP_or: - dwarf_require_integral (value_type (first)); - dwarf_require_integral (value_type (second)); + dwarf_require_integral (first->type ()); + dwarf_require_integral (second->type ()); result_val = value_binop (first, second, BINOP_BITWISE_IOR); break; case DW_OP_plus: result_val = value_binop (first, second, BINOP_ADD); break; case DW_OP_shl: - dwarf_require_integral (value_type (first)); - dwarf_require_integral (value_type (second)); + dwarf_require_integral (first->type ()); + dwarf_require_integral (second->type ()); result_val = value_binop (first, second, BINOP_LSH); break; case DW_OP_shr: - dwarf_require_integral (value_type (first)); - dwarf_require_integral (value_type (second)); - if (!value_type (first)->is_unsigned ()) + dwarf_require_integral (first->type ()); + dwarf_require_integral (second->type ()); + if (!first->type ()->is_unsigned ()) { struct type *utype - = get_unsigned_type (arch, value_type (first)); + = get_unsigned_type (arch, first->type ()); first = value_cast (utype, first); } @@ -2046,16 +2046,16 @@ dwarf_expr_context::execute_stack_op (const gdb_byte *op_ptr, result_val = value_binop (first, second, BINOP_RSH); /* Make sure we wind up with the same type we started with. */ - if (value_type (result_val) != value_type (second)) - result_val = value_cast (value_type (second), result_val); + if (result_val->type () != second->type ()) + result_val = value_cast (second->type (), result_val); break; case DW_OP_shra: - dwarf_require_integral (value_type (first)); - dwarf_require_integral (value_type (second)); - if (value_type (first)->is_unsigned ()) + dwarf_require_integral (first->type ()); + dwarf_require_integral (second->type ()); + if (first->type ()->is_unsigned ()) { struct type *stype - = get_signed_type (arch, value_type (first)); + = get_signed_type (arch, first->type ()); first = value_cast (stype, first); } @@ -2063,12 +2063,12 @@ dwarf_expr_context::execute_stack_op (const gdb_byte *op_ptr, result_val = value_binop (first, second, BINOP_RSH); /* Make sure we wind up with the same type we started with. */ - if (value_type (result_val) != value_type (second)) - result_val = value_cast (value_type (second), result_val); + if (result_val->type () != second->type ()) + result_val = value_cast (second->type (), result_val); break; case DW_OP_xor: - dwarf_require_integral (value_type (first)); - dwarf_require_integral (value_type (second)); + dwarf_require_integral (first->type ()); + dwarf_require_integral (second->type ()); result_val = value_binop (first, second, BINOP_BITWISE_XOR); break; case DW_OP_le: @@ -2142,7 +2142,7 @@ dwarf_expr_context::execute_stack_op (const gdb_byte *op_ptr, offset = extract_signed_integer (op_ptr, 2, byte_order); op_ptr += 2; val = fetch (0); - dwarf_require_integral (value_type (val)); + dwarf_require_integral (val->type ()); if (value_as_long (val) != 0) op_ptr += offset; pop (); @@ -2341,12 +2341,12 @@ dwarf_expr_context::execute_stack_op (const gdb_byte *op_ptr, if (op == DW_OP_convert || op == DW_OP_GNU_convert) result_val = value_cast (type, result_val); - else if (type == value_type (result_val)) + else if (type == result_val->type ()) { /* Nothing. */ } else if (type->length () - != value_type (result_val)->length ()) + != result_val->type ()->length ()) error (_("DW_OP_reinterpret has wrong size")); else result_val diff --git a/gdb/dwarf2/loc.c b/gdb/dwarf2/loc.c index 236ad820462..4af4dfde090 100644 --- a/gdb/dwarf2/loc.c +++ b/gdb/dwarf2/loc.c @@ -1273,7 +1273,7 @@ dwarf_entry_parameter_to_value (struct call_site_parameter *parameter, static struct value * entry_data_value_coerce_ref (const struct value *value) { - struct type *checked_type = check_typedef (value_type (value)); + struct type *checked_type = check_typedef (value->type ()); struct value *target_val; if (!TYPE_IS_REFERENCE (checked_type)) diff --git a/gdb/eval.c b/gdb/eval.c index bb42e693b17..c24ff258b43 100644 --- a/gdb/eval.c +++ b/gdb/eval.c @@ -241,7 +241,7 @@ unop_promote (const struct language_defn *language, struct gdbarch *gdbarch, struct type *type1; *arg1 = coerce_ref (*arg1); - type1 = check_typedef (value_type (*arg1)); + type1 = check_typedef ((*arg1)->type ()); if (is_integral_type (type1)) { @@ -278,8 +278,8 @@ binop_promote (const struct language_defn *language, struct gdbarch *gdbarch, *arg1 = coerce_ref (*arg1); *arg2 = coerce_ref (*arg2); - type1 = check_typedef (value_type (*arg1)); - type2 = check_typedef (value_type (*arg2)); + type1 = check_typedef ((*arg1)->type ()); + type2 = check_typedef ((*arg2)->type ()); if ((type1->code () != TYPE_CODE_FLT && type1->code () != TYPE_CODE_DECFLOAT @@ -628,7 +628,7 @@ evaluate_subexp_do_call (expression *exp, enum noside noside, call an error. This can happen if somebody tries to turn a variable into a function call. */ - type *ftype = value_type (callee); + type *ftype = callee->type (); if (ftype->code () == TYPE_CODE_INTERNAL_FUNCTION) { @@ -672,7 +672,7 @@ evaluate_subexp_do_call (expression *exp, enum noside noside, error (_("Expression of type other than " "\"Function returning ...\" used as function")); } - switch (value_type (callee)->code ()) + switch (callee->type ()->code ()) { case TYPE_CODE_INTERNAL_FUNCTION: return call_internal_function (exp->gdbarch, exp->language_defn, @@ -697,7 +697,7 @@ operation::evaluate_funcall (struct type *expect_type, std::vector vals (args.size ()); value *callee = evaluate_with_coercion (exp, noside); - struct type *type = value_type (callee); + struct type *type = callee->type (); if (type->code () == TYPE_CODE_PTR) type = type->target_type (); for (int i = 0; i < args.size (); ++i) @@ -836,7 +836,7 @@ structop_member_base::evaluate_funcall (struct type *expect_type, value *rhs = std::get<1> (m_storage)->evaluate (nullptr, exp, noside); value *callee; - type *a1_type = check_typedef (value_type (rhs)); + type *a1_type = check_typedef (rhs->type ()); if (a1_type->code () == TYPE_CODE_METHODPTR) { if (noside == EVAL_AVOID_SIDE_EFFECTS) @@ -963,7 +963,7 @@ structop_base_operation::evaluate_funcall /* value_struct_elt updates temp with the correct value of the ``this'' pointer if necessary, so modify it to reflect any ``this'' changes. */ - vals[0] = value_from_longest (lookup_pointer_type (value_type (temp)), + vals[0] = value_from_longest (lookup_pointer_type (temp->type ()), value_address (temp) + value_embedded_offset (temp)); } @@ -1041,7 +1041,7 @@ structop_base_operation::complete (struct expression *exp, value *lhs = std::get<0> (m_storage)->evaluate (nullptr, exp, EVAL_AVOID_SIDE_EFFECTS); - struct type *type = value_type (lhs); + struct type *type = lhs->type (); for (;;) { type = check_typedef (type); @@ -1122,7 +1122,7 @@ eval_op_var_msym_value (struct type *expect_type, struct expression *exp, value *val = evaluate_var_msym_value (noside, msymbol.objfile, msymbol.minsym); - struct type *type = value_type (val); + struct type *type = val->type (); if (type->code () == TYPE_CODE_ERROR && (noside != EVAL_AVOID_SIDE_EFFECTS || !outermost_p)) error_unknown_type (msymbol.minsym->print_name ()); @@ -1224,7 +1224,7 @@ eval_op_structop_struct (struct type *expect_type, struct expression *exp, struct value *arg3 = value_struct_elt (&arg1, {}, string, NULL, "structure"); if (noside == EVAL_AVOID_SIDE_EFFECTS) - arg3 = value_zero (value_type (arg3), VALUE_LVAL (arg3)); + arg3 = value_zero (arg3->type (), VALUE_LVAL (arg3)); return arg3; } @@ -1260,7 +1260,7 @@ eval_op_structop_ptr (struct type *expect_type, struct expression *exp, 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 *arg_type = arg1->type (); struct type *real_type; int full, using_enc; LONGEST top; @@ -1280,7 +1280,7 @@ eval_op_structop_ptr (struct type *expect_type, struct expression *exp, struct value *arg3 = value_struct_elt (&arg1, {}, string, NULL, "structure pointer"); if (noside == EVAL_AVOID_SIDE_EFFECTS) - arg3 = value_zero (value_type (arg3), VALUE_LVAL (arg3)); + arg3 = value_zero (arg3->type (), VALUE_LVAL (arg3)); return arg3; } @@ -1294,7 +1294,7 @@ eval_op_member (struct type *expect_type, struct expression *exp, long mem_offset; struct value *arg3; - struct type *type = check_typedef (value_type (arg2)); + struct type *type = check_typedef (arg2->type ()); switch (type->code ()) { case TYPE_CODE_METHODPTR: @@ -1303,13 +1303,13 @@ eval_op_member (struct type *expect_type, struct expression *exp, else { arg2 = cplus_method_ptr_to_value (&arg1, arg2); - gdb_assert (value_type (arg2)->code () == TYPE_CODE_PTR); + gdb_assert (arg2->type ()->code () == TYPE_CODE_PTR); return value_ind (arg2); } case TYPE_CODE_MEMBERPTR: /* Now, convert these values to an address. */ - if (check_typedef (value_type (arg1))->code () != TYPE_CODE_PTR) + if (check_typedef (arg1->type ())->code () != TYPE_CODE_PTR) arg1 = value_addr (arg1); arg1 = value_cast_pointers (lookup_pointer_type (TYPE_SELF_TYPE (type)), arg1, 1); @@ -1335,11 +1335,11 @@ eval_op_add (struct type *expect_type, struct expression *exp, { if (binop_user_defined_p (BINOP_ADD, arg1, arg2)) return value_x_binop (arg1, arg2, BINOP_ADD, OP_NULL, noside); - else if (ptrmath_type_p (exp->language_defn, value_type (arg1)) - && is_integral_or_integral_reference (value_type (arg2))) + else if (ptrmath_type_p (exp->language_defn, arg1->type ()) + && is_integral_or_integral_reference (arg2->type ())) return value_ptradd (arg1, value_as_long (arg2)); - else if (ptrmath_type_p (exp->language_defn, value_type (arg2)) - && is_integral_or_integral_reference (value_type (arg1))) + else if (ptrmath_type_p (exp->language_defn, arg2->type ()) + && is_integral_or_integral_reference (arg1->type ())) return value_ptradd (arg2, value_as_long (arg1)); else { @@ -1357,15 +1357,15 @@ eval_op_sub (struct type *expect_type, struct expression *exp, { if (binop_user_defined_p (BINOP_SUB, arg1, arg2)) return value_x_binop (arg1, arg2, BINOP_SUB, OP_NULL, noside); - else if (ptrmath_type_p (exp->language_defn, value_type (arg1)) - && ptrmath_type_p (exp->language_defn, value_type (arg2))) + else if (ptrmath_type_p (exp->language_defn, arg1->type ()) + && ptrmath_type_p (exp->language_defn, arg2->type ())) { /* FIXME -- should be ptrdiff_t */ struct type *type = builtin_type (exp->gdbarch)->builtin_long; return value_from_longest (type, value_ptrdiff (arg1, arg2)); } - else if (ptrmath_type_p (exp->language_defn, value_type (arg1)) - && is_integral_or_integral_reference (value_type (arg2))) + else if (ptrmath_type_p (exp->language_defn, arg1->type ()) + && is_integral_or_integral_reference (arg2->type ())) return value_ptradd (arg1, - value_as_long (arg2)); else { @@ -1400,7 +1400,7 @@ eval_op_binary (struct type *expect_type, struct expression *exp, { struct value *v_one; - v_one = value_one (value_type (arg2)); + v_one = value_one (arg2->type ()); binop_promote (exp->language_defn, exp->gdbarch, &arg1, &v_one); return value_binop (arg1, v_one, op); } @@ -1409,7 +1409,7 @@ eval_op_binary (struct type *expect_type, struct expression *exp, /* For shift and integer exponentiation operations, only promote the first argument. */ if ((op == BINOP_LSH || op == BINOP_RSH || op == BINOP_EXP) - && is_integral_type (value_type (arg2))) + && is_integral_type (arg2->type ())) unop_promote (exp->language_defn, exp->gdbarch, &arg1); else binop_promote (exp->language_defn, exp->gdbarch, &arg1, &arg2); @@ -1435,7 +1435,7 @@ eval_op_subscript (struct type *expect_type, struct expression *exp, then report this as an error. */ arg1 = coerce_ref (arg1); - struct type *type = check_typedef (value_type (arg1)); + struct type *type = check_typedef (arg1->type ()); if (type->code () != TYPE_CODE_ARRAY && type->code () != TYPE_CODE_PTR) { @@ -1586,13 +1586,13 @@ eval_op_repeat (struct type *expect_type, struct expression *exp, enum noside noside, enum exp_opcode op, struct value *arg1, struct value *arg2) { - struct type *type = check_typedef (value_type (arg2)); + struct type *type = check_typedef (arg2->type ()); if (type->code () != TYPE_CODE_INT && type->code () != TYPE_CODE_ENUM) error (_("Non-integral right operand for \"@\" operator.")); if (noside == EVAL_AVOID_SIDE_EFFECTS) { - return allocate_repeat_value (value_type (arg1), + return allocate_repeat_value (arg1->type (), longest_to_int (value_as_long (arg2))); } else @@ -1671,7 +1671,7 @@ eval_op_ind (struct type *expect_type, struct expression *exp, enum noside noside, struct value *arg1) { - struct type *type = check_typedef (value_type (arg1)); + struct type *type = check_typedef (arg1->type ()); if (type->code () == TYPE_CODE_METHODPTR || type->code () == TYPE_CODE_MEMBERPTR) error (_("Attempt to dereference pointer " @@ -1680,7 +1680,7 @@ eval_op_ind (struct type *expect_type, struct expression *exp, return value_x_unop (arg1, UNOP_IND, noside); else if (noside == EVAL_AVOID_SIDE_EFFECTS) { - type = check_typedef (value_type (arg1)); + type = check_typedef (arg1->type ()); /* If the type pointed to is dynamic then in order to resolve the dynamic properties we must actually dereference the pointer. @@ -1721,7 +1721,7 @@ eval_op_alignof (struct type *expect_type, struct expression *exp, enum noside noside, struct value *arg1) { - struct type *type = value_type (arg1); + struct type *type = arg1->type (); /* FIXME: This should be size_t. */ struct type *size_type = builtin_type (exp->gdbarch)->builtin_int; ULONGEST align = type_align (type); @@ -1759,13 +1759,13 @@ eval_op_preinc (struct type *expect_type, struct expression *exp, else { struct value *arg2; - if (ptrmath_type_p (exp->language_defn, value_type (arg1))) + if (ptrmath_type_p (exp->language_defn, arg1->type ())) arg2 = value_ptradd (arg1, 1); else { struct value *tmp = arg1; - arg2 = value_one (value_type (arg1)); + arg2 = value_one (arg1->type ()); binop_promote (exp->language_defn, exp->gdbarch, &tmp, &arg2); arg2 = value_binop (tmp, arg2, BINOP_ADD); } @@ -1790,13 +1790,13 @@ eval_op_predec (struct type *expect_type, struct expression *exp, else { struct value *arg2; - if (ptrmath_type_p (exp->language_defn, value_type (arg1))) + if (ptrmath_type_p (exp->language_defn, arg1->type ())) arg2 = value_ptradd (arg1, -1); else { struct value *tmp = arg1; - arg2 = value_one (value_type (arg1)); + arg2 = value_one (arg1->type ()); binop_promote (exp->language_defn, exp->gdbarch, &tmp, &arg2); arg2 = value_binop (tmp, arg2, BINOP_SUB); } @@ -1823,13 +1823,13 @@ eval_op_postinc (struct type *expect_type, struct expression *exp, struct value *arg3 = value_non_lval (arg1); struct value *arg2; - if (ptrmath_type_p (exp->language_defn, value_type (arg1))) + if (ptrmath_type_p (exp->language_defn, arg1->type ())) arg2 = value_ptradd (arg1, 1); else { struct value *tmp = arg1; - arg2 = value_one (value_type (arg1)); + arg2 = value_one (arg1->type ()); binop_promote (exp->language_defn, exp->gdbarch, &tmp, &arg2); arg2 = value_binop (tmp, arg2, BINOP_ADD); } @@ -1857,13 +1857,13 @@ eval_op_postdec (struct type *expect_type, struct expression *exp, struct value *arg3 = value_non_lval (arg1); struct value *arg2; - if (ptrmath_type_p (exp->language_defn, value_type (arg1))) + if (ptrmath_type_p (exp->language_defn, arg1->type ())) arg2 = value_ptradd (arg1, -1); else { struct value *tmp = arg1; - arg2 = value_one (value_type (arg1)); + arg2 = value_one (arg1->type ()); binop_promote (exp->language_defn, exp->gdbarch, &tmp, &arg2); arg2 = value_binop (tmp, arg2, BINOP_SUB); } @@ -1897,12 +1897,12 @@ eval_binop_assign_modify (struct type *expect_type, struct expression *exp, if (binop_user_defined_p (op, arg1, arg2)) return value_x_binop (arg1, arg2, BINOP_ASSIGN_MODIFY, op, noside); else if (op == BINOP_ADD && ptrmath_type_p (exp->language_defn, - value_type (arg1)) - && is_integral_type (value_type (arg2))) + arg1->type ()) + && is_integral_type (arg2->type ())) arg2 = value_ptradd (arg1, value_as_long (arg2)); else if (op == BINOP_SUB && ptrmath_type_p (exp->language_defn, - value_type (arg1)) - && is_integral_type (value_type (arg2))) + arg1->type ()) + && is_integral_type (arg2->type ())) arg2 = value_ptradd (arg1, - value_as_long (arg2)); else { @@ -1911,7 +1911,7 @@ eval_binop_assign_modify (struct type *expect_type, struct expression *exp, /* For shift and integer exponentiation operations, only promote the first argument. */ if ((op == BINOP_LSH || op == BINOP_RSH || op == BINOP_EXP) - && is_integral_type (value_type (arg2))) + && is_integral_type (arg2->type ())) unop_promote (exp->language_defn, exp->gdbarch, &tmp); else binop_promote (exp->language_defn, exp->gdbarch, &tmp, &arg2); @@ -2115,7 +2115,7 @@ eval_op_objc_msgcall (struct type *expect_type, struct expression *exp, if (method) { - if (value_type (method)->code () != TYPE_CODE_FUNC) + if (method->type ()->code () != TYPE_CODE_FUNC) error (_("method address has symbol information " "with non-function type; skipping")); @@ -2127,11 +2127,11 @@ eval_op_objc_msgcall (struct type *expect_type, struct expression *exp, function descriptors. */ if (struct_return) called_method - = value_from_pointer (lookup_pointer_type (value_type (method)), + = value_from_pointer (lookup_pointer_type (method->type ()), value_as_address (msg_send_stret)); else called_method - = value_from_pointer (lookup_pointer_type (value_type (method)), + = value_from_pointer (lookup_pointer_type (method->type ()), value_as_address (msg_send)); } else @@ -2153,7 +2153,7 @@ eval_op_objc_msgcall (struct type *expect_type, struct expression *exp, it's opinion (ie. through "whatis"), it won't offer it. */ - struct type *callee_type = value_type (called_method); + struct type *callee_type = called_method->type (); if (callee_type && callee_type->code () == TYPE_CODE_PTR) callee_type = callee_type->target_type (); @@ -2181,7 +2181,7 @@ eval_op_objc_msgcall (struct type *expect_type, struct expression *exp, if (gnu_runtime && (method != NULL)) { /* Function objc_msg_lookup returns a pointer. */ - struct type *tem_type = value_type (called_method); + struct type *tem_type = called_method->type (); tem_type = lookup_pointer_type (lookup_function_type (tem_type)); deprecated_set_value_type (called_method, tem_type); called_method = call_function_by_hand (called_method, NULL, args); @@ -2206,7 +2206,7 @@ eval_multi_subscript (struct type *expect_type, struct expression *exp, else { arg1 = coerce_ref (arg1); - struct type *type = check_typedef (value_type (arg1)); + struct type *type = check_typedef (arg1->type ()); switch (type->code ()) { @@ -2369,7 +2369,7 @@ array_operation::evaluate_struct_tuple (struct value *struct_val, enum noside noside, int nargs) { const std::vector &in_args = std::get<2> (m_storage); - struct type *struct_type = check_typedef (value_type (struct_val)); + struct type *struct_type = check_typedef (struct_val->type ()); struct type *field_type; int fieldno = -1; @@ -2408,7 +2408,7 @@ array_operation::evaluate_struct_tuple (struct value *struct_val, /* Now actually set the field in struct_val. */ /* Assign val to field fieldno. */ - if (value_type (val) != field_type) + if (val->type () != field_type) val = value_cast (field_type, val); bitsize = TYPE_FIELD_BITSIZE (struct_type, fieldno); @@ -2419,7 +2419,7 @@ array_operation::evaluate_struct_tuple (struct value *struct_val, value_as_long (val), bitpos % 8, bitsize); else memcpy (addr, value_contents (val).data (), - value_type (val)->length ()); + val->type ()->length ()); } return struct_val; @@ -2468,7 +2468,7 @@ array_operation::evaluate (struct type *expect_type, element = in_args[index - low_bound]->evaluate (element_type, exp, noside); - if (value_type (element) != element_type) + if (element->type () != element_type) element = value_cast (element_type, element); if (index > high_bound) /* To avoid memory corruption. */ @@ -2507,7 +2507,7 @@ array_operation::evaluate (struct type *expect_type, struct value *elem_val; elem_val = in_args[idx++]->evaluate (element_type, exp, noside); - range_low_type = range_high_type = value_type (elem_val); + range_low_type = range_high_type = elem_val->type (); range_low = range_high = value_as_long (elem_val); /* Check types of elements to avoid mixture of elements from @@ -2566,7 +2566,7 @@ unop_extract_operation::evaluate (struct type *expect_type, value *old_value = std::get<0> (m_storage)->evaluate (nullptr, exp, noside); struct type *type = get_type (); - if (type->length () > value_type (old_value)->length ()) + if (type->length () > old_value->type ()->length ()) error (_("length type is larger than the value type")); struct value *result = allocate_value (type); @@ -2585,13 +2585,13 @@ evaluate_subexp_for_address_base (struct expression *exp, enum noside noside, { if (noside == EVAL_AVOID_SIDE_EFFECTS) { - struct type *type = check_typedef (value_type (x)); + struct type *type = check_typedef (x->type ()); if (TYPE_IS_REFERENCE (type)) return value_zero (lookup_pointer_type (type->target_type ()), not_lval); else if (VALUE_LVAL (x) == lval_memory || value_must_coerce_to_target (x)) - return value_zero (lookup_pointer_type (value_type (x)), + return value_zero (lookup_pointer_type (x->type ()), not_lval); else error (_("Attempt to take address of " @@ -2655,7 +2655,7 @@ var_msym_value_operation::evaluate_for_address (struct expression *exp, value *val = evaluate_var_msym_value (noside, b.objfile, b.minsym); if (noside == EVAL_AVOID_SIDE_EFFECTS) { - struct type *type = lookup_pointer_type (value_type (val)); + struct type *type = lookup_pointer_type (val->type ()); return value_zero (type, not_lval); } else @@ -2676,7 +2676,7 @@ unop_memval_type_operation::evaluate_for_address (struct expression *exp, { value *typeval = std::get<0> (m_storage)->evaluate (nullptr, exp, EVAL_AVOID_SIDE_EFFECTS); - struct type *type = value_type (typeval); + struct type *type = typeval->type (); return value_cast (lookup_pointer_type (type), std::get<1> (m_storage)->evaluate (nullptr, exp, noside)); } @@ -2751,7 +2751,7 @@ value * operation::evaluate_for_sizeof (struct expression *exp, enum noside noside) { value *val = evaluate (nullptr, exp, EVAL_AVOID_SIDE_EFFECTS); - return evaluate_subexp_for_sizeof_base (exp, value_type (val)); + return evaluate_subexp_for_sizeof_base (exp, val->type ()); } value * @@ -2762,7 +2762,7 @@ var_msym_value_operation::evaluate_for_sizeof (struct expression *exp, const bound_minimal_symbol &b = std::get<0> (m_storage); value *mval = evaluate_var_msym_value (noside, b.objfile, b.minsym); - struct type *type = value_type (mval); + struct type *type = mval->type (); if (type->code () == TYPE_CODE_ERROR) error_unknown_type (b.minsym->print_name ()); @@ -2779,7 +2779,7 @@ subscript_operation::evaluate_for_sizeof (struct expression *exp, { value *val = std::get<0> (m_storage)->evaluate (nullptr, exp, EVAL_AVOID_SIDE_EFFECTS); - struct type *type = check_typedef (value_type (val)); + struct type *type = check_typedef (val->type ()); if (type->code () == TYPE_CODE_ARRAY) { type = check_typedef (type->target_type ()); @@ -2795,7 +2795,7 @@ subscript_operation::evaluate_for_sizeof (struct expression *exp, struct type *size_type = builtin_type (exp->gdbarch)->builtin_int; return value_from_longest - (size_type, (LONGEST) value_type (val)->length ()); + (size_type, (LONGEST) val->type ()->length ()); } } } @@ -2810,13 +2810,13 @@ unop_ind_base_operation::evaluate_for_sizeof (struct expression *exp, { value *val = std::get<0> (m_storage)->evaluate (nullptr, exp, EVAL_AVOID_SIDE_EFFECTS); - struct type *type = check_typedef (value_type (val)); + struct type *type = check_typedef (val->type ()); if (!type->is_pointer_or_reference () && type->code () != TYPE_CODE_ARRAY) error (_("Attempt to take contents of a non-pointer value.")); type = type->target_type (); if (is_dynamic_type (type)) - type = value_type (value_ind (val)); + type = value_ind (val)->type (); /* FIXME: This should be size_t. */ struct type *size_type = builtin_type (exp->gdbarch)->builtin_int; return value_from_longest (size_type, (LONGEST) type->length ()); @@ -2835,7 +2835,7 @@ unop_memval_type_operation::evaluate_for_sizeof (struct expression *exp, { value *typeval = std::get<0> (m_storage)->evaluate (nullptr, exp, EVAL_AVOID_SIDE_EFFECTS); - return evaluate_subexp_for_sizeof_base (exp, value_type (typeval)); + return evaluate_subexp_for_sizeof_base (exp, typeval->type ()); } value * @@ -2846,7 +2846,7 @@ var_value_operation::evaluate_for_sizeof (struct expression *exp, if (is_dynamic_type (type)) { value *val = evaluate (nullptr, exp, EVAL_NORMAL); - type = value_type (val); + type = val->type (); if (type->code () == TYPE_CODE_ARRAY) { /* FIXME: This should be size_t. */ diff --git a/gdb/expop.h b/gdb/expop.h index bfe55e4f2fd..7460343cb48 100644 --- a/gdb/expop.h +++ b/gdb/expop.h @@ -1330,7 +1330,7 @@ class comparison_operation value *lhs = std::get<0> (this->m_storage)->evaluate (nullptr, exp, noside); value *rhs - = std::get<1> (this->m_storage)->evaluate (value_type (lhs), exp, + = std::get<1> (this->m_storage)->evaluate (lhs->type (), exp, noside); return FUNC (expect_type, exp, noside, OP, lhs, rhs); } @@ -1613,7 +1613,7 @@ class decltype_operation || sub_op == STRUCTOP_PTR || sub_op == OP_SCOPE) { - struct type *type = value_type (result); + struct type *type = result->type (); if (!TYPE_IS_REFERENCE (type)) { @@ -1804,7 +1804,7 @@ class unop_memval_type_operation value *typeval = std::get<0> (m_storage)->evaluate (expect_type, exp, EVAL_AVOID_SIDE_EFFECTS); - struct type *type = value_type (typeval); + struct type *type = typeval->type (); value *val = std::get<1> (m_storage)->evaluate (expect_type, exp, noside); return eval_op_memval (expect_type, exp, noside, val, type); } @@ -1891,7 +1891,7 @@ class assign_operation many array elements". */ struct type *xtype = (VALUE_LVAL (lhs) == lval_internalvar ? nullptr - : value_type (lhs)); + : lhs->type ()); value *rhs = std::get<1> (m_storage)->evaluate (xtype, exp, noside); if (noside == EVAL_AVOID_SIDE_EFFECTS) @@ -2030,7 +2030,7 @@ class unop_cast_type_operation { value *val = std::get<0> (m_storage)->evaluate (nullptr, exp, EVAL_AVOID_SIDE_EFFECTS); - return std::get<1> (m_storage)->evaluate_for_cast (value_type (val), + return std::get<1> (m_storage)->evaluate_for_cast (val->type (), exp, noside); } @@ -2064,7 +2064,7 @@ class cxx_cast_operation { value *val = std::get<0> (m_storage)->evaluate (nullptr, exp, EVAL_AVOID_SIDE_EFFECTS); - struct type *type = value_type (val); + struct type *type = val->type (); value *rhs = std::get<1> (m_storage)->evaluate (type, exp, noside); return FUNC (type, rhs); } diff --git a/gdb/f-lang.c b/gdb/f-lang.c index a1e425a2d55..bf2471a1e2c 100644 --- a/gdb/f-lang.c +++ b/gdb/f-lang.c @@ -127,7 +127,7 @@ fortran_bounds_all_dims (bool lbound_p, struct gdbarch *gdbarch, struct value *array) { - type *array_type = check_typedef (value_type (array)); + type *array_type = check_typedef (array->type ()); int ndimensions = calc_f77_array_dims (array_type); /* Allocate a result value of the correct type. */ @@ -156,9 +156,9 @@ fortran_bounds_all_dims (bool lbound_p, /* And copy the value into the result value. */ struct value *v = value_from_longest (elm_type, b); - gdb_assert (dst_offset + value_type (v)->length () - <= value_type (result)->length ()); - gdb_assert (value_type (v)->length () == elm_len); + gdb_assert (dst_offset + v->type ()->length () + <= result->type ()->length ()); + gdb_assert (v->type ()->length () == elm_len); value_contents_copy (result, dst_offset, v, 0, elm_len); /* Peel another dimension of the array. */ @@ -178,7 +178,7 @@ fortran_bounds_for_dimension (bool lbound_p, value *array, value *dim_val, type* result_type) { /* Check the requested dimension is valid for this array. */ - type *array_type = check_typedef (value_type (array)); + type *array_type = check_typedef (array->type ()); int ndimensions = calc_f77_array_dims (array_type); long dim = value_as_long (dim_val); if (dim < 1 || dim > ndimensions) @@ -283,8 +283,8 @@ class fortran_array_repacker_base_impl void copy_element_to_dest (struct value *elt) { value_contents_copy (m_dest, m_dest_offset, elt, 0, - value_type (elt)->length ()); - m_dest_offset += value_type (elt)->length (); + elt->type ()->length ()); + m_dest_offset += elt->type ()->length (); } /* The value being written to. */ @@ -394,7 +394,7 @@ fortran_associated (struct gdbarch *gdbarch, const language_defn *lang, /* All Fortran pointers should have the associated property, this is how we know the pointer is pointing at something or not. */ - struct type *pointer_type = check_typedef (value_type (pointer)); + struct type *pointer_type = check_typedef (pointer->type ()); if (TYPE_ASSOCIATED_PROP (pointer_type) == nullptr && pointer_type->code () != TYPE_CODE_PTR) error (_("ASSOCIATED can only be applied to pointers")); @@ -431,7 +431,7 @@ fortran_associated (struct gdbarch *gdbarch, const language_defn *lang, /* The two argument case, is POINTER associated with TARGET? */ - struct type *target_type = check_typedef (value_type (target)); + struct type *target_type = check_typedef (target->type ()); struct type *pointer_target_type; if (pointer_type->code () == TYPE_CODE_PTR) @@ -588,7 +588,7 @@ static value * fortran_array_size (value *array, value *dim_val, type *result_type) { /* Check that ARRAY is the correct type. */ - struct type *array_type = check_typedef (value_type (array)); + struct type *array_type = check_typedef (array->type ()); if (array_type->code () != TYPE_CODE_ARRAY) error (_("SIZE can only be applied to arrays")); if (type_not_allocated (array_type) || type_not_associated (array_type)) @@ -600,7 +600,7 @@ fortran_array_size (value *array, value *dim_val, type *result_type) if (dim_val != nullptr) { - if (check_typedef (value_type (dim_val))->code () != TYPE_CODE_INT) + if (check_typedef (dim_val->type ())->code () != TYPE_CODE_INT) error (_("DIM argument to SIZE must be an integer")); dim = (int) value_as_long (dim_val); @@ -696,7 +696,7 @@ static struct value * fortran_array_shape (struct gdbarch *gdbarch, const language_defn *lang, struct value *val) { - struct type *val_type = check_typedef (value_type (val)); + struct type *val_type = check_typedef (val->type ()); /* If we are passed an array that is either not allocated, or not associated, then this is explicitly not allowed according to the @@ -741,9 +741,9 @@ fortran_array_shape (struct gdbarch *gdbarch, const language_defn *lang, /* And copy the value into the result value. */ struct value *v = value_from_longest (elm_type, dim_size); - gdb_assert (dst_offset + value_type (v)->length () - <= value_type (result)->length ()); - gdb_assert (value_type (v)->length () == elm_len); + gdb_assert (dst_offset + v->type ()->length () + <= result->type ()->length ()); + gdb_assert (v->type ()->length () == elm_len); value_contents_copy (result, dst_offset, v, 0, elm_len); /* Peel another dimension of the array. */ @@ -772,14 +772,14 @@ eval_op_f_abs (struct type *expect_type, struct expression *exp, enum exp_opcode opcode, struct value *arg1) { - struct type *type = value_type (arg1); + struct type *type = arg1->type (); switch (type->code ()) { case TYPE_CODE_FLT: { double d = fabs (target_float_to_host_double (value_contents (arg1).data (), - value_type (arg1))); + arg1->type ())); return value_from_host_double (type, d); } case TYPE_CODE_INT: @@ -800,8 +800,8 @@ eval_op_f_mod (struct type *expect_type, struct expression *exp, enum exp_opcode opcode, struct value *arg1, struct value *arg2) { - struct type *type = value_type (arg1); - if (type->code () != value_type (arg2)->code ()) + struct type *type = arg1->type (); + if (type->code () != arg2->type ()->code ()) error (_("non-matching types for parameters to MOD ()")); switch (type->code ()) { @@ -809,10 +809,10 @@ eval_op_f_mod (struct type *expect_type, struct expression *exp, { double d1 = target_float_to_host_double (value_contents (arg1).data (), - value_type (arg1)); + arg1->type ()); double d2 = target_float_to_host_double (value_contents (arg2).data (), - value_type (arg2)); + arg2->type ()); double d3 = fmod (d1, d2); return value_from_host_double (type, d3); } @@ -823,7 +823,7 @@ eval_op_f_mod (struct type *expect_type, struct expression *exp, if (v2 == 0) error (_("calling MOD (N, 0) is undefined")); LONGEST v3 = v1 - (v1 / v2) * v2; - return value_from_longest (value_type (arg1), v3); + return value_from_longest (arg1->type (), v3); } } error (_("MOD of type %s not supported"), TYPE_SAFE_NAME (type)); @@ -836,10 +836,10 @@ eval_op_f_mod (struct type *expect_type, struct expression *exp, static value * fortran_ceil_operation (value *arg1, type *result_type) { - if (value_type (arg1)->code () != TYPE_CODE_FLT) + if (arg1->type ()->code () != TYPE_CODE_FLT) error (_("argument to CEILING must be of type float")); double val = target_float_to_host_double (value_contents (arg1).data (), - value_type (arg1)); + arg1->type ()); val = ceil (val); return value_from_longest (result_type, val); } @@ -875,10 +875,10 @@ eval_op_f_ceil (type *expect_type, expression *exp, noside noside, static value * fortran_floor_operation (value *arg1, type *result_type) { - if (value_type (arg1)->code () != TYPE_CODE_FLT) + if (arg1->type ()->code () != TYPE_CODE_FLT) error (_("argument to FLOOR must be of type float")); double val = target_float_to_host_double (value_contents (arg1).data (), - value_type (arg1)); + arg1->type ()); val = floor (val); return value_from_longest (result_type, val); } @@ -915,8 +915,8 @@ eval_op_f_modulo (struct type *expect_type, struct expression *exp, enum exp_opcode opcode, struct value *arg1, struct value *arg2) { - struct type *type = value_type (arg1); - if (type->code () != value_type (arg2)->code ()) + struct type *type = arg1->type (); + if (type->code () != arg2->type ()->code ()) error (_("non-matching types for parameters to MODULO ()")); /* MODULO(A, P) = A - FLOOR (A / P) * P */ switch (type->code ()) @@ -928,16 +928,16 @@ eval_op_f_modulo (struct type *expect_type, struct expression *exp, LONGEST result = a - (a / p) * p; if (result != 0 && (a < 0) != (p < 0)) result += p; - return value_from_longest (value_type (arg1), result); + return value_from_longest (arg1->type (), result); } case TYPE_CODE_FLT: { double a = target_float_to_host_double (value_contents (arg1).data (), - value_type (arg1)); + arg1->type ()); double p = target_float_to_host_double (value_contents (arg2).data (), - value_type (arg2)); + arg2->type ()); double result = fmod (a, p); if (result != 0 && (a < 0.0) != (p < 0.0)) result += p; @@ -957,11 +957,11 @@ eval_op_f_cmplx (type *expect_type, expression *exp, noside noside, type *result_type = builtin_f_type (exp->gdbarch)->builtin_complex; - if (value_type (arg1)->code () == TYPE_CODE_COMPLEX) + if (arg1->type ()->code () == TYPE_CODE_COMPLEX) return value_cast (result_type, arg1); else return value_literal_complex (arg1, - value_zero (value_type (arg1), not_lval), + value_zero (arg1->type (), not_lval), result_type); } @@ -973,8 +973,8 @@ eval_op_f_cmplx (struct type *expect_type, struct expression *exp, enum exp_opcode opcode, struct value *arg1, struct value *arg2) { - if (value_type (arg1)->code () == TYPE_CODE_COMPLEX - || value_type (arg2)->code () == TYPE_CODE_COMPLEX) + if (arg1->type ()->code () == TYPE_CODE_COMPLEX + || arg2->type ()->code () == TYPE_CODE_COMPLEX) error (_("Types of arguments for CMPLX called with more then one argument " "must be REAL or INTEGER")); @@ -989,8 +989,8 @@ eval_op_f_cmplx (type *expect_type, expression *exp, noside noside, exp_opcode opcode, value *arg1, value *arg2, type *kind_arg) { gdb_assert (kind_arg->code () == TYPE_CODE_COMPLEX); - if (value_type (arg1)->code () == TYPE_CODE_COMPLEX - || value_type (arg2)->code () == TYPE_CODE_COMPLEX) + if (arg1->type ()->code () == TYPE_CODE_COMPLEX + || arg2->type ()->code () == TYPE_CODE_COMPLEX) error (_("Types of arguments for CMPLX called with more then one argument " "must be REAL or INTEGER")); @@ -1005,7 +1005,7 @@ eval_op_f_kind (struct type *expect_type, struct expression *exp, enum exp_opcode opcode, struct value *arg1) { - struct type *type = value_type (arg1); + struct type *type = arg1->type (); switch (type->code ()) { @@ -1030,7 +1030,7 @@ eval_op_f_allocated (struct type *expect_type, struct expression *exp, enum noside noside, enum exp_opcode op, struct value *arg1) { - struct type *type = check_typedef (value_type (arg1)); + struct type *type = check_typedef (arg1->type ()); if (type->code () != TYPE_CODE_ARRAY) error (_("ALLOCATED can only be applied to arrays")); struct type *result_type @@ -1052,7 +1052,7 @@ eval_op_f_rank (struct type *expect_type, struct type *result_type = builtin_f_type (exp->gdbarch)->builtin_integer; - struct type *type = check_typedef (value_type (arg1)); + struct type *type = check_typedef (arg1->type ()); if (type->code () != TYPE_CODE_ARRAY) return value_from_longest (result_type, 0); LONGEST ndim = calc_f77_array_dims (type); @@ -1092,7 +1092,7 @@ fortran_undetermined::value_subarray (value *array, struct expression *exp, enum noside noside) { - type *original_array_type = check_typedef (value_type (array)); + type *original_array_type = check_typedef (array->type ()); bool is_string_p = original_array_type->code () == TYPE_CODE_STRING; const std::vector &ops = std::get<1> (m_storage); int nargs = ops.size (); @@ -1443,7 +1443,7 @@ fortran_undetermined::value_subarray (value *array, struct value *dest = allocate_value (repacked_array_type); if (value_lazy (array) || (total_offset + array_slice_type->length () - > check_typedef (value_type (array))->length ())) + > check_typedef (array->type ())->length ())) { fortran_array_walker p (array_slice_type, value_address (array) + total_offset, dest); @@ -1468,7 +1468,7 @@ fortran_undetermined::value_subarray (value *array, contents we're looking for exist. */ if (value_lazy (array) || (total_offset + array_slice_type->length () - > check_typedef (value_type (array))->length ())) + > check_typedef (array->type ())->length ())) array = value_at_lazy (array_slice_type, value_address (array) + total_offset); else @@ -1492,9 +1492,9 @@ fortran_undetermined::evaluate (struct type *expect_type, { value *callee = std::get<0> (m_storage)->evaluate (nullptr, exp, noside); if (noside == EVAL_AVOID_SIDE_EFFECTS - && is_dynamic_type (value_type (callee))) + && is_dynamic_type (callee->type ())) callee = std::get<0> (m_storage)->evaluate (nullptr, exp, EVAL_NORMAL); - struct type *type = check_typedef (value_type (callee)); + struct type *type = check_typedef (callee->type ()); enum type_code code = type->code (); if (code == TYPE_CODE_PTR) @@ -1510,7 +1510,7 @@ fortran_undetermined::evaluate (struct type *expect_type, || target_type->code () == TYPE_CODE_FUNC) { callee = value_ind (callee); - type = check_typedef (value_type (callee)); + type = check_typedef (callee->type ()); code = type->code (); } } @@ -1534,7 +1534,7 @@ fortran_undetermined::evaluate (struct type *expect_type, for (int tem = 0; tem < argvec.size (); tem++) argvec[tem] = fortran_prepare_argument (exp, actual[tem].get (), tem, is_internal_func, - value_type (callee), + callee->type (), noside); return evaluate_subexp_do_call (exp, noside, callee, argvec, nullptr, expect_type); @@ -1552,7 +1552,7 @@ fortran_bound_1arg::evaluate (struct type *expect_type, { bool lbound_p = std::get<0> (m_storage) == FORTRAN_LBOUND; value *arg1 = std::get<1> (m_storage)->evaluate (nullptr, exp, noside); - fortran_require_array (value_type (arg1), lbound_p); + fortran_require_array (arg1->type (), lbound_p); return fortran_bounds_all_dims (lbound_p, exp->gdbarch, arg1); } @@ -1563,11 +1563,11 @@ fortran_bound_2arg::evaluate (struct type *expect_type, { bool lbound_p = std::get<0> (m_storage) == FORTRAN_LBOUND; value *arg1 = std::get<1> (m_storage)->evaluate (nullptr, exp, noside); - fortran_require_array (value_type (arg1), lbound_p); + fortran_require_array (arg1->type (), lbound_p); /* User asked for the bounds of a specific dimension of the array. */ value *arg2 = std::get<2> (m_storage)->evaluate (nullptr, exp, noside); - type *type_arg2 = check_typedef (value_type (arg2)); + type *type_arg2 = check_typedef (arg2->type ()); if (type_arg2->code () != TYPE_CODE_INT) { if (lbound_p) @@ -1587,11 +1587,11 @@ fortran_bound_3arg::evaluate (type *expect_type, { const bool lbound_p = std::get<0> (m_storage) == FORTRAN_LBOUND; value *arg1 = std::get<1> (m_storage)->evaluate (nullptr, exp, noside); - fortran_require_array (value_type (arg1), lbound_p); + fortran_require_array (arg1->type (), lbound_p); /* User asked for the bounds of a specific dimension of the array. */ value *arg2 = std::get<2> (m_storage)->evaluate (nullptr, exp, noside); - type *type_arg2 = check_typedef (value_type (arg2)); + type *type_arg2 = check_typedef (arg2->type ()); if (type_arg2->code () != TYPE_CODE_INT) { if (lbound_p) @@ -1618,7 +1618,7 @@ fortran_structop_operation::evaluate (struct type *expect_type, const char *str = std::get<1> (m_storage).c_str (); if (noside == EVAL_AVOID_SIDE_EFFECTS) { - struct type *type = lookup_struct_elt_type (value_type (arg1), str, 1); + struct type *type = lookup_struct_elt_type (arg1->type (), str, 1); if (type != nullptr && is_dynamic_type (type)) arg1 = std::get<0> (m_storage)->evaluate (nullptr, exp, EVAL_NORMAL); @@ -1628,7 +1628,7 @@ fortran_structop_operation::evaluate (struct type *expect_type, if (noside == EVAL_AVOID_SIDE_EFFECTS) { - struct type *elt_type = value_type (elt); + struct type *elt_type = elt->type (); if (is_dynamic_type (elt_type)) { const gdb_byte *valaddr = value_contents_for_printing (elt).data (); @@ -1874,7 +1874,7 @@ fortran_argument_convert (struct value *value, bool is_artificial) convenience variables and user input. */ if (VALUE_LVAL (value) != lval_memory) { - struct type *type = value_type (value); + struct type *type = value->type (); const int length = type->length (); const CORE_ADDR addr = value_as_long (value_allocate_space_in_inferior (length)); @@ -1953,8 +1953,8 @@ fortran_prepare_argument (struct expression *exp, struct type * fortran_preserve_arg_pointer (struct value *arg, struct type *type) { - if (value_type (arg)->code () == TYPE_CODE_PTR) - return value_type (arg); + if (arg->type ()->code () == TYPE_CODE_PTR) + return arg->type (); return type; } diff --git a/gdb/f-valprint.c b/gdb/f-valprint.c index 55dbcc8309f..1be6294fadb 100644 --- a/gdb/f-valprint.c +++ b/gdb/f-valprint.c @@ -432,7 +432,7 @@ f_language::value_print_inner (struct value *val, struct ui_file *stream, int recurse, const struct value_print_options *options) const { - struct type *type = check_typedef (value_type (val)); + struct type *type = check_typedef (val->type ()); struct gdbarch *gdbarch = type->arch (); int printed_field = 0; /* Number of fields printed. */ struct type *elttype; diff --git a/gdb/findcmd.c b/gdb/findcmd.c index 637d3fdfaf9..42604b1e85e 100644 --- a/gdb/findcmd.c +++ b/gdb/findcmd.c @@ -162,7 +162,7 @@ parse_find_args (const char *args, ULONGEST *max_countp, s = skip_spaces (s); v = parse_to_comma_and_eval (&s); - t = value_type (v); + t = v->type (); if (size != '\0') { diff --git a/gdb/findvar.c b/gdb/findvar.c index 02d498d8c58..6683bf761ad 100644 --- a/gdb/findvar.c +++ b/gdb/findvar.c @@ -844,7 +844,7 @@ read_frame_register_value (struct value *value, frame_info_ptr frame) LONGEST offset = 0; LONGEST reg_offset = value_offset (value); int regnum = VALUE_REGNUM (value); - int len = type_length_units (check_typedef (value_type (value))); + int len = type_length_units (check_typedef (value->type ())); gdb_assert (VALUE_LVAL (value) == lval_register); @@ -859,7 +859,7 @@ read_frame_register_value (struct value *value, frame_info_ptr frame) while (len > 0) { struct value *regval = get_frame_register_value (frame, regnum); - int reg_len = type_length_units (value_type (regval)) - reg_offset; + int reg_len = type_length_units (regval->type ()) - reg_offset; /* If the register length is larger than the number of bytes remaining to copy, then only copy the appropriate bytes. */ diff --git a/gdb/frame.c b/gdb/frame.c index 9235a2ceb38..f845f8caf78 100644 --- a/gdb/frame.c +++ b/gdb/frame.c @@ -1202,9 +1202,9 @@ frame_register_unwind (frame_info_ptr next_frame, int regnum, { if (!*optimizedp && !*unavailablep) memcpy (bufferp, value_contents_all (value).data (), - value_type (value)->length ()); + value->type ()->length ()); else - memset (bufferp, 0, value_type (value)->length ()); + memset (bufferp, 0, value->type ()->length ()); } /* Dispose of the new value. This prevents watchpoints from diff --git a/gdb/frv-tdep.c b/gdb/frv-tdep.c index 1a709b917c3..0922a8e3afe 100644 --- a/gdb/frv-tdep.c +++ b/gdb/frv-tdep.c @@ -1211,7 +1211,7 @@ frv_push_dummy_call (struct gdbarch *gdbarch, struct value *function, stack_space = 0; for (argnum = 0; argnum < nargs; ++argnum) - stack_space += align_up (value_type (args[argnum])->length (), 4); + stack_space += align_up (args[argnum]->type ()->length (), 4); stack_space -= (6 * 4); if (stack_space > 0) @@ -1231,7 +1231,7 @@ frv_push_dummy_call (struct gdbarch *gdbarch, struct value *function, for (argnum = 0; argnum < nargs; ++argnum) { arg = args[argnum]; - arg_type = check_typedef (value_type (arg)); + arg_type = check_typedef (arg->type ()); len = arg_type->length (); typecode = arg_type->code (); diff --git a/gdb/gdbtypes.c b/gdb/gdbtypes.c index 45751c9c895..b14f051c013 100644 --- a/gdb/gdbtypes.c +++ b/gdb/gdbtypes.c @@ -4006,7 +4006,7 @@ is_unique_ancestor (struct type *base, struct value *val) { int offset = -1; - return is_unique_ancestor_worker (base, value_type (val), &offset, + return is_unique_ancestor_worker (base, val->type (), &offset, value_contents_for_printing (val).data (), value_embedded_offset (val), value_address (val), val) == 1; @@ -4177,7 +4177,7 @@ rank_function (gdb::array_view parms, size_t min_len = std::min (parms.size (), args.size ()); for (size_t i = 0; i < min_len; i++) - bv.push_back (rank_one_type (parms[i], value_type (args[i]), + bv.push_back (rank_one_type (parms[i], args[i]->type (), args[i])); /* If more arguments than parameters, add dummy entries. */ @@ -4541,7 +4541,7 @@ rank_one_type_parm_ptr (struct type *parm, struct type *arg, struct value *value case TYPE_CODE_FUNC: return rank_one_type (parm->target_type (), arg, NULL); case TYPE_CODE_INT: - if (value != NULL && value_type (value)->code () == TYPE_CODE_INT) + if (value != NULL && value->type ()->code () == TYPE_CODE_INT) { if (value_as_long (value) == 0) { diff --git a/gdb/gdbtypes.h b/gdb/gdbtypes.h index aaed12f97ee..2a1bf31f290 100644 --- a/gdb/gdbtypes.h +++ b/gdb/gdbtypes.h @@ -932,7 +932,7 @@ struct type /* Note that if thistype is a TYPEDEF type, you have to call check_typedef. But check_typedef does set the TYPE_LENGTH of the TYPEDEF type, so you only have to call check_typedef once. Since allocate_value - calls check_typedef, VALUE_TYPE (X)->length () is safe. */ + calls check_typedef, X->type ()->length () is safe. */ ULONGEST length () const { return this->m_length; diff --git a/gdb/gnu-v2-abi.c b/gdb/gnu-v2-abi.c index cee45ead123..c28df183c8b 100644 --- a/gdb/gnu-v2-abi.c +++ b/gdb/gnu-v2-abi.c @@ -85,7 +85,7 @@ gnuv2_virtual_fn_field (struct value **arg1p, struct fn_field * f, int j, struct type * type, int offset) { struct value *arg1 = *arg1p; - struct type *type1 = check_typedef (value_type (arg1)); + struct type *type1 = check_typedef (arg1->type ()); struct type *entry_type; /* First, get the virtual function table pointer. That comes with a strange type, so cast it to type `pointer to long' (which @@ -113,7 +113,7 @@ gnuv2_virtual_fn_field (struct value **arg1p, struct fn_field * f, int j, struct value *tmp = value_cast (context, value_addr (arg1)); arg1 = value_ind (tmp); - type1 = check_typedef (value_type (arg1)); + type1 = check_typedef (arg1->type ()); } context = type1; @@ -132,8 +132,8 @@ gnuv2_virtual_fn_field (struct value **arg1p, struct fn_field * f, int j, /* With older versions of g++, the vtbl field pointed to an array of structures. Nowadays it points directly to the structure. */ - if (value_type (vtbl)->code () == TYPE_CODE_PTR - && value_type (vtbl)->target_type ()->code () == TYPE_CODE_ARRAY) + if (vtbl->type ()->code () == TYPE_CODE_PTR + && vtbl->type ()->target_type ()->code () == TYPE_CODE_ARRAY) { /* Handle the case where the vtbl field points to an array of structures. */ @@ -153,7 +153,7 @@ gnuv2_virtual_fn_field (struct value **arg1p, struct fn_field * f, int j, entry = value_ind (vtbl); } - entry_type = check_typedef (value_type (entry)); + entry_type = check_typedef (entry->type ()); if (entry_type->code () == TYPE_CODE_STRUCT) { @@ -203,7 +203,7 @@ gnuv2_value_rtti_type (struct value *v, int *full, LONGEST *top, int *using_enc) *using_enc = 0; /* Get declared type. */ - known_type = value_type (v); + known_type = v->type (); known_type = check_typedef (known_type); /* RTTI works only or class objects. */ if (known_type->code () != TYPE_CODE_STRUCT) diff --git a/gdb/gnu-v3-abi.c b/gdb/gnu-v3-abi.c index 6f5b87f1308..d9e0d579259 100644 --- a/gdb/gnu-v3-abi.c +++ b/gdb/gnu-v3-abi.c @@ -298,7 +298,7 @@ gnuv3_rtti_type (struct value *value, int *full_p, LONGEST *top_p, int *using_enc_p) { struct gdbarch *gdbarch; - struct type *values_type = check_typedef (value_type (value)); + struct type *values_type = check_typedef (value->type ()); struct value *vtable; struct minimal_symbol *vtable_symbol; const char *vtable_symbol_name; @@ -389,7 +389,7 @@ gnuv3_get_virtual_fn (struct gdbarch *gdbarch, struct value *container, struct value *vtable, *vfn; /* Every class with virtual functions must have a vtable. */ - vtable = gnuv3_get_vtable (gdbarch, value_type (container), + vtable = gnuv3_get_vtable (gdbarch, container->type (), value_as_address (value_addr (container))); gdb_assert (vtable != NULL); @@ -419,7 +419,7 @@ gnuv3_virtual_fn_field (struct value **value_p, struct fn_field *f, int j, struct type *vfn_base, int offset) { - struct type *values_type = check_typedef (value_type (*value_p)); + struct type *values_type = check_typedef ((*value_p)->type ()); struct gdbarch *gdbarch; /* Some simple sanity checks. */ @@ -740,10 +740,10 @@ gnuv3_method_ptr_to_value (struct value **this_p, struct value *method_ptr) LONGEST adjustment; int vbit; - self_type = TYPE_SELF_TYPE (check_typedef (value_type (method_ptr))); + self_type = TYPE_SELF_TYPE (check_typedef (method_ptr->type ())); final_type = lookup_pointer_type (self_type); - method_type = check_typedef (value_type (method_ptr))->target_type (); + method_type = check_typedef (method_ptr->type ())->target_type (); /* Extract the pointer to member. */ gdbarch = self_type->arch (); @@ -845,7 +845,7 @@ compute_vtable_size (htab_t offset_hash, struct value *value) { int i; - struct type *type = check_typedef (value_type (value)); + struct type *type = check_typedef (value->type ()); void **slot; struct value_and_voffset search_vo, *current_vo; @@ -902,7 +902,7 @@ print_one_vtable (struct gdbarch *gdbarch, struct value *value, struct value_print_options *opts) { int i; - struct type *type = check_typedef (value_type (value)); + struct type *type = check_typedef (value->type ()); struct value *vtable; CORE_ADDR vt_addr; @@ -963,11 +963,11 @@ gnuv3_print_vtable (struct value *value) int count; value = coerce_ref (value); - type = check_typedef (value_type (value)); + type = check_typedef (value->type ()); if (type->code () == TYPE_CODE_PTR) { value = value_ind (value); - type = check_typedef (value_type (value)); + type = check_typedef (value->type ()); } get_user_print_options (&opts); @@ -976,7 +976,7 @@ gnuv3_print_vtable (struct value *value) if (opts.objectprint) { value = value_full_object (value, NULL, 0, 0, 0); - type = check_typedef (value_type (value)); + type = check_typedef (value->type ()); } gdbarch = type->arch (); @@ -1105,7 +1105,7 @@ gnuv3_get_typeid (struct value *value) if (value_lval_const (value) == lval_memory) value = coerce_ref (value); - type = check_typedef (value_type (value)); + type = check_typedef (value->type ()); /* In the non_lvalue case, a reference might have slipped through here. */ @@ -1168,7 +1168,7 @@ gnuv3_get_typeid (struct value *value) static std::string gnuv3_get_typename_from_type_info (struct value *type_info_ptr) { - struct gdbarch *gdbarch = value_type (type_info_ptr)->arch (); + struct gdbarch *gdbarch = type_info_ptr->type ()->arch (); struct bound_minimal_symbol typeinfo_sym; CORE_ADDR addr; const char *symname; @@ -1209,7 +1209,7 @@ gnuv3_get_type_from_type_info (struct value *type_info_ptr) std::string type_name = gnuv3_get_typename_from_type_info (type_info_ptr); expression_up expr (parse_expression (type_name.c_str ())); struct value *type_val = evaluate_type (expr.get ()); - return value_type (type_val); + return type_val->type (); } /* Determine if we are currently in a C++ thunk. If so, get the address diff --git a/gdb/go-valprint.c b/gdb/go-valprint.c index 5ded53ec633..4d3185ed7d2 100644 --- a/gdb/go-valprint.c +++ b/gdb/go-valprint.c @@ -91,7 +91,7 @@ go_language::value_print_inner (struct value *val, struct ui_file *stream, int recurse, const struct value_print_options *options) const { - struct type *type = check_typedef (value_type (val)); + struct type *type = check_typedef (val->type ()); switch (type->code ()) { diff --git a/gdb/guile/scm-math.c b/gdb/guile/scm-math.c index 26019b4df3f..af472c1aff3 100644 --- a/gdb/guile/scm-math.c +++ b/gdb/guile/scm-math.c @@ -109,7 +109,7 @@ vlscm_unop_gdbthrow (enum valscm_unary_opcode opcode, SCM x, res_val = arg1; break; case VALSCM_ABS: - if (value_less (arg1, value_zero (value_type (arg1), not_lval))) + if (value_less (arg1, value_zero (arg1->type (), not_lval))) res_val = value_neg (arg1); else res_val = arg1; @@ -160,8 +160,8 @@ vlscm_binop_gdbthrow (enum valscm_binary_opcode opcode, SCM x, SCM y, { case VALSCM_ADD: { - struct type *ltype = value_type (arg1); - struct type *rtype = value_type (arg2); + struct type *ltype = arg1->type (); + struct type *rtype = arg2->type (); ltype = check_typedef (ltype); ltype = STRIP_REFERENCE (ltype); @@ -180,8 +180,8 @@ vlscm_binop_gdbthrow (enum valscm_binary_opcode opcode, SCM x, SCM y, break; case VALSCM_SUB: { - struct type *ltype = value_type (arg1); - struct type *rtype = value_type (arg2); + struct type *ltype = arg1->type (); + struct type *rtype = arg2->type (); ltype = check_typedef (ltype); ltype = STRIP_REFERENCE (ltype); diff --git a/gdb/guile/scm-pretty-print.c b/gdb/guile/scm-pretty-print.c index cb6677c8831..3e93f3523be 100644 --- a/gdb/guile/scm-pretty-print.c +++ b/gdb/guile/scm-pretty-print.c @@ -956,7 +956,7 @@ gdbscm_apply_val_pretty_printer (const struct extension_language_defn *extlang, const struct value_print_options *options, const struct language_defn *language) { - struct type *type = value_type (value); + struct type *type = value->type (); struct gdbarch *gdbarch = type->arch (); SCM exception = SCM_BOOL_F; SCM printer = SCM_BOOL_F; diff --git a/gdb/guile/scm-value.c b/gdb/guile/scm-value.c index b9948303bc1..0d9e15a7404 100644 --- a/gdb/guile/scm-value.c +++ b/gdb/guile/scm-value.c @@ -470,7 +470,7 @@ gdbscm_value_referenced_value (SCM self) struct value *res_val; - switch (check_typedef (value_type (value))->code ()) + switch (check_typedef (value->type ())->code ()) { case TYPE_CODE_PTR: res_val = value_ind (value); @@ -548,7 +548,7 @@ gdbscm_value_type (SCM self) struct value *value = v_smob->value; if (SCM_UNBNDP (v_smob->type)) - v_smob->type = tyscm_scm_from_type (value_type (value)); + v_smob->type = tyscm_scm_from_type (value->type ()); return v_smob->type; } @@ -571,7 +571,7 @@ gdbscm_value_dynamic_type (SCM self) { scoped_value_mark free_values; - type = value_type (value); + type = value->type (); type = check_typedef (type); if (((type->code () == TYPE_CODE_PTR) @@ -710,7 +710,7 @@ gdbscm_value_subscript (SCM self, SCM index_scm) value_smob *v_smob = vlscm_get_value_smob_arg_unsafe (self, SCM_ARG1, FUNC_NAME); struct value *value = v_smob->value; - struct type *type = value_type (value); + struct type *type = value->type (); SCM_ASSERT (type != NULL, self, SCM_ARG2, FUNC_NAME); @@ -732,7 +732,7 @@ gdbscm_value_subscript (SCM self, SCM index_scm) Check the value's type is something that can be accessed via a subscript. */ struct value *tmp = coerce_ref (value); - struct type *tmp_type = check_typedef (value_type (tmp)); + struct type *tmp_type = check_typedef (tmp->type ()); if (tmp_type->code () != TYPE_CODE_ARRAY && tmp_type->code () != TYPE_CODE_PTR) error (_("Cannot subscript requested type")); @@ -758,7 +758,7 @@ gdbscm_value_call (SCM self, SCM args) gdbscm_gdb_exception exc {}; try { - ftype = check_typedef (value_type (function)); + ftype = check_typedef (function->type ()); } catch (const gdb_exception &except) { @@ -821,7 +821,7 @@ gdbscm_value_to_bytevector (SCM self) const gdb_byte *contents = NULL; SCM bv; - type = value_type (value); + type = value->type (); gdbscm_gdb_exception exc {}; try @@ -866,7 +866,7 @@ gdbscm_value_to_bool (SCM self) struct type *type; LONGEST l = 0; - type = value_type (value); + type = value->type (); gdbscm_gdb_exception exc {}; try @@ -910,7 +910,7 @@ gdbscm_value_to_integer (SCM self) struct type *type; LONGEST l = 0; - type = value_type (value); + type = value->type (); gdbscm_gdb_exception exc {}; try @@ -958,7 +958,7 @@ gdbscm_value_to_real (SCM self) double d = 0; struct value *check = nullptr; - type = value_type (value); + type = value->type (); gdbscm_gdb_exception exc {}; try @@ -1162,7 +1162,7 @@ gdbscm_value_to_lazy_string (SCM self, SCM rest) struct type *type, *realtype; CORE_ADDR addr; - type = value_type (value); + type = value->type (); realtype = check_typedef (type); switch (realtype->code ()) diff --git a/gdb/h8300-tdep.c b/gdb/h8300-tdep.c index 0ac4608fe1e..d53b6857ba5 100644 --- a/gdb/h8300-tdep.c +++ b/gdb/h8300-tdep.c @@ -632,7 +632,7 @@ h8300_push_dummy_call (struct gdbarch *gdbarch, struct value *function, /* Now make sure there's space on the stack for the arguments. We may over-allocate a little here, but that won't hurt anything. */ for (argument = 0; argument < nargs; argument++) - stack_alloc += align_up (value_type (args[argument])->length (), wordsize); + stack_alloc += align_up (args[argument]->type ()->length (), wordsize); sp -= stack_alloc; /* Now load as many arguments as possible into registers, and push @@ -645,7 +645,7 @@ h8300_push_dummy_call (struct gdbarch *gdbarch, struct value *function, for (argument = 0; argument < nargs; argument++) { - struct type *type = value_type (args[argument]); + struct type *type = args[argument]->type (); int len = type->length (); char *contents = (char *) value_contents (args[argument]).data (); diff --git a/gdb/hppa-tdep.c b/gdb/hppa-tdep.c index 920b872d12d..08fea0c091b 100644 --- a/gdb/hppa-tdep.c +++ b/gdb/hppa-tdep.c @@ -731,7 +731,7 @@ hppa32_push_dummy_call (struct gdbarch *gdbarch, struct value *function, for (i = 0; i < nargs; i++) { struct value *arg = args[i]; - struct type *type = check_typedef (value_type (arg)); + struct type *type = check_typedef (arg->type ()); /* The corresponding parameter that is pushed onto the stack, and [possibly] passed in a register. */ gdb_byte param_val[8]; @@ -965,7 +965,7 @@ hppa64_push_dummy_call (struct gdbarch *gdbarch, struct value *function, for (i = 0; i < nargs; i++) { struct value *arg = args[i]; - struct type *type = value_type (arg); + struct type *type = arg->type (); int len = type->length (); const bfd_byte *valbuf; bfd_byte fptrbuf[8]; diff --git a/gdb/i386-tdep.c b/gdb/i386-tdep.c index 580664d2ce5..f8907f5c4f4 100644 --- a/gdb/i386-tdep.c +++ b/gdb/i386-tdep.c @@ -3389,7 +3389,7 @@ i386_pseudo_register_read_into_value (struct gdbarch *gdbarch, status = regcache->raw_read (fpnum, raw_buf); if (status != REG_VALID) mark_value_bytes_unavailable (result_value, 0, - value_type (result_value)->length ()); + result_value->type ()->length ()); else memcpy (buf, raw_buf, register_size (gdbarch, regnum)); } @@ -3526,7 +3526,7 @@ i386_pseudo_register_read_into_value (struct gdbarch *gdbarch, status = regcache->raw_read (gpnum, raw_buf); if (status != REG_VALID) mark_value_bytes_unavailable (result_value, 0, - value_type (result_value)->length ()); + result_value->type ()->length ()); else memcpy (buf, raw_buf, 2); } @@ -3539,7 +3539,7 @@ i386_pseudo_register_read_into_value (struct gdbarch *gdbarch, status = regcache->raw_read (gpnum % 4, raw_buf); if (status != REG_VALID) mark_value_bytes_unavailable (result_value, 0, - value_type (result_value)->length ()); + result_value->type ()->length ()); else if (gpnum >= 4) memcpy (buf, raw_buf + 1, 1); else diff --git a/gdb/i386-windows-tdep.c b/gdb/i386-windows-tdep.c index 595c58e70f5..686004a5d32 100644 --- a/gdb/i386-windows-tdep.c +++ b/gdb/i386-windows-tdep.c @@ -114,7 +114,7 @@ i386_windows_push_dummy_call (struct gdbarch *gdbarch, struct value *function, calling convention is used, so the 'this' pointer is passed in ECX. */ bool thiscall = false; - struct type *type = check_typedef (value_type (function)); + struct type *type = check_typedef (function->type ()); if (type->code () == TYPE_CODE_PTR) type = check_typedef (type->target_type ()); diff --git a/gdb/ia64-tdep.c b/gdb/ia64-tdep.c index f446c41c411..7f09ce4b835 100644 --- a/gdb/ia64-tdep.c +++ b/gdb/ia64-tdep.c @@ -3697,7 +3697,7 @@ ia64_push_dummy_call (struct gdbarch *gdbarch, struct value *function, for (argno = 0; argno < nargs; argno++) { arg = args[argno]; - type = check_typedef (value_type (arg)); + type = check_typedef (arg->type ()); len = type->length (); if ((nslots & 1) && slot_alignment_is_next_even (type)) @@ -3740,7 +3740,7 @@ ia64_push_dummy_call (struct gdbarch *gdbarch, struct value *function, struct type *float_elt_type; arg = args[argno]; - type = check_typedef (value_type (arg)); + type = check_typedef (arg->type ()); len = type->length (); /* Special handling for function parameters. */ diff --git a/gdb/infcall.c b/gdb/infcall.c index 4c2a4e4f400..b58dc201aeb 100644 --- a/gdb/infcall.c +++ b/gdb/infcall.c @@ -181,7 +181,7 @@ value_arg_coerce (struct gdbarch *gdbarch, struct value *arg, struct type *param_type, int is_prototyped) { const struct builtin_type *builtin = builtin_type (gdbarch); - struct type *arg_type = check_typedef (value_type (arg)); + struct type *arg_type = check_typedef (arg->type ()); struct type *type = param_type ? check_typedef (param_type) : arg_type; @@ -278,7 +278,7 @@ find_function_addr (struct value *function, struct type **retval_type, struct type **function_type) { - struct type *ftype = check_typedef (value_type (function)); + struct type *ftype = check_typedef (function->type ()); struct gdbarch *gdbarch = ftype->arch (); struct type *value_type = NULL; /* Initialize it just to avoid a GCC false warning. */ @@ -972,7 +972,7 @@ call_function_by_hand_dummy (struct value *function, else { gdb_assert (sp <= lastval_addr); - sp = lastval_addr + value_type (lastval)->length (); + sp = lastval_addr + lastval->type ()->length (); } if (gdbarch_frame_align_p (gdbarch)) diff --git a/gdb/infcmd.c b/gdb/infcmd.c index 77206fcbfe8..32d30c2a3e8 100644 --- a/gdb/infcmd.c +++ b/gdb/infcmd.c @@ -1478,7 +1478,7 @@ get_return_value (struct symbol *func_symbol, struct value *function) = check_typedef (func_symbol->type ()->target_type ()); gdb_assert (value_type->code () != TYPE_CODE_VOID); - if (is_nocall_function (check_typedef (::value_type (function)))) + if (is_nocall_function (check_typedef (function->type ()))) { warning (_("Function '%s' does not follow the target calling " "convention, cannot determine its returned value."), @@ -2158,7 +2158,7 @@ default_print_one_register_info (struct ui_file *file, const char *name, struct value *val) { - struct type *regtype = value_type (val); + struct type *regtype = val->type (); int print_raw_format; string_file format_stream; enum tab_stops diff --git a/gdb/infrun.c b/gdb/infrun.c index 87ab73c47a4..9e81f83134a 100644 --- a/gdb/infrun.c +++ b/gdb/infrun.c @@ -9145,9 +9145,9 @@ siginfo_value_read (struct value *v) nullptr, value_contents_all_raw (v).data (), value_offset (v), - value_type (v)->length ()); + v->type ()->length ()); - if (transferred != value_type (v)->length ()) + if (transferred != v->type ()->length ()) error (_("Unable to read siginfo")); } @@ -9168,9 +9168,9 @@ siginfo_value_write (struct value *v, struct value *fromval) nullptr, value_contents_all_raw (fromval).data (), value_offset (v), - value_type (fromval)->length ()); + fromval->type ()->length ()); - if (transferred != value_type (fromval)->length ()) + if (transferred != fromval->type ()->length ()) error (_("Unable to write siginfo")); } diff --git a/gdb/iq2000-tdep.c b/gdb/iq2000-tdep.c index b80ee61e437..f2af69e46cd 100644 --- a/gdb/iq2000-tdep.c +++ b/gdb/iq2000-tdep.c @@ -643,7 +643,7 @@ iq2000_push_dummy_call (struct gdbarch *gdbarch, struct value *function, i < nargs; i++) { - type = value_type (args[i]); + type = args[i]->type (); typelen = type->length (); if (typelen <= 4) { @@ -709,7 +709,7 @@ iq2000_push_dummy_call (struct gdbarch *gdbarch, struct value *function, for (i = 0; i < nargs; i++) { - type = value_type (args[i]); + type = args[i]->type (); typelen = type->length (); val = value_contents (args[i]).data (); if (typelen <= 4) diff --git a/gdb/linespec.c b/gdb/linespec.c index d3def7ae070..7761feff8d4 100644 --- a/gdb/linespec.c +++ b/gdb/linespec.c @@ -4081,7 +4081,7 @@ linespec_parse_variable (struct linespec_state *self, const char *variable) sscanf ((variable[1] == '$') ? variable + 2 : variable + 1, "%d", &index); val_history = access_value_history ((variable[1] == '$') ? -index : index); - if (value_type (val_history)->code () != TYPE_CODE_INT) + if (val_history->type ()->code () != TYPE_CODE_INT) error (_("History values used in line " "specs must have integer values.")); offset.offset = value_as_long (val_history); diff --git a/gdb/lm32-tdep.c b/gdb/lm32-tdep.c index 5b69bd06a19..93e2ad940b5 100644 --- a/gdb/lm32-tdep.c +++ b/gdb/lm32-tdep.c @@ -238,7 +238,7 @@ lm32_push_dummy_call (struct gdbarch *gdbarch, struct value *function, for (i = 0; i < nargs; i++) { struct value *arg = args[i]; - struct type *arg_type = check_typedef (value_type (arg)); + struct type *arg_type = check_typedef (arg->type ()); gdb_byte *contents; ULONGEST val; diff --git a/gdb/loongarch-tdep.c b/gdb/loongarch-tdep.c index 10bbed35585..f40a7b4912e 100644 --- a/gdb/loongarch-tdep.c +++ b/gdb/loongarch-tdep.c @@ -566,11 +566,11 @@ loongarch_push_dummy_call (struct gdbarch *gdbarch, { struct value *arg = args[i]; const gdb_byte *val = value_contents (arg).data (); - struct type *type = check_typedef (value_type (arg)); + struct type *type = check_typedef (arg->type ()); size_t len = type->length (); int align = type_align (type); enum type_code code = type->code (); - struct type *func_type = check_typedef (value_type (function)); + struct type *func_type = check_typedef (function->type ()); bool varargs = (func_type->has_varargs () && i >= func_type->num_fields ()); switch (code) diff --git a/gdb/m2-lang.c b/gdb/m2-lang.c index fe02c45fba5..42af96d96f2 100644 --- a/gdb/m2-lang.c +++ b/gdb/m2-lang.c @@ -42,7 +42,7 @@ eval_op_m2_high (struct type *expect_type, struct expression *exp, else { arg1 = coerce_ref (arg1); - struct type *type = check_typedef (value_type (arg1)); + struct type *type = check_typedef (arg1->type ()); if (m2_is_unbounded_array (type)) { @@ -54,7 +54,7 @@ eval_op_m2_high (struct type *expect_type, struct expression *exp, _("unbounded structure " "missing _m2_high field")); - if (value_type (arg1) != type) + if (arg1->type () != type) arg1 = value_cast (type, arg1); } } @@ -73,7 +73,7 @@ eval_op_m2_subscript (struct type *expect_type, struct expression *exp, then report this as an error. */ arg1 = coerce_ref (arg1); - struct type *type = check_typedef (value_type (arg1)); + struct type *type = check_typedef (arg1->type ()); if (m2_is_unbounded_array (type)) { @@ -87,10 +87,10 @@ eval_op_m2_subscript (struct type *expect_type, struct expression *exp, _("unbounded structure " "missing _m2_contents field")); - if (value_type (arg1) != type) + if (arg1->type () != type) arg1 = value_cast (type, arg1); - check_typedef (value_type (arg1)); + check_typedef (arg1->type ()); return value_ind (value_ptradd (arg1, value_as_long (arg2))); } else diff --git a/gdb/m2-valprint.c b/gdb/m2-valprint.c index e4335c188aa..c7187986aeb 100644 --- a/gdb/m2-valprint.c +++ b/gdb/m2-valprint.c @@ -164,7 +164,7 @@ m2_print_unbounded_array (struct value *value, LONGEST len; struct value *val; - struct type *type = check_typedef (value_type (value)); + struct type *type = check_typedef (value->type ()); const gdb_byte *valaddr = value_contents_for_printing (value).data (); addr = unpack_pointer (type->field (0).type (), @@ -260,7 +260,7 @@ m2_print_array_contents (struct value *val, const struct value_print_options *options, int len) { - struct type *type = check_typedef (value_type (val)); + struct type *type = check_typedef (val->type ()); if (type->length () > 0) { @@ -308,7 +308,7 @@ m2_language::value_print_inner (struct value *val, struct ui_file *stream, const gdb_byte *valaddr = value_contents_for_printing (val).data (); const CORE_ADDR address = value_address (val); - struct type *type = check_typedef (value_type (val)); + struct type *type = check_typedef (val->type ()); switch (type->code ()) { case TYPE_CODE_ARRAY: diff --git a/gdb/m32c-tdep.c b/gdb/m32c-tdep.c index c2c37145de8..23add82ae90 100644 --- a/gdb/m32c-tdep.c +++ b/gdb/m32c-tdep.c @@ -2029,7 +2029,7 @@ m32c_push_dummy_call (struct gdbarch *gdbarch, struct value *function, int num_prototyped_args = 0; { - struct type *func_type = value_type (function); + struct type *func_type = function->type (); /* Dereference function pointer types. */ if (func_type->code () == TYPE_CODE_PTR) @@ -2062,7 +2062,7 @@ m32c_push_dummy_call (struct gdbarch *gdbarch, struct value *function, { struct value *arg = args[i]; const gdb_byte *arg_bits = value_contents (arg).data (); - struct type *arg_type = value_type (arg); + struct type *arg_type = arg->type (); ULONGEST arg_size = arg_type->length (); /* Can it go in r1 or r1l (for m16c) or r0 or r0l (for m32c)? */ diff --git a/gdb/m32r-tdep.c b/gdb/m32r-tdep.c index fb1dc661867..ceab11da67f 100644 --- a/gdb/m32r-tdep.c +++ b/gdb/m32r-tdep.c @@ -682,12 +682,12 @@ m32r_push_dummy_call (struct gdbarch *gdbarch, struct value *function, /* Now make sure there's space on the stack. */ for (argnum = 0, stack_alloc = 0; argnum < nargs; argnum++) - stack_alloc += ((value_type (args[argnum])->length () + 3) & ~3); + stack_alloc += ((args[argnum]->type ()->length () + 3) & ~3); sp -= stack_alloc; /* Make room on stack for args. */ for (argnum = 0, stack_offset = 0; argnum < nargs; argnum++) { - type = value_type (args[argnum]); + type = args[argnum]->type (); typecode = type->code (); len = type->length (); diff --git a/gdb/m68hc11-tdep.c b/gdb/m68hc11-tdep.c index 6625506cc4a..86af4521edd 100644 --- a/gdb/m68hc11-tdep.c +++ b/gdb/m68hc11-tdep.c @@ -1170,7 +1170,7 @@ m68hc11_push_dummy_call (struct gdbarch *gdbarch, struct value *function, regcache_cooked_write_unsigned (regcache, HARD_D_REGNUM, struct_addr); else if (nargs > 0) { - type = value_type (args[0]); + type = args[0]->type (); /* First argument is passed in D and X registers. */ if (type->length () <= 4) @@ -1192,7 +1192,7 @@ m68hc11_push_dummy_call (struct gdbarch *gdbarch, struct value *function, for (argnum = nargs - 1; argnum >= first_stack_argnum; argnum--) { - type = value_type (args[argnum]); + type = args[argnum]->type (); if (type->length () & 1) { diff --git a/gdb/mep-tdep.c b/gdb/mep-tdep.c index 2b3f6424012..c70699d1c3d 100644 --- a/gdb/mep-tdep.c +++ b/gdb/mep-tdep.c @@ -2228,7 +2228,7 @@ push_large_arguments (CORE_ADDR sp, int argc, struct value **argv, for (i = 0; i < argc; i++) { - unsigned arg_len = value_type (argv[i])->length (); + unsigned arg_len = argv[i]->type ()->length (); if (arg_len > MEP_GPR_SIZE) { @@ -2288,9 +2288,9 @@ mep_push_dummy_call (struct gdbarch *gdbarch, struct value *function, ULONGEST value; /* Arguments that fit in a GPR get expanded to fill the GPR. */ - if (value_type (argv[i])->length () <= MEP_GPR_SIZE) + if (argv[i]->type ()->length () <= MEP_GPR_SIZE) value = extract_unsigned_integer (value_contents (argv[i]).data (), - value_type (argv[i])->length (), + argv[i]->type ()->length (), byte_order); /* Arguments too large to fit in a GPR get copied to the stack, diff --git a/gdb/mi/mi-cmd-stack.c b/gdb/mi/mi-cmd-stack.c index 4666808a9c9..0ac4d6a63cc 100644 --- a/gdb/mi/mi-cmd-stack.c +++ b/gdb/mi/mi-cmd-stack.c @@ -505,10 +505,10 @@ list_arg_or_local (const struct frame_arg *arg, enum what_to_list what, /* A scalar object that does not have all bits available is also considered unavailable, because all bits contribute to its representation. */ - || (val_print_scalar_type_p (value_type (arg->val)) + || (val_print_scalar_type_p (arg->val->type ()) && !value_bytes_available (arg->val, value_embedded_offset (arg->val), - value_type (arg->val)->length ())))) + arg->val->type ()->length ())))) return; gdb::optional tuple_emitter; diff --git a/gdb/mi/mi-main.c b/gdb/mi/mi-main.c index e0cade2edc3..609872455ff 100644 --- a/gdb/mi/mi-main.c +++ b/gdb/mi/mi-main.c @@ -2474,8 +2474,8 @@ print_variable_or_computed (const char *expression, enum print_values values) switch (values) { case PRINT_SIMPLE_VALUES: - type = check_typedef (value_type (val)); - type_print (value_type (val), "", &stb, -1); + type = check_typedef (val->type ()); + type_print (val->type (), "", &stb, -1); uiout->field_stream ("type", stb); if (type->code () != TYPE_CODE_ARRAY && type->code () != TYPE_CODE_STRUCT diff --git a/gdb/mips-tdep.c b/gdb/mips-tdep.c index 6088587edbf..38ec39d4cc1 100644 --- a/gdb/mips-tdep.c +++ b/gdb/mips-tdep.c @@ -4553,7 +4553,7 @@ mips_eabi_push_dummy_call (struct gdbarch *gdbarch, struct value *function, than necessary for EABI, because the first few arguments are passed in registers, but that's OK. */ for (argnum = 0; argnum < nargs; argnum++) - arg_space += align_up (value_type (args[argnum])->length (), + arg_space += align_up (args[argnum]->type ()->length (), abi_regsize); sp -= align_up (arg_space, 16); @@ -4588,7 +4588,7 @@ mips_eabi_push_dummy_call (struct gdbarch *gdbarch, struct value *function, reference. */ gdb_byte ref_valbuf[MAX_MIPS_ABI_REGSIZE]; struct value *arg = args[argnum]; - struct type *arg_type = check_typedef (value_type (arg)); + struct type *arg_type = check_typedef (arg->type ()); int len = arg_type->length (); enum type_code typecode = arg_type->code (); @@ -4947,7 +4947,7 @@ mips_n32n64_push_dummy_call (struct gdbarch *gdbarch, struct value *function, /* Now make space on the stack for the args. */ for (argnum = 0; argnum < nargs; argnum++) - arg_space += align_up (value_type (args[argnum])->length (), + arg_space += align_up (args[argnum]->type ()->length (), MIPS64_REGSIZE); sp -= align_up (arg_space, 16); @@ -4979,7 +4979,7 @@ mips_n32n64_push_dummy_call (struct gdbarch *gdbarch, struct value *function, { const gdb_byte *val; struct value *arg = args[argnum]; - struct type *arg_type = check_typedef (value_type (arg)); + struct type *arg_type = check_typedef (arg->type ()); int len = arg_type->length (); enum type_code typecode = arg_type->code (); @@ -5420,7 +5420,7 @@ mips_o32_push_dummy_call (struct gdbarch *gdbarch, struct value *function, /* Now make space on the stack for the args. */ for (argnum = 0; argnum < nargs; argnum++) { - struct type *arg_type = check_typedef (value_type (args[argnum])); + struct type *arg_type = check_typedef (args[argnum]->type ()); /* Align to double-word if necessary. */ if (mips_type_needs_double_align (arg_type)) @@ -5459,7 +5459,7 @@ mips_o32_push_dummy_call (struct gdbarch *gdbarch, struct value *function, { const gdb_byte *val; struct value *arg = args[argnum]; - struct type *arg_type = check_typedef (value_type (arg)); + struct type *arg_type = check_typedef (arg->type ()); int len = arg_type->length (); enum type_code typecode = arg_type->code (); @@ -5944,7 +5944,7 @@ mips_o64_push_dummy_call (struct gdbarch *gdbarch, struct value *function, /* Now make space on the stack for the args. */ for (argnum = 0; argnum < nargs; argnum++) { - struct type *arg_type = check_typedef (value_type (args[argnum])); + struct type *arg_type = check_typedef (args[argnum]->type ()); /* Allocate space on the stack. */ arg_space += align_up (arg_type->length (), MIPS64_REGSIZE); @@ -5980,7 +5980,7 @@ mips_o64_push_dummy_call (struct gdbarch *gdbarch, struct value *function, { const gdb_byte *val; struct value *arg = args[argnum]; - struct type *arg_type = check_typedef (value_type (arg)); + struct type *arg_type = check_typedef (arg->type ()); int len = arg_type->length (); enum type_code typecode = arg_type->code (); diff --git a/gdb/mn10300-tdep.c b/gdb/mn10300-tdep.c index fa43e8b9851..ac2b4a7ef71 100644 --- a/gdb/mn10300-tdep.c +++ b/gdb/mn10300-tdep.c @@ -1181,7 +1181,7 @@ mn10300_push_dummy_call (struct gdbarch *gdbarch, regs_used = (return_method == return_method_struct) ? 1 : 0; for (len = 0, argnum = 0; argnum < nargs; argnum++) { - arg_len = (value_type (args[argnum])->length () + 3) & ~3; + arg_len = (args[argnum]->type ()->length () + 3) & ~3; while (regs_used < 2 && arg_len > 0) { regs_used++; @@ -1205,8 +1205,8 @@ mn10300_push_dummy_call (struct gdbarch *gdbarch, for (argnum = 0; argnum < nargs; argnum++) { /* FIXME what about structs? Unions? */ - if (value_type (*args)->code () == TYPE_CODE_STRUCT - && value_type (*args)->length () > 8) + if ((*args)->type ()->code () == TYPE_CODE_STRUCT + && (*args)->type ()->length () > 8) { /* Change to pointer-to-type. */ arg_len = push_size; @@ -1217,7 +1217,7 @@ mn10300_push_dummy_call (struct gdbarch *gdbarch, } else { - arg_len = value_type (*args)->length (); + arg_len = (*args)->type ()->length (); val = value_contents (*args).data (); } diff --git a/gdb/msp430-tdep.c b/gdb/msp430-tdep.c index 051299078c5..30a28d087d9 100644 --- a/gdb/msp430-tdep.c +++ b/gdb/msp430-tdep.c @@ -656,7 +656,7 @@ msp430_push_dummy_call (struct gdbarch *gdbarch, struct value *function, msp430_gdbarch_tdep *tdep = gdbarch_tdep (gdbarch); int code_model = tdep->code_model; - struct type *func_type = value_type (function); + struct type *func_type = function->type (); /* Dereference function pointer types. */ while (func_type->code () == TYPE_CODE_PTR) @@ -690,7 +690,7 @@ msp430_push_dummy_call (struct gdbarch *gdbarch, struct value *function, { struct value *arg = args[i]; const gdb_byte *arg_bits = value_contents_all (arg).data (); - struct type *arg_type = check_typedef (value_type (arg)); + struct type *arg_type = check_typedef (arg->type ()); ULONGEST arg_size = arg_type->length (); int offset; int current_arg_on_stack; diff --git a/gdb/nds32-tdep.c b/gdb/nds32-tdep.c index ede1a188fb5..858b72c2509 100644 --- a/gdb/nds32-tdep.c +++ b/gdb/nds32-tdep.c @@ -1422,7 +1422,7 @@ nds32_push_dummy_call (struct gdbarch *gdbarch, struct value *function, ULONGEST regval; enum bfd_endian byte_order = gdbarch_byte_order (gdbarch); nds32_gdbarch_tdep *tdep = gdbarch_tdep (gdbarch); - struct type *func_type = value_type (function); + struct type *func_type = function->type (); int abi_use_fpr = nds32_abi_use_fpr (tdep->elf_abi); int abi_split = nds32_abi_split (tdep->elf_abi); @@ -1442,7 +1442,7 @@ nds32_push_dummy_call (struct gdbarch *gdbarch, struct value *function, /* Now make sure there's space on the stack */ for (i = 0; i < nargs; i++) { - struct type *type = value_type (args[i]); + struct type *type = args[i]->type (); int align = type_align (type); /* If align is zero, it may be an empty struct. @@ -1466,7 +1466,7 @@ nds32_push_dummy_call (struct gdbarch *gdbarch, struct value *function, int calling_use_fpr; int use_fpr = 0; - type = value_type (args[i]); + type = args[i]->type (); calling_use_fpr = nds32_check_calling_use_fpr (type); len = type->length (); align = type_align (type); diff --git a/gdb/nios2-tdep.c b/gdb/nios2-tdep.c index de61c9c2370..e7ec4552827 100644 --- a/gdb/nios2-tdep.c +++ b/gdb/nios2-tdep.c @@ -1818,7 +1818,7 @@ nios2_push_dummy_call (struct gdbarch *gdbarch, struct value *function, /* Now make space on the stack for the args. */ for (argnum = 0; argnum < nargs; argnum++) - arg_space += align_up (value_type (args[argnum])->length (), 4); + arg_space += align_up (args[argnum]->type ()->length (), 4); sp -= arg_space; /* Initialize the register pointer. */ @@ -1836,7 +1836,7 @@ nios2_push_dummy_call (struct gdbarch *gdbarch, struct value *function, { const gdb_byte *val; struct value *arg = args[argnum]; - struct type *arg_type = check_typedef (value_type (arg)); + struct type *arg_type = check_typedef (arg->type ()); int len = arg_type->length (); val = value_contents (arg).data (); diff --git a/gdb/opencl-lang.c b/gdb/opencl-lang.c index 0052c560dff..f66489bec0f 100644 --- a/gdb/opencl-lang.c +++ b/gdb/opencl-lang.c @@ -120,8 +120,8 @@ static void lval_func_read (struct value *v) { struct lval_closure *c = (struct lval_closure *) value_computed_closure (v); - struct type *type = check_typedef (value_type (v)); - struct type *eltype = check_typedef (value_type (c->val))->target_type (); + struct type *type = check_typedef (v->type ()); + struct type *eltype = check_typedef (c->val->type ())->target_type (); LONGEST offset = value_offset (v); LONGEST elsize = eltype->length (); int n, i, j = 0; @@ -150,8 +150,8 @@ lval_func_write (struct value *v, struct value *fromval) scoped_value_mark mark; struct lval_closure *c = (struct lval_closure *) value_computed_closure (v); - struct type *type = check_typedef (value_type (v)); - struct type *eltype = check_typedef (value_type (c->val))->target_type (); + struct type *type = check_typedef (v->type ()); + struct type *eltype = check_typedef (c->val->type ())->target_type (); LONGEST offset = value_offset (v); LONGEST elsize = eltype->length (); int n, i, j = 0; @@ -197,7 +197,7 @@ lval_func_check_synthetic_pointer (const struct value *v, struct lval_closure *c = (struct lval_closure *) value_computed_closure (v); /* Size of the target type in bits. */ int elsize = - check_typedef (value_type (c->val))->target_type ()->length () * 8; + check_typedef (c->val->type ())->target_type ()->length () * 8; int startrest = offset % elsize; int start = offset / elsize; int endrest = (offset + length) % elsize; @@ -269,7 +269,7 @@ static struct value * create_value (struct gdbarch *gdbarch, struct value *val, enum noside noside, int *indices, int n) { - struct type *type = check_typedef (value_type (val)); + struct type *type = check_typedef (val->type ()); struct type *elm_type = type->target_type (); struct value *ret; @@ -337,7 +337,7 @@ opencl_component_ref (struct expression *exp, struct value *val, int indices[16], i; int dst_len; - if (!get_array_bounds (check_typedef (value_type (val)), &lowb, &highb)) + if (!get_array_bounds (check_typedef (val->type ()), &lowb, &highb)) error (_("Could not determine the vector bounds")); src_len = highb - lowb + 1; @@ -446,7 +446,7 @@ opencl_logical_not (struct type *expect_type, struct expression *exp, enum noside noside, enum exp_opcode op, struct value *arg) { - struct type *type = check_typedef (value_type (arg)); + struct type *type = check_typedef (arg->type ()); struct type *rettype; struct value *ret; @@ -537,8 +537,8 @@ vector_relop (struct expression *exp, struct value *val1, struct value *val2, int t1_is_vec, t2_is_vec, i; LONGEST lowb1, lowb2, highb1, highb2; - type1 = check_typedef (value_type (val1)); - type2 = check_typedef (value_type (val2)); + type1 = check_typedef (val1->type ()); + type2 = check_typedef (val2->type ()); t1_is_vec = (type1->code () == TYPE_CODE_ARRAY && type1->is_vector ()); t2_is_vec = (type2->code () == TYPE_CODE_ARRAY && type2->is_vector ()); @@ -589,7 +589,7 @@ vector_relop (struct expression *exp, struct value *val1, struct value *val2, struct value * opencl_value_cast (struct type *type, struct value *arg) { - if (type != value_type (arg)) + if (type != arg->type ()) { /* Casting scalar to vector is a special case for OpenCL, scalar is cast to element type of vector then replicated into each @@ -603,10 +603,10 @@ opencl_value_cast (struct type *type, struct value *arg) to_type = check_typedef (type); code1 = to_type->code (); - code2 = check_typedef (value_type (arg))->code (); + code2 = check_typedef (arg->type ())->code (); if (code2 == TYPE_CODE_REF) - code2 = check_typedef (value_type (coerce_ref(arg)))->code (); + code2 = check_typedef (coerce_ref(arg)->type ())->code (); scalar = (code2 == TYPE_CODE_INT || code2 == TYPE_CODE_BOOL || code2 == TYPE_CODE_CHAR || code2 == TYPE_CODE_FLT @@ -641,8 +641,8 @@ opencl_relop (struct type *expect_type, struct expression *exp, struct value *arg1, struct value *arg2) { struct value *val; - struct type *type1 = check_typedef (value_type (arg1)); - struct type *type2 = check_typedef (value_type (arg2)); + struct type *type1 = check_typedef (arg1->type ()); + struct type *type2 = check_typedef (arg2->type ()); int t1_is_vec = (type1->code () == TYPE_CODE_ARRAY && type1->is_vector ()); int t2_is_vec = (type2->code () == TYPE_CODE_ARRAY @@ -686,7 +686,7 @@ eval_opencl_assign (struct type *expect_type, struct expression *exp, if (noside == EVAL_AVOID_SIDE_EFFECTS) return arg1; - struct type *type1 = value_type (arg1); + struct type *type1 = arg1->type (); if (deprecated_value_modifiable (arg1) && VALUE_LVAL (arg1) != lval_internalvar) arg2 = opencl_value_cast (type1, arg2); @@ -703,7 +703,7 @@ opencl_structop_operation::evaluate (struct type *expect_type, enum noside noside) { value *arg1 = std::get<0> (m_storage)->evaluate (nullptr, exp, noside); - struct type *type1 = check_typedef (value_type (arg1)); + struct type *type1 = check_typedef (arg1->type ()); if (type1->code () == TYPE_CODE_ARRAY && type1->is_vector ()) return opencl_component_ref (exp, arg1, std::get<1> (m_storage).c_str (), @@ -715,7 +715,7 @@ opencl_structop_operation::evaluate (struct type *expect_type, NULL, "structure"); if (noside == EVAL_AVOID_SIDE_EFFECTS) - v = value_zero (value_type (v), VALUE_LVAL (v)); + v = value_zero (v->type (), VALUE_LVAL (v)); return v; } } @@ -735,8 +735,8 @@ opencl_logical_binop_operation::evaluate (struct type *expect_type, Therefore we evaluate it once using EVAL_AVOID_SIDE_EFFECTS. */ value *arg2 = std::get<2> (m_storage)->evaluate (nullptr, exp, EVAL_AVOID_SIDE_EFFECTS); - struct type *type1 = check_typedef (value_type (arg1)); - struct type *type2 = check_typedef (value_type (arg2)); + struct type *type1 = check_typedef (arg1->type ()); + struct type *type2 = check_typedef (arg2->type ()); if ((type1->code () == TYPE_CODE_ARRAY && type1->is_vector ()) || (type2->code () == TYPE_CODE_ARRAY && type2->is_vector ())) @@ -774,7 +774,7 @@ opencl_ternop_cond_operation::evaluate (struct type *expect_type, enum noside noside) { value *arg1 = std::get<0> (m_storage)->evaluate (nullptr, exp, noside); - struct type *type1 = check_typedef (value_type (arg1)); + struct type *type1 = check_typedef (arg1->type ()); if (type1->code () == TYPE_CODE_ARRAY && type1->is_vector ()) { struct value *arg2, *arg3, *tmp, *ret; @@ -784,8 +784,8 @@ opencl_ternop_cond_operation::evaluate (struct type *expect_type, arg2 = std::get<1> (m_storage)->evaluate (nullptr, exp, noside); arg3 = std::get<2> (m_storage)->evaluate (nullptr, exp, noside); - type2 = check_typedef (value_type (arg2)); - type3 = check_typedef (value_type (arg3)); + type2 = check_typedef (arg2->type ()); + type3 = check_typedef (arg3->type ()); t2_is_vec = type2->code () == TYPE_CODE_ARRAY && type2->is_vector (); t3_is_vec @@ -795,12 +795,12 @@ opencl_ternop_cond_operation::evaluate (struct type *expect_type, if (t2_is_vec || !t3_is_vec) { arg3 = opencl_value_cast (type2, arg3); - type3 = value_type (arg3); + type3 = arg3->type (); } else if (!t2_is_vec || t3_is_vec) { arg2 = opencl_value_cast (type3, arg2); - type2 = value_type (arg2); + type2 = arg2->type (); } else if (!t2_is_vec || !t3_is_vec) { diff --git a/gdb/or1k-tdep.c b/gdb/or1k-tdep.c index 3616d7751ca..d8c30435cc5 100644 --- a/gdb/or1k-tdep.c +++ b/gdb/or1k-tdep.c @@ -637,7 +637,7 @@ or1k_push_dummy_call (struct gdbarch *gdbarch, struct value *function, or1k_gdbarch_tdep *tdep = gdbarch_tdep (gdbarch); int bpa = tdep->bytes_per_address; int bpw = tdep->bytes_per_word; - struct type *func_type = value_type (function); + struct type *func_type = function->type (); /* Return address */ regcache_cooked_write_unsigned (regcache, OR1K_LR_REGNUM, bp_addr); @@ -661,7 +661,7 @@ or1k_push_dummy_call (struct gdbarch *gdbarch, struct value *function, gdb_byte valbuf[sizeof (ULONGEST)]; struct value *arg = args[argnum]; - struct type *arg_type = check_typedef (value_type (arg)); + struct type *arg_type = check_typedef (arg->type ()); int len = arg_type->length (); enum type_code typecode = arg_type->code (); @@ -751,7 +751,7 @@ or1k_push_dummy_call (struct gdbarch *gdbarch, struct value *function, for (argnum = first_stack_arg; argnum < nargs; argnum++) { struct value *arg = args[argnum]; - struct type *arg_type = check_typedef (value_type (arg)); + struct type *arg_type = check_typedef (arg->type ()); int len = arg_type->length (); enum type_code typecode = arg_type->code (); @@ -783,7 +783,7 @@ or1k_push_dummy_call (struct gdbarch *gdbarch, struct value *function, gdb_byte valbuf[sizeof (ULONGEST)]; struct value *arg = args[argnum]; - struct type *arg_type = check_typedef (value_type (arg)); + struct type *arg_type = check_typedef (arg->type ()); int len = arg_type->length (); enum type_code typecode = arg_type->code (); /* The EABI passes structures that do not fit in a register by diff --git a/gdb/p-exp.y b/gdb/p-exp.y index 6e03f1a5381..b5251b932ef 100644 --- a/gdb/p-exp.y +++ b/gdb/p-exp.y @@ -542,7 +542,7 @@ exp : DOLLAR_VARIABLE value *val = value_of_internalvar (pstate->gdbarch (), intvar); - current_type = value_type (val); + current_type = val->type (); } } ; @@ -591,7 +591,7 @@ exp : THIS this_val = value_of_this_silent (pstate->language ()); if (this_val) - this_type = value_type (this_val); + this_type = this_val->type (); else this_type = NULL; if (this_type) @@ -707,7 +707,7 @@ variable: name_not_typename this_val = value_of_this_silent (pstate->language ()); if (this_val) - this_type = value_type (this_val); + this_type = this_val->type (); else this_type = NULL; if (this_type) diff --git a/gdb/p-valprint.c b/gdb/p-valprint.c index 69bfeba1477..2628ebd6bf2 100644 --- a/gdb/p-valprint.c +++ b/gdb/p-valprint.c @@ -69,7 +69,7 @@ pascal_language::value_print_inner (struct value *val, const struct value_print_options *options) const { - struct type *type = check_typedef (value_type (val)); + struct type *type = check_typedef (val->type ()); struct gdbarch *gdbarch = type->arch (); enum bfd_endian byte_order = type_byte_order (type); unsigned int i = 0; /* Number of characters printed */ @@ -408,7 +408,7 @@ void pascal_language::value_print (struct value *val, struct ui_file *stream, const struct value_print_options *options) const { - struct type *type = value_type (val); + struct type *type = val->type (); struct value_print_options opts = *options; opts.deref_ref = true; @@ -521,7 +521,7 @@ pascal_object_print_value_fields (struct value *val, struct ui_file *stream, char *last_dont_print = (char *) obstack_next_free (&dont_print_statmem_obstack); - struct type *type = check_typedef (value_type (val)); + struct type *type = check_typedef (val->type ()); gdb_printf (stream, "{"); len = type->num_fields (); @@ -655,7 +655,7 @@ pascal_object_print_value_fields (struct value *val, struct ui_file *stream, opts.deref_ref = false; struct value *v = value_primitive_field (val, 0, i, - value_type (val)); + val->type ()); common_val_print (v, stream, recurse + 1, &opts, current_language); } @@ -692,7 +692,7 @@ pascal_object_print_value (struct value *val, struct ui_file *stream, struct type **last_dont_print = (struct type **) obstack_next_free (&dont_print_vb_obstack); struct obstack tmp_obstack = dont_print_vb_obstack; - struct type *type = check_typedef (value_type (val)); + struct type *type = check_typedef (val->type ()); int i, n_baseclasses = TYPE_N_BASECLASSES (type); if (dont_print_vb == 0) @@ -757,7 +757,7 @@ pascal_object_print_value (struct value *val, struct ui_file *stream, base_value = value_from_contents_and_address (baseclass, buf.data (), address + boffset); - baseclass = value_type (base_value); + baseclass = base_value->type (); boffset = 0; } } @@ -815,7 +815,7 @@ pascal_object_print_static_field (struct value *val, int recurse, const struct value_print_options *options) { - struct type *type = value_type (val); + struct type *type = val->type (); struct value_print_options opts; if (value_entirely_optimized_out (val)) diff --git a/gdb/ppc-linux-nat.c b/gdb/ppc-linux-nat.c index d8a8fbdf706..cb832726ea5 100644 --- a/gdb/ppc-linux-nat.c +++ b/gdb/ppc-linux-nat.c @@ -2516,7 +2516,7 @@ ppc_linux_nat_target::check_condition (CORE_ADDR watch_addr, /* DATA_VALUE is the constant in RIGHT_VAL, but actually has the same type as the memory region referenced by LEFT_VAL. */ - *len = check_typedef (value_type (left_val))->length (); + *len = check_typedef (left_val->type ())->length (); } else if (num_accesses_left == 0 && num_accesses_right == 1 && VALUE_LVAL (right_val) == lval_memory @@ -2526,7 +2526,7 @@ ppc_linux_nat_target::check_condition (CORE_ADDR watch_addr, /* DATA_VALUE is the constant in LEFT_VAL, but actually has the same type as the memory region referenced by RIGHT_VAL. */ - *len = check_typedef (value_type (right_val))->length (); + *len = check_typedef (right_val->type ())->length (); } else return 0; diff --git a/gdb/ppc-sysv-tdep.c b/gdb/ppc-sysv-tdep.c index 3df56c8b75c..69cc784c558 100644 --- a/gdb/ppc-sysv-tdep.c +++ b/gdb/ppc-sysv-tdep.c @@ -69,7 +69,7 @@ ppc_sysv_abi_push_dummy_call (struct gdbarch *gdbarch, struct value *function, { ppc_gdbarch_tdep *tdep = gdbarch_tdep (gdbarch); enum bfd_endian byte_order = gdbarch_byte_order (gdbarch); - int opencl_abi = ppc_sysv_use_opencl_abi (value_type (function)); + int opencl_abi = ppc_sysv_use_opencl_abi (function->type ()); ULONGEST saved_sp; int argspace = 0; /* 0 is an initial wrong guess. */ int write_pass; @@ -122,7 +122,7 @@ ppc_sysv_abi_push_dummy_call (struct gdbarch *gdbarch, struct value *function, for (argno = 0; argno < nargs; argno++) { struct value *arg = args[argno]; - struct type *type = check_typedef (value_type (arg)); + struct type *type = check_typedef (arg->type ()); int len = type->length (); const bfd_byte *val = value_contents (arg).data (); @@ -1013,7 +1013,7 @@ ppc_sysv_abi_return_value (struct gdbarch *gdbarch, struct value *function, gdb_byte *readbuf, const gdb_byte *writebuf) { return do_ppc_sysv_return_value (gdbarch, - function ? value_type (function) : NULL, + function ? function->type () : NULL, valtype, regcache, readbuf, writebuf, 0); } @@ -1025,7 +1025,7 @@ ppc_sysv_abi_broken_return_value (struct gdbarch *gdbarch, gdb_byte *readbuf, const gdb_byte *writebuf) { return do_ppc_sysv_return_value (gdbarch, - function ? value_type (function) : NULL, + function ? function->type () : NULL, valtype, regcache, readbuf, writebuf, 1); } @@ -1606,7 +1606,7 @@ ppc64_sysv_abi_push_dummy_call (struct gdbarch *gdbarch, CORE_ADDR func_addr = find_function_addr (function, NULL); ppc_gdbarch_tdep *tdep = gdbarch_tdep (gdbarch); enum bfd_endian byte_order = gdbarch_byte_order (gdbarch); - int opencl_abi = ppc_sysv_use_opencl_abi (value_type (function)); + int opencl_abi = ppc_sysv_use_opencl_abi (function->type ()); ULONGEST back_chain; /* See for-loop comment below. */ int write_pass; @@ -1691,7 +1691,7 @@ ppc64_sysv_abi_push_dummy_call (struct gdbarch *gdbarch, for (argno = 0; argno < nargs; argno++) { struct value *arg = args[argno]; - struct type *type = check_typedef (value_type (arg)); + struct type *type = check_typedef (arg->type ()); const bfd_byte *val = value_contents (arg).data (); if (type->code () == TYPE_CODE_COMPLEX) @@ -1760,7 +1760,7 @@ ppc64_sysv_abi_push_dummy_call (struct gdbarch *gdbarch, the pointer itself identifies the descriptor. */ if (tdep->elf_abi == POWERPC_ELF_V1) { - struct type *ftype = check_typedef (value_type (function)); + struct type *ftype = check_typedef (function->type ()); CORE_ADDR desc_addr = value_as_address (function); if (ftype->code () == TYPE_CODE_PTR @@ -1988,7 +1988,7 @@ ppc64_sysv_abi_return_value (struct gdbarch *gdbarch, struct value *function, gdb_byte *readbuf, const gdb_byte *writebuf) { ppc_gdbarch_tdep *tdep = gdbarch_tdep (gdbarch); - struct type *func_type = function ? value_type (function) : NULL; + struct type *func_type = function ? function->type () : NULL; int opencl_abi = func_type? ppc_sysv_use_opencl_abi (func_type) : 0; struct type *eltype; int nelt, ok; diff --git a/gdb/printcmd.c b/gdb/printcmd.c index 7f3551327a8..2962c7111e4 100644 --- a/gdb/printcmd.c +++ b/gdb/printcmd.c @@ -294,7 +294,7 @@ print_formatted (struct value *val, int size, const struct value_print_options *options, struct ui_file *stream) { - struct type *type = check_typedef (value_type (val)); + struct type *type = check_typedef (val->type ()); int len = type->length (); if (VALUE_LVAL (val) == lval_memory) @@ -306,7 +306,7 @@ print_formatted (struct value *val, int size, { case 's': { - struct type *elttype = value_type (val); + struct type *elttype = val->type (); next_address = (value_address (val) + val_print_string (elttype, NULL, @@ -1244,7 +1244,7 @@ print_value (value *val, const value_print_options &opts) { int histindex = record_latest_value (val); - annotate_value_history_begin (histindex, value_type (val)); + annotate_value_history_begin (histindex, val->type ()); gdb_printf ("$%d = ", histindex); @@ -1261,16 +1261,16 @@ print_value (value *val, const value_print_options &opts) static bool should_validate_memtags (struct value *value) { - gdb_assert (value != nullptr && value_type (value) != nullptr); + gdb_assert (value != nullptr && value->type () != nullptr); if (!target_supports_memory_tagging ()) return false; - enum type_code code = value_type (value)->code (); + enum type_code code = value->type ()->code (); /* Skip non-address values. */ if (code != TYPE_CODE_PTR - && !TYPE_IS_REFERENCE (value_type (value))) + && !TYPE_IS_REFERENCE (value->type ())) return false; /* OK, we have an address value. Check we have a complete value we @@ -1319,8 +1319,8 @@ print_command_1 (const char *args, int voidprint) struct value *val = process_print_command_args (args, &print_opts, voidprint); - if (voidprint || (val && value_type (val) && - value_type (val)->code () != TYPE_CODE_VOID)) + if (voidprint || (val && val->type () && + val->type ()->code () != TYPE_CODE_VOID)) { /* If memory tagging validation is on, check if the tag is valid. */ if (print_opts.memory_tag_violations) @@ -1485,7 +1485,7 @@ output_command (const char *exp, int from_tty) val = evaluate_expression (expr.get ()); - annotate_value_begin (value_type (val)); + annotate_value_begin (val->type ()); get_formatted_print_options (&opts, format); opts.raw = fmt.raw; @@ -1883,11 +1883,11 @@ x_command (const char *exp, int from_tty) if (from_tty) set_repeat_arguments (""); val = evaluate_expression (expr.get ()); - if (TYPE_IS_REFERENCE (value_type (val))) + if (TYPE_IS_REFERENCE (val->type ())) val = coerce_ref (val); /* In rvalue contexts, such as this, functions are coerced into pointers to functions. This makes "x/i main" work. */ - if (value_type (val)->code () == TYPE_CODE_FUNC + if (val->type ()->code () == TYPE_CODE_FUNC && VALUE_LVAL (val) == lval_memory) next_address = value_address (val); else @@ -1918,7 +1918,7 @@ x_command (const char *exp, int from_tty) /* Make last address examined available to the user as $_. Use the correct pointer type. */ struct type *pointer_type - = lookup_pointer_type (value_type (last_examine_value.get ())); + = lookup_pointer_type (last_examine_value.get ()->type ()); set_internalvar (lookup_internalvar ("_"), value_from_pointer (pointer_type, last_examine_address)); @@ -2429,11 +2429,11 @@ printf_c_string (struct ui_file *stream, const char *format, { const gdb_byte *str; - if (value_type (value)->code () != TYPE_CODE_PTR + if (value->type ()->code () != TYPE_CODE_PTR && VALUE_LVAL (value) == lval_internalvar - && c_is_string_type_p (value_type (value))) + && c_is_string_type_p (value->type ())) { - size_t len = value_type (value)->length (); + size_t len = value->type ()->length (); /* Copy the internal var value to TEM_STR and append a terminating null character. This protects against corrupted C-style strings that lack @@ -2497,16 +2497,16 @@ printf_wide_c_string (struct ui_file *stream, const char *format, { const gdb_byte *str; size_t len; - struct gdbarch *gdbarch = value_type (value)->arch (); + struct gdbarch *gdbarch = value->type ()->arch (); struct type *wctype = lookup_typename (current_language, "wchar_t", NULL, 0); int wcwidth = wctype->length (); if (VALUE_LVAL (value) == lval_internalvar - && c_is_string_type_p (value_type (value))) + && c_is_string_type_p (value->type ())) { str = value_contents (value).data (); - len = value_type (value)->length (); + len = value->type ()->length (); } else { @@ -2564,7 +2564,7 @@ printf_floating (struct ui_file *stream, const char *format, struct value *value, enum argclass argclass) { /* Parameter data. */ - struct type *param_type = value_type (value); + struct type *param_type = value->type (); struct gdbarch *gdbarch = param_type->arch (); /* Determine target type corresponding to the format string. */ @@ -2613,7 +2613,7 @@ printf_floating (struct ui_file *stream, const char *format, if (fmt_type->code () == TYPE_CODE_FLT) { param_type = float_type_from_length (param_type); - if (param_type != value_type (value)) + if (param_type != value->type ()) value = value_from_contents (param_type, value_contents (value).data ()); } @@ -2772,13 +2772,13 @@ ui_printf (const char *arg, struct ui_file *stream) break; case wide_char_arg: { - struct gdbarch *gdbarch = value_type (val_args[i])->arch (); + struct gdbarch *gdbarch = val_args[i]->type ()->arch (); struct type *wctype = lookup_typename (current_language, "wchar_t", NULL, 0); struct type *valtype; const gdb_byte *bytes; - valtype = value_type (val_args[i]); + valtype = val_args[i]->type (); if (valtype->length () != wctype->length () || valtype->code () != TYPE_CODE_INT) error (_("expected wchar_t argument for %%lc")); diff --git a/gdb/python/py-framefilter.c b/gdb/python/py-framefilter.c index 10a3adadf2f..0e8b2409636 100644 --- a/gdb/python/py-framefilter.c +++ b/gdb/python/py-framefilter.c @@ -206,10 +206,10 @@ mi_should_print (struct symbol *sym, enum mi_print_types type) static void py_print_type (struct ui_out *out, struct value *val) { - check_typedef (value_type (val)); + check_typedef (val->type ()); string_file stb; - type_print (value_type (val), "", &stb, -1); + type_print (val->type (), "", &stb, -1); out->field_stream ("type", stb); } @@ -235,7 +235,7 @@ py_print_value (struct ui_out *out, struct value *val, if (args_type == MI_PRINT_SIMPLE_VALUES || args_type == MI_PRINT_ALL_VALUES) { - struct type *type = check_typedef (value_type (val)); + struct type *type = check_typedef (val->type ()); if (args_type == MI_PRINT_ALL_VALUES) should_print = 1; @@ -378,7 +378,7 @@ py_print_single_arg (struct ui_out *out, py_print_type (out, val); if (val != NULL) - annotate_arg_value (value_type (val)); + annotate_arg_value (val->type ()); /* If the output is to the CLI, and the user option "set print frame-arguments" is set to none, just output "...". */ diff --git a/gdb/python/py-inferior.c b/gdb/python/py-inferior.c index 9b3385c83b5..1a3dcc23aa3 100644 --- a/gdb/python/py-inferior.c +++ b/gdb/python/py-inferior.c @@ -715,7 +715,7 @@ infpy_thread_from_thread_handle (PyObject *self, PyObject *args, PyObject *kw) { struct value *val = value_object_to_value (handle_obj); bytes = value_contents_all (val).data (); - bytes_len = value_type (val)->length (); + bytes_len = val->type ()->length (); } else { diff --git a/gdb/python/py-prettyprint.c b/gdb/python/py-prettyprint.c index 1a5ce08c477..346395e564e 100644 --- a/gdb/python/py-prettyprint.c +++ b/gdb/python/py-prettyprint.c @@ -574,7 +574,7 @@ gdbpy_apply_val_pretty_printer (const struct extension_language_defn *extlang, const struct value_print_options *options, const struct language_defn *language) { - struct type *type = value_type (value); + struct type *type = value->type (); struct gdbarch *gdbarch = type->arch (); enum gdbpy_string_repr_result print_result; diff --git a/gdb/python/py-unwind.c b/gdb/python/py-unwind.c index e7ec660e150..442251201f2 100644 --- a/gdb/python/py-unwind.c +++ b/gdb/python/py-unwind.c @@ -130,7 +130,7 @@ pyuw_value_obj_to_pointer (PyObject *pyo_value, CORE_ADDR *addr) { if ((value = value_object_to_value (pyo_value)) != NULL) { - *addr = unpack_pointer (value_type (value), + *addr = unpack_pointer (value->type (), value_contents (value).data ()); rc = 1; } @@ -292,13 +292,13 @@ unwind_infopy_add_saved_register (PyObject *self, PyObject *args) return NULL; } data_size = register_size (pending_frame->gdbarch, regnum); - if (data_size != value_type (value)->length ()) + if (data_size != value->type ()->length ()) { PyErr_Format ( PyExc_ValueError, "The value of the register returned by the Python " "sniffer has unexpected size: %u instead of %u.", - (unsigned) value_type (value)->length (), + (unsigned) value->type ()->length (), (unsigned) data_size); return NULL; } @@ -620,7 +620,7 @@ pyuw_sniffer (const struct frame_unwind *self, frame_info_ptr this_frame, /* `value' validation was done before, just assert. */ gdb_assert (value != NULL); - gdb_assert (data_size == value_type (value)->length ()); + gdb_assert (data_size == value->type ()->length ()); cached_frame->reg[i].data = (gdb_byte *) xmalloc (data_size); memcpy (cached_frame->reg[i].data, diff --git a/gdb/python/py-value.c b/gdb/python/py-value.c index da2565081e6..c748a87cfc9 100644 --- a/gdb/python/py-value.c +++ b/gdb/python/py-value.c @@ -272,7 +272,7 @@ valpy_referenced_value (PyObject *self, PyObject *args) scoped_value_mark free_values; self_val = ((value_object *) self)->value; - switch (check_typedef (value_type (self_val))->code ()) + switch (check_typedef (self_val->type ())->code ()) { case TYPE_CODE_PTR: res_val = value_ind (self_val); @@ -391,7 +391,7 @@ valpy_get_type (PyObject *self, void *closure) if (!obj->type) { - obj->type = type_to_type_object (value_type (obj->value)); + obj->type = type_to_type_object (obj->value->type ()); if (!obj->type) return NULL; } @@ -418,7 +418,7 @@ valpy_get_dynamic_type (PyObject *self, void *closure) struct value *val = obj->value; scoped_value_mark free_values; - type = value_type (val); + type = val->type (); type = check_typedef (type); if (type->is_pointer_or_reference () @@ -506,7 +506,7 @@ valpy_lazy_string (PyObject *self, PyObject *args, PyObject *kw) struct type *type, *realtype; CORE_ADDR addr; - type = value_type (value); + type = value->type (); realtype = check_typedef (type); switch (realtype->code ()) @@ -885,7 +885,7 @@ value_has_field (struct value *v, PyObject *field) try { - val_type = value_type (v); + val_type = v->type (); val_type = check_typedef (val_type); if (val_type->is_pointer_or_reference ()) val_type = check_typedef (val_type->target_type ()); @@ -1037,7 +1037,7 @@ valpy_getitem (PyObject *self, PyObject *key) { struct type *val_type; - val_type = check_typedef (value_type (tmp)); + val_type = check_typedef (tmp->type ()); if (val_type->code () == TYPE_CODE_PTR) res_val = value_cast (lookup_pointer_type (base_class_type), tmp); else if (val_type->code () == TYPE_CODE_REF) @@ -1063,7 +1063,7 @@ valpy_getitem (PyObject *self, PyObject *key) struct type *type; tmp = coerce_ref (tmp); - type = check_typedef (value_type (tmp)); + type = check_typedef (tmp->type ()); if (type->code () != TYPE_CODE_ARRAY && type->code () != TYPE_CODE_PTR) error (_("Cannot subscript requested type.")); @@ -1106,7 +1106,7 @@ valpy_call (PyObject *self, PyObject *args, PyObject *keywords) try { - ftype = check_typedef (value_type (function)); + ftype = check_typedef (function->type ()); } catch (const gdb_exception &except) { @@ -1311,8 +1311,8 @@ valpy_binop_throw (enum valpy_opcode opcode, PyObject *self, PyObject *other) { case VALPY_ADD: { - struct type *ltype = value_type (arg1); - struct type *rtype = value_type (arg2); + struct type *ltype = arg1->type (); + struct type *rtype = arg2->type (); ltype = check_typedef (ltype); ltype = STRIP_REFERENCE (ltype); @@ -1335,8 +1335,8 @@ valpy_binop_throw (enum valpy_opcode opcode, PyObject *self, PyObject *other) break; case VALPY_SUB: { - struct type *ltype = value_type (arg1); - struct type *rtype = value_type (arg2); + struct type *ltype = arg1->type (); + struct type *rtype = arg2->type (); ltype = check_typedef (ltype); ltype = STRIP_REFERENCE (ltype); @@ -1506,7 +1506,7 @@ valpy_absolute (PyObject *self) { scoped_value_mark free_values; - if (value_less (value, value_zero (value_type (value), not_lval))) + if (value_less (value, value_zero (value->type (), not_lval))) isabs = 0; } catch (const gdb_exception &except) @@ -1531,7 +1531,7 @@ valpy_nonzero (PyObject *self) try { - type = check_typedef (value_type (self_value->value)); + type = check_typedef (self_value->value->type ()); if (is_integral_type (type) || type->code () == TYPE_CODE_PTR) nonzero = !!value_as_long (self_value->value); @@ -1712,7 +1712,7 @@ static PyObject * valpy_long (PyObject *self) { struct value *value = ((value_object *) self)->value; - struct type *type = value_type (value); + struct type *type = value->type (); LONGEST l = 0; try @@ -1747,7 +1747,7 @@ static PyObject * valpy_float (PyObject *self) { struct value *value = ((value_object *) self)->value; - struct type *type = value_type (value); + struct type *type = value->type (); double d = 0; try @@ -1995,7 +1995,7 @@ gdbpy_convenience_variable (PyObject *self, PyObject *args) if (var != NULL) { res_val = value_of_internalvar (gdbpy_enter::get_gdbarch (), var); - if (value_type (res_val)->code () == TYPE_CODE_VOID) + if (res_val->type ()->code () == TYPE_CODE_VOID) res_val = NULL; } } diff --git a/gdb/python/py-xmethods.c b/gdb/python/py-xmethods.c index d6d607d99d4..d3afd26c26e 100644 --- a/gdb/python/py-xmethods.c +++ b/gdb/python/py-xmethods.c @@ -423,7 +423,7 @@ python_xmethod_worker::do_get_result_type (value *obj, return EXT_LANG_RC_OK; } - obj_type = check_typedef (value_type (obj)); + obj_type = check_typedef (obj->type ()); this_type = check_typedef (type_object_to_type (m_this_type)); if (obj_type->code () == TYPE_CODE_PTR) { @@ -508,7 +508,7 @@ python_xmethod_worker::invoke (struct value *obj, struct type *obj_type, *this_type; struct value *res = NULL; - obj_type = check_typedef (value_type (obj)); + obj_type = check_typedef (obj->type ()); this_type = check_typedef (type_object_to_type (m_this_type)); if (obj_type->code () == TYPE_CODE_PTR) { diff --git a/gdb/regcache.c b/gdb/regcache.c index 7aee1c16e2e..4de7026fc28 100644 --- a/gdb/regcache.c +++ b/gdb/regcache.c @@ -753,7 +753,7 @@ readable_regcache::cooked_read_value (int regnum) if (cooked_read (regnum, value_contents_raw (result).data ()) == REG_UNAVAILABLE) mark_value_bytes_unavailable (result, 0, - value_type (result)->length ()); + result->type ()->length ()); return result; } diff --git a/gdb/riscv-tdep.c b/gdb/riscv-tdep.c index 60de60382c8..d34eb56c1b6 100644 --- a/gdb/riscv-tdep.c +++ b/gdb/riscv-tdep.c @@ -1116,7 +1116,7 @@ riscv_print_one_register_info (struct gdbarch *gdbarch, try { val = value_of_register (regnum, frame); - regtype = value_type (val); + regtype = val->type (); } catch (const gdb_exception_error &ex) { @@ -3047,7 +3047,7 @@ riscv_push_dummy_call (struct gdbarch *gdbarch, CORE_ADDR osp = sp; - struct type *ftype = check_typedef (value_type (function)); + struct type *ftype = check_typedef (function->type ()); if (ftype->code () == TYPE_CODE_PTR) ftype = check_typedef (ftype->target_type ()); @@ -3063,7 +3063,7 @@ riscv_push_dummy_call (struct gdbarch *gdbarch, struct riscv_arg_info *info = &arg_info[i]; arg_value = args[i]; - arg_type = check_typedef (value_type (arg_value)); + arg_type = check_typedef (arg_value->type ()); riscv_arg_location (gdbarch, info, &call_info, arg_type, ftype->has_varargs () && i >= ftype->num_fields ()); @@ -3380,7 +3380,7 @@ riscv_return_value (struct gdbarch *gdbarch, type of ABI_VAL will differ from ARG_TYPE due to dynamic type resolution, and so will most likely fail. */ - arg_type = value_type (abi_val); + arg_type = abi_val->type (); } if (writebuf != nullptr) write_memory (addr, writebuf, info.length); diff --git a/gdb/rs6000-aix-tdep.c b/gdb/rs6000-aix-tdep.c index 2c610af1613..579f85f3870 100644 --- a/gdb/rs6000-aix-tdep.c +++ b/gdb/rs6000-aix-tdep.c @@ -350,7 +350,7 @@ rs6000_push_dummy_call (struct gdbarch *gdbarch, struct value *function, int reg_size = register_size (gdbarch, ii + 3); arg = args[argno]; - type = check_typedef (value_type (arg)); + type = check_typedef (arg->type ()); len = type->length (); if (type->code () == TYPE_CODE_FLT) @@ -447,7 +447,7 @@ rs6000_push_dummy_call (struct gdbarch *gdbarch, struct value *function, for (; jj < nargs; ++jj) { struct value *val = args[jj]; - space += ((value_type (val)->length ()) + 3) & -4; + space += ((val->type ()->length ()) + 3) & -4; } /* Add location required for the rest of the parameters. */ @@ -480,7 +480,7 @@ rs6000_push_dummy_call (struct gdbarch *gdbarch, struct value *function, { arg = args[argno]; - type = check_typedef (value_type (arg)); + type = check_typedef (arg->type ()); len = type->length (); diff --git a/gdb/rs6000-lynx178-tdep.c b/gdb/rs6000-lynx178-tdep.c index 042e6e60d91..4d210737535 100644 --- a/gdb/rs6000-lynx178-tdep.c +++ b/gdb/rs6000-lynx178-tdep.c @@ -93,7 +93,7 @@ rs6000_lynx178_push_dummy_call (struct gdbarch *gdbarch, int reg_size = register_size (gdbarch, ii + 3); arg = args[argno]; - type = check_typedef (value_type (arg)); + type = check_typedef (arg->type ()); len = type->length (); if (type->code () == TYPE_CODE_FLT) @@ -184,7 +184,7 @@ rs6000_lynx178_push_dummy_call (struct gdbarch *gdbarch, { struct value *val = args[jj]; - space += align_up (value_type (val)->length (), 4); + space += align_up (val->type ()->length (), 4); } /* Add location required for the rest of the parameters. */ @@ -217,7 +217,7 @@ rs6000_lynx178_push_dummy_call (struct gdbarch *gdbarch, { arg = args[argno]; - type = check_typedef (value_type (arg)); + type = check_typedef (arg->type ()); len = type->length (); diff --git a/gdb/rust-lang.c b/gdb/rust-lang.c index f2017f95211..f6e5089825c 100644 --- a/gdb/rust-lang.c +++ b/gdb/rust-lang.c @@ -244,7 +244,7 @@ rust_chartype_p (struct type *type) static struct value * rust_get_trait_object_pointer (struct value *value) { - struct type *type = check_typedef (value_type (value)); + struct type *type = check_typedef (value->type ()); if (type->code () != TYPE_CODE_STRUCT || type->num_fields () != 2) return NULL; @@ -330,23 +330,23 @@ rust_val_print_slice (struct value *val, struct ui_file *stream, int recurse, "slice"); struct value *len = value_struct_elt (&val, {}, "length", NULL, "slice"); - struct type *type = check_typedef (value_type (val)); + struct type *type = check_typedef (val->type ()); if (strcmp (type->name (), "&str") == 0) - val_print_string (value_type (base)->target_type (), "UTF-8", + val_print_string (base->type ()->target_type (), "UTF-8", value_as_address (base), value_as_long (len), stream, options); else { LONGEST llen = value_as_long (len); - type_print (value_type (val), "", stream, -1); + type_print (val->type (), "", stream, -1); gdb_printf (stream, " "); if (llen == 0) gdb_printf (stream, "[]"); else { - struct type *elt_type = value_type (base)->target_type (); + struct type *elt_type = base->type ()->target_type (); struct type *array_type = lookup_array_range_type (elt_type, 0, llen - 1); struct value *array = allocate_value_lazy (array_type); @@ -368,7 +368,7 @@ rust_language::val_print_struct { int i; int first_field; - struct type *type = check_typedef (value_type (val)); + struct type *type = check_typedef (val->type ()); if (rust_slice_type_p (type)) { @@ -450,14 +450,14 @@ rust_language::print_enum (struct value *val, struct ui_file *stream, const struct value_print_options *options) const { struct value_print_options opts = *options; - struct type *type = check_typedef (value_type (val)); + struct type *type = check_typedef (val->type ()); opts.deref_ref = false; gdb_assert (rust_enum_p (type)); gdb::array_view view (value_contents_for_printing (val).data (), - value_type (val)->length ()); + val->type ()->length ()); type = resolve_dynamic_type (type, view, value_address (val)); if (rust_empty_enum_p (type)) @@ -530,7 +530,7 @@ rust_language::value_print_inner opts.prettyformat = (opts.prettyformat_structs ? Val_prettyformat : Val_no_prettyformat); - struct type *type = check_typedef (value_type (val)); + struct type *type = check_typedef (val->type ()); switch (type->code ()) { case TYPE_CODE_PTR: @@ -635,11 +635,11 @@ rust_language::value_print value_print_options opts = *options; opts.deref_ref = true; - struct type *type = check_typedef (value_type (val)); + struct type *type = check_typedef (val->type ()); if (type->is_pointer_or_reference ()) { gdb_printf (stream, "("); - type_print (value_type (val), "", stream, -1); + type_print (val->type (), "", stream, -1); gdb_printf (stream, ") "); } @@ -1038,7 +1038,7 @@ rust_range (struct type *expect_type, struct expression *exp, } else { - index_type = value_type (high); + index_type = high->type (); name = (inclusive ? "std::ops::RangeToInclusive" : "std::ops::RangeTo"); } @@ -1047,14 +1047,14 @@ rust_range (struct type *expect_type, struct expression *exp, { if (high == NULL) { - index_type = value_type (low); + index_type = low->type (); name = "std::ops::RangeFrom"; } else { - if (!types_equal (value_type (low), value_type (high))) + if (!types_equal (low->type (), high->type ())) error (_("Range expression with different types")); - index_type = value_type (low); + index_type = low->type (); name = inclusive ? "std::ops::RangeInclusive" : "std::ops::Range"; } } @@ -1152,7 +1152,7 @@ rust_subscript (struct type *expect_type, struct expression *exp, LONGEST high = 0; int want_slice = 0; - rhstype = check_typedef (value_type (rhs)); + rhstype = check_typedef (rhs->type ()); if (rust_range_type_p (rhstype)) { if (!for_addr) @@ -1163,7 +1163,7 @@ rust_subscript (struct type *expect_type, struct expression *exp, else low = value_as_long (rhs); - struct type *type = check_typedef (value_type (lhs)); + struct type *type = check_typedef (lhs->type ()); if (noside == EVAL_AVOID_SIDE_EFFECTS) { struct type *base_type = nullptr; @@ -1272,7 +1272,7 @@ rust_subscript (struct type *expect_type, struct expression *exp, && rust_slice_type_p (type)) ? type->name () : "&[*gdb*]"); - slice = rust_slice_type (new_name, value_type (result), usize); + slice = rust_slice_type (new_name, result->type (), usize); addrval = value_allocate_space_in_inferior (slice->length ()); addr = value_as_long (addrval); @@ -1321,8 +1321,8 @@ eval_op_rust_complement (struct type *expect_type, struct expression *exp, enum exp_opcode opcode, struct value *value) { - if (value_type (value)->code () == TYPE_CODE_BOOL) - return value_from_longest (value_type (value), value_logical_not (value)); + if (value->type ()->code () == TYPE_CODE_BOOL) + return value_from_longest (value->type (), value_logical_not (value)); return value_complement (value); } @@ -1350,7 +1350,7 @@ eval_op_rust_array (struct type *expect_type, struct expression *exp, else { struct type *arraytype - = lookup_array_range_type (value_type (elt), 0, copies - 1); + = lookup_array_range_type (elt->type (), 0, copies - 1); return allocate_value (arraytype); } } @@ -1366,7 +1366,7 @@ rust_struct_anon::evaluate (struct type *expect_type, value *lhs = std::get<1> (m_storage)->evaluate (nullptr, exp, noside); int field_number = std::get<0> (m_storage); - struct type *type = value_type (lhs); + struct type *type = lhs->type (); if (type->code () == TYPE_CODE_STRUCT) { @@ -1384,7 +1384,7 @@ rust_struct_anon::evaluate (struct type *expect_type, int fieldno = rust_enum_variant (type); lhs = value_primitive_field (lhs, 0, fieldno, type); outer_type = type; - type = value_type (lhs); + type = lhs->type (); } /* Tuples and tuple structs */ @@ -1434,7 +1434,7 @@ rust_structop::evaluate (struct type *expect_type, const char *field_name = std::get<1> (m_storage).c_str (); struct value *result; - struct type *type = value_type (lhs); + struct type *type = lhs->type (); if (type->code () == TYPE_CODE_STRUCT && rust_enum_p (type)) { type = resolve_dynamic_type (type, value_contents (lhs), @@ -1448,7 +1448,7 @@ rust_structop::evaluate (struct type *expect_type, lhs = value_primitive_field (lhs, 0, fieldno, type); struct type *outer_type = type; - type = value_type (lhs); + type = lhs->type (); if (rust_tuple_type_p (type) || rust_tuple_struct_type_p (type)) error (_("Attempting to access named field %s of tuple " "variant %s::%s, which has only anonymous fields"), @@ -1470,7 +1470,7 @@ rust_structop::evaluate (struct type *expect_type, else result = value_struct_elt (&lhs, {}, field_name, NULL, "structure"); if (noside == EVAL_AVOID_SIDE_EFFECTS) - result = value_zero (value_type (result), VALUE_LVAL (result)); + result = value_zero (result->type (), VALUE_LVAL (result)); return result; } @@ -1537,10 +1537,10 @@ rust_structop::evaluate_funcall (struct type *expect_type, type in order to look up the method. */ args[0] = std::get<0> (m_storage)->evaluate (nullptr, exp, noside); /* We don't yet implement real Deref semantics. */ - while (value_type (args[0])->code () == TYPE_CODE_PTR) + while (args[0]->type ()->code () == TYPE_CODE_PTR) args[0] = value_ind (args[0]); - struct type *type = value_type (args[0]); + struct type *type = args[0]->type (); if ((type->code () != TYPE_CODE_STRUCT && type->code () != TYPE_CODE_UNION && type->code () != TYPE_CODE_ENUM) diff --git a/gdb/rx-tdep.c b/gdb/rx-tdep.c index 675c51cfee9..67db30ace88 100644 --- a/gdb/rx-tdep.c +++ b/gdb/rx-tdep.c @@ -668,7 +668,7 @@ rx_push_dummy_call (struct gdbarch *gdbarch, struct value *function, CORE_ADDR cfa; int num_register_candidate_args; - struct type *func_type = value_type (function); + struct type *func_type = function->type (); /* Dereference function pointer types. */ while (func_type->code () == TYPE_CODE_PTR) @@ -726,7 +726,7 @@ rx_push_dummy_call (struct gdbarch *gdbarch, struct value *function, { struct value *arg = args[i]; const gdb_byte *arg_bits = value_contents_all (arg).data (); - struct type *arg_type = check_typedef (value_type (arg)); + struct type *arg_type = check_typedef (arg->type ()); ULONGEST arg_size = arg_type->length (); if (i == 0 && struct_addr != 0 diff --git a/gdb/s390-tdep.c b/gdb/s390-tdep.c index 17933997d8c..f33a13e8a55 100644 --- a/gdb/s390-tdep.c +++ b/gdb/s390-tdep.c @@ -1749,7 +1749,7 @@ s390_handle_arg (struct s390_arg_state *as, struct value *arg, s390_gdbarch_tdep *tdep, int word_size, enum bfd_endian byte_order, int is_unnamed) { - struct type *type = check_typedef (value_type (arg)); + struct type *type = check_typedef (arg->type ()); unsigned int length = type->length (); int write_mode = as->regcache != NULL; @@ -1911,7 +1911,7 @@ s390_push_dummy_call (struct gdbarch *gdbarch, struct value *function, int i; struct s390_arg_state arg_state, arg_prep; CORE_ADDR param_area_start, new_sp; - struct type *ftype = check_typedef (value_type (function)); + struct type *ftype = check_typedef (function->type ()); if (ftype->code () == TYPE_CODE_PTR) ftype = check_typedef (ftype->target_type ()); diff --git a/gdb/sh-tdep.c b/gdb/sh-tdep.c index a816e6b00cd..c98df0223e9 100644 --- a/gdb/sh-tdep.c +++ b/gdb/sh-tdep.c @@ -897,7 +897,7 @@ sh_stack_allocsize (int nargs, struct value **args) { int stack_alloc = 0; while (nargs-- > 0) - stack_alloc += ((value_type (args[nargs])->length () + 3) & ~3); + stack_alloc += ((args[nargs]->type ()->length () + 3) & ~3); return stack_alloc; } @@ -1030,7 +1030,7 @@ sh_push_dummy_call_fpu (struct gdbarch *gdbarch, int argreg = ARG0_REGNUM; int flt_argreg = 0; int argnum; - struct type *func_type = value_type (function); + struct type *func_type = function->type (); struct type *type; CORE_ADDR regval; const gdb_byte *val; @@ -1060,7 +1060,7 @@ sh_push_dummy_call_fpu (struct gdbarch *gdbarch, in four registers available. Loop thru args from first to last. */ for (argnum = 0; argnum < nargs; argnum++) { - type = value_type (args[argnum]); + type = args[argnum]->type (); len = type->length (); val = sh_justify_value_in_reg (gdbarch, args[argnum], len); @@ -1172,7 +1172,7 @@ sh_push_dummy_call_nofpu (struct gdbarch *gdbarch, int stack_offset = 0; int argreg = ARG0_REGNUM; int argnum; - struct type *func_type = value_type (function); + struct type *func_type = function->type (); struct type *type; CORE_ADDR regval; const gdb_byte *val; @@ -1198,7 +1198,7 @@ sh_push_dummy_call_nofpu (struct gdbarch *gdbarch, in four registers available. Loop thru args from first to last. */ for (argnum = 0; argnum < nargs; argnum++) { - type = value_type (args[argnum]); + type = args[argnum]->type (); len = type->length (); val = sh_justify_value_in_reg (gdbarch, args[argnum], len); @@ -1364,7 +1364,7 @@ sh_return_value_nofpu (struct gdbarch *gdbarch, struct value *function, struct type *type, struct regcache *regcache, gdb_byte *readbuf, const gdb_byte *writebuf) { - struct type *func_type = function ? value_type (function) : NULL; + struct type *func_type = function ? function->type () : NULL; if (sh_use_struct_convention_nofpu (sh_is_renesas_calling_convention (func_type), type)) @@ -1381,7 +1381,7 @@ sh_return_value_fpu (struct gdbarch *gdbarch, struct value *function, struct type *type, struct regcache *regcache, gdb_byte *readbuf, const gdb_byte *writebuf) { - struct type *func_type = function ? value_type (function) : NULL; + struct type *func_type = function ? function->type () : NULL; if (sh_use_struct_convention ( sh_is_renesas_calling_convention (func_type), type)) diff --git a/gdb/sparc-tdep.c b/gdb/sparc-tdep.c index bd3dc946f87..6c41cfd04e2 100644 --- a/gdb/sparc-tdep.c +++ b/gdb/sparc-tdep.c @@ -621,7 +621,7 @@ sparc32_store_arguments (struct regcache *regcache, int nargs, for (i = 0; i < nargs; i++) { - struct type *type = value_type (args[i]); + struct type *type = args[i]->type (); int len = type->length (); if (sparc_arg_by_memory_p (type)) @@ -665,7 +665,7 @@ sparc32_store_arguments (struct regcache *regcache, int nargs, for (i = 0; i < nargs; i++) { const bfd_byte *valbuf = value_contents (args[i]).data (); - struct type *type = value_type (args[i]); + struct type *type = args[i]->type (); int len = type->length (); gdb_byte buf[4]; diff --git a/gdb/sparc64-tdep.c b/gdb/sparc64-tdep.c index 96910be3f0e..eb6a66315c0 100644 --- a/gdb/sparc64-tdep.c +++ b/gdb/sparc64-tdep.c @@ -1381,7 +1381,7 @@ sparc64_store_arguments (struct regcache *regcache, int nargs, for (i = 0; i < nargs; i++) { - struct type *type = value_type (args[i]); + struct type *type = args[i]->type (); int len = type->length (); if (sparc64_structure_or_union_p (type) @@ -1481,7 +1481,7 @@ sparc64_store_arguments (struct regcache *regcache, int nargs, for (i = 0; i < nargs; i++) { const gdb_byte *valbuf = value_contents (args[i]).data (); - struct type *type = value_type (args[i]); + struct type *type = args[i]->type (); int len = type->length (); int regnum = -1; gdb_byte buf[16]; diff --git a/gdb/stack.c b/gdb/stack.c index c36f144f093..9e239ed4f67 100644 --- a/gdb/stack.c +++ b/gdb/stack.c @@ -467,7 +467,7 @@ print_frame_arg (const frame_print_options &fp_opts, because our standard indentation here is 4 spaces, and val_print indents 2 for each recurse. */ - annotate_arg_value (value_type (arg->val)); + annotate_arg_value (arg->val->type ()); /* Use the appropriate language to display our symbol, unless the user forced the language to a specific language. */ @@ -578,7 +578,7 @@ read_frame_arg (const frame_print_options &fp_opts, if (val && entryval && !current_uiout->is_mi_like_p ()) { - struct type *type = value_type (val); + struct type *type = val->type (); if (value_lazy (val)) value_fetch_lazy (val); @@ -601,7 +601,7 @@ read_frame_arg (const frame_print_options &fp_opts, val_deref = coerce_ref (val); if (value_lazy (val_deref)) value_fetch_lazy (val_deref); - type_deref = value_type (val_deref); + type_deref = val_deref->type (); entryval_deref = coerce_ref (entryval); if (value_lazy (entryval_deref)) @@ -2742,7 +2742,7 @@ return_command (const char *retval_exp, int from_tty) error (_("Return value type not available for selected " "stack frame.\n" "Please use an explicit cast of the value to return.")); - return_type = value_type (return_value); + return_type = return_value->type (); } return_type = check_typedef (return_type); return_value = value_cast (return_type, return_value); @@ -2765,7 +2765,7 @@ return_command (const char *retval_exp, int from_tty) return_value = NULL; else if (thisfun != NULL) { - if (is_nocall_function (check_typedef (value_type (function)))) + if (is_nocall_function (check_typedef (function->type ()))) { query_prefix = string_printf ("Function '%s' does not follow the target " @@ -2817,7 +2817,7 @@ return_command (const char *retval_exp, int from_tty) /* Store RETURN_VALUE in the just-returned register set. */ if (return_value != NULL) { - struct type *return_type = value_type (return_value); + struct type *return_type = return_value->type (); struct gdbarch *cache_arch = get_current_regcache ()->arch (); gdb_assert (rv_conv != RETURN_VALUE_STRUCT_CONVENTION diff --git a/gdb/tic6x-tdep.c b/gdb/tic6x-tdep.c index 6c103943b72..000a2a9aaa5 100644 --- a/gdb/tic6x-tdep.c +++ b/gdb/tic6x-tdep.c @@ -864,7 +864,7 @@ tic6x_push_dummy_call (struct gdbarch *gdbarch, struct value *function, int stack_offset = 4; int references_offset = 4; enum bfd_endian byte_order = gdbarch_byte_order (gdbarch); - struct type *func_type = value_type (function); + struct type *func_type = function->type (); /* The first arg passed on stack. Mostly the first 10 args are passed by registers. */ int first_arg_on_stack = 10; @@ -895,7 +895,7 @@ tic6x_push_dummy_call (struct gdbarch *gdbarch, struct value *function, /* Now make space on the stack for the args. */ for (argnum = 0; argnum < nargs; argnum++) { - int len = align_up (value_type (args[argnum])->length (), 4); + int len = align_up (args[argnum]->type ()->length (), 4); if (argnum >= 10 - argreg) references_offset += len; stack_offset += len; @@ -913,7 +913,7 @@ tic6x_push_dummy_call (struct gdbarch *gdbarch, struct value *function, { const gdb_byte *val; struct value *arg = args[argnum]; - struct type *arg_type = check_typedef (value_type (arg)); + struct type *arg_type = check_typedef (arg->type ()); int len = arg_type->length (); enum type_code typecode = arg_type->code (); diff --git a/gdb/typeprint.c b/gdb/typeprint.c index 41b57353ce1..64709b9d1db 100644 --- a/gdb/typeprint.c +++ b/gdb/typeprint.c @@ -515,7 +515,7 @@ whatis_exp (const char *exp, int show) any typedef level. "ptype" always strips all levels of typedefs. */ val = evaluate_type (expr.get ()); - type = value_type (val); + type = val->type (); if (show == -1 && expr->first_opcode () == OP_TYPE) { @@ -536,7 +536,7 @@ whatis_exp (const char *exp, int show) else { val = access_value_history (0); - type = value_type (val); + type = val->type (); } if (flags.print_offsets && is_dynamic_type (type)) @@ -712,7 +712,7 @@ maintenance_print_type (const char *type_name, int from_tty) { expression_up expr = parse_expression (type_name); struct value *val = evaluate_type (expr.get ()); - struct type *type = value_type (val); + struct type *type = val->type (); if (type != nullptr) recursive_dump_type (type, 0); diff --git a/gdb/v850-tdep.c b/gdb/v850-tdep.c index cc7da907a5e..fd801540757 100644 --- a/gdb/v850-tdep.c +++ b/gdb/v850-tdep.c @@ -1037,7 +1037,7 @@ v850_push_dummy_call (struct gdbarch *gdbarch, /* Now make space on the stack for the args. */ for (argnum = 0; argnum < nargs; argnum++) - arg_space += ((value_type (args[argnum])->length () + 3) & ~3); + arg_space += ((args[argnum]->type ()->length () + 3) & ~3); sp -= arg_space + stack_offset; argreg = E_ARG0_REGNUM; @@ -1054,9 +1054,9 @@ v850_push_dummy_call (struct gdbarch *gdbarch, gdb_byte *val; gdb_byte valbuf[v850_reg_size]; - if (!v850_type_is_scalar (value_type (*args)) + if (!v850_type_is_scalar ((*args)->type ()) && tdep->abi == V850_ABI_GCC - && value_type (*args)->length () > E_MAX_RETTYPE_SIZE_IN_REGS) + && (*args)->type ()->length () > E_MAX_RETTYPE_SIZE_IN_REGS) { store_unsigned_integer (valbuf, 4, byte_order, value_address (*args)); @@ -1065,12 +1065,12 @@ v850_push_dummy_call (struct gdbarch *gdbarch, } else { - len = value_type (*args)->length (); + len = (*args)->type ()->length (); val = (gdb_byte *) value_contents (*args).data (); } if (tdep->eight_byte_align - && v850_eight_byte_align_p (value_type (*args))) + && v850_eight_byte_align_p ((*args)->type ())) { if (argreg <= E_ARGLAST_REGNUM && (argreg & 1)) argreg++; diff --git a/gdb/valarith.c b/gdb/valarith.c index 1dce9d0f613..53dfc82012d 100644 --- a/gdb/valarith.c +++ b/gdb/valarith.c @@ -88,7 +88,7 @@ value_ptradd (struct value *arg1, LONGEST arg2) struct value *result; arg1 = coerce_array (arg1); - valptrtype = check_typedef (value_type (arg1)); + valptrtype = check_typedef (arg1->type ()); sz = find_size_for_pointer_math (valptrtype); result = value_from_pointer (valptrtype, @@ -109,8 +109,8 @@ value_ptrdiff (struct value *arg1, struct value *arg2) arg1 = coerce_array (arg1); arg2 = coerce_array (arg2); - type1 = check_typedef (value_type (arg1)); - type2 = check_typedef (value_type (arg2)); + type1 = check_typedef (arg1->type ()); + type2 = check_typedef (arg2->type ()); gdb_assert (type1->code () == TYPE_CODE_PTR); gdb_assert (type2->code () == TYPE_CODE_PTR); @@ -149,7 +149,7 @@ value_subscript (struct value *array, LONGEST index) struct type *tarray; array = coerce_ref (array); - tarray = check_typedef (value_type (array)); + tarray = check_typedef (array->type ()); if (tarray->code () == TYPE_CODE_ARRAY || tarray->code () == TYPE_CODE_STRING) @@ -199,7 +199,7 @@ static struct value * value_subscripted_rvalue (struct value *array, LONGEST index, LONGEST lowerbound) { - struct type *array_type = check_typedef (value_type (array)); + struct type *array_type = check_typedef (array->type ()); struct type *elt_type = array_type->target_type (); LONGEST elt_size = type_length_units (elt_type); @@ -277,7 +277,7 @@ int binop_user_defined_p (enum exp_opcode op, struct value *arg1, struct value *arg2) { - return binop_types_user_defined_p (op, value_type (arg1), value_type (arg2)); + return binop_types_user_defined_p (op, arg1->type (), arg2->type ()); } /* Check to see if argument is a structure. This is called so @@ -293,7 +293,7 @@ unop_user_defined_p (enum exp_opcode op, struct value *arg1) if (op == UNOP_ADDR) return 0; - type1 = check_typedef (value_type (arg1)); + type1 = check_typedef (arg1->type ()); if (TYPE_IS_REFERENCE (type1)) type1 = check_typedef (type1->target_type ()); return type1->code () == TYPE_CODE_STRUCT; @@ -379,7 +379,7 @@ value_x_binop (struct value *arg1, struct value *arg2, enum exp_opcode op, /* now we know that what we have to do is construct our arg vector and find the right function to call it with. */ - if (check_typedef (value_type (arg1))->code () != TYPE_CODE_STRUCT) + if (check_typedef (arg1->type ())->code () != TYPE_CODE_STRUCT) error (_("Can't do that binary op on that type")); /* FIXME be explicit */ value *argvec_storage[3]; @@ -506,7 +506,7 @@ value_x_binop (struct value *arg1, struct value *arg2, enum exp_opcode op, argvec[1] = argvec[0]; argvec = argvec.slice (1); } - if (value_type (argvec[0])->code () == TYPE_CODE_XMETHOD) + if (argvec[0]->type ()->code () == TYPE_CODE_XMETHOD) { /* Static xmethods are not supported yet. */ gdb_assert (static_memfuncp == 0); @@ -525,7 +525,7 @@ value_x_binop (struct value *arg1, struct value *arg2, enum exp_opcode op, { struct type *return_type; - return_type = check_typedef (value_type (argvec[0]))->target_type (); + return_type = check_typedef (argvec[0]->type ())->target_type (); return value_zero (return_type, VALUE_LVAL (arg1)); } return call_function_by_hand (argvec[0], NULL, @@ -544,7 +544,7 @@ value_x_binop (struct value *arg1, struct value *arg2, enum exp_opcode op, struct value * value_x_unop (struct value *arg1, enum exp_opcode op, enum noside noside) { - struct gdbarch *gdbarch = value_type (arg1)->arch (); + struct gdbarch *gdbarch = arg1->type ()->arch (); char *ptr; char tstr[13], mangle_tstr[13]; int static_memfuncp, nargs; @@ -554,7 +554,7 @@ value_x_unop (struct value *arg1, enum exp_opcode op, enum noside noside) /* now we know that what we have to do is construct our arg vector and find the right function to call it with. */ - if (check_typedef (value_type (arg1))->code () != TYPE_CODE_STRUCT) + if (check_typedef (arg1->type ())->code () != TYPE_CODE_STRUCT) error (_("Can't do that unary op on that type")); /* FIXME be explicit */ value *argvec_storage[3]; @@ -619,7 +619,7 @@ value_x_unop (struct value *arg1, enum exp_opcode op, enum noside noside) argvec[1] = argvec[0]; argvec = argvec.slice (1); } - if (value_type (argvec[0])->code () == TYPE_CODE_XMETHOD) + if (argvec[0]->type ()->code () == TYPE_CODE_XMETHOD) { /* Static xmethods are not supported yet. */ gdb_assert (static_memfuncp == 0); @@ -638,7 +638,7 @@ value_x_unop (struct value *arg1, enum exp_opcode op, enum noside noside) { struct type *return_type; - return_type = check_typedef (value_type (argvec[0]))->target_type (); + return_type = check_typedef (argvec[0]->type ())->target_type (); return value_zero (return_type, VALUE_LVAL (arg1)); } return call_function_by_hand (argvec[0], NULL, @@ -656,8 +656,8 @@ value_x_unop (struct value *arg1, enum exp_opcode op, enum noside noside) struct value * value_concat (struct value *arg1, struct value *arg2) { - struct type *type1 = check_typedef (value_type (arg1)); - struct type *type2 = check_typedef (value_type (arg2)); + struct type *type1 = check_typedef (arg1->type ()); + struct type *type2 = check_typedef (arg2->type ()); if (type1->code () != TYPE_CODE_ARRAY && type2->code () != TYPE_CODE_ARRAY) error ("no array provided to concatenation"); @@ -751,8 +751,8 @@ value_args_as_target_float (struct value *arg1, struct value *arg2, { struct type *type1, *type2; - type1 = check_typedef (value_type (arg1)); - type2 = check_typedef (value_type (arg2)); + type1 = check_typedef (arg1->type ()); + type2 = check_typedef (arg2->type ()); /* At least one of the arguments must be of floating-point type. */ gdb_assert (is_floating_type (type1) || is_floating_type (type2)); @@ -811,8 +811,8 @@ value_args_as_target_float (struct value *arg1, struct value *arg2, static struct value * fixed_point_binop (struct value *arg1, struct value *arg2, enum exp_opcode op) { - struct type *type1 = check_typedef (value_type (arg1)); - struct type *type2 = check_typedef (value_type (arg2)); + struct type *type1 = check_typedef (arg1->type ()); + struct type *type2 = check_typedef (arg2->type ()); const struct language_defn *language = current_language; struct gdbarch *gdbarch = type1->arch (); @@ -961,8 +961,8 @@ static struct value *scalar_binop (struct value *arg1, struct value *arg2, static struct value * complex_binop (struct value *arg1, struct value *arg2, enum exp_opcode op) { - struct type *arg1_type = check_typedef (value_type (arg1)); - struct type *arg2_type = check_typedef (value_type (arg2)); + struct type *arg1_type = check_typedef (arg1->type ()); + struct type *arg2_type = check_typedef (arg2->type ()); struct value *arg1_real, *arg1_imag, *arg2_real, *arg2_imag; if (arg1_type->code () == TYPE_CODE_COMPLEX) @@ -986,8 +986,8 @@ complex_binop (struct value *arg1, struct value *arg2, enum exp_opcode op) arg2_imag = value_zero (arg2_type, not_lval); } - struct type *comp_type = promotion_type (value_type (arg1_real), - value_type (arg2_real)); + struct type *comp_type = promotion_type (arg1_real->type (), + arg2_real->type ()); if (!can_create_complex_type (comp_type)) error (_("Argument to complex arithmetic operation not supported.")); @@ -1057,7 +1057,7 @@ complex_binop (struct value *arg1, struct value *arg2, enum exp_opcode op) else v1 = v1 || v2; - return value_from_longest (value_type (x1), v1); + return value_from_longest (x1->type (), v1); } break; @@ -1143,8 +1143,8 @@ scalar_binop (struct value *arg1, struct value *arg2, enum exp_opcode op) arg1 = coerce_ref (arg1); arg2 = coerce_ref (arg2); - type1 = check_typedef (value_type (arg1)); - type2 = check_typedef (value_type (arg2)); + type1 = check_typedef (arg1->type ()); + type2 = check_typedef (arg2->type ()); if (type1->code () == TYPE_CODE_COMPLEX || type2->code () == TYPE_CODE_COMPLEX) @@ -1362,7 +1362,7 @@ scalar_binop (struct value *arg1, struct value *arg2, enum exp_opcode op) val = allocate_value (result_type); store_unsigned_integer (value_contents_raw (val).data (), - value_type (val)->length (), + val->type ()->length (), type_byte_order (result_type), v); } @@ -1523,7 +1523,7 @@ scalar_binop (struct value *arg1, struct value *arg2, enum exp_opcode op) val = allocate_value (result_type); store_signed_integer (value_contents_raw (val).data (), - value_type (val)->length (), + val->type ()->length (), type_byte_order (result_type), v); } @@ -1558,7 +1558,7 @@ value_vector_widen (struct value *scalar_value, struct type *vector_type) eltype = check_typedef (vector_type->target_type ()); elval = value_cast (eltype, scalar_value); - scalar_type = check_typedef (value_type (scalar_value)); + scalar_type = check_typedef (scalar_value->type ()); /* If we reduced the length of the scalar then check we didn't loose any important bits. */ @@ -1588,8 +1588,8 @@ vector_binop (struct value *val1, struct value *val2, enum exp_opcode op) int t1_is_vec, t2_is_vec, elsize, i; LONGEST low_bound1, high_bound1, low_bound2, high_bound2; - type1 = check_typedef (value_type (val1)); - type2 = check_typedef (value_type (val2)); + type1 = check_typedef (val1->type ()); + type2 = check_typedef (val2->type ()); t1_is_vec = (type1->code () == TYPE_CODE_ARRAY && type1->is_vector ()) ? 1 : 0; @@ -1633,8 +1633,8 @@ struct value * value_binop (struct value *arg1, struct value *arg2, enum exp_opcode op) { struct value *val; - struct type *type1 = check_typedef (value_type (arg1)); - struct type *type2 = check_typedef (value_type (arg2)); + struct type *type1 = check_typedef (arg1->type ()); + struct type *type2 = check_typedef (arg2->type ()); int t1_is_vec = (type1->code () == TYPE_CODE_ARRAY && type1->is_vector ()); int t2_is_vec = (type2->code () == TYPE_CODE_ARRAY @@ -1674,7 +1674,7 @@ value_logical_not (struct value *arg1) struct type *type1; arg1 = coerce_array (arg1); - type1 = check_typedef (value_type (arg1)); + type1 = check_typedef (arg1->type ()); if (is_floating_value (arg1)) return target_float_is_zero (value_contents (arg1).data (), type1); @@ -1697,8 +1697,8 @@ value_logical_not (struct value *arg1) static int value_strcmp (struct value *arg1, struct value *arg2) { - int len1 = value_type (arg1)->length (); - int len2 = value_type (arg2)->length (); + int len1 = arg1->type ()->length (); + int len2 = arg2->type ()->length (); const gdb_byte *s1 = value_contents (arg1).data (); const gdb_byte *s2 = value_contents (arg2).data (); int i, len = len1 < len2 ? len1 : len2; @@ -1738,8 +1738,8 @@ value_equal (struct value *arg1, struct value *arg2) arg1 = coerce_array (arg1); arg2 = coerce_array (arg2); - type1 = check_typedef (value_type (arg1)); - type2 = check_typedef (value_type (arg2)); + type1 = check_typedef (arg1->type ()); + type2 = check_typedef (arg2->type ()); code1 = type1->code (); code2 = type2->code (); is_int1 = is_integral_type (type1); @@ -1801,8 +1801,8 @@ value_equal_contents (struct value *arg1, struct value *arg2) { struct type *type1, *type2; - type1 = check_typedef (value_type (arg1)); - type2 = check_typedef (value_type (arg2)); + type1 = check_typedef (arg1->type ()); + type2 = check_typedef (arg2->type ()); return (type1->code () == type2->code () && type1->length () == type2->length () @@ -1825,8 +1825,8 @@ value_less (struct value *arg1, struct value *arg2) arg1 = coerce_array (arg1); arg2 = coerce_array (arg2); - type1 = check_typedef (value_type (arg1)); - type2 = check_typedef (value_type (arg2)); + type1 = check_typedef (arg1->type ()); + type2 = check_typedef (arg2->type ()); code1 = type1->code (); code2 = type2->code (); is_int1 = is_integral_type (type1); @@ -1877,7 +1877,7 @@ value_pos (struct value *arg1) struct type *type; arg1 = coerce_ref (arg1); - type = check_typedef (value_type (arg1)); + type = check_typedef (arg1->type ()); if (is_integral_type (type) || is_floating_value (arg1) || (type->code () == TYPE_CODE_ARRAY && type->is_vector ()) @@ -1893,7 +1893,7 @@ value_neg (struct value *arg1) struct type *type; arg1 = coerce_ref (arg1); - type = check_typedef (value_type (arg1)); + type = check_typedef (arg1->type ()); if (is_integral_type (type) || is_floating_type (type)) return value_binop (value_from_longest (type, 0), arg1, BINOP_SUB); @@ -1940,7 +1940,7 @@ value_complement (struct value *arg1) struct value *val; arg1 = coerce_ref (arg1); - type = check_typedef (value_type (arg1)); + type = check_typedef (arg1->type ()); if (is_integral_type (type)) val = value_from_longest (type, ~value_as_long (arg1)); @@ -2010,8 +2010,8 @@ int value_in (struct value *element, struct value *set) { int member; - struct type *settype = check_typedef (value_type (set)); - struct type *eltype = check_typedef (value_type (element)); + struct type *settype = check_typedef (set->type ()); + struct type *eltype = check_typedef (element->type ()); if (eltype->code () == TYPE_CODE_RANGE) eltype = eltype->target_type (); diff --git a/gdb/valops.c b/gdb/valops.c index c5b16f8d400..a56afce0235 100644 --- a/gdb/valops.c +++ b/gdb/valops.c @@ -213,7 +213,7 @@ value_cast_structs (struct type *type, struct value *v2) gdb_assert (type != NULL && v2 != NULL); t1 = check_typedef (type); - t2 = check_typedef (value_type (v2)); + t2 = check_typedef (v2->type ()); /* Check preconditions. */ gdb_assert ((t1->code () == TYPE_CODE_STRUCT @@ -254,7 +254,7 @@ value_cast_structs (struct type *type, struct value *v2) { v = value_full_object (v2, real_type, full, top, using_enc); v = value_at_lazy (real_type, value_address (v)); - real_type = value_type (v); + real_type = v->type (); /* We might be trying to cast to the outermost enclosing type, in which case search_struct_field won't work. */ @@ -297,7 +297,7 @@ value_cast_pointers (struct type *type, struct value *arg2, int subclass_check) { struct type *type1 = check_typedef (type); - struct type *type2 = check_typedef (value_type (arg2)); + struct type *type2 = check_typedef (arg2->type ()); struct type *t1 = check_typedef (type1->target_type ()); struct type *t2 = check_typedef (type2->target_type ()); @@ -311,7 +311,7 @@ value_cast_pointers (struct type *type, struct value *arg2, v2 = coerce_ref (arg2); else v2 = value_ind (arg2); - gdb_assert (check_typedef (value_type (v2))->code () + gdb_assert (check_typedef (v2->type ())->code () == TYPE_CODE_STRUCT && !!"Why did coercion fail?"); v2 = value_cast_structs (t1, v2); /* At this point we have what we can have, un-dereference if needed. */ @@ -337,7 +337,7 @@ value_cast_pointers (struct type *type, struct value *arg2, gdb_mpq value_to_gdb_mpq (struct value *value) { - struct type *type = check_typedef (value_type (value)); + struct type *type = check_typedef (value->type ()); gdb_mpq result; if (is_floating_type (type)) @@ -370,7 +370,7 @@ value_to_gdb_mpq (struct value *value) static struct value * value_cast_to_fixed_point (struct type *to_type, struct value *from_val) { - struct type *from_type = value_type (from_val); + struct type *from_type = from_val->type (); if (from_type == to_type) return from_val; @@ -416,17 +416,17 @@ value_cast (struct type *type, struct value *arg2) /* TYPE might be equal in meaning to the existing type of ARG2, but for many reasons, might be a different type object (e.g. TYPE might be a - gdbarch owned type, while VALUE_TYPE (ARG2) could be an objfile owned + gdbarch owned type, while ARG2->type () could be an objfile owned type). In this case we want to preserve the LVAL of ARG2 as this allows the resulting value to be used in more places. We do this by calling VALUE_COPY if appropriate. */ - if (types_deeply_equal (value_type (arg2), type)) + if (types_deeply_equal (arg2->type (), type)) { /* If the types are exactly equal then we can avoid creating a new value completely. */ - if (value_type (arg2) != type) + if (arg2->type () != type) { arg2 = value_copy (arg2); deprecated_set_value_type (arg2, type); @@ -450,7 +450,7 @@ value_cast (struct type *type, struct value *arg2) return value_ref (val, t1->code ()); } - if (TYPE_IS_REFERENCE (check_typedef (value_type (arg2)))) + if (TYPE_IS_REFERENCE (check_typedef (arg2->type ()))) /* We deref the value and then do the cast. */ return value_cast (type, coerce_ref (arg2)); @@ -462,7 +462,7 @@ value_cast (struct type *type, struct value *arg2) type = check_typedef (type); code1 = type->code (); arg2 = coerce_ref (arg2); - type2 = check_typedef (value_type (arg2)); + type2 = check_typedef (arg2->type ()); /* You can't cast to a reference type. See value_cast_pointers instead. */ @@ -510,7 +510,7 @@ value_cast (struct type *type, struct value *arg2) if (type2->code () == TYPE_CODE_FUNC) arg2 = value_coerce_function (arg2); - type2 = check_typedef (value_type (arg2)); + type2 = check_typedef (arg2->type ()); code2 = type2->code (); if (code1 == TYPE_CODE_COMPLEX) @@ -691,7 +691,7 @@ value_reinterpret_cast (struct type *type, struct value *arg) real_type = lookup_pointer_type (real_type); } - arg_type = value_type (arg); + arg_type = arg->type (); dest_code = real_type->code (); arg_code = arg_type->code (); @@ -819,7 +819,7 @@ value_dynamic_cast (struct type *type, struct value *arg) int full, using_enc; LONGEST top; struct type *resolved_type = check_typedef (type); - struct type *arg_type = check_typedef (value_type (arg)); + struct type *arg_type = check_typedef (arg->type ()); struct type *class_type, *rtti_type; struct value *result, *tem, *original_arg = arg; CORE_ADDR addr; @@ -894,7 +894,7 @@ value_dynamic_cast (struct type *type, struct value *arg) return value_at_lazy (type, addr); tem = value_at (type, addr); - type = value_type (tem); + type = tem->type (); /* The first dynamic check specified in 5.2.7. */ if (is_public_ancestor (arg_type, resolved_type->target_type ())) @@ -1095,7 +1095,7 @@ value_assign (struct value *toval, struct value *fromval) toval = coerce_ref (toval); - type = value_type (toval); + type = toval->type (); if (VALUE_LVAL (toval) != lval_internalvar) fromval = value_cast (type, fromval); else @@ -1405,7 +1405,7 @@ address_of_variable (struct symbol *var, const struct block *b) Lazy evaluation pays off here. */ val = value_of_variable (var, b); - type = value_type (val); + type = val->type (); if ((VALUE_LVAL (val) == lval_memory && value_lazy (val)) || type->code () == TYPE_CODE_FUNC) @@ -1458,7 +1458,7 @@ value_must_coerce_to_target (struct value *val) && VALUE_LVAL (val) != lval_xcallable) return false; - valtype = check_typedef (value_type (val)); + valtype = check_typedef (val->type ()); switch (valtype->code ()) { @@ -1484,10 +1484,10 @@ value_coerce_to_target (struct value *val) if (!value_must_coerce_to_target (val)) return val; - length = check_typedef (value_type (val))->length (); + length = check_typedef (val->type ())->length (); addr = allocate_space_in_inferior (length); write_memory (addr, value_contents (val).data (), length); - return value_at_lazy (value_type (val), addr); + return value_at_lazy (val->type (), addr); } /* Given a value which is an array, return a value which is a pointer @@ -1516,7 +1516,7 @@ value_coerce_to_target (struct value *val) struct value * value_coerce_array (struct value *arg1) { - struct type *type = check_typedef (value_type (arg1)); + struct type *type = check_typedef (arg1->type ()); /* If the user tries to do something requiring a pointer with an array that has not yet been pushed to the target, then this would @@ -1541,7 +1541,7 @@ value_coerce_function (struct value *arg1) if (VALUE_LVAL (arg1) != lval_memory) error (_("Attempt to take address of value not located in memory.")); - retval = value_from_pointer (lookup_pointer_type (value_type (arg1)), + retval = value_from_pointer (lookup_pointer_type (arg1->type ()), value_address (arg1)); return retval; } @@ -1553,7 +1553,7 @@ struct value * value_addr (struct value *arg1) { struct value *arg2; - struct type *type = check_typedef (value_type (arg1)); + struct type *type = check_typedef (arg1->type ()); if (TYPE_IS_REFERENCE (type)) { @@ -1591,7 +1591,7 @@ value_addr (struct value *arg1) error (_("Attempt to take address of value not located in memory.")); /* Get target memory address. */ - arg2 = value_from_pointer (lookup_pointer_type (value_type (arg1)), + arg2 = value_from_pointer (lookup_pointer_type (arg1->type ()), (value_address (arg1) + value_embedded_offset (arg1))); @@ -1612,7 +1612,7 @@ struct value * value_ref (struct value *arg1, enum type_code refcode) { struct value *arg2; - struct type *type = check_typedef (value_type (arg1)); + struct type *type = check_typedef (arg1->type ()); gdb_assert (refcode == TYPE_CODE_REF || refcode == TYPE_CODE_RVALUE_REF); @@ -1637,7 +1637,7 @@ value_ind (struct value *arg1) arg1 = coerce_array (arg1); - base_type = check_typedef (value_type (arg1)); + base_type = check_typedef (arg1->type ()); if (VALUE_LVAL (arg1) == lval_computed) { @@ -1676,7 +1676,7 @@ value_ind (struct value *arg1) - value_pointed_to_offset (arg1)); } arg2 = value_at_lazy (enc_type, base_addr); - enc_type = value_type (arg2); + enc_type = arg2->type (); return readjust_indirect_value_type (arg2, enc_type, base_type, arg1, base_addr); } @@ -1818,7 +1818,7 @@ typecmp (bool staticp, bool varargs, int nargs, return i + 1; tt1 = check_typedef (t1[i].type ()); - tt2 = check_typedef (value_type (t2[i])); + tt2 = check_typedef (t2[i]->type ()); if (TYPE_IS_REFERENCE (tt1) /* We should be doing hairy argument matching, as below. */ @@ -1856,7 +1856,7 @@ typecmp (bool staticp, bool varargs, int nargs, /* We should be doing much hairier argument matching (see section 13.2 of the ARM), but as a quick kludge, just check for the same type code. */ - if (t1[i].type ()->code () != value_type (t2[i])->code ()) + if (t1[i].type ()->code () != t2[i]->type ()->code ()) return i + 1; } if (varargs || i == t2.size ()) @@ -2104,7 +2104,7 @@ struct_field_searcher::search (struct value *arg1, LONGEST offset, v2 = value_at_lazy (basetype, base_addr); if (target_read_memory (base_addr, value_contents_raw (v2).data (), - value_type (v2)->length ()) != 0) + v2->type ()->length ()) != 0) error (_("virtual baseclass botch")); } else @@ -2162,7 +2162,7 @@ search_struct_field (const char *name, struct value *arg1, { gdb_assert (!candidate.path.empty ()); - struct type *field_type = value_type (candidate.field_value); + struct type *field_type = candidate.field_value->type (); struct type *struct_type = candidate.path.back (); std::string path; @@ -2351,7 +2351,7 @@ value_struct_elt (struct value **argp, *argp = coerce_array (*argp); - t = check_typedef (value_type (*argp)); + t = check_typedef ((*argp)->type ()); /* Follow pointers until we get to a non-pointer. */ @@ -2359,9 +2359,9 @@ value_struct_elt (struct value **argp, { *argp = value_ind (*argp); /* Don't coerce fn pointer to fn and then back again! */ - if (check_typedef (value_type (*argp))->code () != TYPE_CODE_FUNC) + if (check_typedef ((*argp)->type ())->code () != TYPE_CODE_FUNC) *argp = coerce_array (*argp); - t = check_typedef (value_type (*argp)); + t = check_typedef ((*argp)->type ()); } if (t->code () != TYPE_CODE_STRUCT @@ -2449,14 +2449,14 @@ value_struct_elt_bitpos (struct value **argp, int bitpos, struct type *ftype, *argp = coerce_array (*argp); - t = check_typedef (value_type (*argp)); + t = check_typedef ((*argp)->type ()); while (t->is_pointer_or_reference ()) { *argp = value_ind (*argp); - if (check_typedef (value_type (*argp))->code () != TYPE_CODE_FUNC) + if (check_typedef ((*argp)->type ())->code () != TYPE_CODE_FUNC) *argp = coerce_array (*argp); - t = check_typedef (value_type (*argp)); + t = check_typedef ((*argp)->type ()); } if (t->code () != TYPE_CODE_STRUCT @@ -2601,16 +2601,16 @@ value_find_oload_method_list (struct value **argp, const char *method, { struct type *t; - t = check_typedef (value_type (*argp)); + t = check_typedef ((*argp)->type ()); /* Code snarfed from value_struct_elt. */ while (t->is_pointer_or_reference ()) { *argp = value_ind (*argp); /* Don't coerce fn pointer to fn and then back again! */ - if (check_typedef (value_type (*argp))->code () != TYPE_CODE_FUNC) + if (check_typedef ((*argp)->type ())->code () != TYPE_CODE_FUNC) *argp = coerce_array (*argp); - t = check_typedef (value_type (*argp)); + t = check_typedef ((*argp)->type ()); } if (t->code () != TYPE_CODE_STRUCT @@ -2641,7 +2641,7 @@ incomplete_type_hint (gdb::array_view args) std::string incomplete_arg_names; for (const struct value *arg : args) { - struct type *t = value_type (arg); + struct type *t = arg->type (); while (t->code () == TYPE_CODE_PTR) t = t->target_type (); if (t->is_stub ()) @@ -2650,7 +2650,7 @@ incomplete_type_hint (gdb::array_view args) if (incomplete_types > 0) incomplete_arg_names += ", "; - current_language->print_type (value_type (arg), "", &buffer, + current_language->print_type (arg->type (), "", &buffer, -1, 0, &type_print_raw_options); incomplete_types++; @@ -2726,7 +2726,7 @@ find_overload_match (gdb::array_view args, const enum noside noside) { struct value *obj = (objp ? *objp : NULL); - struct type *obj_type = obj ? value_type (obj) : NULL; + struct type *obj_type = obj ? obj->type () : NULL; /* Index of best overloaded function. */ int func_oload_champ = -1; int method_oload_champ = -1; @@ -2765,16 +2765,16 @@ find_overload_match (gdb::array_view args, /* OBJ may be a pointer value rather than the object itself. */ obj = coerce_ref (obj); - while (check_typedef (value_type (obj))->code () == TYPE_CODE_PTR) + while (check_typedef (obj->type ())->code () == TYPE_CODE_PTR) obj = coerce_ref (value_ind (obj)); - obj_type_name = value_type (obj)->name (); + obj_type_name = obj->type ()->name (); /* First check whether this is a data member, e.g. a pointer to a function. */ - if (check_typedef (value_type (obj))->code () == TYPE_CODE_STRUCT) + if (check_typedef (obj->type ())->code () == TYPE_CODE_STRUCT) { *valp = search_struct_field (name, obj, - check_typedef (value_type (obj)), 0); + check_typedef (obj->type ()), 0); if (*valp) { *staticp = 1; @@ -3038,7 +3038,7 @@ find_overload_match (gdb::array_view args, if (objp) { - struct type *temp_type = check_typedef (value_type (temp)); + struct type *temp_type = check_typedef (temp->type ()); struct type *objtype = check_typedef (obj_type); if (temp_type->code () != TYPE_CODE_PTR @@ -3158,7 +3158,7 @@ find_oload_champ_namespace_loop (gdb::array_view args, arg_types = (struct type **) alloca (args.size () * (sizeof (struct type *))); for (ix = 0; ix < args.size (); ix++) - arg_types[ix] = value_type (args[ix]); + arg_types[ix] = args[ix]->type (); add_symbol_overload_list_adl ({arg_types, args.size ()}, func_name, &new_oload_syms); } @@ -3614,7 +3614,7 @@ value_struct_elt_for_reference (struct type *domain, int offset, struct type *type, *tmp; ptr = value_aggregate_elt (domain, name, NULL, 1, noside); - type = check_typedef (value_type (ptr)); + type = check_typedef (ptr->type ()); gdb_assert (type != NULL && type->code () == TYPE_CODE_MEMBERPTR); tmp = lookup_pointer_type (TYPE_SELF_TYPE (type)); @@ -3631,7 +3631,7 @@ value_struct_elt_for_reference (struct type *domain, int offset, mem_offset += boff; else { - struct type *p = check_typedef (value_type (this_v)); + struct type *p = check_typedef (this_v->type ()); p = check_typedef (p->target_type ()); if (get_baseclass_offset (p, curtype, this_v, &boff, &isvirt)) @@ -3741,7 +3741,7 @@ value_struct_elt_for_reference (struct type *domain, int offset, { result = allocate_value (lookup_methodptr_type (TYPE_FN_FIELD_TYPE (f, j))); - cplus_make_method_ptr (value_type (result), + cplus_make_method_ptr (result->type (), value_contents_writeable (result).data (), TYPE_FN_FIELD_VOFFSET (f, j), 1); } @@ -3766,7 +3766,7 @@ value_struct_elt_for_reference (struct type *domain, int offset, else { result = allocate_value (lookup_methodptr_type (TYPE_FN_FIELD_TYPE (f, j))); - cplus_make_method_ptr (value_type (result), + cplus_make_method_ptr (result->type (), value_contents_writeable (result).data (), value_address (v), 0); } @@ -3863,7 +3863,7 @@ value_rtti_indirect_type (struct value *v, int *full, struct value *target = NULL; struct type *type, *real_type, *target_type; - type = value_type (v); + type = v->type (); type = check_typedef (type); if (TYPE_IS_REFERENCE (type)) target = coerce_ref (v); @@ -3894,7 +3894,7 @@ value_rtti_indirect_type (struct value *v, int *full, if (real_type) { /* Copy qualifiers to the referenced object. */ - target_type = value_type (target); + target_type = target->type (); real_type = make_cv_type (TYPE_CONST (target_type), TYPE_VOLATILE (target_type), real_type, NULL); if (TYPE_IS_REFERENCE (type)) @@ -3981,7 +3981,7 @@ value_full_object (struct value *argp, value_rtti_type used for its computation. */ new_val = value_at_lazy (real_type, value_address (argp) - top + (using_enc ? 0 : value_embedded_offset (argp))); - deprecated_set_value_type (new_val, value_type (argp)); + deprecated_set_value_type (new_val, argp->type ()); set_value_embedded_offset (new_val, (using_enc ? top + value_embedded_offset (argp) : top)); @@ -4045,7 +4045,7 @@ value_slice (struct value *array, int lowbound, int length) struct value *slice; struct type *array_type; - array_type = check_typedef (value_type (array)); + array_type = check_typedef (array->type ()); if (array_type->code () != TYPE_CODE_ARRAY && array_type->code () != TYPE_CODE_STRING) error (_("cannot take slice of non-array")); @@ -4125,7 +4125,7 @@ value_literal_complex (struct value *arg1, struct value * value_real_part (struct value *value) { - struct type *type = check_typedef (value_type (value)); + struct type *type = check_typedef (value->type ()); struct type *ttype = type->target_type (); gdb_assert (type->code () == TYPE_CODE_COMPLEX); @@ -4137,7 +4137,7 @@ value_real_part (struct value *value) struct value * value_imaginary_part (struct value *value) { - struct type *type = check_typedef (value_type (value)); + struct type *type = check_typedef (value->type ()); struct type *ttype = type->target_type (); gdb_assert (type->code () == TYPE_CODE_COMPLEX); @@ -4152,9 +4152,9 @@ cast_into_complex (struct type *type, struct value *val) { struct type *real_type = type->target_type (); - if (value_type (val)->code () == TYPE_CODE_COMPLEX) + if (val->type ()->code () == TYPE_CODE_COMPLEX) { - struct type *val_real_type = value_type (val)->target_type (); + struct type *val_real_type = val->type ()->target_type (); struct value *re_val = allocate_value (val_real_type); struct value *im_val = allocate_value (val_real_type); int len = val_real_type->length (); @@ -4166,8 +4166,8 @@ cast_into_complex (struct type *type, struct value *val) return value_literal_complex (re_val, im_val, type); } - else if (value_type (val)->code () == TYPE_CODE_FLT - || value_type (val)->code () == TYPE_CODE_INT) + else if (val->type ()->code () == TYPE_CODE_FLT + || val->type ()->code () == TYPE_CODE_INT) return value_literal_complex (val, value_zero (real_type, not_lval), type); diff --git a/gdb/valprint.c b/gdb/valprint.c index 04f83f5194a..3899d915981 100644 --- a/gdb/valprint.c +++ b/gdb/valprint.c @@ -476,7 +476,7 @@ generic_val_print_array (struct value *val, const struct generic_val_print_decorations *decorations) { - struct type *type = check_typedef (value_type (val)); + struct type *type = check_typedef (val->type ()); struct type *unresolved_elttype = type->target_type (); struct type *elttype = check_typedef (unresolved_elttype); @@ -511,7 +511,7 @@ generic_value_print_ptr (struct value *val, struct ui_file *stream, value_print_scalar_formatted (val, options, 0, stream); else { - struct type *type = check_typedef (value_type (val)); + struct type *type = check_typedef (val->type ()); struct type *elttype = check_typedef (type->target_type ()); const gdb_byte *valaddr = value_contents_for_printing (val).data (); CORE_ADDR addr = unpack_pointer (type, valaddr); @@ -770,7 +770,7 @@ generic_value_print_bool else { const gdb_byte *valaddr = value_contents_for_printing (value).data (); - struct type *type = check_typedef (value_type (value)); + struct type *type = check_typedef (value->type ()); LONGEST val = unpack_long (type, valaddr); if (val == 0) gdb_puts (decorations->false_name, stream); @@ -810,7 +810,7 @@ generic_value_print_char (struct value *value, struct ui_file *stream, } else { - struct type *unresolved_type = value_type (value); + struct type *unresolved_type = value->type (); struct type *type = check_typedef (unresolved_type); const gdb_byte *valaddr = value_contents_for_printing (value).data (); @@ -848,7 +848,7 @@ generic_val_print_fixed_point (struct value *val, struct ui_file *stream, value_print_scalar_formatted (val, options, 0, stream); else { - struct type *type = value_type (val); + struct type *type = val->type (); const gdb_byte *valaddr = value_contents_for_printing (val).data (); gdb_mpf f; @@ -895,7 +895,7 @@ generic_value_print_memberptr { /* Member pointers are essentially specific to C++, and so if we encounter one, we should print it according to C++ rules. */ - struct type *type = check_typedef (value_type (val)); + struct type *type = check_typedef (val->type ()); const gdb_byte *valaddr = value_contents_for_printing (val).data (); cp_print_class_member (valaddr, type, stream, "&"); } @@ -910,7 +910,7 @@ generic_value_print (struct value *val, struct ui_file *stream, int recurse, const struct value_print_options *options, const struct generic_val_print_decorations *decorations) { - struct type *type = value_type (val); + struct type *type = val->type (); type = check_typedef (type); @@ -1047,7 +1047,7 @@ common_val_print (struct value *value, struct ui_file *stream, int recurse, value_fetch_lazy (value); struct value_print_options local_opts = *options; - struct type *type = value_type (value); + struct type *type = value->type (); struct type *real_type = check_typedef (type); if (local_opts.prettyformat == Val_prettyformat_default) @@ -1134,7 +1134,7 @@ value_check_printable (struct value *val, struct ui_file *stream, if (value_entirely_optimized_out (val)) { - if (options->summary && !val_print_scalar_type_p (value_type (val))) + if (options->summary && !val_print_scalar_type_p (val->type ())) gdb_printf (stream, "..."); else val_print_optimized_out (val, stream); @@ -1143,14 +1143,14 @@ value_check_printable (struct value *val, struct ui_file *stream, if (value_entirely_unavailable (val)) { - if (options->summary && !val_print_scalar_type_p (value_type (val))) + if (options->summary && !val_print_scalar_type_p (val->type ())) gdb_printf (stream, "..."); else val_print_unavailable (stream); return 0; } - if (value_type (val)->code () == TYPE_CODE_INTERNAL_FUNCTION) + if (val->type ()->code () == TYPE_CODE_INTERNAL_FUNCTION) { fprintf_styled (stream, metadata_style.style (), _(""), @@ -1158,13 +1158,13 @@ value_check_printable (struct value *val, struct ui_file *stream, return 0; } - if (type_not_associated (value_type (val))) + if (type_not_associated (val->type ())) { val_print_not_associated (stream); return 0; } - if (type_not_allocated (value_type (val))) + if (type_not_allocated (val->type ())) { val_print_not_allocated (stream); return 0; @@ -1282,7 +1282,7 @@ value_print_scalar_formatted (struct value *val, int size, struct ui_file *stream) { - struct type *type = check_typedef (value_type (val)); + struct type *type = check_typedef (val->type ()); gdb_assert (val != NULL); @@ -1955,7 +1955,7 @@ value_print_array_elements (struct value *val, struct ui_file *stream, unsigned int reps; LONGEST low_bound, high_bound; - struct type *type = check_typedef (value_type (val)); + struct type *type = check_typedef (val->type ()); elttype = type->target_type (); unsigned bit_stride = type->bit_stride (); diff --git a/gdb/value.c b/gdb/value.c index 7ba46e20e7b..e2e641386a3 100644 --- a/gdb/value.c +++ b/gdb/value.c @@ -165,7 +165,7 @@ value::~value () struct gdbarch * get_value_arch (const struct value *value) { - return value_type (value)->arch (); + return value->type ()->arch (); } int @@ -894,11 +894,6 @@ allocate_optimized_out_value (struct type *type) /* Accessor methods. */ -struct type * -value_type (const struct value *value) -{ - return value->m_type; -} void deprecated_set_value_type (struct value *value, struct type *type) { @@ -960,7 +955,7 @@ value_contents_raw (struct value *value) allocate_value_contents (value); - ULONGEST length = value_type (value)->length (); + ULONGEST length = value->type ()->length (); return gdb::make_array_view (value->m_contents.get () + value->m_embedded_offset * unit_size, length); } @@ -993,7 +988,7 @@ value_actual_type (struct value *value, int resolve_simple_types, if (real_type_found) *real_type_found = 0; - result = value_type (value); + result = value->type (); if (opts.objectprint) { /* If result's target type is TYPE_CODE_STRUCT, proceed to @@ -1197,7 +1192,7 @@ value_contents_copy_raw_bitwise (struct value *dst, LONGEST dst_bit_offset, copy_bitwise (dst_contents.data (), dst_bit_offset, src_contents.data (), src_bit_offset, bit_length, - type_byte_order (value_type (src)) == BFD_ENDIAN_BIG); + type_byte_order (src->type ()) == BFD_ENDIAN_BIG); /* Copy the meta-data. */ value_ranges_copy_adjusted (dst, dst_bit_offset, @@ -1399,10 +1394,10 @@ value_address (const struct value *value) return 0; if (value->m_parent != NULL) return value_address (value->m_parent.get ()) + value->m_offset; - if (NULL != TYPE_DATA_LOCATION (value_type (value))) + if (NULL != TYPE_DATA_LOCATION (value->type ())) { - gdb_assert (PROP_CONST == TYPE_DATA_LOCATION_KIND (value_type (value))); - return TYPE_DATA_LOCATION_ADDR (value_type (value)); + gdb_assert (PROP_CONST == TYPE_DATA_LOCATION_KIND (value->type ())); + return TYPE_DATA_LOCATION_ADDR (value->type ()); } return value->m_location.address + value->m_offset; @@ -1600,7 +1595,7 @@ value_copy (const value *arg) struct value * make_cv_value (int cnst, int voltl, struct value *v) { - struct type *val_type = value_type (v); + struct type *val_type = v->type (); struct type *m_enclosing_type = value_enclosing_type (v); struct value *cv_val = value_copy (v); @@ -1638,7 +1633,7 @@ value_force_lval (struct value *v, CORE_ADDR addr) { gdb_assert (VALUE_LVAL (v) == not_lval); - write_memory (addr, value_contents_raw (v).data (), value_type (v)->length ()); + write_memory (addr, value_contents_raw (v).data (), v->type ()->length ()); v->m_lval = lval_memory; v->m_location.address = addr; } @@ -1667,14 +1662,14 @@ set_value_component_location (struct value *component, /* If the WHOLE value has a dynamically resolved location property then update the address of the COMPONENT. */ - type = value_type (whole); + type = whole->type (); if (NULL != TYPE_DATA_LOCATION (type) && TYPE_DATA_LOCATION_KIND (type) == PROP_CONST) set_value_address (component, TYPE_DATA_LOCATION_ADDR (type)); /* Similarly, if the COMPONENT value has a dynamically resolved location property then update its address. */ - type = value_type (component); + type = component->type (); if (NULL != TYPE_DATA_LOCATION (type) && TYPE_DATA_LOCATION_KIND (type) == PROP_CONST) { @@ -2132,7 +2127,7 @@ get_internalvar_integer (struct internalvar *var, LONGEST *result) if (var->kind == INTERNALVAR_VALUE) { - struct type *type = check_typedef (value_type (var->u.value)); + struct type *type = check_typedef (var->u.value->type ()); if (type->code () == TYPE_CODE_INT) { @@ -2176,11 +2171,11 @@ set_internalvar_component (struct internalvar *var, unit_size = gdbarch_addressable_memory_unit_size (arch); if (bitsize) - modify_field (value_type (var->u.value), addr + offset, + modify_field (var->u.value->type (), addr + offset, value_as_long (newval), bitpos, bitsize); else memcpy (addr + offset * unit_size, value_contents (newval).data (), - value_type (newval)->length ()); + newval->type ()->length ()); break; default: @@ -2199,7 +2194,7 @@ set_internalvar (struct internalvar *var, struct value *val) error (_("Cannot overwrite convenience function %s"), var->name); /* Prepare new contents. */ - switch (check_typedef (value_type (val))->code ()) + switch (check_typedef (val->type ())->code ()) { case TYPE_CODE_VOID: new_kind = INTERNALVAR_VOID; @@ -2236,7 +2231,7 @@ set_internalvar (struct internalvar *var, struct value *val) when accessing the value. If we keep it, we would still refer to the origin value. Remove the location property in case it exist. */ - value_type (new_data.value)->remove_dyn_prop (DYN_PROP_DATA_LOCATION); + new_data.value->type ()->remove_dyn_prop (DYN_PROP_DATA_LOCATION); break; } @@ -2554,7 +2549,7 @@ value_from_xmethod (xmethod_worker_up &&worker) struct type * result_type_of_xmethod (struct value *method, gdb::array_view argv) { - gdb_assert (value_type (method)->code () == TYPE_CODE_XMETHOD + gdb_assert (method->type ()->code () == TYPE_CODE_XMETHOD && method->m_lval == lval_xcallable && !argv.empty ()); return method->m_location.xm_worker->get_result_type (argv[0], argv.slice (1)); @@ -2565,7 +2560,7 @@ result_type_of_xmethod (struct value *method, gdb::array_view argv) struct value * call_xmethod (struct value *method, gdb::array_view argv) { - gdb_assert (value_type (method)->code () == TYPE_CODE_XMETHOD + gdb_assert (method->type ()->code () == TYPE_CODE_XMETHOD && method->m_lval == lval_xcallable && !argv.empty ()); return method->m_location.xm_worker->invoke (argv[0], argv.slice (1)); @@ -2583,7 +2578,7 @@ value_as_long (struct value *val) in disassemble_command). It also dereferences references, which I suspect is the most logical thing to do. */ val = coerce_array (val); - return unpack_long (value_type (val), value_contents (val).data ()); + return unpack_long (val->type (), value_contents (val).data ()); } /* Extract a value as a C pointer. Does not deallocate the value. @@ -2592,7 +2587,7 @@ value_as_long (struct value *val) CORE_ADDR value_as_address (struct value *val) { - struct gdbarch *gdbarch = value_type (val)->arch (); + struct gdbarch *gdbarch = val->type ()->arch (); /* Assume a CORE_ADDR can fit in a LONGEST (for now). Not sure whether we want this to be true eventually. */ @@ -2621,7 +2616,7 @@ value_as_address (struct value *val) cannot be modified. Upon entry to this function, if VAL is a value of type `function' - (that is, TYPE_CODE (VALUE_TYPE (val)) == TYPE_CODE_FUNC), then + (that is, TYPE_CODE (val->type ()) == TYPE_CODE_FUNC), then value_address (val) is the address of the function. This is what you'll get if you evaluate an expression like `main'. The call to COERCE_ARRAY below actually does all the usual unary @@ -2640,8 +2635,8 @@ value_as_address (struct value *val) The following shortcut avoids this whole mess. If VAL is a function, just return its address directly. */ - if (value_type (val)->code () == TYPE_CODE_FUNC - || value_type (val)->code () == TYPE_CODE_METHOD) + if (val->type ()->code () == TYPE_CODE_FUNC + || val->type ()->code () == TYPE_CODE_METHOD) return value_address (val); val = coerce_array (val); @@ -2683,12 +2678,12 @@ value_as_address (struct value *val) converted to pointers; usually, the ABI doesn't either, but ABI-specific code is a more reasonable place to handle it. */ - if (!value_type (val)->is_pointer_or_reference () + if (!val->type ()->is_pointer_or_reference () && gdbarch_integer_to_address_p (gdbarch)) - return gdbarch_integer_to_address (gdbarch, value_type (val), + return gdbarch_integer_to_address (gdbarch, val->type (), value_contents (val).data ()); - return unpack_long (value_type (val), value_contents (val).data ()); + return unpack_long (val->type (), value_contents (val).data ()); #endif } @@ -2808,7 +2803,7 @@ unpack_pointer (struct type *type, const gdb_byte *valaddr) bool is_floating_value (struct value *val) { - struct type *type = check_typedef (value_type (val)); + struct type *type = check_typedef (val->type ()); if (is_floating_type (type)) { @@ -3017,7 +3012,7 @@ value_primitive_field (struct value *arg1, LONGEST offset, struct value * value_field (struct value *arg1, int fieldno) { - return value_primitive_field (arg1, 0, fieldno, value_type (arg1)); + return value_primitive_field (arg1, 0, fieldno, arg1->type ()); } /* Return a non-virtual function as a value. @@ -3067,7 +3062,7 @@ value_fn_field (struct value **arg1p, struct fn_field *f, if (arg1p) { - if (type != value_type (*arg1p)) + if (type != (*arg1p)->type ()) *arg1p = value_ind (value_cast (lookup_pointer_type (type), value_addr (*arg1p))); @@ -3193,7 +3188,7 @@ unpack_value_bitfield (struct value *dest_val, enum bfd_endian byte_order; int src_bit_offset; int dst_bit_offset; - struct type *field_type = value_type (dest_val); + struct type *field_type = dest_val->type (); byte_order = type_byte_order (field_type); @@ -3456,7 +3451,7 @@ value_from_host_double (struct type *type, double d) struct value *value = allocate_value (type); gdb_assert (type->code () == TYPE_CODE_FLT); target_float_from_host_double (value_contents_raw (value).data (), - value_type (value), d); + value->type (), d); return value; } @@ -3647,7 +3642,7 @@ coerce_ref_if_computed (const struct value *arg) { const struct lval_funcs *funcs; - if (!TYPE_IS_REFERENCE (check_typedef (value_type (arg)))) + if (!TYPE_IS_REFERENCE (check_typedef (arg->type ()))) return NULL; if (value_lval_const (arg) != lval_computed) @@ -3690,7 +3685,7 @@ readjust_indirect_value_type (struct value *value, struct type *enc_type, struct value * coerce_ref (struct value *arg) { - struct type *value_type_arg_tmp = check_typedef (value_type (arg)); + struct type *value_type_arg_tmp = check_typedef (arg->type ()); struct value *retval; struct type *enc_type; @@ -3704,9 +3699,9 @@ coerce_ref (struct value *arg) enc_type = check_typedef (value_enclosing_type (arg)); enc_type = enc_type->target_type (); - CORE_ADDR addr = unpack_pointer (value_type (arg), value_contents (arg).data ()); + CORE_ADDR addr = unpack_pointer (arg->type (), value_contents (arg).data ()); retval = value_at_lazy (enc_type, addr); - enc_type = value_type (retval); + enc_type = retval->type (); return readjust_indirect_value_type (retval, enc_type, value_type_arg_tmp, arg, addr); } @@ -3717,7 +3712,7 @@ coerce_array (struct value *arg) struct type *type; arg = coerce_ref (arg); - type = check_typedef (value_type (arg)); + type = check_typedef (arg->type ()); switch (type->code ()) { @@ -3828,7 +3823,7 @@ value_fetch_lazy_register (struct value *val) { frame_info_ptr next_frame; int regnum; - struct type *type = check_typedef (value_type (val)); + struct type *type = check_typedef (val->type ()); struct value *new_val = val, *mark = value_mark (); /* Offsets are not supported here; lazy register values must @@ -3988,7 +3983,7 @@ isvoid_internal_fn (struct gdbarch *gdbarch, if (argc != 1) error (_("You must provide one argument for $_isvoid.")); - ret = value_type (argv[0])->code () == TYPE_CODE_VOID; + ret = argv[0]->type ()->code () == TYPE_CODE_VOID; return value_from_longest (builtin_type (gdbarch)->builtin_int, ret); } @@ -4005,7 +4000,7 @@ creal_internal_fn (struct gdbarch *gdbarch, error (_("You must provide one argument for $_creal.")); value *cval = argv[0]; - type *ctype = check_typedef (value_type (cval)); + type *ctype = check_typedef (cval->type ()); if (ctype->code () != TYPE_CODE_COMPLEX) error (_("expected a complex number")); return value_real_part (cval); @@ -4024,7 +4019,7 @@ cimag_internal_fn (struct gdbarch *gdbarch, error (_("You must provide one argument for $_cimag.")); value *cval = argv[0]; - type *ctype = check_typedef (value_type (cval)); + type *ctype = check_typedef (cval->type ()); if (ctype->code () != TYPE_CODE_COMPLEX) error (_("expected a complex number")); return value_imaginary_part (cval); diff --git a/gdb/value.h b/gdb/value.h index ea549a8cb81..f4a488c9263 100644 --- a/gdb/value.h +++ b/gdb/value.h @@ -159,6 +159,11 @@ struct value DISABLE_COPY_AND_ASSIGN (value); + /* Type of the value. */ + struct type *type () const + { return m_type; } + + /* Type of value; either not an lval, or one of the various different possible kinds of lval. */ enum lval_type m_lval = not_lval; @@ -325,10 +330,6 @@ struct value std::vector m_optimized_out; }; -/* Type of the value. */ - -extern struct type *value_type (const struct value *); - /* Return the gdbarch associated with the value. */ extern struct gdbarch *get_value_arch (const struct value *value); diff --git a/gdb/varobj.c b/gdb/varobj.c index eb47ecada3e..fb846fd65c7 100644 --- a/gdb/varobj.c +++ b/gdb/varobj.c @@ -377,7 +377,7 @@ varobj_create (const char *objname, right type. */ struct value *type_only_value = evaluate_type (var->root->exp.get ()); - var->type = value_type (type_only_value); + var->type = type_only_value->type (); } if (value != NULL) @@ -1370,7 +1370,7 @@ install_new_value (struct varobj *var, struct value *value, bool initial) } var->print_value = print_value; - gdb_assert (var->value == nullptr || value_type (var->value.get ())); + gdb_assert (var->value == nullptr || var->value.get ()->type ()); return changed; } @@ -1550,7 +1550,7 @@ varobj_update (struct varobj **varp, bool is_explicit) if (update_type_if_necessary (v, newobj)) r.type_changed = true; if (newobj) - new_type = value_type (newobj); + new_type = newobj->type (); else new_type = v->root->lang_ops->type_of_child (v->parent, v->index); @@ -1886,7 +1886,7 @@ varobj_get_value_type (const struct varobj *var) struct type *type; if (var->value != nullptr) - type = value_type (var->value.get ()); + type = var->value.get ()->type (); else type = var->type; @@ -2098,7 +2098,7 @@ value_of_root (struct varobj **var_handle, bool *type_changed) /* For root varobj-s, a NULL value indicates a scoping issue. So, nothing to do in terms of checking for mutations. */ } - else if (varobj_value_has_mutated (var, value, value_type (value))) + else if (varobj_value_has_mutated (var, value, value->type ())) { /* The type has mutated, so the children are no longer valid. Just delete them, and tell our caller that the type has @@ -2229,7 +2229,7 @@ varobj_value_get_print_value (struct value *value, thevalue = std::string (s.get ()); len = thevalue.size (); - gdbarch = value_type (value)->arch (); + gdbarch = value->type ()->arch (); type = builtin_type (gdbarch)->builtin_char; if (!string_print) diff --git a/gdb/windows-tdep.c b/gdb/windows-tdep.c index 00c700422a1..af21aa159f4 100644 --- a/gdb/windows-tdep.c +++ b/gdb/windows-tdep.c @@ -400,7 +400,7 @@ static void tlb_value_read (struct value *val) { CORE_ADDR tlb; - struct type *type = check_typedef (value_type (val)); + struct type *type = check_typedef (val->type ()); if (!target_get_tib_address (inferior_ptid, &tlb)) error (_("Unable to read tlb")); diff --git a/gdb/xtensa-tdep.c b/gdb/xtensa-tdep.c index 8476fecf3a7..c3d175adff6 100644 --- a/gdb/xtensa-tdep.c +++ b/gdb/xtensa-tdep.c @@ -1712,7 +1712,7 @@ xtensa_push_dummy_call (struct gdbarch *gdbarch, for (int i = 0; i < nargs; i++) { struct value *arg = args[i]; - struct type *arg_type = check_typedef (value_type (arg)); + struct type *arg_type = check_typedef (arg->type ()); gdb_printf (gdb_stdlog, "%2d: %s %3s ", i, host_address_to_string (arg), pulongest (arg_type->length ())); @@ -1748,7 +1748,7 @@ xtensa_push_dummy_call (struct gdbarch *gdbarch, { struct argument_info *info = &arg_info[i]; struct value *arg = args[i]; - struct type *arg_type = check_typedef (value_type (arg)); + struct type *arg_type = check_typedef (arg->type ()); switch (arg_type->code ()) { From patchwork Thu Feb 9 21:38:26 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tom Tromey X-Patchwork-Id: 64558 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 F01733882FC6 for ; Thu, 9 Feb 2023 21:39:23 +0000 (GMT) X-Original-To: gdb-patches@sourceware.org Delivered-To: gdb-patches@sourceware.org Received: from gproxy2-pub.mail.unifiedlayer.com (gproxy2-pub.mail.unifiedlayer.com [69.89.18.3]) by sourceware.org (Postfix) with ESMTPS id 7D818385840C for ; Thu, 9 Feb 2023 21:38:41 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 7D818385840C 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 cmgw14.mail.unifiedlayer.com (unknown [10.0.90.129]) by progateway4.mail.pro1.eigbox.com (Postfix) with ESMTP id D4CBD10047E1A for ; Thu, 9 Feb 2023 21:38:40 +0000 (UTC) Received: from box5379.bluehost.com ([162.241.216.53]) by cmsmtp with ESMTP id QEcqpLOqDGAj8QEcqphq2m; Thu, 09 Feb 2023 21:38:40 +0000 X-Authority-Reason: nr=8 X-Authority-Analysis: v=2.4 cv=UdyU9IeN c=1 sm=1 tr=0 ts=63e567e0 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=DAtK919lk117L9zkXUQA: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=Gz3onojrYctupTxch/h3VQ6scj0RJd6tp1bDNUGX9D8=; b=RFSj5cSsarFVGFEip92O4wWjXG 6+mPrfY//WFemg8MGTNKS1fxV4Q5cMXagF3twi28ks+oidnIQyGUWVf8jE5kc2DWTicTW5Mg+AxrQ eorBkt0iIkttzT5YE1mDkZAap; 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 1pQEcq-001ZcE-BK for gdb-patches@sourceware.org; Thu, 09 Feb 2023 14:38:40 -0700 From: Tom Tromey Date: Thu, 09 Feb 2023 14:38:26 -0700 Subject: [PATCH 05/47] Turn deprecated_set_value_type into a method MIME-Version: 1.0 Message-Id: <20230209-submit-value-fixups-2023-v1-5-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: 1pQEcq-001ZcE-BK 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: 6 X-Source-Cap: ZWx5bnJvYmk7ZWx5bnJvYmk7Ym94NTM3OS5ibHVlaG9zdC5jb20= X-Local-Domain: yes X-Spam-Status: No, score=-3025.3 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, GIT_PATCH_0, JMQ_SPF_NEUTRAL, RCVD_IN_BL_SPAMCOP_NET, 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 deprecated_set_value_type to be a method of value. Much of this patch was written by script. --- gdb/ada-lang.c | 6 +++--- gdb/ada-valprint.c | 2 +- gdb/eval.c | 2 +- gdb/gnu-v2-abi.c | 3 +-- gdb/i386-tdep.c | 2 +- gdb/objc-lang.c | 2 +- gdb/valops.c | 19 +++++++++---------- gdb/value.c | 11 ++--------- gdb/value.h | 13 ++++++------- 9 files changed, 25 insertions(+), 35 deletions(-) diff --git a/gdb/ada-lang.c b/gdb/ada-lang.c index da49149c56d..c5b5b14163b 100644 --- a/gdb/ada-lang.c +++ b/gdb/ada-lang.c @@ -2924,7 +2924,7 @@ ada_value_assign (struct value *toval, struct value *fromval) memcpy (value_contents_raw (val).data (), value_contents (fromval).data (), type->length ()); - deprecated_set_value_type (val, type); + val->deprecated_set_type (type); return val; } @@ -3033,7 +3033,7 @@ ada_value_subscript (struct value *arr, int arity, struct value **ind) than as an access. Another symptom of the same issue would be that an expression trying to dereference the element would also be improperly rejected. */ - deprecated_set_value_type (elt, saved_elt_type); + elt->deprecated_set_type (saved_elt_type); } elt_type = ada_check_typedef (elt->type ()); @@ -9334,7 +9334,7 @@ coerce_for_assign (struct type *type, struct value *val) if (type2->target_type ()->length () != type->target_type ()->length ()) error (_("Incompatible types in assignment")); - deprecated_set_value_type (val, type); + val->deprecated_set_type (type); } return val; } diff --git a/gdb/ada-valprint.c b/gdb/ada-valprint.c index 1f22ab61ce2..761d3150937 100644 --- a/gdb/ada-valprint.c +++ b/gdb/ada-valprint.c @@ -1029,7 +1029,7 @@ ada_value_print_inner (struct value *val, struct ui_file *stream, int recurse, if (type != saved_type) { val = value_copy (val); - deprecated_set_value_type (val, type); + val->deprecated_set_type (type); } if (is_fixed_point_type (type)) diff --git a/gdb/eval.c b/gdb/eval.c index c24ff258b43..6fa359966ec 100644 --- a/gdb/eval.c +++ b/gdb/eval.c @@ -2183,7 +2183,7 @@ eval_op_objc_msgcall (struct type *expect_type, struct expression *exp, /* Function objc_msg_lookup returns a pointer. */ struct type *tem_type = called_method->type (); tem_type = lookup_pointer_type (lookup_function_type (tem_type)); - deprecated_set_value_type (called_method, tem_type); + called_method->deprecated_set_type (tem_type); called_method = call_function_by_hand (called_method, NULL, args); } diff --git a/gdb/gnu-v2-abi.c b/gdb/gnu-v2-abi.c index c28df183c8b..b27649051a4 100644 --- a/gdb/gnu-v2-abi.c +++ b/gdb/gnu-v2-abi.c @@ -174,8 +174,7 @@ gnuv2_virtual_fn_field (struct value **arg1p, struct fn_field * f, int j, else error (_("I'm confused: virtual function table has bad type")); /* Reinstantiate the function pointer with the correct type. */ - deprecated_set_value_type (vfn, - lookup_pointer_type (TYPE_FN_FIELD_TYPE (f, j))); + vfn->deprecated_set_type (lookup_pointer_type (TYPE_FN_FIELD_TYPE (f, j))); *arg1p = arg1; return vfn; diff --git a/gdb/i386-tdep.c b/gdb/i386-tdep.c index f8907f5c4f4..f82641debee 100644 --- a/gdb/i386-tdep.c +++ b/gdb/i386-tdep.c @@ -3087,7 +3087,7 @@ i386_return_value (struct gdbarch *gdbarch, struct value *function, = i386_return_value (gdbarch, function, inner_type, regcache, read_value, writebuf); if (read_value != nullptr) - deprecated_set_value_type (*read_value, type); + (*read_value)->deprecated_set_type (type); return result; } diff --git a/gdb/objc-lang.c b/gdb/objc-lang.c index e17a4c406c0..f43d158a770 100644 --- a/gdb/objc-lang.c +++ b/gdb/objc-lang.c @@ -212,7 +212,7 @@ value_nsstring (struct gdbarch *gdbarch, const char *ptr, int len) else type = lookup_pointer_type(sym->type ()); - deprecated_set_value_type (nsstringValue, type); + nsstringValue->deprecated_set_type (type); return nsstringValue; } diff --git a/gdb/valops.c b/gdb/valops.c index a56afce0235..1cac2496183 100644 --- a/gdb/valops.c +++ b/gdb/valops.c @@ -319,14 +319,14 @@ value_cast_pointers (struct type *type, struct value *arg2, { struct value *v = value_addr (v2); - deprecated_set_value_type (v, type); + v->deprecated_set_type (type); return v; } } /* No superclass found, just change the pointer type. */ arg2 = value_copy (arg2); - deprecated_set_value_type (arg2, type); + arg2->deprecated_set_type (type); set_value_enclosing_type (arg2, type); set_value_pointed_to_offset (arg2, 0); /* pai: chk_val */ return arg2; @@ -429,7 +429,7 @@ value_cast (struct type *type, struct value *arg2) if (arg2->type () != type) { arg2 = value_copy (arg2); - deprecated_set_value_type (arg2, type); + arg2->deprecated_set_type (type); } return arg2; } @@ -494,8 +494,7 @@ value_cast (struct type *type, struct value *arg2) range_type->target_type (), low_bound, new_length + low_bound - 1); - deprecated_set_value_type (arg2, - create_array_type (NULL, + arg2->deprecated_set_type (create_array_type (NULL, element_type, range_type)); return arg2; @@ -649,7 +648,7 @@ value_cast (struct type *type, struct value *arg2) return value_cast_pointers (to_type, arg2, 0); arg2 = value_copy (arg2); - deprecated_set_value_type (arg2, to_type); + arg2->deprecated_set_type (to_type); set_value_enclosing_type (arg2, to_type); set_value_pointed_to_offset (arg2, 0); /* pai: chk_val */ return arg2; @@ -1574,7 +1573,7 @@ value_addr (struct value *arg1) = lookup_pointer_type (enclosing_type->target_type ()); arg2 = value_copy (arg1); - deprecated_set_value_type (arg2, type_ptr); + arg2->deprecated_set_type (type_ptr); set_value_enclosing_type (arg2, enclosing_type_ptr); return arg2; @@ -1622,7 +1621,7 @@ value_ref (struct value *arg1, enum type_code refcode) return arg1; arg2 = value_addr (arg1); - deprecated_set_value_type (arg2, lookup_reference_type (type, refcode)); + arg2->deprecated_set_type (lookup_reference_type (type, refcode)); return arg2; } @@ -2110,7 +2109,7 @@ struct_field_searcher::search (struct value *arg1, LONGEST offset, else { v2 = value_copy (arg1); - deprecated_set_value_type (v2, basetype); + v2->deprecated_set_type (basetype); set_value_embedded_offset (v2, boffset); } @@ -3981,7 +3980,7 @@ value_full_object (struct value *argp, value_rtti_type used for its computation. */ new_val = value_at_lazy (real_type, value_address (argp) - top + (using_enc ? 0 : value_embedded_offset (argp))); - deprecated_set_value_type (new_val, argp->type ()); + new_val->deprecated_set_type (argp->type ()); set_value_embedded_offset (new_val, (using_enc ? top + value_embedded_offset (argp) : top)); diff --git a/gdb/value.c b/gdb/value.c index e2e641386a3..bde8f3da4d2 100644 --- a/gdb/value.c +++ b/gdb/value.c @@ -894,12 +894,6 @@ allocate_optimized_out_value (struct type *type) /* Accessor methods. */ -void -deprecated_set_value_type (struct value *value, struct type *type) -{ - value->m_type = type; -} - LONGEST value_offset (const struct value *value) { @@ -1599,8 +1593,7 @@ make_cv_value (int cnst, int voltl, struct value *v) struct type *m_enclosing_type = value_enclosing_type (v); struct value *cv_val = value_copy (v); - deprecated_set_value_type (cv_val, - make_cv_type (cnst, voltl, val_type, NULL)); + cv_val->deprecated_set_type (make_cv_type (cnst, voltl, val_type, NULL)); set_value_enclosing_type (cv_val, make_cv_type (cnst, voltl, m_enclosing_type, NULL)); @@ -3672,7 +3665,7 @@ readjust_indirect_value_type (struct value *value, struct type *enc_type, original_value_address); /* Re-adjust type. */ - deprecated_set_value_type (value, resolved_original_target_type); + value->deprecated_set_type (resolved_original_target_type); /* Add embedding info. */ set_value_enclosing_type (value, enc_type); diff --git a/gdb/value.h b/gdb/value.h index f4a488c9263..cb92b872bc6 100644 --- a/gdb/value.h +++ b/gdb/value.h @@ -163,6 +163,12 @@ struct value struct type *type () const { return m_type; } + /* This is being used to change the type of an existing value, that + code should instead be creating a new value with the changed type + (but possibly shared content). */ + void deprecated_set_type (struct type *type) + { m_type = type; } + /* Type of value; either not an lval, or one of the various different possible kinds of lval. */ @@ -334,13 +340,6 @@ struct value extern struct gdbarch *get_value_arch (const struct value *value); -/* This is being used to change the type of an existing value, that - code should instead be creating a new value with the changed type - (but possibly shared content). */ - -extern void deprecated_set_value_type (struct value *value, - struct type *type); - /* Only used for bitfields; number of bits contained in them. */ extern LONGEST value_bitsize (const struct value *); From patchwork Thu Feb 9 21:38:27 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tom Tromey X-Patchwork-Id: 64556 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 428513881D15 for ; Thu, 9 Feb 2023 21:38:59 +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 6377D3858C74 for ; Thu, 9 Feb 2023 21:38:41 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 6377D3858C74 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 cmgw11.mail.unifiedlayer.com (unknown [10.0.90.126]) by progateway1.mail.pro1.eigbox.com (Postfix) with ESMTP id AEC7310040616 for ; Thu, 9 Feb 2023 21:38:40 +0000 (UTC) Received: from box5379.bluehost.com ([162.241.216.53]) by cmsmtp with ESMTP id QEcqphyBW2s14QEcqphhlb; Thu, 09 Feb 2023 21:38:40 +0000 X-Authority-Reason: nr=8 X-Authority-Analysis: v=2.4 cv=R7DGpfdX c=1 sm=1 tr=0 ts=63e567e0 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=Th0pbswXEgJDPzUh0wYA: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=7SsVdZEt5uXdXgRSA7/VbHkFh1O/LYcV58tnJb/i5Q0=; b=qJkW+9RDYg4TZZehYvphIbcsXI FaWQcGlVKBIItD6iFB9v/CJspBjvk9z0pbrvPXs7kAdcOaCygy9T4A4H+Pfrvz9aLNPyLk7rOcN63 k/21zRanPIu3HSLqM09Uv36IW; 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 1pQEcq-001ZcE-F5 for gdb-patches@sourceware.org; Thu, 09 Feb 2023 14:38:40 -0700 From: Tom Tromey Date: Thu, 09 Feb 2023 14:38:27 -0700 Subject: [PATCH 06/47] Turn value_arch into method MIME-Version: 1.0 Message-Id: <20230209-submit-value-fixups-2023-v1-6-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: 1pQEcq-001ZcE-F5 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: 7 X-Source-Cap: ZWx5bnJvYmk7ZWx5bnJvYmk7Ym94NTM3OS5ibHVlaG9zdC5jb20= X-Local-Domain: yes X-Spam-Status: No, score=-3027.3 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_arch to be a method of value. Much of this patch was written by script. --- gdb/valops.c | 2 +- gdb/value.c | 12 ++++++------ gdb/value.h | 7 +++---- 3 files changed, 10 insertions(+), 11 deletions(-) diff --git a/gdb/valops.c b/gdb/valops.c index 1cac2496183..2d1db3cef83 100644 --- a/gdb/valops.c +++ b/gdb/valops.c @@ -1045,7 +1045,7 @@ read_value_memory (struct value *val, LONGEST bit_offset, gdb_byte *buffer, size_t length) { ULONGEST xfered_total = 0; - struct gdbarch *arch = get_value_arch (val); + struct gdbarch *arch = val->get_arch (); int unit_size = gdbarch_addressable_memory_unit_size (arch); enum target_object object; diff --git a/gdb/value.c b/gdb/value.c index bde8f3da4d2..96db14c99cc 100644 --- a/gdb/value.c +++ b/gdb/value.c @@ -163,9 +163,9 @@ value::~value () /* See value.h. */ struct gdbarch * -get_value_arch (const struct value *value) +value::get_arch () const { - return value->type ()->arch (); + return type ()->arch (); } int @@ -944,7 +944,7 @@ set_value_parent (struct value *value, struct value *parent) gdb::array_view value_contents_raw (struct value *value) { - struct gdbarch *arch = get_value_arch (value); + struct gdbarch *arch = value->get_arch (); int unit_size = gdbarch_addressable_memory_unit_size (arch); allocate_value_contents (value); @@ -1121,7 +1121,7 @@ value_contents_copy_raw (struct value *dst, LONGEST dst_offset, struct value *src, LONGEST src_offset, LONGEST length) { LONGEST src_bit_offset, dst_bit_offset, bit_length; - struct gdbarch *arch = get_value_arch (src); + struct gdbarch *arch = src->get_arch (); int unit_size = gdbarch_addressable_memory_unit_size (arch); /* A lazy DST would make that this copy operation useless, since as @@ -2160,7 +2160,7 @@ set_internalvar_component (struct internalvar *var, { case INTERNALVAR_VALUE: addr = value_contents_writeable (var->u.value).data (); - arch = get_value_arch (var->u.value); + arch = var->u.value->get_arch (); unit_size = gdbarch_addressable_memory_unit_size (arch); if (bitsize) @@ -2884,7 +2884,7 @@ value_primitive_field (struct value *arg1, LONGEST offset, { struct value *v; struct type *type; - struct gdbarch *arch = get_value_arch (arg1); + struct gdbarch *arch = arg1->get_arch (); int unit_size = gdbarch_addressable_memory_unit_size (arch); arg_type = check_typedef (arg_type); diff --git a/gdb/value.h b/gdb/value.h index cb92b872bc6..31ec0b5c202 100644 --- a/gdb/value.h +++ b/gdb/value.h @@ -169,6 +169,9 @@ struct value void deprecated_set_type (struct type *type) { m_type = type; } + /* Return the gdbarch associated with the value. */ + struct gdbarch *get_arch () const; + /* Type of value; either not an lval, or one of the various different possible kinds of lval. */ @@ -336,10 +339,6 @@ struct value std::vector m_optimized_out; }; -/* Return the gdbarch associated with the value. */ - -extern struct gdbarch *get_value_arch (const struct value *value); - /* Only used for bitfields; number of bits contained in them. */ extern LONGEST value_bitsize (const struct value *); From patchwork Thu Feb 9 21:38:28 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tom Tromey X-Patchwork-Id: 64557 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 3BFD0385B50F for ; Thu, 9 Feb 2023 21:39:07 +0000 (GMT) X-Original-To: gdb-patches@sourceware.org Delivered-To: gdb-patches@sourceware.org Received: from gproxy3-pub.mail.unifiedlayer.com (gproxy3-pub.mail.unifiedlayer.com [69.89.30.42]) by sourceware.org (Postfix) with ESMTPS id 6649E3858C2D for ; Thu, 9 Feb 2023 21:38:41 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 6649E3858C2D 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 cmgw13.mail.unifiedlayer.com (unknown [10.0.90.128]) by progateway5.mail.pro1.eigbox.com (Postfix) with ESMTP id CBD461007383F for ; Thu, 9 Feb 2023 21:38:40 +0000 (UTC) Received: from box5379.bluehost.com ([162.241.216.53]) by cmsmtp with ESMTP id QEcqpHubyNX2aQEcqp2uBL; Thu, 09 Feb 2023 21:38:40 +0000 X-Authority-Reason: nr=8 X-Authority-Analysis: v=2.4 cv=NMAQR22g c=1 sm=1 tr=0 ts=63e567e0 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=mBjqKxRsrgyj_eBguyMA: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=5IVdbdU7WopjN4LXaBaj1XcZn7nxqjjQ7HPvC9RRv6A=; b=Ak57gAk0bn4y0LsyBkzg7LwTR1 MaQ99K9G5Tuw/iyz3SC7fSJ4jorFeiJA2Y2Xt64ciqSEqNmmz4f0sHpRy9p2kZ6mnHYdknHDzqeG7 /EY9NtMFUAi2tH0zM7SVl2lIe; 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 1pQEcq-001ZcE-KO for gdb-patches@sourceware.org; Thu, 09 Feb 2023 14:38:40 -0700 From: Tom Tromey Date: Thu, 09 Feb 2023 14:38:28 -0700 Subject: [PATCH 07/47] Turn value_bitsize into method MIME-Version: 1.0 Message-Id: <20230209-submit-value-fixups-2023-v1-7-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: 1pQEcq-001ZcE-KO 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: 8 X-Source-Cap: ZWx5bnJvYmk7ZWx5bnJvYmk7Ym94NTM3OS5ibHVlaG9zdC5jb20= X-Local-Domain: yes X-Spam-Status: No, score=-3027.3 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_bitsize to be a method of value. Much of this patch was written by script. --- gdb/ada-lang.c | 14 +++++++------- gdb/breakpoint.c | 6 +++--- gdb/dwarf2/expr.c | 10 +++++----- gdb/valops.c | 24 ++++++++++++------------ gdb/value.c | 17 +++-------------- gdb/value.h | 12 +++++++----- 6 files changed, 37 insertions(+), 46 deletions(-) diff --git a/gdb/ada-lang.c b/gdb/ada-lang.c index c5b5b14163b..9cbbbb06db3 100644 --- a/gdb/ada-lang.c +++ b/gdb/ada-lang.c @@ -568,7 +568,7 @@ coerce_unspec_val_to_type (struct value *val, struct type *type) value_contents_copy (result, 0, val, 0, type->length ()); } set_value_component_location (result, val); - set_value_bitsize (result, value_bitsize (val)); + result->set_bitsize (val->bitsize ()); set_value_bitpos (result, value_bitpos (val)); if (VALUE_LVAL (result) == lval_memory) set_value_address (result, value_address (val)); @@ -2832,7 +2832,7 @@ ada_value_primitive_packed_val (struct value *obj, const gdb_byte *valaddr, set_value_component_location (v, obj); set_value_bitpos (v, bit_offset + value_bitpos (obj)); - set_value_bitsize (v, bit_size); + v->set_bitsize (bit_size); if (value_bitpos (v) >= HOST_CHAR_BIT) { ++new_offset; @@ -2845,7 +2845,7 @@ ada_value_primitive_packed_val (struct value *obj, const gdb_byte *valaddr, set_value_parent (v, obj); } else - set_value_bitsize (v, bit_size); + v->set_bitsize (bit_size); unpacked = value_contents_writeable (v).data (); if (bit_size == 0) @@ -2878,7 +2878,7 @@ static struct value * ada_value_assign (struct value *toval, struct value *fromval) { struct type *type = toval->type (); - int bits = value_bitsize (toval); + int bits = toval->bitsize (); toval = ada_coerce_ref (toval); fromval = ada_coerce_ref (fromval); @@ -2907,7 +2907,7 @@ ada_value_assign (struct value *toval, struct value *fromval) fromval = value_cast (type, fromval); read_memory (to_addr, buffer, len); - from_size = value_bitsize (fromval); + from_size = fromval->bitsize (); if (from_size == 0) from_size = fromval->type ()->length () * TARGET_CHAR_BIT; @@ -2956,10 +2956,10 @@ value_assign_to_component (struct value *container, struct value *component, val = value_cast (component->type (), val); - if (value_bitsize (component) == 0) + if (component->bitsize () == 0) bits = TARGET_CHAR_BIT * component->type ()->length (); else - bits = value_bitsize (component); + bits = component->bitsize (); if (type_byte_order (container->type ()) == BFD_ENDIAN_BIG) { diff --git a/gdb/breakpoint.c b/gdb/breakpoint.c index 3c099d185f3..edb685fc4d0 100644 --- a/gdb/breakpoint.c +++ b/gdb/breakpoint.c @@ -2084,12 +2084,12 @@ update_watchpoint (struct watchpoint *b, bool reparse) struct bp_location *loc, **tmp; int bitpos = 0, bitsize = 0; - if (value_bitsize (v) != 0) + if (v->bitsize () != 0) { /* Extract the bit parameters out from the bitfield sub-expression. */ bitpos = value_bitpos (v); - bitsize = value_bitsize (v); + bitsize = v->bitsize (); } else if (v == result && b->val_bitsize != 0) { @@ -10170,7 +10170,7 @@ watch_command_1 (const char *arg, int accessflag, int from_tty, if (val_as_value != NULL && just_location) { saved_bitpos = value_bitpos (val_as_value); - saved_bitsize = value_bitsize (val_as_value); + saved_bitsize = val_as_value->bitsize (); } value_ref_ptr val; diff --git a/gdb/dwarf2/expr.c b/gdb/dwarf2/expr.c index 7310295db4d..cbc20509cbe 100644 --- a/gdb/dwarf2/expr.c +++ b/gdb/dwarf2/expr.c @@ -169,7 +169,7 @@ rw_pieced_value (value *v, value *from, bool check_optimized) } ULONGEST bits_to_skip = 8 * value_offset (v); - if (value_bitsize (v)) + if (v->bitsize ()) { bits_to_skip += (8 * value_offset (value_parent (v)) + value_bitpos (v)); @@ -179,10 +179,10 @@ rw_pieced_value (value *v, value *from, bool check_optimized) { /* Use the least significant bits of FROM. */ max_offset = 8 * from->type ()->length (); - offset = max_offset - value_bitsize (v); + offset = max_offset - v->bitsize (); } else - max_offset = value_bitsize (v); + max_offset = v->bitsize (); } else max_offset = 8 * v->type ()->length (); @@ -467,7 +467,7 @@ check_pieced_synthetic_pointer (const value *value, LONGEST bit_offset, int i; bit_offset += 8 * value_offset (value); - if (value_bitsize (value)) + if (value->bitsize ()) bit_offset += value_bitpos (value); for (i = 0; i < c->pieces.size () && bit_length > 0; i++) @@ -513,7 +513,7 @@ indirect_pieced_value (value *value) int bit_length = 8 * type->length (); LONGEST bit_offset = 8 * value_offset (value); - if (value_bitsize (value)) + if (value->bitsize ()) bit_offset += value_bitpos (value); for (i = 0; i < c->pieces.size () && bit_length > 0; i++) diff --git a/gdb/valops.c b/gdb/valops.c index 2d1db3cef83..cbc995295ed 100644 --- a/gdb/valops.c +++ b/gdb/valops.c @@ -1126,8 +1126,8 @@ value_assign (struct value *toval, struct value *fromval) /* Are we dealing with a bitfield? It is important to mention that `value_parent (toval)' is - non-NULL iff `value_bitsize (toval)' is non-zero. */ - if (value_bitsize (toval)) + non-NULL iff `toval->bitsize ()' is non-zero. */ + if (toval->bitsize ()) { /* VALUE_INTERNALVAR below refers to the parent value, while the offset is relative to this parent value. */ @@ -1138,7 +1138,7 @@ value_assign (struct value *toval, struct value *fromval) set_internalvar_component (VALUE_INTERNALVAR (toval), offset, value_bitpos (toval), - value_bitsize (toval), + toval->bitsize (), fromval); } break; @@ -1150,13 +1150,13 @@ value_assign (struct value *toval, struct value *fromval) int changed_len; gdb_byte buffer[sizeof (LONGEST)]; - if (value_bitsize (toval)) + if (toval->bitsize ()) { struct value *parent = value_parent (toval); changed_addr = value_address (parent) + value_offset (toval); changed_len = (value_bitpos (toval) - + value_bitsize (toval) + + toval->bitsize () + HOST_CHAR_BIT - 1) / HOST_CHAR_BIT; @@ -1176,7 +1176,7 @@ value_assign (struct value *toval, struct value *fromval) read_memory (changed_addr, buffer, changed_len); modify_field (type, buffer, value_as_long (fromval), - value_bitpos (toval), value_bitsize (toval)); + value_bitpos (toval), toval->bitsize ()); dest_buffer = buffer; } else @@ -1213,7 +1213,7 @@ value_assign (struct value *toval, struct value *fromval) gdbarch = get_frame_arch (frame); - if (value_bitsize (toval)) + if (toval->bitsize ()) { struct value *parent = value_parent (toval); LONGEST offset = value_offset (parent) + value_offset (toval); @@ -1222,7 +1222,7 @@ value_assign (struct value *toval, struct value *fromval) int optim, unavail; changed_len = (value_bitpos (toval) - + value_bitsize (toval) + + toval->bitsize () + HOST_CHAR_BIT - 1) / HOST_CHAR_BIT; @@ -1244,7 +1244,7 @@ value_assign (struct value *toval, struct value *fromval) } modify_field (type, buffer, value_as_long (fromval), - value_bitpos (toval), value_bitsize (toval)); + value_bitpos (toval), toval->bitsize ()); put_frame_register_bytes (frame, value_reg, offset, {buffer, changed_len}); @@ -1325,11 +1325,11 @@ value_assign (struct value *toval, struct value *fromval) /* If the field does not entirely fill a LONGEST, then zero the sign bits. If the field is signed, and is negative, then sign extend. */ - if ((value_bitsize (toval) > 0) - && (value_bitsize (toval) < 8 * (int) sizeof (LONGEST))) + if ((toval->bitsize () > 0) + && (toval->bitsize () < 8 * (int) sizeof (LONGEST))) { LONGEST fieldval = value_as_long (fromval); - LONGEST valmask = (((ULONGEST) 1) << value_bitsize (toval)) - 1; + LONGEST valmask = (((ULONGEST) 1) << toval->bitsize ()) - 1; fieldval &= valmask; if (!type->is_unsigned () diff --git a/gdb/value.c b/gdb/value.c index 96db14c99cc..963350a487c 100644 --- a/gdb/value.c +++ b/gdb/value.c @@ -916,17 +916,6 @@ set_value_bitpos (struct value *value, LONGEST bit) value->m_bitpos = bit; } -LONGEST -value_bitsize (const struct value *value) -{ - return value->m_bitsize; -} -void -set_value_bitsize (struct value *value, LONGEST bit) -{ - value->m_bitsize = bit; -} - struct value * value_parent (const struct value *value) { @@ -3776,7 +3765,7 @@ value_initialized (const struct value *val) static void value_fetch_lazy_bitfield (struct value *val) { - gdb_assert (value_bitsize (val) != 0); + gdb_assert (val->bitsize () != 0); /* To read a lazy bitfield, read the entire enclosing value. This prevents reading the same block of (possibly volatile) memory once @@ -3788,7 +3777,7 @@ value_fetch_lazy_bitfield (struct value *val) if (value_lazy (parent)) value_fetch_lazy (parent); - unpack_value_bitfield (val, value_bitpos (val), value_bitsize (val), + unpack_value_bitfield (val, value_bitpos (val), val->bitsize (), value_contents_for_printing (parent).data (), value_offset (val), parent); } @@ -3949,7 +3938,7 @@ value_fetch_lazy (struct value *val) { /* Nothing. */ } - else if (value_bitsize (val)) + else if (val->bitsize ()) value_fetch_lazy_bitfield (val); else if (VALUE_LVAL (val) == lval_memory) value_fetch_lazy_memory (val); diff --git a/gdb/value.h b/gdb/value.h index 31ec0b5c202..fed4d804f55 100644 --- a/gdb/value.h +++ b/gdb/value.h @@ -172,6 +172,13 @@ struct value /* Return the gdbarch associated with the value. */ struct gdbarch *get_arch () const; + /* Only used for bitfields; number of bits contained in them. */ + LONGEST bitsize () const + { return m_bitsize; } + + void set_bitsize (LONGEST bit) + { m_bitsize = bit; } + /* Type of value; either not an lval, or one of the various different possible kinds of lval. */ @@ -339,11 +346,6 @@ struct value std::vector m_optimized_out; }; -/* Only used for bitfields; number of bits contained in them. */ - -extern LONGEST value_bitsize (const struct value *); -extern void set_value_bitsize (struct value *, LONGEST bit); - /* Only used for bitfields; position of start of field. For little-endian targets, it is the position of the LSB. For big-endian targets, it is the position of the MSB. */ From patchwork Thu Feb 9 21:38:29 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tom Tromey X-Patchwork-Id: 64560 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 6E055382E6B7 for ; Thu, 9 Feb 2023 21:39:45 +0000 (GMT) X-Original-To: gdb-patches@sourceware.org Delivered-To: gdb-patches@sourceware.org Received: from gproxy4-pub.mail.unifiedlayer.com (gproxy4-pub.mail.unifiedlayer.com [69.89.23.142]) by sourceware.org (Postfix) with ESMTPS id 939D5385840D for ; Thu, 9 Feb 2023 21:38:41 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 939D5385840D 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 cmgw14.mail.unifiedlayer.com (unknown [10.0.90.129]) by progateway6.mail.pro1.eigbox.com (Postfix) with ESMTP id E944D10044F60 for ; Thu, 9 Feb 2023 21:38:40 +0000 (UTC) Received: from box5379.bluehost.com ([162.241.216.53]) by cmsmtp with ESMTP id QEcqpLOqQGAj8QEcqphq2y; Thu, 09 Feb 2023 21:38:40 +0000 X-Authority-Reason: nr=8 X-Authority-Analysis: v=2.4 cv=UdyU9IeN c=1 sm=1 tr=0 ts=63e567e0 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=xaJLygw7yjPnkatONSAA: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=m+XIrR01ZnXN83Ng6db2laYi0MQvVmsFJ1O/X8KbGss=; b=LmeheSyhVzmNsE6Fr7kjJtencA DzmHJPunuuZR3ryD2xlDm7yEMqxNP7xoP8TJ/HP08QTG7t0KlkKczLV+npuniNxAZtVCR1QENo2/w p9BJeczPGVuHWw9JiucAHJFyF; 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 1pQEcq-001ZcE-Ox for gdb-patches@sourceware.org; Thu, 09 Feb 2023 14:38:40 -0700 From: Tom Tromey Date: Thu, 09 Feb 2023 14:38:29 -0700 Subject: [PATCH 08/47] Turn value_bitpos into method MIME-Version: 1.0 Message-Id: <20230209-submit-value-fixups-2023-v1-8-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: 1pQEcq-001ZcE-Ox 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.3 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_bitpos to be a method of value. Much of this patch was written by script. --- gdb/ada-lang.c | 20 ++++++++++---------- gdb/breakpoint.c | 4 ++-- gdb/dwarf2/expr.c | 6 +++--- gdb/valops.c | 10 +++++----- gdb/value.c | 13 +------------ gdb/value.h | 16 +++++++++------- 6 files changed, 30 insertions(+), 39 deletions(-) diff --git a/gdb/ada-lang.c b/gdb/ada-lang.c index 9cbbbb06db3..d1ad9a28ca7 100644 --- a/gdb/ada-lang.c +++ b/gdb/ada-lang.c @@ -569,7 +569,7 @@ coerce_unspec_val_to_type (struct value *val, struct type *type) } set_value_component_location (result, val); result->set_bitsize (val->bitsize ()); - set_value_bitpos (result, value_bitpos (val)); + result->set_bitpos (val->bitpos ()); if (VALUE_LVAL (result) == lval_memory) set_value_address (result, value_address (val)); return result; @@ -2831,12 +2831,12 @@ ada_value_primitive_packed_val (struct value *obj, const gdb_byte *valaddr, long new_offset = offset; set_value_component_location (v, obj); - set_value_bitpos (v, bit_offset + value_bitpos (obj)); + v->set_bitpos (bit_offset + obj->bitpos ()); v->set_bitsize (bit_size); - if (value_bitpos (v) >= HOST_CHAR_BIT) + if (v->bitpos () >= HOST_CHAR_BIT) { ++new_offset; - set_value_bitpos (v, value_bitpos (v) - HOST_CHAR_BIT); + v->set_bitpos (v->bitpos () - HOST_CHAR_BIT); } set_value_offset (v, new_offset); @@ -2896,7 +2896,7 @@ ada_value_assign (struct value *toval, struct value *fromval) && (type->code () == TYPE_CODE_FLT || type->code () == TYPE_CODE_STRUCT)) { - int len = (value_bitpos (toval) + int len = (toval->bitpos () + bits + HOST_CHAR_BIT - 1) / HOST_CHAR_BIT; int from_size; gdb_byte *buffer = (gdb_byte *) alloca (len); @@ -2915,7 +2915,7 @@ ada_value_assign (struct value *toval, struct value *fromval) ULONGEST from_offset = 0; if (is_big_endian && is_scalar_type (fromval->type ())) from_offset = from_size - bits; - copy_bitwise (buffer, value_bitpos (toval), + copy_bitwise (buffer, toval->bitpos (), value_contents (fromval).data (), from_offset, bits, is_big_endian); write_memory_with_notification (to_addr, buffer, len); @@ -2951,7 +2951,7 @@ value_assign_to_component (struct value *container, struct value *component, LONGEST offset_in_container = (LONGEST) (value_address (component) - value_address (container)); int bit_offset_in_container = - value_bitpos (component) - value_bitpos (container); + component->bitpos () - container->bitpos (); int bits; val = value_cast (component->type (), val); @@ -2972,13 +2972,13 @@ value_assign_to_component (struct value *container, struct value *component, src_offset = 0; copy_bitwise ((value_contents_writeable (container).data () + offset_in_container), - value_bitpos (container) + bit_offset_in_container, + container->bitpos () + bit_offset_in_container, value_contents (val).data (), src_offset, bits, 1); } else copy_bitwise ((value_contents_writeable (container).data () + offset_in_container), - value_bitpos (container) + bit_offset_in_container, + container->bitpos () + bit_offset_in_container, value_contents (val).data (), 0, bits, 0); } @@ -6918,7 +6918,7 @@ ada_value_primitive_field (struct value *arg1, int offset, int fieldno, /* Handle packed fields. It might be that the field is not packed relative to its containing structure, but the structure itself is packed; in this case we must take the bit-field path. */ - if (TYPE_FIELD_BITSIZE (arg_type, fieldno) != 0 || value_bitpos (arg1) != 0) + if (TYPE_FIELD_BITSIZE (arg_type, fieldno) != 0 || arg1->bitpos () != 0) { int bit_pos = arg_type->field (fieldno).loc_bitpos (); int bit_size = TYPE_FIELD_BITSIZE (arg_type, fieldno); diff --git a/gdb/breakpoint.c b/gdb/breakpoint.c index edb685fc4d0..7e3bb715a3c 100644 --- a/gdb/breakpoint.c +++ b/gdb/breakpoint.c @@ -2088,7 +2088,7 @@ update_watchpoint (struct watchpoint *b, bool reparse) { /* Extract the bit parameters out from the bitfield sub-expression. */ - bitpos = value_bitpos (v); + bitpos = v->bitpos (); bitsize = v->bitsize (); } else if (v == result && b->val_bitsize != 0) @@ -10169,7 +10169,7 @@ watch_command_1 (const char *arg, int accessflag, int from_tty, if (val_as_value != NULL && just_location) { - saved_bitpos = value_bitpos (val_as_value); + saved_bitpos = val_as_value->bitpos (); saved_bitsize = val_as_value->bitsize (); } diff --git a/gdb/dwarf2/expr.c b/gdb/dwarf2/expr.c index cbc20509cbe..826573b628d 100644 --- a/gdb/dwarf2/expr.c +++ b/gdb/dwarf2/expr.c @@ -172,7 +172,7 @@ rw_pieced_value (value *v, value *from, bool check_optimized) if (v->bitsize ()) { bits_to_skip += (8 * value_offset (value_parent (v)) - + value_bitpos (v)); + + v->bitpos ()); if (from != nullptr && (type_byte_order (from->type ()) == BFD_ENDIAN_BIG)) @@ -468,7 +468,7 @@ check_pieced_synthetic_pointer (const value *value, LONGEST bit_offset, bit_offset += 8 * value_offset (value); if (value->bitsize ()) - bit_offset += value_bitpos (value); + bit_offset += value->bitpos (); for (i = 0; i < c->pieces.size () && bit_length > 0; i++) { @@ -514,7 +514,7 @@ indirect_pieced_value (value *value) int bit_length = 8 * type->length (); LONGEST bit_offset = 8 * value_offset (value); if (value->bitsize ()) - bit_offset += value_bitpos (value); + bit_offset += value->bitpos (); for (i = 0; i < c->pieces.size () && bit_length > 0; i++) { diff --git a/gdb/valops.c b/gdb/valops.c index cbc995295ed..f17a0b6a2d0 100644 --- a/gdb/valops.c +++ b/gdb/valops.c @@ -1137,7 +1137,7 @@ value_assign (struct value *toval, struct value *fromval) set_internalvar_component (VALUE_INTERNALVAR (toval), offset, - value_bitpos (toval), + toval->bitpos (), toval->bitsize (), fromval); } @@ -1155,7 +1155,7 @@ value_assign (struct value *toval, struct value *fromval) struct value *parent = value_parent (toval); changed_addr = value_address (parent) + value_offset (toval); - changed_len = (value_bitpos (toval) + changed_len = (toval->bitpos () + toval->bitsize () + HOST_CHAR_BIT - 1) / HOST_CHAR_BIT; @@ -1176,7 +1176,7 @@ value_assign (struct value *toval, struct value *fromval) read_memory (changed_addr, buffer, changed_len); modify_field (type, buffer, value_as_long (fromval), - value_bitpos (toval), toval->bitsize ()); + toval->bitpos (), toval->bitsize ()); dest_buffer = buffer; } else @@ -1221,7 +1221,7 @@ value_assign (struct value *toval, struct value *fromval) gdb_byte buffer[sizeof (LONGEST)]; int optim, unavail; - changed_len = (value_bitpos (toval) + changed_len = (toval->bitpos () + toval->bitsize () + HOST_CHAR_BIT - 1) / HOST_CHAR_BIT; @@ -1244,7 +1244,7 @@ value_assign (struct value *toval, struct value *fromval) } modify_field (type, buffer, value_as_long (fromval), - value_bitpos (toval), toval->bitsize ()); + toval->bitpos (), toval->bitsize ()); put_frame_register_bytes (frame, value_reg, offset, {buffer, changed_len}); diff --git a/gdb/value.c b/gdb/value.c index 963350a487c..3ef1d85a20a 100644 --- a/gdb/value.c +++ b/gdb/value.c @@ -905,17 +905,6 @@ set_value_offset (struct value *value, LONGEST offset) value->m_offset = offset; } -LONGEST -value_bitpos (const struct value *value) -{ - return value->m_bitpos; -} -void -set_value_bitpos (struct value *value, LONGEST bit) -{ - value->m_bitpos = bit; -} - struct value * value_parent (const struct value *value) { @@ -3777,7 +3766,7 @@ value_fetch_lazy_bitfield (struct value *val) if (value_lazy (parent)) value_fetch_lazy (parent); - unpack_value_bitfield (val, value_bitpos (val), val->bitsize (), + unpack_value_bitfield (val, val->bitpos (), val->bitsize (), value_contents_for_printing (parent).data (), value_offset (val), parent); } diff --git a/gdb/value.h b/gdb/value.h index fed4d804f55..3f48b2350b9 100644 --- a/gdb/value.h +++ b/gdb/value.h @@ -179,6 +179,15 @@ struct value void set_bitsize (LONGEST bit) { m_bitsize = bit; } + /* Only used for bitfields; position of start of field. For + little-endian targets, it is the position of the LSB. For + big-endian targets, it is the position of the MSB. */ + LONGEST bitpos () const + { return m_bitpos; } + + void set_bitpos (LONGEST bit) + { m_bitpos = bit; } + /* Type of value; either not an lval, or one of the various different possible kinds of lval. */ @@ -346,13 +355,6 @@ struct value std::vector m_optimized_out; }; -/* Only used for bitfields; position of start of field. For - little-endian targets, it is the position of the LSB. For - big-endian targets, it is the position of the MSB. */ - -extern LONGEST value_bitpos (const struct value *); -extern void set_value_bitpos (struct value *, LONGEST bit); - /* Only used for bitfields; the containing value. This allows a single read from the target when displaying multiple bitfields. */ From patchwork Thu Feb 9 21:38:30 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tom Tromey X-Patchwork-Id: 64561 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 A696B3885523 for ; Thu, 9 Feb 2023 21:39:47 +0000 (GMT) X-Original-To: gdb-patches@sourceware.org Delivered-To: gdb-patches@sourceware.org Received: from gproxy4-pub.mail.unifiedlayer.com (gproxy4-pub.mail.unifiedlayer.com [69.89.23.142]) by sourceware.org (Postfix) with ESMTPS id AD12E3858423 for ; Thu, 9 Feb 2023 21:38:41 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org AD12E3858423 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 cmgw14.mail.unifiedlayer.com (unknown [10.0.90.129]) by progateway6.mail.pro1.eigbox.com (Postfix) with ESMTP id 1630B10044F57 for ; Thu, 9 Feb 2023 21:38:41 +0000 (UTC) Received: from box5379.bluehost.com ([162.241.216.53]) by cmsmtp with ESMTP id QEcrpLOqUGAj8QEcrphq33; Thu, 09 Feb 2023 21:38:41 +0000 X-Authority-Reason: nr=8 X-Authority-Analysis: v=2.4 cv=UdyU9IeN c=1 sm=1 tr=0 ts=63e567e1 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=vOnlYMU6DkMGRwN2TKcA: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=1pzfZOVEzlduP1IkzcN9MIWyoG19h0N28imczC5McP8=; b=drHT91QiZQv2BuzYoNRzAKXnMb hc0KxQDdZFyoKkEkARpNdGzZXJ/9i1W32MwyhZTDckP4l6jqf29MUbdPu0TNDJOj97tua8ffwEDec RD8pGLGCOvcpBzqqzeunQB3x3; 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 1pQEcq-001ZcE-TV for gdb-patches@sourceware.org; Thu, 09 Feb 2023 14:38:40 -0700 From: Tom Tromey Date: Thu, 09 Feb 2023 14:38:30 -0700 Subject: [PATCH 09/47] Turn value_parent into method MIME-Version: 1.0 Message-Id: <20230209-submit-value-fixups-2023-v1-9-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: 1pQEcq-001ZcE-TV 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: 10 X-Source-Cap: ZWx5bnJvYmk7ZWx5bnJvYmk7Ym94NTM3OS5ibHVlaG9zdC5jb20= X-Local-Domain: yes X-Spam-Status: No, score=-3027.4 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_parent to be a method of value. Much of this patch was written by script. --- gdb/ada-lang.c | 2 +- gdb/dwarf2/expr.c | 2 +- gdb/valops.c | 10 +++++----- gdb/value.c | 18 ++---------------- gdb/value.h | 17 ++++++++++------- 5 files changed, 19 insertions(+), 30 deletions(-) diff --git a/gdb/ada-lang.c b/gdb/ada-lang.c index d1ad9a28ca7..b4fcce21a73 100644 --- a/gdb/ada-lang.c +++ b/gdb/ada-lang.c @@ -2842,7 +2842,7 @@ ada_value_primitive_packed_val (struct value *obj, const gdb_byte *valaddr, /* Also set the parent value. This is needed when trying to assign a new value (in inferior memory). */ - set_value_parent (v, obj); + v->set_parent (obj); } else v->set_bitsize (bit_size); diff --git a/gdb/dwarf2/expr.c b/gdb/dwarf2/expr.c index 826573b628d..2b8feffe881 100644 --- a/gdb/dwarf2/expr.c +++ b/gdb/dwarf2/expr.c @@ -171,7 +171,7 @@ rw_pieced_value (value *v, value *from, bool check_optimized) ULONGEST bits_to_skip = 8 * value_offset (v); if (v->bitsize ()) { - bits_to_skip += (8 * value_offset (value_parent (v)) + bits_to_skip += (8 * value_offset (v->parent ()) + v->bitpos ()); if (from != nullptr && (type_byte_order (from->type ()) diff --git a/gdb/valops.c b/gdb/valops.c index f17a0b6a2d0..2037a8fc8cc 100644 --- a/gdb/valops.c +++ b/gdb/valops.c @@ -1125,14 +1125,14 @@ value_assign (struct value *toval, struct value *fromval) /* Are we dealing with a bitfield? - It is important to mention that `value_parent (toval)' is + It is important to mention that `toval->parent ()' is non-NULL iff `toval->bitsize ()' is non-zero. */ if (toval->bitsize ()) { /* VALUE_INTERNALVAR below refers to the parent value, while the offset is relative to this parent value. */ - gdb_assert (value_parent (value_parent (toval)) == NULL); - offset += value_offset (value_parent (toval)); + gdb_assert (toval->parent ()->parent () == NULL); + offset += value_offset (toval->parent ()); } set_internalvar_component (VALUE_INTERNALVAR (toval), @@ -1152,7 +1152,7 @@ value_assign (struct value *toval, struct value *fromval) if (toval->bitsize ()) { - struct value *parent = value_parent (toval); + struct value *parent = toval->parent (); changed_addr = value_address (parent) + value_offset (toval); changed_len = (toval->bitpos () @@ -1215,7 +1215,7 @@ value_assign (struct value *toval, struct value *fromval) if (toval->bitsize ()) { - struct value *parent = value_parent (toval); + struct value *parent = toval->parent (); LONGEST offset = value_offset (parent) + value_offset (toval); size_t changed_len; gdb_byte buffer[sizeof (LONGEST)]; diff --git a/gdb/value.c b/gdb/value.c index 3ef1d85a20a..9704d25be76 100644 --- a/gdb/value.c +++ b/gdb/value.c @@ -905,20 +905,6 @@ set_value_offset (struct value *value, LONGEST offset) value->m_offset = offset; } -struct value * -value_parent (const struct value *value) -{ - return value->m_parent.get (); -} - -/* See value.h. */ - -void -set_value_parent (struct value *value, struct value *parent) -{ - value->m_parent = value_ref_ptr::new_reference (parent); -} - gdb::array_view value_contents_raw (struct value *value) { @@ -2900,7 +2886,7 @@ value_primitive_field (struct value *arg1, LONGEST offset, v->m_offset = (value_embedded_offset (arg1) + offset + (bitpos - v->m_bitpos) / 8); - set_value_parent (v, arg1); + v->set_parent (arg1); if (!value_lazy (arg1)) value_fetch_lazy (v); } @@ -3761,7 +3747,7 @@ value_fetch_lazy_bitfield (struct value *val) per bitfield. It would be even better to read only the containing word, but we have no way to record that just specific bits of a value have been fetched. */ - struct value *parent = value_parent (val); + struct value *parent = val->parent (); if (value_lazy (parent)) value_fetch_lazy (parent); diff --git a/gdb/value.h b/gdb/value.h index 3f48b2350b9..d0e6b0363e4 100644 --- a/gdb/value.h +++ b/gdb/value.h @@ -188,6 +188,16 @@ struct value void set_bitpos (LONGEST bit) { m_bitpos = bit; } + /* Only used for bitfields; the containing value. This allows a + single read from the target when displaying multiple + bitfields. */ + + value *parent () const + { return m_parent.get (); } + + void set_parent (struct value *parent) + { m_parent = value_ref_ptr::new_reference (parent); } + /* Type of value; either not an lval, or one of the various different possible kinds of lval. */ @@ -355,13 +365,6 @@ struct value std::vector m_optimized_out; }; -/* Only used for bitfields; the containing value. This allows a - single read from the target when displaying multiple - bitfields. */ - -struct value *value_parent (const struct value *); -extern void set_value_parent (struct value *value, struct value *parent); - /* Describes offset of a value within lval of a structure in bytes. If lval == lval_memory, this is an offset to the address. If lval == lval_register, this is a further offset from location.address From patchwork Thu Feb 9 21:38:31 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tom Tromey X-Patchwork-Id: 64562 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 C21183888C65 for ; Thu, 9 Feb 2023 21:39:49 +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 CAB183858428 for ; Thu, 9 Feb 2023 21:38:41 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org CAB183858428 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 32AC410040638 for ; Thu, 9 Feb 2023 21:38:41 +0000 (UTC) Received: from box5379.bluehost.com ([162.241.216.53]) by cmsmtp with ESMTP id QEcrpzBOTP796QEcrpwoVz; Thu, 09 Feb 2023 21:38:41 +0000 X-Authority-Reason: nr=8 X-Authority-Analysis: v=2.4 cv=MJClJOVl c=1 sm=1 tr=0 ts=63e567e1 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=gLCaAbObLp3LQ_0D9LkA: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=1wi2aY1inoWMDCPO3fRDF85P7WN6eC3rMO5LZ77JuAY=; b=sO9VxozARgmurNV6Oyz+UsWviI 8kp8wRAZOGJN4/iodOrc372XugjGDI/XmISX7Ft2B9VjMEidyfGS3qKxqVjXehsiEOKAa0XoJaRfS 2x+HzMFIaouUc1oXKBbrCXmIP; 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 1pQEcr-001ZcE-19 for gdb-patches@sourceware.org; Thu, 09 Feb 2023 14:38:41 -0700 From: Tom Tromey Date: Thu, 09 Feb 2023 14:38:31 -0700 Subject: [PATCH 10/47] Turn value_offset into method MIME-Version: 1.0 Message-Id: <20230209-submit-value-fixups-2023-v1-10-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: 1pQEcr-001ZcE-19 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: 11 X-Source-Cap: ZWx5bnJvYmk7ZWx5bnJvYmk7Ym94NTM3OS5ibHVlaG9zdC5jb20= X-Local-Domain: yes X-Spam-Status: No, score=-3027.4 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_offset to be a method of value. Much of this patch was written by script. --- gdb/ada-lang.c | 2 +- gdb/breakpoint.c | 2 +- gdb/cp-abi.h | 4 ++-- gdb/dwarf2/expr.c | 10 +++++----- gdb/findvar.c | 6 +++--- gdb/gnu-v2-abi.c | 2 +- gdb/infrun.c | 4 ++-- gdb/opencl-lang.c | 4 ++-- gdb/s390-tdep.c | 2 +- gdb/valops.c | 18 +++++++++--------- gdb/value.c | 23 ++++++----------------- gdb/value.h | 21 ++++++++++++--------- 12 files changed, 45 insertions(+), 53 deletions(-) diff --git a/gdb/ada-lang.c b/gdb/ada-lang.c index b4fcce21a73..c660e74e08c 100644 --- a/gdb/ada-lang.c +++ b/gdb/ada-lang.c @@ -2838,7 +2838,7 @@ ada_value_primitive_packed_val (struct value *obj, const gdb_byte *valaddr, ++new_offset; v->set_bitpos (v->bitpos () - HOST_CHAR_BIT); } - set_value_offset (v, new_offset); + v->set_offset (new_offset); /* Also set the parent value. This is needed when trying to assign a new value (in inferior memory). */ diff --git a/gdb/breakpoint.c b/gdb/breakpoint.c index 7e3bb715a3c..1c56b353e27 100644 --- a/gdb/breakpoint.c +++ b/gdb/breakpoint.c @@ -1862,7 +1862,7 @@ extract_bitfield_from_watchpoint_value (struct watchpoint *w, struct value *val) w->val_bitpos, w->val_bitsize, value_contents_for_printing (val).data (), - value_offset (val), + val->offset (), val); return bit_val; diff --git a/gdb/cp-abi.h b/gdb/cp-abi.h index 383746244a7..f7c903eca2d 100644 --- a/gdb/cp-abi.h +++ b/gdb/cp-abi.h @@ -123,12 +123,12 @@ extern struct value *value_virtual_fn_field (struct value **valuep, - If *USING_ENC is zero, then *TOP is the offset from the start of the complete object to the start of the embedded subobject VALUE represents. In other words, the enclosing object starts - at VALUE_ADDR (VALUE) + VALUE_OFFSET (VALUE) + + at VALUE_ADDR (VALUE) + VALUE->offset () + value_embedded_offset (VALUE) + *TOP - If *USING_ENC is non-zero, then *TOP is the offset from the address of the complete object to the enclosing object stored in VALUE. In other words, the enclosing object starts at - VALUE_ADDR (VALUE) + VALUE_OFFSET (VALUE) + *TOP. + VALUE_ADDR (VALUE) + VALUE->offset () + *TOP. If VALUE's type and enclosing type are the same, then these two cases are equivalent. diff --git a/gdb/dwarf2/expr.c b/gdb/dwarf2/expr.c index 2b8feffe881..ccce09350d2 100644 --- a/gdb/dwarf2/expr.c +++ b/gdb/dwarf2/expr.c @@ -168,10 +168,10 @@ rw_pieced_value (value *v, value *from, bool check_optimized) from_contents = nullptr; } - ULONGEST bits_to_skip = 8 * value_offset (v); + ULONGEST bits_to_skip = 8 * v->offset (); if (v->bitsize ()) { - bits_to_skip += (8 * value_offset (v->parent ()) + bits_to_skip += (8 * v->parent ()->offset () + v->bitpos ()); if (from != nullptr && (type_byte_order (from->type ()) @@ -466,7 +466,7 @@ check_pieced_synthetic_pointer (const value *value, LONGEST bit_offset, piece_closure *c = (piece_closure *) value_computed_closure (value); int i; - bit_offset += 8 * value_offset (value); + bit_offset += 8 * value->offset (); if (value->bitsize ()) bit_offset += value->bitpos (); @@ -512,7 +512,7 @@ indirect_pieced_value (value *value) return NULL; int bit_length = 8 * type->length (); - LONGEST bit_offset = 8 * value_offset (value); + LONGEST bit_offset = 8 * value->offset (); if (value->bitsize ()) bit_offset += value->bitpos (); @@ -934,7 +934,7 @@ dwarf_expr_context::fetch_result (struct type *type, struct type *subobj_type, std::move (this->m_pieces), this->m_frame); retval = allocate_computed_value (subobj_type, &pieced_value_funcs, c); - set_value_offset (retval, subobj_offset); + retval->set_offset (subobj_offset); } else { diff --git a/gdb/findvar.c b/gdb/findvar.c index 6683bf761ad..9420286e91c 100644 --- a/gdb/findvar.c +++ b/gdb/findvar.c @@ -822,9 +822,9 @@ default_value_from_register (struct gdbarch *gdbarch, struct type *type, if (type_byte_order (type) == BFD_ENDIAN_BIG && len < register_size (gdbarch, regnum)) /* Big-endian, and we want less than full size. */ - set_value_offset (value, register_size (gdbarch, regnum) - len); + value->set_offset (register_size (gdbarch, regnum) - len); else - set_value_offset (value, 0); + value->set_offset (0); return value; } @@ -842,7 +842,7 @@ read_frame_register_value (struct value *value, frame_info_ptr frame) { struct gdbarch *gdbarch = get_frame_arch (frame); LONGEST offset = 0; - LONGEST reg_offset = value_offset (value); + LONGEST reg_offset = value->offset (); int regnum = VALUE_REGNUM (value); int len = type_length_units (check_typedef (value->type ())); diff --git a/gdb/gnu-v2-abi.c b/gdb/gnu-v2-abi.c index b27649051a4..632b46f92de 100644 --- a/gdb/gnu-v2-abi.c +++ b/gdb/gnu-v2-abi.c @@ -158,7 +158,7 @@ gnuv2_virtual_fn_field (struct value **arg1p, struct fn_field * f, int j, if (entry_type->code () == TYPE_CODE_STRUCT) { /* Move the `this' pointer according to the virtual function table. */ - set_value_offset (arg1, value_offset (arg1) + arg1->set_offset (arg1->offset () + value_as_long (value_field (entry, 0))); if (!value_lazy (arg1)) diff --git a/gdb/infrun.c b/gdb/infrun.c index 9e81f83134a..9e2512e8446 100644 --- a/gdb/infrun.c +++ b/gdb/infrun.c @@ -9144,7 +9144,7 @@ siginfo_value_read (struct value *v) TARGET_OBJECT_SIGNAL_INFO, nullptr, value_contents_all_raw (v).data (), - value_offset (v), + v->offset (), v->type ()->length ()); if (transferred != v->type ()->length ()) @@ -9167,7 +9167,7 @@ siginfo_value_write (struct value *v, struct value *fromval) TARGET_OBJECT_SIGNAL_INFO, nullptr, value_contents_all_raw (fromval).data (), - value_offset (v), + v->offset (), fromval->type ()->length ()); if (transferred != fromval->type ()->length ()) diff --git a/gdb/opencl-lang.c b/gdb/opencl-lang.c index f66489bec0f..107a138ff7c 100644 --- a/gdb/opencl-lang.c +++ b/gdb/opencl-lang.c @@ -122,7 +122,7 @@ lval_func_read (struct value *v) struct lval_closure *c = (struct lval_closure *) value_computed_closure (v); struct type *type = check_typedef (v->type ()); struct type *eltype = check_typedef (c->val->type ())->target_type (); - LONGEST offset = value_offset (v); + LONGEST offset = v->offset (); LONGEST elsize = eltype->length (); int n, i, j = 0; LONGEST lowb = 0; @@ -152,7 +152,7 @@ lval_func_write (struct value *v, struct value *fromval) struct lval_closure *c = (struct lval_closure *) value_computed_closure (v); struct type *type = check_typedef (v->type ()); struct type *eltype = check_typedef (c->val->type ())->target_type (); - LONGEST offset = value_offset (v); + LONGEST offset = v->offset (); LONGEST elsize = eltype->length (); int n, i, j = 0; LONGEST lowb = 0; diff --git a/gdb/s390-tdep.c b/gdb/s390-tdep.c index f33a13e8a55..9aa2c06cec1 100644 --- a/gdb/s390-tdep.c +++ b/gdb/s390-tdep.c @@ -1240,7 +1240,7 @@ s390_value_from_register (struct gdbarch *gdbarch, struct type *type, && type->length () < 8) || regnum_is_vxr_full (tdep, regnum) || (regnum >= S390_V16_REGNUM && regnum <= S390_V31_REGNUM)) - set_value_offset (value, 0); + value->set_offset (0); return value; } diff --git a/gdb/valops.c b/gdb/valops.c index 2037a8fc8cc..276c171f0bc 100644 --- a/gdb/valops.c +++ b/gdb/valops.c @@ -1121,7 +1121,7 @@ value_assign (struct value *toval, struct value *fromval) case lval_internalvar_component: { - LONGEST offset = value_offset (toval); + LONGEST offset = toval->offset (); /* Are we dealing with a bitfield? @@ -1132,7 +1132,7 @@ value_assign (struct value *toval, struct value *fromval) /* VALUE_INTERNALVAR below refers to the parent value, while the offset is relative to this parent value. */ gdb_assert (toval->parent ()->parent () == NULL); - offset += value_offset (toval->parent ()); + offset += toval->parent ()->offset (); } set_internalvar_component (VALUE_INTERNALVAR (toval), @@ -1154,7 +1154,7 @@ value_assign (struct value *toval, struct value *fromval) { struct value *parent = toval->parent (); - changed_addr = value_address (parent) + value_offset (toval); + changed_addr = value_address (parent) + toval->offset (); changed_len = (toval->bitpos () + toval->bitsize () + HOST_CHAR_BIT - 1) @@ -1216,7 +1216,7 @@ value_assign (struct value *toval, struct value *fromval) if (toval->bitsize ()) { struct value *parent = toval->parent (); - LONGEST offset = value_offset (parent) + value_offset (toval); + LONGEST offset = parent->offset () + toval->offset (); size_t changed_len; gdb_byte buffer[sizeof (LONGEST)]; int optim, unavail; @@ -1263,7 +1263,7 @@ value_assign (struct value *toval, struct value *fromval) } else put_frame_register_bytes (frame, value_reg, - value_offset (toval), + toval->offset (), value_contents (fromval)); } @@ -2560,7 +2560,7 @@ find_method_list (struct value **argp, const char *method, { base_offset = baseclass_offset (type, i, value_contents_for_printing (*argp).data (), - value_offset (*argp) + offset, + (*argp)->offset () + offset, value_address (*argp), *argp); } else /* Non-virtual base, simply use bit position from debug @@ -3531,7 +3531,7 @@ get_baseclass_offset (struct type *vt, struct type *cls, if (BASETYPE_VIA_VIRTUAL (vt, i)) { const gdb_byte *adr = value_contents_for_printing (v).data (); - *boffs = baseclass_offset (vt, i, adr, value_offset (v), + *boffs = baseclass_offset (vt, i, adr, v->offset (), value_as_long (v), v); *isvirt = true; } @@ -3545,7 +3545,7 @@ get_baseclass_offset (struct type *vt, struct type *cls, if (*isvirt == false) /* Add non-virtual base offset. */ { const gdb_byte *adr = value_contents_for_printing (v).data (); - *boffs += baseclass_offset (vt, i, adr, value_offset (v), + *boffs += baseclass_offset (vt, i, adr, v->offset (), value_as_long (v), v); } return true; @@ -4089,7 +4089,7 @@ value_slice (struct value *array, int lowbound, int length) } set_value_component_location (slice, array); - set_value_offset (slice, value_offset (array) + offset); + slice->set_offset (array->offset () + offset); } return slice; diff --git a/gdb/value.c b/gdb/value.c index 9704d25be76..64c1bf03956 100644 --- a/gdb/value.c +++ b/gdb/value.c @@ -894,17 +894,6 @@ allocate_optimized_out_value (struct type *type) /* Accessor methods. */ -LONGEST -value_offset (const struct value *value) -{ - return value->m_offset; -} -void -set_value_offset (struct value *value, LONGEST offset) -{ - value->m_offset = offset; -} - gdb::array_view value_contents_raw (struct value *value) { @@ -2922,7 +2911,7 @@ value_primitive_field (struct value *arg1, LONGEST offset, value_enclosing_type (arg1)->length ()); } v->m_type = type; - v->m_offset = value_offset (arg1); + v->m_offset = arg1->offset (); v->m_embedded_offset = offset + value_embedded_offset (arg1) + boffset; } else if (NULL != TYPE_DATA_LOCATION (type)) @@ -2955,7 +2944,7 @@ value_primitive_field (struct value *arg1, LONGEST offset, arg1, value_embedded_offset (arg1) + offset, type_length_units (type)); } - v->m_offset = (value_offset (arg1) + offset + v->m_offset = (arg1->offset () + offset + value_embedded_offset (arg1)); } set_value_component_location (v, arg1); @@ -3024,7 +3013,7 @@ value_fn_field (struct value **arg1p, struct fn_field *f, value_addr (*arg1p))); /* Move the `this' pointer according to the offset. - VALUE_OFFSET (*arg1p) += offset; */ + (*arg1p)->offset () += offset; */ } return v; @@ -3557,7 +3546,7 @@ value_from_component (struct value *whole, struct type *type, LONGEST offset) whole, value_embedded_offset (whole) + offset, type_length_units (type)); } - v->m_offset = value_offset (whole) + offset + value_embedded_offset (whole); + v->m_offset = whole->offset () + offset + value_embedded_offset (whole); set_value_component_location (v, whole); return v; @@ -3754,7 +3743,7 @@ value_fetch_lazy_bitfield (struct value *val) unpack_value_bitfield (val, val->bitpos (), val->bitsize (), value_contents_for_printing (parent).data (), - value_offset (val), parent); + val->offset (), parent); } /* Helper for value_fetch_lazy when the value is in memory. */ @@ -3785,7 +3774,7 @@ value_fetch_lazy_register (struct value *val) /* Offsets are not supported here; lazy register values must refer to the entire register. */ - gdb_assert (value_offset (val) == 0); + gdb_assert (val->offset () == 0); while (VALUE_LVAL (new_val) == lval_register && value_lazy (new_val)) { diff --git a/gdb/value.h b/gdb/value.h index d0e6b0363e4..d79455cc345 100644 --- a/gdb/value.h +++ b/gdb/value.h @@ -198,6 +198,18 @@ struct value void set_parent (struct value *parent) { m_parent = value_ref_ptr::new_reference (parent); } + /* Describes offset of a value within lval of a structure in bytes. + If lval == lval_memory, this is an offset to the address. If + lval == lval_register, this is a further offset from + location.address within the registers structure. Note also the + member embedded_offset below. */ + + LONGEST offset () const + { return m_offset; } + + void set_offset (LONGEST offset) + { m_offset = offset; } + /* Type of value; either not an lval, or one of the various different possible kinds of lval. */ @@ -365,15 +377,6 @@ struct value std::vector m_optimized_out; }; -/* Describes offset of a value within lval of a structure in bytes. - If lval == lval_memory, this is an offset to the address. If lval - == lval_register, this is a further offset from location.address - within the registers structure. Note also the member - embedded_offset below. */ - -extern LONGEST value_offset (const struct value *); -extern void set_value_offset (struct value *, LONGEST offset); - /* The comment from "struct value" reads: ``Is it modifiable? Only relevant if lval != not_lval.''. Shouldn't the value instead be not_lval and be done with it? */ From patchwork Thu Feb 9 21:38:32 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tom Tromey X-Patchwork-Id: 64564 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 1DB493888C47 for ; Thu, 9 Feb 2023 21:40:05 +0000 (GMT) X-Original-To: gdb-patches@sourceware.org Delivered-To: gdb-patches@sourceware.org Received: from progateway7-pub.mail.pro1.eigbox.com (gproxy5-pub.mail.unifiedlayer.com [67.222.38.55]) by sourceware.org (Postfix) with ESMTPS id EE3AD385842C for ; Thu, 9 Feb 2023 21:38:41 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org EE3AD385842C 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 progateway7.mail.pro1.eigbox.com (Postfix) with ESMTP id 5324C10042D11 for ; Thu, 9 Feb 2023 21:38:41 +0000 (UTC) Received: from box5379.bluehost.com ([162.241.216.53]) by cmsmtp with ESMTP id QEcrpzBOaP796QEcrpwoW6; Thu, 09 Feb 2023 21:38:41 +0000 X-Authority-Reason: nr=8 X-Authority-Analysis: v=2.4 cv=MJClJOVl c=1 sm=1 tr=0 ts=63e567e1 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=G3ECseQddodGc2JpXMUA: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=6+hityIQ8A7uKy3XF4jVnE1MlQv2I6vRi11pYUmQi/g=; b=oUvpT5qbv+jodyAUHC78N9mwBv FohQl7lKFI1ipZKoRrPkNDAgPJPZxMr/UaiyO/5zcAfeDLlhasUBc9eB1mHZiOhBSqsSaq1+lgbXI eTUumZk6lqDFVGYZweGLm8xMO; 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 1pQEcr-001ZcE-5V for gdb-patches@sourceware.org; Thu, 09 Feb 2023 14:38:41 -0700 From: Tom Tromey Date: Thu, 09 Feb 2023 14:38:32 -0700 Subject: [PATCH 11/47] Turn deprecated_value_modifiable into method MIME-Version: 1.0 Message-Id: <20230209-submit-value-fixups-2023-v1-11-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: 1pQEcr-001ZcE-5V 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: 12 X-Source-Cap: ZWx5bnJvYmk7ZWx5bnJvYmk7Ym94NTM3OS5ibHVlaG9zdC5jb20= X-Local-Domain: yes X-Spam-Status: No, score=-3027.4 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 deprecated_value_modifiable to be a method of value. --- gdb/ada-lang.c | 4 ++-- gdb/breakpoint.c | 2 +- gdb/opencl-lang.c | 2 +- gdb/ppc-linux-nat.c | 2 +- gdb/valops.c | 2 +- gdb/value.c | 5 ----- gdb/value.h | 12 ++++++------ 7 files changed, 12 insertions(+), 17 deletions(-) diff --git a/gdb/ada-lang.c b/gdb/ada-lang.c index c660e74e08c..5aec8b77b14 100644 --- a/gdb/ada-lang.c +++ b/gdb/ada-lang.c @@ -2888,7 +2888,7 @@ ada_value_assign (struct value *toval, struct value *fromval) if (ada_is_direct_array_type (fromval->type ())) fromval = ada_coerce_to_simple_array (fromval); - if (!deprecated_value_modifiable (toval)) + if (!toval->deprecated_modifiable ()) error (_("Left operand of assignment is not a modifiable lvalue.")); if (VALUE_LVAL (toval) == lval_memory @@ -9531,7 +9531,7 @@ ada_aggregate_operation::assign_aggregate (struct value *container, if (ada_is_direct_array_type (container->type ())) container = ada_coerce_to_simple_array (container); lhs = ada_coerce_ref (lhs); - if (!deprecated_value_modifiable (lhs)) + if (!lhs->deprecated_modifiable ()) error (_("Left operand of assignment is not a modifiable lvalue.")); lhs_type = check_typedef (lhs->type ()); diff --git a/gdb/breakpoint.c b/gdb/breakpoint.c index 1c56b353e27..492b0ef7941 100644 --- a/gdb/breakpoint.c +++ b/gdb/breakpoint.c @@ -10421,7 +10421,7 @@ can_use_hardware_watchpoint (const std::vector &vals) } } else if (VALUE_LVAL (v) != not_lval - && deprecated_value_modifiable (v) == 0) + && v->deprecated_modifiable () == 0) return 0; /* These are values from the history (e.g., $1). */ else if (VALUE_LVAL (v) == lval_register) return 0; /* Cannot watch a register with a HW watchpoint. */ diff --git a/gdb/opencl-lang.c b/gdb/opencl-lang.c index 107a138ff7c..8c59e823d5c 100644 --- a/gdb/opencl-lang.c +++ b/gdb/opencl-lang.c @@ -687,7 +687,7 @@ eval_opencl_assign (struct type *expect_type, struct expression *exp, return arg1; struct type *type1 = arg1->type (); - if (deprecated_value_modifiable (arg1) + if (arg1->deprecated_modifiable () && VALUE_LVAL (arg1) != lval_internalvar) arg2 = opencl_value_cast (type1, arg2); diff --git a/gdb/ppc-linux-nat.c b/gdb/ppc-linux-nat.c index cb832726ea5..a796364b413 100644 --- a/gdb/ppc-linux-nat.c +++ b/gdb/ppc-linux-nat.c @@ -2455,7 +2455,7 @@ ppc_linux_nat_target::num_memory_accesses (const std::vector struct value *v = iter.get (); /* Constants and values from the history are fine. */ - if (VALUE_LVAL (v) == not_lval || deprecated_value_modifiable (v) == 0) + if (VALUE_LVAL (v) == not_lval || v->->deprecated_modifiable () == 0) continue; else if (VALUE_LVAL (v) == lval_memory) { diff --git a/gdb/valops.c b/gdb/valops.c index 276c171f0bc..d0ef2b952c3 100644 --- a/gdb/valops.c +++ b/gdb/valops.c @@ -1089,7 +1089,7 @@ value_assign (struct value *toval, struct value *fromval) struct value *val; struct frame_id old_frame; - if (!deprecated_value_modifiable (toval)) + if (!toval->deprecated_modifiable ()) error (_("Left operand of assignment is not a modifiable lvalue.")); toval = coerce_ref (toval); diff --git a/gdb/value.c b/gdb/value.c index 64c1bf03956..eca340cad80 100644 --- a/gdb/value.c +++ b/gdb/value.c @@ -1385,11 +1385,6 @@ deprecated_value_regnum_hack (struct value *value) return &value->m_location.reg.regnum; } -int -deprecated_value_modifiable (const struct value *value) -{ - return value->m_modifiable; -} /* Return a mark in the value chain. All values allocated after the mark is obtained (except for those released) are subject to being freed diff --git a/gdb/value.h b/gdb/value.h index d79455cc345..360e8c5bc33 100644 --- a/gdb/value.h +++ b/gdb/value.h @@ -210,6 +210,12 @@ struct value void set_offset (LONGEST offset) { m_offset = offset; } + /* The comment from "struct value" reads: ``Is it modifiable? Only + relevant if lval != not_lval.''. Shouldn't the value instead be + not_lval and be done with it? */ + int deprecated_modifiable () const + { return m_modifiable; } + /* Type of value; either not an lval, or one of the various different possible kinds of lval. */ @@ -377,12 +383,6 @@ struct value std::vector m_optimized_out; }; -/* The comment from "struct value" reads: ``Is it modifiable? Only - relevant if lval != not_lval.''. Shouldn't the value instead be - not_lval and be done with it? */ - -extern int deprecated_value_modifiable (const struct value *value); - /* If a value represents a C++ object, then the `type' field gives the object's compile-time type. If the object actually belongs to some class derived from `type', perhaps with other base classes and From patchwork Thu Feb 9 21:38:33 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tom Tromey X-Patchwork-Id: 64567 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 652BB388A417 for ; Thu, 9 Feb 2023 21:40:28 +0000 (GMT) X-Original-To: gdb-patches@sourceware.org Delivered-To: gdb-patches@sourceware.org Received: from outbound-ss-820.bluehost.com (outbound-ss-820.bluehost.com [69.89.24.241]) by sourceware.org (Postfix) with ESMTPS id 14AC83858433 for ; Thu, 9 Feb 2023 21:38:42 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 14AC83858433 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 progateway2.mail.pro1.eigbox.com (Postfix) with ESMTP id 7A6F510047F8C for ; Thu, 9 Feb 2023 21:38:41 +0000 (UTC) Received: from box5379.bluehost.com ([162.241.216.53]) by cmsmtp with ESMTP id QEcrpzBOhP796QEcrpwoWD; Thu, 09 Feb 2023 21:38:41 +0000 X-Authority-Reason: nr=8 X-Authority-Analysis: v=2.4 cv=MJClJOVl c=1 sm=1 tr=0 ts=63e567e1 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=Qpd1Fwm_um4UBxpiPKoA:9 a=bWskf8CFYxATgCEA:21 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=YUvLdHHdFPLzbiBthO/qbFzZu2jv3TxsfO4FM6xsfU4=; b=Em9axlyLWymo1dHzLNR2eXdFmK iW9MKYZV6qneyeHgJq168iwkHXOfPM88vqrWVsjR/ZXJTklUDbd3YdEkXV27lvdhT2C7CwZI6r+Cb gizITsJlwUc96Dk9svgTM6BVk; 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 1pQEcr-001ZcE-9t for gdb-patches@sourceware.org; Thu, 09 Feb 2023 14:38:41 -0700 From: Tom Tromey Date: Thu, 09 Feb 2023 14:38:33 -0700 Subject: [PATCH 12/47] Turn value_enclosing_type into method MIME-Version: 1.0 Message-Id: <20230209-submit-value-fixups-2023-v1-12-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: 1pQEcr-001ZcE-9t 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: 13 X-Source-Cap: ZWx5bnJvYmk7ZWx5bnJvYmk7Ym94NTM3OS5ibHVlaG9zdC5jb20= X-Local-Domain: yes X-Spam-Status: No, score=-3027.5 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_enclosing_type to be a method of value. Much of this patch was written by script. --- gdb/ada-lang.c | 6 ++-- gdb/bfin-tdep.c | 4 +-- gdb/c-valprint.c | 8 ++--- gdb/cp-valprint.c | 2 +- gdb/gnu-v3-abi.c | 2 +- gdb/i386-darwin-tdep.c | 2 +- gdb/i386-tdep.c | 6 ++-- gdb/m68k-tdep.c | 2 +- gdb/rl78-tdep.c | 2 +- gdb/tilegx-tdep.c | 4 +-- gdb/valops.c | 33 +++++++++--------- gdb/value.c | 54 +++++++++++++---------------- gdb/value.h | 93 +++++++++++++++++++++++++------------------------- gdb/vax-tdep.c | 2 +- gdb/xstormy16-tdep.c | 4 +-- 15 files changed, 108 insertions(+), 116 deletions(-) diff --git a/gdb/ada-lang.c b/gdb/ada-lang.c index 5aec8b77b14..baffea75657 100644 --- a/gdb/ada-lang.c +++ b/gdb/ada-lang.c @@ -3060,7 +3060,7 @@ ada_value_ptr_subscript (struct value *arr, int arity, struct value **ind) int k; struct value *array_ind = ada_value_ind (arr); struct type *type - = check_typedef (value_enclosing_type (array_ind)); + = check_typedef (array_ind->enclosing_type ()); if (type->code () == TYPE_CODE_ARRAY && TYPE_FIELD_BITSIZE (type, 0) > 0) @@ -3334,7 +3334,7 @@ ada_array_bound (struct value *arr, int n, int which) if (check_typedef (arr->type ())->code () == TYPE_CODE_PTR) arr = value_ind (arr); - arr_type = value_enclosing_type (arr); + arr_type = arr->enclosing_type (); if (ada_is_constrained_packed_array_type (arr_type)) return ada_array_bound (decode_constrained_packed_array (arr), n, which); @@ -3358,7 +3358,7 @@ ada_array_length (struct value *arr, int n) if (check_typedef (arr->type ())->code () == TYPE_CODE_PTR) arr = value_ind (arr); - arr_type = value_enclosing_type (arr); + arr_type = arr->enclosing_type (); if (ada_is_constrained_packed_array_type (arr_type)) return ada_array_length (decode_constrained_packed_array (arr), n); diff --git a/gdb/bfin-tdep.c b/gdb/bfin-tdep.c index 4d84407cc45..e1be4b77071 100644 --- a/gdb/bfin-tdep.c +++ b/gdb/bfin-tdep.c @@ -509,7 +509,7 @@ bfin_push_dummy_call (struct gdbarch *gdbarch, for (i = nargs - 1; i >= 0; i--) { - struct type *value_type = value_enclosing_type (args[i]); + struct type *value_type = args[i]->enclosing_type (); total_len += align_up (value_type->length (), 4); } @@ -525,7 +525,7 @@ bfin_push_dummy_call (struct gdbarch *gdbarch, for (i = nargs - 1; i >= 0; i--) { - struct type *value_type = value_enclosing_type (args[i]); + struct type *value_type = args[i]->enclosing_type (); struct type *arg_type = check_typedef (value_type); int container_len = align_up (arg_type->length (), 4); diff --git a/gdb/c-valprint.c b/gdb/c-valprint.c index 8d28c45cbfc..0a9e4f49ba6 100644 --- a/gdb/c-valprint.c +++ b/gdb/c-valprint.c @@ -571,18 +571,18 @@ c_value_print (struct value *val, struct ui_file *stream, better to leave the object as-is. */ if (!(full && (real_type->length () - < value_enclosing_type (val)->length ()))) + < val->enclosing_type ()->length ()))) val = value_cast (real_type, val); gdb_printf (stream, "(%s%s) ", real_type->name (), full ? "" : _(" [incomplete object]")); } - else if (type != check_typedef (value_enclosing_type (val))) + else if (type != check_typedef (val->enclosing_type ())) { /* No RTTI information, so let's do our best. */ gdb_printf (stream, "(%s ?) ", - value_enclosing_type (val)->name ()); - val = value_cast (value_enclosing_type (val), val); + val->enclosing_type ()->name ()); + val = value_cast (val->enclosing_type (), val); } } diff --git a/gdb/cp-valprint.c b/gdb/cp-valprint.c index 33ff17b8d2b..476ec9c1b1e 100644 --- a/gdb/cp-valprint.c +++ b/gdb/cp-valprint.c @@ -763,7 +763,7 @@ test_print_fields (gdbarch *arch) value *val = allocate_value (the_struct); gdb_byte *contents = value_contents_writeable (val).data (); - store_unsigned_integer (contents, value_enclosing_type (val)->length (), + store_unsigned_integer (contents, val->enclosing_type ()->length (), gdbarch_byte_order (arch), 0xe9); string_file out; diff --git a/gdb/gnu-v3-abi.c b/gdb/gnu-v3-abi.c index d9e0d579259..782f5765d6f 100644 --- a/gdb/gnu-v3-abi.c +++ b/gdb/gnu-v3-abi.c @@ -372,7 +372,7 @@ gnuv3_rtti_type (struct value *value, if (full_p) *full_p = (- offset_to_top == value_embedded_offset (value) - && (value_enclosing_type (value)->length () + && (value->enclosing_type ()->length () >= run_time_type->length ())); if (top_p) *top_p = - offset_to_top; diff --git a/gdb/i386-darwin-tdep.c b/gdb/i386-darwin-tdep.c index d84e5ed8005..abf68ef7c39 100644 --- a/gdb/i386-darwin-tdep.c +++ b/gdb/i386-darwin-tdep.c @@ -183,7 +183,7 @@ i386_darwin_push_dummy_call (struct gdbarch *gdbarch, struct value *function, for (i = 0; i < nargs; i++) { - struct type *arg_type = value_enclosing_type (args[i]); + struct type *arg_type = args[i]->enclosing_type (); if (i386_m128_p (arg_type) && num_m128 < 4) { diff --git a/gdb/i386-tdep.c b/gdb/i386-tdep.c index f82641debee..f2f8db3aa2c 100644 --- a/gdb/i386-tdep.c +++ b/gdb/i386-tdep.c @@ -2725,11 +2725,11 @@ i386_thiscall_push_dummy_call (struct gdbarch *gdbarch, struct value *function, for (i = thiscall ? 1 : 0; i < nargs; i++) { - int len = value_enclosing_type (args[i])->length (); + int len = args[i]->enclosing_type ()->length (); if (write_pass) { - if (i386_16_byte_align_p (value_enclosing_type (args[i]))) + if (i386_16_byte_align_p (args[i]->enclosing_type ())) args_space_used = align_up (args_space_used, 16); write_memory (sp + args_space_used, @@ -2745,7 +2745,7 @@ i386_thiscall_push_dummy_call (struct gdbarch *gdbarch, struct value *function, } else { - if (i386_16_byte_align_p (value_enclosing_type (args[i]))) + if (i386_16_byte_align_p (args[i]->enclosing_type ())) args_space = align_up (args_space, 16); args_space += align_up (len, 4); } diff --git a/gdb/m68k-tdep.c b/gdb/m68k-tdep.c index ae020c89d19..e776060935c 100644 --- a/gdb/m68k-tdep.c +++ b/gdb/m68k-tdep.c @@ -544,7 +544,7 @@ m68k_push_dummy_call (struct gdbarch *gdbarch, struct value *function, /* Push arguments in reverse order. */ for (i = nargs - 1; i >= 0; i--) { - struct type *value_type = value_enclosing_type (args[i]); + struct type *value_type = args[i]->enclosing_type (); int len = value_type->length (); int container_len = (len + 3) & ~3; int offset; diff --git a/gdb/rl78-tdep.c b/gdb/rl78-tdep.c index 4979e09b15f..cd846669169 100644 --- a/gdb/rl78-tdep.c +++ b/gdb/rl78-tdep.c @@ -1340,7 +1340,7 @@ rl78_push_dummy_call (struct gdbarch *gdbarch, struct value *function, /* Push arguments in reverse order. */ for (i = nargs - 1; i >= 0; i--) { - struct type *value_type = value_enclosing_type (args[i]); + struct type *value_type = args[i]->enclosing_type (); int len = value_type->length (); int container_len = (len + 1) & ~1; diff --git a/gdb/tilegx-tdep.c b/gdb/tilegx-tdep.c index 5dfb2376e99..8f005e81dcc 100644 --- a/gdb/tilegx-tdep.c +++ b/gdb/tilegx-tdep.c @@ -298,7 +298,7 @@ tilegx_push_dummy_call (struct gdbarch *gdbarch, for (i = 0; i < nargs && argreg <= TILEGX_R9_REGNUM; i++) { const gdb_byte *val; - typelen = value_enclosing_type (args[i])->length (); + typelen = args[i]->enclosing_type ()->length (); if (typelen > (TILEGX_R9_REGNUM - argreg + 1) * tilegx_reg_size) break; @@ -325,7 +325,7 @@ tilegx_push_dummy_call (struct gdbarch *gdbarch, { const gdb_byte *contents = value_contents (args[j]).data (); - typelen = value_enclosing_type (args[j])->length (); + typelen = args[j]->enclosing_type ()->length (); slacklen = align_up (typelen, 8) - typelen; gdb::byte_vector val (typelen + slacklen); memcpy (val.data (), contents, typelen); diff --git a/gdb/valops.c b/gdb/valops.c index d0ef2b952c3..9fbcf1740d5 100644 --- a/gdb/valops.c +++ b/gdb/valops.c @@ -327,7 +327,7 @@ value_cast_pointers (struct type *type, struct value *arg2, /* No superclass found, just change the pointer type. */ arg2 = value_copy (arg2); arg2->deprecated_set_type (type); - set_value_enclosing_type (arg2, type); + arg2->set_enclosing_type (type); set_value_pointed_to_offset (arg2, 0); /* pai: chk_val */ return arg2; } @@ -649,7 +649,7 @@ value_cast (struct type *type, struct value *arg2) arg2 = value_copy (arg2); arg2->deprecated_set_type (to_type); - set_value_enclosing_type (arg2, to_type); + arg2->set_enclosing_type (to_type); set_value_pointed_to_offset (arg2, 0); /* pai: chk_val */ return arg2; } @@ -1352,7 +1352,7 @@ value_assign (struct value *toval, struct value *fromval) to by TOVAL retains its original dynamic type after assignment. */ if (type->code () == TYPE_CODE_PTR) { - set_value_enclosing_type (val, value_enclosing_type (fromval)); + val->set_enclosing_type (fromval->enclosing_type ()); set_value_pointed_to_offset (val, value_pointed_to_offset (fromval)); } @@ -1371,14 +1371,14 @@ value_repeat (struct value *arg1, int count) if (count < 1) error (_("Invalid number %d of repetitions."), count); - val = allocate_repeat_value (value_enclosing_type (arg1), count); + val = allocate_repeat_value (arg1->enclosing_type (), count); VALUE_LVAL (val) = lval_memory; set_value_address (val, value_address (arg1)); read_value_memory (val, 0, value_stack (val), value_address (val), value_contents_all_raw (val).data (), - type_length_units (value_enclosing_type (val))); + type_length_units (val->enclosing_type ())); return val; } @@ -1568,13 +1568,13 @@ value_addr (struct value *arg1) struct type *type_ptr = lookup_pointer_type (type->target_type ()); struct type *enclosing_type - = check_typedef (value_enclosing_type (arg1)); + = check_typedef (arg1->enclosing_type ()); struct type *enclosing_type_ptr = lookup_pointer_type (enclosing_type->target_type ()); arg2 = value_copy (arg1); arg2->deprecated_set_type (type_ptr); - set_value_enclosing_type (arg2, enclosing_type_ptr); + arg2->set_enclosing_type (enclosing_type_ptr); return arg2; } @@ -1596,8 +1596,7 @@ value_addr (struct value *arg1) /* This may be a pointer to a base subobject; so remember the full derived object's type ... */ - set_value_enclosing_type (arg2, - lookup_pointer_type (value_enclosing_type (arg1))); + arg2->set_enclosing_type (lookup_pointer_type (arg1->enclosing_type ())); /* ... and also the relative position of the subobject in the full object. */ set_value_pointed_to_offset (arg2, value_embedded_offset (arg1)); @@ -1657,7 +1656,7 @@ value_ind (struct value *arg1) /* We may be pointing to something embedded in a larger object. Get the real type of the enclosing object. */ - enc_type = check_typedef (value_enclosing_type (arg1)); + enc_type = check_typedef (arg1->enclosing_type ()); enc_type = enc_type->target_type (); CORE_ADDR base_addr; @@ -1710,17 +1709,17 @@ value_array (int lowbound, int highbound, struct value **elemvec) { error (_("bad array bounds (%d, %d)"), lowbound, highbound); } - typelength = type_length_units (value_enclosing_type (elemvec[0])); + typelength = type_length_units (elemvec[0]->enclosing_type ()); for (idx = 1; idx < nelem; idx++) { - if (type_length_units (value_enclosing_type (elemvec[idx])) + if (type_length_units (elemvec[idx]->enclosing_type ()) != typelength) { error (_("array elements must all be the same size")); } } - arraytype = lookup_array_range_type (value_enclosing_type (elemvec[0]), + arraytype = lookup_array_range_type (elemvec[0]->enclosing_type (), lowbound, highbound); if (!current_language->c_style_arrays_p ()) @@ -2095,7 +2094,7 @@ struct_field_searcher::search (struct value *arg1, LONGEST offset, boffset += value_embedded_offset (arg1) + offset; if (boffset < 0 - || boffset >= value_enclosing_type (arg1)->length ()) + || boffset >= arg1->enclosing_type ()->length ()) { CORE_ADDR base_addr; @@ -3944,14 +3943,14 @@ value_full_object (struct value *argp, real_type = value_rtti_type (argp, &full, &top, &using_enc); /* If no RTTI data, or if object is already complete, do nothing. */ - if (!real_type || real_type == value_enclosing_type (argp)) + if (!real_type || real_type == argp->enclosing_type ()) return argp; /* In a destructor we might see a real type that is a superclass of the object's type. In this case it is better to leave the object as-is. */ if (full - && real_type->length () < value_enclosing_type (argp)->length ()) + && real_type->length () < argp->enclosing_type ()->length ()) return argp; /* If we have the full object, but for some reason the enclosing @@ -3960,7 +3959,7 @@ value_full_object (struct value *argp, if (full) { argp = value_copy (argp); - set_value_enclosing_type (argp, real_type); + argp->set_enclosing_type (real_type); return argp; } diff --git a/gdb/value.c b/gdb/value.c index eca340cad80..dbc87c6d31c 100644 --- a/gdb/value.c +++ b/gdb/value.c @@ -225,7 +225,7 @@ value_entirely_covered_by_range_vector (struct value *value, if (t.offset == 0 && t.length == (TARGET_CHAR_BIT - * value_enclosing_type (value)->length ())) + * value->enclosing_type ()->length ())) return 1; } @@ -710,8 +710,8 @@ value_contents_eq (const struct value *val1, LONGEST offset1, bool value_contents_eq (const struct value *val1, const struct value *val2) { - ULONGEST len1 = check_typedef (value_enclosing_type (val1))->length (); - ULONGEST len2 = check_typedef (value_enclosing_type (val2))->length (); + ULONGEST len1 = check_typedef (val1->enclosing_type ())->length (); + ULONGEST len2 = check_typedef (val2->enclosing_type ())->length (); if (len1 != len2) return false; return value_contents_eq (val1, 0, val2, 0, len1); @@ -912,16 +912,10 @@ value_contents_all_raw (struct value *value) { allocate_value_contents (value); - ULONGEST length = value_enclosing_type (value)->length (); + ULONGEST length = value->enclosing_type ()->length (); return gdb::make_array_view (value->m_contents.get (), length); } -struct type * -value_enclosing_type (const struct value *value) -{ - return value->m_enclosing_type; -} - /* Look at value.h for description. */ struct type * @@ -959,7 +953,7 @@ value_actual_type (struct value *value, int resolve_simple_types, { if (real_type_found) *real_type_found = 1; - result = value_enclosing_type (value); + result = value->enclosing_type (); } } @@ -998,7 +992,7 @@ value_contents_for_printing (struct value *value) if (value->m_lazy) value_fetch_lazy (value); - ULONGEST length = value_enclosing_type (value)->length (); + ULONGEST length = value->enclosing_type ()->length (); return gdb::make_array_view (value->m_contents.get (), length); } @@ -1007,7 +1001,7 @@ value_contents_for_printing_const (const struct value *value) { gdb_assert (!value->m_lazy); - ULONGEST length = value_enclosing_type (value)->length (); + ULONGEST length = value->enclosing_type ()->length (); return gdb::make_array_view (value->m_contents.get (), length); } @@ -1485,7 +1479,7 @@ value_release_to_mark (const struct value *mark) struct value * value_copy (const value *arg) { - struct type *encl_type = value_enclosing_type (arg); + struct type *encl_type = arg->enclosing_type (); struct value *val; if (value_lazy (arg)) @@ -1511,7 +1505,7 @@ value_copy (const value *arg) if (!value_lazy (val) && !value_entirely_optimized_out (val)) { gdb_assert (arg->m_contents != nullptr); - ULONGEST length = value_enclosing_type (arg)->length (); + ULONGEST length = arg->enclosing_type ()->length (); const auto &arg_view = gdb::make_array_view (arg->m_contents.get (), length); copy (arg_view, value_contents_all_raw (val)); @@ -1538,12 +1532,11 @@ struct value * make_cv_value (int cnst, int voltl, struct value *v) { struct type *val_type = v->type (); - struct type *m_enclosing_type = value_enclosing_type (v); + struct type *m_enclosing_type = v->enclosing_type (); struct value *cv_val = value_copy (v); cv_val->deprecated_set_type (make_cv_type (cnst, voltl, val_type, NULL)); - set_value_enclosing_type (cv_val, - make_cv_type (cnst, voltl, m_enclosing_type, NULL)); + cv_val->set_enclosing_type (make_cv_type (cnst, voltl, m_enclosing_type, NULL)); return cv_val; } @@ -1555,7 +1548,7 @@ value_non_lval (struct value *arg) { if (VALUE_LVAL (arg) != not_lval) { - struct type *enc_type = value_enclosing_type (arg); + struct type *enc_type = arg->enclosing_type (); struct value *val = allocate_value (enc_type); copy (value_contents_all (arg), value_contents_all_raw (val)); @@ -2808,17 +2801,16 @@ value_static_field (struct type *type, int fieldno) data. */ void -set_value_enclosing_type (struct value *val, struct type *new_encl_type) +value::set_enclosing_type (struct type *new_encl_type) { - if (new_encl_type->length () > value_enclosing_type (val)->length ()) + if (new_encl_type->length () > enclosing_type ()->length ()) { check_type_length_before_alloc (new_encl_type); - val->m_contents - .reset ((gdb_byte *) xrealloc (val->m_contents.release (), - new_encl_type->length ())); + m_contents.reset ((gdb_byte *) xrealloc (m_contents.release (), + new_encl_type->length ())); } - val->m_enclosing_type = new_encl_type; + m_enclosing_type = new_encl_type; } /* Given a value ARG1 (offset by OFFSET bytes) @@ -2898,12 +2890,12 @@ value_primitive_field (struct value *arg1, LONGEST offset, boffset = arg_type->field (fieldno).loc_bitpos () / 8; if (value_lazy (arg1)) - v = allocate_value_lazy (value_enclosing_type (arg1)); + v = allocate_value_lazy (arg1->enclosing_type ()); else { - v = allocate_value (value_enclosing_type (arg1)); + v = allocate_value (arg1->enclosing_type ()); value_contents_copy_raw (v, 0, arg1, 0, - value_enclosing_type (arg1)->length ()); + arg1->enclosing_type ()->length ()); } v->m_type = type; v->m_offset = arg1->offset (); @@ -3616,7 +3608,7 @@ readjust_indirect_value_type (struct value *value, struct type *enc_type, value->deprecated_set_type (resolved_original_target_type); /* Add embedding info. */ - set_value_enclosing_type (value, enc_type); + value->set_enclosing_type (enc_type); set_value_embedded_offset (value, value_pointed_to_offset (original_value)); /* We may be pointing to an object of some derived type. */ @@ -3637,7 +3629,7 @@ coerce_ref (struct value *arg) if (!TYPE_IS_REFERENCE (value_type_arg_tmp)) return arg; - enc_type = check_typedef (value_enclosing_type (arg)); + enc_type = check_typedef (arg->enclosing_type ()); enc_type = enc_type->target_type (); CORE_ADDR addr = unpack_pointer (arg->type (), value_contents (arg).data ()); @@ -3749,7 +3741,7 @@ value_fetch_lazy_memory (struct value *val) gdb_assert (VALUE_LVAL (val) == lval_memory); CORE_ADDR addr = value_address (val); - struct type *type = check_typedef (value_enclosing_type (val)); + struct type *type = check_typedef (val->enclosing_type ()); if (type->length ()) read_value_memory (val, 0, value_stack (val), diff --git a/gdb/value.h b/gdb/value.h index 360e8c5bc33..73ee8b5c34e 100644 --- a/gdb/value.h +++ b/gdb/value.h @@ -216,6 +216,52 @@ struct value int deprecated_modifiable () const { return m_modifiable; } + /* If a value represents a C++ object, then the `type' field gives the + object's compile-time type. If the object actually belongs to some + class derived from `type', perhaps with other base classes and + additional members, then `type' is just a subobject of the real + thing, and the full object is probably larger than `type' would + suggest. + + If `type' is a dynamic class (i.e. one with a vtable), then GDB can + actually determine the object's run-time type by looking at the + run-time type information in the vtable. When this information is + available, we may elect to read in the entire object, for several + reasons: + + - When printing the value, the user would probably rather see the + full object, not just the limited portion apparent from the + compile-time type. + + - If `type' has virtual base classes, then even printing `type' + alone may require reaching outside the `type' portion of the + object to wherever the virtual base class has been stored. + + When we store the entire object, `enclosing_type' is the run-time + type -- the complete object -- and `embedded_offset' is the offset + of `type' within that larger type, in bytes. The value_contents() + macro takes `embedded_offset' into account, so most GDB code + continues to see the `type' portion of the value, just as the + inferior would. + + If `type' is a pointer to an object, then `enclosing_type' is a + pointer to the object's run-time type, and `pointed_to_offset' is + the offset in bytes from the full object to the pointed-to object + -- that is, the value `embedded_offset' would have if we followed + the pointer and fetched the complete object. (I don't really see + the point. Why not just determine the run-time type when you + indirect, and avoid the special case? The contents don't matter + until you indirect anyway.) + + If we're not doing anything fancy, `enclosing_type' is equal to + `type', and `embedded_offset' is zero, so everything works + normally. */ + + struct type *enclosing_type () const + { return m_enclosing_type; } + + void set_enclosing_type (struct type *new_type); + /* Type of value; either not an lval, or one of the various different possible kinds of lval. */ @@ -383,51 +429,6 @@ struct value std::vector m_optimized_out; }; -/* If a value represents a C++ object, then the `type' field gives the - object's compile-time type. If the object actually belongs to some - class derived from `type', perhaps with other base classes and - additional members, then `type' is just a subobject of the real - thing, and the full object is probably larger than `type' would - suggest. - - If `type' is a dynamic class (i.e. one with a vtable), then GDB can - actually determine the object's run-time type by looking at the - run-time type information in the vtable. When this information is - available, we may elect to read in the entire object, for several - reasons: - - - When printing the value, the user would probably rather see the - full object, not just the limited portion apparent from the - compile-time type. - - - If `type' has virtual base classes, then even printing `type' - alone may require reaching outside the `type' portion of the - object to wherever the virtual base class has been stored. - - When we store the entire object, `enclosing_type' is the run-time - type -- the complete object -- and `embedded_offset' is the offset - of `type' within that larger type, in bytes. The value_contents() - macro takes `embedded_offset' into account, so most GDB code - continues to see the `type' portion of the value, just as the - inferior would. - - If `type' is a pointer to an object, then `enclosing_type' is a - pointer to the object's run-time type, and `pointed_to_offset' is - the offset in bytes from the full object to the pointed-to object - -- that is, the value `embedded_offset' would have if we followed - the pointer and fetched the complete object. (I don't really see - the point. Why not just determine the run-time type when you - indirect, and avoid the special case? The contents don't matter - until you indirect anyway.) - - If we're not doing anything fancy, `enclosing_type' is equal to - `type', and `embedded_offset' is zero, so everything works - normally. */ - -extern struct type *value_enclosing_type (const struct value *); -extern void set_value_enclosing_type (struct value *val, - struct type *new_type); - /* Returns value_type or value_enclosing_type depending on value_print_options.objectprint. @@ -758,7 +759,7 @@ extern void mark_value_bits_unavailable (struct value *value, example, to compare a complete object value with itself, including its enclosing type chunk, you'd do: - int len = check_typedef (value_enclosing_type (val))->length (); + int len = check_typedef (val->enclosing_type ())->length (); value_contents_eq (val, 0, val, 0, len); Returns true iff the set of available/valid contents match. diff --git a/gdb/vax-tdep.c b/gdb/vax-tdep.c index c229e660423..c46010d0b13 100644 --- a/gdb/vax-tdep.c +++ b/gdb/vax-tdep.c @@ -117,7 +117,7 @@ vax_store_arguments (struct regcache *regcache, int nargs, /* Push arguments in reverse order. */ for (i = nargs - 1; i >= 0; i--) { - int len = value_enclosing_type (args[i])->length (); + int len = args[i]->enclosing_type ()->length (); sp -= (len + 3) & ~3; count += (len + 3) / 4; diff --git a/gdb/xstormy16-tdep.c b/gdb/xstormy16-tdep.c index 0c33b9a7554..c12d83213ae 100644 --- a/gdb/xstormy16-tdep.c +++ b/gdb/xstormy16-tdep.c @@ -247,7 +247,7 @@ xstormy16_push_dummy_call (struct gdbarch *gdbarch, would fit in the remaining unused registers. */ for (i = 0; i < nargs && argreg <= E_LST_ARG_REGNUM; i++) { - typelen = value_enclosing_type (args[i])->length (); + typelen = args[i]->enclosing_type ()->length (); if (typelen > E_MAX_RETTYPE_SIZE (argreg)) break; @@ -272,7 +272,7 @@ xstormy16_push_dummy_call (struct gdbarch *gdbarch, { const gdb_byte *bytes = value_contents (args[j]).data (); - typelen = value_enclosing_type (args[j])->length (); + typelen = args[j]->enclosing_type ()->length (); slacklen = typelen & 1; gdb::byte_vector val (typelen + slacklen); memcpy (val.data (), bytes, typelen); From patchwork Thu Feb 9 21:38:34 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tom Tromey X-Patchwork-Id: 64565 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 41FC23881D3E for ; Thu, 9 Feb 2023 21:40:08 +0000 (GMT) X-Original-To: gdb-patches@sourceware.org Delivered-To: gdb-patches@sourceware.org Received: from outbound-ss-761.bluehost.com (outbound-ss-761.bluehost.com [74.220.211.250]) by sourceware.org (Postfix) with ESMTPS id 516D638582A3 for ; Thu, 9 Feb 2023 21:38:42 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 516D638582A3 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 cmgw15.mail.unifiedlayer.com (unknown [10.0.90.130]) by progateway8.mail.pro1.eigbox.com (Postfix) with ESMTP id B844C1004CA4C for ; Thu, 9 Feb 2023 21:38:41 +0000 (UTC) Received: from box5379.bluehost.com ([162.241.216.53]) by cmsmtp with ESMTP id QEcrpZ3qRbdcfQEcrp7MiN; Thu, 09 Feb 2023 21:38:41 +0000 X-Authority-Reason: nr=8 X-Authority-Analysis: v=2.4 cv=AZB0o1bG c=1 sm=1 tr=0 ts=63e567e1 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=giISpiULoCpoO6mOuxsA: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=bK1k6n5wA9qBsoDR64QFlASddxAbJuss0K+jREeSeEk=; b=OgH/WQENwLfkBeNCpNZzAhd7hF lISdXhJsO8TO/4k81FyCE6YXG9rFNen7vS6LgOxQQsWVp4W1rdE4Sn6Mtf5m9ekvOH4CCMhoTEy24 ua532Cx7Da1gEC2uo9oNu4Rml; 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 1pQEcr-001ZcE-EW for gdb-patches@sourceware.org; Thu, 09 Feb 2023 14:38:41 -0700 From: Tom Tromey Date: Thu, 09 Feb 2023 14:38:34 -0700 Subject: [PATCH 13/47] Turn some value offset functions into method MIME-Version: 1.0 Message-Id: <20230209-submit-value-fixups-2023-v1-13-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: 1pQEcr-001ZcE-EW 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: 14 X-Source-Cap: ZWx5bnJvYmk7ZWx5bnJvYmk7Ym94NTM3OS5ibHVlaG9zdC5jb20= X-Local-Domain: yes X-Spam-Status: No, score=-3027.4 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 various offset-related functions to be methods of value. Much of this patch was written by script. --- gdb/ada-valprint.c | 4 ++-- gdb/cp-abi.h | 2 +- gdb/cp-valprint.c | 6 +++--- gdb/d-valprint.c | 2 +- gdb/dwarf2/expr.c | 2 +- gdb/eval.c | 2 +- gdb/gdbtypes.c | 2 +- gdb/gnu-v3-abi.c | 20 +++++++++--------- gdb/go-valprint.c | 2 +- gdb/mi/mi-cmd-stack.c | 2 +- gdb/valops.c | 40 +++++++++++++++++------------------ gdb/value.c | 58 +++++++++++++++------------------------------------ gdb/value.h | 18 +++++++++++----- 13 files changed, 72 insertions(+), 88 deletions(-) diff --git a/gdb/ada-valprint.c b/gdb/ada-valprint.c index 761d3150937..c1004b5f33c 100644 --- a/gdb/ada-valprint.c +++ b/gdb/ada-valprint.c @@ -199,8 +199,8 @@ val_print_packed_array_elements (struct type *type, const gdb_byte *valaddr, if (check_typedef (v0->type ())->length () != check_typedef (v1->type ())->length ()) break; - if (!value_contents_eq (v0, value_embedded_offset (v0), - v1, value_embedded_offset (v1), + if (!value_contents_eq (v0, v0->embedded_offset (), + v1, v1->embedded_offset (), check_typedef (v0->type ())->length ())) break; } diff --git a/gdb/cp-abi.h b/gdb/cp-abi.h index f7c903eca2d..aade336c3cd 100644 --- a/gdb/cp-abi.h +++ b/gdb/cp-abi.h @@ -124,7 +124,7 @@ extern struct value *value_virtual_fn_field (struct value **valuep, of the complete object to the start of the embedded subobject VALUE represents. In other words, the enclosing object starts at VALUE_ADDR (VALUE) + VALUE->offset () + - value_embedded_offset (VALUE) + *TOP + VALUE->embedded_offset () + *TOP - If *USING_ENC is non-zero, then *TOP is the offset from the address of the complete object to the enclosing object stored in VALUE. In other words, the enclosing object starts at diff --git a/gdb/cp-valprint.c b/gdb/cp-valprint.c index 476ec9c1b1e..634f5a94cee 100644 --- a/gdb/cp-valprint.c +++ b/gdb/cp-valprint.c @@ -282,7 +282,7 @@ cp_print_value_fields (struct value *val, struct ui_file *stream, opts->deref_ref = false; v = value_field_bitfield (type, i, valaddr, - value_embedded_offset (val), val); + val->embedded_offset (), val); common_val_print (v, stream, recurse + 1, opts, current_language); @@ -321,7 +321,7 @@ cp_print_value_fields (struct value *val, struct ui_file *stream, { CORE_ADDR addr; - i_offset += value_embedded_offset (val); + i_offset += val->embedded_offset (); addr = extract_typed_address (valaddr + i_offset, i_type); print_function_pointer_address (opts, type->arch (), @@ -432,7 +432,7 @@ cp_print_value (struct value *val, struct ui_file *stream, try { boffset = baseclass_offset (type, i, valaddr, - value_embedded_offset (val), + val->embedded_offset (), address, val); } catch (const gdb_exception_error &ex) diff --git a/gdb/d-valprint.c b/gdb/d-valprint.c index 6c7748efa4c..bebe02c967c 100644 --- a/gdb/d-valprint.c +++ b/gdb/d-valprint.c @@ -81,7 +81,7 @@ d_value_print_inner (struct value *val, struct ui_file *stream, int recurse, switch (type->code ()) { case TYPE_CODE_STRUCT: - ret = dynamic_array_type (type, value_embedded_offset (val), + ret = dynamic_array_type (type, val->embedded_offset (), value_address (val), stream, recurse, val, options); if (ret == 0) diff --git a/gdb/dwarf2/expr.c b/gdb/dwarf2/expr.c index ccce09350d2..0274372a0c4 100644 --- a/gdb/dwarf2/expr.c +++ b/gdb/dwarf2/expr.c @@ -576,7 +576,7 @@ coerce_pieced_ref (const value *value) { struct type *type = check_typedef (value->type ()); - if (value_bits_synthetic_pointer (value, value_embedded_offset (value), + if (value_bits_synthetic_pointer (value, value->embedded_offset (), TARGET_CHAR_BIT * type->length ())) { const piece_closure *closure diff --git a/gdb/eval.c b/gdb/eval.c index 6fa359966ec..87147593ed9 100644 --- a/gdb/eval.c +++ b/gdb/eval.c @@ -965,7 +965,7 @@ structop_base_operation::evaluate_funcall ``this'' changes. */ vals[0] = value_from_longest (lookup_pointer_type (temp->type ()), value_address (temp) - + value_embedded_offset (temp)); + + temp->embedded_offset ()); } /* Take out `this' if needed. */ diff --git a/gdb/gdbtypes.c b/gdb/gdbtypes.c index b14f051c013..75a567dd3f6 100644 --- a/gdb/gdbtypes.c +++ b/gdb/gdbtypes.c @@ -4008,7 +4008,7 @@ is_unique_ancestor (struct type *base, struct value *val) return is_unique_ancestor_worker (base, val->type (), &offset, value_contents_for_printing (val).data (), - value_embedded_offset (val), + val->embedded_offset (), value_address (val), val) == 1; } diff --git a/gdb/gnu-v3-abi.c b/gdb/gnu-v3-abi.c index 782f5765d6f..36d54b9312b 100644 --- a/gdb/gnu-v3-abi.c +++ b/gdb/gnu-v3-abi.c @@ -326,7 +326,7 @@ gnuv3_rtti_type (struct value *value, /* Find the linker symbol for this vtable. */ vtable_symbol = lookup_minimal_symbol_by_pc (value_address (vtable) - + value_embedded_offset (vtable)).minsym; + + vtable->embedded_offset ()).minsym; if (! vtable_symbol) return NULL; @@ -371,7 +371,7 @@ gnuv3_rtti_type (struct value *value, = value_as_long (value_field (vtable, vtable_field_offset_to_top)); if (full_p) - *full_p = (- offset_to_top == value_embedded_offset (value) + *full_p = (- offset_to_top == value->embedded_offset () && (value->enclosing_type ()->length () >= run_time_type->length ())); if (top_p) @@ -804,7 +804,7 @@ hash_value_and_voffset (const void *p) { const struct value_and_voffset *o = (const struct value_and_voffset *) p; - return value_address (o->value) + value_embedded_offset (o->value); + return value_address (o->value) + o->value->embedded_offset (); } /* Equality function for value_and_voffset. */ @@ -815,8 +815,8 @@ eq_value_and_voffset (const void *a, const void *b) const struct value_and_voffset *ova = (const struct value_and_voffset *) a; const struct value_and_voffset *ovb = (const struct value_and_voffset *) b; - return (value_address (ova->value) + value_embedded_offset (ova->value) - == value_address (ovb->value) + value_embedded_offset (ovb->value)); + return (value_address (ova->value) + ova->value->embedded_offset () + == value_address (ovb->value) + ovb->value->embedded_offset ()); } /* Comparison function for value_and_voffset. */ @@ -826,9 +826,9 @@ compare_value_and_voffset (const struct value_and_voffset *va, const struct value_and_voffset *vb) { CORE_ADDR addra = (value_address (va->value) - + value_embedded_offset (va->value)); + + va->value->embedded_offset ()); CORE_ADDR addrb = (value_address (vb->value) - + value_embedded_offset (vb->value)); + + vb->value->embedded_offset ()); return addra < addrb; } @@ -908,7 +908,7 @@ print_one_vtable (struct gdbarch *gdbarch, struct value *value, vtable = gnuv3_get_vtable (gdbarch, type, value_address (value) - + value_embedded_offset (value)); + + value->embedded_offset ()); vt_addr = value_address (value_field (vtable, vtable_field_virtual_functions)); @@ -916,7 +916,7 @@ print_one_vtable (struct gdbarch *gdbarch, struct value *value, TYPE_SAFE_NAME (type), paddress (gdbarch, vt_addr), paddress (gdbarch, (value_address (value) - + value_embedded_offset (value)))); + + value->embedded_offset ()))); for (i = 0; i <= max_voffset; ++i) { @@ -1138,7 +1138,7 @@ gnuv3_get_typeid (struct value *value) && gnuv3_dynamic_class (type)) { struct value *vtable, *typeinfo_value; - CORE_ADDR address = value_address (value) + value_embedded_offset (value); + CORE_ADDR address = value_address (value) + value->embedded_offset (); vtable = gnuv3_get_vtable (gdbarch, type, address); if (vtable == NULL) diff --git a/gdb/go-valprint.c b/gdb/go-valprint.c index 4d3185ed7d2..dce7bd684b4 100644 --- a/gdb/go-valprint.c +++ b/gdb/go-valprint.c @@ -104,7 +104,7 @@ go_language::value_print_inner (struct value *val, struct ui_file *stream, case GO_TYPE_STRING: if (! options->raw) { - print_go_string (type, value_embedded_offset (val), + print_go_string (type, val->embedded_offset (), value_address (val), stream, recurse, val, options); return; diff --git a/gdb/mi/mi-cmd-stack.c b/gdb/mi/mi-cmd-stack.c index 0ac4d6a63cc..abe0d34f042 100644 --- a/gdb/mi/mi-cmd-stack.c +++ b/gdb/mi/mi-cmd-stack.c @@ -507,7 +507,7 @@ list_arg_or_local (const struct frame_arg *arg, enum what_to_list what, to its representation. */ || (val_print_scalar_type_p (arg->val->type ()) && !value_bytes_available (arg->val, - value_embedded_offset (arg->val), + arg->val->embedded_offset (), arg->val->type ()->length ())))) return; diff --git a/gdb/valops.c b/gdb/valops.c index 9fbcf1740d5..e4e8ff8d876 100644 --- a/gdb/valops.c +++ b/gdb/valops.c @@ -275,9 +275,9 @@ value_cast_structs (struct type *type, struct value *v2) if (v) { /* Downcasting is possible (t1 is superclass of v2). */ - CORE_ADDR addr2 = value_address (v2) + value_embedded_offset (v2); + CORE_ADDR addr2 = value_address (v2) + v2->embedded_offset (); - addr2 -= value_address (v) + value_embedded_offset (v); + addr2 -= value_address (v) + v->embedded_offset (); return value_at (type, addr2); } } @@ -328,7 +328,7 @@ value_cast_pointers (struct type *type, struct value *arg2, arg2 = value_copy (arg2); arg2->deprecated_set_type (type); arg2->set_enclosing_type (type); - set_value_pointed_to_offset (arg2, 0); /* pai: chk_val */ + arg2->set_pointed_to_offset (0); /* pai: chk_val */ return arg2; } @@ -650,7 +650,7 @@ value_cast (struct type *type, struct value *arg2) arg2 = value_copy (arg2); arg2->deprecated_set_type (to_type); arg2->set_enclosing_type (to_type); - set_value_pointed_to_offset (arg2, 0); /* pai: chk_val */ + arg2->set_pointed_to_offset (0); /* pai: chk_val */ return arg2; } else if (VALUE_LVAL (arg2) == lval_memory) @@ -884,7 +884,7 @@ value_dynamic_cast (struct type *type, struct value *arg) else if (using_enc) addr += top; else - addr += top + value_embedded_offset (arg); + addr += top + arg->embedded_offset (); /* dynamic_cast means to return a pointer to the most-derived object. */ @@ -903,7 +903,7 @@ value_dynamic_cast (struct type *type, struct value *arg) result = NULL; if (dynamic_cast_check_1 (resolved_type->target_type (), value_contents_for_printing (tem).data (), - value_embedded_offset (tem), + tem->embedded_offset (), value_address (tem), tem, rtti_type, addr, arg_type, @@ -919,7 +919,7 @@ value_dynamic_cast (struct type *type, struct value *arg) if (is_public_ancestor (arg_type, rtti_type) && dynamic_cast_check_2 (resolved_type->target_type (), value_contents_for_printing (tem).data (), - value_embedded_offset (tem), + tem->embedded_offset (), value_address (tem), tem, rtti_type, &result) == 1) return value_cast (type, @@ -1353,7 +1353,7 @@ value_assign (struct value *toval, struct value *fromval) if (type->code () == TYPE_CODE_PTR) { val->set_enclosing_type (fromval->enclosing_type ()); - set_value_pointed_to_offset (val, value_pointed_to_offset (fromval)); + val->set_pointed_to_offset (fromval->pointed_to_offset ()); } return val; @@ -1556,7 +1556,7 @@ value_addr (struct value *arg1) if (TYPE_IS_REFERENCE (type)) { - if (value_bits_synthetic_pointer (arg1, value_embedded_offset (arg1), + if (value_bits_synthetic_pointer (arg1, arg1->embedded_offset (), TARGET_CHAR_BIT * type->length ())) arg1 = coerce_ref (arg1); else @@ -1592,14 +1592,14 @@ value_addr (struct value *arg1) /* Get target memory address. */ arg2 = value_from_pointer (lookup_pointer_type (arg1->type ()), (value_address (arg1) - + value_embedded_offset (arg1))); + + arg1->embedded_offset ())); /* This may be a pointer to a base subobject; so remember the full derived object's type ... */ arg2->set_enclosing_type (lookup_pointer_type (arg1->enclosing_type ())); /* ... and also the relative position of the subobject in the full object. */ - set_value_pointed_to_offset (arg2, value_embedded_offset (arg1)); + arg2->set_pointed_to_offset (arg1->embedded_offset ()); return arg2; } @@ -1671,7 +1671,7 @@ value_ind (struct value *arg1) { /* Retrieve the enclosing object pointed to. */ base_addr = (value_as_address (arg1) - - value_pointed_to_offset (arg1)); + - arg1->pointed_to_offset ()); } arg2 = value_at_lazy (enc_type, base_addr); enc_type = arg2->type (); @@ -2076,7 +2076,7 @@ struct_field_searcher::search (struct value *arg1, LONGEST offset, int found_baseclass = (m_looking_for_baseclass && TYPE_BASECLASS_NAME (type, i) != NULL && (strcmp_iw (m_name, basetype->name ()) == 0)); - LONGEST boffset = value_embedded_offset (arg1) + offset; + LONGEST boffset = arg1->embedded_offset () + offset; if (BASETYPE_VIA_VIRTUAL (type, i)) { @@ -2084,7 +2084,7 @@ struct_field_searcher::search (struct value *arg1, LONGEST offset, boffset = baseclass_offset (type, i, value_contents_for_printing (arg1).data (), - value_embedded_offset (arg1) + offset, + arg1->embedded_offset () + offset, value_address (arg1), arg1); @@ -2092,7 +2092,7 @@ struct_field_searcher::search (struct value *arg1, LONGEST offset, by the user program. Make sure that it still points to a valid memory location. */ - boffset += value_embedded_offset (arg1) + offset; + boffset += arg1->embedded_offset () + offset; if (boffset < 0 || boffset >= arg1->enclosing_type ()->length ()) { @@ -2109,7 +2109,7 @@ struct_field_searcher::search (struct value *arg1, LONGEST offset, { v2 = value_copy (arg1); v2->deprecated_set_type (basetype); - set_value_embedded_offset (v2, boffset); + v2->set_embedded_offset (boffset); } if (found_baseclass) @@ -3978,11 +3978,11 @@ value_full_object (struct value *argp, object, adjusting for the embedded offset of argp if that's what value_rtti_type used for its computation. */ new_val = value_at_lazy (real_type, value_address (argp) - top + - (using_enc ? 0 : value_embedded_offset (argp))); + (using_enc ? 0 : argp->embedded_offset ())); new_val->deprecated_set_type (argp->type ()); - set_value_embedded_offset (new_val, (using_enc - ? top + value_embedded_offset (argp) - : top)); + new_val->set_embedded_offset ((using_enc + ? top + argp->embedded_offset () + : top)); return new_val; } diff --git a/gdb/value.c b/gdb/value.c index dbc87c6d31c..f5400402638 100644 --- a/gdb/value.c +++ b/gdb/value.c @@ -1276,30 +1276,6 @@ value_bits_synthetic_pointer (const struct value *value, length); } -LONGEST -value_embedded_offset (const struct value *value) -{ - return value->m_embedded_offset; -} - -void -set_value_embedded_offset (struct value *value, LONGEST val) -{ - value->m_embedded_offset = val; -} - -LONGEST -value_pointed_to_offset (const struct value *value) -{ - return value->m_pointed_to_offset; -} - -void -set_value_pointed_to_offset (struct value *value, LONGEST val) -{ - value->m_pointed_to_offset = val; -} - const struct lval_funcs * value_computed_funcs (const struct value *v) { @@ -1493,7 +1469,7 @@ value_copy (const value *arg) val->m_bitpos = arg->m_bitpos; val->m_bitsize = arg->m_bitsize; val->m_lazy = arg->m_lazy; - val->m_embedded_offset = value_embedded_offset (arg); + val->m_embedded_offset = arg->embedded_offset (); val->m_pointed_to_offset = arg->m_pointed_to_offset; val->m_modifiable = arg->m_modifiable; val->m_stack = arg->m_stack; @@ -1553,8 +1529,8 @@ value_non_lval (struct value *arg) copy (value_contents_all (arg), value_contents_all_raw (val)); val->m_type = arg->m_type; - set_value_embedded_offset (val, value_embedded_offset (arg)); - set_value_pointed_to_offset (val, value_pointed_to_offset (arg)); + val->set_embedded_offset (arg->embedded_offset ()); + val->set_pointed_to_offset (arg->pointed_to_offset ()); return val; } return arg; @@ -2859,7 +2835,7 @@ value_primitive_field (struct value *arg1, LONGEST offset, v->m_bitpos = bitpos % container_bitsize; else v->m_bitpos = bitpos % 8; - v->m_offset = (value_embedded_offset (arg1) + v->m_offset = (arg1->embedded_offset () + offset + (bitpos - v->m_bitpos) / 8); v->set_parent (arg1); @@ -2883,7 +2859,7 @@ value_primitive_field (struct value *arg1, LONGEST offset, if (BASETYPE_VIA_VIRTUAL (arg_type, fieldno)) boffset = baseclass_offset (arg_type, fieldno, value_contents (arg1).data (), - value_embedded_offset (arg1), + arg1->embedded_offset (), value_address (arg1), arg1); else @@ -2899,7 +2875,7 @@ value_primitive_field (struct value *arg1, LONGEST offset, } v->m_type = type; v->m_offset = arg1->offset (); - v->m_embedded_offset = offset + value_embedded_offset (arg1) + boffset; + v->m_embedded_offset = offset + arg1->embedded_offset () + boffset; } else if (NULL != TYPE_DATA_LOCATION (type)) { @@ -2927,12 +2903,12 @@ value_primitive_field (struct value *arg1, LONGEST offset, else { v = allocate_value (type); - value_contents_copy_raw (v, value_embedded_offset (v), - arg1, value_embedded_offset (arg1) + offset, + value_contents_copy_raw (v, v->embedded_offset (), + arg1, arg1->embedded_offset () + offset, type_length_units (type)); } v->m_offset = (arg1->offset () + offset - + value_embedded_offset (arg1)); + + arg1->embedded_offset ()); } set_value_component_location (v, arg1); return v; @@ -3529,11 +3505,11 @@ value_from_component (struct value *whole, struct type *type, LONGEST offset) else { v = allocate_value (type); - value_contents_copy (v, value_embedded_offset (v), - whole, value_embedded_offset (whole) + offset, + value_contents_copy (v, v->embedded_offset (), + whole, whole->embedded_offset () + offset, type_length_units (type)); } - v->m_offset = whole->offset () + offset + value_embedded_offset (whole); + v->m_offset = whole->offset () + offset + whole->embedded_offset (); set_value_component_location (v, whole); return v; @@ -3557,14 +3533,14 @@ value_from_component_bitsize (struct value *whole, struct type *type, struct value *v = allocate_value (type); - LONGEST dst_offset = TARGET_CHAR_BIT * value_embedded_offset (v); + LONGEST dst_offset = TARGET_CHAR_BIT * v->embedded_offset (); if (is_scalar_type (type) && type_byte_order (type) == BFD_ENDIAN_BIG) dst_offset += TARGET_CHAR_BIT * type->length () - bit_length; value_contents_copy_raw_bitwise (v, dst_offset, whole, TARGET_CHAR_BIT - * value_embedded_offset (whole) + * whole->embedded_offset () + bit_offset, bit_length); return v; @@ -3609,7 +3585,7 @@ readjust_indirect_value_type (struct value *value, struct type *enc_type, /* Add embedding info. */ value->set_enclosing_type (enc_type); - set_value_embedded_offset (value, value_pointed_to_offset (original_value)); + value->set_embedded_offset (original_value->pointed_to_offset ()); /* We may be pointing to an object of some derived type. */ return value_full_object (value, NULL, 0, 0, 0); @@ -3812,8 +3788,8 @@ value_fetch_lazy_register (struct value *val) /* Copy the contents and the unavailability/optimized-out meta-data from NEW_VAL to VAL. */ set_value_lazy (val, 0); - value_contents_copy (val, value_embedded_offset (val), - new_val, value_embedded_offset (new_val), + value_contents_copy (val, val->embedded_offset (), + new_val, new_val->embedded_offset (), type_length_units (type)); if (frame_debug) diff --git a/gdb/value.h b/gdb/value.h index 73ee8b5c34e..5f1bb1cfca7 100644 --- a/gdb/value.h +++ b/gdb/value.h @@ -216,6 +216,19 @@ struct value int deprecated_modifiable () const { return m_modifiable; } + LONGEST pointed_to_offset () const + { return m_pointed_to_offset; } + + void set_pointed_to_offset (LONGEST val) + { m_pointed_to_offset = val; } + + LONGEST embedded_offset () const + { return m_embedded_offset; } + + void set_embedded_offset (LONGEST val) + { m_embedded_offset = val; } + + /* If a value represents a C++ object, then the `type' field gives the object's compile-time type. If the object actually belongs to some class derived from `type', perhaps with other base classes and @@ -445,11 +458,6 @@ extern struct type *value_actual_type (struct value *value, int resolve_simple_types, int *real_type_found); -extern LONGEST value_pointed_to_offset (const struct value *value); -extern void set_value_pointed_to_offset (struct value *value, LONGEST val); -extern LONGEST value_embedded_offset (const struct value *value); -extern void set_value_embedded_offset (struct value *value, LONGEST val); - /* For lval_computed values, this structure holds functions used to retrieve and set the value (or portions of the value). From patchwork Thu Feb 9 21:38:35 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tom Tromey X-Patchwork-Id: 64581 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 3FB363940CF9 for ; Thu, 9 Feb 2023 21:42:34 +0000 (GMT) X-Original-To: gdb-patches@sourceware.org Delivered-To: gdb-patches@sourceware.org Received: from qproxy4-pub.mail.unifiedlayer.com (qproxy4-pub.mail.unifiedlayer.com [66.147.248.250]) by sourceware.org (Postfix) with ESMTPS id A6CF538493CB for ; Thu, 9 Feb 2023 21:39:12 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org A6CF538493CB 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 gproxy1-pub.mail.unifiedlayer.com (gproxy1-pub.mail.unifiedlayer.com [69.89.25.95]) by qproxy4.mail.unifiedlayer.com (Postfix) with ESMTP id CAEE98025F5B for ; Thu, 9 Feb 2023 21:39:11 +0000 (UTC) Received: from cmgw14.mail.unifiedlayer.com (unknown [10.0.90.129]) by progateway3.mail.pro1.eigbox.com (Postfix) with ESMTP id C32D210046FE0 for ; Thu, 9 Feb 2023 21:38:41 +0000 (UTC) Received: from box5379.bluehost.com ([162.241.216.53]) by cmsmtp with ESMTP id QEcrpLOqwGAj8QEcrphq3U; Thu, 09 Feb 2023 21:38:41 +0000 X-Authority-Reason: nr=8 X-Authority-Analysis: v=2.4 cv=UdyU9IeN c=1 sm=1 tr=0 ts=63e567e1 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=XqSF2npsncGvgfwPtBEA: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=nQnp+xdwHK7yOpz0OjgchWy22qm2OpU8BOHCrQt2wdA=; b=E1jxSTMTUwy8IrEGiUlcyzpq9d 2XvpFMedjsV3qOD+4zenQM/rJoB9oNC75DHHeVmjkqUiMZwHH9IkKTLxUAjZs1Tt+nNKBYkLXOnpd CmXnFI87WMqGeDfoSYsxzNNAI; 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 1pQEcr-001ZcE-JN for gdb-patches@sourceware.org; Thu, 09 Feb 2023 14:38:41 -0700 From: Tom Tromey Date: Thu, 09 Feb 2023 14:38:35 -0700 Subject: [PATCH 14/47] Turn value_lazy and set_value_lazy functions into methods MIME-Version: 1.0 Message-Id: <20230209-submit-value-fixups-2023-v1-14-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: 1pQEcr-001ZcE-JN 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: 15 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_H3, RCVD_IN_MSPIKE_WL, 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 the value_lazy and set_value_lazy functions to be methods of value. Much of this patch was written by script. --- gdb/ada-lang.c | 8 +++---- gdb/ada-valprint.c | 2 +- gdb/breakpoint.c | 4 ++-- gdb/c-varobj.c | 4 ++-- gdb/dwarf2/loc.c | 2 +- gdb/eval.c | 6 ++--- gdb/f-lang.c | 8 +++---- gdb/frame.c | 2 +- gdb/gnu-v2-abi.c | 4 ++-- gdb/guile/scm-pretty-print.c | 2 +- gdb/guile/scm-value.c | 4 ++-- gdb/ppc-linux-nat.c | 2 +- gdb/printcmd.c | 2 +- gdb/python/py-prettyprint.c | 2 +- gdb/python/py-value.c | 4 ++-- gdb/stack.c | 10 ++++---- gdb/valops.c | 6 ++--- gdb/valprint.c | 2 +- gdb/value.c | 54 +++++++++++++++++--------------------------- gdb/value.h | 39 +++++++++++++++++--------------- gdb/varobj.c | 16 ++++++------- 21 files changed, 87 insertions(+), 96 deletions(-) diff --git a/gdb/ada-lang.c b/gdb/ada-lang.c index baffea75657..05f8c3fd0da 100644 --- a/gdb/ada-lang.c +++ b/gdb/ada-lang.c @@ -557,7 +557,7 @@ coerce_unspec_val_to_type (struct value *val, struct type *type) if (value_optimized_out (val)) result = allocate_optimized_out_value (type); - else if (value_lazy (val) + else if (val->lazy () /* Be careful not to make a lazy not_lval value. */ || (VALUE_LVAL (val) != not_lval && type->length () > val->type ()->length ())) @@ -2810,7 +2810,7 @@ ada_value_primitive_packed_val (struct value *obj, const gdb_byte *valaddr, v = allocate_value (type); src = valaddr + offset; } - else if (VALUE_LVAL (obj) == lval_memory && value_lazy (obj)) + else if (VALUE_LVAL (obj) == lval_memory && obj->lazy ()) { int src_len = (bit_size + bit_offset + HOST_CHAR_BIT - 1) / 8; gdb_byte *buf; @@ -10852,7 +10852,7 @@ ada_var_msym_value_operation::evaluate_for_cast (struct type *expect_type, an address of the result of a cast (view conversion in Ada). */ if (VALUE_LVAL (val) == lval_memory) { - if (value_lazy (val)) + if (val->lazy ()) value_fetch_lazy (val); VALUE_LVAL (val) = not_lval; } @@ -10874,7 +10874,7 @@ ada_var_value_operation::evaluate_for_cast (struct type *expect_type, an address of the result of a cast (view conversion in Ada). */ if (VALUE_LVAL (val) == lval_memory) { - if (value_lazy (val)) + if (val->lazy ()) value_fetch_lazy (val); VALUE_LVAL (val) = not_lval; } diff --git a/gdb/ada-valprint.c b/gdb/ada-valprint.c index c1004b5f33c..64d7ac18b8c 100644 --- a/gdb/ada-valprint.c +++ b/gdb/ada-valprint.c @@ -982,7 +982,7 @@ ada_val_print_ref (struct type *type, const gdb_byte *valaddr, if (ada_is_tagged_type (deref_val->type (), 1)) deref_val = ada_tag_value_at_base_address (deref_val); - if (value_lazy (deref_val)) + if (deref_val->lazy ()) value_fetch_lazy (deref_val); common_val_print (deref_val, stream, recurse + 1, diff --git a/gdb/breakpoint.c b/gdb/breakpoint.c index 492b0ef7941..aa3045cd37f 100644 --- a/gdb/breakpoint.c +++ b/gdb/breakpoint.c @@ -2068,7 +2068,7 @@ update_watchpoint (struct watchpoint *b, bool reparse) still lazy, that means an error occurred reading it; watch it anyway in case it becomes readable. */ if (VALUE_LVAL (v) == lval_memory - && (v == val_chain[0] || ! value_lazy (v))) + && (v == val_chain[0] || ! v->lazy ())) { struct type *vtype = check_typedef (v->type ()); @@ -10384,7 +10384,7 @@ can_use_hardware_watchpoint (const std::vector &vals) if (VALUE_LVAL (v) == lval_memory) { - if (v != head && value_lazy (v)) + if (v != head && v->lazy ()) /* A lazy memory lvalue in the chain is one that GDB never needed to fetch; we either just used its address (e.g., `a' in `a.b') or we never needed it at all (e.g., `a' diff --git a/gdb/c-varobj.c b/gdb/c-varobj.c index d517c798a6a..00094244ff1 100644 --- a/gdb/c-varobj.c +++ b/gdb/c-varobj.c @@ -506,14 +506,14 @@ c_value_of_variable (const struct varobj *var, } else { - if (var->not_fetched && value_lazy (var->value.get ())) + if (var->not_fetched && var->value.get ()->lazy ()) /* Frozen variable and no value yet. We don't implicitly fetch the value. MI response will use empty string for the value, which is OK. */ return std::string (); gdb_assert (varobj_value_is_changeable_p (var)); - gdb_assert (!value_lazy (var->value.get ())); + gdb_assert (!var->value.get ()->lazy ()); /* If the specified format is the current one, we can reuse print_value. */ diff --git a/gdb/dwarf2/loc.c b/gdb/dwarf2/loc.c index 4af4dfde090..e5b35b8aadb 100644 --- a/gdb/dwarf2/loc.c +++ b/gdb/dwarf2/loc.c @@ -1366,7 +1366,7 @@ value_of_dwarf_reg_entry (struct type *type, frame_info_ptr frame, memcpy (value_contents_raw (val).data (), value_contents_raw (outer_val).data (), checked_type->length ()); - set_value_lazy (val, 0); + val->set_lazy (0); return val; } diff --git a/gdb/eval.c b/gdb/eval.c index 87147593ed9..934ca4c7ea2 100644 --- a/gdb/eval.c +++ b/gdb/eval.c @@ -205,7 +205,7 @@ fetch_subexp_value (struct expression *exp, have a non-lazy previous value to compare with. */ if (result != NULL) { - if (!value_lazy (result)) + if (!result->lazy ()) *valp = result; else { @@ -2877,7 +2877,7 @@ var_msym_value_operation::evaluate_for_cast (struct type *to_type, /* Don't allow e.g. '&(int)var_with_no_debug_info'. */ if (VALUE_LVAL (val) == lval_memory) { - if (value_lazy (val)) + if (val->lazy ()) value_fetch_lazy (val); VALUE_LVAL (val) = not_lval; } @@ -2898,7 +2898,7 @@ var_value_operation::evaluate_for_cast (struct type *to_type, /* Don't allow e.g. '&(int)var_with_no_debug_info'. */ if (VALUE_LVAL (val) == lval_memory) { - if (value_lazy (val)) + if (val->lazy ()) value_fetch_lazy (val); VALUE_LVAL (val) = not_lval; } diff --git a/gdb/f-lang.c b/gdb/f-lang.c index bf2471a1e2c..d88e81c4a11 100644 --- a/gdb/f-lang.c +++ b/gdb/f-lang.c @@ -356,7 +356,7 @@ class fortran_array_repacker_impl m_base_offset (base_offset), m_val (val) { - gdb_assert (!value_lazy (val)); + gdb_assert (!val->lazy ()); } /* Extract an element of ELT_TYPE at offset (M_BASE_OFFSET + ELT_OFF) @@ -1441,7 +1441,7 @@ fortran_undetermined::value_subarray (value *array, /* Now copy the elements from the original ARRAY into the packed array value DEST. */ struct value *dest = allocate_value (repacked_array_type); - if (value_lazy (array) + if (array->lazy () || (total_offset + array_slice_type->length () > check_typedef (array->type ())->length ())) { @@ -1466,7 +1466,7 @@ fortran_undetermined::value_subarray (value *array, the requested slice is outside the values content range then just create a new lazy value pointing at the memory where the contents we're looking for exist. */ - if (value_lazy (array) + if (array->lazy () || (total_offset + array_slice_type->length () > check_typedef (array->type ())->length ())) array = value_at_lazy (array_slice_type, @@ -1476,7 +1476,7 @@ fortran_undetermined::value_subarray (value *array, (array_slice_type, value_contents (array).data () + total_offset, value_address (array) + total_offset); } - else if (!value_lazy (array)) + else if (!array->lazy ()) array = value_from_component (array, array_slice_type, total_offset); else error (_("cannot subscript arrays that are not in memory")); diff --git a/gdb/frame.c b/gdb/frame.c index f845f8caf78..8bb2385d9e7 100644 --- a/gdb/frame.c +++ b/gdb/frame.c @@ -1306,7 +1306,7 @@ frame_unwind_register_value (frame_info_ptr next_frame, int regnum) else gdb_printf (&debug_file, " computed"); - if (value_lazy (value)) + if (value->lazy ()) gdb_printf (&debug_file, " lazy"); else { diff --git a/gdb/gnu-v2-abi.c b/gdb/gnu-v2-abi.c index 632b46f92de..76dc719719f 100644 --- a/gdb/gnu-v2-abi.c +++ b/gdb/gnu-v2-abi.c @@ -161,9 +161,9 @@ gnuv2_virtual_fn_field (struct value **arg1p, struct fn_field * f, int j, arg1->set_offset (arg1->offset () + value_as_long (value_field (entry, 0))); - if (!value_lazy (arg1)) + if (!arg1->lazy ()) { - set_value_lazy (arg1, 1); + arg1->set_lazy (1); value_fetch_lazy (arg1); } diff --git a/gdb/guile/scm-pretty-print.c b/gdb/guile/scm-pretty-print.c index 3e93f3523be..7a680c052d3 100644 --- a/gdb/guile/scm-pretty-print.c +++ b/gdb/guile/scm-pretty-print.c @@ -965,7 +965,7 @@ gdbscm_apply_val_pretty_printer (const struct extension_language_defn *extlang, enum ext_lang_rc result = EXT_LANG_RC_NOP; enum guile_string_repr_result print_result; - if (value_lazy (value)) + if (value->lazy ()) value_fetch_lazy (value); /* No pretty-printer support for unavailable values. */ diff --git a/gdb/guile/scm-value.c b/gdb/guile/scm-value.c index 0d9e15a7404..5b9a4cfb181 100644 --- a/gdb/guile/scm-value.c +++ b/gdb/guile/scm-value.c @@ -1233,7 +1233,7 @@ gdbscm_value_lazy_p (SCM self) = vlscm_get_value_smob_arg_unsafe (self, SCM_ARG1, FUNC_NAME); struct value *value = v_smob->value; - return scm_from_bool (value_lazy (value)); + return scm_from_bool (value->lazy ()); } /* (value-fetch-lazy! ) -> unspecified */ @@ -1247,7 +1247,7 @@ gdbscm_value_fetch_lazy_x (SCM self) return gdbscm_wrap ([=] { - if (value_lazy (value)) + if (value->lazy ()) value_fetch_lazy (value); return SCM_UNSPECIFIED; }); diff --git a/gdb/ppc-linux-nat.c b/gdb/ppc-linux-nat.c index a796364b413..d6d1d0fe1a2 100644 --- a/gdb/ppc-linux-nat.c +++ b/gdb/ppc-linux-nat.c @@ -2462,7 +2462,7 @@ ppc_linux_nat_target::num_memory_accesses (const std::vector /* A lazy memory lvalue is one that GDB never needed to fetch; we either just used its address (e.g., `a' in `a.b') or we never needed it at all (e.g., `a' in `a,b'). */ - if (!value_lazy (v)) + if (!v->lazy ()) found_memory_cnt++; } /* Other kinds of values are not fine. */ diff --git a/gdb/printcmd.c b/gdb/printcmd.c index 2962c7111e4..539285477db 100644 --- a/gdb/printcmd.c +++ b/gdb/printcmd.c @@ -1927,7 +1927,7 @@ x_command (const char *exp, int from_tty) as $__. If the last value has not been fetched from memory then don't fetch it now; instead mark it by voiding the $__ variable. */ - if (value_lazy (last_examine_value.get ())) + if (last_examine_value.get ()->lazy ()) clear_internalvar (lookup_internalvar ("__")); else set_internalvar (lookup_internalvar ("__"), last_examine_value.get ()); diff --git a/gdb/python/py-prettyprint.c b/gdb/python/py-prettyprint.c index 346395e564e..0bd54dab5c6 100644 --- a/gdb/python/py-prettyprint.c +++ b/gdb/python/py-prettyprint.c @@ -578,7 +578,7 @@ gdbpy_apply_val_pretty_printer (const struct extension_language_defn *extlang, struct gdbarch *gdbarch = type->arch (); enum gdbpy_string_repr_result print_result; - if (value_lazy (value)) + if (value->lazy ()) value_fetch_lazy (value); /* No pretty-printer support for unavailable values. */ diff --git a/gdb/python/py-value.c b/gdb/python/py-value.c index c748a87cfc9..0e3bc699819 100644 --- a/gdb/python/py-value.c +++ b/gdb/python/py-value.c @@ -1219,7 +1219,7 @@ valpy_get_is_lazy (PyObject *self, void *closure) try { - opt = value_lazy (value); + opt = value->lazy (); } catch (const gdb_exception &except) { @@ -1240,7 +1240,7 @@ valpy_fetch_lazy (PyObject *self, PyObject *args) try { - if (value_lazy (value)) + if (value->lazy ()) value_fetch_lazy (value); } catch (const gdb_exception &except) diff --git a/gdb/stack.c b/gdb/stack.c index 9e239ed4f67..5efe024c88e 100644 --- a/gdb/stack.c +++ b/gdb/stack.c @@ -580,9 +580,9 @@ read_frame_arg (const frame_print_options &fp_opts, { struct type *type = val->type (); - if (value_lazy (val)) + if (val->lazy ()) value_fetch_lazy (val); - if (value_lazy (entryval)) + if (entryval->lazy ()) value_fetch_lazy (entryval); if (value_contents_eq (val, 0, entryval, 0, type->length ())) @@ -599,12 +599,12 @@ read_frame_arg (const frame_print_options &fp_opts, struct type *type_deref; val_deref = coerce_ref (val); - if (value_lazy (val_deref)) + if (val_deref->lazy ()) value_fetch_lazy (val_deref); type_deref = val_deref->type (); entryval_deref = coerce_ref (entryval); - if (value_lazy (entryval_deref)) + if (entryval_deref->lazy ()) value_fetch_lazy (entryval_deref); /* If the reference addresses match but dereferenced @@ -2749,7 +2749,7 @@ return_command (const char *retval_exp, int from_tty) /* Make sure the value is fully evaluated. It may live in the stack frame we're about to pop. */ - if (value_lazy (return_value)) + if (return_value->lazy ()) value_fetch_lazy (return_value); if (thisfun != NULL) diff --git a/gdb/valops.c b/gdb/valops.c index e4e8ff8d876..cfa21631850 100644 --- a/gdb/valops.c +++ b/gdb/valops.c @@ -1343,7 +1343,7 @@ value_assign (struct value *toval, struct value *fromval) information, but its contents are updated from FROMVAL. This implies the returned value is not lazy, even if TOVAL was. */ val = value_copy (toval); - set_value_lazy (val, 0); + val->set_lazy (0); copy (value_contents (fromval), value_contents_raw (val)); /* We copy over the enclosing type and pointed-to offset from FROMVAL @@ -1406,7 +1406,7 @@ address_of_variable (struct symbol *var, const struct block *b) val = value_of_variable (var, b); type = val->type (); - if ((VALUE_LVAL (val) == lval_memory && value_lazy (val)) + if ((VALUE_LVAL (val) == lval_memory && val->lazy ()) || type->code () == TYPE_CODE_FUNC) { CORE_ADDR addr = value_address (val); @@ -4078,7 +4078,7 @@ value_slice (struct value *array, int lowbound, int length) slice_range_type); slice_type->set_code (array_type->code ()); - if (VALUE_LVAL (array) == lval_memory && value_lazy (array)) + if (VALUE_LVAL (array) == lval_memory && array->lazy ()) slice = allocate_value_lazy (slice_type); else { diff --git a/gdb/valprint.c b/gdb/valprint.c index 3899d915981..6aef98e37c1 100644 --- a/gdb/valprint.c +++ b/gdb/valprint.c @@ -1043,7 +1043,7 @@ common_val_print (struct value *value, struct ui_file *stream, int recurse, get a fixed representation of our value. */ value = ada_to_fixed_value (value); - if (value_lazy (value)) + if (value->lazy ()) value_fetch_lazy (value); struct value_print_options local_opts = *options; diff --git a/gdb/value.c b/gdb/value.c index f5400402638..46aeeec49b2 100644 --- a/gdb/value.c +++ b/gdb/value.c @@ -888,7 +888,7 @@ allocate_optimized_out_value (struct type *type) struct value *retval = allocate_value_lazy (type); mark_value_bytes_optimized_out (retval, 0, type->length ()); - set_value_lazy (retval, 0); + retval->set_lazy (0); return retval; } @@ -1161,18 +1161,6 @@ value_contents_copy (struct value *dst, LONGEST dst_offset, value_contents_copy_raw (dst, dst_offset, src, src_offset, length); } -int -value_lazy (const struct value *value) -{ - return value->m_lazy; -} - -void -set_value_lazy (struct value *value, int val) -{ - value->m_lazy = val; -} - int value_stack (const struct value *value) { @@ -1458,7 +1446,7 @@ value_copy (const value *arg) struct type *encl_type = arg->enclosing_type (); struct value *val; - if (value_lazy (arg)) + if (arg->lazy ()) val = allocate_value_lazy (encl_type); else val = allocate_value (encl_type); @@ -1478,7 +1466,7 @@ value_copy (const value *arg) val->m_unavailable = arg->m_unavailable; val->m_optimized_out = arg->m_optimized_out; - if (!value_lazy (val) && !value_entirely_optimized_out (val)) + if (!val->lazy () && !value_entirely_optimized_out (val)) { gdb_assert (arg->m_contents != nullptr); ULONGEST length = arg->enclosing_type ()->length (); @@ -1602,7 +1590,7 @@ set_value_component_location (struct value *component, change to how values work in GDB. */ if (VALUE_LVAL (component) == lval_internalvar_component) { - gdb_assert (value_lazy (component)); + gdb_assert (component->lazy ()); VALUE_LVAL (component) = lval_memory; } else @@ -1623,7 +1611,7 @@ record_latest_value (struct value *val) In particular, "set $1 = 50" should not affect the variable from which the value was taken, and fast watchpoints should be able to assume that a value on the value history never changes. */ - if (value_lazy (val)) + if (val->lazy ()) value_fetch_lazy (val); /* We preserve VALUE_LVAL so that the user can find out where it was fetched from. This is a bit dubious, because then *&$1 does not just return $1 @@ -1986,7 +1974,7 @@ value_of_internalvar (struct gdbarch *gdbarch, struct internalvar *var) case INTERNALVAR_VALUE: val = value_copy (var->u.value); - if (value_lazy (val)) + if (val->lazy ()) value_fetch_lazy (val); break; @@ -2126,7 +2114,7 @@ set_internalvar (struct internalvar *var, struct value *val) /* Force the value to be fetched from the target now, to avoid problems later when this internalvar is referenced and the target is gone or has changed. */ - if (value_lazy (copy)) + if (copy->lazy ()) value_fetch_lazy (copy); /* Release the value from the value chain to prevent it from being @@ -2839,7 +2827,7 @@ value_primitive_field (struct value *arg1, LONGEST offset, + offset + (bitpos - v->m_bitpos) / 8); v->set_parent (arg1); - if (!value_lazy (arg1)) + if (!arg1->lazy ()) value_fetch_lazy (v); } else if (fieldno < TYPE_N_BASECLASSES (arg_type)) @@ -2850,7 +2838,7 @@ value_primitive_field (struct value *arg1, LONGEST offset, LONGEST boffset; /* Lazy register values with offsets are not supported. */ - if (VALUE_LVAL (arg1) == lval_register && value_lazy (arg1)) + if (VALUE_LVAL (arg1) == lval_register && arg1->lazy ()) value_fetch_lazy (arg1); /* We special case virtual inheritance here because this @@ -2865,7 +2853,7 @@ value_primitive_field (struct value *arg1, LONGEST offset, else boffset = arg_type->field (fieldno).loc_bitpos () / 8; - if (value_lazy (arg1)) + if (arg1->lazy ()) v = allocate_value_lazy (arg1->enclosing_type ()); else { @@ -2895,10 +2883,10 @@ value_primitive_field (struct value *arg1, LONGEST offset, / (HOST_CHAR_BIT * unit_size)); /* Lazy register values with offsets are not supported. */ - if (VALUE_LVAL (arg1) == lval_register && value_lazy (arg1)) + if (VALUE_LVAL (arg1) == lval_register && arg1->lazy ()) value_fetch_lazy (arg1); - if (value_lazy (arg1)) + if (arg1->lazy ()) v = allocate_value_lazy (type); else { @@ -3500,7 +3488,7 @@ value_from_component (struct value *whole, struct type *type, LONGEST offset) { struct value *v; - if (VALUE_LVAL (whole) == lval_memory && value_lazy (whole)) + if (VALUE_LVAL (whole) == lval_memory && whole->lazy ()) v = allocate_value_lazy (type); else { @@ -3521,7 +3509,7 @@ struct value * value_from_component_bitsize (struct value *whole, struct type *type, LONGEST bit_offset, LONGEST bit_length) { - gdb_assert (!value_lazy (whole)); + gdb_assert (!whole->lazy ()); /* Preserve lvalue-ness if possible. This is needed to avoid array-printing failures (including crashes) when printing Ada @@ -3701,7 +3689,7 @@ value_fetch_lazy_bitfield (struct value *val) value have been fetched. */ struct value *parent = val->parent (); - if (value_lazy (parent)) + if (parent->lazy ()) value_fetch_lazy (parent); unpack_value_bitfield (val, val->bitpos (), val->bitsize (), @@ -3739,7 +3727,7 @@ value_fetch_lazy_register (struct value *val) refer to the entire register. */ gdb_assert (val->offset () == 0); - while (VALUE_LVAL (new_val) == lval_register && value_lazy (new_val)) + while (VALUE_LVAL (new_val) == lval_register && new_val->lazy ()) { struct frame_id next_frame_id = VALUE_NEXT_FRAME_ID (new_val); @@ -3775,19 +3763,19 @@ value_fetch_lazy_register (struct value *val) any case, it should always be an internal error to end up in this situation. */ if (VALUE_LVAL (new_val) == lval_register - && value_lazy (new_val) + && new_val->lazy () && VALUE_NEXT_FRAME_ID (new_val) == next_frame_id) internal_error (_("infinite loop while fetching a register")); } /* If it's still lazy (for instance, a saved register on the stack), fetch it. */ - if (value_lazy (new_val)) + if (new_val->lazy ()) value_fetch_lazy (new_val); /* Copy the contents and the unavailability/optimized-out meta-data from NEW_VAL to VAL. */ - set_value_lazy (val, 0); + val->set_lazy (0); value_contents_copy (val, val->embedded_offset (), new_val, new_val->embedded_offset (), type_length_units (type)); @@ -3854,7 +3842,7 @@ value_fetch_lazy_register (struct value *val) void value_fetch_lazy (struct value *val) { - gdb_assert (value_lazy (val)); + gdb_assert (val->lazy ()); allocate_value_contents (val); /* A value is either lazy, or fully fetched. The availability/validity is only established as we try to fetch a @@ -3877,7 +3865,7 @@ value_fetch_lazy (struct value *val) else internal_error (_("Unexpected lazy value type.")); - set_value_lazy (val, 0); + val->set_lazy (0); } /* Implementation of the convenience function $_isvoid. */ diff --git a/gdb/value.h b/gdb/value.h index 5f1bb1cfca7..a41bd2f4fd2 100644 --- a/gdb/value.h +++ b/gdb/value.h @@ -228,6 +228,27 @@ struct value void set_embedded_offset (LONGEST val) { m_embedded_offset = val; } + /* If zero, contents of this value are in the contents field. If + nonzero, contents are in inferior. If the lval field is lval_memory, + the contents are in inferior memory at location.address plus offset. + The lval field may also be lval_register. + + WARNING: This field is used by the code which handles watchpoints + (see breakpoint.c) to decide whether a particular value can be + watched by hardware watchpoints. If the lazy flag is set for some + member of a value chain, it is assumed that this member of the + chain doesn't need to be watched as part of watching the value + itself. This is how GDB avoids watching the entire struct or array + when the user wants to watch a single struct member or array + element. If you ever change the way lazy flag is set and reset, be + sure to consider this use as well! */ + + int lazy () const + { return m_lazy; } + + void set_lazy (int val) + { m_lazy = val; } + /* If a value represents a C++ object, then the `type' field gives the object's compile-time type. If the object actually belongs to some @@ -537,24 +558,6 @@ extern const struct lval_funcs *value_computed_funcs (const struct value *); extern void *value_computed_closure (const struct value *value); -/* If zero, contents of this value are in the contents field. If - nonzero, contents are in inferior. If the lval field is lval_memory, - the contents are in inferior memory at location.address plus offset. - The lval field may also be lval_register. - - WARNING: This field is used by the code which handles watchpoints - (see breakpoint.c) to decide whether a particular value can be - watched by hardware watchpoints. If the lazy flag is set for some - member of a value chain, it is assumed that this member of the - chain doesn't need to be watched as part of watching the value - itself. This is how GDB avoids watching the entire struct or array - when the user wants to watch a single struct member or array - element. If you ever change the way lazy flag is set and reset, be - sure to consider this use as well! */ - -extern int value_lazy (const struct value *); -extern void set_value_lazy (struct value *value, int val); - extern int value_stack (const struct value *); extern void set_value_stack (struct value *value, int val); diff --git a/gdb/varobj.c b/gdb/varobj.c index fb846fd65c7..0e023c09cf8 100644 --- a/gdb/varobj.c +++ b/gdb/varobj.c @@ -504,7 +504,7 @@ varobj_set_display_format (struct varobj *var, } if (varobj_value_is_changeable_p (var) - && var->value != nullptr && !value_lazy (var->value.get ())) + && var->value != nullptr && !var->value.get ()->lazy ()) { var->print_value = varobj_value_get_print_value (var->value.get (), var->format, var); @@ -1007,7 +1007,7 @@ varobj_set_value (struct varobj *var, const char *expression) gdb_assert (varobj_value_is_changeable_p (var)); /* The value of a changeable variable object must not be lazy. */ - gdb_assert (!value_lazy (var->value.get ())); + gdb_assert (!var->value.get ()->lazy ()); /* Need to coerce the input. We want to check if the value of the variable object will be different @@ -1247,7 +1247,7 @@ install_new_value (struct varobj *var, struct value *value, bool initial) that is we'll be comparing values of this type, fetch the value now. Otherwise, on the next update the old value will be lazy, which means we've lost that old value. */ - if (need_to_fetch && value && value_lazy (value)) + if (need_to_fetch && value && value->lazy ()) { const struct varobj *parent = var->parent; bool frozen = var->frozen; @@ -1292,7 +1292,7 @@ install_new_value (struct varobj *var, struct value *value, bool initial) lazy -- if it is, the code above has decided that the value should not be fetched. */ std::string print_value; - if (value != NULL && !value_lazy (value) + if (value != NULL && !value->lazy () && var->dynamic->pretty_printer == NULL) print_value = varobj_value_get_print_value (value, var->format, var); @@ -1312,7 +1312,7 @@ install_new_value (struct varobj *var, struct value *value, bool initial) { /* Try to compare the values. That requires that both values are non-lazy. */ - if (var->not_fetched && value_lazy (var->value.get ())) + if (var->not_fetched && var->value.get ()->lazy ()) { /* This is a frozen varobj and the value was never read. Presumably, UI shows some "never read" indicator. @@ -1330,8 +1330,8 @@ install_new_value (struct varobj *var, struct value *value, bool initial) } else { - gdb_assert (!value_lazy (var->value.get ())); - gdb_assert (!value_lazy (value)); + gdb_assert (!var->value.get ()->lazy ()); + gdb_assert (!value->lazy ()); gdb_assert (!var->print_value.empty () && !print_value.empty ()); if (var->print_value != print_value) @@ -1351,7 +1351,7 @@ install_new_value (struct varobj *var, struct value *value, bool initial) /* We must always keep the new value, since children depend on it. */ var->value = value_holder; - if (value && value_lazy (value) && intentionally_not_fetched) + if (value && value->lazy () && intentionally_not_fetched) var->not_fetched = true; else var->not_fetched = false; From patchwork Thu Feb 9 21:38:36 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tom Tromey X-Patchwork-Id: 64566 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 58833388E821 for ; Thu, 9 Feb 2023 21:40:10 +0000 (GMT) X-Original-To: gdb-patches@sourceware.org Delivered-To: gdb-patches@sourceware.org Received: from outbound-ss-761.bluehost.com (outbound-ss-761.bluehost.com [74.220.211.250]) by sourceware.org (Postfix) with ESMTPS id 7A28C3858000 for ; Thu, 9 Feb 2023 21:38:42 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 7A28C3858000 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 progateway8.mail.pro1.eigbox.com (Postfix) with ESMTP id E1EB61004CA48 for ; Thu, 9 Feb 2023 21:38:41 +0000 (UTC) Received: from box5379.bluehost.com ([162.241.216.53]) by cmsmtp with ESMTP id QEcrpzBOyP796QEcrpwoWU; Thu, 09 Feb 2023 21:38:41 +0000 X-Authority-Reason: nr=8 X-Authority-Analysis: v=2.4 cv=MJClJOVl c=1 sm=1 tr=0 ts=63e567e1 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=QBX5rj4JYO1zUa3VHh0A: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=hz0siKam7eKpXe8+b8bX2nMMeRyee8ihA/fnLcAX1is=; b=ARz7lY2yhbUDNnGtfdtVcCRWm3 0MGk8xkGNwHZLQWgm9cS4TAr8LJKF7G3/GFyY+6oa9UR7piBAnsjNCAa80xszgwNioJ6MmSHLa2Ww 4i9zAb4LdJHv9zi6YwxnNLrLx; 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 1pQEcr-001ZcE-Od for gdb-patches@sourceware.org; Thu, 09 Feb 2023 14:38:41 -0700 From: Tom Tromey Date: Thu, 09 Feb 2023 14:38:36 -0700 Subject: [PATCH 15/47] Turn value_stack and set_value_stack functions into methods MIME-Version: 1.0 Message-Id: <20230209-submit-value-fixups-2023-v1-15-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: 1pQEcr-001ZcE-Od 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: 16 X-Source-Cap: ZWx5bnJvYmk7ZWx5bnJvYmk7Ym94NTM3OS5ibHVlaG9zdC5jb20= X-Local-Domain: yes X-Spam-Status: No, score=-3027.4 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 the value_stack and set_value_stack functions to be methods of value. --- gdb/dwarf2/expr.c | 2 +- gdb/frame-unwind.c | 2 +- gdb/valops.c | 2 +- gdb/value.c | 14 +------------- gdb/value.h | 9 ++++++--- 5 files changed, 10 insertions(+), 19 deletions(-) diff --git a/gdb/dwarf2/expr.c b/gdb/dwarf2/expr.c index 0274372a0c4..292ac8bb559 100644 --- a/gdb/dwarf2/expr.c +++ b/gdb/dwarf2/expr.c @@ -1005,7 +1005,7 @@ dwarf_expr_context::fetch_result (struct type *type, struct type *subobj_type, retval = value_at_lazy (subobj_type, address + subobj_offset); if (in_stack_memory) - set_value_stack (retval, 1); + retval->set_stack (1); } break; diff --git a/gdb/frame-unwind.c b/gdb/frame-unwind.c index b708c64f967..1e5e821beba 100644 --- a/gdb/frame-unwind.c +++ b/gdb/frame-unwind.c @@ -288,7 +288,7 @@ frame_unwind_got_memory (frame_info_ptr frame, int regnum, CORE_ADDR addr) struct gdbarch *gdbarch = frame_unwind_arch (frame); struct value *v = value_at_lazy (register_type (gdbarch, regnum), addr); - set_value_stack (v, 1); + v->set_stack (1); return v; } diff --git a/gdb/valops.c b/gdb/valops.c index cfa21631850..b4e67951118 100644 --- a/gdb/valops.c +++ b/gdb/valops.c @@ -1376,7 +1376,7 @@ value_repeat (struct value *arg1, int count) VALUE_LVAL (val) = lval_memory; set_value_address (val, value_address (arg1)); - read_value_memory (val, 0, value_stack (val), value_address (val), + read_value_memory (val, 0, val->stack (), value_address (val), value_contents_all_raw (val).data (), type_length_units (val->enclosing_type ())); diff --git a/gdb/value.c b/gdb/value.c index 46aeeec49b2..6607d871fca 100644 --- a/gdb/value.c +++ b/gdb/value.c @@ -1161,18 +1161,6 @@ value_contents_copy (struct value *dst, LONGEST dst_offset, value_contents_copy_raw (dst, dst_offset, src, src_offset, length); } -int -value_stack (const struct value *value) -{ - return value->m_stack; -} - -void -set_value_stack (struct value *value, int val) -{ - value->m_stack = val; -} - gdb::array_view value_contents (struct value *value) { @@ -3708,7 +3696,7 @@ value_fetch_lazy_memory (struct value *val) struct type *type = check_typedef (val->enclosing_type ()); if (type->length ()) - read_value_memory (val, 0, value_stack (val), + read_value_memory (val, 0, val->stack (), addr, value_contents_all_raw (val).data (), type_length_units (type)); } diff --git a/gdb/value.h b/gdb/value.h index a41bd2f4fd2..2d311c69efb 100644 --- a/gdb/value.h +++ b/gdb/value.h @@ -296,6 +296,12 @@ struct value void set_enclosing_type (struct type *new_type); + int stack () const + { return m_stack; } + + void set_stack (int val) + { m_stack = val; } + /* Type of value; either not an lval, or one of the various different possible kinds of lval. */ @@ -558,9 +564,6 @@ extern const struct lval_funcs *value_computed_funcs (const struct value *); extern void *value_computed_closure (const struct value *value); -extern int value_stack (const struct value *); -extern void set_value_stack (struct value *value, int val); - /* Throw an error complaining that the value has been optimized out. */ From patchwork Thu Feb 9 21:38:37 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tom Tromey X-Patchwork-Id: 64568 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 644F6382EF3C for ; Thu, 9 Feb 2023 21:40:29 +0000 (GMT) X-Original-To: gdb-patches@sourceware.org Delivered-To: gdb-patches@sourceware.org Received: from gproxy3-pub.mail.unifiedlayer.com (gproxy3-pub.mail.unifiedlayer.com [69.89.30.42]) by sourceware.org (Postfix) with ESMTPS id AFF81385800C for ; Thu, 9 Feb 2023 21:38:42 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org AFF81385800C 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 progateway5.mail.pro1.eigbox.com (Postfix) with ESMTP id 134BC10073826 for ; Thu, 9 Feb 2023 21:38:42 +0000 (UTC) Received: from box5379.bluehost.com ([162.241.216.53]) by cmsmtp with ESMTP id QEcspzBP4P796QEcspwoWa; Thu, 09 Feb 2023 21:38:42 +0000 X-Authority-Reason: nr=8 X-Authority-Analysis: v=2.4 cv=MJClJOVl c=1 sm=1 tr=0 ts=63e567e2 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=Zij_WFtluohOMlTzaY8A: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=xrKVtNYHnrk+9kqPsGfrLpXL6GCYpWaceh8ZhYbeIQs=; b=QSYMfoFltdVP2wkhY1Fpypau34 1/nUogyJmfJ/kAWtTPcj4nRu6JE1l4tR2KJ6+X2FoeVOypk93uo4F+iO5PRZ0ZDPwN4cT2CmvavK2 vAzCk4ygbUwV8dPBZBs8gBIsF; 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 1pQEcr-001ZcE-Ss for gdb-patches@sourceware.org; Thu, 09 Feb 2023 14:38:41 -0700 From: Tom Tromey Date: Thu, 09 Feb 2023 14:38:37 -0700 Subject: [PATCH 16/47] Turn value_computed_closure and value_computed_funcs functions into methods MIME-Version: 1.0 Message-Id: <20230209-submit-value-fixups-2023-v1-16-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: 1pQEcr-001ZcE-Ss 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: 17 X-Source-Cap: ZWx5bnJvYmk7ZWx5bnJvYmk7Ym94NTM3OS5ibHVlaG9zdC5jb20= X-Local-Domain: yes X-Spam-Status: No, score=-3027.4 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 the value_computed_funcs and value_computed_closure functions to be methods of value. --- gdb/dwarf2/expr.c | 12 ++++++------ gdb/dwarf2/loc.c | 6 +++--- gdb/opencl-lang.c | 10 +++++----- gdb/valops.c | 4 ++-- gdb/value.c | 18 +++++++++--------- gdb/value.h | 18 +++++++++--------- 6 files changed, 34 insertions(+), 34 deletions(-) diff --git a/gdb/dwarf2/expr.c b/gdb/dwarf2/expr.c index 292ac8bb559..8d845e892e3 100644 --- a/gdb/dwarf2/expr.c +++ b/gdb/dwarf2/expr.c @@ -149,7 +149,7 @@ rw_pieced_value (value *v, value *from, bool check_optimized) gdb_byte *v_contents; const gdb_byte *from_contents; piece_closure *c - = (piece_closure *) value_computed_closure (v); + = (piece_closure *) v->computed_closure (); gdb::byte_vector buffer; bool bits_big_endian = type_byte_order (v->type ()) == BFD_ENDIAN_BIG; @@ -463,7 +463,7 @@ static int check_pieced_synthetic_pointer (const value *value, LONGEST bit_offset, int bit_length) { - piece_closure *c = (piece_closure *) value_computed_closure (value); + piece_closure *c = (piece_closure *) value->computed_closure (); int i; bit_offset += 8 * value->offset (); @@ -503,7 +503,7 @@ static value * indirect_pieced_value (value *value) { piece_closure *c - = (piece_closure *) value_computed_closure (value); + = (piece_closure *) value->computed_closure (); int i; dwarf_expr_piece *piece = NULL; @@ -580,7 +580,7 @@ coerce_pieced_ref (const value *value) TARGET_CHAR_BIT * type->length ())) { const piece_closure *closure - = (piece_closure *) value_computed_closure (value); + = (piece_closure *) value->computed_closure (); frame_info_ptr frame = get_selected_frame (_("No frame selected.")); @@ -604,7 +604,7 @@ coerce_pieced_ref (const value *value) static void * copy_pieced_value_closure (const value *v) { - piece_closure *c = (piece_closure *) value_computed_closure (v); + piece_closure *c = (piece_closure *) v->computed_closure (); ++c->refc; return c; @@ -613,7 +613,7 @@ copy_pieced_value_closure (const value *v) static void free_pieced_value_closure (value *v) { - piece_closure *c = (piece_closure *) value_computed_closure (v); + piece_closure *c = (piece_closure *) v->computed_closure (); --c->refc; if (c->refc == 0) diff --git a/gdb/dwarf2/loc.c b/gdb/dwarf2/loc.c index e5b35b8aadb..e975f280cfc 100644 --- a/gdb/dwarf2/loc.c +++ b/gdb/dwarf2/loc.c @@ -1279,7 +1279,7 @@ entry_data_value_coerce_ref (const struct value *value) if (!TYPE_IS_REFERENCE (checked_type)) return NULL; - target_val = (struct value *) value_computed_closure (value); + target_val = (struct value *) value->computed_closure (); value_incref (target_val); return target_val; } @@ -1289,7 +1289,7 @@ entry_data_value_coerce_ref (const struct value *value) static void * entry_data_value_copy_closure (const struct value *v) { - struct value *target_val = (struct value *) value_computed_closure (v); + struct value *target_val = (struct value *) v->computed_closure (); value_incref (target_val); return target_val; @@ -1300,7 +1300,7 @@ entry_data_value_copy_closure (const struct value *v) static void entry_data_value_free_closure (struct value *v) { - struct value *target_val = (struct value *) value_computed_closure (v); + struct value *target_val = (struct value *) v->computed_closure (); value_decref (target_val); } diff --git a/gdb/opencl-lang.c b/gdb/opencl-lang.c index 8c59e823d5c..f7a22b35931 100644 --- a/gdb/opencl-lang.c +++ b/gdb/opencl-lang.c @@ -119,7 +119,7 @@ allocate_lval_closure (int *indices, int n, struct value *val) static void lval_func_read (struct value *v) { - struct lval_closure *c = (struct lval_closure *) value_computed_closure (v); + struct lval_closure *c = (struct lval_closure *) v->computed_closure (); struct type *type = check_typedef (v->type ()); struct type *eltype = check_typedef (c->val->type ())->target_type (); LONGEST offset = v->offset (); @@ -149,7 +149,7 @@ lval_func_write (struct value *v, struct value *fromval) { scoped_value_mark mark; - struct lval_closure *c = (struct lval_closure *) value_computed_closure (v); + struct lval_closure *c = (struct lval_closure *) v->computed_closure (); struct type *type = check_typedef (v->type ()); struct type *eltype = check_typedef (c->val->type ())->target_type (); LONGEST offset = v->offset (); @@ -194,7 +194,7 @@ static int lval_func_check_synthetic_pointer (const struct value *v, LONGEST offset, int length) { - struct lval_closure *c = (struct lval_closure *) value_computed_closure (v); + struct lval_closure *c = (struct lval_closure *) v->computed_closure (); /* Size of the target type in bits. */ int elsize = check_typedef (c->val->type ())->target_type ()->length () * 8; @@ -227,7 +227,7 @@ lval_func_check_synthetic_pointer (const struct value *v, static void * lval_func_copy_closure (const struct value *v) { - struct lval_closure *c = (struct lval_closure *) value_computed_closure (v); + struct lval_closure *c = (struct lval_closure *) v->computed_closure (); ++c->refc; @@ -237,7 +237,7 @@ lval_func_copy_closure (const struct value *v) static void lval_func_free_closure (struct value *v) { - struct lval_closure *c = (struct lval_closure *) value_computed_closure (v); + struct lval_closure *c = (struct lval_closure *) v->computed_closure (); --c->refc; diff --git a/gdb/valops.c b/gdb/valops.c index b4e67951118..17b96ffcc41 100644 --- a/gdb/valops.c +++ b/gdb/valops.c @@ -1273,7 +1273,7 @@ value_assign (struct value *toval, struct value *fromval) case lval_computed: { - const struct lval_funcs *funcs = value_computed_funcs (toval); + const struct lval_funcs *funcs = toval->computed_funcs (); if (funcs->write != NULL) { @@ -1639,7 +1639,7 @@ value_ind (struct value *arg1) if (VALUE_LVAL (arg1) == lval_computed) { - const struct lval_funcs *funcs = value_computed_funcs (arg1); + const struct lval_funcs *funcs = arg1->computed_funcs (); if (funcs->indirect) { diff --git a/gdb/value.c b/gdb/value.c index 6607d871fca..495a45d50ba 100644 --- a/gdb/value.c +++ b/gdb/value.c @@ -1253,19 +1253,19 @@ value_bits_synthetic_pointer (const struct value *value, } const struct lval_funcs * -value_computed_funcs (const struct value *v) +value::computed_funcs () const { - gdb_assert (value_lval_const (v) == lval_computed); + gdb_assert (m_lval == lval_computed); - return v->m_location.computed.funcs; + return m_location.computed.funcs; } void * -value_computed_closure (const struct value *v) +value::computed_closure () const { - gdb_assert (v->m_lval == lval_computed); + gdb_assert (m_lval == lval_computed); - return v->m_location.computed.closure; + return m_location.computed.closure; } enum lval_type * @@ -3533,7 +3533,7 @@ coerce_ref_if_computed (const struct value *arg) if (value_lval_const (arg) != lval_computed) return NULL; - funcs = value_computed_funcs (arg); + funcs = arg->computed_funcs (); if (funcs->coerce_ref == NULL) return NULL; @@ -3848,8 +3848,8 @@ value_fetch_lazy (struct value *val) else if (VALUE_LVAL (val) == lval_register) value_fetch_lazy_register (val); else if (VALUE_LVAL (val) == lval_computed - && value_computed_funcs (val)->read != NULL) - value_computed_funcs (val)->read (val); + && val->computed_funcs ()->read != NULL) + val->computed_funcs ()->read (val); else internal_error (_("Unexpected lazy value type.")); diff --git a/gdb/value.h b/gdb/value.h index 2d311c69efb..8a9406d835b 100644 --- a/gdb/value.h +++ b/gdb/value.h @@ -302,6 +302,15 @@ struct value void set_stack (int val) { m_stack = val; } + /* If this value is lval_computed, return its lval_funcs + structure. */ + const struct lval_funcs *computed_funcs () const; + + /* If this value is lval_computed, return its closure. The meaning + of the returned value depends on the functions this value + uses. */ + void *computed_closure () const; + /* Type of value; either not an lval, or one of the various different possible kinds of lval. */ @@ -555,15 +564,6 @@ extern struct value *allocate_computed_value (struct type *type, extern struct value *allocate_optimized_out_value (struct type *type); -/* If VALUE is lval_computed, return its lval_funcs structure. */ - -extern const struct lval_funcs *value_computed_funcs (const struct value *); - -/* If VALUE is lval_computed, return its closure. The meaning of the - returned value depends on the functions VALUE uses. */ - -extern void *value_computed_closure (const struct value *value); - /* Throw an error complaining that the value has been optimized out. */ From patchwork Thu Feb 9 21:38:38 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tom Tromey X-Patchwork-Id: 64563 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 3C4E9389365A for ; Thu, 9 Feb 2023 21:39:58 +0000 (GMT) X-Original-To: gdb-patches@sourceware.org Delivered-To: gdb-patches@sourceware.org Received: from gproxy2-pub.mail.unifiedlayer.com (gproxy2-pub.mail.unifiedlayer.com [69.89.18.3]) by sourceware.org (Postfix) with ESMTPS id C6F6A3858017 for ; Thu, 9 Feb 2023 21:38:42 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org C6F6A3858017 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 cmgw15.mail.unifiedlayer.com (unknown [10.0.90.130]) by progateway4.mail.pro1.eigbox.com (Postfix) with ESMTP id 2CC5110047E02 for ; Thu, 9 Feb 2023 21:38:42 +0000 (UTC) Received: from box5379.bluehost.com ([162.241.216.53]) by cmsmtp with ESMTP id QEcspZ3qmbdcfQEcsp7Mii; Thu, 09 Feb 2023 21:38:42 +0000 X-Authority-Reason: nr=8 X-Authority-Analysis: v=2.4 cv=AZB0o1bG c=1 sm=1 tr=0 ts=63e567e2 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=tdbrao5GkmUthlhii5QA: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=PLBNB90FI0SReJsTdMvFIO/Dc+mSnB5213iPgJX9Ulg=; b=v5SyJ5O2KhJBlW8zfutH+4NPOC A4E4bqwEGpXhtyFfnliP1VITIxC/K+73Xdi3Y/UikeyviK5OOvTglaZZpU1LUtXH5zeykf6meQ//0 LKGh0Fc5YFNysYhbWnrQ+vaXB; 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 1pQEcs-001ZcE-0W for gdb-patches@sourceware.org; Thu, 09 Feb 2023 14:38:42 -0700 From: Tom Tromey Date: Thu, 09 Feb 2023 14:38:38 -0700 Subject: [PATCH 17/47] Convert value_lval_const and deprecated_lval_hack to methods MIME-Version: 1.0 Message-Id: <20230209-submit-value-fixups-2023-v1-17-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: 1pQEcs-001ZcE-0W 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: 18 X-Source-Cap: ZWx5bnJvYmk7ZWx5bnJvYmk7Ym94NTM3OS5ibHVlaG9zdC5jb20= X-Local-Domain: yes X-Spam-Status: No, score=-3025.4 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, GIT_PATCH_0, JMQ_SPF_NEUTRAL, RCVD_IN_BL_SPAMCOP_NET, 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 converts the value_lval_const and deprecated_lval_hack functions to be methods on value. --- gdb/f-lang.c | 2 +- gdb/gnu-v3-abi.c | 4 ++-- gdb/valprint.c | 6 +++--- gdb/value.c | 14 +------------- gdb/value.h | 12 +++++++----- 5 files changed, 14 insertions(+), 24 deletions(-) diff --git a/gdb/f-lang.c b/gdb/f-lang.c index d88e81c4a11..57c31efc980 100644 --- a/gdb/f-lang.c +++ b/gdb/f-lang.c @@ -458,7 +458,7 @@ fortran_associated (struct gdbarch *gdbarch, const language_defn *lang, looking the value of the pointer itself. We make the assumption that a non-associated pointer will be set to 0. This is probably true for most targets, but might not be true for everyone. */ - if (value_lval_const (target) != lval_memory + if (target->lval () != lval_memory || type_not_associated (pointer_type) || (TYPE_ASSOCIATED_PROP (pointer_type) == nullptr && pointer_type->code () == TYPE_CODE_PTR diff --git a/gdb/gnu-v3-abi.c b/gdb/gnu-v3-abi.c index 36d54b9312b..dc249f0980e 100644 --- a/gdb/gnu-v3-abi.c +++ b/gdb/gnu-v3-abi.c @@ -1102,7 +1102,7 @@ gnuv3_get_typeid (struct value *value) /* We have to handle values a bit trickily here, to allow this code to work properly with non_lvalue values that are really just disguised types. */ - if (value_lval_const (value) == lval_memory) + if (value->lval () == lval_memory) value = coerce_ref (value); type = check_typedef (value->type ()); @@ -1134,7 +1134,7 @@ gnuv3_get_typeid (struct value *value) /* We check for lval_memory because in the "typeid (type-id)" case, the type is passed via a not_lval value object. */ if (type->code () == TYPE_CODE_STRUCT - && value_lval_const (value) == lval_memory + && value->lval () == lval_memory && gnuv3_dynamic_class (type)) { struct value *vtable, *typeinfo_value; diff --git a/gdb/valprint.c b/gdb/valprint.c index 6aef98e37c1..d2fbc93284f 100644 --- a/gdb/valprint.c +++ b/gdb/valprint.c @@ -392,7 +392,7 @@ valprint_check_validity (struct ui_file *stream, const struct value *deref_val = coerce_ref_if_computed (val); if (deref_val != NULL) - ref_is_addressable = value_lval_const (deref_val) == lval_memory; + ref_is_addressable = deref_val->lval () == lval_memory; } if (!is_ref || !ref_is_addressable) @@ -416,7 +416,7 @@ valprint_check_validity (struct ui_file *stream, void val_print_optimized_out (const struct value *val, struct ui_file *stream) { - if (val != NULL && value_lval_const (val) == lval_register) + if (val != NULL && val->lval () == lval_register) val_print_not_saved (stream); else fprintf_styled (stream, metadata_style.style (), _("")); @@ -548,7 +548,7 @@ get_value_addr_contents (struct value *deref_val) { gdb_assert (deref_val != NULL); - if (value_lval_const (deref_val) == lval_memory) + if (deref_val->lval () == lval_memory) return value_contents_for_printing_const (value_addr (deref_val)).data (); else { diff --git a/gdb/value.c b/gdb/value.c index 495a45d50ba..b6fa5929dc1 100644 --- a/gdb/value.c +++ b/gdb/value.c @@ -1268,18 +1268,6 @@ value::computed_closure () const return m_location.computed.closure; } -enum lval_type * -deprecated_value_lval_hack (struct value *value) -{ - return &value->m_lval; -} - -enum lval_type -value_lval_const (const struct value *value) -{ - return value->m_lval; -} - CORE_ADDR value_address (const struct value *value) { @@ -3530,7 +3518,7 @@ coerce_ref_if_computed (const struct value *arg) if (!TYPE_IS_REFERENCE (check_typedef (arg->type ()))) return NULL; - if (value_lval_const (arg) != lval_computed) + if (arg->lval () != lval_computed) return NULL; funcs = arg->computed_funcs (); diff --git a/gdb/value.h b/gdb/value.h index 8a9406d835b..39609c48218 100644 --- a/gdb/value.h +++ b/gdb/value.h @@ -311,6 +311,12 @@ struct value uses. */ void *computed_closure () const; + enum lval_type *deprecated_lval_hack () + { return &m_lval; } + + enum lval_type lval () const + { return m_lval; } + /* Type of value; either not an lval, or one of the various different possible kinds of lval. */ @@ -657,11 +663,7 @@ extern void set_value_component_location (struct value *component, limited to just the first PIECE. Expect further change. */ /* Type of value; either not an lval, or one of the various different possible kinds of lval. */ -extern enum lval_type *deprecated_value_lval_hack (struct value *); -#define VALUE_LVAL(val) (*deprecated_value_lval_hack (val)) - -/* Like VALUE_LVAL, except the parameter can be const. */ -extern enum lval_type value_lval_const (const struct value *value); +#define VALUE_LVAL(val) (*((val)->deprecated_lval_hack ())) /* If lval == lval_memory, return the address in the inferior. If lval == lval_register, return the byte offset into the registers From patchwork Thu Feb 9 21:38:39 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tom Tromey X-Patchwork-Id: 64569 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 2A2F7388553D for ; Thu, 9 Feb 2023 21:40:47 +0000 (GMT) X-Original-To: gdb-patches@sourceware.org Delivered-To: gdb-patches@sourceware.org Received: from progateway7-pub.mail.pro1.eigbox.com (gproxy5-pub.mail.unifiedlayer.com [67.222.38.55]) by sourceware.org (Postfix) with ESMTPS id E40FC3858022 for ; Thu, 9 Feb 2023 21:38:42 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org E40FC3858022 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 cmgw13.mail.unifiedlayer.com (unknown [10.0.90.128]) by progateway7.mail.pro1.eigbox.com (Postfix) with ESMTP id 4796910042D1D for ; Thu, 9 Feb 2023 21:38:42 +0000 (UTC) Received: from box5379.bluehost.com ([162.241.216.53]) by cmsmtp with ESMTP id QEcspHuczNX2aQEcsp2uCO; Thu, 09 Feb 2023 21:38:42 +0000 X-Authority-Reason: nr=8 X-Authority-Analysis: v=2.4 cv=NMAQR22g c=1 sm=1 tr=0 ts=63e567e2 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=FH1zNuIi26YjjqSCN6UA: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=x1CbobfhYDQ4usBs9I8jAgxsdvQSDNXUkiwoOu5iNA8=; b=I6VsMDl0Nxg8rgLUajJsPmHlav 70g25Ov1NTf8PI4csl+BgdP0rhr8Ip8g8GSKes3dsumnW0e/WD0er7JcJTW6qigFCmgZJ6YZDTNse 6BQ9WEtoZKZb5z0jmrhwZNl7S; 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 1pQEcs-001ZcE-4s for gdb-patches@sourceware.org; Thu, 09 Feb 2023 14:38:42 -0700 From: Tom Tromey Date: Thu, 09 Feb 2023 14:38:39 -0700 Subject: [PATCH 18/47] Turn value_initialized and set_value_initialized functions into methods MIME-Version: 1.0 Message-Id: <20230209-submit-value-fixups-2023-v1-18-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: 1pQEcs-001ZcE-4s 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: 19 X-Source-Cap: ZWx5bnJvYmk7ZWx5bnJvYmk7Ym94NTM3OS5ibHVlaG9zdC5jb20= X-Local-Domain: yes X-Spam-Status: No, score=-3027.5 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 the value_initialized and set_value_initialized functions to be methods of value. --- gdb/c-valprint.c | 2 +- gdb/dwarf2/expr.c | 2 +- gdb/value.c | 16 ---------------- gdb/value.h | 15 +++++++++------ 4 files changed, 11 insertions(+), 24 deletions(-) diff --git a/gdb/c-valprint.c b/gdb/c-valprint.c index 0a9e4f49ba6..8cfb3786043 100644 --- a/gdb/c-valprint.c +++ b/gdb/c-valprint.c @@ -554,7 +554,7 @@ c_value_print (struct value *val, struct ui_file *stream, } } - if (!value_initialized (val)) + if (!val->initialized ()) gdb_printf (stream, " [uninitialized] "); if (options->objectprint && (type->code () == TYPE_CODE_STRUCT)) diff --git a/gdb/dwarf2/expr.c b/gdb/dwarf2/expr.c index 8d845e892e3..d6ad0f1776b 100644 --- a/gdb/dwarf2/expr.c +++ b/gdb/dwarf2/expr.c @@ -1057,7 +1057,7 @@ dwarf_expr_context::fetch_result (struct type *type, struct type *subobj_type, } } - set_value_initialized (retval, this->m_initialized); + retval->set_initialized (this->m_initialized); return retval; } diff --git a/gdb/value.c b/gdb/value.c index b6fa5929dc1..c7a6b689e58 100644 --- a/gdb/value.c +++ b/gdb/value.c @@ -3635,22 +3635,6 @@ using_struct_return (struct gdbarch *gdbarch, != RETURN_VALUE_REGISTER_CONVENTION); } -/* Set the initialized field in a value struct. */ - -void -set_value_initialized (struct value *val, int status) -{ - val->m_initialized = status; -} - -/* Return the initialized field in a value struct. */ - -int -value_initialized (const struct value *val) -{ - return val->m_initialized; -} - /* Helper for value_fetch_lazy when the value is a bitfield. */ static void diff --git a/gdb/value.h b/gdb/value.h index 39609c48218..fbbea204e97 100644 --- a/gdb/value.h +++ b/gdb/value.h @@ -317,6 +317,15 @@ struct value enum lval_type lval () const { return m_lval; } + /* Set or return field indicating whether a variable is initialized or + not, based on debugging information supplied by the compiler. + 1 = initialized; 0 = uninitialized. */ + int initialized () const + { return m_initialized; } + + void set_initialized (int value) + { m_initialized = value; } + /* Type of value; either not an lval, or one of the various different possible kinds of lval. */ @@ -647,12 +656,6 @@ extern void mark_value_bytes_optimized_out (struct value *value, extern void mark_value_bits_optimized_out (struct value *value, LONGEST offset, LONGEST length); -/* Set or return field indicating whether a variable is initialized or - not, based on debugging information supplied by the compiler. - 1 = initialized; 0 = uninitialized. */ -extern int value_initialized (const struct value *); -extern void set_value_initialized (struct value *, int); - /* Set COMPONENT's location as appropriate for a component of WHOLE --- regardless of what kind of lvalue WHOLE is. */ extern void set_value_component_location (struct value *component, From patchwork Thu Feb 9 21:38:40 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tom Tromey X-Patchwork-Id: 64577 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 C1DEA38A90B1 for ; Thu, 9 Feb 2023 21:42:00 +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 0F0A43858024 for ; Thu, 9 Feb 2023 21:38:43 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 0F0A43858024 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 cmgw13.mail.unifiedlayer.com (unknown [10.0.90.128]) by progateway1.mail.pro1.eigbox.com (Postfix) with ESMTP id 71FF310040632 for ; Thu, 9 Feb 2023 21:38:42 +0000 (UTC) Received: from box5379.bluehost.com ([162.241.216.53]) by cmsmtp with ESMTP id QEcspHud1NX2aQEcsp2uCQ; Thu, 09 Feb 2023 21:38:42 +0000 X-Authority-Reason: nr=8 X-Authority-Analysis: v=2.4 cv=NMAQR22g c=1 sm=1 tr=0 ts=63e567e2 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=inLrElqqnkYP7ezNmpAA:9 a=3hGvfnqKY7UtFaih:21 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=LLJBcks60x4PnJSiCS1JczfiYRw5HnaFJ09Dy2f6/WA=; b=xrdOlOxlEVNN7Iywv+RMDQNZjV g1clYFzKY3Tt2qJmJlPspamKE3PWDRc+ebugIwlrlx68+GAxNbVEBipC909nUY4wgYg2dbqhtOi66 gqGYx9yBrwcN8vEC/pbmb+V+u; 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 1pQEcs-001ZcE-8g for gdb-patches@sourceware.org; Thu, 09 Feb 2023 14:38:42 -0700 From: Tom Tromey Date: Thu, 09 Feb 2023 14:38:40 -0700 Subject: [PATCH 19/47] Turn value_address and set_value_address functions into methods MIME-Version: 1.0 Message-Id: <20230209-submit-value-fixups-2023-v1-19-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: 1pQEcs-001ZcE-8g 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: 20 X-Source-Cap: ZWx5bnJvYmk7ZWx5bnJvYmk7Ym94NTM3OS5ibHVlaG9zdC5jb20= X-Local-Domain: yes X-Spam-Status: No, score=-3026.8 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, GIT_PATCH_0, JMQ_SPF_NEUTRAL, KAM_STOCKGEN, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2, SPF_HELO_NONE, SPF_PASS, TXREP, T_FILL_THIS_FORM_SHORT 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 the value_address and set_value_address functions to be methods of value. --- gdb/ada-lang.c | 34 +++++++++++------------ gdb/ada-tasks.c | 2 +- gdb/ada-valprint.c | 2 +- gdb/breakpoint.c | 4 +-- gdb/c-lang.c | 2 +- gdb/c-valprint.c | 2 +- gdb/cli/cli-dump.c | 2 +- gdb/compile/compile-c-symbols.c | 2 +- gdb/compile/compile-cplus-symbols.c | 2 +- gdb/compile/compile-loc2c.c | 2 +- gdb/cp-valprint.c | 4 +-- gdb/d-valprint.c | 2 +- gdb/dwarf2/frame.c | 2 +- gdb/dwarf2/loc.c | 8 +++--- gdb/elfread.c | 4 +-- gdb/eval.c | 6 ++-- gdb/f-lang.c | 18 ++++++------ gdb/f-valprint.c | 2 +- gdb/frame.c | 4 +-- gdb/frv-tdep.c | 2 +- gdb/gdbtypes.c | 2 +- gdb/gnu-v2-abi.c | 2 +- gdb/gnu-v3-abi.c | 22 +++++++-------- gdb/go-valprint.c | 2 +- gdb/guile/scm-value.c | 4 +-- gdb/infcall.c | 4 +-- gdb/m2-valprint.c | 4 +-- gdb/m32r-tdep.c | 2 +- gdb/mips-tdep.c | 2 +- gdb/mn10300-tdep.c | 2 +- gdb/msp430-tdep.c | 2 +- gdb/or1k-tdep.c | 4 +-- gdb/p-valprint.c | 8 +++--- gdb/ppc-linux-nat.c | 4 +-- gdb/printcmd.c | 12 ++++---- gdb/python/py-value.c | 4 +-- gdb/rust-lang.c | 8 +++--- gdb/stack.c | 2 +- gdb/tracepoint.c | 2 +- gdb/v850-tdep.c | 2 +- gdb/valarith.c | 2 +- gdb/valops.c | 44 ++++++++++++++--------------- gdb/valprint.c | 4 +-- gdb/value.c | 55 ++++++++++++++++++------------------- gdb/value.h | 26 +++++++++--------- 45 files changed, 165 insertions(+), 166 deletions(-) diff --git a/gdb/ada-lang.c b/gdb/ada-lang.c index 05f8c3fd0da..e13359a68f6 100644 --- a/gdb/ada-lang.c +++ b/gdb/ada-lang.c @@ -571,7 +571,7 @@ coerce_unspec_val_to_type (struct value *val, struct type *type) result->set_bitsize (val->bitsize ()); result->set_bitpos (val->bitpos ()); if (VALUE_LVAL (result) == lval_memory) - set_value_address (result, value_address (val)); + result->set_address (val->address ()); return result; } } @@ -1764,7 +1764,7 @@ thin_data_pntr (struct value *val) if (type->code () == TYPE_CODE_PTR) return value_cast (data_type, value_copy (val)); else - return value_from_longest (data_type, value_address (val)); + return value_from_longest (data_type, val->address ()); } /* True iff TYPE indicates a "thick" array pointer type. */ @@ -1830,7 +1830,7 @@ desc_bounds (struct value *arr) if (type->code () == TYPE_CODE_PTR) addr = value_as_long (arr); else - addr = value_address (arr); + addr = arr->address (); return value_from_longest (lookup_pointer_type (bounds_type), @@ -2517,7 +2517,7 @@ decode_constrained_packed_array (struct value *arr) we further resolve the array bounds here and then update the sizes. */ const gdb_byte *valaddr = value_contents_for_printing (arr).data (); - CORE_ADDR address = value_address (arr); + CORE_ADDR address = arr->address (); gdb::array_view view = gdb::make_array_view (valaddr, type->length ()); type = resolve_dynamic_type (type, view, address); @@ -2815,9 +2815,9 @@ ada_value_primitive_packed_val (struct value *obj, const gdb_byte *valaddr, int src_len = (bit_size + bit_offset + HOST_CHAR_BIT - 1) / 8; gdb_byte *buf; - v = value_at (type, value_address (obj) + offset); + v = value_at (type, obj->address () + offset); buf = (gdb_byte *) alloca (src_len); - read_memory (value_address (v), buf, src_len); + read_memory (v->address (), buf, src_len); src = buf; } else @@ -2901,7 +2901,7 @@ ada_value_assign (struct value *toval, struct value *fromval) int from_size; gdb_byte *buffer = (gdb_byte *) alloca (len); struct value *val; - CORE_ADDR to_addr = value_address (toval); + CORE_ADDR to_addr = toval->address (); if (type->code () == TYPE_CODE_FLT) fromval = value_cast (type, fromval); @@ -2949,7 +2949,7 @@ value_assign_to_component (struct value *container, struct value *component, struct value *val) { LONGEST offset_in_container = - (LONGEST) (value_address (component) - value_address (container)); + (LONGEST) (component->address () - container->address ()); int bit_offset_in_container = component->bitpos () - container->bitpos (); int bits; @@ -4357,7 +4357,7 @@ ensure_lval (struct value *val) value_as_long (value_allocate_space_in_inferior (len)); VALUE_LVAL (val) = lval_memory; - set_value_address (val, addr); + val->set_address (addr); write_memory (addr, value_contents (val).data (), len); } @@ -4425,9 +4425,9 @@ ada_value_struct_elt (struct value *arg, const char *name, int no_err) CORE_ADDR address; if (t->code () == TYPE_CODE_PTR) - address = value_address (ada_value_ind (arg)); + address = ada_value_ind (arg)->address (); else - address = value_address (ada_coerce_ref (arg)); + address = ada_coerce_ref (arg)->address (); /* Check to see if this is a tagged type. We also need to handle the case where the type is a reference to a tagged type, but @@ -4566,7 +4566,7 @@ value_pointer (struct value *value, struct type *type) gdb_byte *buf = (gdb_byte *) alloca (len); CORE_ADDR addr; - addr = value_address (value); + addr = value->address (); gdbarch_address_to_pointer (type->arch (), type, buf, addr); addr = extract_unsigned_integer (buf, len, type_byte_order (type)); return addr; @@ -6510,7 +6510,7 @@ ada_tag_value_at_base_address (struct value *obj) offset_to_top = -offset_to_top; } - base_address = value_address (obj) + offset_to_top; + base_address = obj->address () + offset_to_top; tag = value_tag_from_contents_and_address (obj_type, NULL, base_address); /* Make sure that we have a proper tag at the new address. @@ -8591,7 +8591,7 @@ ada_to_fixed_type_1 (struct type *type, const gdb_byte *valaddr, if (real_type != NULL) return to_fixed_record_type (real_type, NULL, - value_address (ada_tag_value_at_base_address (obj)), NULL); + ada_tag_value_at_base_address (obj)->address (), NULL); } /* Check to see if there is a parallel ___XVZ variable. @@ -8860,7 +8860,7 @@ struct value * ada_to_fixed_value (struct value *val) { val = unwrap_value (val); - val = ada_to_fixed_value_create (val->type (), value_address (val), val); + val = ada_to_fixed_value_create (val->type (), val->address (), val); return val; } @@ -9225,7 +9225,7 @@ unwrap_value (struct value *val) return coerce_unspec_val_to_type (val, ada_to_fixed_type (raw_real_type, 0, - value_address (val), + val->address (), NULL, 1)); } } @@ -12033,7 +12033,7 @@ ada_exception_message_1 (void) return NULL; gdb::unique_xmalloc_ptr e_msg ((char *) xmalloc (e_msg_len + 1)); - read_memory (value_address (e_msg_val), (gdb_byte *) e_msg.get (), + read_memory (e_msg_val->address (), (gdb_byte *) e_msg.get (), e_msg_len); e_msg.get ()[e_msg_len] = '\0'; diff --git a/gdb/ada-tasks.c b/gdb/ada-tasks.c index 979d64a54ad..671ad7af603 100644 --- a/gdb/ada-tasks.c +++ b/gdb/ada-tasks.c @@ -484,7 +484,7 @@ read_fat_string_value (char *dest, struct value *val, int max_len) /* Extract LEN characters from the fat string. */ array_val = value_ind (value_field (val, array_fieldno)); - read_memory (value_address (array_val), (gdb_byte *) dest, len); + read_memory (array_val->address (), (gdb_byte *) dest, len); /* Add the NUL character to close the string. */ dest[len] = '\0'; diff --git a/gdb/ada-valprint.c b/gdb/ada-valprint.c index 64d7ac18b8c..814678ea0e1 100644 --- a/gdb/ada-valprint.c +++ b/gdb/ada-valprint.c @@ -1022,7 +1022,7 @@ ada_value_print_inner (struct value *val, struct ui_file *stream, int recurse, struct type *saved_type = type; const gdb_byte *valaddr = value_contents_for_printing (val).data (); - CORE_ADDR address = value_address (val); + CORE_ADDR address = val->address (); gdb::array_view view = gdb::make_array_view (valaddr, type->length ()); type = ada_check_typedef (resolve_dynamic_type (type, view, address)); diff --git a/gdb/breakpoint.c b/gdb/breakpoint.c index aa3045cd37f..f4b8c272f65 100644 --- a/gdb/breakpoint.c +++ b/gdb/breakpoint.c @@ -2100,7 +2100,7 @@ update_watchpoint (struct watchpoint *b, bool reparse) bitsize = b->val_bitsize; } - addr = value_address (v); + addr = v->address (); if (bitsize != 0) { /* Skip the bytes that don't contain the bitfield. */ @@ -10404,7 +10404,7 @@ can_use_hardware_watchpoint (const std::vector &vals) || (vtype->code () != TYPE_CODE_STRUCT && vtype->code () != TYPE_CODE_ARRAY)) { - CORE_ADDR vaddr = value_address (v); + CORE_ADDR vaddr = v->address (); int len; int num_regs; diff --git a/gdb/c-lang.c b/gdb/c-lang.c index c2c763154c7..a2c50c3ba74 100644 --- a/gdb/c-lang.c +++ b/gdb/c-lang.c @@ -331,7 +331,7 @@ c_get_string (struct value *value, gdb::unique_xmalloc_ptr *buffer, if (VALUE_LVAL (value) != lval_memory) error (_("Attempt to take address of value " "not located in memory.")); - addr = value_address (value); + addr = value->address (); } else addr = value_as_address (value); diff --git a/gdb/c-valprint.c b/gdb/c-valprint.c index 8cfb3786043..63f3e50d350 100644 --- a/gdb/c-valprint.c +++ b/gdb/c-valprint.c @@ -236,7 +236,7 @@ c_value_print_array (struct value *val, const struct value_print_options *options) { struct type *type = check_typedef (val->type ()); - CORE_ADDR address = value_address (val); + CORE_ADDR address = val->address (); const gdb_byte *valaddr = value_contents_for_printing (val).data (); struct type *unresolved_elttype = type->target_type (); struct type *elttype = check_typedef (unresolved_elttype); diff --git a/gdb/cli/cli-dump.c b/gdb/cli/cli-dump.c index e1d40c0e0ce..1e0051757f6 100644 --- a/gdb/cli/cli-dump.c +++ b/gdb/cli/cli-dump.c @@ -232,7 +232,7 @@ dump_value_to_file (const char *cmd, const char *mode, const char *file_format) if (VALUE_LVAL (val)) { - vaddr = value_address (val); + vaddr = val->address (); } else { diff --git a/gdb/compile/compile-c-symbols.c b/gdb/compile/compile-c-symbols.c index 00ac4523f86..5b53ab3263f 100644 --- a/gdb/compile/compile-c-symbols.c +++ b/gdb/compile/compile-c-symbols.c @@ -162,7 +162,7 @@ convert_one_symbol (compile_c_instance *context, sym.symbol->print_name ()); kind = GCC_C_SYMBOL_VARIABLE; - addr = value_address (val); + addr = val->address (); } break; diff --git a/gdb/compile/compile-cplus-symbols.c b/gdb/compile/compile-cplus-symbols.c index 2df68b7dd32..28447776d4f 100644 --- a/gdb/compile/compile-cplus-symbols.c +++ b/gdb/compile/compile-cplus-symbols.c @@ -156,7 +156,7 @@ convert_one_symbol (compile_cplus_instance *instance, sym.symbol->print_name ()); kind = GCC_CP_SYMBOL_VARIABLE; - addr = value_address (val); + addr = val->address (); } break; diff --git a/gdb/compile/compile-loc2c.c b/gdb/compile/compile-loc2c.c index 517cf89b9d2..ae30dd69dec 100644 --- a/gdb/compile/compile-loc2c.c +++ b/gdb/compile/compile-loc2c.c @@ -654,7 +654,7 @@ do_compile_dwarf_expr_to_c (int indent, string_file *stream, gdb_printf (stream, "%*s%s = %s;\n", indent, "", result_name, - core_addr_to_string (value_address (val))); + core_addr_to_string (val->address ())); gdb_printf (stream, "%*s}\n", indent - 2, ""); return; } diff --git a/gdb/cp-valprint.c b/gdb/cp-valprint.c index 634f5a94cee..ebed52c8ea9 100644 --- a/gdb/cp-valprint.c +++ b/gdb/cp-valprint.c @@ -390,7 +390,7 @@ cp_print_value (struct value *val, struct ui_file *stream, struct type **dont_print_vb) { struct type *type = check_typedef (val->type ()); - CORE_ADDR address = value_address (val); + CORE_ADDR address = val->address (); struct type **last_dont_print = (struct type **) obstack_next_free (&dont_print_vb_obstack); struct obstack tmp_obstack = dont_print_vb_obstack; @@ -560,7 +560,7 @@ cp_print_static_field (struct type *type, if (real_type->code () == TYPE_CODE_STRUCT) { CORE_ADDR *first_dont_print; - CORE_ADDR addr = value_address (val); + CORE_ADDR addr = val->address (); int i; first_dont_print diff --git a/gdb/d-valprint.c b/gdb/d-valprint.c index bebe02c967c..173623ea028 100644 --- a/gdb/d-valprint.c +++ b/gdb/d-valprint.c @@ -82,7 +82,7 @@ d_value_print_inner (struct value *val, struct ui_file *stream, int recurse, { case TYPE_CODE_STRUCT: ret = dynamic_array_type (type, val->embedded_offset (), - value_address (val), + val->address (), stream, recurse, val, options); if (ret == 0) break; diff --git a/gdb/dwarf2/frame.c b/gdb/dwarf2/frame.c index 7f2bcf29387..a83df2192c3 100644 --- a/gdb/dwarf2/frame.c +++ b/gdb/dwarf2/frame.c @@ -236,7 +236,7 @@ execute_stack_op (const gdb_byte *exp, ULONGEST len, int addr_size, value *result_val = ctx.evaluate (exp, len, true, nullptr, this_frame); if (VALUE_LVAL (result_val) == lval_memory) - return value_address (result_val); + return result_val->address (); else return value_as_address (result_val); } diff --git a/gdb/dwarf2/loc.c b/gdb/dwarf2/loc.c index e975f280cfc..b1dc5ab72f1 100644 --- a/gdb/dwarf2/loc.c +++ b/gdb/dwarf2/loc.c @@ -516,7 +516,7 @@ locexpr_get_frame_base (struct symbol *framefunc, frame_info_ptr frame) dwarf2_evaluate_loc_desc returns a value representing a variable at that address. The frame base address is thus this variable's address. */ - return value_address (result); + return result->address (); } /* Vector for inferior functions as represented by LOC_BLOCK, if the inferior @@ -573,7 +573,7 @@ loclist_get_frame_base (struct symbol *framefunc, frame_info_ptr frame) dwarf2_evaluate_loc_desc returns a value representing a variable at that address. The frame base address is thus this variable's address. */ - return value_address (result); + return result->address (); } /* Vector for inferior functions as represented by LOC_BLOCK, if the inferior @@ -685,7 +685,7 @@ call_site_target::iterate_over_addresses dwarf_block->per_objfile); /* DW_AT_call_target is a DWARF expression, not a DWARF location. */ if (VALUE_LVAL (val) == lval_memory) - callback (value_address (val)); + callback (val->address ()); else callback (value_as_address (val)); } @@ -1613,7 +1613,7 @@ dwarf2_locexpr_baton_eval (const struct dwarf2_locexpr_baton *dlbaton, return 0; if (VALUE_LVAL (result) == lval_memory) - *valp = value_address (result); + *valp = result->address (); else { if (VALUE_LVAL (result) == not_lval) diff --git a/gdb/elfread.c b/gdb/elfread.c index 45cd73b01af..02d473570b0 100644 --- a/gdb/elfread.c +++ b/gdb/elfread.c @@ -924,7 +924,7 @@ elf_gnu_ifunc_resolve_addr (struct gdbarch *gdbarch, CORE_ADDR pc) function = allocate_value (func_func_type); VALUE_LVAL (function) = lval_memory; - set_value_address (function, pc); + function->set_address (pc); /* STT_GNU_IFUNC resolver functions usually receive the HWCAP vector as parameter. FUNCTION is the function entry address. ADDRESS may be a @@ -1035,7 +1035,7 @@ elf_gnu_ifunc_resolver_return_stop (code_breakpoint *b) func_func = allocate_value (func_func_type); VALUE_LVAL (func_func) = lval_memory; - set_value_address (func_func, b->loc->related_address); + func_func->set_address (b->loc->related_address); value = allocate_value (value_type); gdbarch_return_value_as_value (gdbarch, func_func, value_type, regcache, diff --git a/gdb/eval.c b/gdb/eval.c index 934ca4c7ea2..28b307f07c9 100644 --- a/gdb/eval.c +++ b/gdb/eval.c @@ -651,7 +651,7 @@ evaluate_subexp_do_call (expression *exp, enum noside noside, { if (ftype->is_gnu_ifunc ()) { - CORE_ADDR address = value_address (callee); + CORE_ADDR address = callee->address (); type *resolved_type = find_gnu_ifunc_target_type (address); if (resolved_type != NULL) @@ -964,7 +964,7 @@ structop_base_operation::evaluate_funcall ``this'' pointer if necessary, so modify it to reflect any ``this'' changes. */ vals[0] = value_from_longest (lookup_pointer_type (temp->type ()), - value_address (temp) + temp->address () + temp->embedded_offset ()); } @@ -1136,7 +1136,7 @@ eval_op_func_static_var (struct type *expect_type, struct expression *exp, enum noside noside, value *func, const char *var) { - CORE_ADDR addr = value_address (func); + CORE_ADDR addr = func->address (); const block *blk = block_for_pc (addr); struct block_symbol sym = lookup_symbol (var, blk, VAR_DOMAIN, NULL); if (sym.symbol == NULL) diff --git a/gdb/f-lang.c b/gdb/f-lang.c index 57c31efc980..68d45168be7 100644 --- a/gdb/f-lang.c +++ b/gdb/f-lang.c @@ -408,7 +408,7 @@ fortran_associated (struct gdbarch *gdbarch, const language_defn *lang, if (pointer_type->code () == TYPE_CODE_PTR) pointer_addr = value_as_address (pointer); else - pointer_addr = value_address (pointer); + pointer_addr = pointer->address (); /* The single argument case, is POINTER associated with anything? */ if (target == nullptr) @@ -470,7 +470,7 @@ fortran_associated (struct gdbarch *gdbarch, const language_defn *lang, if (target_type->code () == TYPE_CODE_PTR) target_addr = value_as_address (target); else - target_addr = value_address (target); + target_addr = target->address (); /* Wrap the following checks inside a do { ... } while (false) loop so that we can use `break' to jump out of the loop. */ @@ -1074,7 +1074,7 @@ eval_op_f_loc (struct type *expect_type, struct expression *exp, else result_type = builtin_f_type (exp->gdbarch)->builtin_integer_s8; - LONGEST result_value = value_address (arg1); + LONGEST result_value = arg1->address (); return value_from_longest (result_type, result_value); } @@ -1410,7 +1410,7 @@ fortran_undetermined::value_subarray (value *array, debug_printf (" |-> Total offset: %s\n", plongest (total_offset)); debug_printf (" |-> Base address: %s\n", - core_addr_to_string (value_address (array))); + core_addr_to_string (array->address ())); debug_printf (" '-> Contiguous = %s\n", (is_all_contiguous ? "Yes" : "No")); } @@ -1446,13 +1446,13 @@ fortran_undetermined::value_subarray (value *array, > check_typedef (array->type ())->length ())) { fortran_array_walker p - (array_slice_type, value_address (array) + total_offset, dest); + (array_slice_type, array->address () + total_offset, dest); p.walk (); } else { fortran_array_walker p - (array_slice_type, value_address (array) + total_offset, + (array_slice_type, array->address () + total_offset, total_offset, array, dest); p.walk (); } @@ -1470,11 +1470,11 @@ fortran_undetermined::value_subarray (value *array, || (total_offset + array_slice_type->length () > check_typedef (array->type ())->length ())) array = value_at_lazy (array_slice_type, - value_address (array) + total_offset); + array->address () + total_offset); else array = value_from_contents_and_address (array_slice_type, value_contents (array).data () + total_offset, - value_address (array) + total_offset); + array->address () + total_offset); } else if (!array->lazy ()) array = value_from_component (array, array_slice_type, total_offset); @@ -1632,7 +1632,7 @@ fortran_structop_operation::evaluate (struct type *expect_type, if (is_dynamic_type (elt_type)) { const gdb_byte *valaddr = value_contents_for_printing (elt).data (); - CORE_ADDR address = value_address (elt); + CORE_ADDR address = elt->address (); gdb::array_view view = gdb::make_array_view (valaddr, elt_type->length ()); elt_type = resolve_dynamic_type (elt_type, view, address); diff --git a/gdb/f-valprint.c b/gdb/f-valprint.c index 1be6294fadb..9d0f02af954 100644 --- a/gdb/f-valprint.c +++ b/gdb/f-valprint.c @@ -439,7 +439,7 @@ f_language::value_print_inner (struct value *val, struct ui_file *stream, CORE_ADDR addr; int index; const gdb_byte *valaddr = value_contents_for_printing (val).data (); - const CORE_ADDR address = value_address (val); + const CORE_ADDR address = val->address (); switch (type->code ()) { diff --git a/gdb/frame.c b/gdb/frame.c index 8bb2385d9e7..935dea1e417 100644 --- a/gdb/frame.c +++ b/gdb/frame.c @@ -1192,7 +1192,7 @@ frame_register_unwind (frame_info_ptr next_frame, int regnum, *optimizedp = value_optimized_out (value); *unavailablep = !value_entirely_available (value); *lvalp = VALUE_LVAL (value); - *addrp = value_address (value); + *addrp = value->address (); if (*lvalp == lval_register) *realnump = VALUE_REGNUM (value); else @@ -1302,7 +1302,7 @@ frame_unwind_register_value (frame_info_ptr next_frame, int regnum) else if (VALUE_LVAL (value) == lval_memory) gdb_printf (&debug_file, " address=%s", paddress (gdbarch, - value_address (value))); + value->address ())); else gdb_printf (&debug_file, " computed"); diff --git a/gdb/frv-tdep.c b/gdb/frv-tdep.c index 0922a8e3afe..e9c9a9cd392 100644 --- a/gdb/frv-tdep.c +++ b/gdb/frv-tdep.c @@ -1238,7 +1238,7 @@ frv_push_dummy_call (struct gdbarch *gdbarch, struct value *function, if (typecode == TYPE_CODE_STRUCT || typecode == TYPE_CODE_UNION) { store_unsigned_integer (valbuf, 4, byte_order, - value_address (arg)); + arg->address ()); typecode = TYPE_CODE_PTR; len = 4; val = valbuf; diff --git a/gdb/gdbtypes.c b/gdb/gdbtypes.c index 75a567dd3f6..ff8de6b2b49 100644 --- a/gdb/gdbtypes.c +++ b/gdb/gdbtypes.c @@ -4009,7 +4009,7 @@ is_unique_ancestor (struct type *base, struct value *val) return is_unique_ancestor_worker (base, val->type (), &offset, value_contents_for_printing (val).data (), val->embedded_offset (), - value_address (val), val) == 1; + val->address (), val) == 1; } /* See gdbtypes.h. */ diff --git a/gdb/gnu-v2-abi.c b/gdb/gnu-v2-abi.c index 76dc719719f..908581a2063 100644 --- a/gdb/gnu-v2-abi.c +++ b/gdb/gnu-v2-abi.c @@ -234,7 +234,7 @@ gnuv2_value_rtti_type (struct value *v, int *full, LONGEST *top, int *using_enc) /* We can't use value_ind here, because it would want to use RTTI, and we'd waste a bunch of time figuring out we already know the type. Besides, we don't care about the type, just the actual pointer. */ - if (value_address (value_field (v, known_type_vptr_fieldno)) == 0) + if (value_field (v, known_type_vptr_fieldno)->address () == 0) return NULL; vtbl = value_as_address (value_field (v, known_type_vptr_fieldno)); diff --git a/gdb/gnu-v3-abi.c b/gdb/gnu-v3-abi.c index dc249f0980e..2fa40085f49 100644 --- a/gdb/gnu-v3-abi.c +++ b/gdb/gnu-v3-abi.c @@ -325,7 +325,7 @@ gnuv3_rtti_type (struct value *value, /* Find the linker symbol for this vtable. */ vtable_symbol - = lookup_minimal_symbol_by_pc (value_address (vtable) + = lookup_minimal_symbol_by_pc (vtable->address () + vtable->embedded_offset ()).minsym; if (! vtable_symbol) return NULL; @@ -804,7 +804,7 @@ hash_value_and_voffset (const void *p) { const struct value_and_voffset *o = (const struct value_and_voffset *) p; - return value_address (o->value) + o->value->embedded_offset (); + return o->value->address () + o->value->embedded_offset (); } /* Equality function for value_and_voffset. */ @@ -815,8 +815,8 @@ eq_value_and_voffset (const void *a, const void *b) const struct value_and_voffset *ova = (const struct value_and_voffset *) a; const struct value_and_voffset *ovb = (const struct value_and_voffset *) b; - return (value_address (ova->value) + ova->value->embedded_offset () - == value_address (ovb->value) + ovb->value->embedded_offset ()); + return (ova->value->address () + ova->value->embedded_offset () + == ovb->value->address () + ovb->value->embedded_offset ()); } /* Comparison function for value_and_voffset. */ @@ -825,9 +825,9 @@ static bool compare_value_and_voffset (const struct value_and_voffset *va, const struct value_and_voffset *vb) { - CORE_ADDR addra = (value_address (va->value) + CORE_ADDR addra = (va->value->address () + va->value->embedded_offset ()); - CORE_ADDR addrb = (value_address (vb->value) + CORE_ADDR addrb = (vb->value->address () + vb->value->embedded_offset ()); return addra < addrb; @@ -907,15 +907,15 @@ print_one_vtable (struct gdbarch *gdbarch, struct value *value, CORE_ADDR vt_addr; vtable = gnuv3_get_vtable (gdbarch, type, - value_address (value) + value->address () + value->embedded_offset ()); - vt_addr = value_address (value_field (vtable, - vtable_field_virtual_functions)); + vt_addr = value_field (vtable, + vtable_field_virtual_functions)->address (); gdb_printf (_("vtable for '%s' @ %s (subobject @ %s):\n"), TYPE_SAFE_NAME (type), paddress (gdbarch, vt_addr), - paddress (gdbarch, (value_address (value) + paddress (gdbarch, (value->address () + value->embedded_offset ()))); for (i = 0; i <= max_voffset; ++i) @@ -1138,7 +1138,7 @@ gnuv3_get_typeid (struct value *value) && gnuv3_dynamic_class (type)) { struct value *vtable, *typeinfo_value; - CORE_ADDR address = value_address (value) + value->embedded_offset (); + CORE_ADDR address = value->address () + value->embedded_offset (); vtable = gnuv3_get_vtable (gdbarch, type, address); if (vtable == NULL) diff --git a/gdb/go-valprint.c b/gdb/go-valprint.c index dce7bd684b4..8f6c8849fd9 100644 --- a/gdb/go-valprint.c +++ b/gdb/go-valprint.c @@ -105,7 +105,7 @@ go_language::value_print_inner (struct value *val, struct ui_file *stream, if (! options->raw) { print_go_string (type, val->embedded_offset (), - value_address (val), + val->address (), stream, recurse, val, options); return; } diff --git a/gdb/guile/scm-value.c b/gdb/guile/scm-value.c index 5b9a4cfb181..8f292c25851 100644 --- a/gdb/guile/scm-value.c +++ b/gdb/guile/scm-value.c @@ -1194,7 +1194,7 @@ gdbscm_value_to_lazy_string (SCM self, SCM rest) low_bound, low_bound + length - 1); } - addr = value_address (value); + addr = value->address (); break; } case TYPE_CODE_PTR: @@ -1204,7 +1204,7 @@ gdbscm_value_to_lazy_string (SCM self, SCM rest) break; default: /* Should flag an error here. PR 20769. */ - addr = value_address (value); + addr = value->address (); break; } diff --git a/gdb/infcall.c b/gdb/infcall.c index b58dc201aeb..3e0da94ab17 100644 --- a/gdb/infcall.c +++ b/gdb/infcall.c @@ -290,7 +290,7 @@ find_function_addr (struct value *function, /* Determine address to call. */ if (ftype->code () == TYPE_CODE_FUNC || ftype->code () == TYPE_CODE_METHOD) - funaddr = value_address (function); + funaddr = function->address (); else if (ftype->code () == TYPE_CODE_PTR) { funaddr = value_as_address (function); @@ -962,7 +962,7 @@ call_function_by_hand_dummy (struct value *function, lastval = get_last_thread_stack_temporary (call_thread.get ()); if (lastval != NULL) { - CORE_ADDR lastval_addr = value_address (lastval); + CORE_ADDR lastval_addr = lastval->address (); if (gdbarch_inner_than (gdbarch, 1, 2)) { diff --git a/gdb/m2-valprint.c b/gdb/m2-valprint.c index c7187986aeb..73f9e37aee3 100644 --- a/gdb/m2-valprint.c +++ b/gdb/m2-valprint.c @@ -270,7 +270,7 @@ m2_print_array_contents (struct value *val, || ((current_language->la_language == language_m2) && (type->code () == TYPE_CODE_CHAR))) && (options->format == 0 || options->format == 's')) - val_print_string (type, NULL, value_address (val), len+1, stream, + val_print_string (type, NULL, val->address (), len+1, stream, options); else { @@ -306,7 +306,7 @@ m2_language::value_print_inner (struct value *val, struct ui_file *stream, struct type *elttype; CORE_ADDR addr; const gdb_byte *valaddr = value_contents_for_printing (val).data (); - const CORE_ADDR address = value_address (val); + const CORE_ADDR address = val->address (); struct type *type = check_typedef (val->type ()); switch (type->code ()) diff --git a/gdb/m32r-tdep.c b/gdb/m32r-tdep.c index ceab11da67f..a1d2ad6da80 100644 --- a/gdb/m32r-tdep.c +++ b/gdb/m32r-tdep.c @@ -698,7 +698,7 @@ m32r_push_dummy_call (struct gdbarch *gdbarch, struct value *function, && (typecode == TYPE_CODE_STRUCT || typecode == TYPE_CODE_UNION)) { store_unsigned_integer (valbuf, 4, byte_order, - value_address (args[argnum])); + args[argnum]->address ()); typecode = TYPE_CODE_PTR; len = 4; val = valbuf; diff --git a/gdb/mips-tdep.c b/gdb/mips-tdep.c index 38ec39d4cc1..349a89eb23d 100644 --- a/gdb/mips-tdep.c +++ b/gdb/mips-tdep.c @@ -4604,7 +4604,7 @@ mips_eabi_push_dummy_call (struct gdbarch *gdbarch, struct value *function, { gdb_assert (abi_regsize <= ARRAY_SIZE (ref_valbuf)); store_unsigned_integer (ref_valbuf, abi_regsize, byte_order, - value_address (arg)); + arg->address ()); typecode = TYPE_CODE_PTR; len = abi_regsize; val = ref_valbuf; diff --git a/gdb/mn10300-tdep.c b/gdb/mn10300-tdep.c index ac2b4a7ef71..aade7c3af07 100644 --- a/gdb/mn10300-tdep.c +++ b/gdb/mn10300-tdep.c @@ -1212,7 +1212,7 @@ mn10300_push_dummy_call (struct gdbarch *gdbarch, arg_len = push_size; gdb_assert (push_size <= MN10300_MAX_REGISTER_SIZE); store_unsigned_integer (valbuf, push_size, byte_order, - value_address (*args)); + (*args)->address ()); val = &valbuf[0]; } else diff --git a/gdb/msp430-tdep.c b/gdb/msp430-tdep.c index 30a28d087d9..d4a40d4cd10 100644 --- a/gdb/msp430-tdep.c +++ b/gdb/msp430-tdep.c @@ -703,7 +703,7 @@ msp430_push_dummy_call (struct gdbarch *gdbarch, struct value *function, { /* Aggregates of any size are passed by reference. */ store_unsigned_integer (struct_addr_buf, 4, byte_order, - value_address (arg)); + arg->address ()); arg_bits = struct_addr_buf; arg_size = (code_model == MSP_LARGE_CODE_MODEL) ? 4 : 2; } diff --git a/gdb/or1k-tdep.c b/gdb/or1k-tdep.c index d8c30435cc5..d485d552102 100644 --- a/gdb/or1k-tdep.c +++ b/gdb/or1k-tdep.c @@ -672,7 +672,7 @@ or1k_push_dummy_call (struct gdbarch *gdbarch, struct value *function, if ((TYPE_CODE_STRUCT == typecode) || (TYPE_CODE_UNION == typecode) || (len > bpw * 2)) { - CORE_ADDR valaddr = value_address (arg); + CORE_ADDR valaddr = arg->address (); /* If the arg is fabricated (i.e. 3*i, instead of i) valaddr is undefined. */ @@ -792,7 +792,7 @@ or1k_push_dummy_call (struct gdbarch *gdbarch, struct value *function, || (len > bpw * 2)) { store_unsigned_integer (valbuf, bpa, byte_order, - value_address (arg)); + arg->address ()); len = bpa; val = valbuf; } diff --git a/gdb/p-valprint.c b/gdb/p-valprint.c index 2628ebd6bf2..c6b9b5571dd 100644 --- a/gdb/p-valprint.c +++ b/gdb/p-valprint.c @@ -143,7 +143,7 @@ pascal_language::value_print_inner (struct value *val, break; } /* Array of unspecified length: treat like pointer to first elt. */ - addr = value_address (val); + addr = val->address (); } goto print_unpacked_pointer; @@ -748,7 +748,7 @@ pascal_object_print_value (struct value *val, struct ui_file *stream, if (boffset < 0 || boffset >= type->length ()) { - CORE_ADDR address= value_address (val); + CORE_ADDR address= val->address (); gdb::byte_vector buf (baseclass->length ()); if (target_read_memory (address + boffset, buf.data (), @@ -836,7 +836,7 @@ pascal_object_print_static_field (struct value *val, while (--i >= 0) { - if (value_address (val) == first_dont_print[i]) + if (val->address () == first_dont_print[i]) { fputs_styled (_("\ "), @@ -845,7 +845,7 @@ pascal_object_print_static_field (struct value *val, } } - addr = value_address (val); + addr = val->address (); obstack_grow (&dont_print_statmem_obstack, (char *) &addr, sizeof (CORE_ADDR)); diff --git a/gdb/ppc-linux-nat.c b/gdb/ppc-linux-nat.c index d6d1d0fe1a2..6d4bf2cc618 100644 --- a/gdb/ppc-linux-nat.c +++ b/gdb/ppc-linux-nat.c @@ -2510,7 +2510,7 @@ ppc_linux_nat_target::check_condition (CORE_ADDR watch_addr, if (num_accesses_left == 1 && num_accesses_right == 0 && VALUE_LVAL (left_val) == lval_memory - && value_address (left_val) == watch_addr) + && left_val->address () == watch_addr) { *data_value = value_as_long (right_val); @@ -2520,7 +2520,7 @@ ppc_linux_nat_target::check_condition (CORE_ADDR watch_addr, } else if (num_accesses_left == 0 && num_accesses_right == 1 && VALUE_LVAL (right_val) == lval_memory - && value_address (right_val) == watch_addr) + && right_val->address () == watch_addr) { *data_value = value_as_long (left_val); diff --git a/gdb/printcmd.c b/gdb/printcmd.c index 539285477db..bd442fe2855 100644 --- a/gdb/printcmd.c +++ b/gdb/printcmd.c @@ -298,7 +298,7 @@ print_formatted (struct value *val, int size, int len = type->length (); if (VALUE_LVAL (val) == lval_memory) - next_address = value_address (val) + len; + next_address = val->address () + len; if (size) { @@ -308,9 +308,9 @@ print_formatted (struct value *val, int size, { struct type *elttype = val->type (); - next_address = (value_address (val) + next_address = (val->address () + val_print_string (elttype, NULL, - value_address (val), -1, + val->address (), -1, stream, options) * len); } return; @@ -318,9 +318,9 @@ print_formatted (struct value *val, int size, case 'i': /* We often wrap here if there are long symbolic names. */ stream->wrap_here (4); - next_address = (value_address (val) + next_address = (val->address () + gdb_print_insn (type->arch (), - value_address (val), stream, + val->address (), stream, &branch_delay_insns)); return; } @@ -1889,7 +1889,7 @@ x_command (const char *exp, int from_tty) pointers to functions. This makes "x/i main" work. */ if (val->type ()->code () == TYPE_CODE_FUNC && VALUE_LVAL (val) == lval_memory) - next_address = value_address (val); + next_address = val->address (); else next_address = value_as_address (val); diff --git a/gdb/python/py-value.c b/gdb/python/py-value.c index 0e3bc699819..b387bb813e7 100644 --- a/gdb/python/py-value.c +++ b/gdb/python/py-value.c @@ -538,7 +538,7 @@ valpy_lazy_string (PyObject *self, PyObject *args, PyObject *kw) low_bound, low_bound + length - 1); } - addr = value_address (value); + addr = value->address (); break; } case TYPE_CODE_PTR: @@ -548,7 +548,7 @@ valpy_lazy_string (PyObject *self, PyObject *args, PyObject *kw) break; default: /* Should flag an error here. PR 20769. */ - addr = value_address (value); + addr = value->address (); break; } diff --git a/gdb/rust-lang.c b/gdb/rust-lang.c index f6e5089825c..aa1590078dc 100644 --- a/gdb/rust-lang.c +++ b/gdb/rust-lang.c @@ -351,7 +351,7 @@ rust_val_print_slice (struct value *val, struct ui_file *stream, int recurse, llen - 1); struct value *array = allocate_value_lazy (array_type); VALUE_LVAL (array) = lval_memory; - set_value_address (array, value_as_address (base)); + array->set_address (value_as_address (base)); value_fetch_lazy (array); generic_value_print (array, stream, recurse, options, &rust_decorations); @@ -458,7 +458,7 @@ rust_language::print_enum (struct value *val, struct ui_file *stream, gdb::array_view view (value_contents_for_printing (val).data (), val->type ()->length ()); - type = resolve_dynamic_type (type, view, value_address (val)); + type = resolve_dynamic_type (type, view, val->address ()); if (rust_empty_enum_p (type)) { @@ -1375,7 +1375,7 @@ rust_struct_anon::evaluate (struct type *expect_type, if (rust_enum_p (type)) { type = resolve_dynamic_type (type, value_contents (lhs), - value_address (lhs)); + lhs->address ()); if (rust_empty_enum_p (type)) error (_("Cannot access field %d of empty enum %s"), @@ -1438,7 +1438,7 @@ rust_structop::evaluate (struct type *expect_type, if (type->code () == TYPE_CODE_STRUCT && rust_enum_p (type)) { type = resolve_dynamic_type (type, value_contents (lhs), - value_address (lhs)); + lhs->address ()); if (rust_empty_enum_p (type)) error (_("Cannot access field %s of empty enum %s"), diff --git a/gdb/stack.c b/gdb/stack.c index 5efe024c88e..9952c3a73df 100644 --- a/gdb/stack.c +++ b/gdb/stack.c @@ -1726,7 +1726,7 @@ info_frame_command_core (frame_info_ptr fi, bool selected_frame_p) else if (VALUE_LVAL (value) == lval_memory) { gdb_printf (" Previous frame's sp at "); - gdb_puts (paddress (gdbarch, value_address (value))); + gdb_puts (paddress (gdbarch, value->address ())); gdb_printf ("\n"); } else if (VALUE_LVAL (value) == lval_register) diff --git a/gdb/tracepoint.c b/gdb/tracepoint.c index 7e172dfb3fc..4c181dc7de7 100644 --- a/gdb/tracepoint.c +++ b/gdb/tracepoint.c @@ -1376,7 +1376,7 @@ encode_actions_1 (struct command_line *action, { /* Safe because we know it's a simple expression. */ tempval = evaluate_expression (exp.get ()); - addr = value_address (tempval); + addr = tempval->address (); expr::unop_memval_operation *memop = (gdb::checked_static_cast (exp->op.get ())); diff --git a/gdb/v850-tdep.c b/gdb/v850-tdep.c index fd801540757..74451bbaa9b 100644 --- a/gdb/v850-tdep.c +++ b/gdb/v850-tdep.c @@ -1059,7 +1059,7 @@ v850_push_dummy_call (struct gdbarch *gdbarch, && (*args)->type ()->length () > E_MAX_RETTYPE_SIZE_IN_REGS) { store_unsigned_integer (valbuf, 4, byte_order, - value_address (*args)); + (*args)->address ()); len = 4; val = valbuf; } diff --git a/gdb/valarith.c b/gdb/valarith.c index 53dfc82012d..47eccdbe8a0 100644 --- a/gdb/valarith.c +++ b/gdb/valarith.c @@ -234,7 +234,7 @@ value_subscripted_rvalue (struct value *array, LONGEST index, { CORE_ADDR address; - address = value_address (array) + elt_offs; + address = array->address () + elt_offs; elt_type = resolve_dynamic_type (elt_type, {}, address); } diff --git a/gdb/valops.c b/gdb/valops.c index 17b96ffcc41..6a557c357f1 100644 --- a/gdb/valops.c +++ b/gdb/valops.c @@ -253,7 +253,7 @@ value_cast_structs (struct type *type, struct value *v2) if (real_type) { v = value_full_object (v2, real_type, full, top, using_enc); - v = value_at_lazy (real_type, value_address (v)); + v = value_at_lazy (real_type, v->address ()); real_type = v->type (); /* We might be trying to cast to the outermost enclosing @@ -275,9 +275,9 @@ value_cast_structs (struct type *type, struct value *v2) if (v) { /* Downcasting is possible (t1 is superclass of v2). */ - CORE_ADDR addr2 = value_address (v2) + v2->embedded_offset (); + CORE_ADDR addr2 = v2->address () + v2->embedded_offset (); - addr2 -= value_address (v) + v->embedded_offset (); + addr2 -= v->address () + v->embedded_offset (); return value_at (type, addr2); } } @@ -654,7 +654,7 @@ value_cast (struct type *type, struct value *arg2) return arg2; } else if (VALUE_LVAL (arg2) == lval_memory) - return value_at_lazy (to_type, value_address (arg2)); + return value_at_lazy (to_type, arg2->address ()); else { if (current_language->la_language == language_ada) @@ -876,7 +876,7 @@ value_dynamic_cast (struct type *type, struct value *arg) error (_("Couldn't determine value's most derived type for dynamic_cast")); /* Compute the most derived object's address. */ - addr = value_address (arg); + addr = arg->address (); if (full) { /* Done. */ @@ -904,7 +904,7 @@ value_dynamic_cast (struct type *type, struct value *arg) if (dynamic_cast_check_1 (resolved_type->target_type (), value_contents_for_printing (tem).data (), tem->embedded_offset (), - value_address (tem), tem, + tem->address (), tem, rtti_type, addr, arg_type, &result) == 1) @@ -920,7 +920,7 @@ value_dynamic_cast (struct type *type, struct value *arg) && dynamic_cast_check_2 (resolved_type->target_type (), value_contents_for_printing (tem).data (), tem->embedded_offset (), - value_address (tem), tem, + tem->address (), tem, rtti_type, &result) == 1) return value_cast (type, is_ref @@ -1154,7 +1154,7 @@ value_assign (struct value *toval, struct value *fromval) { struct value *parent = toval->parent (); - changed_addr = value_address (parent) + toval->offset (); + changed_addr = parent->address () + toval->offset (); changed_len = (toval->bitpos () + toval->bitsize () + HOST_CHAR_BIT - 1) @@ -1181,7 +1181,7 @@ value_assign (struct value *toval, struct value *fromval) } else { - changed_addr = value_address (toval); + changed_addr = toval->address (); changed_len = type_length_units (type); dest_buffer = value_contents (fromval).data (); } @@ -1374,9 +1374,9 @@ value_repeat (struct value *arg1, int count) val = allocate_repeat_value (arg1->enclosing_type (), count); VALUE_LVAL (val) = lval_memory; - set_value_address (val, value_address (arg1)); + val->set_address (arg1->address ()); - read_value_memory (val, 0, val->stack (), value_address (val), + read_value_memory (val, 0, val->stack (), val->address (), value_contents_all_raw (val).data (), type_length_units (val->enclosing_type ())); @@ -1409,7 +1409,7 @@ address_of_variable (struct symbol *var, const struct block *b) if ((VALUE_LVAL (val) == lval_memory && val->lazy ()) || type->code () == TYPE_CODE_FUNC) { - CORE_ADDR addr = value_address (val); + CORE_ADDR addr = val->address (); return value_from_pointer (lookup_pointer_type (type), addr); } @@ -1526,7 +1526,7 @@ value_coerce_array (struct value *arg1) error (_("Attempt to take address of value not located in memory.")); return value_from_pointer (lookup_pointer_type (type->target_type ()), - value_address (arg1)); + arg1->address ()); } /* Given a value which is a function, return a value which is a pointer @@ -1541,7 +1541,7 @@ value_coerce_function (struct value *arg1) error (_("Attempt to take address of value not located in memory.")); retval = value_from_pointer (lookup_pointer_type (arg1->type ()), - value_address (arg1)); + arg1->address ()); return retval; } @@ -1591,7 +1591,7 @@ value_addr (struct value *arg1) /* Get target memory address. */ arg2 = value_from_pointer (lookup_pointer_type (arg1->type ()), - (value_address (arg1) + (arg1->address () + arg1->embedded_offset ())); /* This may be a pointer to a base subobject; so remember the @@ -2085,7 +2085,7 @@ struct_field_searcher::search (struct value *arg1, LONGEST offset, boffset = baseclass_offset (type, i, value_contents_for_printing (arg1).data (), arg1->embedded_offset () + offset, - value_address (arg1), + arg1->address (), arg1); /* The virtual base class pointer might have been clobbered @@ -2098,7 +2098,7 @@ struct_field_searcher::search (struct value *arg1, LONGEST offset, { CORE_ADDR base_addr; - base_addr = value_address (arg1) + boffset; + base_addr = arg1->address () + boffset; v2 = value_at_lazy (basetype, base_addr); if (target_read_memory (base_addr, value_contents_raw (v2).data (), @@ -2278,7 +2278,7 @@ search_struct_method (const char *name, struct value **arg1p, CORE_ADDR address; gdb::byte_vector tmp (baseclass->length ()); - address = value_address (*arg1p); + address = (*arg1p)->address (); if (target_read_memory (address + offset, tmp.data (), baseclass->length ()) != 0) @@ -2298,7 +2298,7 @@ search_struct_method (const char *name, struct value **arg1p, } base_offset = baseclass_offset (type, i, base_valaddr, - this_offset, value_address (base_val), + this_offset, base_val->address (), base_val); } else @@ -2560,7 +2560,7 @@ find_method_list (struct value **argp, const char *method, base_offset = baseclass_offset (type, i, value_contents_for_printing (*argp).data (), (*argp)->offset () + offset, - value_address (*argp), *argp); + (*argp)->address (), *argp); } else /* Non-virtual base, simply use bit position from debug info. */ @@ -3766,7 +3766,7 @@ value_struct_elt_for_reference (struct type *domain, int offset, result = allocate_value (lookup_methodptr_type (TYPE_FN_FIELD_TYPE (f, j))); cplus_make_method_ptr (result->type (), value_contents_writeable (result).data (), - value_address (v), 0); + v->address (), 0); } } return result; @@ -3977,7 +3977,7 @@ value_full_object (struct value *argp, /* Go back by the computed top_offset from the beginning of the object, adjusting for the embedded offset of argp if that's what value_rtti_type used for its computation. */ - new_val = value_at_lazy (real_type, value_address (argp) - top + + new_val = value_at_lazy (real_type, argp->address () - top + (using_enc ? 0 : argp->embedded_offset ())); new_val->deprecated_set_type (argp->type ()); new_val->set_embedded_offset ((using_enc diff --git a/gdb/valprint.c b/gdb/valprint.c index d2fbc93284f..20cf64ad2c4 100644 --- a/gdb/valprint.c +++ b/gdb/valprint.c @@ -494,7 +494,7 @@ generic_val_print_array (struct value *val, else { /* Array of unspecified length: treat like pointer to first elt. */ - print_unpacked_pointer (type, elttype, value_address (val), + print_unpacked_pointer (type, elttype, val->address (), stream, options); } @@ -965,7 +965,7 @@ generic_value_print (struct value *val, struct ui_file *stream, int recurse, if (options->format) value_print_scalar_formatted (val, options, 0, stream); else - generic_val_print_func (type, 0, value_address (val), stream, + generic_val_print_func (type, 0, val->address (), stream, val, options); break; diff --git a/gdb/value.c b/gdb/value.c index c7a6b689e58..fa725b1d8af 100644 --- a/gdb/value.c +++ b/gdb/value.c @@ -1269,34 +1269,34 @@ value::computed_closure () const } CORE_ADDR -value_address (const struct value *value) +value::address () const { - if (value->m_lval != lval_memory) + if (m_lval != lval_memory) return 0; - if (value->m_parent != NULL) - return value_address (value->m_parent.get ()) + value->m_offset; - if (NULL != TYPE_DATA_LOCATION (value->type ())) + if (m_parent != NULL) + return m_parent.get ()->address () + m_offset; + if (NULL != TYPE_DATA_LOCATION (type ())) { - gdb_assert (PROP_CONST == TYPE_DATA_LOCATION_KIND (value->type ())); - return TYPE_DATA_LOCATION_ADDR (value->type ()); + gdb_assert (PROP_CONST == TYPE_DATA_LOCATION_KIND (type ())); + return TYPE_DATA_LOCATION_ADDR (type ()); } - return value->m_location.address + value->m_offset; + return m_location.address + m_offset; } CORE_ADDR -value_raw_address (const struct value *value) +value::raw_address () const { - if (value->m_lval != lval_memory) + if (m_lval != lval_memory) return 0; - return value->m_location.address; + return m_location.address; } void -set_value_address (struct value *value, CORE_ADDR addr) +value::set_address (CORE_ADDR addr) { - gdb_assert (value->m_lval == lval_memory); - value->m_location.address = addr; + gdb_assert (m_lval == lval_memory); + m_location.address = addr; } struct internalvar ** @@ -1539,7 +1539,7 @@ set_value_component_location (struct value *component, type = whole->type (); if (NULL != TYPE_DATA_LOCATION (type) && TYPE_DATA_LOCATION_KIND (type) == PROP_CONST) - set_value_address (component, TYPE_DATA_LOCATION_ADDR (type)); + component->set_address (TYPE_DATA_LOCATION_ADDR (type)); /* Similarly, if the COMPONENT value has a dynamically resolved location property then update its address. */ @@ -1571,7 +1571,7 @@ set_value_component_location (struct value *component, } else gdb_assert (VALUE_LVAL (component) == lval_memory); - set_value_address (component, TYPE_DATA_LOCATION_ADDR (type)); + component->set_address (TYPE_DATA_LOCATION_ADDR (type)); } } @@ -2491,7 +2491,7 @@ value_as_address (struct value *val) Upon entry to this function, if VAL is a value of type `function' (that is, TYPE_CODE (val->type ()) == TYPE_CODE_FUNC), then - value_address (val) is the address of the function. This is what + val->address () is the address of the function. This is what you'll get if you evaluate an expression like `main'. The call to COERCE_ARRAY below actually does all the usual unary conversions, which includes converting values of type `function' @@ -2511,7 +2511,7 @@ value_as_address (struct value *val) function, just return its address directly. */ if (val->type ()->code () == TYPE_CODE_FUNC || val->type ()->code () == TYPE_CODE_METHOD) - return value_address (val); + return val->address (); val = coerce_array (val); @@ -2824,7 +2824,7 @@ value_primitive_field (struct value *arg1, LONGEST offset, boffset = baseclass_offset (arg_type, fieldno, value_contents (arg1).data (), arg1->embedded_offset (), - value_address (arg1), + arg1->address (), arg1); else boffset = arg_type->field (fieldno).loc_bitpos () / 8; @@ -2918,7 +2918,7 @@ value_fn_field (struct value **arg1p, struct fn_field *f, VALUE_LVAL (v) = lval_memory; if (sym) { - set_value_address (v, sym->value_block ()->entry_pc ()); + v->set_address (sym->value_block ()->entry_pc ()); } else { @@ -2927,10 +2927,9 @@ value_fn_field (struct value **arg1p, struct fn_field *f, struct objfile *objfile = msym.objfile; struct gdbarch *gdbarch = objfile->arch (); - set_value_address (v, - gdbarch_convert_from_func_ptr_addr - (gdbarch, msym.value_address (), - current_inferior ()->top_target ())); + v->set_address (gdbarch_convert_from_func_ptr_addr + (gdbarch, msym.value_address (), + current_inferior ()->top_target ())); } if (arg1p) @@ -3347,7 +3346,7 @@ value_from_contents_and_address_unresolved (struct type *type, else v = value_from_contents (type, valaddr); VALUE_LVAL (v) = lval_memory; - set_value_address (v, address); + v->set_address (address); return v; } @@ -3376,7 +3375,7 @@ value_from_contents_and_address (struct type *type, && TYPE_DATA_LOCATION_KIND (resolved_type_no_typedef) == PROP_CONST) address = TYPE_DATA_LOCATION_ADDR (resolved_type_no_typedef); VALUE_LVAL (v) = lval_memory; - set_value_address (v, address); + v->set_address (address); return v; } @@ -3664,7 +3663,7 @@ value_fetch_lazy_memory (struct value *val) { gdb_assert (VALUE_LVAL (val) == lval_memory); - CORE_ADDR addr = value_address (val); + CORE_ADDR addr = val->address (); struct type *type = check_typedef (val->enclosing_type ()); if (type->length ()) @@ -3772,7 +3771,7 @@ value_fetch_lazy_register (struct value *val) else if (VALUE_LVAL (new_val) == lval_memory) gdb_printf (&debug_file, " address=%s", paddress (gdbarch, - value_address (new_val))); + new_val->address ())); else gdb_printf (&debug_file, " computed"); diff --git a/gdb/value.h b/gdb/value.h index fbbea204e97..cc7f85acbf2 100644 --- a/gdb/value.h +++ b/gdb/value.h @@ -326,6 +326,19 @@ struct value void set_initialized (int value) { m_initialized = value; } + /* If lval == lval_memory, return the address in the inferior. If + lval == lval_register, return the byte offset into the registers + structure. Otherwise, return 0. The returned address + includes the offset, if any. */ + CORE_ADDR address () const; + + /* Like address, except the result does not include value's + offset. */ + CORE_ADDR raw_address () const; + + /* Set the address of a value. */ + void set_address (CORE_ADDR); + /* Type of value; either not an lval, or one of the various different possible kinds of lval. */ @@ -668,19 +681,6 @@ extern void set_value_component_location (struct value *component, possible kinds of lval. */ #define VALUE_LVAL(val) (*((val)->deprecated_lval_hack ())) -/* If lval == lval_memory, return the address in the inferior. If - lval == lval_register, return the byte offset into the registers - structure. Otherwise, return 0. The returned address - includes the offset, if any. */ -extern CORE_ADDR value_address (const struct value *); - -/* Like value_address, except the result does not include value's - offset. */ -extern CORE_ADDR value_raw_address (const struct value *); - -/* Set the address of a value. */ -extern void set_value_address (struct value *, CORE_ADDR); - /* Pointer to internal variable. */ extern struct internalvar **deprecated_value_internalvar_hack (struct value *); #define VALUE_INTERNALVAR(val) (*deprecated_value_internalvar_hack (val)) From patchwork Thu Feb 9 21:38:41 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tom Tromey X-Patchwork-Id: 64570 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 A991F383FBA0 for ; Thu, 9 Feb 2023 21:41:03 +0000 (GMT) X-Original-To: gdb-patches@sourceware.org Delivered-To: gdb-patches@sourceware.org Received: from gproxy1-pub.mail.unifiedlayer.com (gproxy1-pub.mail.unifiedlayer.com [69.89.25.95]) by sourceware.org (Postfix) with ESMTPS id 3E3403858033 for ; Thu, 9 Feb 2023 21:38:43 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 3E3403858033 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 cmgw10.mail.unifiedlayer.com (unknown [10.0.90.125]) by progateway3.mail.pro1.eigbox.com (Postfix) with ESMTP id 8A96C10046FE4 for ; Thu, 9 Feb 2023 21:38:42 +0000 (UTC) Received: from box5379.bluehost.com ([162.241.216.53]) by cmsmtp with ESMTP id QEcspwJw1OscKQEcspW9Ei; Thu, 09 Feb 2023 21:38:42 +0000 X-Authority-Reason: nr=8 X-Authority-Analysis: v=2.4 cv=Y5c9DjSN c=1 sm=1 tr=0 ts=63e567e2 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=JSklbjCBYTiJxVuva0QA: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=3TfxJYq8ca8G7xJ8rCAh2SpcH0sqf41RlmPmoEAEQfg=; b=EGzl5dxHnlmb5GOhEPtQD6mUHq QQs0Rjasm0SDySsEsSQ4Zrq18/+k5GlFP6a1B5t5vIP5SMSOzK+0cx8m2uMtLLl2/aibA8dnOhA+6 UVqYyUywK+wH0sVcwg5nEne8/; 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 1pQEcs-001ZcE-D3 for gdb-patches@sourceware.org; Thu, 09 Feb 2023 14:38:42 -0700 From: Tom Tromey Date: Thu, 09 Feb 2023 14:38:41 -0700 Subject: [PATCH 20/47] Turn more deprecated_* functions into methods MIME-Version: 1.0 Message-Id: <20230209-submit-value-fixups-2023-v1-20-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: 1pQEcs-001ZcE-D3 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: 21 X-Source-Cap: ZWx5bnJvYmk7ZWx5bnJvYmk7Ym94NTM3OS5ibHVlaG9zdC5jb20= X-Local-Domain: yes X-Spam-Status: No, score=-3027.5 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 deprecated_value_internalvar_hack, deprecated_value_internalvar_hack, and deprecated_value_regnum_hack into methods on value. --- gdb/value.c | 18 ++++++------------ gdb/value.h | 16 ++++++++++------ 2 files changed, 16 insertions(+), 18 deletions(-) diff --git a/gdb/value.c b/gdb/value.c index fa725b1d8af..43543e22f3a 100644 --- a/gdb/value.c +++ b/gdb/value.c @@ -1299,24 +1299,18 @@ value::set_address (CORE_ADDR addr) m_location.address = addr; } -struct internalvar ** -deprecated_value_internalvar_hack (struct value *value) -{ - return &value->m_location.internalvar; -} - struct frame_id * -deprecated_value_next_frame_id_hack (struct value *value) +value::deprecated_next_frame_id_hack () { - gdb_assert (value->m_lval == lval_register); - return &value->m_location.reg.next_frame_id; + gdb_assert (m_lval == lval_register); + return &m_location.reg.next_frame_id; } int * -deprecated_value_regnum_hack (struct value *value) +value::deprecated_regnum_hack () { - gdb_assert (value->m_lval == lval_register); - return &value->m_location.reg.regnum; + gdb_assert (m_lval == lval_register); + return &m_location.reg.regnum; } diff --git a/gdb/value.h b/gdb/value.h index cc7f85acbf2..03a9259a6fe 100644 --- a/gdb/value.h +++ b/gdb/value.h @@ -339,6 +339,13 @@ struct value /* Set the address of a value. */ void set_address (CORE_ADDR); + struct internalvar **deprecated_internalvar_hack () + { return &m_location.internalvar; } + + struct frame_id *deprecated_next_frame_id_hack (); + + int *deprecated_regnum_hack (); + /* Type of value; either not an lval, or one of the various different possible kinds of lval. */ @@ -682,19 +689,16 @@ extern void set_value_component_location (struct value *component, #define VALUE_LVAL(val) (*((val)->deprecated_lval_hack ())) /* Pointer to internal variable. */ -extern struct internalvar **deprecated_value_internalvar_hack (struct value *); -#define VALUE_INTERNALVAR(val) (*deprecated_value_internalvar_hack (val)) +#define VALUE_INTERNALVAR(val) (*((val)->deprecated_internalvar_hack ())) /* Frame ID of "next" frame to which a register value is relative. A register value is indicated by VALUE_LVAL being set to lval_register. So, if the register value is found relative to frame F, then the frame id of F->next will be stored in VALUE_NEXT_FRAME_ID. */ -extern struct frame_id *deprecated_value_next_frame_id_hack (struct value *); -#define VALUE_NEXT_FRAME_ID(val) (*deprecated_value_next_frame_id_hack (val)) +#define VALUE_NEXT_FRAME_ID(val) (*((val)->deprecated_next_frame_id_hack ())) /* Register number if the value is from a register. */ -extern int *deprecated_value_regnum_hack (struct value *); -#define VALUE_REGNUM(val) (*deprecated_value_regnum_hack (val)) +#define VALUE_REGNUM(val) (*((val)->deprecated_regnum_hack ())) /* Return value after lval_funcs->coerce_ref (after check_typedef). Return NULL if lval_funcs->coerce_ref is not applicable for whatever reason. */ From patchwork Thu Feb 9 21:38:42 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tom Tromey X-Patchwork-Id: 64571 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 56AE03889E25 for ; Thu, 9 Feb 2023 21:41:24 +0000 (GMT) X-Original-To: gdb-patches@sourceware.org Delivered-To: gdb-patches@sourceware.org Received: from gproxy4-pub.mail.unifiedlayer.com (gproxy4-pub.mail.unifiedlayer.com [69.89.23.142]) by sourceware.org (Postfix) with ESMTPS id 50DD63857C4F for ; Thu, 9 Feb 2023 21:38:43 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 50DD63857C4F 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 cmgw13.mail.unifiedlayer.com (unknown [10.0.90.128]) by progateway6.mail.pro1.eigbox.com (Postfix) with ESMTP id A7B5410044F43 for ; Thu, 9 Feb 2023 21:38:42 +0000 (UTC) Received: from box5379.bluehost.com ([162.241.216.53]) by cmsmtp with ESMTP id QEcspHud8NX2aQEcsp2uCX; Thu, 09 Feb 2023 21:38:42 +0000 X-Authority-Reason: nr=8 X-Authority-Analysis: v=2.4 cv=NMAQR22g c=1 sm=1 tr=0 ts=63e567e2 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=Oz5qh-HchgrWnQlwOZYA: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=kUJMPb0qtzeOp7ygFvW+M4AZseiWjyo2lBhXhCit6BQ=; b=mJeShl7+baASP1faBCHwQlVGqy rroGHEqunK5BAYORkaewH6zYK4wmElCXv09E7cnNSlhWWy3vI+waQG4m7N5OtWDvtGn1LQZnr4vYw 8KWVZlGVtNjOba941p8ph77nP; 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 1pQEcs-001ZcE-Gx for gdb-patches@sourceware.org; Thu, 09 Feb 2023 14:38:42 -0700 From: Tom Tromey Date: Thu, 09 Feb 2023 14:38:42 -0700 Subject: [PATCH 21/47] Turn allocate_value_lazy into a static "constructor" MIME-Version: 1.0 Message-Id: <20230209-submit-value-fixups-2023-v1-21-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: 1pQEcs-001ZcE-Gx 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: 22 X-Source-Cap: ZWx5bnJvYmk7ZWx5bnJvYmk7Ym94NTM3OS5ibHVlaG9zdC5jb20= X-Local-Domain: yes X-Spam-Status: No, score=-3027.5 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 allocate_value_lazy to be a static "constructor" of struct value. I considered trying to change value to use ordinary new/delete, but it seems to me that due to reference counting, we may someday want to change these static constructors to return value_ref_ptr instead. --- gdb/ada-lang.c | 2 +- gdb/findvar.c | 2 +- gdb/rust-lang.c | 2 +- gdb/valops.c | 2 +- gdb/value.c | 30 ++++++++++++++---------------- gdb/value.h | 12 +++++++++++- 6 files changed, 29 insertions(+), 21 deletions(-) diff --git a/gdb/ada-lang.c b/gdb/ada-lang.c index e13359a68f6..ae2f4df5332 100644 --- a/gdb/ada-lang.c +++ b/gdb/ada-lang.c @@ -561,7 +561,7 @@ coerce_unspec_val_to_type (struct value *val, struct type *type) /* Be careful not to make a lazy not_lval value. */ || (VALUE_LVAL (val) != not_lval && type->length () > val->type ()->length ())) - result = allocate_value_lazy (type); + result = value::allocate_lazy (type); else { result = allocate_value (type); diff --git a/gdb/findvar.c b/gdb/findvar.c index 9420286e91c..cb4eb758bf2 100644 --- a/gdb/findvar.c +++ b/gdb/findvar.c @@ -294,7 +294,7 @@ value_of_register_lazy (frame_info_ptr frame, int regnum) /* We should have a valid next frame. */ gdb_assert (frame_id_p (get_frame_id (next_frame))); - reg_val = allocate_value_lazy (register_type (gdbarch, regnum)); + reg_val = value::allocate_lazy (register_type (gdbarch, regnum)); VALUE_LVAL (reg_val) = lval_register; VALUE_REGNUM (reg_val) = regnum; VALUE_NEXT_FRAME_ID (reg_val) = get_frame_id (next_frame); diff --git a/gdb/rust-lang.c b/gdb/rust-lang.c index aa1590078dc..8f0953649ae 100644 --- a/gdb/rust-lang.c +++ b/gdb/rust-lang.c @@ -349,7 +349,7 @@ rust_val_print_slice (struct value *val, struct ui_file *stream, int recurse, struct type *elt_type = base->type ()->target_type (); struct type *array_type = lookup_array_range_type (elt_type, 0, llen - 1); - struct value *array = allocate_value_lazy (array_type); + struct value *array = value::allocate_lazy (array_type); VALUE_LVAL (array) = lval_memory; array->set_address (value_as_address (base)); value_fetch_lazy (array); diff --git a/gdb/valops.c b/gdb/valops.c index 6a557c357f1..3f91f720aee 100644 --- a/gdb/valops.c +++ b/gdb/valops.c @@ -4079,7 +4079,7 @@ value_slice (struct value *array, int lowbound, int length) slice_type->set_code (array_type->code ()); if (VALUE_LVAL (array) == lval_memory && array->lazy ()) - slice = allocate_value_lazy (slice_type); + slice = value::allocate_lazy (slice_type); else { slice = allocate_value (slice_type); diff --git a/gdb/value.c b/gdb/value.c index 43543e22f3a..9dd6b77443c 100644 --- a/gdb/value.c +++ b/gdb/value.c @@ -729,12 +729,10 @@ static std::vector value_history; static std::vector all_values; -/* Allocate a lazy value for type TYPE. Its actual content is - "lazily" allocated too: the content field of the return value is - NULL; it will be allocated when it is fetched from the target. */ +/* See value.h. */ struct value * -allocate_value_lazy (struct type *type) +value::allocate_lazy (struct type *type) { struct value *val; @@ -841,7 +839,7 @@ allocate_value_contents (struct value *val) struct value * allocate_value (struct type *type) { - struct value *val = allocate_value_lazy (type); + struct value *val = value::allocate_lazy (type); allocate_value_contents (val); val->m_lazy = 0; @@ -871,7 +869,7 @@ allocate_computed_value (struct type *type, const struct lval_funcs *funcs, void *closure) { - struct value *v = allocate_value_lazy (type); + struct value *v = value::allocate_lazy (type); VALUE_LVAL (v) = lval_computed; v->m_location.computed.funcs = funcs; @@ -885,7 +883,7 @@ allocate_computed_value (struct type *type, struct value * allocate_optimized_out_value (struct type *type) { - struct value *retval = allocate_value_lazy (type); + struct value *retval = value::allocate_lazy (type); mark_value_bytes_optimized_out (retval, 0, type->length ()); retval->set_lazy (0); @@ -1417,7 +1415,7 @@ value_copy (const value *arg) struct value *val; if (arg->lazy ()) - val = allocate_value_lazy (encl_type); + val = value::allocate_lazy (encl_type); else val = allocate_value (encl_type); val->m_type = arg->m_type; @@ -2786,7 +2784,7 @@ value_primitive_field (struct value *arg1, LONGEST offset, LONGEST bitpos = arg_type->field (fieldno).loc_bitpos (); LONGEST container_bitsize = type->length () * 8; - v = allocate_value_lazy (type); + v = value::allocate_lazy (type); v->m_bitsize = TYPE_FIELD_BITSIZE (arg_type, fieldno); if ((bitpos % container_bitsize) + v->m_bitsize <= container_bitsize && type->length () <= (int) sizeof (LONGEST)) @@ -2824,7 +2822,7 @@ value_primitive_field (struct value *arg1, LONGEST offset, boffset = arg_type->field (fieldno).loc_bitpos () / 8; if (arg1->lazy ()) - v = allocate_value_lazy (arg1->enclosing_type ()); + v = value::allocate_lazy (arg1->enclosing_type ()); else { v = allocate_value (arg1->enclosing_type ()); @@ -2844,7 +2842,7 @@ value_primitive_field (struct value *arg1, LONGEST offset, gdb_assert (PROP_CONST == TYPE_DATA_LOCATION_KIND (type)); /* For dynamic data types defer memory allocation until we actual access the value. */ - v = allocate_value_lazy (type); + v = value::allocate_lazy (type); } else { @@ -2857,7 +2855,7 @@ value_primitive_field (struct value *arg1, LONGEST offset, value_fetch_lazy (arg1); if (arg1->lazy ()) - v = allocate_value_lazy (type); + v = value::allocate_lazy (type); else { v = allocate_value (type); @@ -3262,7 +3260,7 @@ pack_unsigned_long (gdb_byte *buf, struct type *type, ULONGEST num) struct value * value_zero (struct type *type, enum lval_type lv) { - struct value *val = allocate_value_lazy (type); + struct value *val = value::allocate_lazy (type); VALUE_LVAL (val) = (lv == lval_computed ? not_lval : lv); val->m_is_zero = true; @@ -3336,7 +3334,7 @@ value_from_contents_and_address_unresolved (struct type *type, struct value *v; if (valaddr == NULL) - v = allocate_value_lazy (type); + v = value::allocate_lazy (type); else v = value_from_contents (type, valaddr); VALUE_LVAL (v) = lval_memory; @@ -3362,7 +3360,7 @@ value_from_contents_and_address (struct type *type, struct value *v; if (valaddr == NULL) - v = allocate_value_lazy (resolved_type); + v = value::allocate_lazy (resolved_type); else v = value_from_contents (resolved_type, valaddr); if (TYPE_DATA_LOCATION (resolved_type_no_typedef) != NULL @@ -3458,7 +3456,7 @@ value_from_component (struct value *whole, struct type *type, LONGEST offset) struct value *v; if (VALUE_LVAL (whole) == lval_memory && whole->lazy ()) - v = allocate_value_lazy (type); + v = value::allocate_lazy (type); else { v = allocate_value (type); diff --git a/gdb/value.h b/gdb/value.h index 03a9259a6fe..5fab4e19508 100644 --- a/gdb/value.h +++ b/gdb/value.h @@ -144,6 +144,9 @@ typedef gdb::ref_ptr value_ref_ptr; struct value { +private: + + /* Values can only be created with 'allocate_lazy'. */ explicit value (struct type *type_) : m_modifiable (1), m_lazy (1), @@ -155,6 +158,13 @@ struct value { } +public: + + /* Allocate a lazy value for type TYPE. Its actual content is + "lazily" allocated too: the content field of the return value is + NULL; it will be allocated when it is fetched from the target. */ + static struct value *allocate_lazy (struct type *type); + ~value (); DISABLE_COPY_AND_ASSIGN (value); @@ -992,7 +1002,7 @@ extern struct value *read_var_value (struct symbol *var, frame_info_ptr frame); extern struct value *allocate_value (struct type *type); -extern struct value *allocate_value_lazy (struct type *type); + extern void value_contents_copy (struct value *dst, LONGEST dst_offset, struct value *src, LONGEST src_offset, LONGEST length); From patchwork Thu Feb 9 21:38:43 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tom Tromey X-Patchwork-Id: 64580 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 D8D9A3940CF9 for ; Thu, 9 Feb 2023 21:42:32 +0000 (GMT) X-Original-To: gdb-patches@sourceware.org Delivered-To: gdb-patches@sourceware.org Received: from progateway7-pub.mail.pro1.eigbox.com (gproxy5-pub.mail.unifiedlayer.com [67.222.38.55]) by sourceware.org (Postfix) with ESMTPS id 796FE385781A for ; Thu, 9 Feb 2023 21:38:43 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 796FE385781A 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 cmgw15.mail.unifiedlayer.com (unknown [10.0.90.130]) by progateway7.mail.pro1.eigbox.com (Postfix) with ESMTP id D878710042D13 for ; Thu, 9 Feb 2023 21:38:42 +0000 (UTC) Received: from box5379.bluehost.com ([162.241.216.53]) by cmsmtp with ESMTP id QEcspZ3r6bdcfQEcsp7Mj1; Thu, 09 Feb 2023 21:38:42 +0000 X-Authority-Reason: nr=8 X-Authority-Analysis: v=2.4 cv=AZB0o1bG c=1 sm=1 tr=0 ts=63e567e2 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=_XlYyKohI-ld11rESdYA: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=DVVAbkyTkSxHhkKeo7kvNQ/AWp/jw3+QL3fSZR7dnao=; b=Kcrsj4wJ5QGhrbBbHGqtFkrMU5 FjTu0W/Ayh9u8DOLJcxrq/qi1lLwMjwmf+/6ZlIp2VDKjSgXTzjSMP+6p7Th8czEkQQ006c1lGak6 IXcam/LK4E8sk7nMRUc6x6S51; 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 1pQEcs-001ZcE-LB for gdb-patches@sourceware.org; Thu, 09 Feb 2023 14:38:42 -0700 From: Tom Tromey Date: Thu, 09 Feb 2023 14:38:43 -0700 Subject: [PATCH 22/47] Turn allocate_value into a static "constructor" MIME-Version: 1.0 Message-Id: <20230209-submit-value-fixups-2023-v1-22-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: 1pQEcs-001ZcE-LB 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: 23 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 allocate_value to be a static "constructor" of value. --- gdb/aarch64-tdep.c | 4 ++-- gdb/ada-lang.c | 26 +++++++++++++------------- gdb/amd64-tdep.c | 4 ++-- gdb/amd64-windows-tdep.c | 2 +- gdb/arch-utils.c | 2 +- gdb/arm-tdep.c | 4 ++-- gdb/breakpoint.c | 2 +- gdb/c-lang.c | 2 +- gdb/cli/cli-cmds.c | 2 +- gdb/cp-valprint.c | 2 +- gdb/dwarf2/expr.c | 6 +++--- gdb/dwarf2/loc.c | 2 +- gdb/dwarf2/read.c | 2 +- gdb/elfread.c | 6 +++--- gdb/eval.c | 16 ++++++++-------- gdb/expop.h | 4 ++-- gdb/f-lang.c | 6 +++--- gdb/findvar.c | 8 ++++---- gdb/gdbtypes.h | 2 +- gdb/i386-tdep.c | 4 ++-- gdb/infcall.c | 2 +- gdb/infrun.c | 2 +- gdb/opencl-lang.c | 12 ++++++------ gdb/ppc-linux-tdep.c | 2 +- gdb/python/py-xmethods.c | 2 +- gdb/regcache.c | 2 +- gdb/riscv-tdep.c | 6 +++--- gdb/rust-lang.c | 4 ++-- gdb/sparc-tdep.c | 2 +- gdb/std-regs.c | 4 ++-- gdb/tracepoint.c | 4 ++-- gdb/valarith.c | 20 ++++++++++---------- gdb/valops.c | 36 ++++++++++++++++++------------------ gdb/valprint.c | 2 +- gdb/value.c | 40 +++++++++++++++++++--------------------- gdb/value.h | 5 +++-- gdb/windows-tdep.c | 2 +- 37 files changed, 126 insertions(+), 127 deletions(-) diff --git a/gdb/aarch64-tdep.c b/gdb/aarch64-tdep.c index 058d5bfce85..76c92fd99bd 100644 --- a/gdb/aarch64-tdep.c +++ b/gdb/aarch64-tdep.c @@ -2492,7 +2492,7 @@ aarch64_return_value (struct gdbarch *gdbarch, struct value *func_value, if (read_value) { - *read_value = allocate_value (valtype); + *read_value = value::allocate (valtype); aarch64_extract_return_value (valtype, regcache, value_contents_raw (*read_value).data ()); } @@ -2781,7 +2781,7 @@ aarch64_pseudo_read_value (struct gdbarch *gdbarch, readable_regcache *regcache, int regnum) { aarch64_gdbarch_tdep *tdep = gdbarch_tdep (gdbarch); - struct value *result_value = allocate_value (register_type (gdbarch, regnum)); + struct value *result_value = value::allocate (register_type (gdbarch, regnum)); VALUE_LVAL (result_value) = lval_register; VALUE_REGNUM (result_value) = regnum; diff --git a/gdb/ada-lang.c b/gdb/ada-lang.c index ae2f4df5332..3d2c9f4f2ab 100644 --- a/gdb/ada-lang.c +++ b/gdb/ada-lang.c @@ -564,7 +564,7 @@ coerce_unspec_val_to_type (struct value *val, struct type *type) result = value::allocate_lazy (type); else { - result = allocate_value (type); + result = value::allocate (type); value_contents_copy (result, 0, val, 0, type->length ()); } set_value_component_location (result, val); @@ -2807,7 +2807,7 @@ ada_value_primitive_packed_val (struct value *obj, const gdb_byte *valaddr, if (obj == NULL) { - v = allocate_value (type); + v = value::allocate (type); src = valaddr + offset; } else if (VALUE_LVAL (obj) == lval_memory && obj->lazy ()) @@ -2822,7 +2822,7 @@ ada_value_primitive_packed_val (struct value *obj, const gdb_byte *valaddr, } else { - v = allocate_value (type); + v = value::allocate (type); src = value_contents (obj).data () + offset; } @@ -3404,7 +3404,7 @@ empty_array (struct type *arr_type, int low, int high) high < low ? low - 1 : high); struct type *elt_type = ada_array_element_type (arr_type0, 1); - return allocate_value (create_array_type (NULL, elt_type, index_type)); + return value::allocate (create_array_type (NULL, elt_type, index_type)); } @@ -4528,7 +4528,7 @@ ada_convert_actual (struct value *actual, struct type *formal_type0) struct value *val; actual_type = ada_check_typedef (actual->type ()); - val = allocate_value (actual_type); + val = value::allocate (actual_type); copy (value_contents (actual), value_contents_raw (val)); actual = ensure_lval (val); } @@ -4544,7 +4544,7 @@ ada_convert_actual (struct value *actual, struct type *formal_type0) { /* We need to turn this parameter into an aligner type as well. */ - struct value *aligner = allocate_value (formal_type); + struct value *aligner = value::allocate (formal_type); struct value *component = ada_value_struct_elt (aligner, "F", 0); value_assign_to_component (aligner, component, actual); @@ -4584,8 +4584,8 @@ make_array_descriptor (struct type *type, struct value *arr) { struct type *bounds_type = desc_bounds_type (type); struct type *desc_type = desc_base_type (type); - struct value *descriptor = allocate_value (desc_type); - struct value *bounds = allocate_value (bounds_type); + struct value *descriptor = value::allocate (desc_type); + struct value *bounds = value::allocate (bounds_type); int i; for (i = ada_array_arity (ada_check_typedef (arr->type ())); @@ -9281,7 +9281,7 @@ ada_promote_array_of_integrals (struct type *type, struct value *val) if (!get_array_bounds (type, &lo, &hi)) error (_("unable to determine array bounds")); - value *res = allocate_value (type); + value *res = value::allocate (type); gdb::array_view res_contents = value_contents_writeable (res); /* Promote each array element. */ @@ -9403,7 +9403,7 @@ ada_value_binop (struct value *arg1, struct value *arg2, enum exp_opcode op) v = 0; } - val = allocate_value (type1); + val = value::allocate (type1); store_unsigned_integer (value_contents_raw (val).data (), val->type ()->length (), type_byte_order (type1), v); @@ -10667,7 +10667,7 @@ ada_string_operation::evaluate (struct type *expect_type, historical behavior. */ struct type *stringtype = lookup_array_range_type (char_type, 1, str.length ()); - struct value *val = allocate_value (stringtype); + struct value *val = value::allocate (stringtype); memcpy (value_contents_raw (val).data (), str.c_str (), str.length ()); return val; @@ -10702,7 +10702,7 @@ ada_string_operation::evaluate (struct type *expect_type, = lookup_array_range_type (char_type, 1, obstack_object_size (&converted) / char_type->length ()); - struct value *val = allocate_value (stringtype); + struct value *val = value::allocate (stringtype); memcpy (value_contents_raw (val).data (), obstack_base (&converted), obstack_object_size (&converted)); @@ -11208,7 +11208,7 @@ ada_funcall_operation::evaluate (struct type *expect_type, { if (type->target_type () == NULL) error_call_unknown_return_type (NULL); - return allocate_value (type->target_type ()); + return value::allocate (type->target_type ()); } return call_function_by_hand (callee, NULL, argvec); case TYPE_CODE_INTERNAL_FUNCTION: diff --git a/gdb/amd64-tdep.c b/gdb/amd64-tdep.c index 5e098b1ce79..03e9ac951c8 100644 --- a/gdb/amd64-tdep.c +++ b/gdb/amd64-tdep.c @@ -355,7 +355,7 @@ amd64_pseudo_register_read_value (struct gdbarch *gdbarch, { i386_gdbarch_tdep *tdep = gdbarch_tdep (gdbarch); - value *result_value = allocate_value (register_type (gdbarch, regnum)); + value *result_value = value::allocate (register_type (gdbarch, regnum)); VALUE_LVAL (result_value) = lval_register; VALUE_REGNUM (result_value) = regnum; gdb_byte *buf = value_contents_raw (result_value).data (); @@ -831,7 +831,7 @@ amd64_return_value (struct gdbarch *gdbarch, struct value *function, gdb_byte *readbuf = nullptr; if (read_value != nullptr) { - *read_value = allocate_value (type); + *read_value = value::allocate (type); readbuf = value_contents_raw (*read_value).data (); } diff --git a/gdb/amd64-windows-tdep.c b/gdb/amd64-windows-tdep.c index 5c779cbb118..aea8aaa6200 100644 --- a/gdb/amd64-windows-tdep.c +++ b/gdb/amd64-windows-tdep.c @@ -408,7 +408,7 @@ amd64_windows_return_value (struct gdbarch *gdbarch, struct value *function, /* Extract the return value from the register where it was stored. */ if (read_value != nullptr) { - *read_value = allocate_value (type); + *read_value = value::allocate (type); regcache->raw_read_part (regnum, 0, len, value_contents_raw (*read_value).data ()); } diff --git a/gdb/arch-utils.c b/gdb/arch-utils.c index 617768225d3..49c699fd124 100644 --- a/gdb/arch-utils.c +++ b/gdb/arch-utils.c @@ -1178,7 +1178,7 @@ default_gdbarch_return_value if (read_value != nullptr) { - *read_value = allocate_value (valtype); + *read_value = value::allocate (valtype); readbuf = value_contents_raw (*read_value).data (); } diff --git a/gdb/arm-tdep.c b/gdb/arm-tdep.c index a21f7120ab4..c4b92ea17d9 100644 --- a/gdb/arm-tdep.c +++ b/gdb/arm-tdep.c @@ -9192,7 +9192,7 @@ arm_return_value (struct gdbarch *gdbarch, struct value *function, gdb_byte *readbuf = nullptr; if (read_value != nullptr) { - *read_value = allocate_value (valtype); + *read_value = value::allocate (valtype); readbuf = value_contents_raw (*read_value).data (); } @@ -9268,7 +9268,7 @@ arm_return_value (struct gdbarch *gdbarch, struct value *function, if (read_value != nullptr) { - *read_value = allocate_value (valtype); + *read_value = value::allocate (valtype); gdb_byte *readbuf = value_contents_raw (*read_value).data (); arm_extract_return_value (valtype, regcache, readbuf); } diff --git a/gdb/breakpoint.c b/gdb/breakpoint.c index f4b8c272f65..07f616338a6 100644 --- a/gdb/breakpoint.c +++ b/gdb/breakpoint.c @@ -1856,7 +1856,7 @@ extract_bitfield_from_watchpoint_value (struct watchpoint *w, struct value *val) if (val == NULL) return NULL; - bit_val = allocate_value (val->type ()); + bit_val = value::allocate (val->type ()); unpack_value_bitfield (bit_val, w->val_bitpos, diff --git a/gdb/c-lang.c b/gdb/c-lang.c index a2c50c3ba74..255901887d6 100644 --- a/gdb/c-lang.c +++ b/gdb/c-lang.c @@ -673,7 +673,7 @@ c_string_operation::evaluate (struct type *expect_type, > (high_bound - low_bound + 1)) error (_("Too many array elements")); - result = allocate_value (expect_type); + result = value::allocate (expect_type); memcpy (value_contents_raw (result).data (), obstack_base (&output), obstack_object_size (&output)); } diff --git a/gdb/cli/cli-cmds.c b/gdb/cli/cli-cmds.c index 7267d607916..ce4bf6bc9cd 100644 --- a/gdb/cli/cli-cmds.c +++ b/gdb/cli/cli-cmds.c @@ -2231,7 +2231,7 @@ value_from_setting (const setting &var, struct gdbarch *gdbarch) if (l->val.has_value ()) value = *l->val; else - return allocate_value (builtin_type (gdbarch)->builtin_void); + return value::allocate (builtin_type (gdbarch)->builtin_void); break; } diff --git a/gdb/cp-valprint.c b/gdb/cp-valprint.c index ebed52c8ea9..268a414a37b 100644 --- a/gdb/cp-valprint.c +++ b/gdb/cp-valprint.c @@ -761,7 +761,7 @@ test_print_fields (gdbarch *arch) FIELD_BITSIZE (*f) = 1; } - value *val = allocate_value (the_struct); + value *val = value::allocate (the_struct); gdb_byte *contents = value_contents_writeable (val).data (); store_unsigned_integer (contents, val->enclosing_type ()->length (), gdbarch_byte_order (arch), 0xe9); diff --git a/gdb/dwarf2/expr.c b/gdb/dwarf2/expr.c index d6ad0f1776b..fc92de85840 100644 --- a/gdb/dwarf2/expr.c +++ b/gdb/dwarf2/expr.c @@ -968,7 +968,7 @@ dwarf_expr_context::fetch_result (struct type *type, struct type *subobj_type, inspecting a register ($pc, $sp, etc.), return a generic optimized out value instead, so that we show instead of . */ - value *tmp = allocate_value (subobj_type); + value *tmp = value::allocate (subobj_type); value_contents_copy (tmp, 0, retval, 0, subobj_type->length ()); retval = tmp; @@ -1019,7 +1019,7 @@ dwarf_expr_context::fetch_result (struct type *type, struct type *subobj_type, if (subobj_offset + len > max) invalid_synthetic_pointer (); - retval = allocate_value (subobj_type); + retval = value::allocate (subobj_type); /* The given offset is relative to the actual object. */ if (gdbarch_byte_order (arch) == BFD_ENDIAN_BIG) @@ -1037,7 +1037,7 @@ dwarf_expr_context::fetch_result (struct type *type, struct type *subobj_type, if (subobj_offset + n > this->m_len) invalid_synthetic_pointer (); - retval = allocate_value (subobj_type); + retval = value::allocate (subobj_type); bfd_byte *contents = value_contents_raw (retval).data (); memcpy (contents, this->m_data + subobj_offset, n); } diff --git a/gdb/dwarf2/loc.c b/gdb/dwarf2/loc.c index b1dc5ab72f1..2e0b4a8b45d 100644 --- a/gdb/dwarf2/loc.c +++ b/gdb/dwarf2/loc.c @@ -1514,7 +1514,7 @@ dwarf2_evaluate_loc_desc_full (struct type *type, frame_info_ptr frame, if (ex.error == NOT_AVAILABLE_ERROR) { free_values.free_to_mark (); - retval = allocate_value (subobj_type); + retval = value::allocate (subobj_type); mark_value_bytes_unavailable (retval, 0, subobj_type->length ()); return retval; diff --git a/gdb/dwarf2/read.c b/gdb/dwarf2/read.c index fb5aa7b8e5b..7da86798454 100644 --- a/gdb/dwarf2/read.c +++ b/gdb/dwarf2/read.c @@ -9025,7 +9025,7 @@ dwarf2_compute_name (const char *name, baton->per_objfile); else if (bytes != NULL) { - v = allocate_value (type); + v = value::allocate (type); memcpy (value_contents_writeable (v).data (), bytes, type->length ()); } diff --git a/gdb/elfread.c b/gdb/elfread.c index 02d473570b0..6107a7fac69 100644 --- a/gdb/elfread.c +++ b/gdb/elfread.c @@ -922,7 +922,7 @@ elf_gnu_ifunc_resolve_addr (struct gdbarch *gdbarch, CORE_ADDR pc) else name_at_pc = NULL; - function = allocate_value (func_func_type); + function = value::allocate (func_func_type); VALUE_LVAL (function) = lval_memory; function->set_address (pc); @@ -1033,11 +1033,11 @@ elf_gnu_ifunc_resolver_return_stop (code_breakpoint *b) gdb_assert (b->type == bp_gnu_ifunc_resolver); gdb_assert (b->loc->next == NULL); - func_func = allocate_value (func_func_type); + func_func = value::allocate (func_func_type); VALUE_LVAL (func_func) = lval_memory; func_func->set_address (b->loc->related_address); - value = allocate_value (value_type); + value = value::allocate (value_type); gdbarch_return_value_as_value (gdbarch, func_func, value_type, regcache, &value, NULL); resolved_address = value_as_address (value); diff --git a/gdb/eval.c b/gdb/eval.c index 28b307f07c9..5f8d294322b 100644 --- a/gdb/eval.c +++ b/gdb/eval.c @@ -666,7 +666,7 @@ evaluate_subexp_do_call (expression *exp, enum noside noside, if (return_type == NULL) error_call_unknown_return_type (function_name); - return allocate_value (return_type); + return value::allocate (return_type); } else error (_("Expression of type other than " @@ -1880,7 +1880,7 @@ eval_op_type (struct type *expect_type, struct expression *exp, enum noside noside, struct type *type) { if (noside == EVAL_AVOID_SIDE_EFFECTS) - return allocate_value (type); + return value::allocate (type); else error (_("Attempt to use a type name as an expression")); } @@ -2162,9 +2162,9 @@ eval_op_objc_msgcall (struct type *expect_type, struct expression *exp, if (callee_type) { if ((callee_type->code () == TYPE_CODE_ERROR) && expect_type) - return allocate_value (expect_type); + return value::allocate (expect_type); else - return allocate_value (callee_type); + return value::allocate (callee_type); } else error (_("Expression of type other than " @@ -2440,7 +2440,7 @@ array_operation::evaluate (struct type *expect_type, if (expect_type != nullptr && type->code () == TYPE_CODE_STRUCT) { - struct value *rec = allocate_value (expect_type); + struct value *rec = value::allocate (expect_type); memset (value_contents_raw (rec).data (), '\0', type->length ()); return evaluate_struct_tuple (rec, exp, noside, nargs); @@ -2451,7 +2451,7 @@ array_operation::evaluate (struct type *expect_type, { struct type *range_type = type->index_type (); struct type *element_type = type->target_type (); - struct value *array = allocate_value (expect_type); + struct value *array = value::allocate (expect_type); int element_size = check_typedef (element_type)->length (); LONGEST low_bound, high_bound, index; @@ -2485,7 +2485,7 @@ array_operation::evaluate (struct type *expect_type, if (expect_type != nullptr && type->code () == TYPE_CODE_SET) { - struct value *set = allocate_value (expect_type); + struct value *set = value::allocate (expect_type); gdb_byte *valaddr = value_contents_raw (set).data (); struct type *element_type = type->index_type (); struct type *check_type = element_type; @@ -2569,7 +2569,7 @@ unop_extract_operation::evaluate (struct type *expect_type, if (type->length () > old_value->type ()->length ()) error (_("length type is larger than the value type")); - struct value *result = allocate_value (type); + struct value *result = value::allocate (type); value_contents_copy (result, 0, old_value, 0, type->length ()); return result; } diff --git a/gdb/expop.h b/gdb/expop.h index 7460343cb48..e53474711fe 100644 --- a/gdb/expop.h +++ b/gdb/expop.h @@ -1618,7 +1618,7 @@ class decltype_operation if (!TYPE_IS_REFERENCE (type)) { type = lookup_lvalue_reference_type (type); - result = allocate_value (type); + result = value::allocate (type); } } @@ -1653,7 +1653,7 @@ class typeid_operation value *result = std::get<0> (m_storage)->evaluate (nullptr, exp, sub_noside); if (noside != EVAL_NORMAL) - return allocate_value (cplus_typeid_type (exp->gdbarch)); + return value::allocate (cplus_typeid_type (exp->gdbarch)); return cplus_typeid (result); } diff --git a/gdb/f-lang.c b/gdb/f-lang.c index 68d45168be7..ccaf4fd612f 100644 --- a/gdb/f-lang.c +++ b/gdb/f-lang.c @@ -137,7 +137,7 @@ fortran_bounds_all_dims (bool lbound_p, 1, ndimensions); struct type *elm_type = builtin_f_type (gdbarch)->builtin_integer; struct type *result_type = create_array_type (nullptr, elm_type, range); - struct value *result = allocate_value (result_type); + struct value *result = value::allocate (result_type); /* Walk the array dimensions backwards due to the way the array will be laid out in memory, the first dimension will be the most inner. */ @@ -720,7 +720,7 @@ fortran_array_shape (struct gdbarch *gdbarch, const language_defn *lang, 1, ndimensions); struct type *elm_type = builtin_f_type (gdbarch)->builtin_integer; struct type *result_type = create_array_type (nullptr, elm_type, range); - struct value *result = allocate_value (result_type); + struct value *result = value::allocate (result_type); LONGEST elm_len = elm_type->length (); /* Walk the array dimensions backwards due to the way the array will be @@ -1440,7 +1440,7 @@ fortran_undetermined::value_subarray (value *array, /* Now copy the elements from the original ARRAY into the packed array value DEST. */ - struct value *dest = allocate_value (repacked_array_type); + struct value *dest = value::allocate (repacked_array_type); if (array->lazy () || (total_offset + array_slice_type->length () > check_typedef (array->type ())->length ())) diff --git a/gdb/findvar.c b/gdb/findvar.c index cb4eb758bf2..b59962c65ba 100644 --- a/gdb/findvar.c +++ b/gdb/findvar.c @@ -586,7 +586,7 @@ language_defn::read_var_value (struct symbol *var, type = resolve_dynamic_type (type, {}, /* Unused address. */ 0); } /* Put the constant back in target format. */ - v = allocate_value (type); + v = value::allocate (type); store_signed_integer (value_contents_raw (v).data (), type->length (), type_byte_order (type), var->value_longest ()); VALUE_LVAL (v) = not_lval; @@ -626,7 +626,7 @@ language_defn::read_var_value (struct symbol *var, /* Value is a constant byte-sequence and needs no memory access. */ type = resolve_dynamic_type (type, {}, /* Unused address. */ 0); } - v = allocate_value (type); + v = value::allocate (type); memcpy (value_contents_raw (v).data (), var->value_bytes (), type->length ()); VALUE_LVAL (v) = not_lval; @@ -801,7 +801,7 @@ default_value_from_register (struct gdbarch *gdbarch, struct type *type, int regnum, struct frame_id frame_id) { int len = type->length (); - struct value *value = allocate_value (type); + struct value *value = value::allocate (type); frame_info_ptr frame; VALUE_LVAL (value) = lval_register; @@ -895,7 +895,7 @@ value_from_register (struct type *type, int regnum, frame_info_ptr frame) the corresponding [integer] type (see Alpha). The assumption is that gdbarch_register_to_value populates the entire value including the location. */ - v = allocate_value (type); + v = value::allocate (type); VALUE_LVAL (v) = lval_register; VALUE_NEXT_FRAME_ID (v) = get_frame_id (get_next_frame_sentinel_okay (frame)); VALUE_REGNUM (v) = regnum; diff --git a/gdb/gdbtypes.h b/gdb/gdbtypes.h index 2a1bf31f290..c2253310666 100644 --- a/gdb/gdbtypes.h +++ b/gdb/gdbtypes.h @@ -931,7 +931,7 @@ struct type /* Note that if thistype is a TYPEDEF type, you have to call check_typedef. But check_typedef does set the TYPE_LENGTH of the TYPEDEF type, - so you only have to call check_typedef once. Since allocate_value + so you only have to call check_typedef once. Since value::allocate calls check_typedef, X->type ()->length () is safe. */ ULONGEST length () const { diff --git a/gdb/i386-tdep.c b/gdb/i386-tdep.c index f2f8db3aa2c..5857e16ff36 100644 --- a/gdb/i386-tdep.c +++ b/gdb/i386-tdep.c @@ -3093,7 +3093,7 @@ i386_return_value (struct gdbarch *gdbarch, struct value *function, if (read_value != nullptr) { - *read_value = allocate_value (type); + *read_value = value::allocate (type); i386_extract_return_value (gdbarch, type, regcache, value_contents_raw (*read_value).data ()); } @@ -3557,7 +3557,7 @@ i386_pseudo_register_read_value (struct gdbarch *gdbarch, { struct value *result; - result = allocate_value (register_type (gdbarch, regnum)); + result = value::allocate (register_type (gdbarch, regnum)); VALUE_LVAL (result) = lval_register; VALUE_REGNUM (result) = regnum; diff --git a/gdb/infcall.c b/gdb/infcall.c index 3e0da94ab17..05ae1638857 100644 --- a/gdb/infcall.c +++ b/gdb/infcall.c @@ -466,7 +466,7 @@ get_call_return_value (struct call_return_meta_info *ri) bool stack_temporaries = thread_stack_temporaries_enabled_p (thr); if (ri->value_type->code () == TYPE_CODE_VOID) - retval = allocate_value (ri->value_type); + retval = value::allocate (ri->value_type); else if (ri->struct_return_p) { if (stack_temporaries) diff --git a/gdb/infrun.c b/gdb/infrun.c index 9e2512e8446..acf93033a86 100644 --- a/gdb/infrun.c +++ b/gdb/infrun.c @@ -9197,7 +9197,7 @@ siginfo_make_value (struct gdbarch *gdbarch, struct internalvar *var, return allocate_computed_value (type, &siginfo_value_funcs, nullptr); } - return allocate_value (builtin_type (gdbarch)->builtin_void); + return value::allocate (builtin_type (gdbarch)->builtin_void); } diff --git a/gdb/opencl-lang.c b/gdb/opencl-lang.c index f7a22b35931..c76f948a3ed 100644 --- a/gdb/opencl-lang.c +++ b/gdb/opencl-lang.c @@ -177,7 +177,7 @@ lval_func_write (struct value *v, struct value *fromval) for (i = offset; i < n; i++) { - struct value *from_elm_val = allocate_value (eltype); + struct value *from_elm_val = value::allocate (eltype); struct value *to_elm_val = value_subscript (c->val, c->indices[i]); memcpy (value_contents_writeable (from_elm_val).data (), @@ -297,7 +297,7 @@ create_value (struct gdbarch *gdbarch, struct value *val, enum noside noside, make_cv_type (TYPE_CONST (type), TYPE_VOLATILE (type), dst_type, NULL); if (noside == EVAL_AVOID_SIDE_EFFECTS) - ret = allocate_value (dst_type); + ret = value::allocate (dst_type); else { /* Check whether to create a lvalue or not. */ @@ -310,7 +310,7 @@ create_value (struct gdbarch *gdbarch, struct value *val, enum noside noside, { int i; - ret = allocate_value (dst_type); + ret = value::allocate (dst_type); /* Copy src val contents into the destination value. */ for (i = 0; i < n; i++) @@ -464,7 +464,7 @@ opencl_logical_not (struct type *expect_type, struct expression *exp, rettype = lookup_opencl_vector_type (exp->gdbarch, TYPE_CODE_INT, eltype->length (), 0, highb - lowb + 1); - ret = allocate_value (rettype); + ret = value::allocate (rettype); for (i = 0; i < highb - lowb + 1; i++) { @@ -564,7 +564,7 @@ vector_relop (struct expression *exp, struct value *val1, struct value *val2, rettype = lookup_opencl_vector_type (exp->gdbarch, TYPE_CODE_INT, eltype1->length (), 0, highb1 - lowb1 + 1); - ret = allocate_value (rettype); + ret = value::allocate (rettype); for (i = 0; i < highb1 - lowb1 + 1; i++) { @@ -831,7 +831,7 @@ Cannot perform operation on vectors with different types")); error (_("\ Cannot perform conditional operation on vectors with different sizes")); - ret = allocate_value (type2); + ret = value::allocate (type2); for (i = 0; i < highb1 - lowb1 + 1; i++) { diff --git a/gdb/ppc-linux-tdep.c b/gdb/ppc-linux-tdep.c index 918d8aad7da..2084e2b618f 100644 --- a/gdb/ppc-linux-tdep.c +++ b/gdb/ppc-linux-tdep.c @@ -254,7 +254,7 @@ ppc_linux_return_value (struct gdbarch *gdbarch, struct value *function, gdb_byte *readbuf = nullptr; if (read_value != nullptr) { - *read_value = allocate_value (valtype); + *read_value = value::allocate (valtype); readbuf = value_contents_raw (*read_value).data (); } diff --git a/gdb/python/py-xmethods.c b/gdb/python/py-xmethods.c index d3afd26c26e..2db6793b507 100644 --- a/gdb/python/py-xmethods.c +++ b/gdb/python/py-xmethods.c @@ -580,7 +580,7 @@ python_xmethod_worker::invoke (struct value *obj, } else { - res = allocate_value (lookup_typename (current_language, + res = value::allocate (lookup_typename (current_language, "void", NULL, 0)); } diff --git a/gdb/regcache.c b/gdb/regcache.c index 4de7026fc28..4a31dd5e706 100644 --- a/gdb/regcache.c +++ b/gdb/regcache.c @@ -743,7 +743,7 @@ readable_regcache::cooked_read_value (int regnum) { struct value *result; - result = allocate_value (register_type (m_descr->gdbarch, regnum)); + result = value::allocate (register_type (m_descr->gdbarch, regnum)); VALUE_LVAL (result) = lval_register; VALUE_REGNUM (result) = regnum; diff --git a/gdb/riscv-tdep.c b/gdb/riscv-tdep.c index d34eb56c1b6..375ba4228a2 100644 --- a/gdb/riscv-tdep.c +++ b/gdb/riscv-tdep.c @@ -3277,7 +3277,7 @@ riscv_return_value (struct gdbarch *gdbarch, arg_type->length ()), type_byte_order (arg_type), arg_type->is_unsigned ()); - abi_val = allocate_value (info.type); + abi_val = value::allocate (info.type); unscaled.write (value_contents_raw (abi_val), type_byte_order (info.type), info.type->is_unsigned ()); @@ -3291,7 +3291,7 @@ riscv_return_value (struct gdbarch *gdbarch, } else { - abi_val = allocate_value (info.type); + abi_val = value::allocate (info.type); readbuf = value_contents_raw (abi_val).data (); } arg_len = info.type->length (); @@ -3408,7 +3408,7 @@ riscv_return_value (struct gdbarch *gdbarch, unscaled.read (value_contents (abi_val), type_byte_order (info.type), info.type->is_unsigned ()); - *read_value = allocate_value (arg_type); + *read_value = value::allocate (arg_type); unscaled.write (value_contents_raw (*read_value), type_byte_order (arg_type), arg_type->is_unsigned ()); diff --git a/gdb/rust-lang.c b/gdb/rust-lang.c index 8f0953649ae..edffad4afe7 100644 --- a/gdb/rust-lang.c +++ b/gdb/rust-lang.c @@ -1351,7 +1351,7 @@ eval_op_rust_array (struct type *expect_type, struct expression *exp, { struct type *arraytype = lookup_array_range_type (elt->type (), 0, copies - 1); - return allocate_value (arraytype); + return value::allocate (arraytype); } } @@ -1518,7 +1518,7 @@ rust_aggregate_operation::evaluate (struct type *expect_type, } if (noside == EVAL_AVOID_SIDE_EFFECTS) - result = allocate_value (type); + result = value::allocate (type); else result = value_at_lazy (type, addr); diff --git a/gdb/sparc-tdep.c b/gdb/sparc-tdep.c index 6c41cfd04e2..44f16215bb2 100644 --- a/gdb/sparc-tdep.c +++ b/gdb/sparc-tdep.c @@ -1530,7 +1530,7 @@ sparc32_return_value (struct gdbarch *gdbarch, struct value *function, if (read_value != nullptr) { - *read_value = allocate_value (type); + *read_value = value::allocate (type); gdb_byte *readbuf = value_contents_raw (*read_value).data (); sparc32_extract_return_value (type, regcache, readbuf); } diff --git a/gdb/std-regs.c b/gdb/std-regs.c index 4458c244122..5520789ea95 100644 --- a/gdb/std-regs.c +++ b/gdb/std-regs.c @@ -43,7 +43,7 @@ value_of_builtin_frame_fp_reg (frame_info_ptr frame, const void *baton) else { struct type *data_ptr_type = builtin_type (gdbarch)->builtin_data_ptr; - struct value *val = allocate_value (data_ptr_type); + struct value *val = value::allocate (data_ptr_type); gdb_byte *buf = value_contents_raw (val).data (); gdbarch_address_to_pointer (gdbarch, data_ptr_type, @@ -62,7 +62,7 @@ value_of_builtin_frame_pc_reg (frame_info_ptr frame, const void *baton) else { struct type *func_ptr_type = builtin_type (gdbarch)->builtin_func_ptr; - struct value *val = allocate_value (func_ptr_type); + struct value *val = value::allocate (func_ptr_type); gdb_byte *buf = value_contents_raw (val).data (); gdbarch_address_to_pointer (gdbarch, func_ptr_type, diff --git a/gdb/tracepoint.c b/gdb/tracepoint.c index 4c181dc7de7..bd02cae05ee 100644 --- a/gdb/tracepoint.c +++ b/gdb/tracepoint.c @@ -3777,12 +3777,12 @@ sdata_make_value (struct gdbarch *gdbarch, struct internalvar *var, type = init_vector_type (builtin_type (gdbarch)->builtin_true_char, buf->size ()); - v = allocate_value (type); + v = value::allocate (type); memcpy (value_contents_raw (v).data (), buf->data (), buf->size ()); return v; } else - return allocate_value (builtin_type (gdbarch)->builtin_void); + return value::allocate (builtin_type (gdbarch)->builtin_void); } #if !defined(HAVE_LIBEXPAT) diff --git a/gdb/valarith.c b/gdb/valarith.c index 47eccdbe8a0..5494dde9310 100644 --- a/gdb/valarith.c +++ b/gdb/valarith.c @@ -701,7 +701,7 @@ value_concat (struct value *arg1, struct value *arg2) lowbound, lowbound + n_elts - 1); - struct value *result = allocate_value (atype); + struct value *result = value::allocate (atype); gdb::array_view contents = value_contents_raw (result); gdb::array_view lhs_contents = value_contents (arg1); gdb::array_view rhs_contents = value_contents (arg2); @@ -854,7 +854,7 @@ fixed_point_binop (struct value *arg1, struct value *arg2, enum exp_opcode op) auto fixed_point_to_value = [type1] (const gdb_mpq &fp) { - value *fp_val = allocate_value (type1); + value *fp_val = value::allocate (type1); fp.write_fixed_point (value_contents_raw (fp_val), @@ -1164,7 +1164,7 @@ scalar_binop (struct value *arg1, struct value *arg2, enum exp_opcode op) if (is_floating_type (type1) || is_floating_type (type2)) { result_type = promotion_type (type1, type2); - val = allocate_value (result_type); + val = value::allocate (result_type); struct type *eff_type_v1, *eff_type_v2; gdb::byte_vector v1, v2; @@ -1214,7 +1214,7 @@ scalar_binop (struct value *arg1, struct value *arg2, enum exp_opcode op) result_type = type1; - val = allocate_value (result_type); + val = value::allocate (result_type); store_signed_integer (value_contents_raw (val).data (), result_type->length (), type_byte_order (result_type), @@ -1360,7 +1360,7 @@ scalar_binop (struct value *arg1, struct value *arg2, enum exp_opcode op) error (_("Invalid binary operation on numbers.")); } - val = allocate_value (result_type); + val = value::allocate (result_type); store_unsigned_integer (value_contents_raw (val).data (), val->type ()->length (), type_byte_order (result_type), @@ -1521,7 +1521,7 @@ scalar_binop (struct value *arg1, struct value *arg2, enum exp_opcode op) error (_("Invalid binary operation on numbers.")); } - val = allocate_value (result_type); + val = value::allocate (result_type); store_signed_integer (value_contents_raw (val).data (), val->type ()->length (), type_byte_order (result_type), @@ -1566,7 +1566,7 @@ value_vector_widen (struct value *scalar_value, struct type *vector_type) && !value_equal (elval, scalar_value)) error (_("conversion of scalar to vector involves truncation")); - value *val = allocate_value (vector_type); + value *val = value::allocate (vector_type); gdb::array_view val_contents = value_contents_writeable (val); int elt_len = eltype->length (); @@ -1613,7 +1613,7 @@ vector_binop (struct value *val1, struct value *val2, enum exp_opcode op) || low_bound1 != low_bound2 || high_bound1 != high_bound2) error (_("Cannot perform operation on vectors with different types")); - value *val = allocate_value (type1); + value *val = value::allocate (type1); gdb::array_view val_contents = value_contents_writeable (val); scoped_value_mark mark; for (i = 0; i < high_bound1 - low_bound1 + 1; i++) @@ -1901,7 +1901,7 @@ value_neg (struct value *arg1) return value_binop (value_zero (type, not_lval), arg1, BINOP_SUB); else if (type->code () == TYPE_CODE_ARRAY && type->is_vector ()) { - struct value *val = allocate_value (type); + struct value *val = value::allocate (type); struct type *eltype = check_typedef (type->target_type ()); int i; LONGEST low_bound, high_bound; @@ -1953,7 +1953,7 @@ value_complement (struct value *arg1) if (!get_array_bounds (type, &low_bound, &high_bound)) error (_("Could not determine the vector bounds")); - val = allocate_value (type); + val = value::allocate (type); gdb::array_view val_contents = value_contents_writeable (val); int elt_len = eltype->length (); diff --git a/gdb/valops.c b/gdb/valops.c index 3f91f720aee..19f5fb6f3c9 100644 --- a/gdb/valops.c +++ b/gdb/valops.c @@ -391,7 +391,7 @@ value_cast_to_fixed_point (struct type *to_type, struct value *from_val) /* Finally, create the result value, and pack the unscaled value in it. */ - struct value *result = allocate_value (to_type); + struct value *result = value::allocate (to_type); unscaled.write (value_contents_raw (result), type_byte_order (to_type), to_type->is_unsigned ()); @@ -543,7 +543,7 @@ value_cast (struct type *type, struct value *arg2) { if (is_floating_value (arg2)) { - struct value *v = allocate_value (to_type); + struct value *v = value::allocate (to_type); target_float_convert (value_contents (arg2).data (), type2, value_contents_raw (v).data (), type); return v; @@ -557,7 +557,7 @@ value_cast (struct type *type, struct value *arg2) type2->is_unsigned (), type2->fixed_point_scaling_factor ()); - struct value *v = allocate_value (to_type); + struct value *v = value::allocate (to_type); target_float_from_host_double (value_contents_raw (v).data (), to_type, mpq_get_d (fp_val.val)); return v; @@ -618,7 +618,7 @@ value_cast (struct type *type, struct value *arg2) else if (code1 == TYPE_CODE_METHODPTR && code2 == TYPE_CODE_INT && value_as_long (arg2) == 0) { - struct value *result = allocate_value (to_type); + struct value *result = value::allocate (to_type); cplus_make_method_ptr (to_type, value_contents_writeable (result).data (), 0, 0); @@ -954,7 +954,7 @@ value_one (struct type *type) if (!get_array_bounds (type1, &low_bound, &high_bound)) error (_("Could not determine the vector bounds")); - val = allocate_value (type); + val = value::allocate (type); gdb::array_view val_contents = value_contents_writeable (val); int elt_len = eltype->length (); @@ -1724,7 +1724,7 @@ value_array (int lowbound, int highbound, struct value **elemvec) if (!current_language->c_style_arrays_p ()) { - val = allocate_value (arraytype); + val = value::allocate (arraytype); for (idx = 0; idx < nelem; idx++) value_contents_copy (val, idx * typelength, elemvec[idx], 0, typelength); @@ -1734,7 +1734,7 @@ value_array (int lowbound, int highbound, struct value **elemvec) /* Allocate space to store the array, and then initialize it by copying in each element. */ - val = allocate_value (arraytype); + val = value::allocate (arraytype); for (idx = 0; idx < nelem; idx++) value_contents_copy (val, idx * typelength, elemvec[idx], 0, typelength); return val; @@ -1749,7 +1749,7 @@ value_cstring (const char *ptr, ssize_t len, struct type *char_type) struct type *stringtype = lookup_array_range_type (char_type, lowbound, highbound + lowbound - 1); - val = allocate_value (stringtype); + val = value::allocate (stringtype); memcpy (value_contents_raw (val).data (), ptr, len); return val; } @@ -1772,7 +1772,7 @@ value_string (const char *ptr, ssize_t len, struct type *char_type) struct type *stringtype = lookup_string_range_type (char_type, lowbound, highbound + lowbound - 1); - val = allocate_value (stringtype); + val = value::allocate (stringtype); memcpy (value_contents_raw (val).data (), ptr, len); return val; } @@ -3598,7 +3598,7 @@ value_struct_elt_for_reference (struct type *domain, int offset, (lookup_memberptr_type (t->field (i).type (), domain), offset + (LONGEST) (t->field (i).loc_bitpos () >> 3)); else if (noside != EVAL_NORMAL) - return allocate_value (t->field (i).type ()); + return value::allocate (t->field (i).type ()); else { /* Try to evaluate NAME as a qualified name with implicit @@ -3737,14 +3737,14 @@ value_struct_elt_for_reference (struct type *domain, int offset, { if (want_address) { - result = allocate_value + result = value::allocate (lookup_methodptr_type (TYPE_FN_FIELD_TYPE (f, j))); cplus_make_method_ptr (result->type (), value_contents_writeable (result).data (), TYPE_FN_FIELD_VOFFSET (f, j), 1); } else if (noside == EVAL_AVOID_SIDE_EFFECTS) - return allocate_value (TYPE_FN_FIELD_TYPE (f, j)); + return value::allocate (TYPE_FN_FIELD_TYPE (f, j)); else error (_("Cannot reference virtual member function \"%s\""), name); @@ -3763,7 +3763,7 @@ value_struct_elt_for_reference (struct type *domain, int offset, result = v; else { - result = allocate_value (lookup_methodptr_type (TYPE_FN_FIELD_TYPE (f, j))); + result = value::allocate (lookup_methodptr_type (TYPE_FN_FIELD_TYPE (f, j))); cplus_make_method_ptr (result->type (), value_contents_writeable (result).data (), v->address (), 0); @@ -3839,7 +3839,7 @@ value_maybe_namespace_elt (const struct type *curtype, return NULL; else if ((noside == EVAL_AVOID_SIDE_EFFECTS) && (sym.symbol->aclass () == LOC_TYPEDEF)) - result = allocate_value (sym.symbol->type ()); + result = value::allocate (sym.symbol->type ()); else result = value_of_variable (sym.symbol, sym.block); @@ -4082,7 +4082,7 @@ value_slice (struct value *array, int lowbound, int length) slice = value::allocate_lazy (slice_type); else { - slice = allocate_value (slice_type); + slice = value::allocate (slice_type); value_contents_copy (slice, 0, array, offset, type_length_units (slice_type)); } @@ -4104,7 +4104,7 @@ value_literal_complex (struct value *arg1, struct value *val; struct type *real_type = type->target_type (); - val = allocate_value (type); + val = value::allocate (type); arg1 = value_cast (real_type, arg1); arg2 = value_cast (real_type, arg2); @@ -4153,8 +4153,8 @@ cast_into_complex (struct type *type, struct value *val) if (val->type ()->code () == TYPE_CODE_COMPLEX) { struct type *val_real_type = val->type ()->target_type (); - struct value *re_val = allocate_value (val_real_type); - struct value *im_val = allocate_value (val_real_type); + struct value *re_val = value::allocate (val_real_type); + struct value *im_val = value::allocate (val_real_type); int len = val_real_type->length (); copy (value_contents (val).slice (0, len), diff --git a/gdb/valprint.c b/gdb/valprint.c index 20cf64ad2c4..4a2aa5f4878 100644 --- a/gdb/valprint.c +++ b/gdb/valprint.c @@ -3091,7 +3091,7 @@ test_print_flags (gdbarch *arch) append_flags_type_field (flags_type, 3, 2, field_type, "B"); append_flags_type_field (flags_type, 5, 3, field_type, "C"); - value *val = allocate_value (flags_type); + value *val = value::allocate (flags_type); gdb_byte *contents = value_contents_writeable (val).data (); store_unsigned_integer (contents, 4, gdbarch_byte_order (arch), 0xaa); diff --git a/gdb/value.c b/gdb/value.c index 9dd6b77443c..b3ae930f8d6 100644 --- a/gdb/value.c +++ b/gdb/value.c @@ -834,10 +834,8 @@ allocate_value_contents (struct value *val) } } -/* Allocate a value and its contents for type TYPE. */ - struct value * -allocate_value (struct type *type) +value::allocate (struct type *type) { struct value *val = value::allocate_lazy (type); @@ -861,7 +859,7 @@ allocate_repeat_value (struct type *type, int count) struct type *array_type = lookup_array_range_type (type, low_bound, count + low_bound - 1); - return allocate_value (array_type); + return value::allocate (array_type); } struct value * @@ -1417,7 +1415,7 @@ value_copy (const value *arg) if (arg->lazy ()) val = value::allocate_lazy (encl_type); else - val = allocate_value (encl_type); + val = value::allocate (encl_type); val->m_type = arg->m_type; VALUE_LVAL (val) = arg->m_lval; val->m_location = arg->m_location; @@ -1481,7 +1479,7 @@ value_non_lval (struct value *arg) if (VALUE_LVAL (arg) != not_lval) { struct type *enc_type = arg->enclosing_type (); - struct value *val = allocate_value (enc_type); + struct value *val = value::allocate (enc_type); copy (value_contents_all (arg), value_contents_all_raw (val)); val->m_type = arg->m_type; @@ -1913,18 +1911,18 @@ value_of_internalvar (struct gdbarch *gdbarch, struct internalvar *var) val = value_from_longest (builtin_type (gdbarch)->builtin_int64, tsv->value); else - val = allocate_value (builtin_type (gdbarch)->builtin_void); + val = value::allocate (builtin_type (gdbarch)->builtin_void); return val; } switch (var->kind) { case INTERNALVAR_VOID: - val = allocate_value (builtin_type (gdbarch)->builtin_void); + val = value::allocate (builtin_type (gdbarch)->builtin_void); break; case INTERNALVAR_FUNCTION: - val = allocate_value (builtin_type (gdbarch)->internal_fn); + val = value::allocate (builtin_type (gdbarch)->internal_fn); break; case INTERNALVAR_INTEGER: @@ -2402,7 +2400,7 @@ value_from_xmethod (xmethod_worker_up &&worker) { struct value *v; - v = allocate_value (builtin_type (target_gdbarch ())->xmethod); + v = value::allocate (builtin_type (target_gdbarch ())->xmethod); v->m_lval = lval_xcallable; v->m_location.xm_worker = worker.release (); v->m_modifiable = 0; @@ -2825,7 +2823,7 @@ value_primitive_field (struct value *arg1, LONGEST offset, v = value::allocate_lazy (arg1->enclosing_type ()); else { - v = allocate_value (arg1->enclosing_type ()); + v = value::allocate (arg1->enclosing_type ()); value_contents_copy_raw (v, 0, arg1, 0, arg1->enclosing_type ()->length ()); } @@ -2858,7 +2856,7 @@ value_primitive_field (struct value *arg1, LONGEST offset, v = value::allocate_lazy (type); else { - v = allocate_value (type); + v = value::allocate (type); value_contents_copy_raw (v, v->embedded_offset (), arg1, arg1->embedded_offset () + offset, type_length_units (type)); @@ -2906,7 +2904,7 @@ value_fn_field (struct value **arg1p, struct fn_field *f, return NULL; } - v = allocate_value (ftype); + v = value::allocate (ftype); VALUE_LVAL (v) = lval_memory; if (sym) { @@ -3095,7 +3093,7 @@ value_field_bitfield (struct type *type, int fieldno, { int bitpos = type->field (fieldno).loc_bitpos (); int bitsize = TYPE_FIELD_BITSIZE (type, fieldno); - struct value *res_val = allocate_value (type->field (fieldno).type ()); + struct value *res_val = value::allocate (type->field (fieldno).type ()); unpack_value_bitfield (res_val, bitpos, bitsize, valaddr, embedded_offset, val); @@ -3272,7 +3270,7 @@ value_zero (struct type *type, enum lval_type lv) struct value * value_from_longest (struct type *type, LONGEST num) { - struct value *val = allocate_value (type); + struct value *val = value::allocate (type); pack_long (value_contents_raw (val).data (), type, num); return val; @@ -3284,7 +3282,7 @@ value_from_longest (struct type *type, LONGEST num) struct value * value_from_ulongest (struct type *type, ULONGEST num) { - struct value *val = allocate_value (type); + struct value *val = value::allocate (type); pack_unsigned_long (value_contents_raw (val).data (), type, num); @@ -3298,7 +3296,7 @@ value_from_ulongest (struct type *type, ULONGEST num) struct value * value_from_pointer (struct type *type, CORE_ADDR addr) { - struct value *val = allocate_value (type); + struct value *val = value::allocate (type); store_typed_address (value_contents_raw (val).data (), check_typedef (type), addr); @@ -3312,7 +3310,7 @@ value_from_pointer (struct type *type, CORE_ADDR addr) struct value * value_from_host_double (struct type *type, double d) { - struct value *value = allocate_value (type); + struct value *value = value::allocate (type); gdb_assert (type->code () == TYPE_CODE_FLT); target_float_from_host_double (value_contents_raw (value).data (), value->type (), d); @@ -3379,7 +3377,7 @@ value_from_contents (struct type *type, const gdb_byte *contents) { struct value *result; - result = allocate_value (type); + result = value::allocate (type); memcpy (value_contents_raw (result).data (), contents, type->length ()); return result; } @@ -3459,7 +3457,7 @@ value_from_component (struct value *whole, struct type *type, LONGEST offset) v = value::allocate_lazy (type); else { - v = allocate_value (type); + v = value::allocate (type); value_contents_copy (v, v->embedded_offset (), whole, whole->embedded_offset () + offset, type_length_units (type)); @@ -3486,7 +3484,7 @@ value_from_component_bitsize (struct value *whole, struct type *type, && bit_length == TARGET_CHAR_BIT * type->length ()) return value_from_component (whole, type, bit_offset / TARGET_CHAR_BIT); - struct value *v = allocate_value (type); + struct value *v = value::allocate (type); LONGEST dst_offset = TARGET_CHAR_BIT * v->embedded_offset (); if (is_scalar_type (type) && type_byte_order (type) == BFD_ENDIAN_BIG) diff --git a/gdb/value.h b/gdb/value.h index 5fab4e19508..e12b22e659f 100644 --- a/gdb/value.h +++ b/gdb/value.h @@ -165,6 +165,9 @@ struct value NULL; it will be allocated when it is fetched from the target. */ static struct value *allocate_lazy (struct type *type); + /* Allocate a value and its contents for type TYPE. */ + static struct value *allocate (struct type *type); + ~value (); DISABLE_COPY_AND_ASSIGN (value); @@ -1001,8 +1004,6 @@ extern struct value *read_var_value (struct symbol *var, const struct block *var_block, frame_info_ptr frame); -extern struct value *allocate_value (struct type *type); - extern void value_contents_copy (struct value *dst, LONGEST dst_offset, struct value *src, LONGEST src_offset, LONGEST length); diff --git a/gdb/windows-tdep.c b/gdb/windows-tdep.c index af21aa159f4..741333cf677 100644 --- a/gdb/windows-tdep.c +++ b/gdb/windows-tdep.c @@ -436,7 +436,7 @@ tlb_make_value (struct gdbarch *gdbarch, struct internalvar *var, void *ignore) return allocate_computed_value (type, &tlb_value_funcs, NULL); } - return allocate_value (builtin_type (gdbarch)->builtin_void); + return value::allocate (builtin_type (gdbarch)->builtin_void); } From patchwork Thu Feb 9 21:38:44 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tom Tromey X-Patchwork-Id: 64575 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 A50023838213 for ; Thu, 9 Feb 2023 21:41:44 +0000 (GMT) X-Original-To: gdb-patches@sourceware.org Delivered-To: gdb-patches@sourceware.org Received: from gproxy3-pub.mail.unifiedlayer.com (gproxy3-pub.mail.unifiedlayer.com [69.89.30.42]) by sourceware.org (Postfix) with ESMTPS id 96CB6385783F for ; Thu, 9 Feb 2023 21:38:43 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 96CB6385783F 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 cmgw13.mail.unifiedlayer.com (unknown [10.0.90.128]) by progateway5.mail.pro1.eigbox.com (Postfix) with ESMTP id F19B210073828 for ; Thu, 9 Feb 2023 21:38:42 +0000 (UTC) Received: from box5379.bluehost.com ([162.241.216.53]) by cmsmtp with ESMTP id QEcspHudINX2aQEcsp2uCh; Thu, 09 Feb 2023 21:38:42 +0000 X-Authority-Reason: nr=8 X-Authority-Analysis: v=2.4 cv=NMAQR22g c=1 sm=1 tr=0 ts=63e567e2 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=ur03xR3Ox81Jt2WO-b0A: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=lNi7Hss3SC7KGTXJzDQVKXu1Sczw+QfssMKztctoVZ4=; b=cau1UbomqotZKBr/hwZLUUZaCS hLAya2AnbS6/+tOutEPx6+c3MJewzwwIjg0kNcRcMsPIk6EhKbp/bkr/9NRAAz2rx0XtxcvjSSMWm 6P85FKsBDq2Nhvp/rKfebNx1/; 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 1pQEcs-001ZcE-QE for gdb-patches@sourceware.org; Thu, 09 Feb 2023 14:38:42 -0700 From: Tom Tromey Date: Thu, 09 Feb 2023 14:38:44 -0700 Subject: [PATCH 23/47] Turn allocate_computed_value into static "constructor" MIME-Version: 1.0 Message-Id: <20230209-submit-value-fixups-2023-v1-23-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: 1pQEcs-001ZcE-QE 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: 24 X-Source-Cap: ZWx5bnJvYmk7ZWx5bnJvYmk7Ym94NTM3OS5ibHVlaG9zdC5jb20= X-Local-Domain: yes X-Spam-Status: No, score=-3027.5 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 turns allocate_computed_value into a static "constructor" of value. --- gdb/dwarf2/expr.c | 2 +- gdb/dwarf2/loc.c | 2 +- gdb/infrun.c | 2 +- gdb/opencl-lang.c | 2 +- gdb/value.c | 6 +++--- gdb/value.h | 13 ++++++------- gdb/windows-tdep.c | 2 +- 7 files changed, 14 insertions(+), 15 deletions(-) diff --git a/gdb/dwarf2/expr.c b/gdb/dwarf2/expr.c index fc92de85840..ad6cf563562 100644 --- a/gdb/dwarf2/expr.c +++ b/gdb/dwarf2/expr.c @@ -932,7 +932,7 @@ dwarf_expr_context::fetch_result (struct type *type, struct type *subobj_type, piece_closure *c = allocate_piece_closure (this->m_per_cu, this->m_per_objfile, std::move (this->m_pieces), this->m_frame); - retval = allocate_computed_value (subobj_type, + retval = value::allocate_computed (subobj_type, &pieced_value_funcs, c); retval->set_offset (subobj_offset); } diff --git a/gdb/dwarf2/loc.c b/gdb/dwarf2/loc.c index 2e0b4a8b45d..743a0cefd6d 100644 --- a/gdb/dwarf2/loc.c +++ b/gdb/dwarf2/loc.c @@ -1359,7 +1359,7 @@ value_of_dwarf_reg_entry (struct type *type, frame_info_ptr frame, caller_per_cu, caller_per_objfile); - val = allocate_computed_value (type, &entry_data_value_funcs, + val = value::allocate_computed (type, &entry_data_value_funcs, release_value (target_val).release ()); /* Copy the referencing pointer to the new computed value. */ diff --git a/gdb/infrun.c b/gdb/infrun.c index acf93033a86..c45c6b5c802 100644 --- a/gdb/infrun.c +++ b/gdb/infrun.c @@ -9194,7 +9194,7 @@ siginfo_make_value (struct gdbarch *gdbarch, struct internalvar *var, { struct type *type = gdbarch_get_siginfo_type (gdbarch); - return allocate_computed_value (type, &siginfo_value_funcs, nullptr); + return value::allocate_computed (type, &siginfo_value_funcs, nullptr); } return value::allocate (builtin_type (gdbarch)->builtin_void); diff --git a/gdb/opencl-lang.c b/gdb/opencl-lang.c index c76f948a3ed..25be86ee98a 100644 --- a/gdb/opencl-lang.c +++ b/gdb/opencl-lang.c @@ -304,7 +304,7 @@ create_value (struct gdbarch *gdbarch, struct value *val, enum noside noside, if (VALUE_LVAL (val) != not_lval && !array_has_dups (indices, n)) { struct lval_closure *c = allocate_lval_closure (indices, n, val); - ret = allocate_computed_value (dst_type, &opencl_value_funcs, c); + ret = value::allocate_computed (dst_type, &opencl_value_funcs, c); } else { diff --git a/gdb/value.c b/gdb/value.c index b3ae930f8d6..24cb9c51b8d 100644 --- a/gdb/value.c +++ b/gdb/value.c @@ -863,9 +863,9 @@ allocate_repeat_value (struct type *type, int count) } struct value * -allocate_computed_value (struct type *type, - const struct lval_funcs *funcs, - void *closure) +value::allocate_computed (struct type *type, + const struct lval_funcs *funcs, + void *closure) { struct value *v = value::allocate_lazy (type); diff --git a/gdb/value.h b/gdb/value.h index e12b22e659f..8e408da2bb6 100644 --- a/gdb/value.h +++ b/gdb/value.h @@ -168,6 +168,12 @@ struct value /* Allocate a value and its contents for type TYPE. */ static struct value *allocate (struct type *type); + /* Create a computed lvalue, with type TYPE, function pointers + FUNCS, and closure CLOSURE. */ + static struct value *allocate_computed (struct type *type, + const struct lval_funcs *funcs, + void *closure); + ~value (); DISABLE_COPY_AND_ASSIGN (value); @@ -603,13 +609,6 @@ struct lval_funcs void (*free_closure) (struct value *v); }; -/* Create a computed lvalue, with type TYPE, function pointers FUNCS, - and closure CLOSURE. */ - -extern struct value *allocate_computed_value (struct type *type, - const struct lval_funcs *funcs, - void *closure); - extern struct value *allocate_optimized_out_value (struct type *type); /* Throw an error complaining that the value has been optimized diff --git a/gdb/windows-tdep.c b/gdb/windows-tdep.c index 741333cf677..893e34d9912 100644 --- a/gdb/windows-tdep.c +++ b/gdb/windows-tdep.c @@ -433,7 +433,7 @@ tlb_make_value (struct gdbarch *gdbarch, struct internalvar *var, void *ignore) if (target_has_stack () && inferior_ptid != null_ptid) { struct type *type = windows_get_tlb_type (gdbarch); - return allocate_computed_value (type, &tlb_value_funcs, NULL); + return value::allocate_computed (type, &tlb_value_funcs, NULL); } return value::allocate (builtin_type (gdbarch)->builtin_void); From patchwork Thu Feb 9 21:38:45 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tom Tromey X-Patchwork-Id: 64576 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 8EF2F38A9085 for ; Thu, 9 Feb 2023 21:41:59 +0000 (GMT) X-Original-To: gdb-patches@sourceware.org Delivered-To: gdb-patches@sourceware.org Received: from gproxy3-pub.mail.unifiedlayer.com (gproxy3-pub.mail.unifiedlayer.com [69.89.30.42]) by sourceware.org (Postfix) with ESMTPS id B80CA385AC39 for ; Thu, 9 Feb 2023 21:38:43 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org B80CA385AC39 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 cmgw11.mail.unifiedlayer.com (unknown [10.0.90.126]) by progateway5.mail.pro1.eigbox.com (Postfix) with ESMTP id 1DA8C1007382B for ; Thu, 9 Feb 2023 21:38:43 +0000 (UTC) Received: from box5379.bluehost.com ([162.241.216.53]) by cmsmtp with ESMTP id QEctphyCy2s14QEctphhn3; Thu, 09 Feb 2023 21:38:43 +0000 X-Authority-Reason: nr=8 X-Authority-Analysis: v=2.4 cv=R7DGpfdX c=1 sm=1 tr=0 ts=63e567e3 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=YuOaWP3hLCLYxZglITYA: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=1NJquZR+V8KNEmCibjmjRRgbYFbXIBDYiiwLdQbMDxs=; b=kCo5OUrpk+G8xtDPQhDxcuq1/m Rwon5uy8SqzDzkYIkmoe+MPYhOi4yoOujrSiN0Z6oH5FBbBPco9pj510nTKLr6oiMbepKB/0bg1tJ ze4H+c60Y0oeFKYm/ADbUBwum; 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 1pQEcs-001ZcE-VH for gdb-patches@sourceware.org; Thu, 09 Feb 2023 14:38:42 -0700 From: Tom Tromey Date: Thu, 09 Feb 2023 14:38:45 -0700 Subject: [PATCH 24/47] Turn allocate_optimized_out_value into static "constructor" MIME-Version: 1.0 Message-Id: <20230209-submit-value-fixups-2023-v1-24-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: 1pQEcs-001ZcE-VH 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: 25 X-Source-Cap: ZWx5bnJvYmk7ZWx5bnJvYmk7Ym94NTM3OS5ibHVlaG9zdC5jb20= X-Local-Domain: yes X-Spam-Status: No, score=-3027.5 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 turns allocate_optimized_out_value into a static "constructor" of value. --- gdb/ada-lang.c | 2 +- gdb/dwarf2/expr.c | 2 +- gdb/dwarf2/loc.c | 10 +++++----- gdb/eval.c | 2 +- gdb/findvar.c | 2 +- gdb/frame-unwind.c | 2 +- gdb/python/py-type.c | 2 +- gdb/s390-tdep.c | 2 +- gdb/stack.c | 2 +- gdb/value.c | 10 +++++----- gdb/value.h | 5 +++-- 11 files changed, 21 insertions(+), 20 deletions(-) diff --git a/gdb/ada-lang.c b/gdb/ada-lang.c index 3d2c9f4f2ab..727f816b519 100644 --- a/gdb/ada-lang.c +++ b/gdb/ada-lang.c @@ -556,7 +556,7 @@ coerce_unspec_val_to_type (struct value *val, struct type *type) struct value *result; if (value_optimized_out (val)) - result = allocate_optimized_out_value (type); + result = value::allocate_optimized_out (type); else if (val->lazy () /* Be careful not to make a lazy not_lval value. */ || (VALUE_LVAL (val) != not_lval diff --git a/gdb/dwarf2/expr.c b/gdb/dwarf2/expr.c index ad6cf563562..db88dc368fd 100644 --- a/gdb/dwarf2/expr.c +++ b/gdb/dwarf2/expr.c @@ -1044,7 +1044,7 @@ dwarf_expr_context::fetch_result (struct type *type, struct type *subobj_type, break; case DWARF_VALUE_OPTIMIZED_OUT: - retval = allocate_optimized_out_value (subobj_type); + retval = value::allocate_optimized_out (subobj_type); break; /* DWARF_VALUE_IMPLICIT_POINTER was converted to a pieced diff --git a/gdb/dwarf2/loc.c b/gdb/dwarf2/loc.c index 743a0cefd6d..96686d9a110 100644 --- a/gdb/dwarf2/loc.c +++ b/gdb/dwarf2/loc.c @@ -1429,7 +1429,7 @@ fetch_const_value_from_synthetic_pointer (sect_offset die, LONGEST byte_offset, invalid_synthetic_pointer (); } else - result = allocate_optimized_out_value (type->target_type ()); + result = value::allocate_optimized_out (type->target_type ()); return result; } @@ -1497,7 +1497,7 @@ dwarf2_evaluate_loc_desc_full (struct type *type, frame_info_ptr frame, invalid_synthetic_pointer (); if (size == 0) - return allocate_optimized_out_value (subobj_type); + return value::allocate_optimized_out (subobj_type); dwarf_expr_context ctx (per_objfile, per_cu->addr_size ()); @@ -1524,7 +1524,7 @@ dwarf2_evaluate_loc_desc_full (struct type *type, frame_info_ptr frame, if (entry_values_debug) exception_print (gdb_stdout, ex); free_values.free_to_mark (); - return allocate_optimized_out_value (subobj_type); + return value::allocate_optimized_out (subobj_type); } else throw; @@ -3906,11 +3906,11 @@ loclist_read_variable_at_entry (struct symbol *symbol, frame_info_ptr frame) CORE_ADDR pc; if (frame == NULL || !get_frame_func_if_available (frame, &pc)) - return allocate_optimized_out_value (symbol->type ()); + return value::allocate_optimized_out (symbol->type ()); data = dwarf2_find_location_expression (dlbaton, &size, pc); if (data == NULL) - return allocate_optimized_out_value (symbol->type ()); + return value::allocate_optimized_out (symbol->type ()); return value_of_dwarf_block_entry (symbol->type (), frame, data, size); } diff --git a/gdb/eval.c b/gdb/eval.c index 5f8d294322b..bb72043a28a 100644 --- a/gdb/eval.c +++ b/gdb/eval.c @@ -2855,7 +2855,7 @@ var_value_operation::evaluate_for_sizeof (struct expression *exp, return value_zero (size_type, not_lval); else if (is_dynamic_type (type->index_type ()) && type->bounds ()->high.kind () == PROP_UNDEFINED) - return allocate_optimized_out_value (size_type); + return value::allocate_optimized_out (size_type); } } return evaluate_subexp_for_sizeof_base (exp, type); diff --git a/gdb/findvar.c b/gdb/findvar.c index b59962c65ba..048e439ac33 100644 --- a/gdb/findvar.c +++ b/gdb/findvar.c @@ -769,7 +769,7 @@ language_defn::read_var_value (struct symbol *var, case LOC_OPTIMIZED_OUT: if (is_dynamic_type (type)) type = resolve_dynamic_type (type, {}, /* Unused address. */ 0); - return allocate_optimized_out_value (type); + return value::allocate_optimized_out (type); default: error (_("Cannot look up value of a botched symbol `%s'."), diff --git a/gdb/frame-unwind.c b/gdb/frame-unwind.c index 1e5e821beba..6c8a094242f 100644 --- a/gdb/frame-unwind.c +++ b/gdb/frame-unwind.c @@ -266,7 +266,7 @@ frame_unwind_got_optimized (frame_info_ptr frame, int regnum) struct gdbarch *gdbarch = frame_unwind_arch (frame); struct type *type = register_type (gdbarch, regnum); - return allocate_optimized_out_value (type); + return value::allocate_optimized_out (type); } /* Return a value which indicates that FRAME copied REGNUM into diff --git a/gdb/python/py-type.c b/gdb/python/py-type.c index 81b595140af..0a3787815ec 100644 --- a/gdb/python/py-type.c +++ b/gdb/python/py-type.c @@ -1189,7 +1189,7 @@ typy_optimized_out (PyObject *self, PyObject *args) { struct type *type = ((type_object *) self)->type; - return value_to_value_object (allocate_optimized_out_value (type)); + return value_to_value_object (value::allocate_optimized_out (type)); } /* Return a gdb.Field object for the field named by the argument. */ diff --git a/gdb/s390-tdep.c b/gdb/s390-tdep.c index 9aa2c06cec1..822f66dfc3c 100644 --- a/gdb/s390-tdep.c +++ b/gdb/s390-tdep.c @@ -2239,7 +2239,7 @@ s390_unwind_pseudo_register (frame_info_ptr this_frame, int regnum) return value_cast (type, val); } - return allocate_optimized_out_value (type); + return value::allocate_optimized_out (type); } /* Translate a .eh_frame register to DWARF register, or adjust a diff --git a/gdb/stack.c b/gdb/stack.c index 9952c3a73df..ca6087f3414 100644 --- a/gdb/stack.c +++ b/gdb/stack.c @@ -674,7 +674,7 @@ read_frame_arg (const frame_print_options &fp_opts, || (fp_opts.print_entry_values == print_entry_values_preferred && (!val || value_optimized_out (val)))) { - entryval = allocate_optimized_out_value (sym->type ()); + entryval = value::allocate_optimized_out (sym->type ()); entryval_error = NULL; } } diff --git a/gdb/value.c b/gdb/value.c index 24cb9c51b8d..f0e58a41768 100644 --- a/gdb/value.c +++ b/gdb/value.c @@ -876,10 +876,10 @@ value::allocate_computed (struct type *type, return v; } -/* Allocate NOT_LVAL value for type TYPE being OPTIMIZED_OUT. */ +/* See value.h. */ struct value * -allocate_optimized_out_value (struct type *type) +value::allocate_optimized_out (struct type *type) { struct value *retval = value::allocate_lazy (type); @@ -2709,7 +2709,7 @@ value_static_field (struct type *type, int fieldno) struct type *field_type = type->field (fieldno).type (); if (!msym.minsym) - retval = allocate_optimized_out_value (field_type); + retval = value::allocate_optimized_out (field_type); else retval = value_at_lazy (field_type, msym.value_address ()); } @@ -3058,7 +3058,7 @@ unpack_value_bitfield (struct value *dest_val, valid. Optimized out/unavailable bits are read as zero, but that's OK, as they'll end up marked below. If the VAL is wholly-invalid we may have skipped allocating its contents, - though. See allocate_optimized_out_value. */ + though. See value::allocate_optimized_out. */ if (valaddr != NULL) { LONGEST num; @@ -4017,7 +4017,7 @@ test_value_copy () /* Verify that we can copy an entirely optimized out value, that may not have its contents allocated. */ - value_ref_ptr val = release_value (allocate_optimized_out_value (type)); + value_ref_ptr val = release_value (value::allocate_optimized_out (type)); value_ref_ptr copy = release_value (value_copy (val.get ())); SELF_CHECK (value_entirely_optimized_out (val.get ())); diff --git a/gdb/value.h b/gdb/value.h index 8e408da2bb6..771e50a0b38 100644 --- a/gdb/value.h +++ b/gdb/value.h @@ -174,6 +174,9 @@ struct value const struct lval_funcs *funcs, void *closure); + /* Allocate NOT_LVAL value for type TYPE being OPTIMIZED_OUT. */ + static struct value *allocate_optimized_out (struct type *type); + ~value (); DISABLE_COPY_AND_ASSIGN (value); @@ -609,8 +612,6 @@ struct lval_funcs void (*free_closure) (struct value *v); }; -extern struct value *allocate_optimized_out_value (struct type *type); - /* Throw an error complaining that the value has been optimized out. */ From patchwork Thu Feb 9 21:38:46 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tom Tromey X-Patchwork-Id: 64578 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 5139F392AC33 for ; Thu, 9 Feb 2023 21:42:17 +0000 (GMT) X-Original-To: gdb-patches@sourceware.org Delivered-To: gdb-patches@sourceware.org Received: from gproxy3-pub.mail.unifiedlayer.com (gproxy3-pub.mail.unifiedlayer.com [69.89.30.42]) by sourceware.org (Postfix) with ESMTPS id DFF18385B50C for ; Thu, 9 Feb 2023 21:38:43 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org DFF18385B50C 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 cmgw14.mail.unifiedlayer.com (unknown [10.0.90.129]) by progateway5.mail.pro1.eigbox.com (Postfix) with ESMTP id 45B4010073834 for ; Thu, 9 Feb 2023 21:38:43 +0000 (UTC) Received: from box5379.bluehost.com ([162.241.216.53]) by cmsmtp with ESMTP id QEctpLOrnGAj8QEctphq4M; Thu, 09 Feb 2023 21:38:43 +0000 X-Authority-Reason: nr=8 X-Authority-Analysis: v=2.4 cv=UdyU9IeN c=1 sm=1 tr=0 ts=63e567e3 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=oVhV4unvaFiFioCitJwA: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=qO43N0DU9bPyD3T2eluVjP4CrOAKv3frb9hvEbe1veI=; b=wBNRfSE8qV2zPWX0mn2xK8L9xw TxS3y3dOElOqNk8MFmsO1xg1eibjXw4HHP3QeZKfaHAo7IB3yKq6gjQ6IjxGi7+MyaX09WWVCjyKt HQLlXJMv8phLXm8+pF95WYFSM; 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-37 for gdb-patches@sourceware.org; Thu, 09 Feb 2023 14:38:43 -0700 From: Tom Tromey Date: Thu, 09 Feb 2023 14:38:46 -0700 Subject: [PATCH 25/47] Turn value_zero into static "constructor" MIME-Version: 1.0 Message-Id: <20230209-submit-value-fixups-2023-v1-25-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-37 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: 26 X-Source-Cap: ZWx5bnJvYmk7ZWx5bnJvYmk7Ym94NTM3OS5ibHVlaG9zdC5jb20= X-Local-Domain: yes X-Spam-Status: No, score=-3026.8 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, GIT_PATCH_0, JMQ_SPF_NEUTRAL, KAM_STOCKGEN, 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 turns value_zero into a static "constructor" of value. --- gdb/ada-lang.c | 42 +++++++++++++++++++++--------------------- gdb/dummy-frame.c | 2 +- gdb/dwarf2/expr.c | 2 +- gdb/eval.c | 44 ++++++++++++++++++++++---------------------- gdb/f-lang.c | 4 ++-- gdb/frame-unwind.c | 6 +++--- gdb/guile/scm-math.c | 2 +- gdb/m2-lang.c | 2 +- gdb/opencl-lang.c | 4 ++-- gdb/python/py-value.c | 2 +- gdb/rust-lang.c | 8 ++++---- gdb/valarith.c | 14 +++++++------- gdb/valops.c | 10 +++++----- gdb/value.c | 5 ++--- gdb/value.h | 7 ++++--- 15 files changed, 77 insertions(+), 77 deletions(-) diff --git a/gdb/ada-lang.c b/gdb/ada-lang.c index 727f816b519..53265ca1a9c 100644 --- a/gdb/ada-lang.c +++ b/gdb/ada-lang.c @@ -8922,7 +8922,7 @@ ada_pos_atr (struct type *expect_type, { struct type *type = builtin_type (exp->gdbarch)->builtin_int; if (noside == EVAL_AVOID_SIDE_EFFECTS) - return value_zero (type, not_lval); + return value::zero (type, not_lval); return value_from_longest (type, pos_atr (arg)); } @@ -8947,7 +8947,7 @@ struct value * ada_val_atr (enum noside noside, struct type *type, struct value *arg) { if (noside == EVAL_AVOID_SIDE_EFFECTS) - return value_zero (type, not_lval); + return value::zero (type, not_lval); if (!discrete_type_p (type)) error (_("'VAL only defined on discrete types")); @@ -10164,7 +10164,7 @@ ada_atr_tag (struct type *expect_type, struct value *arg1) { if (noside == EVAL_AVOID_SIDE_EFFECTS) - return value_zero (ada_tag_type (arg1), not_lval); + return value::zero (ada_tag_type (arg1), not_lval); return ada_value_tag (arg1); } @@ -10186,7 +10186,7 @@ ada_atr_size (struct type *expect_type, type = type->target_type (); if (noside == EVAL_AVOID_SIDE_EFFECTS) - return value_zero (builtin_type (exp->gdbarch)->builtin_int, not_lval); + return value::zero (builtin_type (exp->gdbarch)->builtin_int, not_lval); else return value_from_longest (builtin_type (exp->gdbarch)->builtin_int, TARGET_CHAR_BIT * type->length ()); @@ -10201,7 +10201,7 @@ ada_abs (struct type *expect_type, struct value *arg1) { unop_promote (exp->language_defn, exp->gdbarch, &arg1); - if (value_less (arg1, value_zero (arg1->type (), not_lval))) + if (value_less (arg1, value::zero (arg1->type (), not_lval))) return value_neg (arg1); else return arg1; @@ -10218,7 +10218,7 @@ ada_mult_binop (struct type *expect_type, if (noside == EVAL_AVOID_SIDE_EFFECTS) { binop_promote (exp->language_defn, exp->gdbarch, &arg1, &arg2); - return value_zero (arg1->type (), not_lval); + return value::zero (arg1->type (), not_lval); } else { @@ -10340,7 +10340,7 @@ ada_binop_in_bounds (struct expression *exp, enum noside noside, { struct type *type = language_bool_type (exp->language_defn, exp->gdbarch); - return value_zero (type, not_lval); + return value::zero (type, not_lval); } struct type *type = ada_index_type (arg2->type (), n, "range"); @@ -10391,7 +10391,7 @@ ada_unop_atr (struct expression *exp, enum noside noside, enum exp_opcode op, } } - return value_zero (type_arg, not_lval); + return value::zero (type_arg, not_lval); } else if (type_arg == NULL) { @@ -10496,7 +10496,7 @@ ada_binop_minmax (struct type *expect_type, struct value *arg1, struct value *arg2) { if (noside == EVAL_AVOID_SIDE_EFFECTS) - return value_zero (arg1->type (), not_lval); + return value::zero (arg1->type (), not_lval); else { binop_promote (exp->language_defn, exp->gdbarch, &arg1, &arg2); @@ -10513,7 +10513,7 @@ ada_binop_exp (struct type *expect_type, struct value *arg1, struct value *arg2) { if (noside == EVAL_AVOID_SIDE_EFFECTS) - return value_zero (arg1->type (), not_lval); + return value::zero (arg1->type (), not_lval); else { /* For integer exponentiation operations, @@ -10841,7 +10841,7 @@ ada_var_msym_value_operation::evaluate_for_cast (struct type *expect_type, enum noside noside) { if (noside == EVAL_AVOID_SIDE_EFFECTS) - return value_zero (expect_type, not_lval); + return value::zero (expect_type, not_lval); const bound_minimal_symbol &b = std::get<0> (m_storage); value *val = evaluate_var_msym_value (noside, b.objfile, b.minsym); @@ -10938,7 +10938,7 @@ ada_var_value_operation::evaluate (struct type *expect_type, This can happen if the debugging information is incomplete, for instance. */ actual_type = type; - return value_zero (actual_type, not_lval); + return value::zero (actual_type, not_lval); } else { @@ -10963,7 +10963,7 @@ ada_var_value_operation::evaluate (struct type *expect_type, && dynamic_template_type (type) != NULL) || (type->code () == TYPE_CODE_UNION && ada_find_parallel_type (type, "___XVU") != NULL)) - return value_zero (to_static_fixed_type (type), not_lval); + return value::zero (to_static_fixed_type (type), not_lval); } value *arg1 = var_value_operation::evaluate (expect_type, exp, noside); @@ -11047,19 +11047,19 @@ ada_unop_ind_operation::evaluate (struct type *expect_type, (ada_aligned_type (ada_check_typedef (type->target_type ()))); } - return value_zero (type, lval_memory); + return value::zero (type, lval_memory); } else if (type->code () == TYPE_CODE_INT) { /* GDB allows dereferencing an int. */ if (expect_type == NULL) - return value_zero (builtin_type (exp->gdbarch)->builtin_int, + return value::zero (builtin_type (exp->gdbarch)->builtin_int, lval_memory); else { expect_type = to_static_fixed_type (ada_aligned_type (expect_type)); - return value_zero (expect_type, lval_memory); + return value::zero (expect_type, lval_memory); } } else @@ -11120,7 +11120,7 @@ ada_structop_operation::evaluate (struct type *expect_type, else type = ada_lookup_struct_elt_type (type1, str, 1, 0); - return value_zero (ada_aligned_type (type), lval_memory); + return value::zero (ada_aligned_type (type), lval_memory); } else { @@ -11216,7 +11216,7 @@ ada_funcall_operation::evaluate (struct type *expect_type, /* We don't know anything about what the internal function might return, but we have to return something. */ - return value_zero (builtin_type (exp->gdbarch)->builtin_int, + return value::zero (builtin_type (exp->gdbarch)->builtin_int, not_lval); else return call_internal_function (exp->gdbarch, exp->language_defn, @@ -11234,7 +11234,7 @@ ada_funcall_operation::evaluate (struct type *expect_type, if (arity != nargs) error (_("wrong number of subscripts; expecting %d"), arity); if (noside == EVAL_AVOID_SIDE_EFFECTS) - return value_zero (ada_aligned_type (type), lval_memory); + return value::zero (ada_aligned_type (type), lval_memory); return unwrap_value (ada_value_subscript (callee, nargs, argvec.data ())); @@ -11246,7 +11246,7 @@ ada_funcall_operation::evaluate (struct type *expect_type, if (type == NULL) error (_("element type of array unknown")); else - return value_zero (ada_aligned_type (type), lval_memory); + return value::zero (ada_aligned_type (type), lval_memory); } return unwrap_value (ada_value_subscript @@ -11260,7 +11260,7 @@ ada_funcall_operation::evaluate (struct type *expect_type, if (type == NULL) error (_("element type of array unknown")); else - return value_zero (ada_aligned_type (type), lval_memory); + return value::zero (ada_aligned_type (type), lval_memory); } return unwrap_value (ada_value_ptr_subscript (callee, nargs, diff --git a/gdb/dummy-frame.c b/gdb/dummy-frame.c index 784ac103eec..6c3dfb1b24d 100644 --- a/gdb/dummy-frame.c +++ b/gdb/dummy-frame.c @@ -348,7 +348,7 @@ dummy_frame_prev_register (frame_info_ptr this_frame, /* Describe the register's location. Generic dummy frames always have the register value in an ``expression''. */ - reg_val = value_zero (register_type (gdbarch, regnum), not_lval); + reg_val = value::zero (register_type (gdbarch, regnum), not_lval); /* Use the regcache_cooked_read() method so that it, on the fly, constructs either a raw or pseudo register from the raw diff --git a/gdb/dwarf2/expr.c b/gdb/dwarf2/expr.c index db88dc368fd..bb77a969784 100644 --- a/gdb/dwarf2/expr.c +++ b/gdb/dwarf2/expr.c @@ -1929,7 +1929,7 @@ dwarf_expr_context::execute_stack_op (const gdb_byte *op_ptr, { case DW_OP_abs: if (value_less (result_val, - value_zero (result_val->type (), not_lval))) + value::zero (result_val->type (), not_lval))) result_val = value_neg (result_val); break; case DW_OP_neg: diff --git a/gdb/eval.c b/gdb/eval.c index bb72043a28a..7dcad5b5d99 100644 --- a/gdb/eval.c +++ b/gdb/eval.c @@ -552,7 +552,7 @@ type_instance_operation::evaluate (struct type *expect_type, 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 + /* 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 @@ -573,7 +573,7 @@ evaluate_var_value (enum noside noside, const block *blk, symbol *var) if (noside != EVAL_AVOID_SIDE_EFFECTS) throw; - ret = value_zero (var->type (), not_lval); + ret = value::zero (var->type (), not_lval); } return ret; @@ -606,7 +606,7 @@ evaluate_var_msym_value (enum noside noside, type *the_type = find_minsym_type_and_address (msymbol, objfile, &address); if (noside == EVAL_AVOID_SIDE_EFFECTS && !the_type->is_gnu_ifunc ()) - return value_zero (the_type, not_lval); + return value::zero (the_type, not_lval); else return value_at_lazy (the_type, address); } @@ -635,7 +635,7 @@ evaluate_subexp_do_call (expression *exp, enum noside noside, /* We don't know anything about what the internal function might return, but we have to return something. */ - return value_zero (builtin_type (exp->gdbarch)->builtin_int, + return value::zero (builtin_type (exp->gdbarch)->builtin_int, not_lval); } else if (ftype->code () == TYPE_CODE_XMETHOD) @@ -644,7 +644,7 @@ evaluate_subexp_do_call (expression *exp, enum noside noside, if (return_type == NULL) error (_("Xmethod is missing return type.")); - return value_zero (return_type, not_lval); + return value::zero (return_type, not_lval); } else if (ftype->code () == TYPE_CODE_FUNC || ftype->code () == TYPE_CODE_METHOD) @@ -775,7 +775,7 @@ scope_operation::evaluate_funcall (struct type *expect_type, function_name = name.c_str (); /* We need a properly typed value for method lookup. */ - argvec[0] = value_zero (type, lval_memory); + argvec[0] = value::zero (type, lval_memory); } for (int i = 0; i < args.size (); ++i) @@ -840,7 +840,7 @@ structop_member_base::evaluate_funcall (struct type *expect_type, if (a1_type->code () == TYPE_CODE_METHODPTR) { if (noside == EVAL_AVOID_SIDE_EFFECTS) - callee = value_zero (a1_type->target_type (), not_lval); + callee = value::zero (a1_type->target_type (), not_lval); else callee = cplus_method_ptr_to_value (&lhs, rhs); @@ -1101,7 +1101,7 @@ eval_op_var_entry_value (struct type *expect_type, struct expression *exp, enum noside noside, symbol *sym) { if (noside == EVAL_AVOID_SIDE_EFFECTS) - return value_zero (sym->type (), not_lval); + return value::zero (sym->type (), not_lval); if (SYMBOL_COMPUTED_OPS (sym) == NULL || SYMBOL_COMPUTED_OPS (sym)->read_variable_at_entry == NULL) @@ -1165,7 +1165,7 @@ eval_op_register (struct type *expect_type, struct expression *exp, of the evaluation mode. */ if (noside == EVAL_AVOID_SIDE_EFFECTS && regno < gdbarch_num_cooked_regs (exp->gdbarch)) - val = value_zero (register_type (exp->gdbarch, regno), not_lval); + val = value::zero (register_type (exp->gdbarch, regno), not_lval); else val = value_of_register (regno, get_selected_frame (NULL)); if (val == NULL) @@ -1224,7 +1224,7 @@ eval_op_structop_struct (struct type *expect_type, struct expression *exp, struct value *arg3 = value_struct_elt (&arg1, {}, string, NULL, "structure"); if (noside == EVAL_AVOID_SIDE_EFFECTS) - arg3 = value_zero (arg3->type (), VALUE_LVAL (arg3)); + arg3 = value::zero (arg3->type (), VALUE_LVAL (arg3)); return arg3; } @@ -1280,7 +1280,7 @@ eval_op_structop_ptr (struct type *expect_type, struct expression *exp, struct value *arg3 = value_struct_elt (&arg1, {}, string, NULL, "structure pointer"); if (noside == EVAL_AVOID_SIDE_EFFECTS) - arg3 = value_zero (arg3->type (), VALUE_LVAL (arg3)); + arg3 = value::zero (arg3->type (), VALUE_LVAL (arg3)); return arg3; } @@ -1299,7 +1299,7 @@ eval_op_member (struct type *expect_type, struct expression *exp, { case TYPE_CODE_METHODPTR: if (noside == EVAL_AVOID_SIDE_EFFECTS) - return value_zero (type->target_type (), not_lval); + return value::zero (type->target_type (), not_lval); else { arg2 = cplus_method_ptr_to_value (&arg1, arg2); @@ -1447,7 +1447,7 @@ eval_op_subscript (struct type *expect_type, struct expression *exp, } if (noside == EVAL_AVOID_SIDE_EFFECTS) - return value_zero (type->target_type (), VALUE_LVAL (arg1)); + return value::zero (type->target_type (), VALUE_LVAL (arg1)); else return value_subscript (arg1, value_as_long (arg2)); } @@ -1693,11 +1693,11 @@ eval_op_ind (struct type *expect_type, struct expression *exp, if (type->is_pointer_or_reference () /* In C you can dereference an array to get the 1st elt. */ || type->code () == TYPE_CODE_ARRAY) - return value_zero (type->target_type (), + return value::zero (type->target_type (), lval_memory); else if (type->code () == TYPE_CODE_INT) /* GDB allows dereferencing an int. */ - return value_zero (builtin_type (exp->gdbarch)->builtin_int, + return value::zero (builtin_type (exp->gdbarch)->builtin_int, lval_memory); else error (_("Attempt to take contents of a non-pointer value.")); @@ -1738,7 +1738,7 @@ eval_op_memval (struct type *expect_type, struct expression *exp, struct value *arg1, struct type *type) { if (noside == EVAL_AVOID_SIDE_EFFECTS) - return value_zero (type, lval_memory); + return value::zero (type, lval_memory); else return value_at_lazy (type, value_as_address (arg1)); } @@ -2588,10 +2588,10 @@ evaluate_subexp_for_address_base (struct expression *exp, enum noside noside, struct type *type = check_typedef (x->type ()); if (TYPE_IS_REFERENCE (type)) - return value_zero (lookup_pointer_type (type->target_type ()), + return value::zero (lookup_pointer_type (type->target_type ()), not_lval); else if (VALUE_LVAL (x) == lval_memory || value_must_coerce_to_target (x)) - return value_zero (lookup_pointer_type (x->type ()), + return value::zero (lookup_pointer_type (x->type ()), not_lval); else error (_("Attempt to take address of " @@ -2656,7 +2656,7 @@ var_msym_value_operation::evaluate_for_address (struct expression *exp, if (noside == EVAL_AVOID_SIDE_EFFECTS) { struct type *type = lookup_pointer_type (val->type ()); - return value_zero (type, not_lval); + return value::zero (type, not_lval); } else return value_addr (val); @@ -2702,7 +2702,7 @@ var_value_operation::evaluate_for_address (struct expression *exp, || sym_class == LOC_REGISTER) error (_("Attempt to take address of register or constant.")); - return value_zero (type, not_lval); + return value::zero (type, not_lval); } else return address_of_variable (var, std::get<0> (m_storage).block); @@ -2852,7 +2852,7 @@ var_value_operation::evaluate_for_sizeof (struct expression *exp, /* FIXME: This should be size_t. */ struct type *size_type = builtin_type (exp->gdbarch)->builtin_int; if (type_not_allocated (type) || type_not_associated (type)) - return value_zero (size_type, not_lval); + return value::zero (size_type, not_lval); else if (is_dynamic_type (type->index_type ()) && type->bounds ()->high.kind () == PROP_UNDEFINED) return value::allocate_optimized_out (size_type); @@ -2867,7 +2867,7 @@ var_msym_value_operation::evaluate_for_cast (struct type *to_type, enum noside noside) { if (noside == EVAL_AVOID_SIDE_EFFECTS) - return value_zero (to_type, not_lval); + return value::zero (to_type, not_lval); const bound_minimal_symbol &b = std::get<0> (m_storage); value *val = evaluate_var_msym_value (noside, b.objfile, b.minsym); diff --git a/gdb/f-lang.c b/gdb/f-lang.c index ccaf4fd612f..10c46fa0c29 100644 --- a/gdb/f-lang.c +++ b/gdb/f-lang.c @@ -961,7 +961,7 @@ eval_op_f_cmplx (type *expect_type, expression *exp, noside noside, return value_cast (result_type, arg1); else return value_literal_complex (arg1, - value_zero (arg1->type (), not_lval), + value::zero (arg1->type (), not_lval), result_type); } @@ -1637,7 +1637,7 @@ fortran_structop_operation::evaluate (struct type *expect_type, = gdb::make_array_view (valaddr, elt_type->length ()); elt_type = resolve_dynamic_type (elt_type, view, address); } - elt = value_zero (elt_type, VALUE_LVAL (elt)); + elt = value::zero (elt_type, VALUE_LVAL (elt)); } return elt; diff --git a/gdb/frame-unwind.c b/gdb/frame-unwind.c index 6c8a094242f..12f83d58755 100644 --- a/gdb/frame-unwind.c +++ b/gdb/frame-unwind.c @@ -303,7 +303,7 @@ frame_unwind_got_constant (frame_info_ptr frame, int regnum, enum bfd_endian byte_order = gdbarch_byte_order (gdbarch); struct value *reg_val; - reg_val = value_zero (register_type (gdbarch, regnum), not_lval); + reg_val = value::zero (register_type (gdbarch, regnum), not_lval); store_unsigned_integer (value_contents_writeable (reg_val).data (), register_size (gdbarch, regnum), byte_order, val); return reg_val; @@ -315,7 +315,7 @@ frame_unwind_got_bytes (frame_info_ptr frame, int regnum, const gdb_byte *buf) struct gdbarch *gdbarch = frame_unwind_arch (frame); struct value *reg_val; - reg_val = value_zero (register_type (gdbarch, regnum), not_lval); + reg_val = value::zero (register_type (gdbarch, regnum), not_lval); memcpy (value_contents_raw (reg_val).data (), buf, register_size (gdbarch, regnum)); return reg_val; @@ -332,7 +332,7 @@ frame_unwind_got_address (frame_info_ptr frame, int regnum, struct gdbarch *gdbarch = frame_unwind_arch (frame); struct value *reg_val; - reg_val = value_zero (register_type (gdbarch, regnum), not_lval); + reg_val = value::zero (register_type (gdbarch, regnum), not_lval); pack_long (value_contents_writeable (reg_val).data (), register_type (gdbarch, regnum), addr); return reg_val; diff --git a/gdb/guile/scm-math.c b/gdb/guile/scm-math.c index af472c1aff3..dcbdef5f4b0 100644 --- a/gdb/guile/scm-math.c +++ b/gdb/guile/scm-math.c @@ -109,7 +109,7 @@ vlscm_unop_gdbthrow (enum valscm_unary_opcode opcode, SCM x, res_val = arg1; break; case VALSCM_ABS: - if (value_less (arg1, value_zero (arg1->type (), not_lval))) + if (value_less (arg1, value::zero (arg1->type (), not_lval))) res_val = value_neg (arg1); else res_val = arg1; diff --git a/gdb/m2-lang.c b/gdb/m2-lang.c index 42af96d96f2..ffa2faa44a9 100644 --- a/gdb/m2-lang.c +++ b/gdb/m2-lang.c @@ -104,7 +104,7 @@ eval_op_m2_subscript (struct type *expect_type, struct expression *exp, } if (noside == EVAL_AVOID_SIDE_EFFECTS) - return value_zero (type->target_type (), VALUE_LVAL (arg1)); + return value::zero (type->target_type (), VALUE_LVAL (arg1)); else return value_subscript (arg1, value_as_long (arg2)); } diff --git a/gdb/opencl-lang.c b/gdb/opencl-lang.c index 25be86ee98a..dc34dee2995 100644 --- a/gdb/opencl-lang.c +++ b/gdb/opencl-lang.c @@ -278,7 +278,7 @@ create_value (struct gdbarch *gdbarch, struct value *val, enum noside noside, if (n == 1) { if (noside == EVAL_AVOID_SIDE_EFFECTS) - ret = value_zero (elm_type, not_lval); + ret = value::zero (elm_type, not_lval); else ret = value_subscript (val, indices[0]); } @@ -715,7 +715,7 @@ opencl_structop_operation::evaluate (struct type *expect_type, NULL, "structure"); if (noside == EVAL_AVOID_SIDE_EFFECTS) - v = value_zero (v->type (), VALUE_LVAL (v)); + v = value::zero (v->type (), VALUE_LVAL (v)); return v; } } diff --git a/gdb/python/py-value.c b/gdb/python/py-value.c index b387bb813e7..6a176c7efda 100644 --- a/gdb/python/py-value.c +++ b/gdb/python/py-value.c @@ -1506,7 +1506,7 @@ valpy_absolute (PyObject *self) { scoped_value_mark free_values; - if (value_less (value, value_zero (value->type (), not_lval))) + if (value_less (value, value::zero (value->type (), not_lval))) isabs = 0; } catch (const gdb_exception &except) diff --git a/gdb/rust-lang.c b/gdb/rust-lang.c index edffad4afe7..ff30babca75 100644 --- a/gdb/rust-lang.c +++ b/gdb/rust-lang.c @@ -1070,7 +1070,7 @@ rust_range (struct type *expect_type, struct expression *exp, high == NULL ? NULL : "end", index_type); if (noside == EVAL_AVOID_SIDE_EFFECTS) - return value_zero (range_type, lval_memory); + return value::zero (range_type, lval_memory); addrval = value_allocate_space_in_inferior (range_type->length ()); addr = value_as_long (addrval); @@ -1204,7 +1204,7 @@ rust_subscript (struct type *expect_type, struct expression *exp, else new_type = base_type; - return value_zero (new_type, VALUE_LVAL (lhs)); + return value::zero (new_type, VALUE_LVAL (lhs)); } else { @@ -1470,7 +1470,7 @@ rust_structop::evaluate (struct type *expect_type, else result = value_struct_elt (&lhs, {}, field_name, NULL, "structure"); if (noside == EVAL_AVOID_SIDE_EFFECTS) - result = value_zero (result->type (), VALUE_LVAL (result)); + result = value::zero (result->type (), VALUE_LVAL (result)); return result; } @@ -1571,7 +1571,7 @@ rust_structop::evaluate_funcall (struct type *expect_type, args[i + 1] = ops[i]->evaluate (nullptr, exp, noside); if (noside == EVAL_AVOID_SIDE_EFFECTS) - return value_zero (fn_type->target_type (), not_lval); + return value::zero (fn_type->target_type (), not_lval); return call_function_by_hand (function, NULL, args); } diff --git a/gdb/valarith.c b/gdb/valarith.c index 5494dde9310..a2fc1829cd3 100644 --- a/gdb/valarith.c +++ b/gdb/valarith.c @@ -517,7 +517,7 @@ value_x_binop (struct value *arg1, struct value *arg2, enum exp_opcode op, if (return_type == NULL) error (_("Xmethod is missing return type.")); - return value_zero (return_type, VALUE_LVAL (arg1)); + return value::zero (return_type, VALUE_LVAL (arg1)); } return call_xmethod (argvec[0], argvec.slice (1)); } @@ -526,7 +526,7 @@ value_x_binop (struct value *arg1, struct value *arg2, enum exp_opcode op, struct type *return_type; return_type = check_typedef (argvec[0]->type ())->target_type (); - return value_zero (return_type, VALUE_LVAL (arg1)); + return value::zero (return_type, VALUE_LVAL (arg1)); } return call_function_by_hand (argvec[0], NULL, argvec.slice (1, 2 - static_memfuncp)); @@ -630,7 +630,7 @@ value_x_unop (struct value *arg1, enum exp_opcode op, enum noside noside) if (return_type == NULL) error (_("Xmethod is missing return type.")); - return value_zero (return_type, VALUE_LVAL (arg1)); + return value::zero (return_type, VALUE_LVAL (arg1)); } return call_xmethod (argvec[0], argvec[1]); } @@ -639,7 +639,7 @@ value_x_unop (struct value *arg1, enum exp_opcode op, enum noside noside) struct type *return_type; return_type = check_typedef (argvec[0]->type ())->target_type (); - return value_zero (return_type, VALUE_LVAL (arg1)); + return value::zero (return_type, VALUE_LVAL (arg1)); } return call_function_by_hand (argvec[0], NULL, argvec.slice (1, nargs)); @@ -973,7 +973,7 @@ complex_binop (struct value *arg1, struct value *arg2, enum exp_opcode op) else { arg1_real = arg1; - arg1_imag = value_zero (arg1_type, not_lval); + arg1_imag = value::zero (arg1_type, not_lval); } if (arg2_type->code () == TYPE_CODE_COMPLEX) { @@ -983,7 +983,7 @@ complex_binop (struct value *arg1, struct value *arg2, enum exp_opcode op) else { arg2_real = arg2; - arg2_imag = value_zero (arg2_type, not_lval); + arg2_imag = value::zero (arg2_type, not_lval); } struct type *comp_type = promotion_type (arg1_real->type (), @@ -1898,7 +1898,7 @@ value_neg (struct value *arg1) if (is_integral_type (type) || is_floating_type (type)) return value_binop (value_from_longest (type, 0), arg1, BINOP_SUB); else if (is_fixed_point_type (type)) - return value_binop (value_zero (type, not_lval), arg1, BINOP_SUB); + return value_binop (value::zero (type, not_lval), arg1, BINOP_SUB); else if (type->code () == TYPE_CODE_ARRAY && type->is_vector ()) { struct value *val = value::allocate (type); diff --git a/gdb/valops.c b/gdb/valops.c index 19f5fb6f3c9..a6357f0afca 100644 --- a/gdb/valops.c +++ b/gdb/valops.c @@ -271,7 +271,7 @@ value_cast_structs (struct type *type, struct value *v2) T2. This wouldn't work properly for classes with virtual bases, but those were handled above. */ v = search_struct_field (t2->name (), - value_zero (t1, not_lval), t1, 1); + value::zero (t1, not_lval), t1, 1); if (v) { /* Downcasting is possible (t1 is superclass of v2). */ @@ -640,7 +640,7 @@ value_cast (struct type *type, struct value *arg2) error (_("can only cast scalar to vector of same size")); else if (code1 == TYPE_CODE_VOID) { - return value_zero (to_type, not_lval); + return value::zero (to_type, not_lval); } else if (type->length () == type2->length ()) { @@ -848,7 +848,7 @@ value_dynamic_cast (struct type *type, struct value *arg) /* Handle NULL pointers. */ if (value_as_long (arg) == 0) - return value_zero (type, not_lval); + return value::zero (type, not_lval); arg = value_ind (arg); } @@ -928,7 +928,7 @@ value_dynamic_cast (struct type *type, struct value *arg) : value_addr (result)); if (resolved_type->code () == TYPE_CODE_PTR) - return value_zero (type, not_lval); + return value::zero (type, not_lval); error (_("dynamic_cast failed")); } @@ -4167,7 +4167,7 @@ cast_into_complex (struct type *type, struct value *val) else if (val->type ()->code () == TYPE_CODE_FLT || val->type ()->code () == TYPE_CODE_INT) return value_literal_complex (val, - value_zero (real_type, not_lval), + value::zero (real_type, not_lval), type); else error (_("cannot cast non-number to complex")); diff --git a/gdb/value.c b/gdb/value.c index f0e58a41768..550bcb4709f 100644 --- a/gdb/value.c +++ b/gdb/value.c @@ -3252,11 +3252,10 @@ pack_unsigned_long (gdb_byte *buf, struct type *type, ULONGEST num) } } - -/* Create a value of type TYPE that is zero, and return it. */ +/* See value.h. */ struct value * -value_zero (struct type *type, enum lval_type lv) +value::zero (struct type *type, enum lval_type lv) { struct value *val = value::allocate_lazy (type); diff --git a/gdb/value.h b/gdb/value.h index 771e50a0b38..e45ff9f8d9f 100644 --- a/gdb/value.h +++ b/gdb/value.h @@ -177,6 +177,9 @@ struct value /* Allocate NOT_LVAL value for type TYPE being OPTIMIZED_OUT. */ static struct value *allocate_optimized_out (struct type *type); + /* Create a value of type TYPE that is zero, and return it. */ + static struct value *zero (struct type *type, enum lval_type lv); + ~value (); DISABLE_COPY_AND_ASSIGN (value); @@ -399,7 +402,7 @@ struct value used instead of read_memory to enable extra caching. */ unsigned int m_stack : 1; - /* True if this is a zero value, created by 'value_zero'; false + /* True if this is a zero value, created by 'value::zero'; false otherwise. */ bool m_is_zero : 1; @@ -1143,8 +1146,6 @@ extern struct value *value_reinterpret_cast (struct type *type, extern struct value *value_dynamic_cast (struct type *type, struct value *arg); -extern struct value *value_zero (struct type *type, enum lval_type lv); - extern struct value *value_one (struct type *type); extern struct value *value_repeat (struct value *arg1, int count); From patchwork Thu Feb 9 21:38:47 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tom Tromey X-Patchwork-Id: 64582 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 B586A38845FF for ; Thu, 9 Feb 2023 21:42:48 +0000 (GMT) X-Original-To: gdb-patches@sourceware.org Delivered-To: gdb-patches@sourceware.org Received: from outbound-ss-761.bluehost.com (outbound-ss-761.bluehost.com [74.220.211.250]) by sourceware.org (Postfix) with ESMTPS id 12166385B518 for ; Thu, 9 Feb 2023 21:38:44 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 12166385B518 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 cmgw15.mail.unifiedlayer.com (unknown [10.0.90.130]) by progateway8.mail.pro1.eigbox.com (Postfix) with ESMTP id 7C6F21004CA43 for ; Thu, 9 Feb 2023 21:38:43 +0000 (UTC) Received: from box5379.bluehost.com ([162.241.216.53]) by cmsmtp with ESMTP id QEctpZ3rSbdcfQEctp7MjM; Thu, 09 Feb 2023 21:38:43 +0000 X-Authority-Reason: nr=8 X-Authority-Analysis: v=2.4 cv=AZB0o1bG c=1 sm=1 tr=0 ts=63e567e3 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=MQ6vMq2ym46g0SmYa4gA: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=JE68cvhF6x1guvjBUzX7NlXBtzA/dhXgbFE4/Qd12Tg=; b=JAfzolYd0GKaJcpcwUnD3or/PV 2QblqqOspIgGnlkXBUmI8YvHgHqOVDwDW+celFNmP90tuB+lZiTXfyeiziuBDKygISjSpibKvcBaQ pFwtgUv6Tcsf/mV0IFNVGL/xZ; 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-8g for gdb-patches@sourceware.org; Thu, 09 Feb 2023 14:38:43 -0700 From: Tom Tromey Date: Thu, 09 Feb 2023 14:38:47 -0700 Subject: [PATCH 26/47] Turn some value_contents functions into methods MIME-Version: 1.0 Message-Id: <20230209-submit-value-fixups-2023-v1-26-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-8g 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: 27 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 turns value_contents_raw, value_contents_writeable, and value_contents_all_raw into methods on value. The remaining functions will be changed later in the series; they were a bit trickier and so I didn't include them in this patch. --- gdb/aarch64-linux-tdep.c | 2 +- gdb/aarch64-tdep.c | 6 ++--- gdb/ada-lang.c | 26 +++++++++++----------- gdb/amd64-tdep.c | 4 ++-- gdb/amd64-windows-tdep.c | 2 +- gdb/arch-utils.c | 2 +- gdb/arm-tdep.c | 4 ++-- gdb/c-lang.c | 2 +- gdb/cp-valprint.c | 2 +- gdb/dummy-frame.c | 2 +- gdb/dwarf2/expr.c | 6 ++--- gdb/dwarf2/loc.c | 4 ++-- gdb/dwarf2/read.c | 2 +- gdb/eval.c | 10 ++++----- gdb/findvar.c | 6 ++--- gdb/frame-unwind.c | 6 ++--- gdb/frame.c | 4 ++-- gdb/i386-tdep.c | 4 ++-- gdb/infrun.c | 4 ++-- gdb/opencl-lang.c | 12 +++++----- gdb/ppc-linux-tdep.c | 2 +- gdb/regcache.c | 4 ++-- gdb/riscv-tdep.c | 8 +++---- gdb/sparc-tdep.c | 2 +- gdb/std-regs.c | 4 ++-- gdb/tracepoint.c | 2 +- gdb/valarith.c | 20 ++++++++--------- gdb/valops.c | 32 +++++++++++++------------- gdb/valprint.c | 2 +- gdb/value.c | 58 ++++++++++++++++++++++++------------------------ gdb/value.h | 34 +++++++++++++--------------- gdb/windows-tdep.c | 2 +- 32 files changed, 139 insertions(+), 141 deletions(-) diff --git a/gdb/aarch64-linux-tdep.c b/gdb/aarch64-linux-tdep.c index 20a041c599e..9d6ed358597 100644 --- a/gdb/aarch64-linux-tdep.c +++ b/gdb/aarch64-linux-tdep.c @@ -1668,7 +1668,7 @@ aarch64_linux_set_memtags (struct gdbarch *gdbarch, struct value *address, /* Update the value's content with the tag. */ enum bfd_endian byte_order = gdbarch_byte_order (gdbarch); - gdb_byte *srcbuf = value_contents_raw (address).data (); + gdb_byte *srcbuf = address->contents_raw ().data (); store_unsigned_integer (srcbuf, sizeof (addr), byte_order, addr); } else diff --git a/gdb/aarch64-tdep.c b/gdb/aarch64-tdep.c index 76c92fd99bd..1a6fdbebc76 100644 --- a/gdb/aarch64-tdep.c +++ b/gdb/aarch64-tdep.c @@ -2494,7 +2494,7 @@ aarch64_return_value (struct gdbarch *gdbarch, struct value *func_value, { *read_value = value::allocate (valtype); aarch64_extract_return_value (valtype, regcache, - value_contents_raw (*read_value).data ()); + (*read_value)->contents_raw ().data ()); } aarch64_debug_printf ("return value in registers"); @@ -2769,7 +2769,7 @@ aarch64_pseudo_read_value_1 (struct gdbarch *gdbarch, mark_value_bytes_unavailable (result_value, 0, result_value->type ()->length ()); else - memcpy (value_contents_raw (result_value).data (), reg_buf, regsize); + memcpy (result_value->contents_raw ().data (), reg_buf, regsize); return result_value; } @@ -2803,7 +2803,7 @@ aarch64_pseudo_read_value (struct gdbarch *gdbarch, readable_regcache *regcache, if (regcache->raw_read_part (x_regnum, offset, 4, data) != REG_VALID) mark_value_bytes_unavailable (result_value, 0, 4); else - memcpy (value_contents_raw (result_value).data (), data, 4); + memcpy (result_value->contents_raw ().data (), data, 4); return result_value; } diff --git a/gdb/ada-lang.c b/gdb/ada-lang.c index 53265ca1a9c..274b5e3ce03 100644 --- a/gdb/ada-lang.c +++ b/gdb/ada-lang.c @@ -2846,7 +2846,7 @@ ada_value_primitive_packed_val (struct value *obj, const gdb_byte *valaddr, } else v->set_bitsize (bit_size); - unpacked = value_contents_writeable (v).data (); + unpacked = v->contents_writeable ().data (); if (bit_size == 0) { @@ -2921,7 +2921,7 @@ ada_value_assign (struct value *toval, struct value *fromval) write_memory_with_notification (to_addr, buffer, len); val = value_copy (toval); - memcpy (value_contents_raw (val).data (), + memcpy (val->contents_raw ().data (), value_contents (fromval).data (), type->length ()); val->deprecated_set_type (type); @@ -2970,13 +2970,13 @@ value_assign_to_component (struct value *container, struct value *component, = component->type ()->length () * TARGET_CHAR_BIT - bits; else src_offset = 0; - copy_bitwise ((value_contents_writeable (container).data () + copy_bitwise ((container->contents_writeable ().data () + offset_in_container), container->bitpos () + bit_offset_in_container, value_contents (val).data (), src_offset, bits, 1); } else - copy_bitwise ((value_contents_writeable (container).data () + copy_bitwise ((container->contents_writeable ().data () + offset_in_container), container->bitpos () + bit_offset_in_container, value_contents (val).data (), 0, bits, 0); @@ -4529,7 +4529,7 @@ ada_convert_actual (struct value *actual, struct type *formal_type0) actual_type = ada_check_typedef (actual->type ()); val = value::allocate (actual_type); - copy (value_contents (actual), value_contents_raw (val)); + copy (value_contents (actual), val->contents_raw ()); actual = ensure_lval (val); } result = value_addr (actual); @@ -4592,12 +4592,12 @@ make_array_descriptor (struct type *type, struct value *arr) i > 0; i -= 1) { modify_field (bounds->type (), - value_contents_writeable (bounds).data (), + bounds->contents_writeable ().data (), ada_array_bound (arr, i, 0), desc_bound_bitpos (bounds_type, i, 0), desc_bound_bitsize (bounds_type, i, 0)); modify_field (bounds->type (), - value_contents_writeable (bounds).data (), + bounds->contents_writeable ().data (), ada_array_bound (arr, i, 1), desc_bound_bitpos (bounds_type, i, 1), desc_bound_bitsize (bounds_type, i, 1)); @@ -4606,14 +4606,14 @@ make_array_descriptor (struct type *type, struct value *arr) bounds = ensure_lval (bounds); modify_field (descriptor->type (), - value_contents_writeable (descriptor).data (), + descriptor->contents_writeable ().data (), value_pointer (ensure_lval (arr), desc_type->field (0).type ()), fat_pntr_data_bitpos (desc_type), fat_pntr_data_bitsize (desc_type)); modify_field (descriptor->type (), - value_contents_writeable (descriptor).data (), + descriptor->contents_writeable ().data (), value_pointer (bounds, desc_type->field (1).type ()), fat_pntr_bounds_bitpos (desc_type), @@ -9282,7 +9282,7 @@ ada_promote_array_of_integrals (struct type *type, struct value *val) error (_("unable to determine array bounds")); value *res = value::allocate (type); - gdb::array_view res_contents = value_contents_writeable (res); + gdb::array_view res_contents = res->contents_writeable (); /* Promote each array element. */ for (i = 0; i < hi - lo + 1; i++) @@ -9404,7 +9404,7 @@ ada_value_binop (struct value *arg1, struct value *arg2, enum exp_opcode op) } val = value::allocate (type1); - store_unsigned_integer (value_contents_raw (val).data (), + store_unsigned_integer (val->contents_raw ().data (), val->type ()->length (), type_byte_order (type1), v); return val; @@ -10668,7 +10668,7 @@ ada_string_operation::evaluate (struct type *expect_type, struct type *stringtype = lookup_array_range_type (char_type, 1, str.length ()); struct value *val = value::allocate (stringtype); - memcpy (value_contents_raw (val).data (), str.c_str (), + memcpy (val->contents_raw ().data (), str.c_str (), str.length ()); return val; } @@ -10703,7 +10703,7 @@ ada_string_operation::evaluate (struct type *expect_type, obstack_object_size (&converted) / char_type->length ()); struct value *val = value::allocate (stringtype); - memcpy (value_contents_raw (val).data (), + memcpy (val->contents_raw ().data (), obstack_base (&converted), obstack_object_size (&converted)); return val; diff --git a/gdb/amd64-tdep.c b/gdb/amd64-tdep.c index 03e9ac951c8..085e5327a75 100644 --- a/gdb/amd64-tdep.c +++ b/gdb/amd64-tdep.c @@ -358,7 +358,7 @@ amd64_pseudo_register_read_value (struct gdbarch *gdbarch, value *result_value = value::allocate (register_type (gdbarch, regnum)); VALUE_LVAL (result_value) = lval_register; VALUE_REGNUM (result_value) = regnum; - gdb_byte *buf = value_contents_raw (result_value).data (); + gdb_byte *buf = result_value->contents_raw ().data (); if (i386_byte_regnum_p (gdbarch, regnum)) { @@ -832,7 +832,7 @@ amd64_return_value (struct gdbarch *gdbarch, struct value *function, if (read_value != nullptr) { *read_value = value::allocate (type); - readbuf = value_contents_raw (*read_value).data (); + readbuf = (*read_value)->contents_raw ().data (); } /* 8. If the class is COMPLEX_X87, the real part of the value is diff --git a/gdb/amd64-windows-tdep.c b/gdb/amd64-windows-tdep.c index aea8aaa6200..7a7fbbb9859 100644 --- a/gdb/amd64-windows-tdep.c +++ b/gdb/amd64-windows-tdep.c @@ -410,7 +410,7 @@ amd64_windows_return_value (struct gdbarch *gdbarch, struct value *function, { *read_value = value::allocate (type); regcache->raw_read_part (regnum, 0, len, - value_contents_raw (*read_value).data ()); + (*read_value)->contents_raw ().data ()); } if (writebuf) regcache->raw_write_part (regnum, 0, len, writebuf); diff --git a/gdb/arch-utils.c b/gdb/arch-utils.c index 49c699fd124..e3af9ce2dbc 100644 --- a/gdb/arch-utils.c +++ b/gdb/arch-utils.c @@ -1179,7 +1179,7 @@ default_gdbarch_return_value if (read_value != nullptr) { *read_value = value::allocate (valtype); - readbuf = value_contents_raw (*read_value).data (); + readbuf = (*read_value)->contents_raw ().data (); } return gdbarch->return_value (gdbarch, function, valtype, regcache, diff --git a/gdb/arm-tdep.c b/gdb/arm-tdep.c index c4b92ea17d9..bf38880c247 100644 --- a/gdb/arm-tdep.c +++ b/gdb/arm-tdep.c @@ -9193,7 +9193,7 @@ arm_return_value (struct gdbarch *gdbarch, struct value *function, if (read_value != nullptr) { *read_value = value::allocate (valtype); - readbuf = value_contents_raw (*read_value).data (); + readbuf = (*read_value)->contents_raw ().data (); } for (i = 0; i < vfp_base_count; i++) @@ -9269,7 +9269,7 @@ arm_return_value (struct gdbarch *gdbarch, struct value *function, if (read_value != nullptr) { *read_value = value::allocate (valtype); - gdb_byte *readbuf = value_contents_raw (*read_value).data (); + gdb_byte *readbuf = (*read_value)->contents_raw ().data (); arm_extract_return_value (valtype, regcache, readbuf); } diff --git a/gdb/c-lang.c b/gdb/c-lang.c index 255901887d6..ec2e06027d2 100644 --- a/gdb/c-lang.c +++ b/gdb/c-lang.c @@ -674,7 +674,7 @@ c_string_operation::evaluate (struct type *expect_type, error (_("Too many array elements")); result = value::allocate (expect_type); - memcpy (value_contents_raw (result).data (), obstack_base (&output), + memcpy (result->contents_raw ().data (), obstack_base (&output), obstack_object_size (&output)); } else diff --git a/gdb/cp-valprint.c b/gdb/cp-valprint.c index 268a414a37b..dd396825798 100644 --- a/gdb/cp-valprint.c +++ b/gdb/cp-valprint.c @@ -762,7 +762,7 @@ test_print_fields (gdbarch *arch) } value *val = value::allocate (the_struct); - gdb_byte *contents = value_contents_writeable (val).data (); + gdb_byte *contents = val->contents_writeable ().data (); store_unsigned_integer (contents, val->enclosing_type ()->length (), gdbarch_byte_order (arch), 0xe9); diff --git a/gdb/dummy-frame.c b/gdb/dummy-frame.c index 6c3dfb1b24d..961b3ac7a25 100644 --- a/gdb/dummy-frame.c +++ b/gdb/dummy-frame.c @@ -354,7 +354,7 @@ dummy_frame_prev_register (frame_info_ptr this_frame, constructs either a raw or pseudo register from the raw register cache. */ cache->prev_regcache->cooked_read - (regnum, value_contents_writeable (reg_val).data ()); + (regnum, reg_val->contents_writeable ().data ()); return reg_val; } diff --git a/gdb/dwarf2/expr.c b/gdb/dwarf2/expr.c index bb77a969784..e08dca01a67 100644 --- a/gdb/dwarf2/expr.c +++ b/gdb/dwarf2/expr.c @@ -164,7 +164,7 @@ rw_pieced_value (value *v, value *from, bool check_optimized) if (check_optimized) v_contents = nullptr; else - v_contents = value_contents_raw (v).data (); + v_contents = v->contents_raw ().data (); from_contents = nullptr; } @@ -1026,7 +1026,7 @@ dwarf_expr_context::fetch_result (struct type *type, struct type *subobj_type, subobj_offset += n - max; copy (value_contents_all (val).slice (subobj_offset, len), - value_contents_raw (retval)); + retval->contents_raw ()); } break; @@ -1038,7 +1038,7 @@ dwarf_expr_context::fetch_result (struct type *type, struct type *subobj_type, invalid_synthetic_pointer (); retval = value::allocate (subobj_type); - bfd_byte *contents = value_contents_raw (retval).data (); + bfd_byte *contents = retval->contents_raw ().data (); memcpy (contents, this->m_data + subobj_offset, n); } break; diff --git a/gdb/dwarf2/loc.c b/gdb/dwarf2/loc.c index 96686d9a110..0aa6aafe823 100644 --- a/gdb/dwarf2/loc.c +++ b/gdb/dwarf2/loc.c @@ -1363,8 +1363,8 @@ value_of_dwarf_reg_entry (struct type *type, frame_info_ptr frame, release_value (target_val).release ()); /* Copy the referencing pointer to the new computed value. */ - memcpy (value_contents_raw (val).data (), - value_contents_raw (outer_val).data (), + memcpy (val->contents_raw ().data (), + outer_val->contents_raw ().data (), checked_type->length ()); val->set_lazy (0); diff --git a/gdb/dwarf2/read.c b/gdb/dwarf2/read.c index 7da86798454..3faaf2ce883 100644 --- a/gdb/dwarf2/read.c +++ b/gdb/dwarf2/read.c @@ -9026,7 +9026,7 @@ dwarf2_compute_name (const char *name, else if (bytes != NULL) { v = value::allocate (type); - memcpy (value_contents_writeable (v).data (), bytes, + memcpy (v->contents_writeable ().data (), bytes, type->length ()); } else diff --git a/gdb/eval.c b/gdb/eval.c index 7dcad5b5d99..fbc72a5a34e 100644 --- a/gdb/eval.c +++ b/gdb/eval.c @@ -2413,7 +2413,7 @@ array_operation::evaluate_struct_tuple (struct value *struct_val, bitsize = TYPE_FIELD_BITSIZE (struct_type, fieldno); bitpos = struct_type->field (fieldno).loc_bitpos (); - addr = value_contents_writeable (struct_val).data () + bitpos / 8; + addr = struct_val->contents_writeable ().data () + bitpos / 8; if (bitsize) modify_field (struct_type, addr, value_as_long (val), bitpos % 8, bitsize); @@ -2442,7 +2442,7 @@ array_operation::evaluate (struct type *expect_type, { struct value *rec = value::allocate (expect_type); - memset (value_contents_raw (rec).data (), '\0', type->length ()); + memset (rec->contents_raw ().data (), '\0', type->length ()); return evaluate_struct_tuple (rec, exp, noside, nargs); } @@ -2461,7 +2461,7 @@ array_operation::evaluate (struct type *expect_type, high_bound = (type->length () / element_size) - 1; } index = low_bound; - memset (value_contents_raw (array).data (), 0, expect_type->length ()); + memset (array->contents_raw ().data (), 0, expect_type->length ()); for (tem = nargs; --nargs >= 0;) { struct value *element; @@ -2473,7 +2473,7 @@ array_operation::evaluate (struct type *expect_type, if (index > high_bound) /* To avoid memory corruption. */ error (_("Too many array elements")); - memcpy (value_contents_raw (array).data () + memcpy (array->contents_raw ().data () + (index - low_bound) * element_size, value_contents (element).data (), element_size); @@ -2486,7 +2486,7 @@ array_operation::evaluate (struct type *expect_type, && type->code () == TYPE_CODE_SET) { struct value *set = value::allocate (expect_type); - gdb_byte *valaddr = value_contents_raw (set).data (); + gdb_byte *valaddr = set->contents_raw ().data (); struct type *element_type = type->index_type (); struct type *check_type = element_type; LONGEST low_bound, high_bound; diff --git a/gdb/findvar.c b/gdb/findvar.c index 048e439ac33..a64b35c2bcf 100644 --- a/gdb/findvar.c +++ b/gdb/findvar.c @@ -587,7 +587,7 @@ language_defn::read_var_value (struct symbol *var, } /* Put the constant back in target format. */ v = value::allocate (type); - store_signed_integer (value_contents_raw (v).data (), type->length (), + store_signed_integer (v->contents_raw ().data (), type->length (), type_byte_order (type), var->value_longest ()); VALUE_LVAL (v) = not_lval; return v; @@ -627,7 +627,7 @@ language_defn::read_var_value (struct symbol *var, type = resolve_dynamic_type (type, {}, /* Unused address. */ 0); } v = value::allocate (type); - memcpy (value_contents_raw (v).data (), var->value_bytes (), + memcpy (v->contents_raw ().data (), var->value_bytes (), type->length ()); VALUE_LVAL (v) = not_lval; return v; @@ -900,7 +900,7 @@ value_from_register (struct type *type, int regnum, frame_info_ptr frame) VALUE_NEXT_FRAME_ID (v) = get_frame_id (get_next_frame_sentinel_okay (frame)); VALUE_REGNUM (v) = regnum; ok = gdbarch_register_to_value (gdbarch, frame, regnum, type1, - value_contents_raw (v).data (), &optim, + v->contents_raw ().data (), &optim, &unavail); if (!ok) diff --git a/gdb/frame-unwind.c b/gdb/frame-unwind.c index 12f83d58755..279d86a5ffc 100644 --- a/gdb/frame-unwind.c +++ b/gdb/frame-unwind.c @@ -304,7 +304,7 @@ frame_unwind_got_constant (frame_info_ptr frame, int regnum, struct value *reg_val; reg_val = value::zero (register_type (gdbarch, regnum), not_lval); - store_unsigned_integer (value_contents_writeable (reg_val).data (), + store_unsigned_integer (reg_val->contents_writeable ().data (), register_size (gdbarch, regnum), byte_order, val); return reg_val; } @@ -316,7 +316,7 @@ frame_unwind_got_bytes (frame_info_ptr frame, int regnum, const gdb_byte *buf) struct value *reg_val; reg_val = value::zero (register_type (gdbarch, regnum), not_lval); - memcpy (value_contents_raw (reg_val).data (), buf, + memcpy (reg_val->contents_raw ().data (), buf, register_size (gdbarch, regnum)); return reg_val; } @@ -333,7 +333,7 @@ frame_unwind_got_address (frame_info_ptr frame, int regnum, struct value *reg_val; reg_val = value::zero (register_type (gdbarch, regnum), not_lval); - pack_long (value_contents_writeable (reg_val).data (), + pack_long (reg_val->contents_writeable ().data (), register_type (gdbarch, regnum), addr); return reg_val; } diff --git a/gdb/frame.c b/gdb/frame.c index 935dea1e417..0fcf3f43492 100644 --- a/gdb/frame.c +++ b/gdb/frame.c @@ -1598,10 +1598,10 @@ put_frame_register_bytes (frame_info_ptr frame, int regnum, regnum); gdb_assert (value != NULL); - memcpy ((char *) value_contents_writeable (value).data () + offset, + memcpy ((char *) value->contents_writeable ().data () + offset, myaddr, curr_len); put_frame_register (frame, regnum, - value_contents_raw (value).data ()); + value->contents_raw ().data ()); release_value (value); } diff --git a/gdb/i386-tdep.c b/gdb/i386-tdep.c index 5857e16ff36..c6078e726ab 100644 --- a/gdb/i386-tdep.c +++ b/gdb/i386-tdep.c @@ -3095,7 +3095,7 @@ i386_return_value (struct gdbarch *gdbarch, struct value *function, { *read_value = value::allocate (type); i386_extract_return_value (gdbarch, type, regcache, - value_contents_raw (*read_value).data ()); + (*read_value)->contents_raw ().data ()); } if (writebuf) i386_store_return_value (gdbarch, type, regcache, writebuf); @@ -3379,7 +3379,7 @@ i386_pseudo_register_read_into_value (struct gdbarch *gdbarch, { gdb_byte raw_buf[I386_MAX_REGISTER_SIZE]; enum register_status status; - gdb_byte *buf = value_contents_raw (result_value).data (); + gdb_byte *buf = result_value->contents_raw ().data (); if (i386_mmx_regnum_p (gdbarch, regnum)) { diff --git a/gdb/infrun.c b/gdb/infrun.c index c45c6b5c802..c5718580162 100644 --- a/gdb/infrun.c +++ b/gdb/infrun.c @@ -9143,7 +9143,7 @@ siginfo_value_read (struct value *v) target_read (current_inferior ()->top_target (), TARGET_OBJECT_SIGNAL_INFO, nullptr, - value_contents_all_raw (v).data (), + v->contents_all_raw ().data (), v->offset (), v->type ()->length ()); @@ -9166,7 +9166,7 @@ siginfo_value_write (struct value *v, struct value *fromval) transferred = target_write (current_inferior ()->top_target (), TARGET_OBJECT_SIGNAL_INFO, nullptr, - value_contents_all_raw (fromval).data (), + fromval->contents_all_raw ().data (), v->offset (), fromval->type ()->length ()); diff --git a/gdb/opencl-lang.c b/gdb/opencl-lang.c index dc34dee2995..8bc727cdfdf 100644 --- a/gdb/opencl-lang.c +++ b/gdb/opencl-lang.c @@ -139,7 +139,7 @@ lval_func_read (struct value *v) gdb_assert (n <= c->n); for (i = offset; i < n; i++) - memcpy (value_contents_raw (v).data () + j++ * elsize, + memcpy (v->contents_raw ().data () + j++ * elsize, value_contents (c->val).data () + c->indices[i] * elsize, elsize); } @@ -180,7 +180,7 @@ lval_func_write (struct value *v, struct value *fromval) struct value *from_elm_val = value::allocate (eltype); struct value *to_elm_val = value_subscript (c->val, c->indices[i]); - memcpy (value_contents_writeable (from_elm_val).data (), + memcpy (from_elm_val->contents_writeable ().data (), value_contents (fromval).data () + j++ * elsize, elsize); value_assign (to_elm_val, from_elm_val); @@ -314,7 +314,7 @@ create_value (struct gdbarch *gdbarch, struct value *val, enum noside noside, /* Copy src val contents into the destination value. */ for (i = 0; i < n; i++) - memcpy (value_contents_writeable (ret).data () + memcpy (ret->contents_writeable ().data () + (i * elm_type->length ()), value_contents (val).data () + (indices[i] * elm_type->length ()), @@ -472,7 +472,7 @@ opencl_logical_not (struct type *expect_type, struct expression *exp, value of its operand compares unequal to 0, and -1 (i.e. all bits set) if the value of its operand compares equal to 0. */ int tmp = value_logical_not (value_subscript (arg, i)) ? -1 : 0; - memset ((value_contents_writeable (ret).data () + memset ((ret->contents_writeable ().data () + i * eltype->length ()), tmp, eltype->length ()); } @@ -573,7 +573,7 @@ vector_relop (struct expression *exp, struct value *val1, struct value *val2, if the specified relation is true. */ int tmp = scalar_relop (value_subscript (val1, i), value_subscript (val2, i), op) ? -1 : 0; - memset ((value_contents_writeable (ret).data () + memset ((ret->contents_writeable ().data () + i * eltype1->length ()), tmp, eltype1->length ()); } @@ -837,7 +837,7 @@ Cannot perform conditional operation on vectors with different sizes")); { tmp = value_logical_not (value_subscript (arg1, i)) ? value_subscript (arg3, i) : value_subscript (arg2, i); - memcpy (value_contents_writeable (ret).data () + + memcpy (ret->contents_writeable ().data () + i * eltype2->length (), value_contents_all (tmp).data (), eltype2->length ()); } diff --git a/gdb/ppc-linux-tdep.c b/gdb/ppc-linux-tdep.c index 2084e2b618f..fcddb2008a0 100644 --- a/gdb/ppc-linux-tdep.c +++ b/gdb/ppc-linux-tdep.c @@ -255,7 +255,7 @@ ppc_linux_return_value (struct gdbarch *gdbarch, struct value *function, if (read_value != nullptr) { *read_value = value::allocate (valtype); - readbuf = value_contents_raw (*read_value).data (); + readbuf = (*read_value)->contents_raw ().data (); } if ((valtype->code () == TYPE_CODE_STRUCT diff --git a/gdb/regcache.c b/gdb/regcache.c index 4a31dd5e706..90989595acc 100644 --- a/gdb/regcache.c +++ b/gdb/regcache.c @@ -716,7 +716,7 @@ readable_regcache::cooked_read (int regnum, gdb_byte *buf) computed = gdbarch_pseudo_register_read_value (m_descr->gdbarch, this, regnum); if (value_entirely_available (computed)) - memcpy (buf, value_contents_raw (computed).data (), + memcpy (buf, computed->contents_raw ().data (), m_descr->sizeof_register[regnum]); else { @@ -751,7 +751,7 @@ readable_regcache::cooked_read_value (int regnum) direction than in the other one, even though the value-based API is preferred. */ if (cooked_read (regnum, - value_contents_raw (result).data ()) == REG_UNAVAILABLE) + result->contents_raw ().data ()) == REG_UNAVAILABLE) mark_value_bytes_unavailable (result, 0, result->type ()->length ()); diff --git a/gdb/riscv-tdep.c b/gdb/riscv-tdep.c index 375ba4228a2..f8be46c9fb6 100644 --- a/gdb/riscv-tdep.c +++ b/gdb/riscv-tdep.c @@ -3278,7 +3278,7 @@ riscv_return_value (struct gdbarch *gdbarch, type_byte_order (arg_type), arg_type->is_unsigned ()); abi_val = value::allocate (info.type); - unscaled.write (value_contents_raw (abi_val), + unscaled.write (abi_val->contents_raw (), type_byte_order (info.type), info.type->is_unsigned ()); } @@ -3287,12 +3287,12 @@ riscv_return_value (struct gdbarch *gdbarch, arg_val = value_from_contents (arg_type, writebuf); abi_val = value_cast (info.type, arg_val); } - writebuf = value_contents_raw (abi_val).data (); + writebuf = abi_val->contents_raw ().data (); } else { abi_val = value::allocate (info.type); - readbuf = value_contents_raw (abi_val).data (); + readbuf = abi_val->contents_raw ().data (); } arg_len = info.type->length (); @@ -3409,7 +3409,7 @@ riscv_return_value (struct gdbarch *gdbarch, type_byte_order (info.type), info.type->is_unsigned ()); *read_value = value::allocate (arg_type); - unscaled.write (value_contents_raw (*read_value), + unscaled.write ((*read_value)->contents_raw (), type_byte_order (arg_type), arg_type->is_unsigned ()); } diff --git a/gdb/sparc-tdep.c b/gdb/sparc-tdep.c index 44f16215bb2..5e582c7b77a 100644 --- a/gdb/sparc-tdep.c +++ b/gdb/sparc-tdep.c @@ -1531,7 +1531,7 @@ sparc32_return_value (struct gdbarch *gdbarch, struct value *function, if (read_value != nullptr) { *read_value = value::allocate (type); - gdb_byte *readbuf = value_contents_raw (*read_value).data (); + gdb_byte *readbuf = (*read_value)->contents_raw ().data (); sparc32_extract_return_value (type, regcache, readbuf); } if (writebuf) diff --git a/gdb/std-regs.c b/gdb/std-regs.c index 5520789ea95..54cf9018e42 100644 --- a/gdb/std-regs.c +++ b/gdb/std-regs.c @@ -44,7 +44,7 @@ value_of_builtin_frame_fp_reg (frame_info_ptr frame, const void *baton) { struct type *data_ptr_type = builtin_type (gdbarch)->builtin_data_ptr; struct value *val = value::allocate (data_ptr_type); - gdb_byte *buf = value_contents_raw (val).data (); + gdb_byte *buf = val->contents_raw ().data (); gdbarch_address_to_pointer (gdbarch, data_ptr_type, buf, get_frame_base_address (frame)); @@ -63,7 +63,7 @@ value_of_builtin_frame_pc_reg (frame_info_ptr frame, const void *baton) { struct type *func_ptr_type = builtin_type (gdbarch)->builtin_func_ptr; struct value *val = value::allocate (func_ptr_type); - gdb_byte *buf = value_contents_raw (val).data (); + gdb_byte *buf = val->contents_raw ().data (); gdbarch_address_to_pointer (gdbarch, func_ptr_type, buf, get_frame_pc (frame)); diff --git a/gdb/tracepoint.c b/gdb/tracepoint.c index bd02cae05ee..1c1fea7d970 100644 --- a/gdb/tracepoint.c +++ b/gdb/tracepoint.c @@ -3778,7 +3778,7 @@ sdata_make_value (struct gdbarch *gdbarch, struct internalvar *var, type = init_vector_type (builtin_type (gdbarch)->builtin_true_char, buf->size ()); v = value::allocate (type); - memcpy (value_contents_raw (v).data (), buf->data (), buf->size ()); + memcpy (v->contents_raw ().data (), buf->data (), buf->size ()); return v; } else diff --git a/gdb/valarith.c b/gdb/valarith.c index a2fc1829cd3..adc7da76b65 100644 --- a/gdb/valarith.c +++ b/gdb/valarith.c @@ -702,7 +702,7 @@ value_concat (struct value *arg1, struct value *arg2) lowbound + n_elts - 1); struct value *result = value::allocate (atype); - gdb::array_view contents = value_contents_raw (result); + gdb::array_view contents = result->contents_raw (); gdb::array_view lhs_contents = value_contents (arg1); gdb::array_view rhs_contents = value_contents (arg2); gdb::copy (lhs_contents, contents.slice (0, lhs_contents.size ())); @@ -857,7 +857,7 @@ fixed_point_binop (struct value *arg1, struct value *arg2, enum exp_opcode op) value *fp_val = value::allocate (type1); fp.write_fixed_point - (value_contents_raw (fp_val), + (fp_val->contents_raw (), type_byte_order (type1), type1->is_unsigned (), type1->fixed_point_scaling_factor ()); @@ -1176,7 +1176,7 @@ scalar_binop (struct value *arg1, struct value *arg2, enum exp_opcode op) v2.data (), &eff_type_v2); target_float_binop (op, v1.data (), eff_type_v1, v2.data (), eff_type_v2, - value_contents_raw (val).data (), result_type); + val->contents_raw ().data (), result_type); } else if (type1->code () == TYPE_CODE_BOOL || type2->code () == TYPE_CODE_BOOL) @@ -1215,7 +1215,7 @@ scalar_binop (struct value *arg1, struct value *arg2, enum exp_opcode op) result_type = type1; val = value::allocate (result_type); - store_signed_integer (value_contents_raw (val).data (), + store_signed_integer (val->contents_raw ().data (), result_type->length (), type_byte_order (result_type), v); @@ -1361,7 +1361,7 @@ scalar_binop (struct value *arg1, struct value *arg2, enum exp_opcode op) } val = value::allocate (result_type); - store_unsigned_integer (value_contents_raw (val).data (), + store_unsigned_integer (val->contents_raw ().data (), val->type ()->length (), type_byte_order (result_type), v); @@ -1522,7 +1522,7 @@ scalar_binop (struct value *arg1, struct value *arg2, enum exp_opcode op) } val = value::allocate (result_type); - store_signed_integer (value_contents_raw (val).data (), + store_signed_integer (val->contents_raw ().data (), val->type ()->length (), type_byte_order (result_type), v); @@ -1567,7 +1567,7 @@ value_vector_widen (struct value *scalar_value, struct type *vector_type) error (_("conversion of scalar to vector involves truncation")); value *val = value::allocate (vector_type); - gdb::array_view val_contents = value_contents_writeable (val); + gdb::array_view val_contents = val->contents_writeable (); int elt_len = eltype->length (); for (i = 0; i < high_bound - low_bound + 1; i++) @@ -1614,7 +1614,7 @@ vector_binop (struct value *val1, struct value *val2, enum exp_opcode op) error (_("Cannot perform operation on vectors with different types")); value *val = value::allocate (type1); - gdb::array_view val_contents = value_contents_writeable (val); + gdb::array_view val_contents = val->contents_writeable (); scoped_value_mark mark; for (i = 0; i < high_bound1 - low_bound1 + 1; i++) { @@ -1909,7 +1909,7 @@ value_neg (struct value *arg1) if (!get_array_bounds (type, &low_bound, &high_bound)) error (_("Could not determine the vector bounds")); - gdb::array_view val_contents = value_contents_writeable (val); + gdb::array_view val_contents = val->contents_writeable (); int elt_len = eltype->length (); for (i = 0; i < high_bound - low_bound + 1; i++) @@ -1954,7 +1954,7 @@ value_complement (struct value *arg1) error (_("Could not determine the vector bounds")); val = value::allocate (type); - gdb::array_view val_contents = value_contents_writeable (val); + gdb::array_view val_contents = val->contents_writeable (); int elt_len = eltype->length (); for (i = 0; i < high_bound - low_bound + 1; i++) diff --git a/gdb/valops.c b/gdb/valops.c index a6357f0afca..738967cc88d 100644 --- a/gdb/valops.c +++ b/gdb/valops.c @@ -392,7 +392,7 @@ value_cast_to_fixed_point (struct type *to_type, struct value *from_val) /* Finally, create the result value, and pack the unscaled value in it. */ struct value *result = value::allocate (to_type); - unscaled.write (value_contents_raw (result), + unscaled.write (result->contents_raw (), type_byte_order (to_type), to_type->is_unsigned ()); @@ -545,7 +545,7 @@ value_cast (struct type *type, struct value *arg2) { struct value *v = value::allocate (to_type); target_float_convert (value_contents (arg2).data (), type2, - value_contents_raw (v).data (), type); + v->contents_raw ().data (), type); return v; } else if (is_fixed_point_type (type2)) @@ -558,7 +558,7 @@ value_cast (struct type *type, struct value *arg2) type2->fixed_point_scaling_factor ()); struct value *v = value::allocate (to_type); - target_float_from_host_double (value_contents_raw (v).data (), + target_float_from_host_double (v->contents_raw ().data (), to_type, mpq_get_d (fp_val.val)); return v; } @@ -621,7 +621,7 @@ value_cast (struct type *type, struct value *arg2) struct value *result = value::allocate (to_type); cplus_make_method_ptr (to_type, - value_contents_writeable (result).data (), 0, 0); + result->contents_writeable ().data (), 0, 0); return result; } else if (code1 == TYPE_CODE_MEMBERPTR && code2 == TYPE_CODE_INT @@ -955,7 +955,7 @@ value_one (struct type *type) error (_("Could not determine the vector bounds")); val = value::allocate (type); - gdb::array_view val_contents = value_contents_writeable (val); + gdb::array_view val_contents = val->contents_writeable (); int elt_len = eltype->length (); for (i = 0; i < high_bound - low_bound + 1; i++) @@ -1344,7 +1344,7 @@ value_assign (struct value *toval, struct value *fromval) implies the returned value is not lazy, even if TOVAL was. */ val = value_copy (toval); val->set_lazy (0); - copy (value_contents (fromval), value_contents_raw (val)); + copy (value_contents (fromval), val->contents_raw ()); /* We copy over the enclosing type and pointed-to offset from FROMVAL in the case of pointer types. For object types, the enclosing type @@ -1377,7 +1377,7 @@ value_repeat (struct value *arg1, int count) val->set_address (arg1->address ()); read_value_memory (val, 0, val->stack (), val->address (), - value_contents_all_raw (val).data (), + val->contents_all_raw ().data (), type_length_units (val->enclosing_type ())); return val; @@ -1750,7 +1750,7 @@ value_cstring (const char *ptr, ssize_t len, struct type *char_type) = lookup_array_range_type (char_type, lowbound, highbound + lowbound - 1); val = value::allocate (stringtype); - memcpy (value_contents_raw (val).data (), ptr, len); + memcpy (val->contents_raw ().data (), ptr, len); return val; } @@ -1773,7 +1773,7 @@ value_string (const char *ptr, ssize_t len, struct type *char_type) = lookup_string_range_type (char_type, lowbound, highbound + lowbound - 1); val = value::allocate (stringtype); - memcpy (value_contents_raw (val).data (), ptr, len); + memcpy (val->contents_raw ().data (), ptr, len); return val; } @@ -2101,7 +2101,7 @@ struct_field_searcher::search (struct value *arg1, LONGEST offset, base_addr = arg1->address () + boffset; v2 = value_at_lazy (basetype, base_addr); if (target_read_memory (base_addr, - value_contents_raw (v2).data (), + v2->contents_raw ().data (), v2->type ()->length ()) != 0) error (_("virtual baseclass botch")); } @@ -3740,7 +3740,7 @@ value_struct_elt_for_reference (struct type *domain, int offset, result = value::allocate (lookup_methodptr_type (TYPE_FN_FIELD_TYPE (f, j))); cplus_make_method_ptr (result->type (), - value_contents_writeable (result).data (), + result->contents_writeable ().data (), TYPE_FN_FIELD_VOFFSET (f, j), 1); } else if (noside == EVAL_AVOID_SIDE_EFFECTS) @@ -3765,7 +3765,7 @@ value_struct_elt_for_reference (struct type *domain, int offset, { result = value::allocate (lookup_methodptr_type (TYPE_FN_FIELD_TYPE (f, j))); cplus_make_method_ptr (result->type (), - value_contents_writeable (result).data (), + result->contents_writeable ().data (), v->address (), 0); } } @@ -4111,9 +4111,9 @@ value_literal_complex (struct value *arg1, int len = real_type->length (); copy (value_contents (arg1), - value_contents_raw (val).slice (0, len)); + val->contents_raw ().slice (0, len)); copy (value_contents (arg2), - value_contents_raw (val).slice (len, len)); + val->contents_raw ().slice (len, len)); return val; } @@ -4158,9 +4158,9 @@ cast_into_complex (struct type *type, struct value *val) int len = val_real_type->length (); copy (value_contents (val).slice (0, len), - value_contents_raw (re_val)); + re_val->contents_raw ()); copy (value_contents (val).slice (len, len), - value_contents_raw (im_val)); + im_val->contents_raw ()); return value_literal_complex (re_val, im_val, type); } diff --git a/gdb/valprint.c b/gdb/valprint.c index 4a2aa5f4878..8c6973ca1f1 100644 --- a/gdb/valprint.c +++ b/gdb/valprint.c @@ -3092,7 +3092,7 @@ test_print_flags (gdbarch *arch) append_flags_type_field (flags_type, 5, 3, field_type, "C"); value *val = value::allocate (flags_type); - gdb_byte *contents = value_contents_writeable (val).data (); + gdb_byte *contents = val->contents_writeable ().data (); store_unsigned_integer (contents, 4, gdbarch_byte_order (arch), 0xaa); string_file out; diff --git a/gdb/value.c b/gdb/value.c index 550bcb4709f..c22c7670a6a 100644 --- a/gdb/value.c +++ b/gdb/value.c @@ -891,25 +891,25 @@ value::allocate_optimized_out (struct type *type) /* Accessor methods. */ gdb::array_view -value_contents_raw (struct value *value) +value::contents_raw () { - struct gdbarch *arch = value->get_arch (); + struct gdbarch *arch = get_arch (); int unit_size = gdbarch_addressable_memory_unit_size (arch); - allocate_value_contents (value); + allocate_value_contents (this); - ULONGEST length = value->type ()->length (); + ULONGEST length = type ()->length (); return gdb::make_array_view - (value->m_contents.get () + value->m_embedded_offset * unit_size, length); + (m_contents.get () + m_embedded_offset * unit_size, length); } gdb::array_view -value_contents_all_raw (struct value *value) +value::contents_all_raw () { - allocate_value_contents (value); + allocate_value_contents (this); - ULONGEST length = value->enclosing_type ()->length (); - return gdb::make_array_view (value->m_contents.get (), length); + ULONGEST length = enclosing_type ()->length (); + return gdb::make_array_view (m_contents.get (), length); } /* Look at value.h for description. */ @@ -1083,10 +1083,10 @@ value_contents_copy_raw (struct value *dst, LONGEST dst_offset, /* Copy the data. */ gdb::array_view dst_contents - = value_contents_all_raw (dst).slice (dst_offset * unit_size, + = dst->contents_all_raw ().slice (dst_offset * unit_size, length * unit_size); gdb::array_view src_contents - = value_contents_all_raw (src).slice (src_offset * unit_size, + = src->contents_all_raw ().slice (src_offset * unit_size, length * unit_size); copy (src_contents, dst_contents); @@ -1124,8 +1124,8 @@ value_contents_copy_raw_bitwise (struct value *dst, LONGEST dst_bit_offset, bit_length)); /* Copy the data. */ - gdb::array_view dst_contents = value_contents_all_raw (dst); - gdb::array_view src_contents = value_contents_all_raw (src); + gdb::array_view dst_contents = dst->contents_all_raw (); + gdb::array_view src_contents = src->contents_all_raw (); copy_bitwise (dst_contents.data (), dst_bit_offset, src_contents.data (), src_bit_offset, bit_length, @@ -1160,18 +1160,18 @@ value_contents_copy (struct value *dst, LONGEST dst_offset, gdb::array_view value_contents (struct value *value) { - gdb::array_view result = value_contents_writeable (value); + gdb::array_view result = value->contents_writeable (); require_not_optimized_out (value); require_available (value); return result; } gdb::array_view -value_contents_writeable (struct value *value) +value::contents_writeable () { - if (value->m_lazy) - value_fetch_lazy (value); - return value_contents_raw (value); + if (m_lazy) + value_fetch_lazy (this); + return contents_raw (); } int @@ -1438,7 +1438,7 @@ value_copy (const value *arg) ULONGEST length = arg->enclosing_type ()->length (); const auto &arg_view = gdb::make_array_view (arg->m_contents.get (), length); - copy (arg_view, value_contents_all_raw (val)); + copy (arg_view, val->contents_all_raw ()); } val->m_parent = arg->m_parent; @@ -1481,7 +1481,7 @@ value_non_lval (struct value *arg) struct type *enc_type = arg->enclosing_type (); struct value *val = value::allocate (enc_type); - copy (value_contents_all (arg), value_contents_all_raw (val)); + copy (value_contents_all (arg), val->contents_all_raw ()); val->m_type = arg->m_type; val->set_embedded_offset (arg->embedded_offset ()); val->set_pointed_to_offset (arg->pointed_to_offset ()); @@ -1497,7 +1497,7 @@ value_force_lval (struct value *v, CORE_ADDR addr) { gdb_assert (VALUE_LVAL (v) == not_lval); - write_memory (addr, value_contents_raw (v).data (), v->type ()->length ()); + write_memory (addr, v->contents_raw ().data (), v->type ()->length ()); v->m_lval = lval_memory; v->m_location.address = addr; } @@ -2030,7 +2030,7 @@ set_internalvar_component (struct internalvar *var, switch (var->kind) { case INTERNALVAR_VALUE: - addr = value_contents_writeable (var->u.value).data (); + addr = var->u.value->contents_writeable ().data (); arch = var->u.value->get_arch (); unit_size = gdbarch_addressable_memory_unit_size (arch); @@ -3065,7 +3065,7 @@ unpack_value_bitfield (struct value *dest_val, num = unpack_bits_as_long (field_type, valaddr + embedded_offset, bitpos, bitsize); - store_signed_integer (value_contents_raw (dest_val).data (), + store_signed_integer (dest_val->contents_raw ().data (), field_type->length (), byte_order, num); } @@ -3271,7 +3271,7 @@ value_from_longest (struct type *type, LONGEST num) { struct value *val = value::allocate (type); - pack_long (value_contents_raw (val).data (), type, num); + pack_long (val->contents_raw ().data (), type, num); return val; } @@ -3283,7 +3283,7 @@ value_from_ulongest (struct type *type, ULONGEST num) { struct value *val = value::allocate (type); - pack_unsigned_long (value_contents_raw (val).data (), type, num); + pack_unsigned_long (val->contents_raw ().data (), type, num); return val; } @@ -3297,7 +3297,7 @@ value_from_pointer (struct type *type, CORE_ADDR addr) { struct value *val = value::allocate (type); - store_typed_address (value_contents_raw (val).data (), + store_typed_address (val->contents_raw ().data (), check_typedef (type), addr); return val; } @@ -3311,7 +3311,7 @@ value_from_host_double (struct type *type, double d) { struct value *value = value::allocate (type); gdb_assert (type->code () == TYPE_CODE_FLT); - target_float_from_host_double (value_contents_raw (value).data (), + target_float_from_host_double (value->contents_raw ().data (), value->type (), d); return value; } @@ -3377,7 +3377,7 @@ value_from_contents (struct type *type, const gdb_byte *contents) struct value *result; result = value::allocate (type); - memcpy (value_contents_raw (result).data (), contents, type->length ()); + memcpy (result->contents_raw ().data (), contents, type->length ()); return result; } @@ -3657,7 +3657,7 @@ value_fetch_lazy_memory (struct value *val) if (type->length ()) read_value_memory (val, 0, val->stack (), - addr, value_contents_all_raw (val).data (), + addr, val->contents_all_raw ().data (), type_length_units (type)); } diff --git a/gdb/value.h b/gdb/value.h index e45ff9f8d9f..4f161a9ed4f 100644 --- a/gdb/value.h +++ b/gdb/value.h @@ -371,6 +371,22 @@ struct value int *deprecated_regnum_hack (); + /* contents() and contents_raw() both return the address of the gdb + buffer used to hold a copy of the contents of the lval. + contents() is used when the contents of the buffer are needed -- + it uses fetch_lazy() to load the buffer from the process being + debugged if it hasn't already been loaded (contents_writeable() + is used when a writeable but fetched buffer is required).. + contents_raw() is used when data is being stored into the buffer, + or when it is certain that the contents of the buffer are valid. + + Note: The contents pointer is adjusted by the offset required to + get to the real subobject, if the value happens to represent + something embedded in a larger run-time object. */ + gdb::array_view contents_raw (); + gdb::array_view contents_all_raw (); + gdb::array_view contents_writeable (); + /* Type of value; either not an lval, or one of the various different possible kinds of lval. */ @@ -620,22 +636,6 @@ struct lval_funcs extern void error_value_optimized_out (void); -/* value_contents() and value_contents_raw() both return the address - of the gdb buffer used to hold a copy of the contents of the lval. - value_contents() is used when the contents of the buffer are needed - -- it uses value_fetch_lazy() to load the buffer from the process - being debugged if it hasn't already been loaded - (value_contents_writeable() is used when a writeable but fetched - buffer is required).. value_contents_raw() is used when data is - being stored into the buffer, or when it is certain that the - contents of the buffer are valid. - - Note: The contents pointer is adjusted by the offset required to - get to the real subobject, if the value happens to represent - something embedded in a larger run-time object. */ - -extern gdb::array_view value_contents_raw (struct value *); - /* Actual contents of the value. For use of this value; setting it uses the stuff above. Not valid if lazy is nonzero. Target byte-order. We force it to be aligned properly for any possible @@ -643,12 +643,10 @@ extern gdb::array_view value_contents_raw (struct value *); declared here. */ extern gdb::array_view value_contents (struct value *); -extern gdb::array_view value_contents_writeable (struct value *); /* The ALL variants of the above two macros do not adjust the returned pointer by the embedded_offset value. */ -extern gdb::array_view value_contents_all_raw (struct value *); extern gdb::array_view value_contents_all (struct value *); /* Like value_contents_all, but does not require that the returned diff --git a/gdb/windows-tdep.c b/gdb/windows-tdep.c index 893e34d9912..97199527c8b 100644 --- a/gdb/windows-tdep.c +++ b/gdb/windows-tdep.c @@ -404,7 +404,7 @@ tlb_value_read (struct value *val) if (!target_get_tib_address (inferior_ptid, &tlb)) error (_("Unable to read tlb")); - store_typed_address (value_contents_raw (val).data (), type, tlb); + store_typed_address (val->contents_raw ().data (), type, tlb); } /* This function implements the lval_computed support for writing a From patchwork Thu Feb 9 21:38:48 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tom Tromey X-Patchwork-Id: 64579 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 CABA5392AC38 for ; Thu, 9 Feb 2023 21:42:18 +0000 (GMT) X-Original-To: gdb-patches@sourceware.org Delivered-To: gdb-patches@sourceware.org Received: from gproxy4-pub.mail.unifiedlayer.com (gproxy4-pub.mail.unifiedlayer.com [69.89.23.142]) by sourceware.org (Postfix) with ESMTPS id 31A48385B51E for ; Thu, 9 Feb 2023 21:38:44 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 31A48385B51E 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 cmgw13.mail.unifiedlayer.com (unknown [10.0.90.128]) by progateway6.mail.pro1.eigbox.com (Postfix) with ESMTP id 93EFB10044F53 for ; Thu, 9 Feb 2023 21:38:43 +0000 (UTC) Received: from box5379.bluehost.com ([162.241.216.53]) by cmsmtp with ESMTP id QEctpHudbNX2aQEctp2uD0; Thu, 09 Feb 2023 21:38:43 +0000 X-Authority-Reason: nr=8 X-Authority-Analysis: v=2.4 cv=NMAQR22g c=1 sm=1 tr=0 ts=63e567e3 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=j9QHJdDZFMasv2pPwIUA: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=CMWiSLpg8WT/Nrq287RZAGgqy2Nmd2wLR9T1qqokqqE=; b=oywXowynRm0Mvbnuho2ZHvPtzM HQJdPhfarlcowE8qlJB/ItblJ28g6EOmdF35WVG5mp20i/fTBTrCEPCwmUW3OXtwtL2DosLr9V9we liiNLA3s0J3/oQFNB1BAqvcel; 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-Ds for gdb-patches@sourceware.org; Thu, 09 Feb 2023 14:38:43 -0700 From: Tom Tromey Date: Thu, 09 Feb 2023 14:38:48 -0700 Subject: [PATCH 27/47] Turn value_fetch_lazy into a method MIME-Version: 1.0 Message-Id: <20230209-submit-value-fixups-2023-v1-27-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-Ds 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: 28 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_fetch_lazy to be a method of value. --- gdb/ada-lang.c | 4 +-- gdb/ada-valprint.c | 2 +- gdb/eval.c | 6 ++-- gdb/findvar.c | 2 +- gdb/gnu-v2-abi.c | 2 +- gdb/guile/scm-pretty-print.c | 2 +- gdb/guile/scm-value.c | 2 +- gdb/python/py-prettyprint.c | 2 +- gdb/python/py-value.c | 2 +- gdb/rust-lang.c | 2 +- gdb/stack.c | 10 +++---- gdb/valops.c | 2 +- gdb/valprint.c | 2 +- gdb/value.c | 68 ++++++++++++++++++++------------------------ gdb/value.h | 11 +++++-- gdb/varobj.c | 2 +- 16 files changed, 61 insertions(+), 60 deletions(-) diff --git a/gdb/ada-lang.c b/gdb/ada-lang.c index 274b5e3ce03..7f962200a1f 100644 --- a/gdb/ada-lang.c +++ b/gdb/ada-lang.c @@ -10853,7 +10853,7 @@ ada_var_msym_value_operation::evaluate_for_cast (struct type *expect_type, if (VALUE_LVAL (val) == lval_memory) { if (val->lazy ()) - value_fetch_lazy (val); + val->fetch_lazy (); VALUE_LVAL (val) = not_lval; } return val; @@ -10875,7 +10875,7 @@ ada_var_value_operation::evaluate_for_cast (struct type *expect_type, if (VALUE_LVAL (val) == lval_memory) { if (val->lazy ()) - value_fetch_lazy (val); + val->fetch_lazy (); VALUE_LVAL (val) = not_lval; } return val; diff --git a/gdb/ada-valprint.c b/gdb/ada-valprint.c index 814678ea0e1..05d30649887 100644 --- a/gdb/ada-valprint.c +++ b/gdb/ada-valprint.c @@ -983,7 +983,7 @@ ada_val_print_ref (struct type *type, const gdb_byte *valaddr, deref_val = ada_tag_value_at_base_address (deref_val); if (deref_val->lazy ()) - value_fetch_lazy (deref_val); + deref_val->fetch_lazy (); common_val_print (deref_val, stream, recurse + 1, options, language_def (language_ada)); diff --git a/gdb/eval.c b/gdb/eval.c index fbc72a5a34e..74ce57ac70c 100644 --- a/gdb/eval.c +++ b/gdb/eval.c @@ -212,7 +212,7 @@ fetch_subexp_value (struct expression *exp, try { - value_fetch_lazy (result); + result->fetch_lazy (); *valp = result; } catch (const gdb_exception_error &except) @@ -2878,7 +2878,7 @@ var_msym_value_operation::evaluate_for_cast (struct type *to_type, if (VALUE_LVAL (val) == lval_memory) { if (val->lazy ()) - value_fetch_lazy (val); + val->fetch_lazy (); VALUE_LVAL (val) = not_lval; } return val; @@ -2899,7 +2899,7 @@ var_value_operation::evaluate_for_cast (struct type *to_type, if (VALUE_LVAL (val) == lval_memory) { if (val->lazy ()) - value_fetch_lazy (val); + val->fetch_lazy (); VALUE_LVAL (val) = not_lval; } return val; diff --git a/gdb/findvar.c b/gdb/findvar.c index a64b35c2bcf..b4852b2cfb3 100644 --- a/gdb/findvar.c +++ b/gdb/findvar.c @@ -262,7 +262,7 @@ value_of_register (int regnum, frame_info_ptr frame) return value_of_user_reg (regnum, frame); reg_val = value_of_register_lazy (frame, regnum); - value_fetch_lazy (reg_val); + reg_val->fetch_lazy (); return reg_val; } diff --git a/gdb/gnu-v2-abi.c b/gdb/gnu-v2-abi.c index 908581a2063..4636ad55109 100644 --- a/gdb/gnu-v2-abi.c +++ b/gdb/gnu-v2-abi.c @@ -164,7 +164,7 @@ gnuv2_virtual_fn_field (struct value **arg1p, struct fn_field * f, int j, if (!arg1->lazy ()) { arg1->set_lazy (1); - value_fetch_lazy (arg1); + arg1->fetch_lazy (); } vfn = value_field (entry, 2); diff --git a/gdb/guile/scm-pretty-print.c b/gdb/guile/scm-pretty-print.c index 7a680c052d3..ca44133cd7f 100644 --- a/gdb/guile/scm-pretty-print.c +++ b/gdb/guile/scm-pretty-print.c @@ -966,7 +966,7 @@ gdbscm_apply_val_pretty_printer (const struct extension_language_defn *extlang, enum guile_string_repr_result print_result; if (value->lazy ()) - value_fetch_lazy (value); + value->fetch_lazy (); /* No pretty-printer support for unavailable values. */ if (!value_bytes_available (value, 0, type->length ())) diff --git a/gdb/guile/scm-value.c b/gdb/guile/scm-value.c index 8f292c25851..195fd3b8912 100644 --- a/gdb/guile/scm-value.c +++ b/gdb/guile/scm-value.c @@ -1248,7 +1248,7 @@ gdbscm_value_fetch_lazy_x (SCM self) return gdbscm_wrap ([=] { if (value->lazy ()) - value_fetch_lazy (value); + value->fetch_lazy (); return SCM_UNSPECIFIED; }); } diff --git a/gdb/python/py-prettyprint.c b/gdb/python/py-prettyprint.c index 0bd54dab5c6..18d2b7f5ba4 100644 --- a/gdb/python/py-prettyprint.c +++ b/gdb/python/py-prettyprint.c @@ -579,7 +579,7 @@ gdbpy_apply_val_pretty_printer (const struct extension_language_defn *extlang, enum gdbpy_string_repr_result print_result; if (value->lazy ()) - value_fetch_lazy (value); + value->fetch_lazy (); /* No pretty-printer support for unavailable values. */ if (!value_bytes_available (value, 0, type->length ())) diff --git a/gdb/python/py-value.c b/gdb/python/py-value.c index 6a176c7efda..465d8d92bd2 100644 --- a/gdb/python/py-value.c +++ b/gdb/python/py-value.c @@ -1241,7 +1241,7 @@ valpy_fetch_lazy (PyObject *self, PyObject *args) try { if (value->lazy ()) - value_fetch_lazy (value); + value->fetch_lazy (); } catch (const gdb_exception &except) { diff --git a/gdb/rust-lang.c b/gdb/rust-lang.c index ff30babca75..cca2baa6f63 100644 --- a/gdb/rust-lang.c +++ b/gdb/rust-lang.c @@ -352,7 +352,7 @@ rust_val_print_slice (struct value *val, struct ui_file *stream, int recurse, struct value *array = value::allocate_lazy (array_type); VALUE_LVAL (array) = lval_memory; array->set_address (value_as_address (base)); - value_fetch_lazy (array); + array->fetch_lazy (); generic_value_print (array, stream, recurse, options, &rust_decorations); } diff --git a/gdb/stack.c b/gdb/stack.c index ca6087f3414..983c99e5860 100644 --- a/gdb/stack.c +++ b/gdb/stack.c @@ -581,9 +581,9 @@ read_frame_arg (const frame_print_options &fp_opts, struct type *type = val->type (); if (val->lazy ()) - value_fetch_lazy (val); + val->fetch_lazy (); if (entryval->lazy ()) - value_fetch_lazy (entryval); + entryval->fetch_lazy (); if (value_contents_eq (val, 0, entryval, 0, type->length ())) { @@ -600,12 +600,12 @@ read_frame_arg (const frame_print_options &fp_opts, val_deref = coerce_ref (val); if (val_deref->lazy ()) - value_fetch_lazy (val_deref); + val_deref->fetch_lazy (); type_deref = val_deref->type (); entryval_deref = coerce_ref (entryval); if (entryval_deref->lazy ()) - value_fetch_lazy (entryval_deref); + entryval_deref->fetch_lazy (); /* If the reference addresses match but dereferenced content does not match print them. */ @@ -2750,7 +2750,7 @@ return_command (const char *retval_exp, int from_tty) /* Make sure the value is fully evaluated. It may live in the stack frame we're about to pop. */ if (return_value->lazy ()) - value_fetch_lazy (return_value); + return_value->fetch_lazy (); if (thisfun != NULL) function = read_var_value (thisfun, NULL, thisframe); diff --git a/gdb/valops.c b/gdb/valops.c index 738967cc88d..ceec461c483 100644 --- a/gdb/valops.c +++ b/gdb/valops.c @@ -992,7 +992,7 @@ get_value_at (struct type *type, CORE_ADDR addr, int lazy) val = value_from_contents_and_address (type, NULL, addr); if (!lazy) - value_fetch_lazy (val); + val->fetch_lazy (); return val; } diff --git a/gdb/valprint.c b/gdb/valprint.c index 8c6973ca1f1..8b565955e1c 100644 --- a/gdb/valprint.c +++ b/gdb/valprint.c @@ -1044,7 +1044,7 @@ common_val_print (struct value *value, struct ui_file *stream, int recurse, value = ada_to_fixed_value (value); if (value->lazy ()) - value_fetch_lazy (value); + value->fetch_lazy (); struct value_print_options local_opts = *options; struct type *type = value->type (); diff --git a/gdb/value.c b/gdb/value.c index c22c7670a6a..57f57f38b26 100644 --- a/gdb/value.c +++ b/gdb/value.c @@ -199,7 +199,7 @@ value_entirely_available (struct value *value) /* We can only tell whether the whole value is available when we try to read it. */ if (value->m_lazy) - value_fetch_lazy (value); + value->fetch_lazy (); if (value->m_unavailable.empty ()) return 1; @@ -217,7 +217,7 @@ value_entirely_covered_by_range_vector (struct value *value, /* We can only tell whether the whole value is optimized out / unavailable when we try to read it. */ if (value->m_lazy) - value_fetch_lazy (value); + value->fetch_lazy (); if (ranges.size () == 1) { @@ -986,7 +986,7 @@ gdb::array_view value_contents_for_printing (struct value *value) { if (value->m_lazy) - value_fetch_lazy (value); + value->fetch_lazy (); ULONGEST length = value->enclosing_type ()->length (); return gdb::make_array_view (value->m_contents.get (), length); @@ -1152,7 +1152,7 @@ value_contents_copy (struct value *dst, LONGEST dst_offset, struct value *src, LONGEST src_offset, LONGEST length) { if (src->m_lazy) - value_fetch_lazy (src); + src->fetch_lazy (); value_contents_copy_raw (dst, dst_offset, src, src_offset, length); } @@ -1170,7 +1170,7 @@ gdb::array_view value::contents_writeable () { if (m_lazy) - value_fetch_lazy (this); + fetch_lazy (); return contents_raw (); } @@ -1194,7 +1194,7 @@ value_optimized_out (struct value *value) /* Fall back to fetching. */ try { - value_fetch_lazy (value); + value->fetch_lazy (); } catch (const gdb_exception_error &ex) { @@ -1578,7 +1578,7 @@ record_latest_value (struct value *val) the value was taken, and fast watchpoints should be able to assume that a value on the value history never changes. */ if (val->lazy ()) - value_fetch_lazy (val); + val->fetch_lazy (); /* We preserve VALUE_LVAL so that the user can find out where it was fetched from. This is a bit dubious, because then *&$1 does not just return $1 but the current contents of that location. c'est la vie... */ @@ -1941,7 +1941,7 @@ value_of_internalvar (struct gdbarch *gdbarch, struct internalvar *var) case INTERNALVAR_VALUE: val = value_copy (var->u.value); if (val->lazy ()) - value_fetch_lazy (val); + val->fetch_lazy (); break; case INTERNALVAR_MAKE_VALUE: @@ -2081,7 +2081,7 @@ set_internalvar (struct internalvar *var, struct value *val) later when this internalvar is referenced and the target is gone or has changed. */ if (copy->lazy ()) - value_fetch_lazy (copy); + copy->fetch_lazy (); /* Release the value from the value chain to prevent it from being deleted by free_all_values. From here on this function should not @@ -2794,7 +2794,7 @@ value_primitive_field (struct value *arg1, LONGEST offset, + (bitpos - v->m_bitpos) / 8); v->set_parent (arg1); if (!arg1->lazy ()) - value_fetch_lazy (v); + v->fetch_lazy (); } else if (fieldno < TYPE_N_BASECLASSES (arg_type)) { @@ -2805,7 +2805,7 @@ value_primitive_field (struct value *arg1, LONGEST offset, /* Lazy register values with offsets are not supported. */ if (VALUE_LVAL (arg1) == lval_register && arg1->lazy ()) - value_fetch_lazy (arg1); + arg1->fetch_lazy (); /* We special case virtual inheritance here because this requires access to the contents, which we would rather avoid @@ -2850,7 +2850,7 @@ value_primitive_field (struct value *arg1, LONGEST offset, /* Lazy register values with offsets are not supported. */ if (VALUE_LVAL (arg1) == lval_register && arg1->lazy ()) - value_fetch_lazy (arg1); + arg1->fetch_lazy (); if (arg1->lazy ()) v = value::allocate_lazy (type); @@ -3638,7 +3638,7 @@ value_fetch_lazy_bitfield (struct value *val) struct value *parent = val->parent (); if (parent->lazy ()) - value_fetch_lazy (parent); + parent->fetch_lazy (); unpack_value_bitfield (val, val->bitpos (), val->bitsize (), value_contents_for_printing (parent).data (), @@ -3719,7 +3719,7 @@ value_fetch_lazy_register (struct value *val) /* If it's still lazy (for instance, a saved register on the stack), fetch it. */ if (new_val->lazy ()) - value_fetch_lazy (new_val); + new_val->fetch_lazy (); /* Copy the contents and the unavailability/optimized-out meta-data from NEW_VAL to VAL. */ @@ -3779,41 +3779,35 @@ value_fetch_lazy_register (struct value *val) value_free_to_mark (mark); } -/* Load the actual content of a lazy value. Fetch the data from the - user's process and clear the lazy flag to indicate that the data in - the buffer is valid. - - If the value is zero-length, we avoid calling read_memory, which - would abort. We mark the value as fetched anyway -- all 0 bytes of - it. */ +/* See value.h. */ void -value_fetch_lazy (struct value *val) +value::fetch_lazy () { - gdb_assert (val->lazy ()); - allocate_value_contents (val); + gdb_assert (lazy ()); + allocate_value_contents (this); /* A value is either lazy, or fully fetched. The availability/validity is only established as we try to fetch a value. */ - gdb_assert (val->m_optimized_out.empty ()); - gdb_assert (val->m_unavailable.empty ()); - if (val->m_is_zero) + gdb_assert (m_optimized_out.empty ()); + gdb_assert (m_unavailable.empty ()); + if (m_is_zero) { /* Nothing. */ } - else if (val->bitsize ()) - value_fetch_lazy_bitfield (val); - else if (VALUE_LVAL (val) == lval_memory) - value_fetch_lazy_memory (val); - else if (VALUE_LVAL (val) == lval_register) - value_fetch_lazy_register (val); - else if (VALUE_LVAL (val) == lval_computed - && val->computed_funcs ()->read != NULL) - val->computed_funcs ()->read (val); + else if (bitsize ()) + value_fetch_lazy_bitfield (this); + else if (VALUE_LVAL (this) == lval_memory) + value_fetch_lazy_memory (this); + else if (VALUE_LVAL (this) == lval_register) + value_fetch_lazy_register (this); + else if (VALUE_LVAL (this) == lval_computed + && computed_funcs ()->read != NULL) + computed_funcs ()->read (this); else internal_error (_("Unexpected lazy value type.")); - val->set_lazy (0); + set_lazy (0); } /* Implementation of the convenience function $_isvoid. */ diff --git a/gdb/value.h b/gdb/value.h index 4f161a9ed4f..23fffb18158 100644 --- a/gdb/value.h +++ b/gdb/value.h @@ -387,6 +387,15 @@ struct value gdb::array_view contents_all_raw (); gdb::array_view contents_writeable (); + /* Load the actual content of a lazy value. Fetch the data from the + user's process and clear the lazy flag to indicate that the data in + the buffer is valid. + + If the value is zero-length, we avoid calling read_memory, which + would abort. We mark the value as fetched anyway -- all 0 bytes of + it. */ + void fetch_lazy (); + /* Type of value; either not an lval, or one of the various different possible kinds of lval. */ @@ -660,8 +669,6 @@ extern gdb::array_view value_contents_for_printing (struct value extern gdb::array_view value_contents_for_printing_const (const struct value *value); -extern void value_fetch_lazy (struct value *val); - /* If nonzero, this is the value of a variable which does not actually exist in the program, at least partially. If the value is lazy, this may fetch it now. */ diff --git a/gdb/varobj.c b/gdb/varobj.c index 0e023c09cf8..72d5e7f2a25 100644 --- a/gdb/varobj.c +++ b/gdb/varobj.c @@ -1268,7 +1268,7 @@ install_new_value (struct varobj *var, struct value *value, bool initial) try { - value_fetch_lazy (value); + value->fetch_lazy (); } catch (const gdb_exception_error &except) From patchwork Thu Feb 9 21:38:49 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tom Tromey X-Patchwork-Id: 64572 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 B2299389EC4C for ; Thu, 9 Feb 2023 21:41:25 +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 55D6C385B51F for ; Thu, 9 Feb 2023 21:38:44 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 55D6C385B51F 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 cmgw13.mail.unifiedlayer.com (unknown [10.0.90.128]) by progateway1.mail.pro1.eigbox.com (Postfix) with ESMTP id AFC191004061E for ; Thu, 9 Feb 2023 21:38:43 +0000 (UTC) Received: from box5379.bluehost.com ([162.241.216.53]) by cmsmtp with ESMTP id QEctpHudfNX2aQEctp2uD3; Thu, 09 Feb 2023 21:38:43 +0000 X-Authority-Reason: nr=8 X-Authority-Analysis: v=2.4 cv=NMAQR22g c=1 sm=1 tr=0 ts=63e567e3 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=RL-fo4EtTtgTAjgKU3cA: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=2/EEukR8SpJH8I+iUGtXDxrankJj9+bT/v7OglRFs3Y=; b=be0xyUfdVbp9X439FaNwKh3+y0 2w33Hf2epl/CQQBjHBE2F2WoF6V9FyZvPuQvGPn0R+8qqvGk0m7/uIbTZ4LtT4+9CEvCAStAvkY9H T+ckisFHIdAWDdXjrBDs1JxXI; 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-IG for gdb-patches@sourceware.org; Thu, 09 Feb 2023 14:38:43 -0700 From: Tom Tromey Date: Thu, 09 Feb 2023 14:38:49 -0700 Subject: [PATCH 28/47] Turn allocate_value_contents into a method MIME-Version: 1.0 Message-Id: <20230209-submit-value-fixups-2023-v1-28-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-IG 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: 29 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 turns the static function allocate_value_contents into a private method on value. --- gdb/value.c | 21 ++++++++++----------- gdb/value.h | 6 ++++++ 2 files changed, 16 insertions(+), 11 deletions(-) diff --git a/gdb/value.c b/gdb/value.c index 57f57f38b26..77315a1a337 100644 --- a/gdb/value.c +++ b/gdb/value.c @@ -821,16 +821,15 @@ check_type_length_before_alloc (const struct type *type) } } -/* Allocate the contents of VAL if it has not been allocated yet. */ +/* See value.h. */ -static void -allocate_value_contents (struct value *val) +void +value::allocate_contents () { - if (!val->m_contents) + if (!m_contents) { - check_type_length_before_alloc (val->m_enclosing_type); - val->m_contents.reset - ((gdb_byte *) xzalloc (val->m_enclosing_type->length ())); + check_type_length_before_alloc (m_enclosing_type); + m_contents.reset ((gdb_byte *) xzalloc (m_enclosing_type->length ())); } } @@ -839,7 +838,7 @@ value::allocate (struct type *type) { struct value *val = value::allocate_lazy (type); - allocate_value_contents (val); + val->allocate_contents (); val->m_lazy = 0; return val; } @@ -896,7 +895,7 @@ value::contents_raw () struct gdbarch *arch = get_arch (); int unit_size = gdbarch_addressable_memory_unit_size (arch); - allocate_value_contents (this); + this->allocate_contents (); ULONGEST length = type ()->length (); return gdb::make_array_view @@ -906,7 +905,7 @@ value::contents_raw () gdb::array_view value::contents_all_raw () { - allocate_value_contents (this); + this->allocate_contents (); ULONGEST length = enclosing_type ()->length (); return gdb::make_array_view (m_contents.get (), length); @@ -3785,7 +3784,7 @@ void value::fetch_lazy () { gdb_assert (lazy ()); - allocate_value_contents (this); + this->allocate_contents (); /* A value is either lazy, or fully fetched. The availability/validity is only established as we try to fetch a value. */ diff --git a/gdb/value.h b/gdb/value.h index 23fffb18158..e3574b3a169 100644 --- a/gdb/value.h +++ b/gdb/value.h @@ -561,6 +561,12 @@ struct value treated pretty much the same, except not-saved registers have a different string representation and related error strings. */ std::vector m_optimized_out; + +private: + + /* Allocate the contents of this value if it has not been allocated + yet. */ + void allocate_contents (); }; /* Returns value_type or value_enclosing_type depending on From patchwork Thu Feb 9 21:38:50 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tom Tromey X-Patchwork-Id: 64573 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 15F143894C1B for ; Thu, 9 Feb 2023 21:41:32 +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 70BFD385B520 for ; Thu, 9 Feb 2023 21:38:44 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 70BFD385B520 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 cmgw11.mail.unifiedlayer.com (unknown [10.0.90.126]) by progateway1.mail.pro1.eigbox.com (Postfix) with ESMTP id D0AE110040631 for ; Thu, 9 Feb 2023 21:38:43 +0000 (UTC) Received: from box5379.bluehost.com ([162.241.216.53]) by cmsmtp with ESMTP id QEctphyDK2s14QEctphhnP; Thu, 09 Feb 2023 21:38:43 +0000 X-Authority-Reason: nr=8 X-Authority-Analysis: v=2.4 cv=R7DGpfdX c=1 sm=1 tr=0 ts=63e567e3 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=Yn_925DSyGT9ronrvdoA: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=594qB/vWUYi1cG3jn/y2WyA3yR+fJFCYwqMQOtPyJ/0=; b=l79pfWckek7WDUgpCrsw8ajywo 4z8PRUhWSTXQn0Vtbkeku+rh1nR4dSu7Wqs+XvLvA3b5IiqcbKkCwPJ55SNOh4M6qEk5736VfjKQM rtZWzfnBNSUfAC9cYEL3MxMAL; 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-Lv for gdb-patches@sourceware.org; Thu, 09 Feb 2023 14:38:43 -0700 From: Tom Tromey Date: Thu, 09 Feb 2023 14:38:50 -0700 Subject: [PATCH 29/47] Turn value_contents_eq into a method MIME-Version: 1.0 Message-Id: <20230209-submit-value-fixups-2023-v1-29-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-Lv 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: 30 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_contents_eq to be a method of value. It also converts the static function value_contents_bits_eq into a private method. --- gdb/ada-valprint.c | 6 +-- gdb/f-valprint.c | 8 ++-- gdb/mi/mi-main.c | 4 +- gdb/stack.c | 8 ++-- gdb/valprint.c | 2 +- gdb/value.c | 37 +++++++-------- gdb/value.h | 132 ++++++++++++++++++++++++++++------------------------- 7 files changed, 102 insertions(+), 95 deletions(-) diff --git a/gdb/ada-valprint.c b/gdb/ada-valprint.c index 05d30649887..491346b450d 100644 --- a/gdb/ada-valprint.c +++ b/gdb/ada-valprint.c @@ -199,9 +199,9 @@ val_print_packed_array_elements (struct type *type, const gdb_byte *valaddr, if (check_typedef (v0->type ())->length () != check_typedef (v1->type ())->length ()) break; - if (!value_contents_eq (v0, v0->embedded_offset (), - v1, v1->embedded_offset (), - check_typedef (v0->type ())->length ())) + if (!v0->contents_eq (v0->embedded_offset (), + v1, v1->embedded_offset (), + check_typedef (v0->type ())->length ())) break; } diff --git a/gdb/f-valprint.c b/gdb/f-valprint.c index 9d0f02af954..8d4177f3243 100644 --- a/gdb/f-valprint.c +++ b/gdb/f-valprint.c @@ -263,8 +263,8 @@ class fortran_array_printer_impl : public fortran_array_walker_base_impl LONGEST elt_off_prev = m_elt_off_prev; bool repeated = (m_options->repeat_count_threshold < UINT_MAX && elt_type_prev != nullptr - && value_contents_eq (m_val, elt_off_prev, m_val, elt_off, - elt_type->length ())); + && m_val->contents_eq (elt_off_prev, m_val, elt_off, + elt_type->length ())); if (repeated) m_nrepeats++; @@ -362,8 +362,8 @@ class fortran_array_printer_impl : public fortran_array_walker_base_impl return true; } else - return value_contents_eq (val, offset1, val, offset2, - type->length ()); + return val->contents_eq (offset1, val, offset2, + type->length ()); } /* The number of elements printed so far. */ diff --git a/gdb/mi/mi-main.c b/gdb/mi/mi-main.c index 609872455ff..f2e680cb0d3 100644 --- a/gdb/mi/mi-main.c +++ b/gdb/mi/mi-main.c @@ -983,8 +983,8 @@ register_changed_p (int regnum, readonly_detached_regcache *prev_regs, gdb_assert (prev_value != NULL); gdb_assert (this_value != NULL); - auto ret = !value_contents_eq (prev_value, 0, this_value, 0, - register_size (gdbarch, regnum)); + auto ret = !prev_value->contents_eq (0, this_value, 0, + register_size (gdbarch, regnum)); release_value (prev_value); release_value (this_value); diff --git a/gdb/stack.c b/gdb/stack.c index 983c99e5860..cd5e391debe 100644 --- a/gdb/stack.c +++ b/gdb/stack.c @@ -585,7 +585,7 @@ read_frame_arg (const frame_print_options &fp_opts, if (entryval->lazy ()) entryval->fetch_lazy (); - if (value_contents_eq (val, 0, entryval, 0, type->length ())) + if (val->contents_eq (0, entryval, 0, type->length ())) { /* Initialize it just to avoid a GCC false warning. */ struct value *val_deref = NULL, *entryval_deref; @@ -610,9 +610,9 @@ read_frame_arg (const frame_print_options &fp_opts, /* If the reference addresses match but dereferenced content does not match print them. */ if (val != val_deref - && value_contents_eq (val_deref, 0, - entryval_deref, 0, - type_deref->length ())) + && val_deref->contents_eq (0, + entryval_deref, 0, + type_deref->length ())) val_equal = 1; } catch (const gdb_exception_error &except) diff --git a/gdb/valprint.c b/gdb/valprint.c index 8b565955e1c..decaaa2710c 100644 --- a/gdb/valprint.c +++ b/gdb/valprint.c @@ -2024,7 +2024,7 @@ value_print_array_elements (struct value *val, struct ui_file *stream, = value_from_component_bitsize (val, elttype, rep1 * bit_stride, bit_stride); - if (!value_contents_eq (element, rep_elt)) + if (!element->contents_eq (rep_elt)) break; ++reps; ++rep1; diff --git a/gdb/value.c b/gdb/value.c index 77315a1a337..342f7edb034 100644 --- a/gdb/value.c +++ b/gdb/value.c @@ -633,29 +633,28 @@ find_first_range_overlap_and_match (struct ranges_and_idx *rp1, with LENGTH bits of VAL2's contents starting at OFFSET2 bits. Return true if the available bits match. */ -static bool -value_contents_bits_eq (const struct value *val1, int offset1, - const struct value *val2, int offset2, - int length) +bool +value::contents_bits_eq (int offset1, const struct value *val2, int offset2, + int length) const { /* Each array element corresponds to a ranges source (unavailable, optimized out). '1' is for VAL1, '2' for VAL2. */ struct ranges_and_idx rp1[2], rp2[2]; /* See function description in value.h. */ - gdb_assert (!val1->m_lazy && !val2->m_lazy); + gdb_assert (!m_lazy && !val2->m_lazy); /* We shouldn't be trying to compare past the end of the values. */ gdb_assert (offset1 + length - <= val1->m_enclosing_type->length () * TARGET_CHAR_BIT); + <= m_enclosing_type->length () * TARGET_CHAR_BIT); gdb_assert (offset2 + length <= val2->m_enclosing_type->length () * TARGET_CHAR_BIT); memset (&rp1, 0, sizeof (rp1)); memset (&rp2, 0, sizeof (rp2)); - rp1[0].ranges = &val1->m_unavailable; + rp1[0].ranges = &m_unavailable; rp2[0].ranges = &val2->m_unavailable; - rp1[1].ranges = &val1->m_optimized_out; + rp1[1].ranges = &m_optimized_out; rp2[1].ranges = &val2->m_optimized_out; while (length > 0) @@ -683,7 +682,7 @@ value_contents_bits_eq (const struct value *val1, int offset1, } /* Compare the available/valid contents. */ - if (memcmp_with_bit_offsets (val1->m_contents.get (), offset1, + if (memcmp_with_bit_offsets (m_contents.get (), offset1, val2->m_contents.get (), offset2, l) != 0) return false; @@ -695,26 +694,28 @@ value_contents_bits_eq (const struct value *val1, int offset1, return true; } +/* See value.h. */ + bool -value_contents_eq (const struct value *val1, LONGEST offset1, - const struct value *val2, LONGEST offset2, - LONGEST length) +value::contents_eq (LONGEST offset1, + const struct value *val2, LONGEST offset2, + LONGEST length) const { - return value_contents_bits_eq (val1, offset1 * TARGET_CHAR_BIT, - val2, offset2 * TARGET_CHAR_BIT, - length * TARGET_CHAR_BIT); + return contents_bits_eq (offset1 * TARGET_CHAR_BIT, + val2, offset2 * TARGET_CHAR_BIT, + length * TARGET_CHAR_BIT); } /* See value.h. */ bool -value_contents_eq (const struct value *val1, const struct value *val2) +value::contents_eq (const struct value *val2) const { - ULONGEST len1 = check_typedef (val1->enclosing_type ())->length (); + ULONGEST len1 = check_typedef (enclosing_type ())->length (); ULONGEST len2 = check_typedef (val2->enclosing_type ())->length (); if (len1 != len2) return false; - return value_contents_eq (val1, 0, val2, 0, len1); + return contents_eq (0, val2, 0, len1); } /* The value-history records all the values printed by print commands diff --git a/gdb/value.h b/gdb/value.h index e3574b3a169..2253784aedb 100644 --- a/gdb/value.h +++ b/gdb/value.h @@ -396,6 +396,66 @@ struct value it. */ void fetch_lazy (); + /* Compare LENGTH bytes of VAL1's contents starting at OFFSET1 with + LENGTH bytes of VAL2's contents starting at OFFSET2. + + Note that "contents" refers to the whole value's contents + (value_contents_all), without any embedded offset adjustment. For + example, to compare a complete object value with itself, including + its enclosing type chunk, you'd do: + + int len = check_typedef (val->enclosing_type ())->length (); + val->contents_eq (0, val, 0, len); + + Returns true iff the set of available/valid contents match. + + Optimized-out contents are equal to optimized-out contents, and are + not equal to non-optimized-out contents. + + Unavailable contents are equal to unavailable contents, and are not + equal to non-unavailable contents. + + For example, if 'x's represent an unavailable byte, and 'V' and 'Z' + represent different available/valid bytes, in a value with length + 16: + + offset: 0 4 8 12 16 + contents: xxxxVVVVxxxxVVZZ + + then: + + val->contents_eq(0, val, 8, 6) => true + val->contents_eq(0, val, 4, 4) => false + val->contents_eq(0, val, 8, 8) => false + val->contents_eq(4, val, 12, 2) => true + val->contents_eq(4, val, 12, 4) => true + val->contents_eq(3, val, 4, 4) => true + + If 'x's represent an unavailable byte, 'o' represents an optimized + out byte, in a value with length 8: + + offset: 0 4 8 + contents: xxxxoooo + + then: + + val->contents_eq(0, val, 2, 2) => true + val->contents_eq(4, val, 6, 2) => true + val->contents_eq(0, val, 4, 4) => true + + We only know whether a value chunk is unavailable or optimized out + if we've tried to read it. As this routine is used by printing + routines, which may be printing values in the value history, long + after the inferior is gone, it works with const values. Therefore, + this routine must not be called with lazy values. */ + + bool contents_eq (LONGEST offset1, const struct value *val2, LONGEST offset2, + LONGEST length) const; + + /* An overload of contents_eq that compares the entirety of both + values. */ + bool contents_eq (const struct value *val2) const; + /* Type of value; either not an lval, or one of the various different possible kinds of lval. */ @@ -567,6 +627,15 @@ struct value /* Allocate the contents of this value if it has not been allocated yet. */ void allocate_contents (); + + /* Helper function for value_contents_eq. The only difference is that + this function is bit rather than byte based. + + Compare LENGTH bits of VAL1's contents starting at OFFSET1 bits + with LENGTH bits of VAL2's contents starting at OFFSET2 bits. + Return true if the available bits match. */ + bool contents_bits_eq (int offset1, const struct value *val2, int offset2, + int length) const; }; /* Returns value_type or value_enclosing_type depending on @@ -801,69 +870,6 @@ extern void mark_value_bytes_unavailable (struct value *value, extern void mark_value_bits_unavailable (struct value *value, LONGEST offset, LONGEST length); -/* Compare LENGTH bytes of VAL1's contents starting at OFFSET1 with - LENGTH bytes of VAL2's contents starting at OFFSET2. - - Note that "contents" refers to the whole value's contents - (value_contents_all), without any embedded offset adjustment. For - example, to compare a complete object value with itself, including - its enclosing type chunk, you'd do: - - int len = check_typedef (val->enclosing_type ())->length (); - value_contents_eq (val, 0, val, 0, len); - - Returns true iff the set of available/valid contents match. - - Optimized-out contents are equal to optimized-out contents, and are - not equal to non-optimized-out contents. - - Unavailable contents are equal to unavailable contents, and are not - equal to non-unavailable contents. - - For example, if 'x's represent an unavailable byte, and 'V' and 'Z' - represent different available/valid bytes, in a value with length - 16: - - offset: 0 4 8 12 16 - contents: xxxxVVVVxxxxVVZZ - - then: - - value_contents_eq(val, 0, val, 8, 6) => true - value_contents_eq(val, 0, val, 4, 4) => false - value_contents_eq(val, 0, val, 8, 8) => false - value_contents_eq(val, 4, val, 12, 2) => true - value_contents_eq(val, 4, val, 12, 4) => true - value_contents_eq(val, 3, val, 4, 4) => true - - If 'x's represent an unavailable byte, 'o' represents an optimized - out byte, in a value with length 8: - - offset: 0 4 8 - contents: xxxxoooo - - then: - - value_contents_eq(val, 0, val, 2, 2) => true - value_contents_eq(val, 4, val, 6, 2) => true - value_contents_eq(val, 0, val, 4, 4) => true - - We only know whether a value chunk is unavailable or optimized out - if we've tried to read it. As this routine is used by printing - routines, which may be printing values in the value history, long - after the inferior is gone, it works with const values. Therefore, - this routine must not be called with lazy values. */ - -extern bool value_contents_eq (const struct value *val1, LONGEST offset1, - const struct value *val2, LONGEST offset2, - LONGEST length); - -/* An overload of value_contents_eq that compares the entirety of both - values. */ - -extern bool value_contents_eq (const struct value *val1, - const struct value *val2); - /* Read LENGTH addressable memory units starting at MEMADDR into BUFFER, which is (or will be copied to) VAL's contents buffer offset by BIT_OFFSET bits. Marks value contents ranges as unavailable if 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 From patchwork Thu Feb 9 21:38:52 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tom Tromey X-Patchwork-Id: 64605 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 5EC653889E0A for ; Thu, 9 Feb 2023 23:37:52 +0000 (GMT) X-Original-To: gdb-patches@sourceware.org Delivered-To: gdb-patches@sourceware.org Received: from gproxy4-pub.mail.unifiedlayer.com (gproxy4-pub.mail.unifiedlayer.com [69.89.23.142]) by sourceware.org (Postfix) with ESMTPS id 67AC93858C2D for ; Thu, 9 Feb 2023 23:36:42 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 67AC93858C2D 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 progateway6.mail.pro1.eigbox.com (Postfix) with ESMTP id D1342100478B0 for ; Thu, 9 Feb 2023 23:36:41 +0000 (UTC) Received: from box5379.bluehost.com ([162.241.216.53]) by cmsmtp with ESMTP id QGT3p0VteP796QGT3py8K9; Thu, 09 Feb 2023 23:36:41 +0000 X-Authority-Reason: nr=8 X-Authority-Analysis: v=2.4 cv=MJClJOVl c=1 sm=1 tr=0 ts=63e58389 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=ve6D31HdKIF5tFk1LdcA: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=XHzl6UzdaH9vpmhbnJNU8f5wxpmJIkUWpGe5lUR7D2A=; b=bmotGOM1IVrh2j36SY6Gl5U2UR gHLEX4PSvoUS2d+B3taa2uUzUj5ewWJK/b9QVn7K9Alp26JRBdS4cdeoCEjdDlb3nW/GlXLezu4lI GSruMvY1Ql6/jqItNZgiT71zR; 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-Tk for gdb-patches@sourceware.org; Thu, 09 Feb 2023 14:38:43 -0700 From: Tom Tromey Date: Thu, 09 Feb 2023 14:38:52 -0700 Subject: [PATCH 31/47] Move value_ref_policy methods out-of-line MIME-Version: 1.0 Message-Id: <20230209-submit-value-fixups-2023-v1-31-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-Tk 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: 10 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 moves the value_ref_policy methods to be defined out-of-line. This is a necessary step to change value_incref and value_decref to be methods of value. --- gdb/value.h | 23 ++++++++++++++--------- 1 file changed, 14 insertions(+), 9 deletions(-) diff --git a/gdb/value.h b/gdb/value.h index bf5effccfa9..c72bee07ca6 100644 --- a/gdb/value.h +++ b/gdb/value.h @@ -124,15 +124,8 @@ extern void value_decref (struct value *val); struct value_ref_policy { - static void incref (struct value *ptr) - { - value_incref (ptr); - } - - static void decref (struct value *ptr) - { - value_decref (ptr); - } + static void incref (struct value *ptr); + static void decref (struct value *ptr); }; /* A gdb:;ref_ptr pointer to a struct value. */ @@ -643,6 +636,18 @@ struct value int length) const; }; +inline void +value_ref_policy::incref (struct value *ptr) +{ + value_incref (ptr); +} + +inline void +value_ref_policy::decref (struct value *ptr) +{ + value_decref (ptr); +} + /* Returns value_type or value_enclosing_type depending on value_print_options.objectprint. From patchwork Thu Feb 9 21:38:53 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tom Tromey X-Patchwork-Id: 64609 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 907B33881D26 for ; Thu, 9 Feb 2023 23:38:20 +0000 (GMT) X-Original-To: gdb-patches@sourceware.org Delivered-To: gdb-patches@sourceware.org Received: from outbound-ss-761.bluehost.com (outbound-ss-761.bluehost.com [74.220.211.250]) by sourceware.org (Postfix) with ESMTPS id 447FB385800A for ; Thu, 9 Feb 2023 23:36:36 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 447FB385800A 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 cmgw13.mail.unifiedlayer.com (unknown [10.0.90.128]) by progateway8.mail.pro1.eigbox.com (Postfix) with ESMTP id B13C110046D29 for ; Thu, 9 Feb 2023 23:36:35 +0000 (UTC) Received: from box5379.bluehost.com ([162.241.216.53]) by cmsmtp with ESMTP id QGSxpJEykNX2aQGSxp4Dqr; Thu, 09 Feb 2023 23:36:35 +0000 X-Authority-Reason: nr=8 X-Authority-Analysis: v=2.4 cv=NMAQR22g c=1 sm=1 tr=0 ts=63e58383 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=JCnJhiDBTAdtJNuVAs8A: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=EcYqj3cpvyfZgltv5s0R7Oz26UxzA485S1sL0GzuFXE=; b=XAWAotGXPQnaTrjCzka/+yxp37 05Sk5xCx24xVjujMP4Z/Sr+ScP1S0i1//yJf4RScNhwMpBeoIZHWY7ap/MWRSIPeA03zPVvJC5SEW +RP8rtbEdzNpZxPZl2PNe95cK; 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 1pQEcu-001ZcE-1P for gdb-patches@sourceware.org; Thu, 09 Feb 2023 14:38:44 -0700 From: Tom Tromey Date: Thu, 09 Feb 2023 14:38:53 -0700 Subject: [PATCH 32/47] Turn value_incref and value_decref into methods MIME-Version: 1.0 Message-Id: <20230209-submit-value-fixups-2023-v1-32-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: 1pQEcu-001ZcE-1P 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: 8 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_incref and value_decref to be methods of value. Much of this patch was written by script. --- gdb/dwarf2/expr.c | 4 ++-- gdb/dwarf2/loc.c | 6 +++--- gdb/guile/scm-value.c | 4 ++-- gdb/opencl-lang.c | 4 ++-- gdb/python/py-value.c | 4 ++-- gdb/value.c | 23 ++++++----------------- gdb/value.h | 21 ++++++++++----------- 7 files changed, 27 insertions(+), 39 deletions(-) diff --git a/gdb/dwarf2/expr.c b/gdb/dwarf2/expr.c index ef93b89aaa9..f2a1305713a 100644 --- a/gdb/dwarf2/expr.c +++ b/gdb/dwarf2/expr.c @@ -128,7 +128,7 @@ allocate_piece_closure (dwarf2_per_cu_data *per_cu, for (dwarf_expr_piece &piece : c->pieces) if (piece.location == DWARF_VALUE_STACK) - value_incref (piece.v.value); + piece.v.value->incref (); return c; } @@ -620,7 +620,7 @@ free_pieced_value_closure (value *v) { for (dwarf_expr_piece &p : c->pieces) if (p.location == DWARF_VALUE_STACK) - value_decref (p.v.value); + p.v.value->decref (); delete c; } diff --git a/gdb/dwarf2/loc.c b/gdb/dwarf2/loc.c index 0aa6aafe823..64a7e035b06 100644 --- a/gdb/dwarf2/loc.c +++ b/gdb/dwarf2/loc.c @@ -1280,7 +1280,7 @@ entry_data_value_coerce_ref (const struct value *value) return NULL; target_val = (struct value *) value->computed_closure (); - value_incref (target_val); + target_val->incref (); return target_val; } @@ -1291,7 +1291,7 @@ entry_data_value_copy_closure (const struct value *v) { struct value *target_val = (struct value *) v->computed_closure (); - value_incref (target_val); + target_val->incref (); return target_val; } @@ -1302,7 +1302,7 @@ entry_data_value_free_closure (struct value *v) { struct value *target_val = (struct value *) v->computed_closure (); - value_decref (target_val); + target_val->decref (); } /* Vector for methods for an entry value reference where the referenced value diff --git a/gdb/guile/scm-value.c b/gdb/guile/scm-value.c index 195fd3b8912..09b1ce30024 100644 --- a/gdb/guile/scm-value.c +++ b/gdb/guile/scm-value.c @@ -131,7 +131,7 @@ vlscm_free_value_smob (SCM self) value_smob *v_smob = (value_smob *) SCM_SMOB_DATA (self); vlscm_forget_value_smob (v_smob); - value_decref (v_smob->value); + v_smob->value->decref (); return 0; } @@ -272,7 +272,7 @@ vlscm_scm_from_value_no_release (struct value *value) SCM v_scm = vlscm_make_value_smob (); value_smob *v_smob = (value_smob *) SCM_SMOB_DATA (v_scm); - value_incref (value); + value->incref (); v_smob->value = value; vlscm_remember_scheme_value (v_smob); diff --git a/gdb/opencl-lang.c b/gdb/opencl-lang.c index e4a88a23d49..81889b97e95 100644 --- a/gdb/opencl-lang.c +++ b/gdb/opencl-lang.c @@ -110,7 +110,7 @@ allocate_lval_closure (int *indices, int n, struct value *val) c->n = n; c->indices = XCNEWVEC (int, n); memcpy (c->indices, indices, n * sizeof (int)); - value_incref (val); /* Increment the reference counter of the value. */ + val->incref (); /* Increment the reference counter of the value. */ c->val = val; return c; @@ -242,7 +242,7 @@ lval_func_free_closure (struct value *v) if (c->refc == 0) { - value_decref (c->val); /* Decrement the reference counter of the value. */ + c->val->decref (); /* Decrement the reference counter of the value. */ xfree (c->indices); xfree (c); } diff --git a/gdb/python/py-value.c b/gdb/python/py-value.c index 465d8d92bd2..c2db2d58b0d 100644 --- a/gdb/python/py-value.c +++ b/gdb/python/py-value.c @@ -81,7 +81,7 @@ static void valpy_clear_value (value_object *self) { /* Indicate we are no longer interested in the value object. */ - value_decref (self->value); + self->value->decref (); self->value = nullptr; Py_CLEAR (self->address); @@ -1806,7 +1806,7 @@ value_to_value_object_no_release (struct value *val) val_obj = PyObject_New (value_object, &value_object_type); if (val_obj != NULL) { - value_incref (val); + val->incref (); val_obj->value = val; val_obj->next = nullptr; val_obj->prev = nullptr; diff --git a/gdb/value.c b/gdb/value.c index 1b304e07204..bd2a2b88b2b 100644 --- a/gdb/value.c +++ b/gdb/value.c @@ -1319,28 +1319,17 @@ value_mark (void) return all_values.back ().get (); } -/* See value.h. */ - -void -value_incref (struct value *val) -{ - val->m_reference_count++; -} - /* Release a reference to VAL, which was acquired with value_incref. This function is also called to deallocate values from the value chain. */ void -value_decref (struct value *val) +value::decref () { - if (val != nullptr) - { - gdb_assert (val->m_reference_count > 0); - val->m_reference_count--; - if (val->m_reference_count == 0) - delete val; - } + gdb_assert (m_reference_count > 0); + m_reference_count--; + if (m_reference_count == 0) + delete this; } /* Free all values allocated since MARK was obtained by value_mark @@ -2147,7 +2136,7 @@ clear_internalvar (struct internalvar *var) switch (var->kind) { case INTERNALVAR_VALUE: - value_decref (var->u.value); + var->u.value->decref (); break; case INTERNALVAR_STRING: diff --git a/gdb/value.h b/gdb/value.h index c72bee07ca6..2d1c489e245 100644 --- a/gdb/value.h +++ b/gdb/value.h @@ -111,15 +111,6 @@ struct range } }; -/* Increase VAL's reference count. */ - -extern void value_incref (struct value *val); - -/* Decrease VAL's reference count. When the reference count drops to - 0, VAL will be freed. */ - -extern void value_decref (struct value *val); - /* A policy class to interface gdb::ref_ptr with struct value. */ struct value_ref_policy @@ -454,6 +445,14 @@ struct value int bits_synthetic_pointer (LONGEST offset, LONGEST length) const; + /* Increase this value's reference count. */ + void incref () + { ++m_reference_count; } + + /* Decrease this value's reference count. When the reference count + drops to 0, it will be freed. */ + void decref (); + /* Type of value; either not an lval, or one of the various different possible kinds of lval. */ @@ -639,13 +638,13 @@ struct value inline void value_ref_policy::incref (struct value *ptr) { - value_incref (ptr); + ptr->incref (); } inline void value_ref_policy::decref (struct value *ptr) { - value_decref (ptr); + ptr->decref (); } /* Returns value_type or value_enclosing_type depending on From patchwork Thu Feb 9 21:38:54 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tom Tromey X-Patchwork-Id: 64611 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 0E8463887F70 for ; Thu, 9 Feb 2023 23:38:46 +0000 (GMT) X-Original-To: gdb-patches@sourceware.org Delivered-To: gdb-patches@sourceware.org Received: from outbound-ss-820.bluehost.com (outbound-ss-820.bluehost.com [69.89.24.241]) by sourceware.org (Postfix) with ESMTPS id 13405385828E for ; Thu, 9 Feb 2023 23:36:36 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 13405385828E 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 cmgw14.mail.unifiedlayer.com (unknown [10.0.90.129]) by progateway2.mail.pro1.eigbox.com (Postfix) with ESMTP id 8A67E10047FB6 for ; Thu, 9 Feb 2023 23:36:35 +0000 (UTC) Received: from box5379.bluehost.com ([162.241.216.53]) by cmsmtp with ESMTP id QGSxpMjBwGAj8QGSxpj9hG; Thu, 09 Feb 2023 23:36:35 +0000 X-Authority-Reason: nr=8 X-Authority-Analysis: v=2.4 cv=UdyU9IeN c=1 sm=1 tr=0 ts=63e58383 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=jyoQSPAERYBThNyhhN4A:9 a=BbPmO4dm0wJUFgDG:21 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=NV6Ev5V7BmFpyCMpF3YIH+QvZMDuzMWLaQylT9X6e5A=; b=q59Uv7PdNYNg5KGgUxagZ/2Wow NGsHuU9XLI6k4ZZklhh7elgiAi3768aAMfGIaYIOFplOuaqYaSAKNHCZZZWfICDF7ijSxO5JspHpE d/eNxQM3mHfZugOS+VOqYPDGl; 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 1pQEcu-001ZcE-5T for gdb-patches@sourceware.org; Thu, 09 Feb 2023 14:38:44 -0700 From: Tom Tromey Date: Thu, 09 Feb 2023 14:38:54 -0700 Subject: [PATCH 33/47] Turn remaining value_contents functions into methods MIME-Version: 1.0 Message-Id: <20230209-submit-value-fixups-2023-v1-33-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: 1pQEcu-001ZcE-5T 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: 7 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 turns the remaining value_contents functions -- value_contents, value_contents_all, value_contents_for_printing, and value_contents_for_printing_const -- into methods of value. It also converts the static functions require_not_optimized_out and require_available to be private methods. --- gdb/aarch64-tdep.c | 12 +++---- gdb/ada-lang.c | 28 ++++++++-------- gdb/ada-tasks.c | 2 +- gdb/ada-valprint.c | 10 +++--- gdb/alpha-tdep.c | 8 ++--- gdb/amd64-tdep.c | 4 +-- gdb/amd64-windows-tdep.c | 6 ++-- gdb/arc-tdep.c | 4 +-- gdb/arm-tdep.c | 2 +- gdb/avr-tdep.c | 2 +- gdb/bfin-tdep.c | 2 +- gdb/breakpoint.c | 2 +- gdb/c-lang.c | 2 +- gdb/c-valprint.c | 8 ++--- gdb/cli/cli-cmds.c | 2 +- gdb/cli/cli-dump.c | 4 +-- gdb/compile/compile-object-load.c | 2 +- gdb/cp-valprint.c | 4 +-- gdb/cris-tdep.c | 2 +- gdb/csky-tdep.c | 2 +- gdb/d-valprint.c | 2 +- gdb/dwarf2/expr.c | 12 +++---- gdb/eval.c | 4 +-- gdb/f-lang.c | 22 ++++++------- gdb/f-valprint.c | 2 +- gdb/findcmd.c | 2 +- gdb/frame.c | 12 +++---- gdb/frv-tdep.c | 4 +-- gdb/gdbtypes.c | 2 +- gdb/gnu-v3-abi.c | 2 +- gdb/go-valprint.c | 2 +- gdb/guile/scm-value.c | 4 +-- gdb/h8300-tdep.c | 2 +- gdb/hppa-tdep.c | 16 ++++----- gdb/i386-darwin-tdep.c | 4 +-- gdb/i386-tdep.c | 4 +-- gdb/i387-tdep.c | 2 +- gdb/ia64-tdep.c | 28 ++++++++-------- gdb/infcall.c | 2 +- gdb/infcmd.c | 2 +- gdb/iq2000-tdep.c | 2 +- gdb/lm32-tdep.c | 2 +- gdb/loongarch-tdep.c | 2 +- gdb/m2-valprint.c | 4 +-- gdb/m32c-tdep.c | 2 +- gdb/m32r-tdep.c | 4 +-- gdb/m68hc11-tdep.c | 4 +-- gdb/m68k-tdep.c | 2 +- gdb/mep-tdep.c | 4 +-- gdb/mips-tdep.c | 10 +++--- gdb/mn10300-tdep.c | 2 +- gdb/msp430-tdep.c | 2 +- gdb/nds32-tdep.c | 2 +- gdb/nios2-tdep.c | 2 +- gdb/opencl-lang.c | 8 ++--- gdb/or1k-tdep.c | 6 ++-- gdb/p-valprint.c | 4 +-- gdb/ppc-sysv-tdep.c | 4 +-- gdb/printcmd.c | 10 +++--- gdb/python/py-inferior.c | 2 +- gdb/python/py-unwind.c | 4 +-- gdb/python/py-value.c | 4 +-- gdb/riscv-tdep.c | 6 ++-- gdb/rl78-tdep.c | 2 +- gdb/rs6000-aix-tdep.c | 14 ++++---- gdb/rs6000-lynx178-tdep.c | 12 +++---- gdb/rust-lang.c | 8 ++--- gdb/rx-tdep.c | 4 +-- gdb/s390-tdep.c | 20 ++++++------ gdb/sh-tdep.c | 6 ++-- gdb/sparc-tdep.c | 4 +-- gdb/sparc64-tdep.c | 4 +-- gdb/stack.c | 4 +-- gdb/tic6x-tdep.c | 2 +- gdb/tilegx-tdep.c | 4 +-- gdb/v850-tdep.c | 2 +- gdb/valarith.c | 40 +++++++++++------------ gdb/valops.c | 46 +++++++++++++------------- gdb/valprint.c | 24 +++++++------- gdb/value.c | 68 +++++++++++++++++++-------------------- gdb/value.h | 53 +++++++++++++++--------------- gdb/vax-tdep.c | 2 +- gdb/xstormy16-tdep.c | 4 +-- gdb/xtensa-tdep.c | 4 +-- 84 files changed, 329 insertions(+), 328 deletions(-) diff --git a/gdb/aarch64-tdep.c b/gdb/aarch64-tdep.c index 1a6fdbebc76..0aaa746760e 100644 --- a/gdb/aarch64-tdep.c +++ b/gdb/aarch64-tdep.c @@ -1622,7 +1622,7 @@ pass_in_x (struct gdbarch *gdbarch, struct regcache *regcache, int len = type->length (); enum type_code typecode = type->code (); int regnum = AARCH64_X0_REGNUM + info->ngrn; - const bfd_byte *buf = value_contents (arg).data (); + const bfd_byte *buf = arg->contents ().data (); info->argnum++; @@ -1692,7 +1692,7 @@ static void pass_on_stack (struct aarch64_call_info *info, struct type *type, struct value *arg) { - const bfd_byte *buf = value_contents (arg).data (); + const bfd_byte *buf = arg->contents ().data (); int len = type->length (); int align; stack_item_t item; @@ -1769,12 +1769,12 @@ pass_in_v_vfp_candidate (struct gdbarch *gdbarch, struct regcache *regcache, case TYPE_CODE_FLT: case TYPE_CODE_DECFLOAT: return pass_in_v (gdbarch, regcache, info, arg_type->length (), - value_contents (arg).data ()); + arg->contents ().data ()); break; case TYPE_CODE_COMPLEX: { - const bfd_byte *buf = value_contents (arg).data (); + const bfd_byte *buf = arg->contents ().data (); struct type *target_type = check_typedef (arg_type->target_type ()); if (!pass_in_v (gdbarch, regcache, info, target_type->length (), @@ -1788,7 +1788,7 @@ pass_in_v_vfp_candidate (struct gdbarch *gdbarch, struct regcache *regcache, case TYPE_CODE_ARRAY: if (arg_type->is_vector ()) return pass_in_v (gdbarch, regcache, info, arg_type->length (), - value_contents (arg).data ()); + arg->contents ().data ()); /* fall through. */ case TYPE_CODE_STRUCT: @@ -1930,7 +1930,7 @@ aarch64_push_dummy_call (struct gdbarch *gdbarch, struct value *function, sp = align_down (sp - len, 16); /* Write the real data into the stack. */ - write_memory (sp, value_contents (arg).data (), len); + write_memory (sp, arg->contents ().data (), len); /* Construct the indirection. */ arg_type = lookup_pointer_type (arg_type); diff --git a/gdb/ada-lang.c b/gdb/ada-lang.c index 7f962200a1f..c11182a5a0f 100644 --- a/gdb/ada-lang.c +++ b/gdb/ada-lang.c @@ -2516,7 +2516,7 @@ decode_constrained_packed_array (struct value *arr) bounds may be variable and were not passed to that function. So, we further resolve the array bounds here and then update the sizes. */ - const gdb_byte *valaddr = value_contents_for_printing (arr).data (); + const gdb_byte *valaddr = arr->contents_for_printing ().data (); CORE_ADDR address = arr->address (); gdb::array_view view = gdb::make_array_view (valaddr, type->length ()); @@ -2773,7 +2773,7 @@ ada_value_primitive_packed_val (struct value *obj, const gdb_byte *valaddr, if (obj == NULL) src = valaddr + offset; else - src = value_contents (obj).data () + offset; + src = obj->contents ().data () + offset; if (is_dynamic_type (type)) { @@ -2823,7 +2823,7 @@ ada_value_primitive_packed_val (struct value *obj, const gdb_byte *valaddr, else { v = value::allocate (type); - src = value_contents (obj).data () + offset; + src = obj->contents ().data () + offset; } if (obj != NULL) @@ -2916,13 +2916,13 @@ ada_value_assign (struct value *toval, struct value *fromval) if (is_big_endian && is_scalar_type (fromval->type ())) from_offset = from_size - bits; copy_bitwise (buffer, toval->bitpos (), - value_contents (fromval).data (), from_offset, + fromval->contents ().data (), from_offset, bits, is_big_endian); write_memory_with_notification (to_addr, buffer, len); val = value_copy (toval); memcpy (val->contents_raw ().data (), - value_contents (fromval).data (), + fromval->contents ().data (), type->length ()); val->deprecated_set_type (type); @@ -2973,13 +2973,13 @@ value_assign_to_component (struct value *container, struct value *component, copy_bitwise ((container->contents_writeable ().data () + offset_in_container), container->bitpos () + bit_offset_in_container, - value_contents (val).data (), src_offset, bits, 1); + val->contents ().data (), src_offset, bits, 1); } else copy_bitwise ((container->contents_writeable ().data () + offset_in_container), container->bitpos () + bit_offset_in_container, - value_contents (val).data (), 0, bits, 0); + val->contents ().data (), 0, bits, 0); } /* Determine if TYPE is an access to an unconstrained array. */ @@ -4358,7 +4358,7 @@ ensure_lval (struct value *val) VALUE_LVAL (val) = lval_memory; val->set_address (addr); - write_memory (addr, value_contents (val).data (), len); + write_memory (addr, val->contents ().data (), len); } return val; @@ -4529,7 +4529,7 @@ ada_convert_actual (struct value *actual, struct type *formal_type0) actual_type = ada_check_typedef (actual->type ()); val = value::allocate (actual_type); - copy (value_contents (actual), val->contents_raw ()); + copy (actual->contents (), val->contents_raw ()); actual = ensure_lval (val); } result = value_addr (actual); @@ -6924,7 +6924,7 @@ ada_value_primitive_field (struct value *arg1, int offset, int fieldno, int bit_size = TYPE_FIELD_BITSIZE (arg_type, fieldno); return ada_value_primitive_packed_val (arg1, - value_contents (arg1).data (), + arg1->contents ().data (), offset + bit_pos / 8, bit_pos % 8, bit_size, type); } @@ -8846,7 +8846,7 @@ ada_to_fixed_value_create (struct type *type0, CORE_ADDR address, /* Our value does not live in memory; it could be a convenience variable, for instance. Create a not_lval value using val0's contents. */ - return value_from_contents (type, value_contents (val0).data ()); + return value_from_contents (type, val0->contents ().data ()); } return value_from_contents_and_address (type, 0, address); @@ -9290,7 +9290,7 @@ ada_promote_array_of_integrals (struct type *type, struct value *val) struct value *elt = value_cast (elt_type, value_subscript (val, lo + i)); int elt_len = elt_type->length (); - copy (value_contents_all (elt), res_contents.slice (elt_len * i, elt_len)); + copy (elt->contents_all (), res_contents.slice (elt_len * i, elt_len)); } return res; @@ -9436,8 +9436,8 @@ ada_value_equal (struct value *arg1, struct value *arg2) representations use all bits (no padding or undefined bits) and do not have user-defined equality. */ return (arg1_type->length () == arg2_type->length () - && memcmp (value_contents (arg1).data (), - value_contents (arg2).data (), + && memcmp (arg1->contents ().data (), + arg2->contents ().data (), arg1_type->length ()) == 0); } return value_equal (arg1, arg2); diff --git a/gdb/ada-tasks.c b/gdb/ada-tasks.c index 671ad7af603..b14d159df14 100644 --- a/gdb/ada-tasks.c +++ b/gdb/ada-tasks.c @@ -430,7 +430,7 @@ iterate_over_live_ada_tasks (ada_task_list_iterator_ftype iterator) static void value_as_string (char *dest, struct value *val, int length) { - memcpy (dest, value_contents (val).data (), length); + memcpy (dest, val->contents ().data (), length); dest[length] = '\0'; } diff --git a/gdb/ada-valprint.c b/gdb/ada-valprint.c index 491346b450d..a56c8a1de81 100644 --- a/gdb/ada-valprint.c +++ b/gdb/ada-valprint.c @@ -759,7 +759,7 @@ ada_value_print_num (struct value *val, struct ui_file *stream, int recurse, const struct value_print_options *options) { struct type *type = ada_check_typedef (val->type ()); - const gdb_byte *valaddr = value_contents_for_printing (val).data (); + const gdb_byte *valaddr = val->contents_for_printing ().data (); if (type->code () == TYPE_CODE_RANGE && (type->target_type ()->code () == TYPE_CODE_ENUM @@ -839,7 +839,7 @@ ada_val_print_enum (struct value *value, struct ui_file *stream, int recurse, } struct type *type = ada_check_typedef (value->type ()); - const gdb_byte *valaddr = value_contents_for_printing (value).data (); + const gdb_byte *valaddr = value->contents_for_printing ().data (); int offset_aligned = ada_aligned_value_addr (type, valaddr) - valaddr; len = type->num_fields (); @@ -907,7 +907,7 @@ ada_value_print_array (struct value *val, struct ui_file *stream, int recurse, if (ada_is_string_type (type) && (options->format == 0 || options->format == 's')) { - const gdb_byte *valaddr = value_contents_for_printing (val).data (); + const gdb_byte *valaddr = val->contents_for_printing ().data (); int offset_aligned = ada_aligned_value_addr (type, valaddr) - valaddr; ada_val_print_string (type, valaddr, offset_aligned, stream, recurse, @@ -922,7 +922,7 @@ ada_value_print_array (struct value *val, struct ui_file *stream, int recurse, val_print_optimized_out (val, stream); else if (TYPE_FIELD_BITSIZE (type, 0) > 0) { - const gdb_byte *valaddr = value_contents_for_printing (val).data (); + const gdb_byte *valaddr = val->contents_for_printing ().data (); int offset_aligned = ada_aligned_value_addr (type, valaddr) - valaddr; val_print_packed_array_elements (type, valaddr, offset_aligned, stream, recurse, options); @@ -1021,7 +1021,7 @@ ada_value_print_inner (struct value *val, struct ui_file *stream, int recurse, type = val->type (); struct type *saved_type = type; - const gdb_byte *valaddr = value_contents_for_printing (val).data (); + const gdb_byte *valaddr = val->contents_for_printing ().data (); CORE_ADDR address = val->address (); gdb::array_view view = gdb::make_array_view (valaddr, type->length ()); diff --git a/gdb/alpha-tdep.c b/gdb/alpha-tdep.c index 5edde7abcae..0d51ff73b3d 100644 --- a/gdb/alpha-tdep.c +++ b/gdb/alpha-tdep.c @@ -253,7 +253,7 @@ alpha_register_to_value (frame_info_ptr frame, int regnum, /* Convert to VALTYPE. */ gdb_assert (valtype->length () == 4); - alpha_sts (gdbarch, out, value_contents_all (value).data ()); + alpha_sts (gdbarch, out, value->contents_all ().data ()); release_value (value); return 1; @@ -360,7 +360,7 @@ alpha_push_dummy_call (struct gdbarch *gdbarch, struct value *function, sp = (sp & -16) - 16; /* Write the real data into the stack. */ - write_memory (sp, value_contents (arg).data (), 16); + write_memory (sp, arg->contents ().data (), 16); /* Construct the indirection. */ arg_type = lookup_pointer_type (arg_type); @@ -381,7 +381,7 @@ alpha_push_dummy_call (struct gdbarch *gdbarch, struct value *function, sp = (sp & -16) - 16; /* Write the real data into the stack. */ - write_memory (sp, value_contents (arg).data (), 32); + write_memory (sp, arg->contents ().data (), 32); /* Construct the indirection. */ arg_type = lookup_pointer_type (arg_type); @@ -395,7 +395,7 @@ alpha_push_dummy_call (struct gdbarch *gdbarch, struct value *function, m_arg->len = arg_type->length (); m_arg->offset = accumulate_size; accumulate_size = (accumulate_size + m_arg->len + 7) & ~7; - m_arg->contents = value_contents (arg).data (); + m_arg->contents = arg->contents ().data (); } /* Determine required argument register loads, loading an argument register diff --git a/gdb/amd64-tdep.c b/gdb/amd64-tdep.c index 085e5327a75..9c4a90287bc 100644 --- a/gdb/amd64-tdep.c +++ b/gdb/amd64-tdep.c @@ -995,7 +995,7 @@ if (return_method == return_method_struct) else { /* The argument will be passed in registers. */ - const gdb_byte *valbuf = value_contents (args[i]).data (); + const gdb_byte *valbuf = args[i]->contents ().data (); gdb_byte buf[8]; gdb_assert (len <= 16); @@ -1047,7 +1047,7 @@ if (return_method == return_method_struct) for (i = 0; i < num_stack_args; i++) { struct type *type = stack_args[i]->type (); - const gdb_byte *valbuf = value_contents (stack_args[i]).data (); + const gdb_byte *valbuf = stack_args[i]->contents ().data (); int len = type->length (); write_memory (sp + element * 8, valbuf, len); diff --git a/gdb/amd64-windows-tdep.c b/gdb/amd64-windows-tdep.c index 7a7fbbb9859..07df64bed60 100644 --- a/gdb/amd64-windows-tdep.c +++ b/gdb/amd64-windows-tdep.c @@ -179,7 +179,7 @@ amd64_windows_adjust_args_passed_by_pointer (struct value **args, if (amd64_windows_passed_by_pointer (args[i]->type ())) { struct type *type = args[i]->type (); - const gdb_byte *valbuf = value_contents (args[i]).data (); + const gdb_byte *valbuf = args[i]->contents ().data (); const int len = type->length (); /* Store a copy of that argument on the stack, aligned to @@ -205,7 +205,7 @@ amd64_windows_store_arg_in_reg (struct regcache *regcache, struct value *arg, int regno) { struct type *type = arg->type (); - const gdb_byte *valbuf = value_contents (arg).data (); + const gdb_byte *valbuf = arg->contents ().data (); gdb_byte buf[8]; gdb_assert (type->length () <= 8); @@ -295,7 +295,7 @@ amd64_windows_push_arguments (struct regcache *regcache, int nargs, for (i = 0; i < num_stack_args; i++) { struct type *type = stack_args[i]->type (); - const gdb_byte *valbuf = value_contents (stack_args[i]).data (); + const gdb_byte *valbuf = stack_args[i]->contents ().data (); write_memory (sp + element * 8, valbuf, type->length ()); element += ((type->length () + 7) / 8); diff --git a/gdb/arc-tdep.c b/gdb/arc-tdep.c index f42abc2ec42..bbdcb8d4ce6 100644 --- a/gdb/arc-tdep.c +++ b/gdb/arc-tdep.c @@ -779,9 +779,9 @@ arc_push_dummy_call (struct gdbarch *gdbarch, struct value *function, unsigned int len = args[i]->type ()->length (); unsigned int space = align_up (len, 4); - memcpy (data, value_contents (args[i]).data (), (size_t) len); + memcpy (data, args[i]->contents ().data (), (size_t) len); arc_debug_printf ("copying arg %d, val 0x%08x, len %d to mem", - i, *((int *) value_contents (args[i]).data ()), + i, *((int *) args[i]->contents ().data ()), len); data += space; diff --git a/gdb/arm-tdep.c b/gdb/arm-tdep.c index bf38880c247..03df41a64b3 100644 --- a/gdb/arm-tdep.c +++ b/gdb/arm-tdep.c @@ -4682,7 +4682,7 @@ arm_push_dummy_call (struct gdbarch *gdbarch, struct value *function, len = arg_type->length (); target_type = arg_type->target_type (); typecode = arg_type->code (); - val = value_contents (args[argnum]).data (); + val = args[argnum]->contents ().data (); align = type_align (arg_type); /* Round alignment up to a whole number of words. */ diff --git a/gdb/avr-tdep.c b/gdb/avr-tdep.c index 023ebc37efb..ba98fbf6f82 100644 --- a/gdb/avr-tdep.c +++ b/gdb/avr-tdep.c @@ -1299,7 +1299,7 @@ avr_push_dummy_call (struct gdbarch *gdbarch, struct value *function, int j; struct value *arg = args[i]; struct type *type = check_typedef (arg->type ()); - const bfd_byte *contents = value_contents (arg).data (); + const bfd_byte *contents = arg->contents ().data (); int len = type->length (); /* Calculate the potential last register needed. diff --git a/gdb/bfin-tdep.c b/gdb/bfin-tdep.c index e1be4b77071..4b9067a2d0f 100644 --- a/gdb/bfin-tdep.c +++ b/gdb/bfin-tdep.c @@ -530,7 +530,7 @@ bfin_push_dummy_call (struct gdbarch *gdbarch, int container_len = align_up (arg_type->length (), 4); sp -= container_len; - write_memory (sp, value_contents (args[i]).data (), container_len); + write_memory (sp, args[i]->contents ().data (), container_len); } /* Initialize R0, R1, and R2 to the first 3 words of parameters. */ diff --git a/gdb/breakpoint.c b/gdb/breakpoint.c index 07f616338a6..c3524a9c9a1 100644 --- a/gdb/breakpoint.c +++ b/gdb/breakpoint.c @@ -1861,7 +1861,7 @@ extract_bitfield_from_watchpoint_value (struct watchpoint *w, struct value *val) unpack_value_bitfield (bit_val, w->val_bitpos, w->val_bitsize, - value_contents_for_printing (val).data (), + val->contents_for_printing ().data (), val->offset (), val); diff --git a/gdb/c-lang.c b/gdb/c-lang.c index ec2e06027d2..e4027d8ee96 100644 --- a/gdb/c-lang.c +++ b/gdb/c-lang.c @@ -301,7 +301,7 @@ c_get_string (struct value *value, gdb::unique_xmalloc_ptr *buffer, && (*length < 0 || *length <= fetchlimit)) { int i; - const gdb_byte *contents = value_contents (value).data (); + const gdb_byte *contents = value->contents ().data (); /* If a length is specified, use that. */ if (*length >= 0) diff --git a/gdb/c-valprint.c b/gdb/c-valprint.c index 63f3e50d350..55ba02996f3 100644 --- a/gdb/c-valprint.c +++ b/gdb/c-valprint.c @@ -237,7 +237,7 @@ c_value_print_array (struct value *val, { struct type *type = check_typedef (val->type ()); CORE_ADDR address = val->address (); - const gdb_byte *valaddr = value_contents_for_printing (val).data (); + const gdb_byte *valaddr = val->contents_for_printing ().data (); struct type *unresolved_elttype = type->target_type (); struct type *elttype = check_typedef (unresolved_elttype); @@ -334,7 +334,7 @@ c_value_print_ptr (struct value *val, struct ui_file *stream, int recurse, } struct type *type = check_typedef (val->type ()); - const gdb_byte *valaddr = value_contents_for_printing (val).data (); + const gdb_byte *valaddr = val->contents_for_printing ().data (); if (options->vtblprint && cp_is_vtbl_ptr_type (type)) { @@ -375,7 +375,7 @@ c_value_print_struct (struct value *val, struct ui_file *stream, int recurse, TYPE_CODE_PTR.) */ int offset = type->field (VTBL_FNADDR_OFFSET).loc_bitpos () / 8; struct type *field_type = type->field (VTBL_FNADDR_OFFSET).type (); - const gdb_byte *valaddr = value_contents_for_printing (val).data (); + const gdb_byte *valaddr = val->contents_for_printing ().data (); CORE_ADDR addr = extract_typed_address (valaddr + offset, field_type); print_function_pointer_address (options, type->arch (), addr, stream); @@ -406,7 +406,7 @@ c_value_print_int (struct value *val, struct ui_file *stream, intended to be used as an integer or a character, print the character equivalent as well. */ struct type *type = val->type (); - const gdb_byte *valaddr = value_contents_for_printing (val).data (); + const gdb_byte *valaddr = val->contents_for_printing ().data (); if (c_textual_element_type (type, options->format)) { gdb_puts (" ", stream); diff --git a/gdb/cli/cli-cmds.c b/gdb/cli/cli-cmds.c index ce4bf6bc9cd..871785d8886 100644 --- a/gdb/cli/cli-cmds.c +++ b/gdb/cli/cli-cmds.c @@ -2196,7 +2196,7 @@ setting_cmd (const char *fnname, struct cmd_list_element *showlist, && type0->code () != TYPE_CODE_STRING) error (_("First argument of %s must be a string."), fnname); - const char *a0 = (const char *) value_contents (argv[0]).data (); + const char *a0 = (const char *) argv[0]->contents ().data (); cmd_list_element *cmd = lookup_cmd (&a0, showlist, "", NULL, -1, 0); if (cmd == nullptr || cmd->type != show_cmd) diff --git a/gdb/cli/cli-dump.c b/gdb/cli/cli-dump.c index 1e0051757f6..769f6a589b6 100644 --- a/gdb/cli/cli-dump.c +++ b/gdb/cli/cli-dump.c @@ -224,7 +224,7 @@ dump_value_to_file (const char *cmd, const char *mode, const char *file_format) /* Have everything. Open/write the data. */ if (file_format == NULL || strcmp (file_format, "binary") == 0) - dump_binary_file (filename.get (), mode, value_contents (val).data (), + dump_binary_file (filename.get (), mode, val->contents ().data (), val->type ()->length ()); else { @@ -241,7 +241,7 @@ dump_value_to_file (const char *cmd, const char *mode, const char *file_format) } dump_bfd_file (filename.get (), mode, file_format, vaddr, - value_contents (val).data (), + val->contents ().data (), val->type ()->length ()); } } diff --git a/gdb/compile/compile-object-load.c b/gdb/compile/compile-object-load.c index 83b97f13105..af4f6e2c2ef 100644 --- a/gdb/compile/compile-object-load.c +++ b/gdb/compile/compile-object-load.c @@ -585,7 +585,7 @@ store_regs (struct type *regs_type, CORE_ADDR regs_base) inferior_addr = regs_base + reg_offset; if (0 != target_write_memory (inferior_addr, - value_contents (regval).data (), + regval->contents ().data (), reg_size)) error (_("Cannot write register \"%s\" to inferior memory at %s."), reg_name, paddress (gdbarch, inferior_addr)); diff --git a/gdb/cp-valprint.c b/gdb/cp-valprint.c index 5f18d372aa3..687be9d4bd6 100644 --- a/gdb/cp-valprint.c +++ b/gdb/cp-valprint.c @@ -189,7 +189,7 @@ cp_print_value_fields (struct value *val, struct ui_file *stream, vptr_fieldno = get_vptr_fieldno (type, &vptr_basetype); for (i = n_baseclasses; i < len; i++) { - const gdb_byte *valaddr = value_contents_for_printing (val).data (); + const gdb_byte *valaddr = val->contents_for_printing ().data (); /* If requested, skip printing of static fields. */ if (!options->static_field_print @@ -395,7 +395,7 @@ cp_print_value (struct value *val, struct ui_file *stream, = (struct type **) obstack_next_free (&dont_print_vb_obstack); struct obstack tmp_obstack = dont_print_vb_obstack; int i, n_baseclasses = TYPE_N_BASECLASSES (type); - const gdb_byte *valaddr = value_contents_for_printing (val).data (); + const gdb_byte *valaddr = val->contents_for_printing ().data (); if (dont_print_vb == 0) { diff --git a/gdb/cris-tdep.c b/gdb/cris-tdep.c index cc8d7634c9d..af8fb95a5d2 100644 --- a/gdb/cris-tdep.c +++ b/gdb/cris-tdep.c @@ -822,7 +822,7 @@ cris_push_dummy_call (struct gdbarch *gdbarch, struct value *function, int i; len = args[argnum]->type ()->length (); - val = value_contents (args[argnum]).data (); + val = args[argnum]->contents ().data (); /* How may registers worth of storage do we need for this argument? */ reg_demand = (len / 4) + (len % 4 != 0 ? 1 : 0); diff --git a/gdb/csky-tdep.c b/gdb/csky-tdep.c index 9fa1fb37154..8fd68bab7a6 100644 --- a/gdb/csky-tdep.c +++ b/gdb/csky-tdep.c @@ -808,7 +808,7 @@ csky_push_dummy_call (struct gdbarch *gdbarch, struct value *function, arg_type = check_typedef (args[argnum]->type ()); len = arg_type->length (); - val = value_contents (args[argnum]).data (); + val = args[argnum]->contents ().data (); /* Copy the argument to argument registers or the dummy stack. Large arguments are split between registers and stack. diff --git a/gdb/d-valprint.c b/gdb/d-valprint.c index 173623ea028..b5e981874c1 100644 --- a/gdb/d-valprint.c +++ b/gdb/d-valprint.c @@ -48,7 +48,7 @@ dynamic_array_type (struct type *type, struct type *ptr_type; struct value *ival; int length; - const gdb_byte *valaddr = value_contents_for_printing (val).data (); + const gdb_byte *valaddr = val->contents_for_printing ().data (); length = unpack_field_as_long (type, valaddr + embedded_offset, 0); diff --git a/gdb/dwarf2/expr.c b/gdb/dwarf2/expr.c index f2a1305713a..a1119e16c23 100644 --- a/gdb/dwarf2/expr.c +++ b/gdb/dwarf2/expr.c @@ -156,7 +156,7 @@ rw_pieced_value (value *v, value *from, bool check_optimized) gdb_assert (!check_optimized || from == nullptr); if (from != nullptr) { - from_contents = value_contents (from).data (); + from_contents = from->contents ().data (); v_contents = nullptr; } else @@ -377,7 +377,7 @@ rw_pieced_value (value *v, value *from, bool check_optimized) bits_to_skip += p->offset; copy_bitwise (v_contents, offset, - value_contents_all (p->v.value).data (), + p->v.value->contents_all ().data (), bits_to_skip, this_size_bits, bits_big_endian); } @@ -560,7 +560,7 @@ indirect_pieced_value (value *value) encode address spaces and other things in CORE_ADDR. */ bfd_endian byte_order = gdbarch_byte_order (get_frame_arch (frame)); LONGEST byte_offset - = extract_signed_integer (value_contents (value), byte_order); + = extract_signed_integer (value->contents (), byte_order); byte_offset += piece->v.ptr.offset; return indirect_synthetic_pointer (piece->v.ptr.die_sect_off, @@ -1025,7 +1025,7 @@ dwarf_expr_context::fetch_result (struct type *type, struct type *subobj_type, if (gdbarch_byte_order (arch) == BFD_ENDIAN_BIG) subobj_offset += n - max; - copy (value_contents_all (val).slice (subobj_offset, len), + copy (val->contents_all ().slice (subobj_offset, len), retval->contents_raw ()); } break; @@ -1145,7 +1145,7 @@ dwarf_expr_context::fetch_address (int n) ULONGEST result; dwarf_require_integral (result_val->type ()); - result = extract_unsigned_integer (value_contents (result_val), byte_order); + result = extract_unsigned_integer (result_val->contents (), byte_order); /* For most architectures, calling extract_unsigned_integer() alone is sufficient for extracting an address. However, some @@ -2351,7 +2351,7 @@ dwarf_expr_context::execute_stack_op (const gdb_byte *op_ptr, else result_val = value_from_contents (type, - value_contents_all (result_val).data ()); + result_val->contents_all ().data ()); } break; diff --git a/gdb/eval.c b/gdb/eval.c index 74ce57ac70c..dca98d07fbe 100644 --- a/gdb/eval.c +++ b/gdb/eval.c @@ -2418,7 +2418,7 @@ array_operation::evaluate_struct_tuple (struct value *struct_val, modify_field (struct_type, addr, value_as_long (val), bitpos % 8, bitsize); else - memcpy (addr, value_contents (val).data (), + memcpy (addr, val->contents ().data (), val->type ()->length ()); } @@ -2475,7 +2475,7 @@ array_operation::evaluate (struct type *expect_type, error (_("Too many array elements")); memcpy (array->contents_raw ().data () + (index - low_bound) * element_size, - value_contents (element).data (), + element->contents ().data (), element_size); index++; } diff --git a/gdb/f-lang.c b/gdb/f-lang.c index 10c46fa0c29..f883b08e2ae 100644 --- a/gdb/f-lang.c +++ b/gdb/f-lang.c @@ -778,7 +778,7 @@ eval_op_f_abs (struct type *expect_type, struct expression *exp, case TYPE_CODE_FLT: { double d - = fabs (target_float_to_host_double (value_contents (arg1).data (), + = fabs (target_float_to_host_double (arg1->contents ().data (), arg1->type ())); return value_from_host_double (type, d); } @@ -808,10 +808,10 @@ eval_op_f_mod (struct type *expect_type, struct expression *exp, case TYPE_CODE_FLT: { double d1 - = target_float_to_host_double (value_contents (arg1).data (), + = target_float_to_host_double (arg1->contents ().data (), arg1->type ()); double d2 - = target_float_to_host_double (value_contents (arg2).data (), + = target_float_to_host_double (arg2->contents ().data (), arg2->type ()); double d3 = fmod (d1, d2); return value_from_host_double (type, d3); @@ -838,7 +838,7 @@ fortran_ceil_operation (value *arg1, type *result_type) { if (arg1->type ()->code () != TYPE_CODE_FLT) error (_("argument to CEILING must be of type float")); - double val = target_float_to_host_double (value_contents (arg1).data (), + double val = target_float_to_host_double (arg1->contents ().data (), arg1->type ()); val = ceil (val); return value_from_longest (result_type, val); @@ -877,7 +877,7 @@ fortran_floor_operation (value *arg1, type *result_type) { if (arg1->type ()->code () != TYPE_CODE_FLT) error (_("argument to FLOOR must be of type float")); - double val = target_float_to_host_double (value_contents (arg1).data (), + double val = target_float_to_host_double (arg1->contents ().data (), arg1->type ()); val = floor (val); return value_from_longest (result_type, val); @@ -933,10 +933,10 @@ eval_op_f_modulo (struct type *expect_type, struct expression *exp, case TYPE_CODE_FLT: { double a - = target_float_to_host_double (value_contents (arg1).data (), + = target_float_to_host_double (arg1->contents ().data (), arg1->type ()); double p - = target_float_to_host_double (value_contents (arg2).data (), + = target_float_to_host_double (arg2->contents ().data (), arg2->type ()); double result = fmod (a, p); if (result != 0 && (a < 0.0) != (p < 0.0)) @@ -1473,7 +1473,7 @@ fortran_undetermined::value_subarray (value *array, array->address () + total_offset); else array = value_from_contents_and_address - (array_slice_type, value_contents (array).data () + total_offset, + (array_slice_type, array->contents ().data () + total_offset, array->address () + total_offset); } else if (!array->lazy ()) @@ -1631,7 +1631,7 @@ fortran_structop_operation::evaluate (struct type *expect_type, struct type *elt_type = elt->type (); if (is_dynamic_type (elt_type)) { - const gdb_byte *valaddr = value_contents_for_printing (elt).data (); + const gdb_byte *valaddr = elt->contents_for_printing ().data (); CORE_ADDR address = elt->address (); gdb::array_view view = gdb::make_array_view (valaddr, elt_type->length ()); @@ -1878,9 +1878,9 @@ fortran_argument_convert (struct value *value, bool is_artificial) const int length = type->length (); const CORE_ADDR addr = value_as_long (value_allocate_space_in_inferior (length)); - write_memory (addr, value_contents (value).data (), length); + write_memory (addr, value->contents ().data (), length); struct value *val = value_from_contents_and_address - (type, value_contents (value).data (), addr); + (type, value->contents ().data (), addr); return value_addr (val); } else diff --git a/gdb/f-valprint.c b/gdb/f-valprint.c index 8d4177f3243..4d42b22d960 100644 --- a/gdb/f-valprint.c +++ b/gdb/f-valprint.c @@ -438,7 +438,7 @@ f_language::value_print_inner (struct value *val, struct ui_file *stream, struct type *elttype; CORE_ADDR addr; int index; - const gdb_byte *valaddr = value_contents_for_printing (val).data (); + const gdb_byte *valaddr = val->contents_for_printing ().data (); const CORE_ADDR address = val->address (); switch (type->code ()) diff --git a/gdb/findcmd.c b/gdb/findcmd.c index 42604b1e85e..16a5fdd525b 100644 --- a/gdb/findcmd.c +++ b/gdb/findcmd.c @@ -185,7 +185,7 @@ parse_find_args (const char *args, ULONGEST *max_countp, } else { - const gdb_byte *contents = value_contents (v).data (); + const gdb_byte *contents = v->contents ().data (); pattern_buf.insert (pattern_buf.end (), contents, contents + t->length ()); } diff --git a/gdb/frame.c b/gdb/frame.c index 0fcf3f43492..2ca2a6b30fc 100644 --- a/gdb/frame.c +++ b/gdb/frame.c @@ -1201,7 +1201,7 @@ frame_register_unwind (frame_info_ptr next_frame, int regnum, if (bufferp) { if (!*optimizedp && !*unavailablep) - memcpy (bufferp, value_contents_all (value).data (), + memcpy (bufferp, value->contents_all ().data (), value->type ()->length ()); else memset (bufferp, 0, value->type ()->length ()); @@ -1311,7 +1311,7 @@ frame_unwind_register_value (frame_info_ptr next_frame, int regnum) else { int i; - gdb::array_view buf = value_contents (value); + gdb::array_view buf = value->contents (); gdb_printf (&debug_file, " bytes="); gdb_printf (&debug_file, "["); @@ -1353,7 +1353,7 @@ frame_unwind_register_signed (frame_info_ptr next_frame, int regnum) _("Register %d is not available"), regnum); } - LONGEST r = extract_signed_integer (value_contents_all (value), byte_order); + LONGEST r = extract_signed_integer (value->contents_all (), byte_order); release_value (value); return r; @@ -1386,7 +1386,7 @@ frame_unwind_register_unsigned (frame_info_ptr next_frame, int regnum) _("Register %d is not available"), regnum); } - ULONGEST r = extract_unsigned_integer (value_contents_all (value).data (), + ULONGEST r = extract_unsigned_integer (value->contents_all ().data (), size, byte_order); release_value (value); @@ -1412,7 +1412,7 @@ read_frame_register_unsigned (frame_info_ptr frame, int regnum, enum bfd_endian byte_order = gdbarch_byte_order (gdbarch); int size = register_size (gdbarch, VALUE_REGNUM (regval)); - *val = extract_unsigned_integer (value_contents (regval).data (), size, + *val = extract_unsigned_integer (regval->contents ().data (), size, byte_order); return true; } @@ -1546,7 +1546,7 @@ get_frame_register_bytes (frame_info_ptr frame, int regnum, return false; } - memcpy (myaddr, value_contents_all (value).data () + offset, + memcpy (myaddr, value->contents_all ().data () + offset, curr_len); release_value (value); } diff --git a/gdb/frv-tdep.c b/gdb/frv-tdep.c index e9c9a9cd392..6c6050a919a 100644 --- a/gdb/frv-tdep.c +++ b/gdb/frv-tdep.c @@ -1251,7 +1251,7 @@ frv_push_dummy_call (struct gdbarch *gdbarch, struct value *function, /* The FDPIC ABI requires function descriptors to be passed instead of entry points. */ CORE_ADDR addr = extract_unsigned_integer - (value_contents (arg).data (), 4, byte_order); + (arg->contents ().data (), 4, byte_order); addr = find_func_descr (gdbarch, addr); store_unsigned_integer (valbuf, 4, byte_order, addr); typecode = TYPE_CODE_PTR; @@ -1260,7 +1260,7 @@ frv_push_dummy_call (struct gdbarch *gdbarch, struct value *function, } else { - val = value_contents (arg).data (); + val = arg->contents ().data (); } while (len > 0) diff --git a/gdb/gdbtypes.c b/gdb/gdbtypes.c index ff8de6b2b49..73ccd1cf3f8 100644 --- a/gdb/gdbtypes.c +++ b/gdb/gdbtypes.c @@ -4007,7 +4007,7 @@ is_unique_ancestor (struct type *base, struct value *val) int offset = -1; return is_unique_ancestor_worker (base, val->type (), &offset, - value_contents_for_printing (val).data (), + val->contents_for_printing ().data (), val->embedded_offset (), val->address (), val) == 1; } diff --git a/gdb/gnu-v3-abi.c b/gdb/gnu-v3-abi.c index 2fa40085f49..6d1a36623f8 100644 --- a/gdb/gnu-v3-abi.c +++ b/gdb/gnu-v3-abi.c @@ -734,7 +734,7 @@ static struct value * gnuv3_method_ptr_to_value (struct value **this_p, struct value *method_ptr) { struct gdbarch *gdbarch; - const gdb_byte *contents = value_contents (method_ptr).data (); + const gdb_byte *contents = method_ptr->contents ().data (); CORE_ADDR ptr_value; struct type *self_type, *final_type, *method_type; LONGEST adjustment; diff --git a/gdb/go-valprint.c b/gdb/go-valprint.c index 8f6c8849fd9..05788af15a6 100644 --- a/gdb/go-valprint.c +++ b/gdb/go-valprint.c @@ -52,7 +52,7 @@ print_go_string (struct type *type, unpack_value_field_as_pointer. Do this until we can get unpack_value_field_as_pointer. */ LONGEST addr; - const gdb_byte *valaddr = value_contents_for_printing (val).data (); + const gdb_byte *valaddr = val->contents_for_printing ().data (); if (! unpack_value_field_as_long (type, valaddr, embedded_offset, 0, diff --git a/gdb/guile/scm-value.c b/gdb/guile/scm-value.c index 09b1ce30024..df76f8a49d1 100644 --- a/gdb/guile/scm-value.c +++ b/gdb/guile/scm-value.c @@ -828,7 +828,7 @@ gdbscm_value_to_bytevector (SCM self) { type = check_typedef (type); length = type->length (); - contents = value_contents (value).data (); + contents = value->contents ().data (); } catch (const gdb_exception &except) { @@ -978,7 +978,7 @@ gdbscm_value_to_real (SCM self) { if (is_floating_value (value)) { - d = target_float_to_host_double (value_contents (value).data (), + d = target_float_to_host_double (value->contents ().data (), type); check = value_from_host_double (type, d); } diff --git a/gdb/h8300-tdep.c b/gdb/h8300-tdep.c index d53b6857ba5..d1494916f59 100644 --- a/gdb/h8300-tdep.c +++ b/gdb/h8300-tdep.c @@ -647,7 +647,7 @@ h8300_push_dummy_call (struct gdbarch *gdbarch, struct value *function, { struct type *type = args[argument]->type (); int len = type->length (); - char *contents = (char *) value_contents (args[argument]).data (); + char *contents = (char *) args[argument]->contents ().data (); /* Pad the argument appropriately. */ int padded_len = align_up (len, wordsize); diff --git a/gdb/hppa-tdep.c b/gdb/hppa-tdep.c index 08fea0c091b..d054e8011e8 100644 --- a/gdb/hppa-tdep.c +++ b/gdb/hppa-tdep.c @@ -745,7 +745,7 @@ hppa32_push_dummy_call (struct gdbarch *gdbarch, struct value *function, struct_ptr += align_up (type->length (), 8); if (write_pass) write_memory (struct_end - struct_ptr, - value_contents (arg).data (), type->length ()); + arg->contents ().data (), type->length ()); store_unsigned_integer (param_val, 4, byte_order, struct_end - struct_ptr); } @@ -757,13 +757,13 @@ hppa32_push_dummy_call (struct gdbarch *gdbarch, struct value *function, param_len = align_up (type->length (), 4); store_unsigned_integer (param_val, param_len, byte_order, - unpack_long (type, value_contents (arg).data ())); + unpack_long (type, arg->contents ().data ())); } else if (type->code () == TYPE_CODE_FLT) { /* Floating point value store, right aligned. */ param_len = align_up (type->length (), 4); - memcpy (param_val, value_contents (arg).data (), param_len); + memcpy (param_val, arg->contents ().data (), param_len); } else { @@ -771,7 +771,7 @@ hppa32_push_dummy_call (struct gdbarch *gdbarch, struct value *function, /* Small struct value are stored right-aligned. */ memcpy (param_val + param_len - type->length (), - value_contents (arg).data (), type->length ()); + arg->contents ().data (), type->length ()); /* Structures of size 5, 6 and 7 bytes are special in that the higher-ordered word is stored in the lower-ordered @@ -1027,7 +1027,7 @@ hppa64_push_dummy_call (struct gdbarch *gdbarch, struct value *function, the right halves of the floating point registers; the left halves are unused." */ regcache->cooked_write_part (regnum, offset % 8, len, - value_contents (arg).data ()); + arg->contents ().data ()); } } } @@ -1051,7 +1051,7 @@ hppa64_push_dummy_call (struct gdbarch *gdbarch, struct value *function, { ULONGEST codeptr, fptr; - codeptr = unpack_long (type, value_contents (arg).data ()); + codeptr = unpack_long (type, arg->contents ().data ()); fptr = hppa64_convert_code_addr_to_fptr (gdbarch, codeptr); store_unsigned_integer (fptrbuf, type->length (), byte_order, fptr); @@ -1059,7 +1059,7 @@ hppa64_push_dummy_call (struct gdbarch *gdbarch, struct value *function, } else { - valbuf = value_contents (arg).data (); + valbuf = arg->contents ().data (); } /* Always store the argument in memory. */ @@ -2722,7 +2722,7 @@ hppa_frame_prev_register_helper (frame_info_ptr this_frame, trad_frame_get_prev_register (this_frame, saved_regs, HPPA_PCOQ_HEAD_REGNUM); - pc = extract_unsigned_integer (value_contents_all (pcoq_val).data (), + pc = extract_unsigned_integer (pcoq_val->contents_all ().data (), size, byte_order); return frame_unwind_got_constant (this_frame, regnum, pc + 4); } diff --git a/gdb/i386-darwin-tdep.c b/gdb/i386-darwin-tdep.c index abf68ef7c39..34de8e72918 100644 --- a/gdb/i386-darwin-tdep.c +++ b/gdb/i386-darwin-tdep.c @@ -189,7 +189,7 @@ i386_darwin_push_dummy_call (struct gdbarch *gdbarch, struct value *function, { if (write_pass) { - const gdb_byte *val = value_contents_all (args[i]).data (); + const gdb_byte *val = args[i]->contents_all ().data (); regcache->raw_write (I387_MM0_REGNUM(tdep) + num_m128, val); } num_m128++; @@ -200,7 +200,7 @@ i386_darwin_push_dummy_call (struct gdbarch *gdbarch, struct value *function, i386_darwin_arg_type_alignment (arg_type)); if (write_pass) write_memory (sp + args_space, - value_contents_all (args[i]).data (), + args[i]->contents_all ().data (), arg_type->length ()); /* The System V ABI says that: diff --git a/gdb/i386-tdep.c b/gdb/i386-tdep.c index c6078e726ab..f12b9038f9e 100644 --- a/gdb/i386-tdep.c +++ b/gdb/i386-tdep.c @@ -2733,7 +2733,7 @@ i386_thiscall_push_dummy_call (struct gdbarch *gdbarch, struct value *function, args_space_used = align_up (args_space_used, 16); write_memory (sp + args_space_used, - value_contents_all (args[i]).data (), len); + args[i]->contents_all ().data (), len); /* The System V ABI says that: "An argument's size is increased, if necessary, to make it a @@ -2778,7 +2778,7 @@ i386_thiscall_push_dummy_call (struct gdbarch *gdbarch, struct value *function, /* The 'this' pointer needs to be in ECX. */ if (thiscall) regcache->cooked_write (I386_ECX_REGNUM, - value_contents_all (args[0]).data ()); + args[0]->contents_all ().data ()); /* If the PLT is position-independent, the SYSTEM V ABI requires %ebx to be set to the address of the GOT when doing a call to a PLT address. diff --git a/gdb/i387-tdep.c b/gdb/i387-tdep.c index 04bbf71952b..e1cbab580eb 100644 --- a/gdb/i387-tdep.c +++ b/gdb/i387-tdep.c @@ -284,7 +284,7 @@ i387_print_float_info (struct gdbarch *gdbarch, struct ui_file *file, if (value_entirely_available (regval)) { - const gdb_byte *raw = value_contents (regval).data (); + const gdb_byte *raw = regval->contents ().data (); gdb_puts ("0x", file); for (i = 9; i >= 0; i--) diff --git a/gdb/ia64-tdep.c b/gdb/ia64-tdep.c index 7f09ce4b835..f714c98d8d4 100644 --- a/gdb/ia64-tdep.c +++ b/gdb/ia64-tdep.c @@ -1934,7 +1934,7 @@ ia64_frame_prev_register (frame_info_ptr this_frame, void **this_cache, that frame by adding the size of output: (sof (size of frame) - sol (size of locals)). */ val = ia64_frame_prev_register (this_frame, this_cache, IA64_CFM_REGNUM); - prev_cfm = extract_unsigned_integer (value_contents_all (val).data (), + prev_cfm = extract_unsigned_integer (val->contents_all ().data (), 8, byte_order); bsp = rse_address_add (cache->bsp, -(cache->sof)); prev_bsp = @@ -1984,7 +1984,7 @@ ia64_frame_prev_register (frame_info_ptr this_frame, void **this_cache, /* Adjust the register number to account for register rotation. */ regnum = VP16_REGNUM + ((regnum - VP16_REGNUM) + rrb_pr) % 48; } - prN = extract_bit_field (value_contents_all (pr_val).data (), + prN = extract_bit_field (pr_val->contents_all ().data (), regnum - VP0_REGNUM, 1); return frame_unwind_got_constant (this_frame, regnum, prN); } @@ -1995,7 +1995,7 @@ ia64_frame_prev_register (frame_info_ptr this_frame, void **this_cache, ULONGEST unatN; unat_val = ia64_frame_prev_register (this_frame, this_cache, IA64_UNAT_REGNUM); - unatN = extract_bit_field (value_contents_all (unat_val).data (), + unatN = extract_bit_field (unat_val->contents_all ().data (), regnum - IA64_NAT0_REGNUM, 1); return frame_unwind_got_constant (this_frame, regnum, unatN); } @@ -2118,11 +2118,11 @@ ia64_frame_prev_register (frame_info_ptr this_frame, void **this_cache, reg_val = ia64_frame_prev_register (this_frame, this_cache, IA64_CFM_REGNUM); prev_cfm = extract_unsigned_integer - (value_contents_all (reg_val).data (), 8, byte_order); + (reg_val->contents_all ().data (), 8, byte_order); reg_val = ia64_frame_prev_register (this_frame, this_cache, IA64_BSP_REGNUM); prev_bsp = extract_unsigned_integer - (value_contents_all (reg_val).data (), 8, byte_order); + (reg_val->contents_all ().data (), 8, byte_order); prev_bof = rse_address_add (prev_bsp, -(prev_cfm & 0x7f)); addr = rse_address_add (prev_bof, (regnum - IA64_GR32_REGNUM)); @@ -2957,7 +2957,7 @@ ia64_libunwind_frame_prev_register (frame_info_ptr this_frame, /* Adjust the register number to account for register rotation. */ regnum = VP16_REGNUM + ((regnum - VP16_REGNUM) + rrb_pr) % 48; } - prN_val = extract_bit_field (value_contents_all (val).data (), + prN_val = extract_bit_field (val->contents_all ().data (), regnum - VP0_REGNUM, 1); return frame_unwind_got_constant (this_frame, regnum, prN_val); } @@ -2966,7 +2966,7 @@ ia64_libunwind_frame_prev_register (frame_info_ptr this_frame, { ULONGEST unatN_val; - unatN_val = extract_bit_field (value_contents_all (val).data (), + unatN_val = extract_bit_field (val->contents_all ().data (), regnum - IA64_NAT0_REGNUM, 1); return frame_unwind_got_constant (this_frame, regnum, unatN_val); } @@ -2981,11 +2981,11 @@ ia64_libunwind_frame_prev_register (frame_info_ptr this_frame, register will be if we pop the frame back which is why we might have been called. We know that libunwind will pass us back the beginning of the current frame so we should just add sof to it. */ - prev_bsp = extract_unsigned_integer (value_contents_all (val).data (), + prev_bsp = extract_unsigned_integer (val->contents_all ().data (), 8, byte_order); cfm_val = libunwind_frame_prev_register (this_frame, this_cache, IA64_CFM_REGNUM); - prev_cfm = extract_unsigned_integer (value_contents_all (cfm_val).data (), + prev_cfm = extract_unsigned_integer (cfm_val->contents_all ().data (), 8, byte_order); prev_bsp = rse_address_add (prev_bsp, (prev_cfm & 0x7f)); @@ -3068,7 +3068,7 @@ ia64_libunwind_sigtramp_frame_prev_register (frame_info_ptr this_frame, method of getting previous registers. */ prev_ip_val = libunwind_frame_prev_register (this_frame, this_cache, IA64_IP_REGNUM); - prev_ip = extract_unsigned_integer (value_contents_all (prev_ip_val).data (), + prev_ip = extract_unsigned_integer (prev_ip_val->contents_all ().data (), 8, byte_order); if (prev_ip == 0) @@ -3750,7 +3750,7 @@ ia64_push_dummy_call (struct gdbarch *gdbarch, struct value *function, { gdb_byte val_buf[8]; ULONGEST faddr = extract_unsigned_integer - (value_contents (arg).data (), 8, byte_order); + (arg->contents ().data (), 8, byte_order); store_unsigned_integer (val_buf, 8, byte_order, find_func_descr (regcache, faddr, &funcdescaddr)); @@ -3782,7 +3782,7 @@ ia64_push_dummy_call (struct gdbarch *gdbarch, struct value *function, This is why we use store_unsigned_integer. */ store_unsigned_integer (val_buf, 8, byte_order, - extract_unsigned_integer (value_contents (arg).data (), len, + extract_unsigned_integer (arg->contents ().data (), len, byte_order)); } else @@ -3796,7 +3796,7 @@ ia64_push_dummy_call (struct gdbarch *gdbarch, struct value *function, In this case, the data is Byte0-aligned. Happy news, this means that we don't need to differentiate the handling of 8byte blocks and less-than-8bytes blocks. */ - memcpy (val_buf, value_contents (arg).data () + argoffset, + memcpy (val_buf, arg->contents ().data () + argoffset, (len > 8) ? 8 : len); } @@ -3820,7 +3820,7 @@ ia64_push_dummy_call (struct gdbarch *gdbarch, struct value *function, while (len > 0 && floatreg < IA64_FR16_REGNUM) { gdb_byte to[IA64_FP_REGISTER_SIZE]; - target_float_convert (value_contents (arg).data () + argoffset, + target_float_convert (arg->contents ().data () + argoffset, float_elt_type, to, ia64_ext_type (gdbarch)); regcache->cooked_write (floatreg, to); diff --git a/gdb/infcall.c b/gdb/infcall.c index 05ae1638857..d6992228498 100644 --- a/gdb/infcall.c +++ b/gdb/infcall.c @@ -1130,7 +1130,7 @@ call_function_by_hand_dummy (struct value *function, if (info.trivially_copy_constructible) { int length = param_type->length (); - write_memory (addr, value_contents (args[i]).data (), length); + write_memory (addr, args[i]->contents ().data (), length); } else { diff --git a/gdb/infcmd.c b/gdb/infcmd.c index 32d30c2a3e8..50378b111c0 100644 --- a/gdb/infcmd.c +++ b/gdb/infcmd.c @@ -2181,7 +2181,7 @@ default_print_one_register_info (struct ui_file *file, || regtype->code () == TYPE_CODE_DECFLOAT) { struct value_print_options opts; - const gdb_byte *valaddr = value_contents_for_printing (val).data (); + const gdb_byte *valaddr = val->contents_for_printing ().data (); enum bfd_endian byte_order = type_byte_order (regtype); get_user_print_options (&opts); diff --git a/gdb/iq2000-tdep.c b/gdb/iq2000-tdep.c index f2af69e46cd..d4509f93b74 100644 --- a/gdb/iq2000-tdep.c +++ b/gdb/iq2000-tdep.c @@ -711,7 +711,7 @@ iq2000_push_dummy_call (struct gdbarch *gdbarch, struct value *function, { type = args[i]->type (); typelen = type->length (); - val = value_contents (args[i]).data (); + val = args[i]->contents ().data (); if (typelen <= 4) { /* Char, short, int, float, pointer, and structs <= four bytes. */ diff --git a/gdb/lm32-tdep.c b/gdb/lm32-tdep.c index 93e2ad940b5..23998f85dd8 100644 --- a/gdb/lm32-tdep.c +++ b/gdb/lm32-tdep.c @@ -260,7 +260,7 @@ lm32_push_dummy_call (struct gdbarch *gdbarch, struct value *function, /* FIXME: Handle structures. */ - contents = (gdb_byte *) value_contents (arg).data (); + contents = (gdb_byte *) arg->contents ().data (); val = extract_unsigned_integer (contents, arg_type->length (), byte_order); diff --git a/gdb/loongarch-tdep.c b/gdb/loongarch-tdep.c index f40a7b4912e..5f7a8a00ce7 100644 --- a/gdb/loongarch-tdep.c +++ b/gdb/loongarch-tdep.c @@ -565,7 +565,7 @@ loongarch_push_dummy_call (struct gdbarch *gdbarch, for (int i = 0; i < nargs; i++) { struct value *arg = args[i]; - const gdb_byte *val = value_contents (arg).data (); + const gdb_byte *val = arg->contents ().data (); struct type *type = check_typedef (arg->type ()); size_t len = type->length (); int align = type_align (type); diff --git a/gdb/m2-valprint.c b/gdb/m2-valprint.c index 73f9e37aee3..96a566fb810 100644 --- a/gdb/m2-valprint.c +++ b/gdb/m2-valprint.c @@ -165,7 +165,7 @@ m2_print_unbounded_array (struct value *value, struct value *val; struct type *type = check_typedef (value->type ()); - const gdb_byte *valaddr = value_contents_for_printing (value).data (); + const gdb_byte *valaddr = value->contents_for_printing ().data (); addr = unpack_pointer (type->field (0).type (), (type->field (0).loc_bitpos () / 8) + @@ -305,7 +305,7 @@ m2_language::value_print_inner (struct value *val, struct ui_file *stream, unsigned len; struct type *elttype; CORE_ADDR addr; - const gdb_byte *valaddr = value_contents_for_printing (val).data (); + const gdb_byte *valaddr = val->contents_for_printing ().data (); const CORE_ADDR address = val->address (); struct type *type = check_typedef (val->type ()); diff --git a/gdb/m32c-tdep.c b/gdb/m32c-tdep.c index 23add82ae90..2899c9aef90 100644 --- a/gdb/m32c-tdep.c +++ b/gdb/m32c-tdep.c @@ -2061,7 +2061,7 @@ m32c_push_dummy_call (struct gdbarch *gdbarch, struct value *function, for (i = nargs - 1; i >= 0; i--) { struct value *arg = args[i]; - const gdb_byte *arg_bits = value_contents (arg).data (); + const gdb_byte *arg_bits = arg->contents ().data (); struct type *arg_type = arg->type (); ULONGEST arg_size = arg_type->length (); diff --git a/gdb/m32r-tdep.c b/gdb/m32r-tdep.c index a1d2ad6da80..ba525998e0c 100644 --- a/gdb/m32r-tdep.c +++ b/gdb/m32r-tdep.c @@ -707,11 +707,11 @@ m32r_push_dummy_call (struct gdbarch *gdbarch, struct value *function, { /* Value gets right-justified in the register or stack word. */ memcpy (valbuf + (register_size (gdbarch, argreg) - len), - (gdb_byte *) value_contents (args[argnum]).data (), len); + (gdb_byte *) args[argnum]->contents ().data (), len); val = valbuf; } else - val = (gdb_byte *) value_contents (args[argnum]).data (); + val = (gdb_byte *) args[argnum]->contents ().data (); while (len > 0) { diff --git a/gdb/m68hc11-tdep.c b/gdb/m68hc11-tdep.c index 86af4521edd..1257c55ce66 100644 --- a/gdb/m68hc11-tdep.c +++ b/gdb/m68hc11-tdep.c @@ -1177,7 +1177,7 @@ m68hc11_push_dummy_call (struct gdbarch *gdbarch, struct value *function, { ULONGEST v; - v = extract_unsigned_integer (value_contents (args[0]).data (), + v = extract_unsigned_integer (args[0]->contents ().data (), type->length (), byte_order); first_stack_argnum = 1; @@ -1201,7 +1201,7 @@ m68hc11_push_dummy_call (struct gdbarch *gdbarch, struct value *function, sp--; write_memory (sp, &zero, 1); } - val = value_contents (args[argnum]).data (); + val = args[argnum]->contents ().data (); sp -= type->length (); write_memory (sp, val, type->length ()); } diff --git a/gdb/m68k-tdep.c b/gdb/m68k-tdep.c index e776060935c..cbd79765ab9 100644 --- a/gdb/m68k-tdep.c +++ b/gdb/m68k-tdep.c @@ -559,7 +559,7 @@ m68k_push_dummy_call (struct gdbarch *gdbarch, struct value *function, else offset = container_len - len; sp -= container_len; - write_memory (sp + offset, value_contents_all (args[i]).data (), len); + write_memory (sp + offset, args[i]->contents_all ().data (), len); } /* Store struct value address. */ diff --git a/gdb/mep-tdep.c b/gdb/mep-tdep.c index c70699d1c3d..fc786f09e44 100644 --- a/gdb/mep-tdep.c +++ b/gdb/mep-tdep.c @@ -2235,7 +2235,7 @@ push_large_arguments (CORE_ADDR sp, int argc, struct value **argv, /* Reserve space for the copy, and then round the SP down, to make sure it's all aligned properly. */ sp = (sp - arg_len) & -4; - write_memory (sp, value_contents (argv[i]).data (), arg_len); + write_memory (sp, argv[i]->contents ().data (), arg_len); copy[i] = sp; } } @@ -2289,7 +2289,7 @@ mep_push_dummy_call (struct gdbarch *gdbarch, struct value *function, /* Arguments that fit in a GPR get expanded to fill the GPR. */ if (argv[i]->type ()->length () <= MEP_GPR_SIZE) - value = extract_unsigned_integer (value_contents (argv[i]).data (), + value = extract_unsigned_integer (argv[i]->contents ().data (), argv[i]->type ()->length (), byte_order); diff --git a/gdb/mips-tdep.c b/gdb/mips-tdep.c index 349a89eb23d..19e0fdcf81e 100644 --- a/gdb/mips-tdep.c +++ b/gdb/mips-tdep.c @@ -4612,7 +4612,7 @@ mips_eabi_push_dummy_call (struct gdbarch *gdbarch, struct value *function, gdb_printf (gdb_stdlog, " push"); } else - val = value_contents (arg).data (); + val = arg->contents ().data (); /* 32-bit ABIs always start floating point arguments in an even-numbered floating point register. Round the FP register @@ -4988,7 +4988,7 @@ mips_n32n64_push_dummy_call (struct gdbarch *gdbarch, struct value *function, "mips_n32n64_push_dummy_call: %d len=%d type=%d", argnum + 1, len, (int) typecode); - val = value_contents (arg).data (); + val = arg->contents ().data (); /* A 128-bit long double value requires an even-odd pair of floating-point registers. */ @@ -5468,7 +5468,7 @@ mips_o32_push_dummy_call (struct gdbarch *gdbarch, struct value *function, "mips_o32_push_dummy_call: %d len=%d type=%d", argnum + 1, len, (int) typecode); - val = value_contents (arg).data (); + val = arg->contents ().data (); /* 32-bit ABIs always start floating point arguments in an even-numbered floating point register. Round the FP register @@ -5989,7 +5989,7 @@ mips_o64_push_dummy_call (struct gdbarch *gdbarch, struct value *function, "mips_o64_push_dummy_call: %d len=%d type=%d", argnum + 1, len, (int) typecode); - val = value_contents (arg).data (); + val = arg->contents ().data (); /* Floating point arguments passed in registers have to be treated specially. On 32-bit architectures, doubles are @@ -6595,7 +6595,7 @@ print_gp_register_row (struct ui_file *file, frame_info_ptr frame, col++; continue; } - raw_buffer = value_contents_all (value).data (); + raw_buffer = value->contents_all ().data (); /* pad small registers */ for (byte = 0; byte < (mips_abi_regsize (gdbarch) diff --git a/gdb/mn10300-tdep.c b/gdb/mn10300-tdep.c index aade7c3af07..f52b6990a60 100644 --- a/gdb/mn10300-tdep.c +++ b/gdb/mn10300-tdep.c @@ -1218,7 +1218,7 @@ mn10300_push_dummy_call (struct gdbarch *gdbarch, else { arg_len = (*args)->type ()->length (); - val = value_contents (*args).data (); + val = (*args)->contents ().data (); } while (regs_used < 2 && arg_len > 0) diff --git a/gdb/msp430-tdep.c b/gdb/msp430-tdep.c index d4a40d4cd10..2768e4e3a21 100644 --- a/gdb/msp430-tdep.c +++ b/gdb/msp430-tdep.c @@ -689,7 +689,7 @@ msp430_push_dummy_call (struct gdbarch *gdbarch, struct value *function, for (i = 0; i < nargs; i++) { struct value *arg = args[i]; - const gdb_byte *arg_bits = value_contents_all (arg).data (); + const gdb_byte *arg_bits = arg->contents_all ().data (); struct type *arg_type = check_typedef (arg->type ()); ULONGEST arg_size = arg_type->length (); int offset; diff --git a/gdb/nds32-tdep.c b/gdb/nds32-tdep.c index 858b72c2509..c65bc1a47c5 100644 --- a/gdb/nds32-tdep.c +++ b/gdb/nds32-tdep.c @@ -1470,7 +1470,7 @@ nds32_push_dummy_call (struct gdbarch *gdbarch, struct value *function, calling_use_fpr = nds32_check_calling_use_fpr (type); len = type->length (); align = type_align (type); - val = value_contents (args[i]).data (); + val = args[i]->contents ().data (); /* The size of a composite type larger than 4 bytes will be rounded up to the nearest multiple of 4. */ diff --git a/gdb/nios2-tdep.c b/gdb/nios2-tdep.c index e7ec4552827..40d65b64b18 100644 --- a/gdb/nios2-tdep.c +++ b/gdb/nios2-tdep.c @@ -1839,7 +1839,7 @@ nios2_push_dummy_call (struct gdbarch *gdbarch, struct value *function, struct type *arg_type = check_typedef (arg->type ()); int len = arg_type->length (); - val = value_contents (arg).data (); + val = arg->contents ().data (); /* Copy the argument to general registers or the stack in register-sized pieces. Large arguments are split between diff --git a/gdb/opencl-lang.c b/gdb/opencl-lang.c index 81889b97e95..b3e82f4a6ae 100644 --- a/gdb/opencl-lang.c +++ b/gdb/opencl-lang.c @@ -140,7 +140,7 @@ lval_func_read (struct value *v) for (i = offset; i < n; i++) memcpy (v->contents_raw ().data () + j++ * elsize, - value_contents (c->val).data () + c->indices[i] * elsize, + c->val->contents ().data () + c->indices[i] * elsize, elsize); } @@ -181,7 +181,7 @@ lval_func_write (struct value *v, struct value *fromval) struct value *to_elm_val = value_subscript (c->val, c->indices[i]); memcpy (from_elm_val->contents_writeable ().data (), - value_contents (fromval).data () + j++ * elsize, + fromval->contents ().data () + j++ * elsize, elsize); value_assign (to_elm_val, from_elm_val); } @@ -315,7 +315,7 @@ create_value (struct gdbarch *gdbarch, struct value *val, enum noside noside, for (i = 0; i < n; i++) memcpy (ret->contents_writeable ().data () + (i * elm_type->length ()), - value_contents (val).data () + val->contents ().data () + (indices[i] * elm_type->length ()), elm_type->length ()); } @@ -837,7 +837,7 @@ Cannot perform conditional operation on vectors with different sizes")); tmp = value_logical_not (value_subscript (arg1, i)) ? value_subscript (arg3, i) : value_subscript (arg2, i); memcpy (ret->contents_writeable ().data () + - i * eltype2->length (), value_contents_all (tmp).data (), + i * eltype2->length (), tmp->contents_all ().data (), eltype2->length ()); } diff --git a/gdb/or1k-tdep.c b/gdb/or1k-tdep.c index d485d552102..0d520661f09 100644 --- a/gdb/or1k-tdep.c +++ b/gdb/or1k-tdep.c @@ -685,7 +685,7 @@ or1k_push_dummy_call (struct gdbarch *gdbarch, struct value *function, heap_offset += align_up (len, bpw); valaddr = heap_sp + heap_offset; - write_memory (valaddr, value_contents (arg).data (), len); + write_memory (valaddr, arg->contents ().data (), len); } /* The ABI passes all structures by reference, so get its @@ -697,7 +697,7 @@ or1k_push_dummy_call (struct gdbarch *gdbarch, struct value *function, else { /* Everything else, we just get the value. */ - val = value_contents (arg).data (); + val = arg->contents ().data (); } /* Stick the value in a register. */ @@ -797,7 +797,7 @@ or1k_push_dummy_call (struct gdbarch *gdbarch, struct value *function, val = valbuf; } else - val = value_contents (arg).data (); + val = arg->contents ().data (); while (len > 0) { diff --git a/gdb/p-valprint.c b/gdb/p-valprint.c index 4b84ec1c43f..10d41523851 100644 --- a/gdb/p-valprint.c +++ b/gdb/p-valprint.c @@ -80,7 +80,7 @@ pascal_language::value_print_inner (struct value *val, struct type *char_type; CORE_ADDR addr; int want_space = 0; - const gdb_byte *valaddr = value_contents_for_printing (val).data (); + const gdb_byte *valaddr = val->contents_for_printing ().data (); switch (type->code ()) { @@ -539,7 +539,7 @@ pascal_object_print_value_fields (struct value *val, struct ui_file *stream, { struct obstack tmp_obstack = dont_print_statmem_obstack; int fields_seen = 0; - const gdb_byte *valaddr = value_contents_for_printing (val).data (); + const gdb_byte *valaddr = val->contents_for_printing ().data (); if (dont_print_statmem == 0) { diff --git a/gdb/ppc-sysv-tdep.c b/gdb/ppc-sysv-tdep.c index 69cc784c558..3d270a4f7ac 100644 --- a/gdb/ppc-sysv-tdep.c +++ b/gdb/ppc-sysv-tdep.c @@ -124,7 +124,7 @@ ppc_sysv_abi_push_dummy_call (struct gdbarch *gdbarch, struct value *function, struct value *arg = args[argno]; struct type *type = check_typedef (arg->type ()); int len = type->length (); - const bfd_byte *val = value_contents (arg).data (); + const bfd_byte *val = arg->contents ().data (); if (type->code () == TYPE_CODE_FLT && len <= 8 && !tdep->soft_float) @@ -1692,7 +1692,7 @@ ppc64_sysv_abi_push_dummy_call (struct gdbarch *gdbarch, { struct value *arg = args[argno]; struct type *type = check_typedef (arg->type ()); - const bfd_byte *val = value_contents (arg).data (); + const bfd_byte *val = arg->contents ().data (); if (type->code () == TYPE_CODE_COMPLEX) { diff --git a/gdb/printcmd.c b/gdb/printcmd.c index bd442fe2855..94e531df446 100644 --- a/gdb/printcmd.c +++ b/gdb/printcmd.c @@ -2441,7 +2441,7 @@ printf_c_string (struct ui_file *stream, const char *format, null terminated) to be printed without problems. */ gdb_byte *tem_str = (gdb_byte *) alloca (len + 1); - memcpy (tem_str, value_contents (value).data (), len); + memcpy (tem_str, value->contents ().data (), len); tem_str [len] = 0; str = tem_str; } @@ -2505,7 +2505,7 @@ printf_wide_c_string (struct ui_file *stream, const char *format, if (VALUE_LVAL (value) == lval_internalvar && c_is_string_type_p (value->type ())) { - str = value_contents (value).data (); + str = value->contents ().data (); len = value->type ()->length (); } else @@ -2615,14 +2615,14 @@ printf_floating (struct ui_file *stream, const char *format, param_type = float_type_from_length (param_type); if (param_type != value->type ()) value = value_from_contents (param_type, - value_contents (value).data ()); + value->contents ().data ()); } value = value_cast (fmt_type, value); /* Convert the value to a string and print it. */ std::string str - = target_float_to_string (value_contents (value).data (), fmt_type, format); + = target_float_to_string (value->contents ().data (), fmt_type, format); gdb_puts (str.c_str (), stream); } @@ -2783,7 +2783,7 @@ ui_printf (const char *arg, struct ui_file *stream) || valtype->code () != TYPE_CODE_INT) error (_("expected wchar_t argument for %%lc")); - bytes = value_contents (val_args[i]).data (); + bytes = val_args[i]->contents ().data (); auto_obstack output; diff --git a/gdb/python/py-inferior.c b/gdb/python/py-inferior.c index 1a3dcc23aa3..8b21f28afbe 100644 --- a/gdb/python/py-inferior.c +++ b/gdb/python/py-inferior.c @@ -714,7 +714,7 @@ infpy_thread_from_thread_handle (PyObject *self, PyObject *args, PyObject *kw) else if (gdbpy_is_value_object (handle_obj)) { struct value *val = value_object_to_value (handle_obj); - bytes = value_contents_all (val).data (); + bytes = val->contents_all ().data (); bytes_len = val->type ()->length (); } else diff --git a/gdb/python/py-unwind.c b/gdb/python/py-unwind.c index 442251201f2..97b472f25b1 100644 --- a/gdb/python/py-unwind.c +++ b/gdb/python/py-unwind.c @@ -131,7 +131,7 @@ pyuw_value_obj_to_pointer (PyObject *pyo_value, CORE_ADDR *addr) if ((value = value_object_to_value (pyo_value)) != NULL) { *addr = unpack_pointer (value->type (), - value_contents (value).data ()); + value->contents ().data ()); rc = 1; } } @@ -624,7 +624,7 @@ pyuw_sniffer (const struct frame_unwind *self, frame_info_ptr this_frame, cached_frame->reg[i].data = (gdb_byte *) xmalloc (data_size); memcpy (cached_frame->reg[i].data, - value_contents (value).data (), data_size); + value->contents ().data (), data_size); } } diff --git a/gdb/python/py-value.c b/gdb/python/py-value.c index c2db2d58b0d..26cbac3586c 100644 --- a/gdb/python/py-value.c +++ b/gdb/python/py-value.c @@ -1537,7 +1537,7 @@ valpy_nonzero (PyObject *self) nonzero = !!value_as_long (self_value->value); else if (is_floating_value (self_value->value)) nonzero = !target_float_is_zero - (value_contents (self_value->value).data (), type); + (self_value->value->contents ().data (), type); else /* All other values are True. */ nonzero = 1; @@ -1755,7 +1755,7 @@ valpy_float (PyObject *self) type = check_typedef (type); if (type->code () == TYPE_CODE_FLT && is_floating_value (value)) - d = target_float_to_host_double (value_contents (value).data (), type); + d = target_float_to_host_double (value->contents ().data (), type); else if (type->code () == TYPE_CODE_INT) { /* Note that valpy_long accepts TYPE_CODE_PTR and some diff --git a/gdb/riscv-tdep.c b/gdb/riscv-tdep.c index f8be46c9fb6..78c23ee86fc 100644 --- a/gdb/riscv-tdep.c +++ b/gdb/riscv-tdep.c @@ -1141,7 +1141,7 @@ riscv_print_one_register_info (struct gdbarch *gdbarch, && regtype->field (2).type ()->code () == TYPE_CODE_FLT)) { struct value_print_options opts; - const gdb_byte *valaddr = value_contents_for_printing (val).data (); + const gdb_byte *valaddr = val->contents_for_printing ().data (); enum bfd_endian byte_order = type_byte_order (regtype); get_user_print_options (&opts); @@ -3070,7 +3070,7 @@ riscv_push_dummy_call (struct gdbarch *gdbarch, if (info->type != arg_type) arg_value = value_cast (info->type, arg_value); - info->contents = value_contents (arg_value).data (); + info->contents = arg_value->contents ().data (); } /* Adjust the stack pointer and align it. */ @@ -3405,7 +3405,7 @@ riscv_return_value (struct gdbarch *gdbarch, is unscaled. */ gdb_mpz unscaled; - unscaled.read (value_contents (abi_val), + unscaled.read (abi_val->contents (), type_byte_order (info.type), info.type->is_unsigned ()); *read_value = value::allocate (arg_type); diff --git a/gdb/rl78-tdep.c b/gdb/rl78-tdep.c index cd846669169..1af78d9c652 100644 --- a/gdb/rl78-tdep.c +++ b/gdb/rl78-tdep.c @@ -1346,7 +1346,7 @@ rl78_push_dummy_call (struct gdbarch *gdbarch, struct value *function, sp -= container_len; write_memory (rl78_make_data_address (sp), - value_contents_all (args[i]).data (), len); + args[i]->contents_all ().data (), len); } /* Store struct value address. */ diff --git a/gdb/rs6000-aix-tdep.c b/gdb/rs6000-aix-tdep.c index 579f85f3870..15602c80b00 100644 --- a/gdb/rs6000-aix-tdep.c +++ b/gdb/rs6000-aix-tdep.c @@ -367,7 +367,7 @@ rs6000_push_dummy_call (struct gdbarch *gdbarch, struct value *function, gdb_assert (len <= 8); - target_float_convert (value_contents (arg).data (), type, reg_val, + target_float_convert (arg->contents ().data (), type, reg_val, reg_type); regcache->cooked_write (fp_regnum, reg_val); ++f_argno; @@ -382,7 +382,7 @@ rs6000_push_dummy_call (struct gdbarch *gdbarch, struct value *function, gdb_byte word[PPC_MAX_REGISTER_SIZE]; memset (word, 0, reg_size); memcpy (word, - ((char *) value_contents (arg).data ()) + argbytes, + ((char *) arg->contents ().data ()) + argbytes, (len - argbytes) > reg_size ? reg_size : len - argbytes); regcache->cooked_write (tdep->ppc_gp0_regnum + 3 + ii, word); @@ -406,9 +406,9 @@ rs6000_push_dummy_call (struct gdbarch *gdbarch, struct value *function, || type->code () == TYPE_CODE_CHAR) /* Sign or zero extend the "int" into a "word". */ store_unsigned_integer (word, reg_size, byte_order, - unpack_long (type, value_contents (arg).data ())); + unpack_long (type, arg->contents ().data ())); else - memcpy (word, value_contents (arg).data (), len); + memcpy (word, arg->contents ().data (), len); regcache->cooked_write (tdep->ppc_gp0_regnum + 3 +ii, word); } ++argno; @@ -469,7 +469,7 @@ rs6000_push_dummy_call (struct gdbarch *gdbarch, struct value *function, if (argbytes) { write_memory (sp + 24 + (ii * 4), - value_contents (arg).data () + argbytes, + arg->contents ().data () + argbytes, len - argbytes); ++argno; ii += ((len - argbytes + 3) & -4) / 4; @@ -492,11 +492,11 @@ rs6000_push_dummy_call (struct gdbarch *gdbarch, struct value *function, gdb_assert (len <= 8); regcache->cooked_write (tdep->ppc_fp0_regnum + 1 + f_argno, - value_contents (arg).data ()); + arg->contents ().data ()); ++f_argno; } - write_memory (sp + 24 + (ii * 4), value_contents (arg).data (), len); + write_memory (sp + 24 + (ii * 4), arg->contents ().data (), len); ii += ((len + 3) & -4) / 4; } } diff --git a/gdb/rs6000-lynx178-tdep.c b/gdb/rs6000-lynx178-tdep.c index 4d210737535..c5ae38f9200 100644 --- a/gdb/rs6000-lynx178-tdep.c +++ b/gdb/rs6000-lynx178-tdep.c @@ -111,7 +111,7 @@ rs6000_lynx178_push_dummy_call (struct gdbarch *gdbarch, gdb_assert (len <= 8); - target_float_convert (value_contents (arg).data (), type, reg_val, + target_float_convert (arg->contents ().data (), type, reg_val, reg_type); regcache->cooked_write (fp_regnum, reg_val); ++f_argno; @@ -126,7 +126,7 @@ rs6000_lynx178_push_dummy_call (struct gdbarch *gdbarch, gdb_byte word[PPC_MAX_REGISTER_SIZE]; memset (word, 0, reg_size); memcpy (word, - ((char *) value_contents (arg).data ()) + argbytes, + ((char *) arg->contents ().data ()) + argbytes, (len - argbytes) > reg_size ? reg_size : len - argbytes); regcache->cooked_write (tdep->ppc_gp0_regnum + 3 + ii, word); @@ -144,7 +144,7 @@ rs6000_lynx178_push_dummy_call (struct gdbarch *gdbarch, gdb_byte word[PPC_MAX_REGISTER_SIZE]; memset (word, 0, reg_size); - memcpy (word, value_contents (arg).data (), len); + memcpy (word, arg->contents ().data (), len); regcache->cooked_write (tdep->ppc_gp0_regnum + 3 +ii, word); } ++argno; @@ -206,7 +206,7 @@ rs6000_lynx178_push_dummy_call (struct gdbarch *gdbarch, if (argbytes) { write_memory (sp + 24 + (ii * 4), - value_contents (arg).data () + argbytes, + arg->contents ().data () + argbytes, len - argbytes); ++argno; ii += align_up (len - argbytes, 4) / 4; @@ -229,11 +229,11 @@ rs6000_lynx178_push_dummy_call (struct gdbarch *gdbarch, gdb_assert (len <= 8); regcache->cooked_write (tdep->ppc_fp0_regnum + 1 + f_argno, - value_contents (arg).data ()); + arg->contents ().data ()); ++f_argno; } - write_memory (sp + 24 + (ii * 4), value_contents (arg).data (), len); + write_memory (sp + 24 + (ii * 4), arg->contents ().data (), len); ii += align_up (len, 4) / 4; } } diff --git a/gdb/rust-lang.c b/gdb/rust-lang.c index cca2baa6f63..a5be110a33b 100644 --- a/gdb/rust-lang.c +++ b/gdb/rust-lang.c @@ -456,7 +456,7 @@ rust_language::print_enum (struct value *val, struct ui_file *stream, gdb_assert (rust_enum_p (type)); gdb::array_view view - (value_contents_for_printing (val).data (), + (val->contents_for_printing ().data (), val->type ()->length ()); type = resolve_dynamic_type (type, view, val->address ()); @@ -585,7 +585,7 @@ rust_language::value_print_inner encoding. */ gdb_puts ("b", stream); printstr (stream, type->target_type (), - value_contents_for_printing (val).data (), + val->contents_for_printing ().data (), high_bound - low_bound + 1, "ASCII", 0, &opts); } break; @@ -1374,7 +1374,7 @@ rust_struct_anon::evaluate (struct type *expect_type, if (rust_enum_p (type)) { - type = resolve_dynamic_type (type, value_contents (lhs), + type = resolve_dynamic_type (type, lhs->contents (), lhs->address ()); if (rust_empty_enum_p (type)) @@ -1437,7 +1437,7 @@ rust_structop::evaluate (struct type *expect_type, struct type *type = lhs->type (); if (type->code () == TYPE_CODE_STRUCT && rust_enum_p (type)) { - type = resolve_dynamic_type (type, value_contents (lhs), + type = resolve_dynamic_type (type, lhs->contents (), lhs->address ()); if (rust_empty_enum_p (type)) diff --git a/gdb/rx-tdep.c b/gdb/rx-tdep.c index 67db30ace88..7bd469d5185 100644 --- a/gdb/rx-tdep.c +++ b/gdb/rx-tdep.c @@ -520,7 +520,7 @@ rx_frame_prev_register (frame_info_ptr this_frame, void **this_cache, psw_val = rx_frame_prev_register (this_frame, this_cache, RX_PSW_REGNUM); psw = extract_unsigned_integer - (value_contents_all (psw_val).data (), 4, + (psw_val->contents_all ().data (), 4, gdbarch_byte_order (get_frame_arch (this_frame))); if ((psw & 0x20000 /* U bit */) != 0) @@ -725,7 +725,7 @@ rx_push_dummy_call (struct gdbarch *gdbarch, struct value *function, for (i = 0; i < nargs; i++) { struct value *arg = args[i]; - const gdb_byte *arg_bits = value_contents_all (arg).data (); + const gdb_byte *arg_bits = arg->contents_all ().data (); struct type *arg_type = check_typedef (arg->type ()); ULONGEST arg_size = arg_type->length (); diff --git a/gdb/s390-tdep.c b/gdb/s390-tdep.c index 822f66dfc3c..7d2cdf2a873 100644 --- a/gdb/s390-tdep.c +++ b/gdb/s390-tdep.c @@ -1764,7 +1764,7 @@ s390_handle_arg (struct s390_arg_state *as, struct value *arg, it occupies the leftmost bits. */ if (write_mode) as->regcache->cooked_write_part (S390_F0_REGNUM + as->fr, 0, length, - value_contents (arg).data ()); + arg->contents ().data ()); as->fr += 2; } else @@ -1773,7 +1773,7 @@ s390_handle_arg (struct s390_arg_state *as, struct value *arg, it occupies the rightmost bits. */ as->argp = align_up (as->argp + length, word_size); if (write_mode) - write_memory (as->argp - length, value_contents (arg).data (), + write_memory (as->argp - length, arg->contents ().data (), length); } } @@ -1788,13 +1788,13 @@ s390_handle_arg (struct s390_arg_state *as, struct value *arg, if (write_mode) as->regcache->cooked_write_part (regnum, 0, length, - value_contents (arg).data ()); + arg->contents ().data ()); as->vr++; } else { if (write_mode) - write_memory (as->argp, value_contents (arg).data (), length); + write_memory (as->argp, arg->contents ().data (), length); as->argp = align_up (as->argp + length, word_size); } } @@ -1809,9 +1809,9 @@ s390_handle_arg (struct s390_arg_state *as, struct value *arg, memory word and sign- or zero-extend to full word size. This also applies to a struct or union. */ val = type->is_unsigned () - ? extract_unsigned_integer (value_contents (arg).data (), + ? extract_unsigned_integer (arg->contents ().data (), length, byte_order) - : extract_signed_integer (value_contents (arg).data (), + : extract_signed_integer (arg->contents ().data (), length, byte_order); } @@ -1838,10 +1838,10 @@ s390_handle_arg (struct s390_arg_state *as, struct value *arg, if (write_mode) { as->regcache->cooked_write (S390_R0_REGNUM + as->gr, - value_contents (arg).data ()); + arg->contents ().data ()); as->regcache->cooked_write (S390_R0_REGNUM + as->gr + 1, - value_contents (arg).data () + word_size); + arg->contents ().data () + word_size); } as->gr += 2; } @@ -1852,7 +1852,7 @@ s390_handle_arg (struct s390_arg_state *as, struct value *arg, as->gr = 7; if (write_mode) - write_memory (as->argp, value_contents (arg).data (), length); + write_memory (as->argp, arg->contents ().data (), length); as->argp += length; } } @@ -1863,7 +1863,7 @@ s390_handle_arg (struct s390_arg_state *as, struct value *arg, alignment as a conservative assumption. */ as->copy = align_down (as->copy - length, 8); if (write_mode) - write_memory (as->copy, value_contents (arg).data (), length); + write_memory (as->copy, arg->contents ().data (), length); if (as->gr <= 6) { diff --git a/gdb/sh-tdep.c b/gdb/sh-tdep.c index c98df0223e9..60f15f1b58e 100644 --- a/gdb/sh-tdep.c +++ b/gdb/sh-tdep.c @@ -883,12 +883,12 @@ sh_justify_value_in_reg (struct gdbarch *gdbarch, struct value *val, int len) { /* value gets right-justified in the register or stack word. */ if (gdbarch_byte_order (gdbarch) == BFD_ENDIAN_BIG) - memcpy (valbuf + (4 - len), value_contents (val).data (), len); + memcpy (valbuf + (4 - len), val->contents ().data (), len); else - memcpy (valbuf, value_contents (val).data (), len); + memcpy (valbuf, val->contents ().data (), len); return valbuf; } - return value_contents (val).data (); + return val->contents ().data (); } /* Helper function to eval number of bytes to allocate on stack. */ diff --git a/gdb/sparc-tdep.c b/gdb/sparc-tdep.c index 5e582c7b77a..78f240db04e 100644 --- a/gdb/sparc-tdep.c +++ b/gdb/sparc-tdep.c @@ -633,7 +633,7 @@ sparc32_store_arguments (struct regcache *regcache, int nargs, correct, and wasting a few bytes shouldn't be a problem. */ sp &= ~0x7; - write_memory (sp, value_contents (args[i]).data (), len); + write_memory (sp, args[i]->contents ().data (), len); args[i] = value_from_pointer (lookup_pointer_type (type), sp); num_elements++; } @@ -664,7 +664,7 @@ sparc32_store_arguments (struct regcache *regcache, int nargs, for (i = 0; i < nargs; i++) { - const bfd_byte *valbuf = value_contents (args[i]).data (); + const bfd_byte *valbuf = args[i]->contents ().data (); struct type *type = args[i]->type (); int len = type->length (); gdb_byte buf[4]; diff --git a/gdb/sparc64-tdep.c b/gdb/sparc64-tdep.c index eb6a66315c0..19534fc7379 100644 --- a/gdb/sparc64-tdep.c +++ b/gdb/sparc64-tdep.c @@ -1411,7 +1411,7 @@ sparc64_store_arguments (struct regcache *regcache, int nargs, a problem. */ sp &= ~0xf; - write_memory (sp, value_contents (args[i]).data (), len); + write_memory (sp, args[i]->contents ().data (), len); args[i] = value_from_pointer (lookup_pointer_type (type), sp); num_elements++; } @@ -1480,7 +1480,7 @@ sparc64_store_arguments (struct regcache *regcache, int nargs, for (i = 0; i < nargs; i++) { - const gdb_byte *valbuf = value_contents (args[i]).data (); + const gdb_byte *valbuf = args[i]->contents ().data (); struct type *type = args[i]->type (); int len = type->length (); int regnum = -1; diff --git a/gdb/stack.c b/gdb/stack.c index cd5e391debe..576947c5dac 100644 --- a/gdb/stack.c +++ b/gdb/stack.c @@ -1717,7 +1717,7 @@ info_frame_command_core (frame_info_ptr fi, bool selected_frame_p) int sp_size = register_size (gdbarch, sp_regnum); sp = extract_unsigned_integer - (value_contents_all (value).data (), sp_size, byte_order); + (value->contents_all ().data (), sp_size, byte_order); gdb_printf (" Previous frame's sp is "); gdb_puts (paddress (gdbarch, sp)); @@ -2825,7 +2825,7 @@ return_command (const char *retval_exp, int from_tty) gdbarch_return_value_as_value (cache_arch, function, return_type, get_current_regcache (), NULL /*read*/, - value_contents (return_value).data () /*write*/); + return_value->contents ().data () /*write*/); } /* If we are at the end of a call dummy now, pop the dummy frame diff --git a/gdb/tic6x-tdep.c b/gdb/tic6x-tdep.c index 000a2a9aaa5..568e5a233db 100644 --- a/gdb/tic6x-tdep.c +++ b/gdb/tic6x-tdep.c @@ -917,7 +917,7 @@ tic6x_push_dummy_call (struct gdbarch *gdbarch, struct value *function, int len = arg_type->length (); enum type_code typecode = arg_type->code (); - val = value_contents (arg).data (); + val = arg->contents ().data (); /* Copy the argument to general registers or the stack in register-sized pieces. */ diff --git a/gdb/tilegx-tdep.c b/gdb/tilegx-tdep.c index 8f005e81dcc..1ec37d45d79 100644 --- a/gdb/tilegx-tdep.c +++ b/gdb/tilegx-tdep.c @@ -304,7 +304,7 @@ tilegx_push_dummy_call (struct gdbarch *gdbarch, break; /* Put argument into registers wordwise. */ - val = value_contents (args[i]).data (); + val = args[i]->contents ().data (); for (j = 0; j < typelen; j += tilegx_reg_size) { /* ISSUE: Why special handling for "typelen = 4x + 1"? @@ -323,7 +323,7 @@ tilegx_push_dummy_call (struct gdbarch *gdbarch, the stack, word aligned. */ for (j = nargs - 1; j >= i; j--) { - const gdb_byte *contents = value_contents (args[j]).data (); + const gdb_byte *contents = args[j]->contents ().data (); typelen = args[j]->enclosing_type ()->length (); slacklen = align_up (typelen, 8) - typelen; diff --git a/gdb/v850-tdep.c b/gdb/v850-tdep.c index 74451bbaa9b..240536805d7 100644 --- a/gdb/v850-tdep.c +++ b/gdb/v850-tdep.c @@ -1066,7 +1066,7 @@ v850_push_dummy_call (struct gdbarch *gdbarch, else { len = (*args)->type ()->length (); - val = (gdb_byte *) value_contents (*args).data (); + val = (gdb_byte *) (*args)->contents ().data (); } if (tdep->eight_byte_align diff --git a/gdb/valarith.c b/gdb/valarith.c index adc7da76b65..a453eb1f40d 100644 --- a/gdb/valarith.c +++ b/gdb/valarith.c @@ -703,8 +703,8 @@ value_concat (struct value *arg1, struct value *arg2) struct value *result = value::allocate (atype); gdb::array_view contents = result->contents_raw (); - gdb::array_view lhs_contents = value_contents (arg1); - gdb::array_view rhs_contents = value_contents (arg2); + gdb::array_view lhs_contents = arg1->contents (); + gdb::array_view rhs_contents = arg2->contents (); gdb::copy (lhs_contents, contents.slice (0, lhs_contents.size ())); gdb::copy (rhs_contents, contents.slice (lhs_contents.size ())); @@ -770,7 +770,7 @@ value_args_as_target_float (struct value *arg1, struct value *arg2, if (is_floating_type (type1)) { *eff_type_x = type1; - memcpy (x, value_contents (arg1).data (), type1->length ()); + memcpy (x, arg1->contents ().data (), type1->length ()); } else if (is_integral_type (type1)) { @@ -789,7 +789,7 @@ value_args_as_target_float (struct value *arg1, struct value *arg2, if (is_floating_type (type2)) { *eff_type_y = type2; - memcpy (y, value_contents (arg2).data (), type2->length ()); + memcpy (y, arg2->contents ().data (), type2->length ()); } else if (is_integral_type (type2)) { @@ -844,10 +844,10 @@ fixed_point_binop (struct value *arg1, struct value *arg2, enum exp_opcode op) type2 = type1; } - v1.read_fixed_point (value_contents (arg1), + v1.read_fixed_point (arg1->contents (), type_byte_order (type1), type1->is_unsigned (), type1->fixed_point_scaling_factor ()); - v2.read_fixed_point (value_contents (arg2), + v2.read_fixed_point (arg2->contents (), type_byte_order (type2), type2->is_unsigned (), type2->fixed_point_scaling_factor ()); } @@ -1572,7 +1572,7 @@ value_vector_widen (struct value *scalar_value, struct type *vector_type) for (i = 0; i < high_bound - low_bound + 1; i++) /* Duplicate the contents of elval into the destination vector. */ - copy (value_contents_all (elval), + copy (elval->contents_all (), val_contents.slice (i * elt_len, elt_len)); return val; @@ -1620,7 +1620,7 @@ vector_binop (struct value *val1, struct value *val2, enum exp_opcode op) { value *tmp = value_binop (value_subscript (val1, i), value_subscript (val2, i), op); - copy (value_contents_all (tmp), + copy (tmp->contents_all (), val_contents.slice (i * elsize, elsize)); } @@ -1677,10 +1677,10 @@ value_logical_not (struct value *arg1) type1 = check_typedef (arg1->type ()); if (is_floating_value (arg1)) - return target_float_is_zero (value_contents (arg1).data (), type1); + return target_float_is_zero (arg1->contents ().data (), type1); len = type1->length (); - p = value_contents (arg1).data (); + p = arg1->contents ().data (); while (--len >= 0) { @@ -1699,8 +1699,8 @@ value_strcmp (struct value *arg1, struct value *arg2) { int len1 = arg1->type ()->length (); int len2 = arg2->type ()->length (); - const gdb_byte *s1 = value_contents (arg1).data (); - const gdb_byte *s2 = value_contents (arg2).data (); + const gdb_byte *s1 = arg1->contents ().data (); + const gdb_byte *s2 = arg2->contents ().data (); int i, len = len1 < len2 ? len1 : len2; for (i = 0; i < len; i++) @@ -1775,8 +1775,8 @@ value_equal (struct value *arg1, struct value *arg2) && ((len = (int) type1->length ()) == (int) type2->length ())) { - p1 = value_contents (arg1).data (); - p2 = value_contents (arg2).data (); + p1 = arg1->contents ().data (); + p2 = arg2->contents ().data (); while (--len >= 0) { if (*p1++ != *p2++) @@ -1806,8 +1806,8 @@ value_equal_contents (struct value *arg1, struct value *arg2) return (type1->code () == type2->code () && type1->length () == type2->length () - && memcmp (value_contents (arg1).data (), - value_contents (arg2).data (), + && memcmp (arg1->contents ().data (), + arg2->contents ().data (), type1->length ()) == 0); } @@ -1882,7 +1882,7 @@ value_pos (struct value *arg1) if (is_integral_type (type) || is_floating_value (arg1) || (type->code () == TYPE_CODE_ARRAY && type->is_vector ()) || type->code () == TYPE_CODE_COMPLEX) - return value_from_contents (type, value_contents (arg1).data ()); + return value_from_contents (type, arg1->contents ().data ()); else error (_("Argument to positive operation not a number.")); } @@ -1915,7 +1915,7 @@ value_neg (struct value *arg1) for (i = 0; i < high_bound - low_bound + 1; i++) { value *tmp = value_neg (value_subscript (arg1, i)); - copy (value_contents_all (tmp), + copy (tmp->contents_all (), val_contents.slice (i * elt_len, elt_len)); } return val; @@ -1960,7 +1960,7 @@ value_complement (struct value *arg1) for (i = 0; i < high_bound - low_bound + 1; i++) { value *tmp = value_complement (value_subscript (arg1, i)); - copy (value_contents_all (tmp), + copy (tmp->contents_all (), val_contents.slice (i * elt_len, elt_len)); } } @@ -2022,7 +2022,7 @@ value_in (struct value *element, struct value *set) && eltype->code () != TYPE_CODE_ENUM && eltype->code () != TYPE_CODE_BOOL) error (_("First argument of 'IN' has wrong type")); - member = value_bit_index (settype, value_contents (set).data (), + member = value_bit_index (settype, set->contents ().data (), value_as_long (element)); if (member < 0) error (_("First argument of 'IN' not in range")); diff --git a/gdb/valops.c b/gdb/valops.c index d2249d79b15..efe75e12da6 100644 --- a/gdb/valops.c +++ b/gdb/valops.c @@ -342,7 +342,7 @@ value_to_gdb_mpq (struct value *value) gdb_mpq result; if (is_floating_type (type)) { - double d = target_float_to_host_double (value_contents (value).data (), + double d = target_float_to_host_double (value->contents ().data (), type); mpq_set_d (result.val, d); } @@ -352,7 +352,7 @@ value_to_gdb_mpq (struct value *value) || is_fixed_point_type (type)); gdb_mpz vz; - vz.read (value_contents (value), type_byte_order (type), + vz.read (value->contents (), type_byte_order (type), type->is_unsigned ()); mpq_set_z (result.val, vz.val); @@ -544,7 +544,7 @@ value_cast (struct type *type, struct value *arg2) if (is_floating_value (arg2)) { struct value *v = value::allocate (to_type); - target_float_convert (value_contents (arg2).data (), type2, + target_float_convert (arg2->contents ().data (), type2, v->contents_raw ().data (), type); return v; } @@ -552,7 +552,7 @@ value_cast (struct type *type, struct value *arg2) { gdb_mpq fp_val; - fp_val.read_fixed_point (value_contents (arg2), + fp_val.read_fixed_point (arg2->contents (), type_byte_order (type2), type2->is_unsigned (), type2->fixed_point_scaling_factor ()); @@ -584,7 +584,7 @@ value_cast (struct type *type, struct value *arg2) bits. */ if (code2 == TYPE_CODE_PTR) longest = extract_unsigned_integer - (value_contents (arg2), type_byte_order (type2)); + (arg2->contents (), type_byte_order (type2)); else longest = value_as_long (arg2); return value_from_longest (to_type, convert_to_boolean ? @@ -902,7 +902,7 @@ value_dynamic_cast (struct type *type, struct value *arg) return tem; result = NULL; if (dynamic_cast_check_1 (resolved_type->target_type (), - value_contents_for_printing (tem).data (), + tem->contents_for_printing ().data (), tem->embedded_offset (), tem->address (), tem, rtti_type, addr, @@ -918,7 +918,7 @@ value_dynamic_cast (struct type *type, struct value *arg) result = NULL; if (is_public_ancestor (arg_type, rtti_type) && dynamic_cast_check_2 (resolved_type->target_type (), - value_contents_for_printing (tem).data (), + tem->contents_for_printing ().data (), tem->embedded_offset (), tem->address (), tem, rtti_type, &result) == 1) @@ -961,7 +961,7 @@ value_one (struct type *type) for (i = 0; i < high_bound - low_bound + 1; i++) { value *tmp = value_one (eltype); - copy (value_contents_all (tmp), + copy (tmp->contents_all (), val_contents.slice (i * elt_len, elt_len)); } } @@ -1183,7 +1183,7 @@ value_assign (struct value *toval, struct value *fromval) { changed_addr = toval->address (); changed_len = type_length_units (type); - dest_buffer = value_contents (fromval).data (); + dest_buffer = fromval->contents ().data (); } write_memory_with_notification (changed_addr, dest_buffer, changed_len); @@ -1259,12 +1259,12 @@ value_assign (struct value *toval, struct value *fromval) format. */ gdbarch_value_to_register (gdbarch, frame, VALUE_REGNUM (toval), type, - value_contents (fromval).data ()); + fromval->contents ().data ()); } else put_frame_register_bytes (frame, value_reg, toval->offset (), - value_contents (fromval)); + fromval->contents ()); } gdb::observers::register_changed.notify (frame, value_reg); @@ -1344,7 +1344,7 @@ value_assign (struct value *toval, struct value *fromval) implies the returned value is not lazy, even if TOVAL was. */ val = value_copy (toval); val->set_lazy (0); - copy (value_contents (fromval), val->contents_raw ()); + copy (fromval->contents (), val->contents_raw ()); /* We copy over the enclosing type and pointed-to offset from FROMVAL in the case of pointer types. For object types, the enclosing type @@ -1485,7 +1485,7 @@ value_coerce_to_target (struct value *val) length = check_typedef (val->type ())->length (); addr = allocate_space_in_inferior (length); - write_memory (addr, value_contents (val).data (), length); + write_memory (addr, val->contents ().data (), length); return value_at_lazy (val->type (), addr); } @@ -2083,7 +2083,7 @@ struct_field_searcher::search (struct value *arg1, LONGEST offset, struct value *v2; boffset = baseclass_offset (type, i, - value_contents_for_printing (arg1).data (), + arg1->contents_for_printing ().data (), arg1->embedded_offset () + offset, arg1->address (), arg1); @@ -2287,13 +2287,13 @@ search_struct_method (const char *name, struct value **arg1p, base_val = value_from_contents_and_address (baseclass, tmp.data (), address + offset); - base_valaddr = value_contents_for_printing (base_val).data (); + base_valaddr = base_val->contents_for_printing ().data (); this_offset = 0; } else { base_val = *arg1p; - base_valaddr = value_contents_for_printing (*arg1p).data (); + base_valaddr = (*arg1p)->contents_for_printing ().data (); this_offset = offset; } @@ -2558,7 +2558,7 @@ find_method_list (struct value **argp, const char *method, if (BASETYPE_VIA_VIRTUAL (type, i)) { base_offset = baseclass_offset (type, i, - value_contents_for_printing (*argp).data (), + (*argp)->contents_for_printing ().data (), (*argp)->offset () + offset, (*argp)->address (), *argp); } @@ -3529,7 +3529,7 @@ get_baseclass_offset (struct type *vt, struct type *cls, { if (BASETYPE_VIA_VIRTUAL (vt, i)) { - const gdb_byte *adr = value_contents_for_printing (v).data (); + const gdb_byte *adr = v->contents_for_printing ().data (); *boffs = baseclass_offset (vt, i, adr, v->offset (), value_as_long (v), v); *isvirt = true; @@ -3543,7 +3543,7 @@ get_baseclass_offset (struct type *vt, struct type *cls, { if (*isvirt == false) /* Add non-virtual base offset. */ { - const gdb_byte *adr = value_contents_for_printing (v).data (); + const gdb_byte *adr = v->contents_for_printing ().data (); *boffs += baseclass_offset (vt, i, adr, v->offset (), value_as_long (v), v); } @@ -4110,9 +4110,9 @@ value_literal_complex (struct value *arg1, int len = real_type->length (); - copy (value_contents (arg1), + copy (arg1->contents (), val->contents_raw ().slice (0, len)); - copy (value_contents (arg2), + copy (arg2->contents (), val->contents_raw ().slice (len, len)); return val; @@ -4157,9 +4157,9 @@ cast_into_complex (struct type *type, struct value *val) struct value *im_val = value::allocate (val_real_type); int len = val_real_type->length (); - copy (value_contents (val).slice (0, len), + copy (val->contents ().slice (0, len), re_val->contents_raw ()); - copy (value_contents (val).slice (len, len), + copy (val->contents ().slice (len, len), im_val->contents_raw ()); return value_literal_complex (re_val, im_val, type); diff --git a/gdb/valprint.c b/gdb/valprint.c index d94121edd29..89d3bbf066c 100644 --- a/gdb/valprint.c +++ b/gdb/valprint.c @@ -513,7 +513,7 @@ generic_value_print_ptr (struct value *val, struct ui_file *stream, { struct type *type = check_typedef (val->type ()); struct type *elttype = check_typedef (type->target_type ()); - const gdb_byte *valaddr = value_contents_for_printing (val).data (); + const gdb_byte *valaddr = val->contents_for_printing ().data (); CORE_ADDR addr = unpack_pointer (type, valaddr); print_unpacked_pointer (type, elttype, addr, stream, options); @@ -549,7 +549,7 @@ get_value_addr_contents (struct value *deref_val) gdb_assert (deref_val != NULL); if (deref_val->lval () == lval_memory) - return value_contents_for_printing_const (value_addr (deref_val)).data (); + return value_addr (deref_val)->contents_for_printing ().data (); else { /* We have a non-addressable value, such as a DW_AT_const_value. */ @@ -573,7 +573,7 @@ generic_val_print_ref (struct type *type, const int must_coerce_ref = ((options->addressprint && value_is_synthetic) || options->deref_ref); const int type_is_defined = elttype->code () != TYPE_CODE_UNDEF; - const gdb_byte *valaddr = value_contents_for_printing (original_value).data (); + const gdb_byte *valaddr = original_value->contents_for_printing ().data (); if (must_coerce_ref && type_is_defined) { @@ -721,7 +721,7 @@ generic_val_print_enum (struct type *type, gdb_assert (!options->format); - const gdb_byte *valaddr = value_contents_for_printing (original_value).data (); + const gdb_byte *valaddr = original_value->contents_for_printing ().data (); val = unpack_long (type, valaddr + embedded_offset * unit_size); @@ -768,7 +768,7 @@ generic_value_print_bool } else { - const gdb_byte *valaddr = value_contents_for_printing (value).data (); + const gdb_byte *valaddr = value->contents_for_printing ().data (); struct type *type = check_typedef (value->type ()); LONGEST val = unpack_long (type, valaddr); if (val == 0) @@ -811,7 +811,7 @@ generic_value_print_char (struct value *value, struct ui_file *stream, { struct type *unresolved_type = value->type (); struct type *type = check_typedef (unresolved_type); - const gdb_byte *valaddr = value_contents_for_printing (value).data (); + const gdb_byte *valaddr = value->contents_for_printing ().data (); LONGEST val = unpack_long (type, valaddr); if (type->is_unsigned ()) @@ -832,7 +832,7 @@ generic_val_print_float (struct type *type, struct ui_file *stream, { gdb_assert (!options->format); - const gdb_byte *valaddr = value_contents_for_printing (original_value).data (); + const gdb_byte *valaddr = original_value->contents_for_printing ().data (); print_floating (valaddr, type, stream); } @@ -849,7 +849,7 @@ generic_val_print_fixed_point (struct value *val, struct ui_file *stream, { struct type *type = val->type (); - const gdb_byte *valaddr = value_contents_for_printing (val).data (); + const gdb_byte *valaddr = val->contents_for_printing ().data (); gdb_mpf f; f.read_fixed_point (gdb::make_array_view (valaddr, type->length ()), @@ -895,7 +895,7 @@ generic_value_print_memberptr /* Member pointers are essentially specific to C++, and so if we encounter one, we should print it according to C++ rules. */ struct type *type = check_typedef (val->type ()); - const gdb_byte *valaddr = value_contents_for_printing (val).data (); + const gdb_byte *valaddr = val->contents_for_printing ().data (); cp_print_class_member (valaddr, type, stream, "&"); } else @@ -1012,7 +1012,7 @@ generic_value_print (struct value *val, struct ui_file *stream, int recurse, break; case TYPE_CODE_METHODPTR: - cplus_print_method_ptr (value_contents_for_printing (val).data (), type, + cplus_print_method_ptr (val->contents_for_printing ().data (), type, stream); break; @@ -1226,7 +1226,7 @@ static void val_print_type_code_flags (struct type *type, struct value *original_value, int embedded_offset, struct ui_file *stream) { - const gdb_byte *valaddr = (value_contents_for_printing (original_value).data () + const gdb_byte *valaddr = (original_value->contents_for_printing ().data () + embedded_offset); ULONGEST val = unpack_long (type, valaddr); int field, nfields = type->num_fields (); @@ -1300,7 +1300,7 @@ value_print_scalar_formatted (struct value *val, /* value_contents_for_printing fetches all VAL's contents. They are needed to check whether VAL is optimized-out or unavailable below. */ - const gdb_byte *valaddr = value_contents_for_printing (val).data (); + const gdb_byte *valaddr = val->contents_for_printing ().data (); /* A scalar object that does not have all bits available can't be printed, because all bits contribute to its representation. */ diff --git a/gdb/value.c b/gdb/value.c index bd2a2b88b2b..a17a3bd8e8d 100644 --- a/gdb/value.c +++ b/gdb/value.c @@ -962,12 +962,12 @@ error_value_optimized_out (void) throw_error (OPTIMIZED_OUT_ERROR, _("value has been optimized out")); } -static void -require_not_optimized_out (const struct value *value) +void +value::require_not_optimized_out () const { - if (!value->m_optimized_out.empty ()) + if (!m_optimized_out.empty ()) { - if (value->m_lval == lval_register) + if (m_lval == lval_register) throw_error (OPTIMIZED_OUT_ERROR, _("register has not been saved in frame")); else @@ -975,38 +975,38 @@ require_not_optimized_out (const struct value *value) } } -static void -require_available (const struct value *value) +void +value::require_available () const { - if (!value->m_unavailable.empty ()) + if (!m_unavailable.empty ()) throw_error (NOT_AVAILABLE_ERROR, _("value is not available")); } gdb::array_view -value_contents_for_printing (struct value *value) +value::contents_for_printing () { - if (value->m_lazy) - value->fetch_lazy (); + if (m_lazy) + fetch_lazy (); - ULONGEST length = value->enclosing_type ()->length (); - return gdb::make_array_view (value->m_contents.get (), length); + ULONGEST length = enclosing_type ()->length (); + return gdb::make_array_view (m_contents.get (), length); } gdb::array_view -value_contents_for_printing_const (const struct value *value) +value::contents_for_printing () const { - gdb_assert (!value->m_lazy); + gdb_assert (!m_lazy); - ULONGEST length = value->enclosing_type ()->length (); - return gdb::make_array_view (value->m_contents.get (), length); + ULONGEST length = enclosing_type ()->length (); + return gdb::make_array_view (m_contents.get (), length); } gdb::array_view -value_contents_all (struct value *value) +value::contents_all () { - gdb::array_view result = value_contents_for_printing (value); - require_not_optimized_out (value); - require_available (value); + gdb::array_view result = contents_for_printing (); + require_not_optimized_out (); + require_available (); return result; } @@ -1158,11 +1158,11 @@ value_contents_copy (struct value *dst, LONGEST dst_offset, } gdb::array_view -value_contents (struct value *value) +value::contents () { - gdb::array_view result = value->contents_writeable (); - require_not_optimized_out (value); - require_available (value); + gdb::array_view result = contents_writeable (); + require_not_optimized_out (); + require_available (); return result; } @@ -1468,7 +1468,7 @@ value_non_lval (struct value *arg) struct type *enc_type = arg->enclosing_type (); struct value *val = value::allocate (enc_type); - copy (value_contents_all (arg), val->contents_all_raw ()); + copy (arg->contents_all (), val->contents_all_raw ()); val->m_type = arg->m_type; val->set_embedded_offset (arg->embedded_offset ()); val->set_pointed_to_offset (arg->pointed_to_offset ()); @@ -2025,7 +2025,7 @@ set_internalvar_component (struct internalvar *var, modify_field (var->u.value->type (), addr + offset, value_as_long (newval), bitpos, bitsize); else - memcpy (addr + offset * unit_size, value_contents (newval).data (), + memcpy (addr + offset * unit_size, newval->contents ().data (), newval->type ()->length ()); break; @@ -2429,7 +2429,7 @@ value_as_long (struct value *val) in disassemble_command). It also dereferences references, which I suspect is the most logical thing to do. */ val = coerce_array (val); - return unpack_long (val->type (), value_contents (val).data ()); + return unpack_long (val->type (), val->contents ().data ()); } /* Extract a value as a C pointer. Does not deallocate the value. @@ -2532,9 +2532,9 @@ value_as_address (struct value *val) if (!val->type ()->is_pointer_or_reference () && gdbarch_integer_to_address_p (gdbarch)) return gdbarch_integer_to_address (gdbarch, val->type (), - value_contents (val).data ()); + val->contents ().data ()); - return unpack_long (val->type (), value_contents (val).data ()); + return unpack_long (val->type (), val->contents ().data ()); #endif } @@ -2658,7 +2658,7 @@ is_floating_value (struct value *val) if (is_floating_type (type)) { - if (!target_float_is_valid (value_contents (val).data (), type)) + if (!target_float_is_valid (val->contents ().data (), type)) error (_("Invalid floating value found in program.")); return true; } @@ -2799,7 +2799,7 @@ value_primitive_field (struct value *arg1, LONGEST offset, for references to ordinary fields of unavailable values. */ if (BASETYPE_VIA_VIRTUAL (arg_type, fieldno)) boffset = baseclass_offset (arg_type, fieldno, - value_contents (arg1).data (), + arg1->contents ().data (), arg1->embedded_offset (), arg1->address (), arg1); @@ -3547,7 +3547,7 @@ coerce_ref (struct value *arg) enc_type = check_typedef (arg->enclosing_type ()); enc_type = enc_type->target_type (); - CORE_ADDR addr = unpack_pointer (arg->type (), value_contents (arg).data ()); + CORE_ADDR addr = unpack_pointer (arg->type (), arg->contents ().data ()); retval = value_at_lazy (enc_type, addr); enc_type = retval->type (); return readjust_indirect_value_type (retval, enc_type, value_type_arg_tmp, @@ -3628,7 +3628,7 @@ value_fetch_lazy_bitfield (struct value *val) parent->fetch_lazy (); unpack_value_bitfield (val, val->bitpos (), val->bitsize (), - value_contents_for_printing (parent).data (), + parent->contents_for_printing ().data (), val->offset (), parent); } @@ -3739,7 +3739,7 @@ value_fetch_lazy_register (struct value *val) else { int i; - gdb::array_view buf = value_contents (new_val); + gdb::array_view buf = new_val->contents (); if (VALUE_LVAL (new_val) == lval_register) gdb_printf (&debug_file, " register=%d", diff --git a/gdb/value.h b/gdb/value.h index 2d1c489e245..7b034bba1e2 100644 --- a/gdb/value.h +++ b/gdb/value.h @@ -282,7 +282,7 @@ struct value When we store the entire object, `enclosing_type' is the run-time type -- the complete object -- and `embedded_offset' is the offset - of `type' within that larger type, in bytes. The value_contents() + of `type' within that larger type, in bytes. The ->contents() macro takes `embedded_offset' into account, so most GDB code continues to see the `type' portion of the value, just as the inferior would. @@ -368,9 +368,31 @@ struct value get to the real subobject, if the value happens to represent something embedded in a larger run-time object. */ gdb::array_view contents_raw (); + + /* Actual contents of the value. For use of this value; setting it + uses the stuff above. Not valid if lazy is nonzero. Target + byte-order. We force it to be aligned properly for any possible + value. Note that a value therefore extends beyond what is + declared here. */ + gdb::array_view contents (); + + /* The ALL variants of the above two methods do not adjust the + returned pointer by the embedded_offset value. */ + gdb::array_view contents_all (); gdb::array_view contents_all_raw (); + gdb::array_view contents_writeable (); + /* Like contents_all, but does not require that the returned bits be + valid. This should only be used in situations where you plan to + check the validity manually. */ + gdb::array_view contents_for_printing (); + + /* Like contents_for_printing, but accepts a constant value pointer. + Unlike contents_for_printing however, the pointed value must + _not_ be lazy. */ + gdb::array_view contents_for_printing () const; + /* Load the actual content of a lazy value. Fetch the data from the user's process and clear the lazy flag to indicate that the data in the buffer is valid. @@ -576,7 +598,7 @@ struct value When we store the entire object, `enclosing_type' is the run-time type -- the complete object -- and `embedded_offset' is the offset of `type' within that larger type, in target addressable memory - units. The value_contents() macro takes `embedded_offset' into account, + units. The ->contents() macro takes `embedded_offset' into account, so most GDB code continues to see the `type' portion of the value, just as the inferior would. @@ -633,6 +655,9 @@ struct value Return true if the available bits match. */ bool contents_bits_eq (int offset1, const struct value *val2, int offset2, int length) const; + + void require_not_optimized_out () const; + void require_available () const; }; inline void @@ -729,30 +754,6 @@ struct lval_funcs extern void error_value_optimized_out (void); -/* Actual contents of the value. For use of this value; setting it - uses the stuff above. Not valid if lazy is nonzero. Target - byte-order. We force it to be aligned properly for any possible - value. Note that a value therefore extends beyond what is - declared here. */ - -extern gdb::array_view value_contents (struct value *); - -/* The ALL variants of the above two macros do not adjust the returned - pointer by the embedded_offset value. */ - -extern gdb::array_view value_contents_all (struct value *); - -/* Like value_contents_all, but does not require that the returned - bits be valid. This should only be used in situations where you - plan to check the validity manually. */ -extern gdb::array_view value_contents_for_printing (struct value *value); - -/* Like value_contents_for_printing, but accepts a constant value - pointer. Unlike value_contents_for_printing however, the pointed - value must _not_ be lazy. */ -extern gdb::array_view - value_contents_for_printing_const (const struct value *value); - /* If nonzero, this is the value of a variable which does not actually exist in the program, at least partially. If the value is lazy, this may fetch it now. */ diff --git a/gdb/vax-tdep.c b/gdb/vax-tdep.c index c46010d0b13..0f92a469d6c 100644 --- a/gdb/vax-tdep.c +++ b/gdb/vax-tdep.c @@ -121,7 +121,7 @@ vax_store_arguments (struct regcache *regcache, int nargs, sp -= (len + 3) & ~3; count += (len + 3) / 4; - write_memory (sp, value_contents_all (args[i]).data (), len); + write_memory (sp, args[i]->contents_all ().data (), len); } /* Push argument count. */ diff --git a/gdb/xstormy16-tdep.c b/gdb/xstormy16-tdep.c index c12d83213ae..c505281622a 100644 --- a/gdb/xstormy16-tdep.c +++ b/gdb/xstormy16-tdep.c @@ -252,7 +252,7 @@ xstormy16_push_dummy_call (struct gdbarch *gdbarch, break; /* Put argument into registers wordwise. */ - const gdb_byte *val = value_contents (args[i]).data (); + const gdb_byte *val = args[i]->contents ().data (); for (j = 0; j < typelen; j += xstormy16_reg_size) { ULONGEST regval; @@ -270,7 +270,7 @@ xstormy16_push_dummy_call (struct gdbarch *gdbarch, wordaligned. */ for (j = nargs - 1; j >= i; j--) { - const gdb_byte *bytes = value_contents (args[j]).data (); + const gdb_byte *bytes = args[j]->contents ().data (); typelen = args[j]->enclosing_type ()->length (); slacklen = typelen & 1; diff --git a/gdb/xtensa-tdep.c b/gdb/xtensa-tdep.c index c3d175adff6..092ae088932 100644 --- a/gdb/xtensa-tdep.c +++ b/gdb/xtensa-tdep.c @@ -1729,7 +1729,7 @@ xtensa_push_dummy_call (struct gdbarch *gdbarch, break; } gdb_printf (gdb_stdlog, " %s\n", - host_address_to_string (value_contents (arg).data ())); + host_address_to_string (arg->contents ().data ())); } } @@ -1785,7 +1785,7 @@ xtensa_push_dummy_call (struct gdbarch *gdbarch, break; } info->length = arg_type->length (); - info->contents = value_contents (arg).data (); + info->contents = arg->contents ().data (); /* Align size and onstack_size. */ size = (size + info->align - 1) & ~(info->align - 1); From patchwork Thu Feb 9 21:38:55 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tom Tromey X-Patchwork-Id: 64597 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 A599E3857B93 for ; Thu, 9 Feb 2023 23:36:57 +0000 (GMT) X-Original-To: gdb-patches@sourceware.org Delivered-To: gdb-patches@sourceware.org Received: from outbound-ss-820.bluehost.com (outbound-ss-820.bluehost.com [69.89.24.241]) by sourceware.org (Postfix) with ESMTPS id 59BDA3858C50 for ; Thu, 9 Feb 2023 23:36:33 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 59BDA3858C50 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 cmgw15.mail.unifiedlayer.com (unknown [10.0.90.130]) by progateway2.mail.pro1.eigbox.com (Postfix) with ESMTP id CC82210047FB1 for ; Thu, 9 Feb 2023 23:36:32 +0000 (UTC) Received: from box5379.bluehost.com ([162.241.216.53]) by cmsmtp with ESMTP id QGSupaODObdcfQGSup8gNj; Thu, 09 Feb 2023 23:36:32 +0000 X-Authority-Reason: nr=8 X-Authority-Analysis: v=2.4 cv=AZB0o1bG c=1 sm=1 tr=0 ts=63e58380 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=ADIHfbCV9bHn2TrqPpQA: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=WySdvQj0FVTqm/wAlHAk2UyIgUz0qYKgstgutpES2qg=; b=SAg/gC6hOGNd+lXSTxQPB88K6h VUuEmncbshGWF1eVOfs8OUx7B8e4ZYmfjwO+gxWuYv0TvD+ZCetNAKT4l/xr2felOjKqWXNzmSu5w zlvToJJtbMxl2vGmiP9jun8QV; 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 1pQEcu-001ZcE-AU for gdb-patches@sourceware.org; Thu, 09 Feb 2023 14:38:44 -0700 From: Tom Tromey Date: Thu, 09 Feb 2023 14:38:55 -0700 Subject: [PATCH 34/47] Fully qualify calls to copy in value.c MIME-Version: 1.0 Message-Id: <20230209-submit-value-fixups-2023-v1-34-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: 1pQEcu-001ZcE-AU 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: 1 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" A coming patch will add value::copy, so this namespace-qualifies existing calls to 'copy' in value.c, to ensure it will still compile after that change is done. --- gdb/value.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/gdb/value.c b/gdb/value.c index a17a3bd8e8d..81199ab4b9a 100644 --- a/gdb/value.c +++ b/gdb/value.c @@ -1088,7 +1088,7 @@ value_contents_copy_raw (struct value *dst, LONGEST dst_offset, gdb::array_view src_contents = src->contents_all_raw ().slice (src_offset * unit_size, length * unit_size); - copy (src_contents, dst_contents); + gdb::copy (src_contents, dst_contents); /* Copy the meta-data, adjusted. */ src_bit_offset = src_offset * unit_size * HOST_CHAR_BIT; @@ -1425,7 +1425,7 @@ value_copy (const value *arg) ULONGEST length = arg->enclosing_type ()->length (); const auto &arg_view = gdb::make_array_view (arg->m_contents.get (), length); - copy (arg_view, val->contents_all_raw ()); + gdb::copy (arg_view, val->contents_all_raw ()); } val->m_parent = arg->m_parent; @@ -1468,7 +1468,7 @@ value_non_lval (struct value *arg) struct type *enc_type = arg->enclosing_type (); struct value *val = value::allocate (enc_type); - copy (arg->contents_all (), val->contents_all_raw ()); + gdb::copy (arg->contents_all (), val->contents_all_raw ()); val->m_type = arg->m_type; val->set_embedded_offset (arg->embedded_offset ()); val->set_pointed_to_offset (arg->pointed_to_offset ()); From patchwork Thu Feb 9 21:38:56 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tom Tromey X-Patchwork-Id: 64598 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 3BE103846414 for ; Thu, 9 Feb 2023 23:36:59 +0000 (GMT) X-Original-To: gdb-patches@sourceware.org Delivered-To: gdb-patches@sourceware.org Received: from progateway7-pub.mail.pro1.eigbox.com (gproxy5-pub.mail.unifiedlayer.com [67.222.38.55]) by sourceware.org (Postfix) with ESMTPS id 987063858C5F for ; Thu, 9 Feb 2023 23:36:33 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 987063858C5F 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 cmgw11.mail.unifiedlayer.com (unknown [10.0.90.126]) by progateway7.mail.pro1.eigbox.com (Postfix) with ESMTP id 05A4B10048163 for ; Thu, 9 Feb 2023 23:36:33 +0000 (UTC) Received: from box5379.bluehost.com ([162.241.216.53]) by cmsmtp with ESMTP id QGSupjIhb2s14QGSupj1Yc; Thu, 09 Feb 2023 23:36:32 +0000 X-Authority-Reason: nr=8 X-Authority-Analysis: v=2.4 cv=R7DGpfdX c=1 sm=1 tr=0 ts=63e58381 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=44RPbHKIDy2rvR-I3r0A: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=iAVbZXferV4tF+/LLJpgurpEgkHpxRhwXuXoS9UHSRo=; b=hv0RJyYKZnSLfhiJdVHsoEIVe8 XrsDgMRh/4N9rAFpcVFIitjXJLWbbPOcrAkdb9SypExiUI4fO7E/K+in0XxpSvxuJAIlNp/syQJp0 yyOhezQRokk8XyBQUG8nKJhog; 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 1pQEcu-001ZcE-Er for gdb-patches@sourceware.org; Thu, 09 Feb 2023 14:38:44 -0700 From: Tom Tromey Date: Thu, 09 Feb 2023 14:38:56 -0700 Subject: [PATCH 35/47] Turn value_copy into a method MIME-Version: 1.0 Message-Id: <20230209-submit-value-fixups-2023-v1-35-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: 1pQEcu-001ZcE-Er 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: 2 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 turns value_copy into a method of value. Much of this was written by script. --- gdb/ada-lang.c | 8 +++---- gdb/ada-valprint.c | 2 +- gdb/breakpoint.c | 2 +- gdb/dwarf2/loc.c | 2 +- gdb/guile/scm-math.c | 2 +- gdb/python/py-prettyprint.c | 2 +- gdb/python/py-value.c | 4 ++-- gdb/valops.c | 14 +++++------ gdb/value.c | 58 ++++++++++++++++++++++----------------------- gdb/value.h | 7 ++++-- 10 files changed, 51 insertions(+), 50 deletions(-) diff --git a/gdb/ada-lang.c b/gdb/ada-lang.c index c11182a5a0f..e2aa4041263 100644 --- a/gdb/ada-lang.c +++ b/gdb/ada-lang.c @@ -1762,7 +1762,7 @@ thin_data_pntr (struct value *val) data_type = lookup_pointer_type (data_type); if (type->code () == TYPE_CODE_PTR) - return value_cast (data_type, value_copy (val)); + return value_cast (data_type, val->copy ()); else return value_from_longest (data_type, val->address ()); } @@ -2190,7 +2190,7 @@ ada_coerce_to_simple_array_ptr (struct value *arr) if (arrType == NULL) return NULL; - return value_cast (arrType, value_copy (desc_data (arr))); + return value_cast (arrType, desc_data (arr)->copy ()); } else if (ada_is_constrained_packed_array_type (arr->type ())) return decode_constrained_packed_array (arr); @@ -2920,7 +2920,7 @@ ada_value_assign (struct value *toval, struct value *fromval) bits, is_big_endian); write_memory_with_notification (to_addr, buffer, len); - val = value_copy (toval); + val = toval->copy (); memcpy (val->contents_raw ().data (), fromval->contents ().data (), type->length ()); @@ -3073,7 +3073,7 @@ ada_value_ptr_subscript (struct value *arr, int arity, struct value **ind) if (type->code () != TYPE_CODE_ARRAY) error (_("too many subscripts (%d expected)"), k); arr = value_cast (lookup_pointer_type (type->target_type ()), - value_copy (arr)); + arr->copy ()); get_discrete_bounds (type->index_type (), &lwb, &upb); arr = value_ptradd (arr, pos_atr (ind[k]) - lwb); type = type->target_type (); diff --git a/gdb/ada-valprint.c b/gdb/ada-valprint.c index a56c8a1de81..16e865c5de6 100644 --- a/gdb/ada-valprint.c +++ b/gdb/ada-valprint.c @@ -1028,7 +1028,7 @@ ada_value_print_inner (struct value *val, struct ui_file *stream, int recurse, type = ada_check_typedef (resolve_dynamic_type (type, view, address)); if (type != saved_type) { - val = value_copy (val); + val = val->copy (); val->deprecated_set_type (type); } diff --git a/gdb/breakpoint.c b/gdb/breakpoint.c index c3524a9c9a1..1ffdb4bf33d 100644 --- a/gdb/breakpoint.c +++ b/gdb/breakpoint.c @@ -4408,7 +4408,7 @@ bpstat::bpstat (const bpstat &other) print_it (other.print_it) { if (other.old_val != NULL) - old_val = release_value (value_copy (other.old_val.get ())); + old_val = release_value (other.old_val.get ()->copy ()); } /* Return a copy of a bpstat. Like "bs1 = bs2" but all storage that diff --git a/gdb/dwarf2/loc.c b/gdb/dwarf2/loc.c index 64a7e035b06..f9706a0bc05 100644 --- a/gdb/dwarf2/loc.c +++ b/gdb/dwarf2/loc.c @@ -1538,7 +1538,7 @@ dwarf2_evaluate_loc_desc_full (struct type *type, frame_info_ptr frame, value_ref_ptr value_holder = value_ref_ptr::new_reference (retval); free_values.free_to_mark (); - return value_copy (retval); + return retval->copy (); } /* The exported interface to dwarf2_evaluate_loc_desc_full; it always diff --git a/gdb/guile/scm-math.c b/gdb/guile/scm-math.c index dcbdef5f4b0..5036871c5f1 100644 --- a/gdb/guile/scm-math.c +++ b/gdb/guile/scm-math.c @@ -744,7 +744,7 @@ vlscm_convert_typed_value_from_scheme (const char *func_name, value = NULL; } else - value = value_copy (vlscm_scm_to_value (obj)); + value = vlscm_scm_to_value (obj)->copy (); } else if (gdbscm_is_true (scm_bytevector_p (obj))) { diff --git a/gdb/python/py-prettyprint.c b/gdb/python/py-prettyprint.c index 18d2b7f5ba4..dd72e230157 100644 --- a/gdb/python/py-prettyprint.c +++ b/gdb/python/py-prettyprint.c @@ -663,7 +663,7 @@ gdbpy_get_varobj_pretty_printer (struct value *value) { try { - value = value_copy (value); + value = value->copy (); } catch (const gdb_exception &except) { diff --git a/gdb/python/py-value.c b/gdb/python/py-value.c index 26cbac3586c..f339845c272 100644 --- a/gdb/python/py-value.c +++ b/gdb/python/py-value.c @@ -1900,13 +1900,13 @@ convert_value_from_python (PyObject *obj) builtin_type_pychar); } else if (PyObject_TypeCheck (obj, &value_object_type)) - value = value_copy (((value_object *) obj)->value); + value = ((value_object *) obj)->value->copy (); else if (gdbpy_is_lazy_string (obj)) { PyObject *result; result = PyObject_CallMethodObjArgs (obj, gdbpy_value_cst, NULL); - value = value_copy (((value_object *) result)->value); + value = ((value_object *) result)->value->copy (); } else PyErr_Format (PyExc_TypeError, diff --git a/gdb/valops.c b/gdb/valops.c index efe75e12da6..93e58d1d168 100644 --- a/gdb/valops.c +++ b/gdb/valops.c @@ -325,7 +325,7 @@ value_cast_pointers (struct type *type, struct value *arg2, } /* No superclass found, just change the pointer type. */ - arg2 = value_copy (arg2); + arg2 = arg2->copy (); arg2->deprecated_set_type (type); arg2->set_enclosing_type (type); arg2->set_pointed_to_offset (0); /* pai: chk_val */ @@ -428,7 +428,7 @@ value_cast (struct type *type, struct value *arg2) value completely. */ if (arg2->type () != type) { - arg2 = value_copy (arg2); + arg2 = arg2->copy (); arg2->deprecated_set_type (type); } return arg2; @@ -647,7 +647,7 @@ value_cast (struct type *type, struct value *arg2) if (code1 == TYPE_CODE_PTR && code2 == TYPE_CODE_PTR) return value_cast_pointers (to_type, arg2, 0); - arg2 = value_copy (arg2); + arg2 = arg2->copy (); arg2->deprecated_set_type (to_type); arg2->set_enclosing_type (to_type); arg2->set_pointed_to_offset (0); /* pai: chk_val */ @@ -1342,7 +1342,7 @@ value_assign (struct value *toval, struct value *fromval) /* The return value is a copy of TOVAL so it shares its location information, but its contents are updated from FROMVAL. This implies the returned value is not lazy, even if TOVAL was. */ - val = value_copy (toval); + val = toval->copy (); val->set_lazy (0); copy (fromval->contents (), val->contents_raw ()); @@ -1572,7 +1572,7 @@ value_addr (struct value *arg1) struct type *enclosing_type_ptr = lookup_pointer_type (enclosing_type->target_type ()); - arg2 = value_copy (arg1); + arg2 = arg1->copy (); arg2->deprecated_set_type (type_ptr); arg2->set_enclosing_type (enclosing_type_ptr); @@ -2107,7 +2107,7 @@ struct_field_searcher::search (struct value *arg1, LONGEST offset, } else { - v2 = value_copy (arg1); + v2 = arg1->copy (); v2->deprecated_set_type (basetype); v2->set_embedded_offset (boffset); } @@ -3958,7 +3958,7 @@ value_full_object (struct value *argp, /* pai: FIXME -- sounds iffy */ if (full) { - argp = value_copy (argp); + argp = argp->copy (); argp->set_enclosing_type (real_type); return argp; } diff --git a/gdb/value.c b/gdb/value.c index 81199ab4b9a..98078ed44d2 100644 --- a/gdb/value.c +++ b/gdb/value.c @@ -1389,46 +1389,44 @@ value_release_to_mark (const struct value *mark) return result; } -/* Return a copy of the value ARG. - It contains the same contents, for same memory address, - but it's a different block of storage. */ +/* See value.h. */ struct value * -value_copy (const value *arg) +value::copy () const { - struct type *encl_type = arg->enclosing_type (); + struct type *encl_type = enclosing_type (); struct value *val; - if (arg->lazy ()) + if (lazy ()) val = value::allocate_lazy (encl_type); else val = value::allocate (encl_type); - val->m_type = arg->m_type; - VALUE_LVAL (val) = arg->m_lval; - val->m_location = arg->m_location; - val->m_offset = arg->m_offset; - val->m_bitpos = arg->m_bitpos; - val->m_bitsize = arg->m_bitsize; - val->m_lazy = arg->m_lazy; - val->m_embedded_offset = arg->embedded_offset (); - val->m_pointed_to_offset = arg->m_pointed_to_offset; - val->m_modifiable = arg->m_modifiable; - val->m_stack = arg->m_stack; - val->m_is_zero = arg->m_is_zero; - val->m_initialized = arg->m_initialized; - val->m_unavailable = arg->m_unavailable; - val->m_optimized_out = arg->m_optimized_out; + val->m_type = m_type; + VALUE_LVAL (val) = m_lval; + val->m_location = m_location; + val->m_offset = m_offset; + val->m_bitpos = m_bitpos; + val->m_bitsize = m_bitsize; + val->m_lazy = m_lazy; + val->m_embedded_offset = embedded_offset (); + val->m_pointed_to_offset = m_pointed_to_offset; + val->m_modifiable = m_modifiable; + val->m_stack = m_stack; + val->m_is_zero = m_is_zero; + val->m_initialized = m_initialized; + val->m_unavailable = m_unavailable; + val->m_optimized_out = m_optimized_out; if (!val->lazy () && !value_entirely_optimized_out (val)) { - gdb_assert (arg->m_contents != nullptr); - ULONGEST length = arg->enclosing_type ()->length (); + gdb_assert (m_contents != nullptr); + ULONGEST length = enclosing_type ()->length (); const auto &arg_view - = gdb::make_array_view (arg->m_contents.get (), length); + = gdb::make_array_view (m_contents.get (), length); gdb::copy (arg_view, val->contents_all_raw ()); } - val->m_parent = arg->m_parent; + val->m_parent = m_parent; if (VALUE_LVAL (val) == lval_computed) { const struct lval_funcs *funcs = val->m_location.computed.funcs; @@ -1450,7 +1448,7 @@ make_cv_value (int cnst, int voltl, struct value *v) { struct type *val_type = v->type (); struct type *m_enclosing_type = v->enclosing_type (); - struct value *cv_val = value_copy (v); + struct value *cv_val = v->copy (); cv_val->deprecated_set_type (make_cv_type (cnst, voltl, val_type, NULL)); cv_val->set_enclosing_type (make_cv_type (cnst, voltl, m_enclosing_type, NULL)); @@ -1600,7 +1598,7 @@ access_value_history (int num) absnum--; - return value_copy (value_history[absnum].get ()); + return value_history[absnum].get ()->copy (); } /* See value.h. */ @@ -1926,7 +1924,7 @@ value_of_internalvar (struct gdbarch *gdbarch, struct internalvar *var) break; case INTERNALVAR_VALUE: - val = value_copy (var->u.value); + val = var->u.value->copy (); if (val->lazy ()) val->fetch_lazy (); break; @@ -2061,7 +2059,7 @@ set_internalvar (struct internalvar *var, struct value *val) default: new_kind = INTERNALVAR_VALUE; - struct value *copy = value_copy (val); + struct value *copy = val->copy (); copy->m_modifiable = 1; /* Force the value to be fetched from the target now, to avoid problems @@ -3998,7 +3996,7 @@ test_value_copy () /* Verify that we can copy an entirely optimized out value, that may not have its contents allocated. */ value_ref_ptr val = release_value (value::allocate_optimized_out (type)); - value_ref_ptr copy = release_value (value_copy (val.get ())); + value_ref_ptr copy = release_value (val.get ()->copy ()); SELF_CHECK (value_entirely_optimized_out (val.get ())); SELF_CHECK (value_entirely_optimized_out (copy.get ())); diff --git a/gdb/value.h b/gdb/value.h index 7b034bba1e2..fdecfa99405 100644 --- a/gdb/value.h +++ b/gdb/value.h @@ -164,6 +164,11 @@ struct value /* Create a value of type TYPE that is zero, and return it. */ static struct value *zero (struct type *type, enum lval_type lv); + /* Return a copy of the value. + It contains the same contents, for same memory address, + but it's a different block of storage. */ + struct value *copy () const; + ~value (); DISABLE_COPY_AND_ASSIGN (value); @@ -1413,8 +1418,6 @@ extern void preserve_values (struct objfile *); /* From values.c */ -extern struct value *value_copy (const value *); - extern struct value *value_non_lval (struct value *); extern void value_force_lval (struct value *, CORE_ADDR); From patchwork Thu Feb 9 21:38:57 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tom Tromey X-Patchwork-Id: 64602 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 3BD3738493FD for ; Thu, 9 Feb 2023 23:37:32 +0000 (GMT) X-Original-To: gdb-patches@sourceware.org Delivered-To: gdb-patches@sourceware.org Received: from gproxy3-pub.mail.unifiedlayer.com (gproxy3-pub.mail.unifiedlayer.com [69.89.30.42]) by sourceware.org (Postfix) with ESMTPS id BDA443858C74 for ; Thu, 9 Feb 2023 23:36:33 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org BDA443858C74 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 progateway5.mail.pro1.eigbox.com (Postfix) with ESMTP id 34AA410048779 for ; Thu, 9 Feb 2023 23:36:33 +0000 (UTC) Received: from box5379.bluehost.com ([162.241.216.53]) by cmsmtp with ESMTP id QGSvp0VoNP796QGSvpy8Ez; Thu, 09 Feb 2023 23:36:33 +0000 X-Authority-Reason: nr=8 X-Authority-Analysis: v=2.4 cv=MJClJOVl c=1 sm=1 tr=0 ts=63e58381 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=eODo5UU9N5Sx8X_Y1oQA: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=3Ed3lXh6Lq0pUKwzu/Jw++N4Dyln+NXVJ5Zw7ej3on8=; b=pCvFCExbjnQXWzHfdKZMIMZqP8 j6xDXvkiaqQ/94twWzg5yd6b6uyOzVF1w3XerVJIsXRKRYUdxk8nmgaN6GwJCykANNTUix8fRo2l0 CDbCb9faBEIPOXdyAHSqjvL/J; 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 1pQEcu-001ZcE-Is for gdb-patches@sourceware.org; Thu, 09 Feb 2023 14:38:44 -0700 From: Tom Tromey Date: Thu, 09 Feb 2023 14:38:57 -0700 Subject: [PATCH 36/47] Turn many optimized-out value functions into methods MIME-Version: 1.0 Message-Id: <20230209-submit-value-fixups-2023-v1-36-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: 1pQEcu-001ZcE-Is 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: 3 X-Source-Cap: ZWx5bnJvYmk7ZWx5bnJvYmk7Ym94NTM3OS5ibHVlaG9zdC5jb20= X-Local-Domain: yes X-Spam-Status: No, score=-3026.9 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, GIT_PATCH_0, JMQ_SPF_NEUTRAL, KAM_STOCKGEN, 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 turns many functions that are related to optimized-out or availability-checking to be methods of value. The static function value_entirely_covered_by_range_vector is also converted to be a private method. --- gdb/aarch64-tdep.c | 6 +- gdb/ada-lang.c | 2 +- gdb/ada-valprint.c | 2 +- gdb/alpha-tdep.c | 4 +- gdb/amd64-tdep.c | 12 ++-- gdb/c-valprint.c | 8 +-- gdb/compile/compile-object-load.c | 4 +- gdb/cp-valprint.c | 2 +- gdb/d-valprint.c | 5 +- gdb/dwarf2/expr.c | 18 +++--- gdb/dwarf2/loc.c | 8 +-- gdb/findvar.c | 6 +- gdb/frame.c | 22 +++---- gdb/gnu-v2-abi.c | 4 +- gdb/guile/scm-pretty-print.c | 2 +- gdb/guile/scm-value.c | 2 +- gdb/i386-tdep.c | 34 +++++----- gdb/i387-tdep.c | 2 +- gdb/infcmd.c | 4 +- gdb/infrun.c | 2 +- gdb/mi/mi-cmd-stack.c | 7 +-- gdb/mi/mi-main.c | 2 +- gdb/mips-tdep.c | 4 +- gdb/p-valprint.c | 2 +- gdb/printcmd.c | 4 +- gdb/python/py-prettyprint.c | 2 +- gdb/python/py-value.c | 2 +- gdb/regcache.c | 6 +- gdb/riscv-tdep.c | 4 +- gdb/s390-tdep.c | 6 +- gdb/stack.c | 10 +-- gdb/valops.c | 6 +- gdb/valprint.c | 17 +++-- gdb/value.c | 126 +++++++++++++++----------------------- gdb/value.h | 124 ++++++++++++++++++------------------- 35 files changed, 219 insertions(+), 252 deletions(-) diff --git a/gdb/aarch64-tdep.c b/gdb/aarch64-tdep.c index 0aaa746760e..a4f71f246c6 100644 --- a/gdb/aarch64-tdep.c +++ b/gdb/aarch64-tdep.c @@ -2766,8 +2766,8 @@ aarch64_pseudo_read_value_1 (struct gdbarch *gdbarch, gdb_static_assert (AARCH64_V0_REGNUM == AARCH64_SVE_Z0_REGNUM); if (regcache->raw_read (v_regnum, reg_buf) != REG_VALID) - mark_value_bytes_unavailable (result_value, 0, - result_value->type ()->length ()); + result_value->mark_bytes_unavailable (0, + result_value->type ()->length ()); else memcpy (result_value->contents_raw ().data (), reg_buf, regsize); @@ -2801,7 +2801,7 @@ aarch64_pseudo_read_value (struct gdbarch *gdbarch, readable_regcache *regcache, /* Read the bottom 4 bytes of X. */ if (regcache->raw_read_part (x_regnum, offset, 4, data) != REG_VALID) - mark_value_bytes_unavailable (result_value, 0, 4); + result_value->mark_bytes_unavailable (0, 4); else memcpy (result_value->contents_raw ().data (), data, 4); diff --git a/gdb/ada-lang.c b/gdb/ada-lang.c index e2aa4041263..1b0dc2291d0 100644 --- a/gdb/ada-lang.c +++ b/gdb/ada-lang.c @@ -555,7 +555,7 @@ coerce_unspec_val_to_type (struct value *val, struct type *type) { struct value *result; - if (value_optimized_out (val)) + if (val->optimized_out ()) result = value::allocate_optimized_out (type); else if (val->lazy () /* Be careful not to make a lazy not_lval value. */ diff --git a/gdb/ada-valprint.c b/gdb/ada-valprint.c index 16e865c5de6..02ae46bce9e 100644 --- a/gdb/ada-valprint.c +++ b/gdb/ada-valprint.c @@ -918,7 +918,7 @@ ada_value_print_array (struct value *val, struct ui_file *stream, int recurse, gdb_printf (stream, "("); print_optional_low_bound (stream, type, options); - if (value_entirely_optimized_out (val)) + if (val->entirely_optimized_out ()) val_print_optimized_out (val, stream); else if (TYPE_FIELD_BITSIZE (type, 0) > 0) { diff --git a/gdb/alpha-tdep.c b/gdb/alpha-tdep.c index 0d51ff73b3d..9fb973597fc 100644 --- a/gdb/alpha-tdep.c +++ b/gdb/alpha-tdep.c @@ -241,8 +241,8 @@ alpha_register_to_value (frame_info_ptr frame, int regnum, struct value *value = get_frame_register_value (frame, regnum); gdb_assert (value != NULL); - *optimizedp = value_optimized_out (value); - *unavailablep = !value_entirely_available (value); + *optimizedp = value->optimized_out (); + *unavailablep = !value->entirely_available (); if (*optimizedp || *unavailablep) { diff --git a/gdb/amd64-tdep.c b/gdb/amd64-tdep.c index 9c4a90287bc..38440639565 100644 --- a/gdb/amd64-tdep.c +++ b/gdb/amd64-tdep.c @@ -375,8 +375,8 @@ amd64_pseudo_register_read_value (struct gdbarch *gdbarch, if (status == REG_VALID) memcpy (buf, raw_buf + 1, 1); else - mark_value_bytes_unavailable (result_value, 0, - result_value->type ()->length ()); + result_value->mark_bytes_unavailable (0, + result_value->type ()->length ()); } else { @@ -385,8 +385,8 @@ amd64_pseudo_register_read_value (struct gdbarch *gdbarch, if (status == REG_VALID) memcpy (buf, raw_buf, 1); else - mark_value_bytes_unavailable (result_value, 0, - result_value->type ()->length ()); + result_value->mark_bytes_unavailable (0, + result_value->type ()->length ()); } } else if (i386_dword_regnum_p (gdbarch, regnum)) @@ -398,8 +398,8 @@ amd64_pseudo_register_read_value (struct gdbarch *gdbarch, if (status == REG_VALID) memcpy (buf, raw_buf, 4); else - mark_value_bytes_unavailable (result_value, 0, - result_value->type ()->length ()); + result_value->mark_bytes_unavailable (0, + result_value->type ()->length ()); } else i386_pseudo_register_read_into_value (gdbarch, regcache, regnum, diff --git a/gdb/c-valprint.c b/gdb/c-valprint.c index 55ba02996f3..34a9d0f6075 100644 --- a/gdb/c-valprint.c +++ b/gdb/c-valprint.c @@ -257,9 +257,9 @@ c_value_print_array (struct value *val, long as the entire array is valid. */ if (c_textual_element_type (unresolved_elttype, options->format) - && value_bytes_available (val, 0, type->length ()) - && !value_bits_any_optimized_out (val, 0, - TARGET_CHAR_BIT * type->length ())) + && val->bytes_available (0, type->length ()) + && !val->bits_any_optimized_out (0, + TARGET_CHAR_BIT * type->length ())) { int force_ellipses = 0; @@ -520,7 +520,7 @@ c_value_print (struct value *val, struct ui_file *stream, /* Pointer to class, check real type of object. */ gdb_printf (stream, "("); - if (value_entirely_available (val)) + if (val->entirely_available ()) { real_type = value_rtti_indirect_type (val, &full, &top, &using_enc); diff --git a/gdb/compile/compile-object-load.c b/gdb/compile/compile-object-load.c index af4f6e2c2ef..12939b19e09 100644 --- a/gdb/compile/compile-object-load.c +++ b/gdb/compile/compile-object-load.c @@ -578,9 +578,9 @@ store_regs (struct type *regs_type, CORE_ADDR regs_base) regnum = compile_register_name_demangle (gdbarch, reg_name); regval = value_from_register (reg_type, regnum, get_current_frame ()); - if (value_optimized_out (regval)) + if (regval->optimized_out ()) error (_("Register \"%s\" is optimized out."), reg_name); - if (!value_entirely_available (regval)) + if (!regval->entirely_available ()) error (_("Register \"%s\" is not available."), reg_name); inferior_addr = regs_base + reg_offset; diff --git a/gdb/cp-valprint.c b/gdb/cp-valprint.c index 687be9d4bd6..37147749619 100644 --- a/gdb/cp-valprint.c +++ b/gdb/cp-valprint.c @@ -550,7 +550,7 @@ cp_print_static_field (struct type *type, { struct value_print_options opts; - if (value_entirely_optimized_out (val)) + if (val->entirely_optimized_out ()) { val_print_optimized_out (val, stream); return; diff --git a/gdb/d-valprint.c b/gdb/d-valprint.c index b5e981874c1..38fb2a07c1f 100644 --- a/gdb/d-valprint.c +++ b/gdb/d-valprint.c @@ -38,9 +38,8 @@ dynamic_array_type (struct type *type, && type->field (0).type ()->code () == TYPE_CODE_INT && strcmp (type->field (0).name (), "length") == 0 && strcmp (type->field (1).name (), "ptr") == 0 - && !value_bits_any_optimized_out (val, - TARGET_CHAR_BIT * embedded_offset, - TARGET_CHAR_BIT * type->length ())) + && !val->bits_any_optimized_out (TARGET_CHAR_BIT * embedded_offset, + TARGET_CHAR_BIT * type->length ())) { CORE_ADDR addr; struct type *elttype; diff --git a/gdb/dwarf2/expr.c b/gdb/dwarf2/expr.c index a1119e16c23..45bdb007420 100644 --- a/gdb/dwarf2/expr.c +++ b/gdb/dwarf2/expr.c @@ -233,12 +233,12 @@ rw_pieced_value (value *v, value *from, bool check_optimized) { if (check_optimized) return true; - mark_value_bits_optimized_out (v, offset, - this_size_bits); + v->mark_bits_optimized_out (offset, + this_size_bits); } if (unavail && !check_optimized) - mark_value_bits_unavailable (v, offset, - this_size_bits); + v->mark_bits_unavailable (offset, + this_size_bits); break; } @@ -358,7 +358,7 @@ rw_pieced_value (value *v, value *from, bool check_optimized) if (from != nullptr) { - mark_value_bits_optimized_out (v, offset, this_size_bits); + v->mark_bits_optimized_out (offset, this_size_bits); break; } @@ -390,7 +390,7 @@ rw_pieced_value (value *v, value *from, bool check_optimized) if (from != nullptr) { - mark_value_bits_optimized_out (v, offset, this_size_bits); + v->mark_bits_optimized_out (offset, this_size_bits); break; } @@ -413,7 +413,7 @@ rw_pieced_value (value *v, value *from, bool check_optimized) case DWARF_VALUE_IMPLICIT_POINTER: if (from != nullptr) { - mark_value_bits_optimized_out (v, offset, this_size_bits); + v->mark_bits_optimized_out (offset, this_size_bits); break; } @@ -424,7 +424,7 @@ rw_pieced_value (value *v, value *from, bool check_optimized) case DWARF_VALUE_OPTIMIZED_OUT: if (check_optimized) return true; - mark_value_bits_optimized_out (v, offset, this_size_bits); + v->mark_bits_optimized_out (offset, this_size_bits); break; default: @@ -960,7 +960,7 @@ dwarf_expr_context::fetch_result (struct type *type, struct type *subobj_type, retval = value_from_register (subobj_type, gdb_regnum, this->m_frame); - if (value_optimized_out (retval)) + if (retval->optimized_out ()) { /* This means the register has undefined value / was not saved. As we're computing the location of some diff --git a/gdb/dwarf2/loc.c b/gdb/dwarf2/loc.c index f9706a0bc05..616db13488b 100644 --- a/gdb/dwarf2/loc.c +++ b/gdb/dwarf2/loc.c @@ -1515,8 +1515,8 @@ dwarf2_evaluate_loc_desc_full (struct type *type, frame_info_ptr frame, { free_values.free_to_mark (); retval = value::allocate (subobj_type); - mark_value_bytes_unavailable (retval, 0, - subobj_type->length ()); + retval->mark_bytes_unavailable (0, + subobj_type->length ()); return retval; } else if (ex.error == NO_ENTRY_VALUE_ERROR) @@ -1609,7 +1609,7 @@ dwarf2_locexpr_baton_eval (const struct dwarf2_locexpr_baton *dlbaton, throw; } - if (value_optimized_out (result)) + if (result->optimized_out ()) return 0; if (VALUE_LVAL (result) == lval_memory) @@ -1709,7 +1709,7 @@ dwarf2_evaluate_property (const struct dynamic_prop *prop, val = dwarf2_evaluate_loc_desc (baton->property_type, frame, data, size, baton->loclist.per_cu, baton->loclist.per_objfile); - if (!value_optimized_out (val)) + if (!val->optimized_out ()) { *value = value_as_address (val); return true; diff --git a/gdb/findvar.c b/gdb/findvar.c index b4852b2cfb3..2a2c3eb2ab4 100644 --- a/gdb/findvar.c +++ b/gdb/findvar.c @@ -906,9 +906,9 @@ value_from_register (struct type *type, int regnum, frame_info_ptr frame) if (!ok) { if (optim) - mark_value_bytes_optimized_out (v, 0, type->length ()); + v->mark_bytes_optimized_out (0, type->length ()); if (unavail) - mark_value_bytes_unavailable (v, 0, type->length ()); + v->mark_bytes_unavailable (0, type->length ()); } } else @@ -971,7 +971,7 @@ address_from_register (int regnum, frame_info_ptr frame) value = gdbarch_value_from_register (gdbarch, type, regnum, null_frame_id); read_frame_register_value (value, frame); - if (value_optimized_out (value)) + if (value->optimized_out ()) { /* This function is used while computing a location expression. Complain about the value being optimized out, rather than diff --git a/gdb/frame.c b/gdb/frame.c index 2ca2a6b30fc..095682fd8fa 100644 --- a/gdb/frame.c +++ b/gdb/frame.c @@ -1189,8 +1189,8 @@ frame_register_unwind (frame_info_ptr next_frame, int regnum, gdb_assert (value != NULL); - *optimizedp = value_optimized_out (value); - *unavailablep = !value_entirely_available (value); + *optimizedp = value->optimized_out (); + *unavailablep = !value->entirely_available (); *lvalp = VALUE_LVAL (value); *addrp = value->address (); if (*lvalp == lval_register) @@ -1289,7 +1289,7 @@ frame_unwind_register_value (frame_info_ptr next_frame, int regnum) string_file debug_file; gdb_printf (&debug_file, " ->"); - if (value_optimized_out (value)) + if (value->optimized_out ()) { gdb_printf (&debug_file, " "); val_print_not_saved (&debug_file); @@ -1342,12 +1342,12 @@ frame_unwind_register_signed (frame_info_ptr next_frame, int regnum) gdb_assert (value != NULL); - if (value_optimized_out (value)) + if (value->optimized_out ()) { throw_error (OPTIMIZED_OUT_ERROR, _("Register %d was not saved"), regnum); } - if (!value_entirely_available (value)) + if (!value->entirely_available ()) { throw_error (NOT_AVAILABLE_ERROR, _("Register %d is not available"), regnum); @@ -1375,12 +1375,12 @@ frame_unwind_register_unsigned (frame_info_ptr next_frame, int regnum) gdb_assert (value != NULL); - if (value_optimized_out (value)) + if (value->optimized_out ()) { throw_error (OPTIMIZED_OUT_ERROR, _("Register %d was not saved"), regnum); } - if (!value_entirely_available (value)) + if (!value->entirely_available ()) { throw_error (NOT_AVAILABLE_ERROR, _("Register %d is not available"), regnum); @@ -1405,8 +1405,8 @@ read_frame_register_unsigned (frame_info_ptr frame, int regnum, { struct value *regval = get_frame_register_value (frame, regnum); - if (!value_optimized_out (regval) - && value_entirely_available (regval)) + if (!regval->optimized_out () + && regval->entirely_available ()) { struct gdbarch *gdbarch = get_frame_arch (frame); enum bfd_endian byte_order = gdbarch_byte_order (gdbarch); @@ -1537,8 +1537,8 @@ get_frame_register_bytes (frame_info_ptr frame, int regnum, = frame_unwind_register_value (frame_info_ptr (frame->next), regnum); gdb_assert (value != NULL); - *optimizedp = value_optimized_out (value); - *unavailablep = !value_entirely_available (value); + *optimizedp = value->optimized_out (); + *unavailablep = !value->entirely_available (); if (*optimizedp || *unavailablep) { diff --git a/gdb/gnu-v2-abi.c b/gdb/gnu-v2-abi.c index 4636ad55109..e8202667e24 100644 --- a/gdb/gnu-v2-abi.c +++ b/gdb/gnu-v2-abi.c @@ -366,8 +366,8 @@ gnuv2_baseclass_offset (struct type *type, int index, field_offset = type->field (i).loc_bitpos () / 8; field_length = field_type->length (); - if (!value_bytes_available (val, embedded_offset + field_offset, - field_length)) + if (!val->bytes_available (embedded_offset + field_offset, + field_length)) throw_error (NOT_AVAILABLE_ERROR, _("Virtual baseclass pointer is not available")); diff --git a/gdb/guile/scm-pretty-print.c b/gdb/guile/scm-pretty-print.c index ca44133cd7f..e172a14dbb3 100644 --- a/gdb/guile/scm-pretty-print.c +++ b/gdb/guile/scm-pretty-print.c @@ -969,7 +969,7 @@ gdbscm_apply_val_pretty_printer (const struct extension_language_defn *extlang, value->fetch_lazy (); /* No pretty-printer support for unavailable values. */ - if (!value_bytes_available (value, 0, type->length ())) + if (!value->bytes_available (0, type->length ())) return EXT_LANG_RC_NOP; if (!gdb_scheme_initialized) diff --git a/gdb/guile/scm-value.c b/gdb/guile/scm-value.c index df76f8a49d1..3e18bd1fdc3 100644 --- a/gdb/guile/scm-value.c +++ b/gdb/guile/scm-value.c @@ -390,7 +390,7 @@ gdbscm_value_optimized_out_p (SCM self) return gdbscm_wrap ([=] { - return scm_from_bool (value_optimized_out (v_smob->value)); + return scm_from_bool (v_smob->value->optimized_out ()); }); } diff --git a/gdb/i386-tdep.c b/gdb/i386-tdep.c index f12b9038f9e..53e531ca90c 100644 --- a/gdb/i386-tdep.c +++ b/gdb/i386-tdep.c @@ -3388,8 +3388,8 @@ i386_pseudo_register_read_into_value (struct gdbarch *gdbarch, /* Extract (always little endian). */ status = regcache->raw_read (fpnum, raw_buf); if (status != REG_VALID) - mark_value_bytes_unavailable (result_value, 0, - result_value->type ()->length ()); + result_value->mark_bytes_unavailable (0, + result_value->type ()->length ()); else memcpy (buf, raw_buf, register_size (gdbarch, regnum)); } @@ -3404,7 +3404,7 @@ i386_pseudo_register_read_into_value (struct gdbarch *gdbarch, status = regcache->raw_read (I387_BND0R_REGNUM (tdep) + regnum, raw_buf); if (status != REG_VALID) - mark_value_bytes_unavailable (result_value, 0, 16); + result_value->mark_bytes_unavailable (0, 16); else { enum bfd_endian byte_order = gdbarch_byte_order (target_gdbarch ()); @@ -3426,7 +3426,7 @@ i386_pseudo_register_read_into_value (struct gdbarch *gdbarch, /* Extract (always little endian). */ status = regcache->raw_read (tdep->k0_regnum + regnum, raw_buf); if (status != REG_VALID) - mark_value_bytes_unavailable (result_value, 0, 8); + result_value->mark_bytes_unavailable (0, 8); else memcpy (buf, raw_buf, 8); } @@ -3440,7 +3440,7 @@ i386_pseudo_register_read_into_value (struct gdbarch *gdbarch, status = regcache->raw_read (I387_XMM0_REGNUM (tdep) + regnum, raw_buf); if (status != REG_VALID) - mark_value_bytes_unavailable (result_value, 0, 16); + result_value->mark_bytes_unavailable (0, 16); else memcpy (buf, raw_buf, 16); @@ -3448,7 +3448,7 @@ i386_pseudo_register_read_into_value (struct gdbarch *gdbarch, status = regcache->raw_read (tdep->ymm0h_regnum + regnum, raw_buf); if (status != REG_VALID) - mark_value_bytes_unavailable (result_value, 16, 16); + result_value->mark_bytes_unavailable (16, 16); else memcpy (buf + 16, raw_buf, 16); } @@ -3459,7 +3459,7 @@ i386_pseudo_register_read_into_value (struct gdbarch *gdbarch, - num_lower_zmm_regs, raw_buf); if (status != REG_VALID) - mark_value_bytes_unavailable (result_value, 0, 16); + result_value->mark_bytes_unavailable (0, 16); else memcpy (buf, raw_buf, 16); @@ -3468,7 +3468,7 @@ i386_pseudo_register_read_into_value (struct gdbarch *gdbarch, - num_lower_zmm_regs, raw_buf); if (status != REG_VALID) - mark_value_bytes_unavailable (result_value, 16, 16); + result_value->mark_bytes_unavailable (16, 16); else memcpy (buf + 16, raw_buf, 16); } @@ -3477,7 +3477,7 @@ i386_pseudo_register_read_into_value (struct gdbarch *gdbarch, status = regcache->raw_read (tdep->zmm0h_regnum + regnum, raw_buf); if (status != REG_VALID) - mark_value_bytes_unavailable (result_value, 32, 32); + result_value->mark_bytes_unavailable (32, 32); else memcpy (buf + 32, raw_buf, 32); } @@ -3489,14 +3489,14 @@ i386_pseudo_register_read_into_value (struct gdbarch *gdbarch, status = regcache->raw_read (I387_XMM0_REGNUM (tdep) + regnum, raw_buf); if (status != REG_VALID) - mark_value_bytes_unavailable (result_value, 0, 16); + result_value->mark_bytes_unavailable (0, 16); else memcpy (buf, raw_buf, 16); /* Read upper 128bits. */ status = regcache->raw_read (tdep->ymm0h_regnum + regnum, raw_buf); if (status != REG_VALID) - mark_value_bytes_unavailable (result_value, 16, 32); + result_value->mark_bytes_unavailable (16, 32); else memcpy (buf + 16, raw_buf, 16); } @@ -3507,14 +3507,14 @@ i386_pseudo_register_read_into_value (struct gdbarch *gdbarch, status = regcache->raw_read (I387_XMM16_REGNUM (tdep) + regnum, raw_buf); if (status != REG_VALID) - mark_value_bytes_unavailable (result_value, 0, 16); + result_value->mark_bytes_unavailable (0, 16); else memcpy (buf, raw_buf, 16); /* Read upper 128bits. */ status = regcache->raw_read (tdep->ymm16h_regnum + regnum, raw_buf); if (status != REG_VALID) - mark_value_bytes_unavailable (result_value, 16, 16); + result_value->mark_bytes_unavailable (16, 16); else memcpy (buf + 16, raw_buf, 16); } @@ -3525,8 +3525,8 @@ i386_pseudo_register_read_into_value (struct gdbarch *gdbarch, /* Extract (always little endian). */ status = regcache->raw_read (gpnum, raw_buf); if (status != REG_VALID) - mark_value_bytes_unavailable (result_value, 0, - result_value->type ()->length ()); + result_value->mark_bytes_unavailable (0, + result_value->type ()->length ()); else memcpy (buf, raw_buf, 2); } @@ -3538,8 +3538,8 @@ i386_pseudo_register_read_into_value (struct gdbarch *gdbarch, upper registers. */ status = regcache->raw_read (gpnum % 4, raw_buf); if (status != REG_VALID) - mark_value_bytes_unavailable (result_value, 0, - result_value->type ()->length ()); + result_value->mark_bytes_unavailable (0, + result_value->type ()->length ()); else if (gpnum >= 4) memcpy (buf, raw_buf + 1, 1); else diff --git a/gdb/i387-tdep.c b/gdb/i387-tdep.c index e1cbab580eb..df0a6058adc 100644 --- a/gdb/i387-tdep.c +++ b/gdb/i387-tdep.c @@ -282,7 +282,7 @@ i387_print_float_info (struct gdbarch *gdbarch, struct ui_file *file, regnum = (fpreg + 8 - top) % 8 + I387_ST0_REGNUM (tdep); regval = get_frame_register_value (frame, regnum); - if (value_entirely_available (regval)) + if (regval->entirely_available ()) { const gdb_byte *raw = regval->contents ().data (); diff --git a/gdb/infcmd.c b/gdb/infcmd.c index 50378b111c0..3943a562590 100644 --- a/gdb/infcmd.c +++ b/gdb/infcmd.c @@ -2172,8 +2172,8 @@ default_print_one_register_info (struct ui_file *file, format_stream.puts (name); pad_to_column (format_stream, value_column_1); - print_raw_format = (value_entirely_available (val) - && !value_optimized_out (val)); + print_raw_format = (val->entirely_available () + && !val->optimized_out ()); /* If virtual format is floating, print it that way, and in raw hex. */ diff --git a/gdb/infrun.c b/gdb/infrun.c index c5718580162..e5d2b97f1dd 100644 --- a/gdb/infrun.c +++ b/gdb/infrun.c @@ -7989,7 +7989,7 @@ insert_exception_resume_breakpoint (struct thread_info *tp, b, VAR_DOMAIN); value = read_var_value (vsym.symbol, vsym.block, frame); /* If the value was optimized out, revert to the old behavior. */ - if (! value_optimized_out (value)) + if (! value->optimized_out ()) { handler = value_as_address (value); diff --git a/gdb/mi/mi-cmd-stack.c b/gdb/mi/mi-cmd-stack.c index abe0d34f042..1554f9550e6 100644 --- a/gdb/mi/mi-cmd-stack.c +++ b/gdb/mi/mi-cmd-stack.c @@ -501,14 +501,13 @@ list_arg_or_local (const struct frame_arg *arg, enum what_to_list what, && (arg->val || arg->error))); if (skip_unavailable && arg->val != NULL - && (value_entirely_unavailable (arg->val) + && (arg->val->entirely_unavailable () /* A scalar object that does not have all bits available is also considered unavailable, because all bits contribute to its representation. */ || (val_print_scalar_type_p (arg->val->type ()) - && !value_bytes_available (arg->val, - arg->val->embedded_offset (), - arg->val->type ()->length ())))) + && !arg->val->bytes_available (arg->val->embedded_offset (), + arg->val->type ()->length ())))) return; gdb::optional tuple_emitter; diff --git a/gdb/mi/mi-main.c b/gdb/mi/mi-main.c index f2e680cb0d3..84a95a24684 100644 --- a/gdb/mi/mi-main.c +++ b/gdb/mi/mi-main.c @@ -1096,7 +1096,7 @@ output_register (frame_info_ptr frame, int regnum, int format, struct value *val = value_of_register (regnum, frame); struct value_print_options opts; - if (skip_unavailable && !value_entirely_available (val)) + if (skip_unavailable && !val->entirely_available ()) return; ui_out_emit_tuple tuple_emitter (uiout, NULL); diff --git a/gdb/mips-tdep.c b/gdb/mips-tdep.c index 19e0fdcf81e..b88a2f67ded 100644 --- a/gdb/mips-tdep.c +++ b/gdb/mips-tdep.c @@ -6585,8 +6585,8 @@ print_gp_register_row (struct ui_file *file, frame_info_ptr frame, /* OK: get the data in raw format. */ value = get_frame_register_value (frame, regnum); - if (value_optimized_out (value) - || !value_entirely_available (value)) + if (value->optimized_out () + || !value->entirely_available ()) { gdb_printf (file, "%*s ", (int) mips_abi_regsize (gdbarch) * 2, diff --git a/gdb/p-valprint.c b/gdb/p-valprint.c index 10d41523851..f13f0ef6625 100644 --- a/gdb/p-valprint.c +++ b/gdb/p-valprint.c @@ -818,7 +818,7 @@ pascal_object_print_static_field (struct value *val, struct type *type = val->type (); struct value_print_options opts; - if (value_entirely_optimized_out (val)) + if (val->entirely_optimized_out ()) { val_print_optimized_out (val, stream); return; diff --git a/gdb/printcmd.c b/gdb/printcmd.c index 94e531df446..514261e7ea7 100644 --- a/gdb/printcmd.c +++ b/gdb/printcmd.c @@ -1275,8 +1275,8 @@ should_validate_memtags (struct value *value) /* OK, we have an address value. Check we have a complete value we can extract. */ - if (value_optimized_out (value) - || !value_entirely_available (value)) + if (value->optimized_out () + || !value->entirely_available ()) return false; /* We do. Check whether it includes any tags. */ diff --git a/gdb/python/py-prettyprint.c b/gdb/python/py-prettyprint.c index dd72e230157..dbacb3f3fe2 100644 --- a/gdb/python/py-prettyprint.c +++ b/gdb/python/py-prettyprint.c @@ -582,7 +582,7 @@ gdbpy_apply_val_pretty_printer (const struct extension_language_defn *extlang, value->fetch_lazy (); /* No pretty-printer support for unavailable values. */ - if (!value_bytes_available (value, 0, type->length ())) + if (!value->bytes_available (0, type->length ())) return EXT_LANG_RC_NOP; if (!gdb_python_initialized) diff --git a/gdb/python/py-value.c b/gdb/python/py-value.c index f339845c272..6c33e3529c8 100644 --- a/gdb/python/py-value.c +++ b/gdb/python/py-value.c @@ -1197,7 +1197,7 @@ valpy_get_is_optimized_out (PyObject *self, void *closure) try { - opt = value_optimized_out (value); + opt = value->optimized_out (); } catch (const gdb_exception &except) { diff --git a/gdb/regcache.c b/gdb/regcache.c index 90989595acc..09dd6a4b79e 100644 --- a/gdb/regcache.c +++ b/gdb/regcache.c @@ -715,7 +715,7 @@ readable_regcache::cooked_read (int regnum, gdb_byte *buf) computed = gdbarch_pseudo_register_read_value (m_descr->gdbarch, this, regnum); - if (value_entirely_available (computed)) + if (computed->entirely_available ()) memcpy (buf, computed->contents_raw ().data (), m_descr->sizeof_register[regnum]); else @@ -752,8 +752,8 @@ readable_regcache::cooked_read_value (int regnum) API is preferred. */ if (cooked_read (regnum, result->contents_raw ().data ()) == REG_UNAVAILABLE) - mark_value_bytes_unavailable (result, 0, - result->type ()->length ()); + result->mark_bytes_unavailable (0, + result->type ()->length ()); return result; } diff --git a/gdb/riscv-tdep.c b/gdb/riscv-tdep.c index 78c23ee86fc..388ce8c2519 100644 --- a/gdb/riscv-tdep.c +++ b/gdb/riscv-tdep.c @@ -1126,8 +1126,8 @@ riscv_print_one_register_info (struct gdbarch *gdbarch, return; } - print_raw_format = (value_entirely_available (val) - && !value_optimized_out (val)); + print_raw_format = (val->entirely_available () + && !val->optimized_out ()); if (regtype->code () == TYPE_CODE_FLT || (regtype->code () == TYPE_CODE_UNION diff --git a/gdb/s390-tdep.c b/gdb/s390-tdep.c index 7d2cdf2a873..cab1757c5ab 100644 --- a/gdb/s390-tdep.c +++ b/gdb/s390-tdep.c @@ -2199,7 +2199,7 @@ s390_unwind_pseudo_register (frame_info_ptr this_frame, int regnum) struct value *val; val = frame_unwind_register_value (this_frame, S390_PSWA_REGNUM); - if (!value_optimized_out (val)) + if (!val->optimized_out ()) { LONGEST pswa = value_as_long (val); @@ -2216,7 +2216,7 @@ s390_unwind_pseudo_register (frame_info_ptr this_frame, int regnum) struct value *val; val = frame_unwind_register_value (this_frame, S390_PSWM_REGNUM); - if (!value_optimized_out (val)) + if (!val->optimized_out ()) { LONGEST pswm = value_as_long (val); @@ -2235,7 +2235,7 @@ s390_unwind_pseudo_register (frame_info_ptr this_frame, int regnum) struct value *val; val = frame_unwind_register_value (this_frame, S390_R0_REGNUM + reg); - if (!value_optimized_out (val)) + if (!val->optimized_out ()) return value_cast (type, val); } diff --git a/gdb/stack.c b/gdb/stack.c index 576947c5dac..934220e7c33 100644 --- a/gdb/stack.c +++ b/gdb/stack.c @@ -550,7 +550,7 @@ read_frame_arg (const frame_print_options &fp_opts, && SYMBOL_COMPUTED_OPS (sym)->read_variable_at_entry != NULL && fp_opts.print_entry_values != print_entry_values_no && (fp_opts.print_entry_values != print_entry_values_if_needed - || !val || value_optimized_out (val))) + || !val || val->optimized_out ())) { try { @@ -568,7 +568,7 @@ read_frame_arg (const frame_print_options &fp_opts, } } - if (entryval != NULL && value_optimized_out (entryval)) + if (entryval != NULL && entryval->optimized_out ()) entryval = NULL; if (fp_opts.print_entry_values == print_entry_values_compact @@ -672,7 +672,7 @@ read_frame_arg (const frame_print_options &fp_opts, if (fp_opts.print_entry_values == print_entry_values_only || fp_opts.print_entry_values == print_entry_values_both || (fp_opts.print_entry_values == print_entry_values_preferred - && (!val || value_optimized_out (val)))) + && (!val || val->optimized_out ()))) { entryval = value::allocate_optimized_out (sym->type ()); entryval_error = NULL; @@ -681,7 +681,7 @@ read_frame_arg (const frame_print_options &fp_opts, if ((fp_opts.print_entry_values == print_entry_values_compact || fp_opts.print_entry_values == print_entry_values_if_needed || fp_opts.print_entry_values == print_entry_values_preferred) - && (!val || value_optimized_out (val)) && entryval != NULL) + && (!val || val->optimized_out ()) && entryval != NULL) { val = NULL; val_error = NULL; @@ -1708,7 +1708,7 @@ info_frame_command_core (frame_info_ptr fi, bool selected_frame_p) struct value *value = frame_unwind_register_value (fi, sp_regnum); gdb_assert (value != NULL); - if (!value_optimized_out (value) && value_entirely_available (value)) + if (!value->optimized_out () && value->entirely_available ()) { if (VALUE_LVAL (value) == not_lval) { diff --git a/gdb/valops.c b/gdb/valops.c index 93e58d1d168..656ed700fb1 100644 --- a/gdb/valops.c +++ b/gdb/valops.c @@ -1066,9 +1066,9 @@ read_value_memory (struct value *val, LONGEST bit_offset, if (status == TARGET_XFER_OK) /* nothing */; else if (status == TARGET_XFER_UNAVAILABLE) - mark_value_bits_unavailable (val, (xfered_total * HOST_CHAR_BIT - + bit_offset), - xfered_partial * HOST_CHAR_BIT); + val->mark_bits_unavailable ((xfered_total * HOST_CHAR_BIT + + bit_offset), + xfered_partial * HOST_CHAR_BIT); else if (status == TARGET_XFER_EOF) memory_error (TARGET_XFER_E_IO, memaddr + xfered_total); else diff --git a/gdb/valprint.c b/gdb/valprint.c index 89d3bbf066c..ad25c141aa4 100644 --- a/gdb/valprint.c +++ b/gdb/valprint.c @@ -373,9 +373,8 @@ valprint_check_validity (struct ui_file *stream, && type->code () != TYPE_CODE_STRUCT && type->code () != TYPE_CODE_ARRAY) { - if (value_bits_any_optimized_out (val, - TARGET_CHAR_BIT * embedded_offset, - TARGET_CHAR_BIT * type->length ())) + if (val->bits_any_optimized_out (TARGET_CHAR_BIT * embedded_offset, + TARGET_CHAR_BIT * type->length ())) { val_print_optimized_out (val, stream); return 0; @@ -403,7 +402,7 @@ valprint_check_validity (struct ui_file *stream, return is_ref; } - if (!value_bytes_available (val, embedded_offset, type->length ())) + if (!val->bytes_available (embedded_offset, type->length ())) { val_print_unavailable (stream); return 0; @@ -1131,7 +1130,7 @@ value_check_printable (struct value *val, struct ui_file *stream, return 0; } - if (value_entirely_optimized_out (val)) + if (val->entirely_optimized_out ()) { if (options->summary && !val_print_scalar_type_p (val->type ())) gdb_printf (stream, "..."); @@ -1140,7 +1139,7 @@ value_check_printable (struct value *val, struct ui_file *stream, return 0; } - if (value_entirely_unavailable (val)) + if (val->entirely_unavailable ()) { if (options->summary && !val_print_scalar_type_p (val->type ())) gdb_printf (stream, "..."); @@ -1304,10 +1303,10 @@ value_print_scalar_formatted (struct value *val, /* A scalar object that does not have all bits available can't be printed, because all bits contribute to its representation. */ - if (value_bits_any_optimized_out (val, 0, - TARGET_CHAR_BIT * type->length ())) + if (val->bits_any_optimized_out (0, + TARGET_CHAR_BIT * type->length ())) val_print_optimized_out (val, stream); - else if (!value_bytes_available (val, 0, type->length ())) + else if (!val->bytes_available (0, type->length ())) val_print_unavailable (stream); else print_scalar_formatted (valaddr, type, options, size, stream); diff --git a/gdb/value.c b/gdb/value.c index 98078ed44d2..a9db9e04bab 100644 --- a/gdb/value.c +++ b/gdb/value.c @@ -169,81 +169,63 @@ value::get_arch () const } int -value_bits_available (const struct value *value, LONGEST offset, LONGEST length) +value::bits_available (LONGEST offset, LONGEST length) const { - gdb_assert (!value->m_lazy); + gdb_assert (!m_lazy); - return !ranges_contain (value->m_unavailable, offset, length); + return !ranges_contain (m_unavailable, offset, length); } int -value_bytes_available (const struct value *value, - LONGEST offset, LONGEST length) +value::bytes_available (LONGEST offset, LONGEST length) const { - return value_bits_available (value, - offset * TARGET_CHAR_BIT, - length * TARGET_CHAR_BIT); + return bits_available (offset * TARGET_CHAR_BIT, + length * TARGET_CHAR_BIT); } int -value_bits_any_optimized_out (const struct value *value, int bit_offset, int bit_length) +value::bits_any_optimized_out (int bit_offset, int bit_length) const { - gdb_assert (!value->m_lazy); + gdb_assert (!m_lazy); - return ranges_contain (value->m_optimized_out, bit_offset, bit_length); + return ranges_contain (m_optimized_out, bit_offset, bit_length); } int -value_entirely_available (struct value *value) +value::entirely_available () { /* We can only tell whether the whole value is available when we try to read it. */ - if (value->m_lazy) - value->fetch_lazy (); + if (m_lazy) + fetch_lazy (); - if (value->m_unavailable.empty ()) + if (m_unavailable.empty ()) return 1; return 0; } -/* Returns true if VALUE is entirely covered by RANGES. If the value - is lazy, it'll be read now. Note that RANGE is a pointer to - pointer because reading the value might change *RANGE. */ +/* See value.h. */ -static int -value_entirely_covered_by_range_vector (struct value *value, - const std::vector &ranges) +int +value::entirely_covered_by_range_vector (const std::vector &ranges) { /* We can only tell whether the whole value is optimized out / unavailable when we try to read it. */ - if (value->m_lazy) - value->fetch_lazy (); + if (m_lazy) + fetch_lazy (); if (ranges.size () == 1) { const struct range &t = ranges[0]; if (t.offset == 0 - && t.length == (TARGET_CHAR_BIT - * value->enclosing_type ()->length ())) + && t.length == TARGET_CHAR_BIT * enclosing_type ()->length ()) return 1; } return 0; } -int -value_entirely_unavailable (struct value *value) -{ - return value_entirely_covered_by_range_vector (value, value->m_unavailable); -} - -int -value_entirely_optimized_out (struct value *value) -{ - return value_entirely_covered_by_range_vector (value, value->m_optimized_out); -} - /* Insert into the vector pointed to by VECTORP the bit range starting of OFFSET bits, and extending for the next LENGTH bits. */ @@ -414,19 +396,16 @@ insert_into_bit_range_vector (std::vector *vectorp, } void -mark_value_bits_unavailable (struct value *value, - LONGEST offset, LONGEST length) +value::mark_bits_unavailable (LONGEST offset, LONGEST length) { - insert_into_bit_range_vector (&value->m_unavailable, offset, length); + insert_into_bit_range_vector (&m_unavailable, offset, length); } void -mark_value_bytes_unavailable (struct value *value, - LONGEST offset, LONGEST length) +value::mark_bytes_unavailable (LONGEST offset, LONGEST length) { - mark_value_bits_unavailable (value, - offset * TARGET_CHAR_BIT, - length * TARGET_CHAR_BIT); + mark_bits_unavailable (offset * TARGET_CHAR_BIT, + length * TARGET_CHAR_BIT); } /* Find the first range in RANGES that overlaps the range defined by @@ -883,7 +862,7 @@ value::allocate_optimized_out (struct type *type) { struct value *retval = value::allocate_lazy (type); - mark_value_bytes_optimized_out (retval, 0, type->length ()); + retval->mark_bytes_optimized_out (0, type->length ()); retval->set_lazy (0); return retval; } @@ -933,7 +912,7 @@ value_actual_type (struct value *value, int resolve_simple_types, if (result->is_pointer_or_reference () && (check_typedef (result->target_type ())->code () == TYPE_CODE_STRUCT) - && !value_optimized_out (value)) + && !value->optimized_out ()) { struct type *real_type; @@ -1076,10 +1055,9 @@ value_contents_copy_raw (struct value *dst, LONGEST dst_offset, /* The overwritten DST range gets unavailability ORed in, not replaced. Make sure to remember to implement replacing if it turns out actually necessary. */ - gdb_assert (value_bytes_available (dst, dst_offset, length)); - gdb_assert (!value_bits_any_optimized_out (dst, - TARGET_CHAR_BIT * dst_offset, - TARGET_CHAR_BIT * length)); + gdb_assert (dst->bytes_available (dst_offset, length)); + gdb_assert (!dst->bits_any_optimized_out (TARGET_CHAR_BIT * dst_offset, + TARGET_CHAR_BIT * length)); /* Copy the data. */ gdb::array_view dst_contents @@ -1119,9 +1097,9 @@ value_contents_copy_raw_bitwise (struct value *dst, LONGEST dst_bit_offset, turns out actually necessary. */ LONGEST dst_offset = dst_bit_offset / TARGET_CHAR_BIT; LONGEST length = bit_length / TARGET_CHAR_BIT; - gdb_assert (value_bytes_available (dst, dst_offset, length)); - gdb_assert (!value_bits_any_optimized_out (dst, dst_bit_offset, - bit_length)); + gdb_assert (dst->bytes_available (dst_offset, length)); + gdb_assert (!dst->bits_any_optimized_out (dst_bit_offset, + bit_length)); /* Copy the data. */ gdb::array_view dst_contents = dst->contents_all_raw (); @@ -1175,26 +1153,26 @@ value::contents_writeable () } int -value_optimized_out (struct value *value) +value::optimized_out () { - if (value->m_lazy) + if (m_lazy) { /* See if we can compute the result without fetching the value. */ - if (VALUE_LVAL (value) == lval_memory) + if (VALUE_LVAL (this) == lval_memory) return false; - else if (VALUE_LVAL (value) == lval_computed) + else if (VALUE_LVAL (this) == lval_computed) { - const struct lval_funcs *funcs = value->m_location.computed.funcs; + const struct lval_funcs *funcs = m_location.computed.funcs; if (funcs->is_optimized_out != nullptr) - return funcs->is_optimized_out (value); + return funcs->is_optimized_out (this); } /* Fall back to fetching. */ try { - value->fetch_lazy (); + fetch_lazy (); } catch (const gdb_exception_error &ex) { @@ -1213,27 +1191,25 @@ value_optimized_out (struct value *value) } } - return !value->m_optimized_out.empty (); + return !m_optimized_out.empty (); } /* Mark contents of VALUE as optimized out, starting at OFFSET bytes, and the following LENGTH bytes. */ void -mark_value_bytes_optimized_out (struct value *value, int offset, int length) +value::mark_bytes_optimized_out (int offset, int length) { - mark_value_bits_optimized_out (value, - offset * TARGET_CHAR_BIT, - length * TARGET_CHAR_BIT); + mark_bits_optimized_out (offset * TARGET_CHAR_BIT, + length * TARGET_CHAR_BIT); } /* See value.h. */ void -mark_value_bits_optimized_out (struct value *value, - LONGEST offset, LONGEST length) +value::mark_bits_optimized_out (LONGEST offset, LONGEST length) { - insert_into_bit_range_vector (&value->m_optimized_out, offset, length); + insert_into_bit_range_vector (&m_optimized_out, offset, length); } int @@ -1417,7 +1393,7 @@ value::copy () const val->m_unavailable = m_unavailable; val->m_optimized_out = m_optimized_out; - if (!val->lazy () && !value_entirely_optimized_out (val)) + if (!val->lazy () && !val->entirely_optimized_out ()) { gdb_assert (m_contents != nullptr); ULONGEST length = enclosing_type ()->length (); @@ -2996,8 +2972,8 @@ unpack_value_field_as_long (struct type *type, const gdb_byte *valaddr, gdb_assert (val != NULL); bit_offset = embedded_offset * TARGET_CHAR_BIT + bitpos; - if (value_bits_any_optimized_out (val, bit_offset, bitsize) - || !value_bits_available (val, bit_offset, bitsize)) + if (val->bits_any_optimized_out (bit_offset, bitsize) + || !val->bits_available (bit_offset, bitsize)) return 0; *result = unpack_bits_as_long (field_type, valaddr + embedded_offset, @@ -3729,7 +3705,7 @@ value_fetch_lazy_register (struct value *val) user_reg_map_regnum_to_name (gdbarch, regnum)); gdb_printf (&debug_file, "->"); - if (value_optimized_out (new_val)) + if (new_val->optimized_out ()) { gdb_printf (&debug_file, " "); val_print_optimized_out (new_val, &debug_file); @@ -3998,8 +3974,8 @@ test_value_copy () value_ref_ptr val = release_value (value::allocate_optimized_out (type)); value_ref_ptr copy = release_value (val.get ()->copy ()); - SELF_CHECK (value_entirely_optimized_out (val.get ())); - SELF_CHECK (value_entirely_optimized_out (copy.get ())); + SELF_CHECK (val.get ()->entirely_optimized_out ()); + SELF_CHECK (copy.get ()->entirely_optimized_out ()); } } /* namespace selftests */ diff --git a/gdb/value.h b/gdb/value.h index fdecfa99405..f46d0fc9d78 100644 --- a/gdb/value.h +++ b/gdb/value.h @@ -263,7 +263,6 @@ struct value void set_lazy (int val) { m_lazy = val; } - /* If a value represents a C++ object, then the `type' field gives the object's compile-time type. If the object actually belongs to some class derived from `type', perhaps with other base classes and @@ -480,6 +479,60 @@ struct value drops to 0, it will be freed. */ void decref (); + /* 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 + byte is unavailable. */ + int bytes_available (LONGEST offset, LONGEST length) const; + + /* Given a value, determine whether the contents bits starting at + OFFSET and extending for LENGTH bits are available. This returns + nonzero if all bits in the given range are available, zero if any + bit is unavailable. */ + int bits_available (LONGEST offset, LONGEST length) const; + + /* Like bytes_available, but return false if any byte in the + whole object is unavailable. */ + int entirely_available (); + + /* Like entirely_available, but return false if any byte in the + whole object is available. */ + int entirely_unavailable () + { return entirely_covered_by_range_vector (m_unavailable); } + + /* Mark this value's content bytes starting at OFFSET and extending + for LENGTH bytes as unavailable. */ + void mark_bytes_unavailable (LONGEST offset, LONGEST length); + + /* Mark this value's content bits starting at OFFSET and extending + for LENGTH bits as unavailable. */ + void mark_bits_unavailable (LONGEST offset, LONGEST length); + + /* If nonzero, this is the value of a variable which does not actually + exist in the program, at least partially. If the value is lazy, + this may fetch it now. */ + int optimized_out (); + + /* Given a value, return true if any of the contents bits starting at + OFFSET and extending for LENGTH bits is optimized out, false + otherwise. */ + int bits_any_optimized_out (int bit_offset, int bit_length) const; + + /* Like optimized_out, but return true iff the whole value is + optimized out. */ + int entirely_optimized_out () + { + return entirely_covered_by_range_vector (m_optimized_out); + } + + /* Mark this value's content bytes starting at OFFSET and extending + for LENGTH bytes as optimized out. */ + void mark_bytes_optimized_out (int offset, int length); + + /* Mark this value's content bits starting at OFFSET and extending + for LENGTH bits as optimized out. */ + void mark_bits_optimized_out (LONGEST offset, LONGEST length); + /* Type of value; either not an lval, or one of the various different possible kinds of lval. */ @@ -663,6 +716,11 @@ struct value void require_not_optimized_out () const; void require_available () const; + + /* Returns true if this value is entirely covered by RANGES. If the + value is lazy, it'll be read now. Note that RANGE is a pointer + to pointer because reading the value might change *RANGE. */ + int entirely_covered_by_range_vector (const std::vector &ranges); }; inline void @@ -759,34 +817,6 @@ struct lval_funcs extern void error_value_optimized_out (void); -/* If nonzero, this is the value of a variable which does not actually - exist in the program, at least partially. If the value is lazy, - this may fetch it now. */ -extern int value_optimized_out (struct value *value); - -/* Given a value, return true if any of the contents bits starting at - OFFSET and extending for LENGTH bits is optimized out, false - otherwise. */ - -extern int value_bits_any_optimized_out (const struct value *value, - int bit_offset, int bit_length); - -/* Like value_optimized_out, but return true iff the whole value is - optimized out. */ -extern int value_entirely_optimized_out (struct value *value); - -/* Mark VALUE's content bytes starting at OFFSET and extending for - LENGTH bytes as optimized out. */ - -extern void mark_value_bytes_optimized_out (struct value *value, - int offset, int length); - -/* Mark VALUE's content bits starting at OFFSET and extending for - LENGTH bits as optimized out. */ - -extern void mark_value_bits_optimized_out (struct value *value, - LONGEST offset, LONGEST length); - /* Set COMPONENT's location as appropriate for a component of WHOLE --- regardless of what kind of lvalue WHOLE is. */ extern void set_value_component_location (struct value *component, @@ -843,42 +873,6 @@ extern struct value *coerce_ref (struct value *value); extern struct value *coerce_array (struct value *value); -/* 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 - byte is unavailable. */ - -extern int value_bytes_available (const struct value *value, - LONGEST offset, LONGEST length); - -/* Given a value, determine whether the contents bits starting at - OFFSET and extending for LENGTH bits are available. This returns - nonzero if all bits in the given range are available, zero if any - bit is unavailable. */ - -extern int value_bits_available (const struct value *value, - LONGEST offset, LONGEST length); - -/* Like value_bytes_available, but return false if any byte in the - whole object is unavailable. */ -extern int value_entirely_available (struct value *value); - -/* Like value_entirely_available, but return false if any byte in the - whole object is available. */ -extern int value_entirely_unavailable (struct value *value); - -/* Mark VALUE's content bytes starting at OFFSET and extending for - LENGTH bytes as unavailable. */ - -extern void mark_value_bytes_unavailable (struct value *value, - LONGEST offset, LONGEST length); - -/* Mark VALUE's content bits starting at OFFSET and extending for - LENGTH bits as unavailable. */ - -extern void mark_value_bits_unavailable (struct value *value, - LONGEST offset, LONGEST length); - /* Read LENGTH addressable memory units starting at MEMADDR into BUFFER, which is (or will be copied to) VAL's contents buffer offset by BIT_OFFSET bits. Marks value contents ranges as unavailable if From patchwork Thu Feb 9 21:38:58 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tom Tromey X-Patchwork-Id: 64600 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 F3566382E686 for ; Thu, 9 Feb 2023 23:37:22 +0000 (GMT) X-Original-To: gdb-patches@sourceware.org Delivered-To: gdb-patches@sourceware.org Received: from progateway7-pub.mail.pro1.eigbox.com (gproxy5-pub.mail.unifiedlayer.com [67.222.38.55]) by sourceware.org (Postfix) with ESMTPS id F293B3858C2D for ; Thu, 9 Feb 2023 23:36:33 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org F293B3858C2D 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 cmgw10.mail.unifiedlayer.com (unknown [10.0.90.125]) by progateway7.mail.pro1.eigbox.com (Postfix) with ESMTP id 687221004817B for ; Thu, 9 Feb 2023 23:36:33 +0000 (UTC) Received: from box5379.bluehost.com ([162.241.216.53]) by cmsmtp with ESMTP id QGSvpxeHkOscKQGSvpXStb; Thu, 09 Feb 2023 23:36:33 +0000 X-Authority-Reason: nr=8 X-Authority-Analysis: v=2.4 cv=Y5c9DjSN c=1 sm=1 tr=0 ts=63e58381 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=ZyA2r0vRcygUns3lk1sA: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=y3ZJ1TB2Y0YrThJtgmBioznSpr+bNAoVZW0bI8LGMxQ=; b=PmCJD9R5wfjLNguQyZ8Nv0jsmw DIqJfMgxuT1+UTqh/GVC2wzgRlI6DzVTlFM6jYnyY7ZvCCkshV/BdcWMe3FOHGa2pv3+ekNjdd5+U kaPRX547FgqhJLSztBYA17uRq; 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 1pQEcu-001ZcE-Ns for gdb-patches@sourceware.org; Thu, 09 Feb 2023 14:38:44 -0700 From: Tom Tromey Date: Thu, 09 Feb 2023 14:38:58 -0700 Subject: [PATCH 37/47] Turn value_non_lval and value_force_lval into methods MIME-Version: 1.0 Message-Id: <20230209-submit-value-fixups-2023-v1-37-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: 1pQEcu-001ZcE-Ns 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: 4 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_non_lval and value_force_lval to be methods of value. --- gdb/eval.c | 6 +++--- gdb/infcall.c | 2 +- gdb/value.c | 30 +++++++++++++++--------------- gdb/value.h | 11 +++++++---- 4 files changed, 26 insertions(+), 23 deletions(-) diff --git a/gdb/eval.c b/gdb/eval.c index dca98d07fbe..808cc916bb4 100644 --- a/gdb/eval.c +++ b/gdb/eval.c @@ -111,7 +111,7 @@ expression::evaluate (struct type *expect_type, enum noside noside) if (stack_temporaries.has_value () && value_in_thread_stack_temporaries (retval, inferior_thread ())) - retval = value_non_lval (retval); + retval = retval->non_lval (); return retval; } @@ -1820,7 +1820,7 @@ eval_op_postinc (struct type *expect_type, struct expression *exp, } else { - struct value *arg3 = value_non_lval (arg1); + struct value *arg3 = arg1->non_lval (); struct value *arg2; if (ptrmath_type_p (exp->language_defn, arg1->type ())) @@ -1854,7 +1854,7 @@ eval_op_postdec (struct type *expect_type, struct expression *exp, } else { - struct value *arg3 = value_non_lval (arg1); + struct value *arg3 = arg1->non_lval (); struct value *arg2; if (ptrmath_type_p (exp->language_defn, arg1->type ())) diff --git a/gdb/infcall.c b/gdb/infcall.c index d6992228498..81a073d2123 100644 --- a/gdb/infcall.c +++ b/gdb/infcall.c @@ -492,7 +492,7 @@ get_call_return_value (struct call_return_meta_info *ri) requiring GDB to evaluate the "this" pointer. To evaluate the this pointer, GDB needs the memory address of the value. */ - value_force_lval (retval, ri->struct_addr); + retval->force_lval (ri->struct_addr); push_thread_stack_temporary (thr, retval); } } diff --git a/gdb/value.c b/gdb/value.c index a9db9e04bab..9cef9f4fcea 100644 --- a/gdb/value.c +++ b/gdb/value.c @@ -1432,35 +1432,35 @@ make_cv_value (int cnst, int voltl, struct value *v) return cv_val; } -/* Return a version of ARG that is non-lvalue. */ +/* See value.h. */ struct value * -value_non_lval (struct value *arg) +value::non_lval () { - if (VALUE_LVAL (arg) != not_lval) + if (VALUE_LVAL (this) != not_lval) { - struct type *enc_type = arg->enclosing_type (); + struct type *enc_type = enclosing_type (); struct value *val = value::allocate (enc_type); - gdb::copy (arg->contents_all (), val->contents_all_raw ()); - val->m_type = arg->m_type; - val->set_embedded_offset (arg->embedded_offset ()); - val->set_pointed_to_offset (arg->pointed_to_offset ()); + gdb::copy (contents_all (), val->contents_all_raw ()); + val->m_type = m_type; + val->set_embedded_offset (embedded_offset ()); + val->set_pointed_to_offset (pointed_to_offset ()); return val; } - return arg; + return this; } -/* Write contents of V at ADDR and set its lval type to be LVAL_MEMORY. */ +/* See value.h. */ void -value_force_lval (struct value *v, CORE_ADDR addr) +value::force_lval (CORE_ADDR addr) { - gdb_assert (VALUE_LVAL (v) == not_lval); + gdb_assert (VALUE_LVAL (this) == not_lval); - write_memory (addr, v->contents_raw ().data (), v->type ()->length ()); - v->m_lval = lval_memory; - v->m_location.address = addr; + write_memory (addr, contents_raw ().data (), type ()->length ()); + m_lval = lval_memory; + m_location.address = addr; } void diff --git a/gdb/value.h b/gdb/value.h index f46d0fc9d78..ba45ad64ff0 100644 --- a/gdb/value.h +++ b/gdb/value.h @@ -533,6 +533,13 @@ struct value for LENGTH bits as optimized out. */ void mark_bits_optimized_out (LONGEST offset, LONGEST length); + /* Return a version of this that is non-lvalue. */ + struct value *non_lval (); + + /* Write contents of this value at ADDR and set its lval type to be + LVAL_MEMORY. */ + void force_lval (CORE_ADDR); + /* Type of value; either not an lval, or one of the various different possible kinds of lval. */ @@ -1412,10 +1419,6 @@ extern void preserve_values (struct objfile *); /* From values.c */ -extern struct value *value_non_lval (struct value *); - -extern void value_force_lval (struct value *, CORE_ADDR); - extern struct value *make_cv_value (int, int, struct value *); extern void preserve_one_value (struct value *, struct objfile *, htab_t); From patchwork Thu Feb 9 21:38:59 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tom Tromey X-Patchwork-Id: 64603 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 F07FD3884578 for ; Thu, 9 Feb 2023 23:37:42 +0000 (GMT) X-Original-To: gdb-patches@sourceware.org Delivered-To: gdb-patches@sourceware.org Received: from gproxy3-pub.mail.unifiedlayer.com (gproxy3-pub.mail.unifiedlayer.com [69.89.30.42]) by sourceware.org (Postfix) with ESMTPS id 1E76D385840D for ; Thu, 9 Feb 2023 23:36:34 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 1E76D385840D 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 cmgw11.mail.unifiedlayer.com (unknown [10.0.90.126]) by progateway5.mail.pro1.eigbox.com (Postfix) with ESMTP id 8C3C810048771 for ; Thu, 9 Feb 2023 23:36:33 +0000 (UTC) Received: from box5379.bluehost.com ([162.241.216.53]) by cmsmtp with ESMTP id QGSvpjIhu2s14QGSvpj1Yu; Thu, 09 Feb 2023 23:36:33 +0000 X-Authority-Reason: nr=8 X-Authority-Analysis: v=2.4 cv=R7DGpfdX c=1 sm=1 tr=0 ts=63e58381 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=40k_50kCSyWTxUfR4oUA: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=VB5znTQ9vBmMglwuDObCi3naRvqCr9+SrlqSno3Fv44=; b=Wi6GJiZ17WgVSVb1R9365/uDkb ADwkm+L/wFzN4NDlKVPH1/p4vsE4M/Wwwl4wfkptatk5BYS1CuByfe2J0fMMfH4hBMQMPVfr1jBYz gtoUVteWjczAnnGNPST+dneGG; 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 1pQEcu-001ZcE-Ra for gdb-patches@sourceware.org; Thu, 09 Feb 2023 14:38:44 -0700 From: Tom Tromey Date: Thu, 09 Feb 2023 14:38:59 -0700 Subject: [PATCH 38/47] Turn set_value_component_location into method MIME-Version: 1.0 Message-Id: <20230209-submit-value-fixups-2023-v1-38-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: 1pQEcu-001ZcE-Ra 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: 5 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 turns set_value_component_location into a method of value. --- gdb/ada-lang.c | 4 ++-- gdb/valarith.c | 2 +- gdb/valops.c | 2 +- gdb/value.c | 29 ++++++++++++++--------------- gdb/value.h | 9 ++++----- 5 files changed, 22 insertions(+), 24 deletions(-) diff --git a/gdb/ada-lang.c b/gdb/ada-lang.c index 1b0dc2291d0..37aea44b8d5 100644 --- a/gdb/ada-lang.c +++ b/gdb/ada-lang.c @@ -567,7 +567,7 @@ coerce_unspec_val_to_type (struct value *val, struct type *type) result = value::allocate (type); value_contents_copy (result, 0, val, 0, type->length ()); } - set_value_component_location (result, val); + result->set_component_location (val); result->set_bitsize (val->bitsize ()); result->set_bitpos (val->bitpos ()); if (VALUE_LVAL (result) == lval_memory) @@ -2830,7 +2830,7 @@ ada_value_primitive_packed_val (struct value *obj, const gdb_byte *valaddr, { long new_offset = offset; - set_value_component_location (v, obj); + v->set_component_location (obj); v->set_bitpos (bit_offset + obj->bitpos ()); v->set_bitsize (bit_size); if (v->bitpos () >= HOST_CHAR_BIT) diff --git a/gdb/valarith.c b/gdb/valarith.c index a453eb1f40d..328781ba784 100644 --- a/gdb/valarith.c +++ b/gdb/valarith.c @@ -94,7 +94,7 @@ value_ptradd (struct value *arg1, LONGEST arg2) result = value_from_pointer (valptrtype, value_as_address (arg1) + sz * arg2); if (VALUE_LVAL (result) != lval_internalvar) - set_value_component_location (result, arg1); + result->set_component_location (arg1); return result; } diff --git a/gdb/valops.c b/gdb/valops.c index 656ed700fb1..85add0c7f9a 100644 --- a/gdb/valops.c +++ b/gdb/valops.c @@ -4087,7 +4087,7 @@ value_slice (struct value *array, int lowbound, int length) type_length_units (slice_type)); } - set_value_component_location (slice, array); + slice->set_component_location (array); slice->set_offset (array->offset () + offset); } diff --git a/gdb/value.c b/gdb/value.c index 9cef9f4fcea..bb23ff2dc40 100644 --- a/gdb/value.c +++ b/gdb/value.c @@ -1464,25 +1464,24 @@ value::force_lval (CORE_ADDR addr) } void -set_value_component_location (struct value *component, - const struct value *whole) +value::set_component_location (const struct value *whole) { struct type *type; gdb_assert (whole->m_lval != lval_xcallable); if (whole->m_lval == lval_internalvar) - VALUE_LVAL (component) = lval_internalvar_component; + VALUE_LVAL (this) = lval_internalvar_component; else - VALUE_LVAL (component) = whole->m_lval; + VALUE_LVAL (this) = whole->m_lval; - component->m_location = whole->m_location; + m_location = whole->m_location; if (whole->m_lval == lval_computed) { const struct lval_funcs *funcs = whole->m_location.computed.funcs; if (funcs->copy_closure) - component->m_location.computed.closure = funcs->copy_closure (whole); + m_location.computed.closure = funcs->copy_closure (whole); } /* If the WHOLE value has a dynamically resolved location property then @@ -1490,11 +1489,11 @@ set_value_component_location (struct value *component, type = whole->type (); if (NULL != TYPE_DATA_LOCATION (type) && TYPE_DATA_LOCATION_KIND (type) == PROP_CONST) - component->set_address (TYPE_DATA_LOCATION_ADDR (type)); + set_address (TYPE_DATA_LOCATION_ADDR (type)); /* Similarly, if the COMPONENT value has a dynamically resolved location property then update its address. */ - type = component->type (); + type = this->type (); if (NULL != TYPE_DATA_LOCATION (type) && TYPE_DATA_LOCATION_KIND (type) == PROP_CONST) { @@ -1515,14 +1514,14 @@ set_value_component_location (struct value *component, carry around both the parent value contents, and the contents of any dynamic fields within the parent. This is a substantial change to how values work in GDB. */ - if (VALUE_LVAL (component) == lval_internalvar_component) + if (VALUE_LVAL (this) == lval_internalvar_component) { - gdb_assert (component->lazy ()); - VALUE_LVAL (component) = lval_memory; + gdb_assert (lazy ()); + VALUE_LVAL (this) = lval_memory; } else - gdb_assert (VALUE_LVAL (component) == lval_memory); - component->set_address (TYPE_DATA_LOCATION_ADDR (type)); + gdb_assert (VALUE_LVAL (this) == lval_memory); + set_address (TYPE_DATA_LOCATION_ADDR (type)); } } @@ -2825,7 +2824,7 @@ value_primitive_field (struct value *arg1, LONGEST offset, v->m_offset = (arg1->offset () + offset + arg1->embedded_offset ()); } - set_value_component_location (v, arg1); + v->set_component_location (arg1); return v; } @@ -3423,7 +3422,7 @@ value_from_component (struct value *whole, struct type *type, LONGEST offset) type_length_units (type)); } v->m_offset = whole->offset () + offset + whole->embedded_offset (); - set_value_component_location (v, whole); + v->set_component_location (whole); return v; } diff --git a/gdb/value.h b/gdb/value.h index ba45ad64ff0..46b7e62e610 100644 --- a/gdb/value.h +++ b/gdb/value.h @@ -540,6 +540,10 @@ struct value LVAL_MEMORY. */ void force_lval (CORE_ADDR); + /* Set this values's location as appropriate for a component of + WHOLE --- regardless of what kind of lvalue WHOLE is. */ + void set_component_location (const struct value *whole); + /* Type of value; either not an lval, or one of the various different possible kinds of lval. */ @@ -824,11 +828,6 @@ struct lval_funcs extern void error_value_optimized_out (void); -/* Set COMPONENT's location as appropriate for a component of WHOLE - --- regardless of what kind of lvalue WHOLE is. */ -extern void set_value_component_location (struct value *component, - const struct value *whole); - /* While the following fields are per- VALUE .CONTENT .PIECE (i.e., a single value might have multiple LVALs), this hacked interface is limited to just the first PIECE. Expect further change. */ From patchwork Thu Feb 9 21:39:00 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tom Tromey X-Patchwork-Id: 64599 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 BC67A38493E6 for ; Thu, 9 Feb 2023 23:37:02 +0000 (GMT) X-Original-To: gdb-patches@sourceware.org Delivered-To: gdb-patches@sourceware.org Received: from outbound-ss-820.bluehost.com (outbound-ss-820.bluehost.com [69.89.24.241]) by sourceware.org (Postfix) with ESMTPS id 3F87F3858414 for ; Thu, 9 Feb 2023 23:36:34 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 3F87F3858414 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 cmgw15.mail.unifiedlayer.com (unknown [10.0.90.130]) by progateway2.mail.pro1.eigbox.com (Postfix) with ESMTP id AE9D910047FAA for ; Thu, 9 Feb 2023 23:36:33 +0000 (UTC) Received: from box5379.bluehost.com ([162.241.216.53]) by cmsmtp with ESMTP id QGSvpaODqbdcfQGSvp8gOA; Thu, 09 Feb 2023 23:36:33 +0000 X-Authority-Reason: nr=8 X-Authority-Analysis: v=2.4 cv=AZB0o1bG c=1 sm=1 tr=0 ts=63e58381 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=RxpNcV5vAaEiEZTR0RsA: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=NbkAP7cl6wtKslfIoyFXDC+eKw2bwWGZo46haCIM8vE=; b=Fogt1FVAF2vuXTwizmfxq8v7Mz 14z8bpoZifMWd5agXVWoPHOHl4kV+PI3fzIiMExWbRGXtFZv8v7S18Po5G8LFoFgyZMyvFtz9t27+ Vw7Y6zGspFnyLsaZ77BzdNprM; 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 1pQEcu-001ZcE-VK for gdb-patches@sourceware.org; Thu, 09 Feb 2023 14:38:44 -0700 From: Tom Tromey Date: Thu, 09 Feb 2023 14:39:00 -0700 Subject: [PATCH 39/47] Change some code to use value methods MIME-Version: 1.0 Message-Id: <20230209-submit-value-fixups-2023-v1-39-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: 1pQEcu-001ZcE-VK 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: 6 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" A few functions in value.c were accessing the internal fields of struct value. However, in these cases it seemed simpler to change them to use the public API rather than convert them to be methods. --- gdb/value.c | 30 +++++++++++++++--------------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/gdb/value.c b/gdb/value.c index bb23ff2dc40..265feee1e4b 100644 --- a/gdb/value.c +++ b/gdb/value.c @@ -819,7 +819,7 @@ value::allocate (struct type *type) struct value *val = value::allocate_lazy (type); val->allocate_contents (); - val->m_lazy = 0; + val->set_lazy (0); return val; } @@ -1931,7 +1931,7 @@ value_of_internalvar (struct gdbarch *gdbarch, struct internalvar *var) want. */ if (var->kind != INTERNALVAR_MAKE_VALUE - && val->m_lval != lval_computed) + && val->lval () != lval_computed) { VALUE_LVAL (val) = lval_internalvar; VALUE_INTERNALVAR (val) = var; @@ -2743,15 +2743,15 @@ value_primitive_field (struct value *arg1, LONGEST offset, LONGEST container_bitsize = type->length () * 8; v = value::allocate_lazy (type); - v->m_bitsize = TYPE_FIELD_BITSIZE (arg_type, fieldno); - if ((bitpos % container_bitsize) + v->m_bitsize <= container_bitsize + v->set_bitsize (TYPE_FIELD_BITSIZE (arg_type, fieldno)); + if ((bitpos % container_bitsize) + v->bitsize () <= container_bitsize && type->length () <= (int) sizeof (LONGEST)) - v->m_bitpos = bitpos % container_bitsize; + v->set_bitpos (bitpos % container_bitsize); else - v->m_bitpos = bitpos % 8; - v->m_offset = (arg1->embedded_offset () - + offset - + (bitpos - v->m_bitpos) / 8); + v->set_bitpos (bitpos % 8); + v->set_offset ((arg1->embedded_offset () + + offset + + (bitpos - v->bitpos ()) / 8)); v->set_parent (arg1); if (!arg1->lazy ()) v->fetch_lazy (); @@ -2787,9 +2787,9 @@ value_primitive_field (struct value *arg1, LONGEST offset, value_contents_copy_raw (v, 0, arg1, 0, arg1->enclosing_type ()->length ()); } - v->m_type = type; - v->m_offset = arg1->offset (); - v->m_embedded_offset = offset + arg1->embedded_offset () + boffset; + v->deprecated_set_type (type); + v->set_offset (arg1->offset ()); + v->set_embedded_offset (offset + arg1->embedded_offset () + boffset); } else if (NULL != TYPE_DATA_LOCATION (type)) { @@ -2821,8 +2821,8 @@ value_primitive_field (struct value *arg1, LONGEST offset, arg1, arg1->embedded_offset () + offset, type_length_units (type)); } - v->m_offset = (arg1->offset () + offset - + arg1->embedded_offset ()); + v->set_offset ((arg1->offset () + offset + + arg1->embedded_offset ())); } v->set_component_location (arg1); return v; @@ -3421,7 +3421,7 @@ value_from_component (struct value *whole, struct type *type, LONGEST offset) whole, whole->embedded_offset () + offset, type_length_units (type)); } - v->m_offset = whole->offset () + offset + whole->embedded_offset (); + v->set_offset (whole->offset () + offset + whole->embedded_offset ()); v->set_component_location (whole); return v; From patchwork Thu Feb 9 21:39:01 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tom Tromey X-Patchwork-Id: 64610 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 5EF48382E6A6 for ; Thu, 9 Feb 2023 23:38:30 +0000 (GMT) X-Original-To: gdb-patches@sourceware.org Delivered-To: gdb-patches@sourceware.org Received: from gproxy1-pub.mail.unifiedlayer.com (gproxy1-pub.mail.unifiedlayer.com [69.89.25.95]) by sourceware.org (Postfix) with ESMTPS id 89714386EC0C for ; Thu, 9 Feb 2023 23:37:20 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 89714386EC0C 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 cmgw15.mail.unifiedlayer.com (unknown [10.0.90.130]) by progateway3.mail.pro1.eigbox.com (Postfix) with ESMTP id 01B5A10047A87 for ; Thu, 9 Feb 2023 23:37:20 +0000 (UTC) Received: from box5379.bluehost.com ([162.241.216.53]) by cmsmtp with ESMTP id QGTfpaOgIbdcfQGTfp8gqN; Thu, 09 Feb 2023 23:37:19 +0000 X-Authority-Reason: nr=8 X-Authority-Analysis: v=2.4 cv=AZB0o1bG c=1 sm=1 tr=0 ts=63e583af 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=R80hmTpovpAVeOU5vtMA: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=wBoWnSHTrUnLHaHtP/5tXUiqOyPOepSyoWFzoipkkA8=; b=wpGeEEdeRFkCabaJFsm6+C8Fs0 F01TRKgjZlBertgA+gbQILmNF41uMshEYFJrM3IpAHr819Xffa3vdEx3LWhcdhhNLQOWIv37zcSKf g9lsCeCMKdM/GONqywVdmKzk1; 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 1pQEcv-001ZcE-2v for gdb-patches@sourceware.org; Thu, 09 Feb 2023 14:38:45 -0700 From: Tom Tromey Date: Thu, 09 Feb 2023 14:39:01 -0700 Subject: [PATCH 40/47] Turn some xmethod functions into methods MIME-Version: 1.0 Message-Id: <20230209-submit-value-fixups-2023-v1-40-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: 1pQEcv-001ZcE-2v 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: 18 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 turns value_from_xmethod, result_type_of_xmethod, and call_xmethod to be methods of value. value_from_xmethod is a static "constructor" now. --- gdb/eval.c | 4 ++-- gdb/valarith.c | 8 ++++---- gdb/valops.c | 2 +- gdb/value.c | 22 +++++++++++----------- gdb/value.h | 22 +++++++++++----------- 5 files changed, 29 insertions(+), 29 deletions(-) diff --git a/gdb/eval.c b/gdb/eval.c index 808cc916bb4..b263dc998d6 100644 --- a/gdb/eval.c +++ b/gdb/eval.c @@ -640,7 +640,7 @@ evaluate_subexp_do_call (expression *exp, enum noside noside, } else if (ftype->code () == TYPE_CODE_XMETHOD) { - type *return_type = result_type_of_xmethod (callee, argvec); + type *return_type = callee->result_type_of_xmethod (argvec); if (return_type == NULL) error (_("Xmethod is missing return type.")); @@ -678,7 +678,7 @@ evaluate_subexp_do_call (expression *exp, enum noside noside, return call_internal_function (exp->gdbarch, exp->language_defn, callee, argvec.size (), argvec.data ()); case TYPE_CODE_XMETHOD: - return call_xmethod (callee, argvec); + return callee->call_xmethod (argvec); default: return call_function_by_hand (callee, default_return_type, argvec); } diff --git a/gdb/valarith.c b/gdb/valarith.c index 328781ba784..117662fda95 100644 --- a/gdb/valarith.c +++ b/gdb/valarith.c @@ -513,13 +513,13 @@ value_x_binop (struct value *arg1, struct value *arg2, enum exp_opcode op, if (noside == EVAL_AVOID_SIDE_EFFECTS) { struct type *return_type - = result_type_of_xmethod (argvec[0], argvec.slice (1)); + = argvec[0]->result_type_of_xmethod (argvec.slice (1)); if (return_type == NULL) error (_("Xmethod is missing return type.")); return value::zero (return_type, VALUE_LVAL (arg1)); } - return call_xmethod (argvec[0], argvec.slice (1)); + return argvec[0]->call_xmethod (argvec.slice (1)); } if (noside == EVAL_AVOID_SIDE_EFFECTS) { @@ -626,13 +626,13 @@ value_x_unop (struct value *arg1, enum exp_opcode op, enum noside noside) if (noside == EVAL_AVOID_SIDE_EFFECTS) { struct type *return_type - = result_type_of_xmethod (argvec[0], argvec[1]); + = argvec[0]->result_type_of_xmethod (argvec[1]); if (return_type == NULL) error (_("Xmethod is missing return type.")); return value::zero (return_type, VALUE_LVAL (arg1)); } - return call_xmethod (argvec[0], argvec[1]); + return argvec[0]->call_xmethod (argvec[1]); } if (noside == EVAL_AVOID_SIDE_EFFECTS) { diff --git a/gdb/valops.c b/gdb/valops.c index 85add0c7f9a..5cada155073 100644 --- a/gdb/valops.c +++ b/gdb/valops.c @@ -3028,7 +3028,7 @@ find_overload_match (gdb::array_view args, method_oload_champ, basetype, boffset); } else - *valp = value_from_xmethod + *valp = value::from_xmethod (std::move (xmethods[ext_method_oload_champ])); } else diff --git a/gdb/value.c b/gdb/value.c index 265feee1e4b..f902d121d9c 100644 --- a/gdb/value.c +++ b/gdb/value.c @@ -2356,7 +2356,7 @@ show_convenience (const char *ignore, int from_tty) /* See value.h. */ struct value * -value_from_xmethod (xmethod_worker_up &&worker) +value::from_xmethod (xmethod_worker_up &&worker) { struct value *v; @@ -2368,26 +2368,26 @@ value_from_xmethod (xmethod_worker_up &&worker) return v; } -/* Return the type of the result of TYPE_CODE_XMETHOD value METHOD. */ +/* See value.h. */ struct type * -result_type_of_xmethod (struct value *method, gdb::array_view argv) +value::result_type_of_xmethod (gdb::array_view argv) { - gdb_assert (method->type ()->code () == TYPE_CODE_XMETHOD - && method->m_lval == lval_xcallable && !argv.empty ()); + gdb_assert (type ()->code () == TYPE_CODE_XMETHOD + && m_lval == lval_xcallable && !argv.empty ()); - return method->m_location.xm_worker->get_result_type (argv[0], argv.slice (1)); + return m_location.xm_worker->get_result_type (argv[0], argv.slice (1)); } -/* Call the xmethod corresponding to the TYPE_CODE_XMETHOD value METHOD. */ +/* See value.h. */ struct value * -call_xmethod (struct value *method, gdb::array_view argv) +value::call_xmethod (gdb::array_view argv) { - gdb_assert (method->type ()->code () == TYPE_CODE_XMETHOD - && method->m_lval == lval_xcallable && !argv.empty ()); + gdb_assert (type ()->code () == TYPE_CODE_XMETHOD + && m_lval == lval_xcallable && !argv.empty ()); - return method->m_location.xm_worker->invoke (argv[0], argv.slice (1)); + return m_location.xm_worker->invoke (argv[0], argv.slice (1)); } /* Extract a value as a C number (either long or double). diff --git a/gdb/value.h b/gdb/value.h index 46b7e62e610..b331f90edd4 100644 --- a/gdb/value.h +++ b/gdb/value.h @@ -544,6 +544,17 @@ struct value WHOLE --- regardless of what kind of lvalue WHOLE is. */ void set_component_location (const struct value *whole); + /* Build a value wrapping and representing WORKER. The value takes + ownership of the xmethod_worker object. */ + static struct value *from_xmethod (xmethod_worker_up &&worker); + + /* Return the type of the result of TYPE_CODE_XMETHOD value METHOD. */ + struct type *result_type_of_xmethod (gdb::array_view argv); + + /* Call the xmethod corresponding to the TYPE_CODE_XMETHOD value + METHOD. */ + struct value *call_xmethod (gdb::array_view argv); + /* Type of value; either not an lval, or one of the various different possible kinds of lval. */ @@ -1480,17 +1491,6 @@ struct value *call_internal_function (struct gdbarch *gdbarch, const char *value_internal_function_name (struct value *); -/* Build a value wrapping and representing WORKER. The value takes ownership - of the xmethod_worker object. */ - -extern struct value *value_from_xmethod (xmethod_worker_up &&worker); - -extern struct type *result_type_of_xmethod (struct value *method, - gdb::array_view argv); - -extern struct value *call_xmethod (struct value *method, - gdb::array_view argv); - /* Destroy the values currently allocated. This is called when GDB is exiting (e.g., on quit_force). */ extern void finalize_values (); From patchwork Thu Feb 9 21:39:02 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tom Tromey X-Patchwork-Id: 64614 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 5C4CB388B6A5 for ; Thu, 9 Feb 2023 23:39:20 +0000 (GMT) X-Original-To: gdb-patches@sourceware.org Delivered-To: gdb-patches@sourceware.org Received: from gproxy1-pub.mail.unifiedlayer.com (gproxy1-pub.mail.unifiedlayer.com [69.89.25.95]) by sourceware.org (Postfix) with ESMTPS id 665DC3853573 for ; Thu, 9 Feb 2023 23:37:20 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 665DC3853573 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 cmgw13.mail.unifiedlayer.com (unknown [10.0.90.128]) by progateway3.mail.pro1.eigbox.com (Postfix) with ESMTP id D172010047A8A for ; Thu, 9 Feb 2023 23:37:19 +0000 (UTC) Received: from box5379.bluehost.com ([162.241.216.53]) by cmsmtp with ESMTP id QGTfpJFQ8NX2aQGTfp4EHy; Thu, 09 Feb 2023 23:37:19 +0000 X-Authority-Reason: nr=8 X-Authority-Analysis: v=2.4 cv=NMAQR22g c=1 sm=1 tr=0 ts=63e583af 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=NKo4NCb8YE0nb4qGYwcA: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=6hsW63894FWdEPtIMk7ThFERbJFTyq7Qs3mBCeXbPSk=; b=E//LQtWiDabygjEv1d0d7LYObn 7y/v4TsZ+OxYcUjznpVQlSwhS9lwZYVVM/08zz2uOXBkeemrsd3lRmCxz7RxPIiyp+Bh8PLqsLF88 hgaZ+ACn/bZVdGyzz7t7yHXQu; 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 1pQEcv-001ZcE-6h for gdb-patches@sourceware.org; Thu, 09 Feb 2023 14:38:45 -0700 From: Tom Tromey Date: Thu, 09 Feb 2023 14:39:02 -0700 Subject: [PATCH 41/47] Turn preserve_one_value into method MIME-Version: 1.0 Message-Id: <20230209-submit-value-fixups-2023-v1-41-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: 1pQEcv-001ZcE-6h 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: 17 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 preserve_one_value to be a method of value. Much of this patch was written by script. --- gdb/guile/scm-value.c | 2 +- gdb/python/py-value.c | 2 +- gdb/value.c | 21 ++++++++------------- gdb/value.h | 6 ++++-- 4 files changed, 14 insertions(+), 17 deletions(-) diff --git a/gdb/guile/scm-value.c b/gdb/guile/scm-value.c index 3e18bd1fdc3..a0b7e6661b5 100644 --- a/gdb/guile/scm-value.c +++ b/gdb/guile/scm-value.c @@ -91,7 +91,7 @@ gdbscm_preserve_values (const struct extension_language_defn *extlang, value_smob *iter; for (iter = values_in_scheme; iter; iter = iter->next) - preserve_one_value (iter->value, objfile, copied_types); + iter->value->preserve (objfile, copied_types); } /* Helper to add a value_smob to the global list. */ diff --git a/gdb/python/py-value.c b/gdb/python/py-value.c index 6c33e3529c8..658a9a3f18c 100644 --- a/gdb/python/py-value.c +++ b/gdb/python/py-value.c @@ -228,7 +228,7 @@ gdbpy_preserve_values (const struct extension_language_defn *extlang, value_object *iter; for (iter = values_in_python; iter; iter = iter->next) - preserve_one_value (iter->value, objfile, copied_types); + iter->value->preserve (objfile, copied_types); } /* Given a value of a pointer type, apply the C unary * operator to it. */ diff --git a/gdb/value.c b/gdb/value.c index f902d121d9c..7433e698a44 100644 --- a/gdb/value.c +++ b/gdb/value.c @@ -2219,19 +2219,14 @@ add_internal_function (gdb::unique_xmalloc_ptr &&name, cmd->name_allocated = 1; } -/* Update VALUE before discarding OBJFILE. COPIED_TYPES is used to - prevent cycles / duplicates. */ - void -preserve_one_value (struct value *value, struct objfile *objfile, - htab_t copied_types) +value::preserve (struct objfile *objfile, htab_t copied_types) { - if (value->m_type->objfile_owner () == objfile) - value->m_type = copy_type_recursive (value->m_type, copied_types); + if (m_type->objfile_owner () == objfile) + m_type = copy_type_recursive (m_type, copied_types); - if (value->m_enclosing_type->objfile_owner () == objfile) - value->m_enclosing_type = copy_type_recursive (value->m_enclosing_type, - copied_types); + if (m_enclosing_type->objfile_owner () == objfile) + m_enclosing_type = copy_type_recursive (m_enclosing_type, copied_types); } /* Likewise for internal variable VAR. */ @@ -2250,7 +2245,7 @@ preserve_one_internalvar (struct internalvar *var, struct objfile *objfile, break; case INTERNALVAR_VALUE: - preserve_one_value (var->u.value, objfile, copied_types); + var->u.value->preserve (objfile, copied_types); break; } } @@ -2271,7 +2266,7 @@ preserve_one_varobj (struct varobj *varobj, struct objfile *objfile, } if (varobj->value != nullptr) - preserve_one_value (varobj->value.get (), objfile, copied_types); + varobj->value.get ()->preserve (objfile, copied_types); } /* Update the internal variables and value history when OBJFILE is @@ -2290,7 +2285,7 @@ preserve_values (struct objfile *objfile) htab_up copied_types = create_copied_types_hash (); for (const value_ref_ptr &item : value_history) - preserve_one_value (item.get (), objfile, copied_types.get ()); + item.get ()->preserve (objfile, copied_types.get ()); for (var = internalvars; var; var = var->next) preserve_one_internalvar (var, objfile, copied_types.get ()); diff --git a/gdb/value.h b/gdb/value.h index b331f90edd4..95573a55d99 100644 --- a/gdb/value.h +++ b/gdb/value.h @@ -555,6 +555,10 @@ struct value METHOD. */ struct value *call_xmethod (gdb::array_view argv); + /* Update this value before discarding OBJFILE. COPIED_TYPES is + used to prevent cycles / duplicates. */ + void preserve (struct objfile *objfile, htab_t copied_types); + /* Type of value; either not an lval, or one of the various different possible kinds of lval. */ @@ -1431,8 +1435,6 @@ extern void preserve_values (struct objfile *); extern struct value *make_cv_value (int, int, struct value *); -extern void preserve_one_value (struct value *, struct objfile *, htab_t); - /* From valops.c */ extern struct value *varying_to_slice (struct value *); From patchwork Thu Feb 9 21:39:03 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tom Tromey X-Patchwork-Id: 64612 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 2D1A0385B53C for ; Thu, 9 Feb 2023 23:38:46 +0000 (GMT) X-Original-To: gdb-patches@sourceware.org Delivered-To: gdb-patches@sourceware.org Received: from outbound-ss-820.bluehost.com (outbound-ss-820.bluehost.com [69.89.24.241]) by sourceware.org (Postfix) with ESMTPS id 3C7763846054 for ; Thu, 9 Feb 2023 23:37:20 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 3C7763846054 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 cmgw14.mail.unifiedlayer.com (unknown [10.0.90.129]) by progateway2.mail.pro1.eigbox.com (Postfix) with ESMTP id AC0C9100478D5 for ; Thu, 9 Feb 2023 23:37:19 +0000 (UTC) Received: from box5379.bluehost.com ([162.241.216.53]) by cmsmtp with ESMTP id QGTfpMjdbGAj8QGTfpjA8f; Thu, 09 Feb 2023 23:37:19 +0000 X-Authority-Reason: nr=8 X-Authority-Analysis: v=2.4 cv=UdyU9IeN c=1 sm=1 tr=0 ts=63e583af 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=8xypBqB_5mXeirqxGCoA: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=o1qINpdJbdRNgnA9tdJkNagtPJglYKjercMGBihfCco=; b=ET6ZuD+zJ3asXp2TRcqkqn3jMB vLuDX/tkSlkdxzrqBRhDYibDPG7KsRI3RkT6mK/8tlMWp56mrzMYwhDT8gUiUkjn2PG/f/uzWnCT6 3jyRtelLCF6X/9hrW9Y107+y4; 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 1pQEcv-001ZcE-Al for gdb-patches@sourceware.org; Thu, 09 Feb 2023 14:38:45 -0700 From: Tom Tromey Date: Thu, 09 Feb 2023 14:39:03 -0700 Subject: [PATCH 42/47] Turn various value copying-related functions into methods MIME-Version: 1.0 Message-Id: <20230209-submit-value-fixups-2023-v1-42-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: 1pQEcv-001ZcE-Al 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: 16 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 patch turns a grab bag of value functions to methods of value. These are done together because their implementations are interrelated. --- gdb/aarch64-tdep.c | 2 +- gdb/ada-lang.c | 4 +- gdb/breakpoint.c | 11 ++- gdb/c-varobj.c | 2 +- gdb/cp-valprint.c | 6 +- gdb/dwarf2/expr.c | 4 +- gdb/eval.c | 2 +- gdb/f-lang.c | 8 +- gdb/findvar.c | 2 +- gdb/gnu-v2-abi.c | 2 +- gdb/p-valprint.c | 6 +- gdb/rust-lang.c | 6 +- gdb/valops.c | 15 ++-- gdb/valprint.c | 12 +-- gdb/value.c | 219 +++++++++++++++++++++++------------------------------ gdb/value.h | 97 +++++++++++++++++------- 16 files changed, 202 insertions(+), 196 deletions(-) diff --git a/gdb/aarch64-tdep.c b/gdb/aarch64-tdep.c index a4f71f246c6..fa8db9c788d 100644 --- a/gdb/aarch64-tdep.c +++ b/gdb/aarch64-tdep.c @@ -1799,7 +1799,7 @@ pass_in_v_vfp_candidate (struct gdbarch *gdbarch, struct regcache *regcache, if (field_is_static (&arg_type->field (i))) continue; - struct value *field = value_primitive_field (arg, 0, i, arg_type); + struct value *field = arg->primitive_field (0, i, arg_type); struct type *field_type = check_typedef (field->type ()); if (!pass_in_v_vfp_candidate (gdbarch, regcache, info, field_type, diff --git a/gdb/ada-lang.c b/gdb/ada-lang.c index 37aea44b8d5..cc69281075e 100644 --- a/gdb/ada-lang.c +++ b/gdb/ada-lang.c @@ -565,7 +565,7 @@ coerce_unspec_val_to_type (struct value *val, struct type *type) else { result = value::allocate (type); - value_contents_copy (result, 0, val, 0, type->length ()); + val->contents_copy (result, 0, 0, type->length ()); } result->set_component_location (val); result->set_bitsize (val->bitsize ()); @@ -6929,7 +6929,7 @@ ada_value_primitive_field (struct value *arg1, int offset, int fieldno, bit_pos % 8, bit_size, type); } else - return value_primitive_field (arg1, offset, fieldno, arg_type); + return arg1->primitive_field (offset, fieldno, arg_type); } /* Find field with name NAME in object of type TYPE. If found, diff --git a/gdb/breakpoint.c b/gdb/breakpoint.c index 1ffdb4bf33d..2ccc7c97b4c 100644 --- a/gdb/breakpoint.c +++ b/gdb/breakpoint.c @@ -1858,12 +1858,11 @@ extract_bitfield_from_watchpoint_value (struct watchpoint *w, struct value *val) bit_val = value::allocate (val->type ()); - unpack_value_bitfield (bit_val, - w->val_bitpos, - w->val_bitsize, - val->contents_for_printing ().data (), - val->offset (), - val); + val->unpack_bitfield (bit_val, + w->val_bitpos, + w->val_bitsize, + val->contents_for_printing ().data (), + val->offset ()); return bit_val; } diff --git a/gdb/c-varobj.c b/gdb/c-varobj.c index 00094244ff1..3e3919a65c0 100644 --- a/gdb/c-varobj.c +++ b/gdb/c-varobj.c @@ -257,7 +257,7 @@ value_struct_element_index (struct value *value, int type_index) if (field_is_static (&type->field (type_index))) result = value_static_field (type, type_index); else - result = value_primitive_field (value, 0, type_index, type); + result = value->primitive_field (0, type_index, type); } catch (const gdb_exception_error &e) { diff --git a/gdb/cp-valprint.c b/gdb/cp-valprint.c index 37147749619..167cf0314af 100644 --- a/gdb/cp-valprint.c +++ b/gdb/cp-valprint.c @@ -330,7 +330,7 @@ cp_print_value_fields (struct value *val, struct ui_file *stream, } else { - struct value *v = value_primitive_field (val, 0, i, type); + struct value *v = val->primitive_field (0, i, type); opts->deref_ref = false; common_val_print (v, stream, recurse + 1, opts, current_language); @@ -498,8 +498,8 @@ cp_print_value (struct value *val, struct ui_file *stream, if (!val_print_check_max_depth (stream, recurse, options, current_language)) { - struct value *baseclass_val = value_primitive_field (val, 0, - i, type); + struct value *baseclass_val = val->primitive_field (0, + i, type); /* Attempt to run an extension language pretty-printer on the baseclass if possible. */ diff --git a/gdb/dwarf2/expr.c b/gdb/dwarf2/expr.c index 45bdb007420..60d9bf5f1f9 100644 --- a/gdb/dwarf2/expr.c +++ b/gdb/dwarf2/expr.c @@ -969,8 +969,8 @@ dwarf_expr_context::fetch_result (struct type *type, struct type *subobj_type, generic optimized out value instead, so that we show instead of . */ value *tmp = value::allocate (subobj_type); - value_contents_copy (tmp, 0, retval, 0, - subobj_type->length ()); + retval->contents_copy (tmp, 0, 0, + subobj_type->length ()); retval = tmp; } } diff --git a/gdb/eval.c b/gdb/eval.c index b263dc998d6..2bff97227dd 100644 --- a/gdb/eval.c +++ b/gdb/eval.c @@ -2570,7 +2570,7 @@ unop_extract_operation::evaluate (struct type *expect_type, error (_("length type is larger than the value type")); struct value *result = value::allocate (type); - value_contents_copy (result, 0, old_value, 0, type->length ()); + old_value->contents_copy (result, 0, 0, type->length ()); return result; } diff --git a/gdb/f-lang.c b/gdb/f-lang.c index f883b08e2ae..d935f59088f 100644 --- a/gdb/f-lang.c +++ b/gdb/f-lang.c @@ -159,7 +159,7 @@ fortran_bounds_all_dims (bool lbound_p, gdb_assert (dst_offset + v->type ()->length () <= result->type ()->length ()); gdb_assert (v->type ()->length () == elm_len); - value_contents_copy (result, dst_offset, v, 0, elm_len); + v->contents_copy (result, dst_offset, 0, elm_len); /* Peel another dimension of the array. */ array_type = array_type->target_type (); @@ -282,8 +282,8 @@ class fortran_array_repacker_base_impl available offset. */ void copy_element_to_dest (struct value *elt) { - value_contents_copy (m_dest, m_dest_offset, elt, 0, - elt->type ()->length ()); + elt->contents_copy (m_dest, m_dest_offset, 0, + elt->type ()->length ()); m_dest_offset += elt->type ()->length (); } @@ -744,7 +744,7 @@ fortran_array_shape (struct gdbarch *gdbarch, const language_defn *lang, gdb_assert (dst_offset + v->type ()->length () <= result->type ()->length ()); gdb_assert (v->type ()->length () == elm_len); - value_contents_copy (result, dst_offset, v, 0, elm_len); + v->contents_copy (result, dst_offset, 0, elm_len); /* Peel another dimension of the array. */ val_type = val_type->target_type (); diff --git a/gdb/findvar.c b/gdb/findvar.c index 2a2c3eb2ab4..a82cf8c0afa 100644 --- a/gdb/findvar.c +++ b/gdb/findvar.c @@ -866,7 +866,7 @@ read_frame_register_value (struct value *value, frame_info_ptr frame) if (reg_len > len) reg_len = len; - value_contents_copy (value, offset, regval, reg_offset, reg_len); + regval->contents_copy (value, offset, reg_offset, reg_len); offset += reg_len; len -= reg_len; diff --git a/gdb/gnu-v2-abi.c b/gdb/gnu-v2-abi.c index e8202667e24..fa46d474914 100644 --- a/gdb/gnu-v2-abi.c +++ b/gdb/gnu-v2-abi.c @@ -127,7 +127,7 @@ gnuv2_virtual_fn_field (struct value **arg1p, struct fn_field * f, int j, /* The virtual function table is now an array of structures which have the form { int16 offset, delta; void *pfn; }. */ - vtbl = value_primitive_field (arg1, 0, context_vptr_fieldno, + vtbl = arg1->primitive_field (0, context_vptr_fieldno, context_vptr_basetype); /* With older versions of g++, the vtbl field pointed to an array diff --git a/gdb/p-valprint.c b/gdb/p-valprint.c index f13f0ef6625..d74c738bc22 100644 --- a/gdb/p-valprint.c +++ b/gdb/p-valprint.c @@ -654,8 +654,8 @@ pascal_object_print_value_fields (struct value *val, struct ui_file *stream, opts.deref_ref = false; - struct value *v = value_primitive_field (val, 0, i, - val->type ()); + struct value *v = val->primitive_field (0, i, + val->type ()); common_val_print (v, stream, recurse + 1, &opts, current_language); } @@ -729,7 +729,7 @@ pascal_object_print_value (struct value *val, struct ui_file *stream, struct value *base_value; try { - base_value = value_primitive_field (val, 0, i, type); + base_value = val->primitive_field (0, i, type); } catch (const gdb_exception_error &ex) { diff --git a/gdb/rust-lang.c b/gdb/rust-lang.c index a5be110a33b..013b8a4c0d2 100644 --- a/gdb/rust-lang.c +++ b/gdb/rust-lang.c @@ -1382,7 +1382,7 @@ rust_struct_anon::evaluate (struct type *expect_type, field_number, type->name ()); int fieldno = rust_enum_variant (type); - lhs = value_primitive_field (lhs, 0, fieldno, type); + lhs = lhs->primitive_field (0, fieldno, type); outer_type = type; type = lhs->type (); } @@ -1418,7 +1418,7 @@ rust_struct_anon::evaluate (struct type *expect_type, field_number, type->name ()); } - return value_primitive_field (lhs, 0, field_number, type); + return lhs->primitive_field (0, field_number, type); } else error(_("Anonymous field access is only allowed on tuples, \ @@ -1445,7 +1445,7 @@ rust_structop::evaluate (struct type *expect_type, field_name, type->name ()); int fieldno = rust_enum_variant (type); - lhs = value_primitive_field (lhs, 0, fieldno, type); + lhs = lhs->primitive_field (0, fieldno, type); struct type *outer_type = type; type = lhs->type (); diff --git a/gdb/valops.c b/gdb/valops.c index 5cada155073..e9641b9066b 100644 --- a/gdb/valops.c +++ b/gdb/valops.c @@ -1726,8 +1726,7 @@ value_array (int lowbound, int highbound, struct value **elemvec) { val = value::allocate (arraytype); for (idx = 0; idx < nelem; idx++) - value_contents_copy (val, idx * typelength, elemvec[idx], 0, - typelength); + elemvec[idx]->contents_copy (val, idx * typelength, 0, typelength); return val; } @@ -1736,7 +1735,7 @@ value_array (int lowbound, int highbound, struct value **elemvec) val = value::allocate (arraytype); for (idx = 0; idx < nelem; idx++) - value_contents_copy (val, idx * typelength, elemvec[idx], 0, typelength); + elemvec[idx]->contents_copy (val, idx * typelength, 0, typelength); return val; } @@ -2022,7 +2021,7 @@ struct_field_searcher::search (struct value *arg1, LONGEST offset, if (field_is_static (&type->field (i))) v = value_static_field (type, i); else - v = value_primitive_field (arg1, offset, i, type); + v = arg1->primitive_field (offset, i, type); update_result (v, offset); return; @@ -2118,7 +2117,7 @@ struct_field_searcher::search (struct value *arg1, LONGEST offset, search (v2, 0, TYPE_BASECLASS (type, i)); } else if (found_baseclass) - v = value_primitive_field (arg1, offset, i, type); + v = arg1->primitive_field (offset, i, type); else { search (arg1, offset + TYPE_BASECLASS_BITPOS (type, i) / 8, @@ -2467,7 +2466,7 @@ value_struct_elt_bitpos (struct value **argp, int bitpos, struct type *ftype, if (!field_is_static (&t->field (i)) && bitpos == t->field (i).loc_bitpos () && types_equal (ftype, t->field (i).type ())) - return value_primitive_field (*argp, 0, i, t); + return (*argp)->primitive_field (0, i, t); } error (_("No field with matching bitpos and type.")); @@ -4083,8 +4082,8 @@ value_slice (struct value *array, int lowbound, int length) else { slice = value::allocate (slice_type); - value_contents_copy (slice, 0, array, offset, - type_length_units (slice_type)); + array->contents_copy (slice, 0, offset, + type_length_units (slice_type)); } slice->set_component_location (array); diff --git a/gdb/valprint.c b/gdb/valprint.c index ad25c141aa4..91866f4be61 100644 --- a/gdb/valprint.c +++ b/gdb/valprint.c @@ -2007,9 +2007,9 @@ value_print_array_elements (struct value *val, struct ui_file *stream, maybe_print_array_index (index_type, i + low_bound, stream, options); - struct value *element = value_from_component_bitsize (val, elttype, - bit_stride * i, - bit_stride); + struct value *element = val->from_component_bitsize (elttype, + bit_stride * i, + bit_stride); rep1 = i + 1; reps = 1; /* Only check for reps if repeat_count_threshold is not set to @@ -2019,9 +2019,9 @@ value_print_array_elements (struct value *val, struct ui_file *stream, while (rep1 < len) { struct value *rep_elt - = value_from_component_bitsize (val, elttype, - rep1 * bit_stride, - bit_stride); + = val->from_component_bitsize (elttype, + rep1 * bit_stride, + bit_stride); if (!element->contents_eq (rep_elt)) break; ++reps; diff --git a/gdb/value.c b/gdb/value.c index 7433e698a44..498832c1364 100644 --- a/gdb/value.c +++ b/gdb/value.c @@ -891,6 +891,14 @@ value::contents_all_raw () return gdb::make_array_view (m_contents.get (), length); } +gdb::array_view +value::contents_all_raw () const +{ + gdb_assert (!lazy ()); + ULONGEST length = enclosing_type ()->length (); + return gdb::make_array_view (m_contents.get (), length); +} + /* Look at value.h for description. */ struct type * @@ -1012,45 +1020,35 @@ ranges_copy_adjusted (std::vector *dst_range, int dst_bit_offset, } } -/* Copy the ranges metadata in SRC that overlaps [SRC_BIT_OFFSET, - SRC_BIT_OFFSET+BIT_LENGTH) into DST, adjusted. */ +/* See value.h. */ -static void -value_ranges_copy_adjusted (struct value *dst, int dst_bit_offset, - const struct value *src, int src_bit_offset, - int bit_length) +void +value::ranges_copy_adjusted (struct value *dst, int dst_bit_offset, + int src_bit_offset, int bit_length) const { - ranges_copy_adjusted (&dst->m_unavailable, dst_bit_offset, - src->m_unavailable, src_bit_offset, - bit_length); - ranges_copy_adjusted (&dst->m_optimized_out, dst_bit_offset, - src->m_optimized_out, src_bit_offset, - bit_length); + ::ranges_copy_adjusted (&dst->m_unavailable, dst_bit_offset, + m_unavailable, src_bit_offset, + bit_length); + ::ranges_copy_adjusted (&dst->m_optimized_out, dst_bit_offset, + m_optimized_out, src_bit_offset, + bit_length); } -/* Copy LENGTH target addressable memory units of SRC value's (all) contents - (value_contents_all) starting at SRC_OFFSET, into DST value's (all) - contents, starting at DST_OFFSET. If unavailable contents are - being copied from SRC, the corresponding DST contents are marked - unavailable accordingly. Neither DST nor SRC may be lazy - values. - - It is assumed the contents of DST in the [DST_OFFSET, - DST_OFFSET+LENGTH) range are wholly available. */ +/* See value.h. */ -static void -value_contents_copy_raw (struct value *dst, LONGEST dst_offset, - struct value *src, LONGEST src_offset, LONGEST length) +void +value::contents_copy_raw (struct value *dst, LONGEST dst_offset, + LONGEST src_offset, LONGEST length) const { LONGEST src_bit_offset, dst_bit_offset, bit_length; - struct gdbarch *arch = src->get_arch (); + struct gdbarch *arch = get_arch (); int unit_size = gdbarch_addressable_memory_unit_size (arch); /* A lazy DST would make that this copy operation useless, since as soon as DST's contents were un-lazied (by a later value_contents call, say), the contents would be overwritten. A lazy SRC would mean we'd be copying garbage. */ - gdb_assert (!dst->m_lazy && !src->m_lazy); + gdb_assert (!dst->m_lazy && !m_lazy); /* The overwritten DST range gets unavailability ORed in, not replaced. Make sure to remember to implement replacing if it @@ -1064,8 +1062,8 @@ value_contents_copy_raw (struct value *dst, LONGEST dst_offset, = dst->contents_all_raw ().slice (dst_offset * unit_size, length * unit_size); gdb::array_view src_contents - = src->contents_all_raw ().slice (src_offset * unit_size, - length * unit_size); + = contents_all_raw ().slice (src_offset * unit_size, + length * unit_size); gdb::copy (src_contents, dst_contents); /* Copy the meta-data, adjusted. */ @@ -1073,24 +1071,22 @@ value_contents_copy_raw (struct value *dst, LONGEST dst_offset, dst_bit_offset = dst_offset * unit_size * HOST_CHAR_BIT; bit_length = length * unit_size * HOST_CHAR_BIT; - value_ranges_copy_adjusted (dst, dst_bit_offset, - src, src_bit_offset, - bit_length); + ranges_copy_adjusted (dst, dst_bit_offset, + src_bit_offset, bit_length); } -/* A helper for value_from_component_bitsize that copies bits from SRC - to DEST. */ +/* See value.h. */ -static void -value_contents_copy_raw_bitwise (struct value *dst, LONGEST dst_bit_offset, - struct value *src, LONGEST src_bit_offset, - LONGEST bit_length) +void +value::contents_copy_raw_bitwise (struct value *dst, LONGEST dst_bit_offset, + LONGEST src_bit_offset, + LONGEST bit_length) const { /* A lazy DST would make that this copy operation useless, since as soon as DST's contents were un-lazied (by a later value_contents call, say), the contents would be overwritten. A lazy SRC would mean we'd be copying garbage. */ - gdb_assert (!dst->m_lazy && !src->m_lazy); + gdb_assert (!dst->m_lazy && !m_lazy); /* The overwritten DST range gets unavailability ORed in, not replaced. Make sure to remember to implement replacing if it @@ -1103,36 +1099,24 @@ value_contents_copy_raw_bitwise (struct value *dst, LONGEST dst_bit_offset, /* Copy the data. */ gdb::array_view dst_contents = dst->contents_all_raw (); - gdb::array_view src_contents = src->contents_all_raw (); + gdb::array_view src_contents = contents_all_raw (); copy_bitwise (dst_contents.data (), dst_bit_offset, src_contents.data (), src_bit_offset, bit_length, - type_byte_order (src->type ()) == BFD_ENDIAN_BIG); + type_byte_order (type ()) == BFD_ENDIAN_BIG); /* Copy the meta-data. */ - value_ranges_copy_adjusted (dst, dst_bit_offset, - src, src_bit_offset, - bit_length); + ranges_copy_adjusted (dst, dst_bit_offset, src_bit_offset, bit_length); } -/* Copy LENGTH bytes of SRC value's (all) contents - (value_contents_all) starting at SRC_OFFSET byte, into DST value's - (all) contents, starting at DST_OFFSET. If unavailable contents - are being copied from SRC, the corresponding DST contents are - marked unavailable accordingly. DST must not be lazy. If SRC is - lazy, it will be fetched now. - - It is assumed the contents of DST in the [DST_OFFSET, - DST_OFFSET+LENGTH) range are wholly available. */ - void -value_contents_copy (struct value *dst, LONGEST dst_offset, - struct value *src, LONGEST src_offset, LONGEST length) +value::contents_copy (struct value *dst, LONGEST dst_offset, + LONGEST src_offset, LONGEST length) { - if (src->m_lazy) - src->fetch_lazy (); + if (m_lazy) + fetch_lazy (); - value_contents_copy_raw (dst, dst_offset, src, src_offset, length); + contents_copy_raw (dst, dst_offset, src_offset, length); } gdb::array_view @@ -2698,18 +2682,14 @@ value::set_enclosing_type (struct type *new_encl_type) m_enclosing_type = new_encl_type; } -/* Given a value ARG1 (offset by OFFSET bytes) - of a struct or union type ARG_TYPE, - extract and return the value of one of its (non-static) fields. - FIELDNO says which field. */ +/* See value.h. */ struct value * -value_primitive_field (struct value *arg1, LONGEST offset, - int fieldno, struct type *arg_type) +value::primitive_field (LONGEST offset, int fieldno, struct type *arg_type) { struct value *v; struct type *type; - struct gdbarch *arch = arg1->get_arch (); + struct gdbarch *arch = get_arch (); int unit_size = gdbarch_addressable_memory_unit_size (arch); arg_type = check_typedef (arg_type); @@ -2744,11 +2724,11 @@ value_primitive_field (struct value *arg1, LONGEST offset, v->set_bitpos (bitpos % container_bitsize); else v->set_bitpos (bitpos % 8); - v->set_offset ((arg1->embedded_offset () + v->set_offset ((embedded_offset () + offset + (bitpos - v->bitpos ()) / 8)); - v->set_parent (arg1); - if (!arg1->lazy ()) + v->set_parent (this); + if (!lazy ()) v->fetch_lazy (); } else if (fieldno < TYPE_N_BASECLASSES (arg_type)) @@ -2759,32 +2739,31 @@ value_primitive_field (struct value *arg1, LONGEST offset, LONGEST boffset; /* Lazy register values with offsets are not supported. */ - if (VALUE_LVAL (arg1) == lval_register && arg1->lazy ()) - arg1->fetch_lazy (); + if (VALUE_LVAL (this) == lval_register && lazy ()) + fetch_lazy (); /* We special case virtual inheritance here because this requires access to the contents, which we would rather avoid for references to ordinary fields of unavailable values. */ if (BASETYPE_VIA_VIRTUAL (arg_type, fieldno)) boffset = baseclass_offset (arg_type, fieldno, - arg1->contents ().data (), - arg1->embedded_offset (), - arg1->address (), - arg1); + contents ().data (), + embedded_offset (), + address (), + this); else boffset = arg_type->field (fieldno).loc_bitpos () / 8; - if (arg1->lazy ()) - v = value::allocate_lazy (arg1->enclosing_type ()); + if (lazy ()) + v = value::allocate_lazy (enclosing_type ()); else { - v = value::allocate (arg1->enclosing_type ()); - value_contents_copy_raw (v, 0, arg1, 0, - arg1->enclosing_type ()->length ()); + v = value::allocate (enclosing_type ()); + contents_copy_raw (v, 0, 0, enclosing_type ()->length ()); } v->deprecated_set_type (type); - v->set_offset (arg1->offset ()); - v->set_embedded_offset (offset + arg1->embedded_offset () + boffset); + v->set_offset (this->offset ()); + v->set_embedded_offset (offset + embedded_offset () + boffset); } else if (NULL != TYPE_DATA_LOCATION (type)) { @@ -2804,22 +2783,21 @@ value_primitive_field (struct value *arg1, LONGEST offset, / (HOST_CHAR_BIT * unit_size)); /* Lazy register values with offsets are not supported. */ - if (VALUE_LVAL (arg1) == lval_register && arg1->lazy ()) - arg1->fetch_lazy (); + if (VALUE_LVAL (this) == lval_register && lazy ()) + fetch_lazy (); - if (arg1->lazy ()) + if (lazy ()) v = value::allocate_lazy (type); else { v = value::allocate (type); - value_contents_copy_raw (v, v->embedded_offset (), - arg1, arg1->embedded_offset () + offset, - type_length_units (type)); + contents_copy_raw (v, v->embedded_offset (), + embedded_offset () + offset, + type_length_units (type)); } - v->set_offset ((arg1->offset () + offset - + arg1->embedded_offset ())); + v->set_offset (this->offset () + offset + embedded_offset ()); } - v->set_component_location (arg1); + v->set_component_location (this); return v; } @@ -2830,7 +2808,7 @@ value_primitive_field (struct value *arg1, LONGEST offset, struct value * value_field (struct value *arg1, int fieldno) { - return value_primitive_field (arg1, 0, fieldno, arg1->type ()); + return arg1->primitive_field (0, fieldno, arg1->type ()); } /* Return a non-virtual function as a value. @@ -2988,19 +2966,13 @@ unpack_field_as_long (struct type *type, const gdb_byte *valaddr, int fieldno) return unpack_bits_as_long (field_type, valaddr, bitpos, bitsize); } -/* Unpack a bitfield of BITSIZE bits found at BITPOS in the object at - VALADDR + EMBEDDEDOFFSET that has the type of DEST_VAL and store - the contents in DEST_VAL, zero or sign extending if the type of - DEST_VAL is wider than BITSIZE. VALADDR points to the contents of - VAL. If the VAL's contents required to extract the bitfield from - are unavailable/optimized out, DEST_VAL is correspondingly - marked unavailable/optimized out. */ +/* See value.h. */ void -unpack_value_bitfield (struct value *dest_val, - LONGEST bitpos, LONGEST bitsize, - const gdb_byte *valaddr, LONGEST embedded_offset, - const struct value *val) +value::unpack_bitfield (struct value *dest_val, + LONGEST bitpos, LONGEST bitsize, + const gdb_byte *valaddr, LONGEST embedded_offset) + const { enum bfd_endian byte_order; int src_bit_offset; @@ -3031,8 +3003,7 @@ unpack_value_bitfield (struct value *dest_val, dst_bit_offset = field_type->length () * TARGET_CHAR_BIT - bitsize; else dst_bit_offset = 0; - value_ranges_copy_adjusted (dest_val, dst_bit_offset, - val, src_bit_offset, bitsize); + ranges_copy_adjusted (dest_val, dst_bit_offset, src_bit_offset, bitsize); } /* Return a new value with type TYPE, which is FIELDNO field of the @@ -3050,8 +3021,7 @@ value_field_bitfield (struct type *type, int fieldno, int bitsize = TYPE_FIELD_BITSIZE (type, fieldno); struct value *res_val = value::allocate (type->field (fieldno).type ()); - unpack_value_bitfield (res_val, bitpos, bitsize, - valaddr, embedded_offset, val); + val->unpack_bitfield (res_val, bitpos, bitsize, valaddr, embedded_offset); return res_val; } @@ -3412,9 +3382,9 @@ value_from_component (struct value *whole, struct type *type, LONGEST offset) else { v = value::allocate (type); - value_contents_copy (v, v->embedded_offset (), - whole, whole->embedded_offset () + offset, - type_length_units (type)); + whole->contents_copy (v, v->embedded_offset (), + whole->embedded_offset () + offset, + type_length_units (type)); } v->set_offset (whole->offset () + offset + whole->embedded_offset ()); v->set_component_location (whole); @@ -3425,10 +3395,10 @@ value_from_component (struct value *whole, struct type *type, LONGEST offset) /* See value.h. */ struct value * -value_from_component_bitsize (struct value *whole, struct type *type, - LONGEST bit_offset, LONGEST bit_length) +value::from_component_bitsize (struct type *type, + LONGEST bit_offset, LONGEST bit_length) { - gdb_assert (!whole->lazy ()); + gdb_assert (!lazy ()); /* Preserve lvalue-ness if possible. This is needed to avoid array-printing failures (including crashes) when printing Ada @@ -3436,7 +3406,7 @@ value_from_component_bitsize (struct value *whole, struct type *type, if ((bit_offset % TARGET_CHAR_BIT) == 0 && (bit_length % TARGET_CHAR_BIT) == 0 && bit_length == TARGET_CHAR_BIT * type->length ()) - return value_from_component (whole, type, bit_offset / TARGET_CHAR_BIT); + return value_from_component (this, type, bit_offset / TARGET_CHAR_BIT); struct value *v = value::allocate (type); @@ -3444,12 +3414,11 @@ value_from_component_bitsize (struct value *whole, struct type *type, if (is_scalar_type (type) && type_byte_order (type) == BFD_ENDIAN_BIG) dst_offset += TARGET_CHAR_BIT * type->length () - bit_length; - value_contents_copy_raw_bitwise (v, dst_offset, - whole, - TARGET_CHAR_BIT - * whole->embedded_offset () - + bit_offset, - bit_length); + contents_copy_raw_bitwise (v, dst_offset, + TARGET_CHAR_BIT + * embedded_offset () + + bit_offset, + bit_length); return v; } @@ -3595,9 +3564,9 @@ value_fetch_lazy_bitfield (struct value *val) if (parent->lazy ()) parent->fetch_lazy (); - unpack_value_bitfield (val, val->bitpos (), val->bitsize (), - parent->contents_for_printing ().data (), - val->offset (), parent); + parent->unpack_bitfield (val, val->bitpos (), val->bitsize (), + parent->contents_for_printing ().data (), + val->offset ()); } /* Helper for value_fetch_lazy when the value is in memory. */ @@ -3679,9 +3648,9 @@ value_fetch_lazy_register (struct value *val) /* Copy the contents and the unavailability/optimized-out meta-data from NEW_VAL to VAL. */ val->set_lazy (0); - value_contents_copy (val, val->embedded_offset (), - new_val, new_val->embedded_offset (), - type_length_units (type)); + new_val->contents_copy (val, val->embedded_offset (), + new_val->embedded_offset (), + type_length_units (type)); if (frame_debug) { diff --git a/gdb/value.h b/gdb/value.h index 95573a55d99..17a536433e0 100644 --- a/gdb/value.h +++ b/gdb/value.h @@ -384,6 +384,7 @@ struct value returned pointer by the embedded_offset value. */ gdb::array_view contents_all (); gdb::array_view contents_all_raw (); + gdb::array_view contents_all_raw () const; gdb::array_view contents_writeable (); @@ -559,6 +560,49 @@ struct value used to prevent cycles / duplicates. */ void preserve (struct objfile *objfile, htab_t copied_types); + /* Unpack a bitfield of BITSIZE bits found at BITPOS in the object + at VALADDR + EMBEDDEDOFFSET that has the type of DEST_VAL and + store the contents in DEST_VAL, zero or sign extending if the + type of DEST_VAL is wider than BITSIZE. VALADDR points to the + contents of this value. If this value's contents required to + extract the bitfield from are unavailable/optimized out, DEST_VAL + is correspondingly marked unavailable/optimized out. */ + void unpack_bitfield (struct value *dest_val, + LONGEST bitpos, LONGEST bitsize, + const gdb_byte *valaddr, LONGEST embedded_offset) + const; + + /* Copy LENGTH bytes of this value's (all) contents + (value_contents_all) starting at SRC_OFFSET byte, into DST + value's (all) contents, starting at DST_OFFSET. If unavailable + contents are being copied from this value, the corresponding DST + contents are marked unavailable accordingly. DST must not be + lazy. If this value is lazy, it will be fetched now. + + It is assumed the contents of DST in the [DST_OFFSET, + DST_OFFSET+LENGTH) range are wholly available. */ + void contents_copy (struct value *dst, LONGEST dst_offset, + LONGEST src_offset, LONGEST length); + + /* Given a value (offset by OFFSET bytes) + of a struct or union type ARG_TYPE, + extract and return the value of one of its (non-static) fields. + FIELDNO says which field. */ + struct value *primitive_field (LONGEST offset, int fieldno, + struct type *arg_type); + + /* Create a new value by extracting it from this value. TYPE is the + type of the new value. BIT_OFFSET and BIT_LENGTH describe the + offset and field width of the value to extract from this value -- + BIT_LENGTH may differ from TYPE's length in the case where this + value's type is packed. + + When the value does come from a non-byte-aligned offset or field + width, it will be marked non_lval. */ + struct value *from_component_bitsize (struct type *type, + LONGEST bit_offset, + LONGEST bit_length); + /* Type of value; either not an lval, or one of the various different possible kinds of lval. */ @@ -747,6 +791,30 @@ struct value value is lazy, it'll be read now. Note that RANGE is a pointer to pointer because reading the value might change *RANGE. */ int entirely_covered_by_range_vector (const std::vector &ranges); + + /* Copy the ranges metadata from this value that overlaps + [SRC_BIT_OFFSET, SRC_BIT_OFFSET+BIT_LENGTH) into DST, + adjusted. */ + void ranges_copy_adjusted (struct value *dst, int dst_bit_offset, + int src_bit_offset, int bit_length) const; + + /* Copy LENGTH target addressable memory units of this value's (all) + contents (value_contents_all) starting at SRC_OFFSET, into DST + value's (all) contents, starting at DST_OFFSET. If unavailable + contents are being copied from this, the corresponding DST + contents are marked unavailable accordingly. Neither DST nor + this value may be lazy values. + + It is assumed the contents of DST in the [DST_OFFSET, + DST_OFFSET+LENGTH) range are wholly available. */ + void contents_copy_raw (struct value *dst, LONGEST dst_offset, + LONGEST src_offset, LONGEST length) const; + + /* A helper for value_from_component_bitsize that copies bits from + this value to DEST. */ + void contents_copy_raw_bitwise (struct value *dst, LONGEST dst_bit_offset, + LONGEST src_bit_offset, LONGEST bit_length) + const; }; inline void @@ -961,12 +1029,6 @@ extern int unpack_value_field_as_long (struct type *type, const gdb_byte *valadd LONGEST embedded_offset, int fieldno, const struct value *val, LONGEST *result); -extern void unpack_value_bitfield (struct value *dest_val, - LONGEST bitpos, LONGEST bitsize, - const gdb_byte *valaddr, - LONGEST embedded_offset, - const struct value *val); - extern struct value *value_field_bitfield (struct type *type, int fieldno, const gdb_byte *valaddr, LONGEST embedded_offset, @@ -983,20 +1045,6 @@ extern struct value *value_from_component (struct value *, struct type *, LONGEST); -/* Create a new value by extracting it from WHOLE. TYPE is the type - of the new value. BIT_OFFSET and BIT_LENGTH describe the offset - and field width of the value to extract from WHOLE -- BIT_LENGTH - may differ from TYPE's length in the case where WHOLE's type is - packed. - - When the value does come from a non-byte-aligned offset or field - width, it will be marked non_lval. */ - -extern struct value *value_from_component_bitsize (struct value *whole, - struct type *type, - LONGEST bit_offset, - LONGEST bit_length); - extern struct value *value_at (struct type *type, CORE_ADDR addr); extern struct value *value_at_lazy (struct type *type, CORE_ADDR addr); @@ -1048,10 +1096,6 @@ extern struct value *read_var_value (struct symbol *var, const struct block *var_block, frame_info_ptr frame); -extern void value_contents_copy (struct value *dst, LONGEST dst_offset, - struct value *src, LONGEST src_offset, - LONGEST length); - extern struct value *allocate_repeat_value (struct type *type, int count); extern struct value *value_mark (void); @@ -1167,11 +1211,6 @@ extern int find_overload_match (gdb::array_view args, extern struct value *value_field (struct value *arg1, int fieldno); -extern struct value *value_primitive_field (struct value *arg1, LONGEST offset, - int fieldno, - struct type *arg_type); - - extern struct type *value_rtti_indirect_type (struct value *, int *, LONGEST *, int *); From patchwork Thu Feb 9 21:39:04 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tom Tromey X-Patchwork-Id: 64613 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 3D3853889E06 for ; Thu, 9 Feb 2023 23:39:05 +0000 (GMT) X-Original-To: gdb-patches@sourceware.org Delivered-To: gdb-patches@sourceware.org Received: from gproxy4-pub.mail.unifiedlayer.com (gproxy4-pub.mail.unifiedlayer.com [69.89.23.142]) by sourceware.org (Postfix) with ESMTPS id A142438493FB for ; Thu, 9 Feb 2023 23:37:15 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org A142438493FB 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 cmgw10.mail.unifiedlayer.com (unknown [10.0.90.125]) by progateway6.mail.pro1.eigbox.com (Postfix) with ESMTP id 21121100478AA for ; Thu, 9 Feb 2023 23:37:15 +0000 (UTC) Received: from box5379.bluehost.com ([162.241.216.53]) by cmsmtp with ESMTP id QGTbpxehSOscKQGTbpXTJ7; Thu, 09 Feb 2023 23:37:15 +0000 X-Authority-Reason: nr=8 X-Authority-Analysis: v=2.4 cv=Y5c9DjSN c=1 sm=1 tr=0 ts=63e583ab 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=7A4R5JU01LyMgewauvEA: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=SUYhIQtWou8w0ZCZNPBYq3Or/spBtOI6S7XDLqfkPrU=; b=kqb74zQDTsJ9h5zsA6MNBtKN+N tIefiTPaKhL4zjyAQ8AE3pCERwl8yHoPwizusxXrcDIa7z3aDVYXPwinPkNJQm4ZG5VqSDJiLZZwn AVvaDg0XtHgDXQr5l9DRqhlH0; 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 1pQEcv-001ZcE-FD for gdb-patches@sourceware.org; Thu, 09 Feb 2023 14:38:45 -0700 From: Tom Tromey Date: Thu, 09 Feb 2023 14:39:04 -0700 Subject: [PATCH 43/47] Add value::set_modifiable MIME-Version: 1.0 Message-Id: <20230209-submit-value-fixups-2023-v1-43-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: 1pQEcv-001ZcE-FD 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: 11 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 introduces a value::set_modifiable and changes a couple of spots to use it. I'm not completely sure the comments by deprecated_modifiable are correct any more. Perhaps they should be removed and the method renamed. Like so many before me, though, I've deferred investigation of the issue. --- gdb/value.c | 4 ++-- gdb/value.h | 4 ++++ 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/gdb/value.c b/gdb/value.c index 498832c1364..54de45eb22e 100644 --- a/gdb/value.c +++ b/gdb/value.c @@ -1526,7 +1526,7 @@ record_latest_value (struct value *val) /* We preserve VALUE_LVAL so that the user can find out where it was fetched from. This is a bit dubious, because then *&$1 does not just return $1 but the current contents of that location. c'est la vie... */ - val->m_modifiable = 0; + val->set_modifiable (0); value_history.push_back (release_value (val)); @@ -2019,7 +2019,7 @@ set_internalvar (struct internalvar *var, struct value *val) default: new_kind = INTERNALVAR_VALUE; struct value *copy = val->copy (); - copy->m_modifiable = 1; + copy->set_modifiable (1); /* Force the value to be fetched from the target now, to avoid problems later when this internalvar is referenced and the target is gone or diff --git a/gdb/value.h b/gdb/value.h index 17a536433e0..f082c6f62ff 100644 --- a/gdb/value.h +++ b/gdb/value.h @@ -230,6 +230,10 @@ struct value int deprecated_modifiable () const { return m_modifiable; } + /* Set or clear the modifiable flag. */ + void set_modifiable (int val) + { m_modifiable = val; } + LONGEST pointed_to_offset () const { return m_pointed_to_offset; } From patchwork Thu Feb 9 21:39:05 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tom Tromey X-Patchwork-Id: 64607 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 80C203839DF3 for ; Thu, 9 Feb 2023 23:38:09 +0000 (GMT) X-Original-To: gdb-patches@sourceware.org Delivered-To: gdb-patches@sourceware.org Received: from gproxy2-pub.mail.unifiedlayer.com (gproxy2-pub.mail.unifiedlayer.com [69.89.18.3]) by sourceware.org (Postfix) with ESMTPS id 145433881D1A for ; Thu, 9 Feb 2023 23:37:20 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 145433881D1A 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 cmgw14.mail.unifiedlayer.com (unknown [10.0.90.129]) by progateway4.mail.pro1.eigbox.com (Postfix) with ESMTP id 85C8010047A2C for ; Thu, 9 Feb 2023 23:37:19 +0000 (UTC) Received: from box5379.bluehost.com ([162.241.216.53]) by cmsmtp with ESMTP id QGTfpMjdTGAj8QGTfpjA8Y; Thu, 09 Feb 2023 23:37:19 +0000 X-Authority-Reason: nr=8 X-Authority-Analysis: v=2.4 cv=UdyU9IeN c=1 sm=1 tr=0 ts=63e583af 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=JH8mnPVmZJAf71OYdSEA: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=B9vH8aWZKwD64ph8Wj+sZQmTN65AhzC4xxIfyeC16qA=; b=QkqiPI0MxssoaA2by0ZNQvkPs2 6gef5TYbCdDCK4RPWv67ygUx4+1uAhUUcfyzgDINnRmJVtFinycCPLWRHdPyQrjLU/opHBM6ddDFl 8pm/7ZMwXxYYLEIAU9OWqX/d4; 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 1pQEcv-001ZcE-Iv for gdb-patches@sourceware.org; Thu, 09 Feb 2023 14:38:45 -0700 From: Tom Tromey Date: Thu, 09 Feb 2023 14:39:05 -0700 Subject: [PATCH 44/47] Make struct value data members private MIME-Version: 1.0 Message-Id: <20230209-submit-value-fixups-2023-v1-44-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: 1pQEcv-001ZcE-Iv 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: 15 X-Source-Cap: ZWx5bnJvYmk7ZWx5bnJvYmk7Ym94NTM3OS5ibHVlaG9zdC5jb20= X-Local-Domain: yes X-Spam-Status: No, score=-3025.6 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, GIT_PATCH_0, JMQ_SPF_NEUTRAL, RCVD_IN_BL_SPAMCOP_NET, 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 hoists the 'private' in struct value to also encompass the data members. --- gdb/value.h | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/gdb/value.h b/gdb/value.h index f082c6f62ff..6d0a2881d55 100644 --- a/gdb/value.h +++ b/gdb/value.h @@ -607,6 +607,7 @@ struct value LONGEST bit_offset, LONGEST bit_length); +private: /* Type of value; either not an lval, or one of the various different possible kinds of lval. */ @@ -773,8 +774,6 @@ struct value different string representation and related error strings. */ std::vector m_optimized_out; -private: - /* Allocate the contents of this value if it has not been allocated yet. */ void allocate_contents (); From patchwork Thu Feb 9 21:39:06 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tom Tromey X-Patchwork-Id: 64604 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 2E37C3889E00 for ; Thu, 9 Feb 2023 23:37:47 +0000 (GMT) X-Original-To: gdb-patches@sourceware.org Delivered-To: gdb-patches@sourceware.org Received: from gproxy2-pub.mail.unifiedlayer.com (gproxy2-pub.mail.unifiedlayer.com [69.89.18.3]) by sourceware.org (Postfix) with ESMTPS id C7E5B384B02A for ; Thu, 9 Feb 2023 23:37:15 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org C7E5B384B02A 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 cmgw13.mail.unifiedlayer.com (unknown [10.0.90.128]) by progateway4.mail.pro1.eigbox.com (Postfix) with ESMTP id 409E410047A27 for ; Thu, 9 Feb 2023 23:37:15 +0000 (UTC) Received: from box5379.bluehost.com ([162.241.216.53]) by cmsmtp with ESMTP id QGTbpJFNRNX2aQGTbp4EFI; Thu, 09 Feb 2023 23:37:15 +0000 X-Authority-Reason: nr=8 X-Authority-Analysis: v=2.4 cv=NMAQR22g c=1 sm=1 tr=0 ts=63e583ab 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=WtJdfjHS06G0fdgfgGMA: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=AUmGWff5s/+Nlwcj3+l1iC2tHt/95X8kG733er8kcsI=; b=mFdOOhKjlN2cStB8l1rTWnunBw 4behx9Y8NAifx3jOEd4GtahF+S+Ez+AbwNIDS3J2OnGL97q1hSO8vvzn7hMHE5W5JDm4CdBzH2KzQ xQpjx3NC3tvp9VJPi6Yuy0Ger; 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 1pQEcv-001ZcE-N4 for gdb-patches@sourceware.org; Thu, 09 Feb 2023 14:38:45 -0700 From: Tom Tromey Date: Thu, 09 Feb 2023 14:39:06 -0700 Subject: [PATCH 45/47] Make ~value private MIME-Version: 1.0 Message-Id: <20230209-submit-value-fixups-2023-v1-45-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: 1pQEcv-001ZcE-N4 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: 12 X-Source-Cap: ZWx5bnJvYmk7ZWx5bnJvYmk7Ym94NTM3OS5ibHVlaG9zdC5jb20= X-Local-Domain: yes X-Spam-Status: No, score=-3025.6 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, GIT_PATCH_0, JMQ_SPF_NEUTRAL, RCVD_IN_BL_SPAMCOP_NET, 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" At the end of this series, I belatedly realized that values should only be destroyed by value_decref. This patch marks the the destructor private to enforce this. --- gdb/value.h | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/gdb/value.h b/gdb/value.h index 6d0a2881d55..373711f3932 100644 --- a/gdb/value.h +++ b/gdb/value.h @@ -142,6 +142,12 @@ struct value { } + /* Values can only be destroyed via the reference-counting + mechanism. */ + ~value (); + + DISABLE_COPY_AND_ASSIGN (value); + public: /* Allocate a lazy value for type TYPE. Its actual content is @@ -169,10 +175,6 @@ struct value but it's a different block of storage. */ struct value *copy () const; - ~value (); - - DISABLE_COPY_AND_ASSIGN (value); - /* Type of the value. */ struct type *type () const { return m_type; } From patchwork Thu Feb 9 21:39:07 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tom Tromey X-Patchwork-Id: 64606 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 4EFD33895FFC for ; Thu, 9 Feb 2023 23:38:02 +0000 (GMT) X-Original-To: gdb-patches@sourceware.org Delivered-To: gdb-patches@sourceware.org Received: from gproxy4-pub.mail.unifiedlayer.com (gproxy4-pub.mail.unifiedlayer.com [69.89.23.142]) by sourceware.org (Postfix) with ESMTPS id D9BF73881D13 for ; Thu, 9 Feb 2023 23:37:19 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org D9BF73881D13 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 cmgw11.mail.unifiedlayer.com (unknown [10.0.90.126]) by progateway6.mail.pro1.eigbox.com (Postfix) with ESMTP id 5B6CF100478B7 for ; Thu, 9 Feb 2023 23:37:19 +0000 (UTC) Received: from box5379.bluehost.com ([162.241.216.53]) by cmsmtp with ESMTP id QGTfpjJ9i2s14QGTfpj20R; Thu, 09 Feb 2023 23:37:19 +0000 X-Authority-Reason: nr=8 X-Authority-Analysis: v=2.4 cv=R7DGpfdX c=1 sm=1 tr=0 ts=63e583af 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=v85dP2qSnKjgY_-bvVsA: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=vRSbzPqDLfxWmh0pe3XFAK4OnsYsZUHMwziDGijHrec=; b=KyV+Zqkax48P11+50xEV2PrOKH atRwiRueodKTG4UygAD0mSBwX8iCinLP49qdws8xFqrzuAUThdKqV9uYvozjBA60dHZeYRyDFnefV U6QD6yyXFoMV/kkeHX7yeapCb; 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 1pQEcv-001ZcE-Ql for gdb-patches@sourceware.org; Thu, 09 Feb 2023 14:38:45 -0700 From: Tom Tromey Date: Thu, 09 Feb 2023 14:39:07 -0700 Subject: [PATCH 46/47] Introduce set_lval method on value MIME-Version: 1.0 Message-Id: <20230209-submit-value-fixups-2023-v1-46-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: 1pQEcv-001ZcE-Ql 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: 14 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 introduces the set_lval method on value, one step toward removing deprecated_lval_hack. Ultimately I think the goal should be for some of these set_* methods to be replaced with constructors; but I haven't done this, as the series is already too long. Other 'deprecated' methods can probably be handled the same way. --- gdb/aarch64-tdep.c | 2 +- gdb/ada-lang.c | 6 +++--- gdb/amd64-tdep.c | 2 +- gdb/elfread.c | 4 ++-- gdb/eval.c | 4 ++-- gdb/findvar.c | 12 ++++++------ gdb/i386-tdep.c | 2 +- gdb/regcache.c | 2 +- gdb/rust-lang.c | 2 +- gdb/valops.c | 4 ++-- gdb/value.c | 20 ++++++++++---------- gdb/value.h | 4 ++++ 12 files changed, 34 insertions(+), 30 deletions(-) diff --git a/gdb/aarch64-tdep.c b/gdb/aarch64-tdep.c index fa8db9c788d..0bf6085c43a 100644 --- a/gdb/aarch64-tdep.c +++ b/gdb/aarch64-tdep.c @@ -2783,7 +2783,7 @@ aarch64_pseudo_read_value (struct gdbarch *gdbarch, readable_regcache *regcache, aarch64_gdbarch_tdep *tdep = gdbarch_tdep (gdbarch); struct value *result_value = value::allocate (register_type (gdbarch, regnum)); - VALUE_LVAL (result_value) = lval_register; + result_value->set_lval (lval_register); VALUE_REGNUM (result_value) = regnum; if (is_w_pseudo_register (gdbarch, regnum)) diff --git a/gdb/ada-lang.c b/gdb/ada-lang.c index cc69281075e..1fd424c60c2 100644 --- a/gdb/ada-lang.c +++ b/gdb/ada-lang.c @@ -4356,7 +4356,7 @@ ensure_lval (struct value *val) const CORE_ADDR addr = value_as_long (value_allocate_space_in_inferior (len)); - VALUE_LVAL (val) = lval_memory; + val->set_lval (lval_memory); val->set_address (addr); write_memory (addr, val->contents ().data (), len); } @@ -10854,7 +10854,7 @@ ada_var_msym_value_operation::evaluate_for_cast (struct type *expect_type, { if (val->lazy ()) val->fetch_lazy (); - VALUE_LVAL (val) = not_lval; + val->set_lval (not_lval); } return val; } @@ -10876,7 +10876,7 @@ ada_var_value_operation::evaluate_for_cast (struct type *expect_type, { if (val->lazy ()) val->fetch_lazy (); - VALUE_LVAL (val) = not_lval; + val->set_lval (not_lval); } return val; } diff --git a/gdb/amd64-tdep.c b/gdb/amd64-tdep.c index 38440639565..9ce3e37a159 100644 --- a/gdb/amd64-tdep.c +++ b/gdb/amd64-tdep.c @@ -356,7 +356,7 @@ amd64_pseudo_register_read_value (struct gdbarch *gdbarch, i386_gdbarch_tdep *tdep = gdbarch_tdep (gdbarch); value *result_value = value::allocate (register_type (gdbarch, regnum)); - VALUE_LVAL (result_value) = lval_register; + result_value->set_lval (lval_register); VALUE_REGNUM (result_value) = regnum; gdb_byte *buf = result_value->contents_raw ().data (); diff --git a/gdb/elfread.c b/gdb/elfread.c index 6107a7fac69..ca684aab57e 100644 --- a/gdb/elfread.c +++ b/gdb/elfread.c @@ -923,7 +923,7 @@ elf_gnu_ifunc_resolve_addr (struct gdbarch *gdbarch, CORE_ADDR pc) name_at_pc = NULL; function = value::allocate (func_func_type); - VALUE_LVAL (function) = lval_memory; + function->set_lval (lval_memory); function->set_address (pc); /* STT_GNU_IFUNC resolver functions usually receive the HWCAP vector as @@ -1034,7 +1034,7 @@ elf_gnu_ifunc_resolver_return_stop (code_breakpoint *b) gdb_assert (b->loc->next == NULL); func_func = value::allocate (func_func_type); - VALUE_LVAL (func_func) = lval_memory; + func_func->set_lval (lval_memory); func_func->set_address (b->loc->related_address); value = value::allocate (value_type); diff --git a/gdb/eval.c b/gdb/eval.c index 2bff97227dd..e043991c254 100644 --- a/gdb/eval.c +++ b/gdb/eval.c @@ -2879,7 +2879,7 @@ var_msym_value_operation::evaluate_for_cast (struct type *to_type, { if (val->lazy ()) val->fetch_lazy (); - VALUE_LVAL (val) = not_lval; + val->set_lval (not_lval); } return val; } @@ -2900,7 +2900,7 @@ var_value_operation::evaluate_for_cast (struct type *to_type, { if (val->lazy ()) val->fetch_lazy (); - VALUE_LVAL (val) = not_lval; + val->set_lval (not_lval); } return val; } diff --git a/gdb/findvar.c b/gdb/findvar.c index a82cf8c0afa..37ae518d6c4 100644 --- a/gdb/findvar.c +++ b/gdb/findvar.c @@ -295,7 +295,7 @@ value_of_register_lazy (frame_info_ptr frame, int regnum) gdb_assert (frame_id_p (get_frame_id (next_frame))); reg_val = value::allocate_lazy (register_type (gdbarch, regnum)); - VALUE_LVAL (reg_val) = lval_register; + reg_val->set_lval (lval_register); VALUE_REGNUM (reg_val) = regnum; VALUE_NEXT_FRAME_ID (reg_val) = get_frame_id (next_frame); @@ -589,7 +589,7 @@ language_defn::read_var_value (struct symbol *var, v = value::allocate (type); store_signed_integer (v->contents_raw ().data (), type->length (), type_byte_order (type), var->value_longest ()); - VALUE_LVAL (v) = not_lval; + v->set_lval (not_lval); return v; case LOC_LABEL: @@ -616,7 +616,7 @@ language_defn::read_var_value (struct symbol *var, struct type *void_ptr_type = builtin_type (var->arch ())->builtin_data_ptr; v = value_cast_pointers (void_ptr_type, v, 0); - VALUE_LVAL (v) = not_lval; + v->set_lval (not_lval); return v; } @@ -629,7 +629,7 @@ language_defn::read_var_value (struct symbol *var, v = value::allocate (type); memcpy (v->contents_raw ().data (), var->value_bytes (), type->length ()); - VALUE_LVAL (v) = not_lval; + v->set_lval (not_lval); return v; case LOC_STATIC: @@ -804,7 +804,7 @@ default_value_from_register (struct gdbarch *gdbarch, struct type *type, struct value *value = value::allocate (type); frame_info_ptr frame; - VALUE_LVAL (value) = lval_register; + value->set_lval (lval_register); frame = frame_find_by_id (frame_id); if (frame == NULL) @@ -896,7 +896,7 @@ value_from_register (struct type *type, int regnum, frame_info_ptr frame) is that gdbarch_register_to_value populates the entire value including the location. */ v = value::allocate (type); - VALUE_LVAL (v) = lval_register; + v->set_lval (lval_register); VALUE_NEXT_FRAME_ID (v) = get_frame_id (get_next_frame_sentinel_okay (frame)); VALUE_REGNUM (v) = regnum; ok = gdbarch_register_to_value (gdbarch, frame, regnum, type1, diff --git a/gdb/i386-tdep.c b/gdb/i386-tdep.c index 53e531ca90c..989803f3816 100644 --- a/gdb/i386-tdep.c +++ b/gdb/i386-tdep.c @@ -3558,7 +3558,7 @@ i386_pseudo_register_read_value (struct gdbarch *gdbarch, struct value *result; result = value::allocate (register_type (gdbarch, regnum)); - VALUE_LVAL (result) = lval_register; + result->set_lval (lval_register); VALUE_REGNUM (result) = regnum; i386_pseudo_register_read_into_value (gdbarch, regcache, regnum, result); diff --git a/gdb/regcache.c b/gdb/regcache.c index 09dd6a4b79e..af76fab1a34 100644 --- a/gdb/regcache.c +++ b/gdb/regcache.c @@ -744,7 +744,7 @@ readable_regcache::cooked_read_value (int regnum) struct value *result; result = value::allocate (register_type (m_descr->gdbarch, regnum)); - VALUE_LVAL (result) = lval_register; + result->set_lval (lval_register); VALUE_REGNUM (result) = regnum; /* It is more efficient in general to do this delegation in this diff --git a/gdb/rust-lang.c b/gdb/rust-lang.c index 013b8a4c0d2..27b5928298f 100644 --- a/gdb/rust-lang.c +++ b/gdb/rust-lang.c @@ -350,7 +350,7 @@ rust_val_print_slice (struct value *val, struct ui_file *stream, int recurse, struct type *array_type = lookup_array_range_type (elt_type, 0, llen - 1); struct value *array = value::allocate_lazy (array_type); - VALUE_LVAL (array) = lval_memory; + array->set_lval (lval_memory); array->set_address (value_as_address (base)); array->fetch_lazy (); generic_value_print (array, stream, recurse, options, diff --git a/gdb/valops.c b/gdb/valops.c index e9641b9066b..6a0a6706157 100644 --- a/gdb/valops.c +++ b/gdb/valops.c @@ -1024,7 +1024,7 @@ struct value * value_at_non_lval (struct type *type, CORE_ADDR addr) { struct value *result = value_at (type, addr); - VALUE_LVAL (result) = not_lval; + result->set_lval (not_lval); return result; } @@ -1373,7 +1373,7 @@ value_repeat (struct value *arg1, int count) val = allocate_repeat_value (arg1->enclosing_type (), count); - VALUE_LVAL (val) = lval_memory; + val->set_lval (lval_memory); val->set_address (arg1->address ()); read_value_memory (val, 0, val->stack (), val->address (), diff --git a/gdb/value.c b/gdb/value.c index 54de45eb22e..bba78c3d10e 100644 --- a/gdb/value.c +++ b/gdb/value.c @@ -848,7 +848,7 @@ value::allocate_computed (struct type *type, { struct value *v = value::allocate_lazy (type); - VALUE_LVAL (v) = lval_computed; + v->set_lval (lval_computed); v->m_location.computed.funcs = funcs; v->m_location.computed.closure = closure; @@ -1362,7 +1362,7 @@ value::copy () const else val = value::allocate (encl_type); val->m_type = m_type; - VALUE_LVAL (val) = m_lval; + val->set_lval (m_lval); val->m_location = m_location; val->m_offset = m_offset; val->m_bitpos = m_bitpos; @@ -1455,9 +1455,9 @@ value::set_component_location (const struct value *whole) gdb_assert (whole->m_lval != lval_xcallable); if (whole->m_lval == lval_internalvar) - VALUE_LVAL (this) = lval_internalvar_component; + m_lval = lval_internalvar_component; else - VALUE_LVAL (this) = whole->m_lval; + m_lval = whole->m_lval; m_location = whole->m_location; if (whole->m_lval == lval_computed) @@ -1501,7 +1501,7 @@ value::set_component_location (const struct value *whole) if (VALUE_LVAL (this) == lval_internalvar_component) { gdb_assert (lazy ()); - VALUE_LVAL (this) = lval_memory; + m_lval = lval_memory; } else gdb_assert (VALUE_LVAL (this) == lval_memory); @@ -1917,7 +1917,7 @@ value_of_internalvar (struct gdbarch *gdbarch, struct internalvar *var) if (var->kind != INTERNALVAR_MAKE_VALUE && val->lval () != lval_computed) { - VALUE_LVAL (val) = lval_internalvar; + val->set_lval (lval_internalvar); VALUE_INTERNALVAR (val) = var; } @@ -2838,7 +2838,7 @@ value_fn_field (struct value **arg1p, struct fn_field *f, } v = value::allocate (ftype); - VALUE_LVAL (v) = lval_memory; + v->set_lval (lval_memory); if (sym) { v->set_address (sym->value_block ()->entry_pc ()); @@ -3184,7 +3184,7 @@ value::zero (struct type *type, enum lval_type lv) { struct value *val = value::allocate_lazy (type); - VALUE_LVAL (val) = (lv == lval_computed ? not_lval : lv); + val->set_lval (lv == lval_computed ? not_lval : lv); val->m_is_zero = true; return val; } @@ -3259,7 +3259,7 @@ value_from_contents_and_address_unresolved (struct type *type, v = value::allocate_lazy (type); else v = value_from_contents (type, valaddr); - VALUE_LVAL (v) = lval_memory; + v->set_lval (lval_memory); v->set_address (address); return v; } @@ -3288,7 +3288,7 @@ value_from_contents_and_address (struct type *type, if (TYPE_DATA_LOCATION (resolved_type_no_typedef) != NULL && TYPE_DATA_LOCATION_KIND (resolved_type_no_typedef) == PROP_CONST) address = TYPE_DATA_LOCATION_ADDR (resolved_type_no_typedef); - VALUE_LVAL (v) = lval_memory; + v->set_lval (lval_memory); v->set_address (address); return v; } diff --git a/gdb/value.h b/gdb/value.h index 373711f3932..36bc00629d8 100644 --- a/gdb/value.h +++ b/gdb/value.h @@ -336,6 +336,10 @@ struct value enum lval_type lval () const { return m_lval; } + /* Set the 'lval' of this value. */ + void set_lval (lval_type val) + { m_lval = val; } + /* Set or return field indicating whether a variable is initialized or not, based on debugging information supplied by the compiler. 1 = initialized; 0 = uninitialized. */ From patchwork Thu Feb 9 21:39:08 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tom Tromey X-Patchwork-Id: 64608 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 7892C388A412 for ; Thu, 9 Feb 2023 23:38:12 +0000 (GMT) X-Original-To: gdb-patches@sourceware.org Delivered-To: gdb-patches@sourceware.org Received: from gproxy4-pub.mail.unifiedlayer.com (gproxy4-pub.mail.unifiedlayer.com [69.89.23.142]) by sourceware.org (Postfix) with ESMTPS id E90F7383FBAD for ; Thu, 9 Feb 2023 23:37:15 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org E90F7383FBAD 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 cmgw11.mail.unifiedlayer.com (unknown [10.0.90.126]) by progateway6.mail.pro1.eigbox.com (Postfix) with ESMTP id 6751A100478BA for ; Thu, 9 Feb 2023 23:37:15 +0000 (UTC) Received: from box5379.bluehost.com ([162.241.216.53]) by cmsmtp with ESMTP id QGTbpjJ7Y2s14QGTbpj1yK; Thu, 09 Feb 2023 23:37:15 +0000 X-Authority-Reason: nr=8 X-Authority-Analysis: v=2.4 cv=R7DGpfdX c=1 sm=1 tr=0 ts=63e583ab 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=ElkN3movYDqdZHBH6hwA:9 a=r849fpiV9y4eDnPW:21 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=c8tafPvkM5PDUD66Zuz5CyKTS9JMUDHvUMenwCCo2P4=; b=ONHbpcm9JK0DvZJAN099h4nxn9 uIljvOqmnBOiu5qDHfXE81nKsImn9dlSeAf4hRmrqR+Y+kRFFs/etaIpTBIp8D1HVPq/Vbm3DM+jK QhQdE4J8MVMWC5+FjfeLPvy1m; 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 1pQEcv-001ZcE-Uj for gdb-patches@sourceware.org; Thu, 09 Feb 2023 14:38:45 -0700 From: Tom Tromey Date: Thu, 09 Feb 2023 14:39:08 -0700 Subject: [PATCH 47/47] Remove deprecated_lval_hack MIME-Version: 1.0 Message-Id: <20230209-submit-value-fixups-2023-v1-47-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: 1pQEcv-001ZcE-Uj 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: 13 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 removes deprecated_lval_hack and the VALUE_LVAL macro, replacing all uses with a call to value::lval. --- gdb/ada-lang.c | 28 +++++++++++----------- gdb/breakpoint.c | 8 +++---- gdb/c-lang.c | 6 ++--- gdb/cli/cli-dump.c | 2 +- gdb/compile/compile-c-symbols.c | 2 +- gdb/compile/compile-cplus-symbols.c | 2 +- gdb/compile/compile-loc2c.c | 2 +- gdb/dwarf2/frame.c | 2 +- gdb/dwarf2/loc.c | 6 ++--- gdb/eval.c | 12 +++++----- gdb/expop.h | 2 +- gdb/f-lang.c | 8 +++---- gdb/findvar.c | 2 +- gdb/frame.c | 8 +++---- gdb/gdbtypes.c | 2 +- gdb/infcall.c | 2 +- gdb/m2-lang.c | 2 +- gdb/opencl-lang.c | 6 ++--- gdb/ppc-linux-nat.c | 8 +++---- gdb/printcmd.c | 8 +++---- gdb/python/py-unwind.c | 2 +- gdb/rust-lang.c | 4 ++-- gdb/stack.c | 6 ++--- gdb/valarith.c | 14 +++++------ gdb/valops.c | 34 +++++++++++++-------------- gdb/value.c | 46 ++++++++++++++++++------------------- gdb/value.h | 10 -------- gdb/varobj.c | 2 +- 28 files changed, 113 insertions(+), 123 deletions(-) diff --git a/gdb/ada-lang.c b/gdb/ada-lang.c index 1fd424c60c2..ec85729042f 100644 --- a/gdb/ada-lang.c +++ b/gdb/ada-lang.c @@ -559,7 +559,7 @@ coerce_unspec_val_to_type (struct value *val, struct type *type) result = value::allocate_optimized_out (type); else if (val->lazy () /* Be careful not to make a lazy not_lval value. */ - || (VALUE_LVAL (val) != not_lval + || (val->lval () != not_lval && type->length () > val->type ()->length ())) result = value::allocate_lazy (type); else @@ -570,7 +570,7 @@ coerce_unspec_val_to_type (struct value *val, struct type *type) result->set_component_location (val); result->set_bitsize (val->bitsize ()); result->set_bitpos (val->bitpos ()); - if (VALUE_LVAL (result) == lval_memory) + if (result->lval () == lval_memory) result->set_address (val->address ()); return result; } @@ -2810,7 +2810,7 @@ ada_value_primitive_packed_val (struct value *obj, const gdb_byte *valaddr, v = value::allocate (type); src = valaddr + offset; } - else if (VALUE_LVAL (obj) == lval_memory && obj->lazy ()) + else if (obj->lval () == lval_memory && obj->lazy ()) { int src_len = (bit_size + bit_offset + HOST_CHAR_BIT - 1) / 8; gdb_byte *buf; @@ -2891,7 +2891,7 @@ ada_value_assign (struct value *toval, struct value *fromval) if (!toval->deprecated_modifiable ()) error (_("Left operand of assignment is not a modifiable lvalue.")); - if (VALUE_LVAL (toval) == lval_memory + if (toval->lval () == lval_memory && bits > 0 && (type->code () == TYPE_CODE_FLT || type->code () == TYPE_CODE_STRUCT)) @@ -4349,8 +4349,8 @@ ada_read_renaming_var_value (struct symbol *renaming_sym, static struct value * ensure_lval (struct value *val) { - if (VALUE_LVAL (val) == not_lval - || VALUE_LVAL (val) == lval_internalvar) + if (val->lval () == not_lval + || val->lval () == lval_internalvar) { int len = ada_check_typedef (val->type ())->length (); const CORE_ADDR addr = @@ -4523,7 +4523,7 @@ ada_convert_actual (struct value *actual, struct type *formal_type0) result = desc_data (actual); else if (formal_type->code () != TYPE_CODE_PTR) { - if (VALUE_LVAL (actual) != lval_memory) + if (actual->lval () != lval_memory) { struct value *val; @@ -8841,7 +8841,7 @@ ada_to_fixed_value_create (struct type *type0, CORE_ADDR address, if (type == type0 && val0 != NULL) return val0; - if (VALUE_LVAL (val0) != lval_memory) + if (val0->lval () != lval_memory) { /* Our value does not live in memory; it could be a convenience variable, for instance. Create a not_lval value using val0's @@ -9771,12 +9771,12 @@ ada_assign_operation::evaluate (struct type *expect_type, In the case of assigning to a convenience variable, the lhs should be exactly the result of the evaluation of the rhs. */ struct type *type = arg1->type (); - if (VALUE_LVAL (arg1) == lval_internalvar) + if (arg1->lval () == lval_internalvar) type = NULL; value *arg2 = std::get<1> (m_storage)->evaluate (type, exp, noside); if (noside == EVAL_AVOID_SIDE_EFFECTS) return arg1; - if (VALUE_LVAL (arg1) == lval_internalvar) + if (arg1->lval () == lval_internalvar) { /* Nothing. */ } @@ -10279,7 +10279,7 @@ ada_ternop_slice (struct expression *exp, convert to a pointer. */ if (array->type ()->code () == TYPE_CODE_REF || (array->type ()->code () == TYPE_CODE_ARRAY - && VALUE_LVAL (array) == lval_memory)) + && array->lval () == lval_memory)) array = value_addr (array); if (noside == EVAL_AVOID_SIDE_EFFECTS @@ -10850,7 +10850,7 @@ ada_var_msym_value_operation::evaluate_for_cast (struct type *expect_type, /* Follow the Ada language semantics that do not allow taking an address of the result of a cast (view conversion in Ada). */ - if (VALUE_LVAL (val) == lval_memory) + if (val->lval () == lval_memory) { if (val->lazy ()) val->fetch_lazy (); @@ -10872,7 +10872,7 @@ ada_var_value_operation::evaluate_for_cast (struct type *expect_type, /* Follow the Ada language semantics that do not allow taking an address of the result of a cast (view conversion in Ada). */ - if (VALUE_LVAL (val) == lval_memory) + if (val->lval () == lval_memory) { if (val->lazy ()) val->fetch_lazy (); @@ -11169,7 +11169,7 @@ ada_funcall_operation::evaluate (struct type *expect_type, callee = ada_to_fixed_value (coerce_ref (callee)); } else if (callee->type ()->code () == TYPE_CODE_ARRAY - && VALUE_LVAL (callee) == lval_memory) + && callee->lval () == lval_memory) callee = value_addr (callee); struct type *type = ada_check_typedef (callee->type ()); diff --git a/gdb/breakpoint.c b/gdb/breakpoint.c index 2ccc7c97b4c..239926ffd4a 100644 --- a/gdb/breakpoint.c +++ b/gdb/breakpoint.c @@ -2066,7 +2066,7 @@ update_watchpoint (struct watchpoint *b, bool reparse) must watch it. If the first value returned is still lazy, that means an error occurred reading it; watch it anyway in case it becomes readable. */ - if (VALUE_LVAL (v) == lval_memory + if (v->lval () == lval_memory && (v == val_chain[0] || ! v->lazy ())) { struct type *vtype = check_typedef (v->type ()); @@ -10381,7 +10381,7 @@ can_use_hardware_watchpoint (const std::vector &vals) { struct value *v = iter.get (); - if (VALUE_LVAL (v) == lval_memory) + if (v->lval () == lval_memory) { if (v != head && v->lazy ()) /* A lazy memory lvalue in the chain is one that GDB never @@ -10419,10 +10419,10 @@ can_use_hardware_watchpoint (const std::vector &vals) } } } - else if (VALUE_LVAL (v) != not_lval + else if (v->lval () != not_lval && v->deprecated_modifiable () == 0) return 0; /* These are values from the history (e.g., $1). */ - else if (VALUE_LVAL (v) == lval_register) + else if (v->lval () == lval_register) return 0; /* Cannot watch a register with a HW watchpoint. */ } diff --git a/gdb/c-lang.c b/gdb/c-lang.c index e4027d8ee96..6535ab93498 100644 --- a/gdb/c-lang.c +++ b/gdb/c-lang.c @@ -294,8 +294,8 @@ c_get_string (struct value *value, gdb::unique_xmalloc_ptr *buffer, C struct hack. So, only do this if either no length was specified, or the length is within the existing bounds. This avoids running off the end of the value's contents. */ - if ((VALUE_LVAL (value) == not_lval - || VALUE_LVAL (value) == lval_internalvar + if ((value->lval () == not_lval + || value->lval () == lval_internalvar || type->code () == TYPE_CODE_ARRAY) && fetchlimit != UINT_MAX && (*length < 0 || *length <= fetchlimit)) @@ -328,7 +328,7 @@ c_get_string (struct value *value, gdb::unique_xmalloc_ptr *buffer, CORE_ADDR addr; if (type->code () == TYPE_CODE_ARRAY) { - if (VALUE_LVAL (value) != lval_memory) + if (value->lval () != lval_memory) error (_("Attempt to take address of value " "not located in memory.")); addr = value->address (); diff --git a/gdb/cli/cli-dump.c b/gdb/cli/cli-dump.c index 769f6a589b6..08984f6fdf3 100644 --- a/gdb/cli/cli-dump.c +++ b/gdb/cli/cli-dump.c @@ -230,7 +230,7 @@ dump_value_to_file (const char *cmd, const char *mode, const char *file_format) { CORE_ADDR vaddr; - if (VALUE_LVAL (val)) + if (val->lval ()) { vaddr = val->address (); } diff --git a/gdb/compile/compile-c-symbols.c b/gdb/compile/compile-c-symbols.c index 5b53ab3263f..6faff0eee06 100644 --- a/gdb/compile/compile-c-symbols.c +++ b/gdb/compile/compile-c-symbols.c @@ -156,7 +156,7 @@ convert_one_symbol (compile_c_instance *context, } val = read_var_value (sym.symbol, sym.block, frame); - if (VALUE_LVAL (val) != lval_memory) + if (val->lval () != lval_memory) error (_("Symbol \"%s\" cannot be used for compilation " "evaluation as its address has not been found."), sym.symbol->print_name ()); diff --git a/gdb/compile/compile-cplus-symbols.c b/gdb/compile/compile-cplus-symbols.c index 28447776d4f..039aee34ab7 100644 --- a/gdb/compile/compile-cplus-symbols.c +++ b/gdb/compile/compile-cplus-symbols.c @@ -150,7 +150,7 @@ convert_one_symbol (compile_cplus_instance *instance, } val = read_var_value (sym.symbol, sym.block, frame); - if (VALUE_LVAL (val) != lval_memory) + if (val->lval () != lval_memory) error (_("Symbol \"%s\" cannot be used for compilation " "evaluation as its address has not been found."), sym.symbol->print_name ()); diff --git a/gdb/compile/compile-loc2c.c b/gdb/compile/compile-loc2c.c index ae30dd69dec..558460a7c57 100644 --- a/gdb/compile/compile-loc2c.c +++ b/gdb/compile/compile-loc2c.c @@ -642,7 +642,7 @@ do_compile_dwarf_expr_to_c (int indent, string_file *stream, sym->print_name ()); val = read_var_value (sym, NULL, frame); - if (VALUE_LVAL (val) != lval_memory) + if (val->lval () != lval_memory) error (_("Symbol \"%s\" cannot be used for compilation evaluation " "as its address has not been found."), sym->print_name ()); diff --git a/gdb/dwarf2/frame.c b/gdb/dwarf2/frame.c index a83df2192c3..a561aaf3100 100644 --- a/gdb/dwarf2/frame.c +++ b/gdb/dwarf2/frame.c @@ -235,7 +235,7 @@ execute_stack_op (const gdb_byte *exp, ULONGEST len, int addr_size, ctx.push_address (initial, initial_in_stack_memory); value *result_val = ctx.evaluate (exp, len, true, nullptr, this_frame); - if (VALUE_LVAL (result_val) == lval_memory) + if (result_val->lval () == lval_memory) return result_val->address (); else return value_as_address (result_val); diff --git a/gdb/dwarf2/loc.c b/gdb/dwarf2/loc.c index 616db13488b..27c4b7ce31a 100644 --- a/gdb/dwarf2/loc.c +++ b/gdb/dwarf2/loc.c @@ -684,7 +684,7 @@ call_site_target::iterate_over_addresses dwarf_block->per_cu, dwarf_block->per_objfile); /* DW_AT_call_target is a DWARF expression, not a DWARF location. */ - if (VALUE_LVAL (val) == lval_memory) + if (val->lval () == lval_memory) callback (val->address ()); else callback (value_as_address (val)); @@ -1612,11 +1612,11 @@ dwarf2_locexpr_baton_eval (const struct dwarf2_locexpr_baton *dlbaton, if (result->optimized_out ()) return 0; - if (VALUE_LVAL (result) == lval_memory) + if (result->lval () == lval_memory) *valp = result->address (); else { - if (VALUE_LVAL (result) == not_lval) + if (result->lval () == not_lval) *is_reference = false; *valp = value_as_address (result); diff --git a/gdb/eval.c b/gdb/eval.c index e043991c254..f8bbb9ef766 100644 --- a/gdb/eval.c +++ b/gdb/eval.c @@ -1224,7 +1224,7 @@ eval_op_structop_struct (struct type *expect_type, struct expression *exp, struct value *arg3 = value_struct_elt (&arg1, {}, string, NULL, "structure"); if (noside == EVAL_AVOID_SIDE_EFFECTS) - arg3 = value::zero (arg3->type (), VALUE_LVAL (arg3)); + arg3 = value::zero (arg3->type (), arg3->lval ()); return arg3; } @@ -1280,7 +1280,7 @@ eval_op_structop_ptr (struct type *expect_type, struct expression *exp, struct value *arg3 = value_struct_elt (&arg1, {}, string, NULL, "structure pointer"); if (noside == EVAL_AVOID_SIDE_EFFECTS) - arg3 = value::zero (arg3->type (), VALUE_LVAL (arg3)); + arg3 = value::zero (arg3->type (), arg3->lval ()); return arg3; } @@ -1447,7 +1447,7 @@ eval_op_subscript (struct type *expect_type, struct expression *exp, } if (noside == EVAL_AVOID_SIDE_EFFECTS) - return value::zero (type->target_type (), VALUE_LVAL (arg1)); + return value::zero (type->target_type (), arg1->lval ()); else return value_subscript (arg1, value_as_long (arg2)); } @@ -2590,7 +2590,7 @@ evaluate_subexp_for_address_base (struct expression *exp, enum noside noside, if (TYPE_IS_REFERENCE (type)) return value::zero (lookup_pointer_type (type->target_type ()), not_lval); - else if (VALUE_LVAL (x) == lval_memory || value_must_coerce_to_target (x)) + else if (x->lval () == lval_memory || value_must_coerce_to_target (x)) return value::zero (lookup_pointer_type (x->type ()), not_lval); else @@ -2875,7 +2875,7 @@ var_msym_value_operation::evaluate_for_cast (struct type *to_type, val = value_cast (to_type, val); /* Don't allow e.g. '&(int)var_with_no_debug_info'. */ - if (VALUE_LVAL (val) == lval_memory) + if (val->lval () == lval_memory) { if (val->lazy ()) val->fetch_lazy (); @@ -2896,7 +2896,7 @@ var_value_operation::evaluate_for_cast (struct type *to_type, val = value_cast (to_type, val); /* Don't allow e.g. '&(int)var_with_no_debug_info'. */ - if (VALUE_LVAL (val) == lval_memory) + if (val->lval () == lval_memory) { if (val->lazy ()) val->fetch_lazy (); diff --git a/gdb/expop.h b/gdb/expop.h index e53474711fe..d973d2314bb 100644 --- a/gdb/expop.h +++ b/gdb/expop.h @@ -1889,7 +1889,7 @@ class assign_operation expected type. This avoids a weird case where re-assigning a string or array to an internal variable could error with "Too many array elements". */ - struct type *xtype = (VALUE_LVAL (lhs) == lval_internalvar + struct type *xtype = (lhs->lval () == lval_internalvar ? nullptr : lhs->type ()); value *rhs = std::get<1> (m_storage)->evaluate (xtype, exp, noside); diff --git a/gdb/f-lang.c b/gdb/f-lang.c index d935f59088f..0d7863e4fd1 100644 --- a/gdb/f-lang.c +++ b/gdb/f-lang.c @@ -1363,7 +1363,7 @@ fortran_undetermined::value_subarray (value *array, if (index < lb || (dim_type->index_type ()->bounds ()->high.kind () != PROP_UNDEFINED && index > ub) - || (VALUE_LVAL (array) != lval_memory + || (array->lval () != lval_memory && dim_type->index_type ()->bounds ()->high.kind () == PROP_UNDEFINED)) { if (type_not_associated (dim_type)) @@ -1460,7 +1460,7 @@ fortran_undetermined::value_subarray (value *array, } else { - if (VALUE_LVAL (array) == lval_memory) + if (array->lval () == lval_memory) { /* If the value we're taking a slice from is not yet loaded, or the requested slice is outside the values content range then @@ -1637,7 +1637,7 @@ fortran_structop_operation::evaluate (struct type *expect_type, = gdb::make_array_view (valaddr, elt_type->length ()); elt_type = resolve_dynamic_type (elt_type, view, address); } - elt = value::zero (elt_type, VALUE_LVAL (elt)); + elt = value::zero (elt_type, elt->lval ()); } return elt; @@ -1872,7 +1872,7 @@ fortran_argument_convert (struct value *value, bool is_artificial) { /* If the value is not in the inferior e.g. registers values, convenience variables and user input. */ - if (VALUE_LVAL (value) != lval_memory) + if (value->lval () != lval_memory) { struct type *type = value->type (); const int length = type->length (); diff --git a/gdb/findvar.c b/gdb/findvar.c index 37ae518d6c4..7006500574c 100644 --- a/gdb/findvar.c +++ b/gdb/findvar.c @@ -846,7 +846,7 @@ read_frame_register_value (struct value *value, frame_info_ptr frame) int regnum = VALUE_REGNUM (value); int len = type_length_units (check_typedef (value->type ())); - gdb_assert (VALUE_LVAL (value) == lval_register); + gdb_assert (value->lval () == lval_register); /* Skip registers wholly inside of REG_OFFSET. */ while (reg_offset >= register_size (gdbarch, regnum)) diff --git a/gdb/frame.c b/gdb/frame.c index 095682fd8fa..2c22673c82e 100644 --- a/gdb/frame.c +++ b/gdb/frame.c @@ -930,7 +930,7 @@ frame_find_by_id (struct frame_id id) and get_prev_frame performs a series of checks that are relatively expensive). This optimization is particularly useful when this function is called from another function (such as value_fetch_lazy, case - VALUE_LVAL (val) == lval_register) which already loops over all frames, + val->lval () == lval_register) which already loops over all frames, making the overall behavior O(n^2). */ frame = frame_stash_find (id); if (frame) @@ -1191,7 +1191,7 @@ frame_register_unwind (frame_info_ptr next_frame, int regnum, *optimizedp = value->optimized_out (); *unavailablep = !value->entirely_available (); - *lvalp = VALUE_LVAL (value); + *lvalp = value->lval (); *addrp = value->address (); if (*lvalp == lval_register) *realnump = VALUE_REGNUM (value); @@ -1296,10 +1296,10 @@ frame_unwind_register_value (frame_info_ptr next_frame, int regnum) } else { - if (VALUE_LVAL (value) == lval_register) + if (value->lval () == lval_register) gdb_printf (&debug_file, " register=%d", VALUE_REGNUM (value)); - else if (VALUE_LVAL (value) == lval_memory) + else if (value->lval () == lval_memory) gdb_printf (&debug_file, " address=%s", paddress (gdbarch, value->address ())); diff --git a/gdb/gdbtypes.c b/gdb/gdbtypes.c index 73ccd1cf3f8..f22ba44a538 100644 --- a/gdb/gdbtypes.c +++ b/gdb/gdbtypes.c @@ -4908,7 +4908,7 @@ rank_one_type (struct type *parm, struct type *arg, struct value *value) if (TYPE_IS_REFERENCE (parm) && value != NULL) { - if (VALUE_LVAL (value) == not_lval) + if (value->lval () == not_lval) { /* Rvalues should preferably bind to rvalue references or const lvalue references. */ diff --git a/gdb/infcall.c b/gdb/infcall.c index 81a073d2123..9ed17bf4f8b 100644 --- a/gdb/infcall.c +++ b/gdb/infcall.c @@ -343,7 +343,7 @@ find_function_addr (struct value *function, int found_descriptor = 0; funaddr = 0; /* pacify "gcc -Werror" */ - if (VALUE_LVAL (function) == lval_memory) + if (function->lval () == lval_memory) { CORE_ADDR nfunaddr; diff --git a/gdb/m2-lang.c b/gdb/m2-lang.c index ffa2faa44a9..72d0b58d675 100644 --- a/gdb/m2-lang.c +++ b/gdb/m2-lang.c @@ -104,7 +104,7 @@ eval_op_m2_subscript (struct type *expect_type, struct expression *exp, } if (noside == EVAL_AVOID_SIDE_EFFECTS) - return value::zero (type->target_type (), VALUE_LVAL (arg1)); + return value::zero (type->target_type (), arg1->lval ()); else return value_subscript (arg1, value_as_long (arg2)); } diff --git a/gdb/opencl-lang.c b/gdb/opencl-lang.c index b3e82f4a6ae..3e4a9c360b2 100644 --- a/gdb/opencl-lang.c +++ b/gdb/opencl-lang.c @@ -300,7 +300,7 @@ create_value (struct gdbarch *gdbarch, struct value *val, enum noside noside, else { /* Check whether to create a lvalue or not. */ - if (VALUE_LVAL (val) != not_lval && !array_has_dups (indices, n)) + if (val->lval () != not_lval && !array_has_dups (indices, n)) { struct lval_closure *c = allocate_lval_closure (indices, n, val); ret = value::allocate_computed (dst_type, &opencl_value_funcs, c); @@ -687,7 +687,7 @@ eval_opencl_assign (struct type *expect_type, struct expression *exp, struct type *type1 = arg1->type (); if (arg1->deprecated_modifiable () - && VALUE_LVAL (arg1) != lval_internalvar) + && arg1->lval () != lval_internalvar) arg2 = opencl_value_cast (type1, arg2); return value_assign (arg1, arg2); @@ -714,7 +714,7 @@ opencl_structop_operation::evaluate (struct type *expect_type, NULL, "structure"); if (noside == EVAL_AVOID_SIDE_EFFECTS) - v = value::zero (v->type (), VALUE_LVAL (v)); + v = value::zero (v->type (), v->lval ()); return v; } } diff --git a/gdb/ppc-linux-nat.c b/gdb/ppc-linux-nat.c index 6d4bf2cc618..e4fcce694cf 100644 --- a/gdb/ppc-linux-nat.c +++ b/gdb/ppc-linux-nat.c @@ -2455,9 +2455,9 @@ ppc_linux_nat_target::num_memory_accesses (const std::vector struct value *v = iter.get (); /* Constants and values from the history are fine. */ - if (VALUE_LVAL (v) == not_lval || v->->deprecated_modifiable () == 0) + if (v->lval () == not_lval || v->->deprecated_modifiable () == 0) continue; - else if (VALUE_LVAL (v) == lval_memory) + else if (v->lval () == lval_memory) { /* A lazy memory lvalue is one that GDB never needed to fetch; we either just used its address (e.g., `a' in `a.b') or @@ -2509,7 +2509,7 @@ ppc_linux_nat_target::check_condition (CORE_ADDR watch_addr, return 0; if (num_accesses_left == 1 && num_accesses_right == 0 - && VALUE_LVAL (left_val) == lval_memory + && left_val->lval () == lval_memory && left_val->address () == watch_addr) { *data_value = value_as_long (right_val); @@ -2519,7 +2519,7 @@ ppc_linux_nat_target::check_condition (CORE_ADDR watch_addr, *len = check_typedef (left_val->type ())->length (); } else if (num_accesses_left == 0 && num_accesses_right == 1 - && VALUE_LVAL (right_val) == lval_memory + && right_val->lval () == lval_memory && right_val->address () == watch_addr) { *data_value = value_as_long (left_val); diff --git a/gdb/printcmd.c b/gdb/printcmd.c index 514261e7ea7..c6b55e97f40 100644 --- a/gdb/printcmd.c +++ b/gdb/printcmd.c @@ -297,7 +297,7 @@ print_formatted (struct value *val, int size, struct type *type = check_typedef (val->type ()); int len = type->length (); - if (VALUE_LVAL (val) == lval_memory) + if (val->lval () == lval_memory) next_address = val->address () + len; if (size) @@ -1888,7 +1888,7 @@ x_command (const char *exp, int from_tty) /* In rvalue contexts, such as this, functions are coerced into pointers to functions. This makes "x/i main" work. */ if (val->type ()->code () == TYPE_CODE_FUNC - && VALUE_LVAL (val) == lval_memory) + && val->lval () == lval_memory) next_address = val->address (); else next_address = value_as_address (val); @@ -2430,7 +2430,7 @@ printf_c_string (struct ui_file *stream, const char *format, const gdb_byte *str; if (value->type ()->code () != TYPE_CODE_PTR - && VALUE_LVAL (value) == lval_internalvar + && value->lval () == lval_internalvar && c_is_string_type_p (value->type ())) { size_t len = value->type ()->length (); @@ -2502,7 +2502,7 @@ printf_wide_c_string (struct ui_file *stream, const char *format, "wchar_t", NULL, 0); int wcwidth = wctype->length (); - if (VALUE_LVAL (value) == lval_internalvar + if (value->lval () == lval_internalvar && c_is_string_type_p (value->type ())) { str = value->contents ().data (); diff --git a/gdb/python/py-unwind.c b/gdb/python/py-unwind.c index 97b472f25b1..5b512c95dc7 100644 --- a/gdb/python/py-unwind.c +++ b/gdb/python/py-unwind.c @@ -272,7 +272,7 @@ unwind_infopy_add_saved_register (PyObject *self, PyObject *args) { struct value *user_reg_value = value_of_user_reg (regnum, pending_frame->frame_info); - if (VALUE_LVAL (user_reg_value) == lval_register) + if (user_reg_value->lval () == lval_register) regnum = VALUE_REGNUM (user_reg_value); if (regnum >= gdbarch_num_cooked_regs (pending_frame->gdbarch)) { diff --git a/gdb/rust-lang.c b/gdb/rust-lang.c index 27b5928298f..fb9db9fe31b 100644 --- a/gdb/rust-lang.c +++ b/gdb/rust-lang.c @@ -1204,7 +1204,7 @@ rust_subscript (struct type *expect_type, struct expression *exp, else new_type = base_type; - return value::zero (new_type, VALUE_LVAL (lhs)); + return value::zero (new_type, lhs->lval ()); } else { @@ -1470,7 +1470,7 @@ rust_structop::evaluate (struct type *expect_type, else result = value_struct_elt (&lhs, {}, field_name, NULL, "structure"); if (noside == EVAL_AVOID_SIDE_EFFECTS) - result = value::zero (result->type (), VALUE_LVAL (result)); + result = value::zero (result->type (), result->lval ()); return result; } diff --git a/gdb/stack.c b/gdb/stack.c index 934220e7c33..a26f65af1c4 100644 --- a/gdb/stack.c +++ b/gdb/stack.c @@ -1710,7 +1710,7 @@ info_frame_command_core (frame_info_ptr fi, bool selected_frame_p) if (!value->optimized_out () && value->entirely_available ()) { - if (VALUE_LVAL (value) == not_lval) + if (value->lval () == not_lval) { CORE_ADDR sp; enum bfd_endian byte_order = gdbarch_byte_order (gdbarch); @@ -1723,13 +1723,13 @@ info_frame_command_core (frame_info_ptr fi, bool selected_frame_p) gdb_puts (paddress (gdbarch, sp)); gdb_printf ("\n"); } - else if (VALUE_LVAL (value) == lval_memory) + else if (value->lval () == lval_memory) { gdb_printf (" Previous frame's sp at "); gdb_puts (paddress (gdbarch, value->address ())); gdb_printf ("\n"); } - else if (VALUE_LVAL (value) == lval_register) + else if (value->lval () == lval_register) { gdb_printf (" Previous frame's sp in %s\n", gdbarch_register_name (gdbarch, diff --git a/gdb/valarith.c b/gdb/valarith.c index 117662fda95..51965e4cf57 100644 --- a/gdb/valarith.c +++ b/gdb/valarith.c @@ -93,7 +93,7 @@ value_ptradd (struct value *arg1, LONGEST arg2) result = value_from_pointer (valptrtype, value_as_address (arg1) + sz * arg2); - if (VALUE_LVAL (result) != lval_internalvar) + if (result->lval () != lval_internalvar) result->set_component_location (arg1); return result; } @@ -159,7 +159,7 @@ value_subscript (struct value *array, LONGEST index) if (!lowerbound.has_value ()) lowerbound = 0; - if (VALUE_LVAL (array) != lval_memory) + if (array->lval () != lval_memory) return value_subscripted_rvalue (array, index, *lowerbound); gdb::optional upperbound @@ -220,7 +220,7 @@ value_subscripted_rvalue (struct value *array, LONGEST index, if (index < lowerbound || (!array_upper_bound_undefined && elt_offs >= type_length_units (array_type)) - || (VALUE_LVAL (array) != lval_memory && array_upper_bound_undefined)) + || (array->lval () != lval_memory && array_upper_bound_undefined)) { if (type_not_associated (array_type)) error (_("no such vector element (vector not associated)")); @@ -517,7 +517,7 @@ value_x_binop (struct value *arg1, struct value *arg2, enum exp_opcode op, if (return_type == NULL) error (_("Xmethod is missing return type.")); - return value::zero (return_type, VALUE_LVAL (arg1)); + return value::zero (return_type, arg1->lval ()); } return argvec[0]->call_xmethod (argvec.slice (1)); } @@ -526,7 +526,7 @@ value_x_binop (struct value *arg1, struct value *arg2, enum exp_opcode op, struct type *return_type; return_type = check_typedef (argvec[0]->type ())->target_type (); - return value::zero (return_type, VALUE_LVAL (arg1)); + return value::zero (return_type, arg1->lval ()); } return call_function_by_hand (argvec[0], NULL, argvec.slice (1, 2 - static_memfuncp)); @@ -630,7 +630,7 @@ value_x_unop (struct value *arg1, enum exp_opcode op, enum noside noside) if (return_type == NULL) error (_("Xmethod is missing return type.")); - return value::zero (return_type, VALUE_LVAL (arg1)); + return value::zero (return_type, arg1->lval ()); } return argvec[0]->call_xmethod (argvec[1]); } @@ -639,7 +639,7 @@ value_x_unop (struct value *arg1, enum exp_opcode op, enum noside noside) struct type *return_type; return_type = check_typedef (argvec[0]->type ())->target_type (); - return value::zero (return_type, VALUE_LVAL (arg1)); + return value::zero (return_type, arg1->lval ()); } return call_function_by_hand (argvec[0], NULL, argvec.slice (1, nargs)); diff --git a/gdb/valops.c b/gdb/valops.c index 6a0a6706157..6d305756625 100644 --- a/gdb/valops.c +++ b/gdb/valops.c @@ -653,7 +653,7 @@ value_cast (struct type *type, struct value *arg2) arg2->set_pointed_to_offset (0); /* pai: chk_val */ return arg2; } - else if (VALUE_LVAL (arg2) == lval_memory) + else if (arg2->lval () == lval_memory) return value_at_lazy (to_type, arg2->address ()); else { @@ -971,7 +971,7 @@ value_one (struct type *type) } /* value_one result is never used for assignments to. */ - gdb_assert (VALUE_LVAL (val) == not_lval); + gdb_assert (val->lval () == not_lval); return val; } @@ -1095,7 +1095,7 @@ value_assign (struct value *toval, struct value *fromval) toval = coerce_ref (toval); type = toval->type (); - if (VALUE_LVAL (toval) != lval_internalvar) + if (toval->lval () != lval_internalvar) fromval = value_cast (type, fromval); else { @@ -1112,7 +1112,7 @@ value_assign (struct value *toval, struct value *fromval) and then restore the new frame afterwards. */ old_frame = get_frame_id (deprecated_safe_get_selected_frame ()); - switch (VALUE_LVAL (toval)) + switch (toval->lval ()) { case lval_internalvar: set_internalvar (VALUE_INTERNALVAR (toval), fromval); @@ -1292,7 +1292,7 @@ value_assign (struct value *toval, struct value *fromval) cause the frame cache and regcache to be out of date. Assigning to memory also can. We just do this on all assignments to registers or memory, for simplicity's sake; I doubt the slowdown matters. */ - switch (VALUE_LVAL (toval)) + switch (toval->lval ()) { case lval_memory: case lval_register: @@ -1366,7 +1366,7 @@ value_repeat (struct value *arg1, int count) { struct value *val; - if (VALUE_LVAL (arg1) != lval_memory) + if (arg1->lval () != lval_memory) error (_("Only values in memory can be extended with '@'.")); if (count < 1) error (_("Invalid number %d of repetitions."), count); @@ -1406,7 +1406,7 @@ address_of_variable (struct symbol *var, const struct block *b) val = value_of_variable (var, b); type = val->type (); - if ((VALUE_LVAL (val) == lval_memory && val->lazy ()) + if ((val->lval () == lval_memory && val->lazy ()) || type->code () == TYPE_CODE_FUNC) { CORE_ADDR addr = val->address (); @@ -1415,7 +1415,7 @@ address_of_variable (struct symbol *var, const struct block *b) } /* Not a memory address; check what the problem was. */ - switch (VALUE_LVAL (val)) + switch (val->lval ()) { case lval_register: { @@ -1452,9 +1452,9 @@ value_must_coerce_to_target (struct value *val) struct type *valtype; /* The only lval kinds which do not live in target memory. */ - if (VALUE_LVAL (val) != not_lval - && VALUE_LVAL (val) != lval_internalvar - && VALUE_LVAL (val) != lval_xcallable) + if (val->lval () != not_lval + && val->lval () != lval_internalvar + && val->lval () != lval_xcallable) return false; valtype = check_typedef (val->type ()); @@ -1522,7 +1522,7 @@ value_coerce_array (struct value *arg1) be a good time to do so. */ arg1 = value_coerce_to_target (arg1); - if (VALUE_LVAL (arg1) != lval_memory) + if (arg1->lval () != lval_memory) error (_("Attempt to take address of value not located in memory.")); return value_from_pointer (lookup_pointer_type (type->target_type ()), @@ -1537,7 +1537,7 @@ value_coerce_function (struct value *arg1) { struct value *retval; - if (VALUE_LVAL (arg1) != lval_memory) + if (arg1->lval () != lval_memory) error (_("Attempt to take address of value not located in memory.")); retval = value_from_pointer (lookup_pointer_type (arg1->type ()), @@ -1586,7 +1586,7 @@ value_addr (struct value *arg1) then this would be a good time to force it to memory. */ arg1 = value_coerce_to_target (arg1); - if (VALUE_LVAL (arg1) != lval_memory) + if (arg1->lval () != lval_memory) error (_("Attempt to take address of value not located in memory.")); /* Get target memory address. */ @@ -1637,7 +1637,7 @@ value_ind (struct value *arg1) base_type = check_typedef (arg1->type ()); - if (VALUE_LVAL (arg1) == lval_computed) + if (arg1->lval () == lval_computed) { const struct lval_funcs *funcs = arg1->computed_funcs (); @@ -3963,7 +3963,7 @@ value_full_object (struct value *argp, } /* Check if object is in memory. */ - if (VALUE_LVAL (argp) != lval_memory) + if (argp->lval () != lval_memory) { warning (_("Couldn't retrieve complete object of RTTI " "type %s; object may be in register(s)."), @@ -4077,7 +4077,7 @@ value_slice (struct value *array, int lowbound, int length) slice_range_type); slice_type->set_code (array_type->code ()); - if (VALUE_LVAL (array) == lval_memory && array->lazy ()) + if (array->lval () == lval_memory && array->lazy ()) slice = value::allocate_lazy (slice_type); else { diff --git a/gdb/value.c b/gdb/value.c index bba78c3d10e..2cc37bc79b1 100644 --- a/gdb/value.c +++ b/gdb/value.c @@ -149,14 +149,14 @@ static struct cmd_list_element *functionlist; value::~value () { - if (VALUE_LVAL (this) == lval_computed) + if (this->lval () == lval_computed) { const struct lval_funcs *funcs = m_location.computed.funcs; if (funcs->free_closure) funcs->free_closure (this); } - else if (VALUE_LVAL (this) == lval_xcallable) + else if (this->lval () == lval_xcallable) delete m_location.xm_worker; } @@ -1143,9 +1143,9 @@ value::optimized_out () { /* See if we can compute the result without fetching the value. */ - if (VALUE_LVAL (this) == lval_memory) + if (this->lval () == lval_memory) return false; - else if (VALUE_LVAL (this) == lval_computed) + else if (this->lval () == lval_computed) { const struct lval_funcs *funcs = m_location.computed.funcs; @@ -1387,7 +1387,7 @@ value::copy () const } val->m_parent = m_parent; - if (VALUE_LVAL (val) == lval_computed) + if (val->lval () == lval_computed) { const struct lval_funcs *funcs = val->m_location.computed.funcs; @@ -1421,7 +1421,7 @@ make_cv_value (int cnst, int voltl, struct value *v) struct value * value::non_lval () { - if (VALUE_LVAL (this) != not_lval) + if (this->lval () != not_lval) { struct type *enc_type = enclosing_type (); struct value *val = value::allocate (enc_type); @@ -1440,7 +1440,7 @@ value::non_lval () void value::force_lval (CORE_ADDR addr) { - gdb_assert (VALUE_LVAL (this) == not_lval); + gdb_assert (this->lval () == not_lval); write_memory (addr, contents_raw ().data (), type ()->length ()); m_lval = lval_memory; @@ -1498,13 +1498,13 @@ value::set_component_location (const struct value *whole) carry around both the parent value contents, and the contents of any dynamic fields within the parent. This is a substantial change to how values work in GDB. */ - if (VALUE_LVAL (this) == lval_internalvar_component) + if (this->lval () == lval_internalvar_component) { gdb_assert (lazy ()); m_lval = lval_memory; } else - gdb_assert (VALUE_LVAL (this) == lval_memory); + gdb_assert (this->lval () == lval_memory); set_address (TYPE_DATA_LOCATION_ADDR (type)); } } @@ -2009,7 +2009,7 @@ set_internalvar (struct internalvar *var, struct value *val) break; case TYPE_CODE_INTERNAL_FUNCTION: - gdb_assert (VALUE_LVAL (val) == lval_internalvar); + gdb_assert (val->lval () == lval_internalvar); new_kind = INTERNALVAR_FUNCTION; get_internalvar_function (VALUE_INTERNALVAR (val), &new_data.fn.function); @@ -2132,7 +2132,7 @@ value_internal_function_name (struct value *val) struct internal_function *ifn; int result; - gdb_assert (VALUE_LVAL (val) == lval_internalvar); + gdb_assert (val->lval () == lval_internalvar); result = get_internalvar_function (VALUE_INTERNALVAR (val), &ifn); gdb_assert (result); @@ -2147,7 +2147,7 @@ call_internal_function (struct gdbarch *gdbarch, struct internal_function *ifn; int result; - gdb_assert (VALUE_LVAL (func) == lval_internalvar); + gdb_assert (func->lval () == lval_internalvar); result = get_internalvar_function (VALUE_INTERNALVAR (func), &ifn); gdb_assert (result); @@ -2739,7 +2739,7 @@ value::primitive_field (LONGEST offset, int fieldno, struct type *arg_type) LONGEST boffset; /* Lazy register values with offsets are not supported. */ - if (VALUE_LVAL (this) == lval_register && lazy ()) + if (this->lval () == lval_register && lazy ()) fetch_lazy (); /* We special case virtual inheritance here because this @@ -2783,7 +2783,7 @@ value::primitive_field (LONGEST offset, int fieldno, struct type *arg_type) / (HOST_CHAR_BIT * unit_size)); /* Lazy register values with offsets are not supported. */ - if (VALUE_LVAL (this) == lval_register && lazy ()) + if (this->lval () == lval_register && lazy ()) fetch_lazy (); if (lazy ()) @@ -3377,7 +3377,7 @@ value_from_component (struct value *whole, struct type *type, LONGEST offset) { struct value *v; - if (VALUE_LVAL (whole) == lval_memory && whole->lazy ()) + if (whole->lval () == lval_memory && whole->lazy ()) v = value::allocate_lazy (type); else { @@ -3574,7 +3574,7 @@ value_fetch_lazy_bitfield (struct value *val) static void value_fetch_lazy_memory (struct value *val) { - gdb_assert (VALUE_LVAL (val) == lval_memory); + gdb_assert (val->lval () == lval_memory); CORE_ADDR addr = val->address (); struct type *type = check_typedef (val->enclosing_type ()); @@ -3599,7 +3599,7 @@ value_fetch_lazy_register (struct value *val) refer to the entire register. */ gdb_assert (val->offset () == 0); - while (VALUE_LVAL (new_val) == lval_register && new_val->lazy ()) + while (new_val->lval () == lval_register && new_val->lazy ()) { struct frame_id next_frame_id = VALUE_NEXT_FRAME_ID (new_val); @@ -3634,7 +3634,7 @@ value_fetch_lazy_register (struct value *val) sniffer trying to unwind), bypassing its validations. In any case, it should always be an internal error to end up in this situation. */ - if (VALUE_LVAL (new_val) == lval_register + if (new_val->lval () == lval_register && new_val->lazy () && VALUE_NEXT_FRAME_ID (new_val) == next_frame_id) internal_error (_("infinite loop while fetching a register")); @@ -3678,10 +3678,10 @@ value_fetch_lazy_register (struct value *val) int i; gdb::array_view buf = new_val->contents (); - if (VALUE_LVAL (new_val) == lval_register) + if (new_val->lval () == lval_register) gdb_printf (&debug_file, " register=%d", VALUE_REGNUM (new_val)); - else if (VALUE_LVAL (new_val) == lval_memory) + else if (new_val->lval () == lval_memory) gdb_printf (&debug_file, " address=%s", paddress (gdbarch, new_val->address ())); @@ -3721,11 +3721,11 @@ value::fetch_lazy () } else if (bitsize ()) value_fetch_lazy_bitfield (this); - else if (VALUE_LVAL (this) == lval_memory) + else if (this->lval () == lval_memory) value_fetch_lazy_memory (this); - else if (VALUE_LVAL (this) == lval_register) + else if (this->lval () == lval_register) value_fetch_lazy_register (this); - else if (VALUE_LVAL (this) == lval_computed + else if (this->lval () == lval_computed && computed_funcs ()->read != NULL) computed_funcs ()->read (this); else diff --git a/gdb/value.h b/gdb/value.h index 36bc00629d8..1b51810f022 100644 --- a/gdb/value.h +++ b/gdb/value.h @@ -330,9 +330,6 @@ struct value uses. */ void *computed_closure () const; - enum lval_type *deprecated_lval_hack () - { return &m_lval; } - enum lval_type lval () const { return m_lval; } @@ -920,13 +917,6 @@ struct lval_funcs extern void error_value_optimized_out (void); -/* While the following fields are per- VALUE .CONTENT .PIECE (i.e., a - single value might have multiple LVALs), this hacked interface is - limited to just the first PIECE. Expect further change. */ -/* Type of value; either not an lval, or one of the various different - possible kinds of lval. */ -#define VALUE_LVAL(val) (*((val)->deprecated_lval_hack ())) - /* Pointer to internal variable. */ #define VALUE_INTERNALVAR(val) (*((val)->deprecated_internalvar_hack ())) diff --git a/gdb/varobj.c b/gdb/varobj.c index 72d5e7f2a25..37b64a0c4bd 100644 --- a/gdb/varobj.c +++ b/gdb/varobj.c @@ -2270,7 +2270,7 @@ varobj_editable_p (const struct varobj *var) struct type *type; if (!(var->root->is_valid && var->value != nullptr - && VALUE_LVAL (var->value.get ()))) + && var->value.get ()->lval ())) return false; type = varobj_get_value_type (var);