From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from alt-proxy28.mail.unifiedlayer.com (alt-proxy28.mail.unifiedlayer.com [74.220.216.123]) by sourceware.org (Postfix) with ESMTPS id 026313858433 for ; Mon, 13 Feb 2023 03:15:28 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 026313858433 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 progateway1.mail.pro1.eigbox.com (Postfix) with ESMTP id 7A78B10040635 for ; Mon, 13 Feb 2023 03:15:27 +0000 (UTC) Received: from box5379.bluehost.com ([162.241.216.53]) by cmsmtp with ESMTP id RPJPpyfLlA1zNRPJPplPW5; Mon, 13 Feb 2023 03:15:27 +0000 X-Authority-Reason: nr=8 X-Authority-Analysis: v=2.4 cv=CqN6zl0D c=1 sm=1 tr=0 ts=63e9ab4f 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=7d_E57ReAAAA:8 a=giISpiULoCpoO6mOuxsA:9 a=QEXdDO2ut3YA:10:nop_charset_2 a=jhqOcbufqs7Y1TYCrUUU:22 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=tromey.com; s=default; h=Cc:To:In-Reply-To:References:Message-Id: Content-Transfer-Encoding:Content-Type:MIME-Version:Subject:Date:From:Sender: Reply-To: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=slk6t2sjYGpu0m3wIf7bdv9Nf1K2qzW6HcpEAz8pN8s=; b=mV69M7NzIooAm1J1/fGsCvf8W5 rnb+Gfm8SAY/8Taz+xrEot58stf8G3Rgz5twOEZYDX+kSduFUki4UJbzfpFyCmzVfzWCKk7oBtXjS d6R7ksVM/MppaWO2eKW/4R1YH; Received: from 75-166-130-93.hlrn.qwest.net ([75.166.130.93]:37668 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 1pRPJP-001AGJ-5i; Sun, 12 Feb 2023 20:15:27 -0700 From: Tom Tromey Date: Sun, 12 Feb 2023 20:15:30 -0700 Subject: [PATCH v3 14/50] Turn some value offset functions into method MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit Message-Id: <20230209-submit-value-fixups-2023-v3-14-45e91a20c742@tromey.com> References: <20230209-submit-value-fixups-2023-v3-0-45e91a20c742@tromey.com> In-Reply-To: <20230209-submit-value-fixups-2023-v3-0-45e91a20c742@tromey.com> To: gdb-patches@sourceware.org Cc: Simon Marchi 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: 1pRPJP-001AGJ-5i 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]:37668 X-Source-Auth: tom+tromey.com X-Email-Count: 31 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 List-Id: This changes various offset-related functions to be methods of value. Much of this patch was written by script. Approved-By: Simon Marchi --- 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 9870e0da337..079b64dbbe6 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 efa780a897a..c56e0404471 100644 --- a/gdb/value.c +++ b/gdb/value.c @@ -1406,30 +1406,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) { @@ -1619,7 +1595,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; @@ -1691,8 +1667,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; @@ -3023,7 +2999,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); @@ -3047,7 +3023,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 @@ -3063,7 +3039,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)) { @@ -3091,12 +3067,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; @@ -3693,11 +3669,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; @@ -3721,14 +3697,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; @@ -3773,7 +3749,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); @@ -3989,8 +3965,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 a3d07c0b5fd..d27ac7c5cf8 100644 --- a/gdb/value.h +++ b/gdb/value.h @@ -215,6 +215,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 @@ -455,11 +468,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). -- 2.39.1