From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 2126) id 8A72E3858D35; Mon, 13 Feb 2023 22:29:51 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 8A72E3858D35 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1676327391; bh=2b11xqq8/z2WSnq2z4xbTpDD7AMATFo7pxESYpv0/2o=; h=From:To:Subject:Date:From; b=H3vyLsJESVi06fn6kXG6Ze27sG6EqaFivYncCCPuU5nqca3dPmqqMfAtQ7OlY8Hw6 m4IFagqbDU0+CbMY6egazLRT2YIbYSacRyJC+9ibba6af1MkJoL/W+MtvEjyJLNwGz rnkLWGWg5uRizObrdK05AA/dnJAJrGWs5lczo66Q= Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable From: Tom Tromey To: gdb-cvs@sourceware.org Subject: [binutils-gdb] Turn value_bits_synthetic_pointer into a method X-Act-Checkin: binutils-gdb X-Git-Author: Tom Tromey X-Git-Refname: refs/heads/master X-Git-Oldrev: 02744ba9a2cfb7d1d2b8ebb6e80178a68bf56e06 X-Git-Newrev: e989e63761c66d632e1e3b9b40feb12e76cc5dd3 Message-Id: <20230213222951.8A72E3858D35@sourceware.org> Date: Mon, 13 Feb 2023 22:29:51 +0000 (GMT) List-Id: https://sourceware.org/git/gitweb.cgi?p=3Dbinutils-gdb.git;h=3De989e63761c6= 6d632e1e3b9b40feb12e76cc5dd3 commit e989e63761c66d632e1e3b9b40feb12e76cc5dd3 Author: Tom Tromey Date: Tue Jan 31 14:17:50 2023 -0700 Turn value_bits_synthetic_pointer into a method =20 This changes value_bits_synthetic_pointer to be a method of value. =20 Approved-By: Simon Marchi Diff: --- 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_fil= e *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 =3D check_typedef (value->type ()); =20 - 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 =3D (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 =3D (i =3D=3D start) ? startrest : 0; int comp_length =3D (i =3D=3D end) ? endrest : elsize; =20 - 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_o= ffset, + comp_length)) return 0; } =20 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, st= ruct 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 6896478c0f8..fc9c6dcfe64 100644 --- a/gdb/valops.c +++ b/gdb/valops.c @@ -1556,8 +1556,8 @@ value_addr (struct value *arg1) =20 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 =3D coerce_ref (arg1); else { diff --git a/gdb/valprint.c b/gdb/valprint.c index 2fa18b8f8e8..08e8826e5b9 100644 --- a/gdb/valprint.c +++ b/gdb/valprint.c @@ -381,8 +381,8 @@ valprint_check_validity (struct ui_file *stream, return 0; } =20 - if (value_bits_synthetic_pointer (val, TARGET_CHAR_BIT * embedded_of= fset, - TARGET_CHAR_BIT * type->length ())) + if (val->bits_synthetic_pointer (TARGET_CHAR_BIT * embedded_offset, + TARGET_CHAR_BIT * type->length ())) { const int is_ref =3D type->code () =3D=3D TYPE_CODE_REF; int ref_is_addressable =3D 0; @@ -568,9 +568,8 @@ generic_val_print_ref (struct type *type, struct type *elttype =3D check_typedef (type->target_type ()); struct value *deref_val =3D NULL; const int value_is_synthetic - =3D value_bits_synthetic_pointer (original_value, - TARGET_CHAR_BIT * embedded_offset, - TARGET_CHAR_BIT * type->length ()); + =3D original_value->bits_synthetic_pointer (TARGET_CHAR_BIT * embedded= _offset, + TARGET_CHAR_BIT * type->length ()); const int must_coerce_ref =3D ((options->addressprint && value_is_synthe= tic) || options->deref_ref); const int type_is_defined =3D elttype->code () !=3D TYPE_CODE_UNDEF; diff --git a/gdb/value.c b/gdb/value.c index 6198fb84d22..75f8dc49b0a 100644 --- a/gdb/value.c +++ b/gdb/value.c @@ -1365,15 +1365,13 @@ mark_value_bits_optimized_out (struct value *value, } =20 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 !=3D lval_computed - || !value->m_location.computed.funcs->check_synthetic_pointer) + if (m_lval !=3D 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); } =20 const struct lval_funcs * diff --git a/gdb/value.h b/gdb/value.h index b025d678c6d..57385842919 100644 --- a/gdb/value.h +++ b/gdb/value.h @@ -455,6 +455,11 @@ public: values. */ bool contents_eq (const struct value *val2) const; =20 + /* 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; + =20 /* Type of value; either not an lval, or one of the various different possible kinds of lval. */ @@ -862,12 +867,6 @@ extern struct value *coerce_ref (struct value *value); =20 extern struct value *coerce_array (struct value *value); =20 -/* 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