From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 2126) id 059803858D33; Mon, 13 Feb 2023 22:30:22 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 059803858D33 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1676327422; bh=vOLwG5gykluEg4zudRCVRrLgdjk1Q4iiGPjImePwSmQ=; h=From:To:Subject:Date:From; b=fzXLU2FsLU3xuZlOeSQONIiUb7BbqSc5vZ3jclZRBA/xoKL63GSNA0ns/Q2zsZdDe tiYRvmYLfRdAZrjlvgE0PcxUlrfkoXp21a6C/uvHxbBrkYW8ux0p5gW9OlLPmUjpzw R3n2EuvB2Jk2QEA1OdNIvM+pNDKDuTx4FM0os7XI= 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 many optimized-out value functions into methods X-Act-Checkin: binutils-gdb X-Git-Author: Tom Tromey X-Git-Refname: refs/heads/master X-Git-Oldrev: cda0334434412d888443e9a98386255f2e0c2eab X-Git-Newrev: d00664dbba2802bacfed2335b6f249fc418182a0 Message-Id: <20230213223022.059803858D33@sourceware.org> Date: Mon, 13 Feb 2023 22:30:22 +0000 (GMT) List-Id: https://sourceware.org/git/gitweb.cgi?p=3Dbinutils-gdb.git;h=3Dd00664dbba28= 02bacfed2335b6f249fc418182a0 commit d00664dbba2802bacfed2335b6f249fc418182a0 Author: Tom Tromey Date: Tue Jan 31 16:13:08 2023 -0700 Turn many optimized-out value functions into methods =20 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. =20 Approved-By: Simon Marchi Diff: --- 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/f-valprint.c | 16 ++--- 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/valarith.c | 4 +- gdb/valops.c | 6 +- gdb/valprint.c | 25 ++++--- gdb/value.c | 136 +++++++++++++++-------------------= ---- gdb/value.h | 124 +++++++++++++++++----------------- 37 files changed, 237 insertions(+), 272 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 =3D=3D AARCH64_SVE_Z0_REGNUM); =20 if (regcache->raw_read (v_regnum, reg_buf) !=3D 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); =20 @@ -2801,7 +2801,7 @@ aarch64_pseudo_read_value (struct gdbarch *gdbarch, r= eadable_regcache *regcache, =20 /* Read the bottom 4 bytes of X. */ if (regcache->raw_read_part (x_regnum, offset, 4, data) !=3D REG_VAL= ID) - mark_value_bytes_unavailable (result_value, 0, 4); + result_value->mark_bytes_unavailable (0, 4); else memcpy (result_value->contents_raw ().data (), data, 4); =20 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 ty= pe *type) { struct value *result; =20 - if (value_optimized_out (val)) + if (val->optimized_out ()) result =3D 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_fil= e *stream, int recurse, gdb_printf (stream, "("); print_optional_low_bound (stream, type, options); =20 - 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 regn= um, struct value *value =3D get_frame_register_value (frame, regnum); =20 gdb_assert (value !=3D NULL); - *optimizedp =3D value_optimized_out (value); - *unavailablep =3D !value_entirely_available (value); + *optimizedp =3D value->optimized_out (); + *unavailablep =3D !value->entirely_available (); =20 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 *gdbar= ch, if (status =3D=3D 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 *gdbar= ch, if (status =3D=3D 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 *gdbar= ch, if (status =3D=3D 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 =3D 0; =20 @@ -520,7 +520,7 @@ c_value_print (struct value *val, struct ui_file *strea= m, /* Pointer to class, check real type of object. */ gdb_printf (stream, "("); =20 - if (value_entirely_available (val)) + if (val->entirely_available ()) { real_type =3D 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 =3D compile_register_name_demangle (gdbarch, reg_name); =20 regval =3D 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); =20 inferior_addr =3D 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; =20 - 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 () =3D=3D TYPE_CODE_INT && strcmp (type->field (0).name (), "length") =3D=3D 0 && strcmp (type->field (1).name (), "ptr") =3D=3D 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_op= timized) { 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; } =20 @@ -358,7 +358,7 @@ rw_pieced_value (value *v, value *from, bool check_opti= mized) =20 if (from !=3D nullptr) { - mark_value_bits_optimized_out (v, offset, this_size_bits); + v->mark_bits_optimized_out (offset, this_size_bits); break; } =20 @@ -390,7 +390,7 @@ rw_pieced_value (value *v, value *from, bool check_opti= mized) =20 if (from !=3D nullptr) { - mark_value_bits_optimized_out (v, offset, this_size_bits); + v->mark_bits_optimized_out (offset, this_size_bits); break; } =20 @@ -413,7 +413,7 @@ rw_pieced_value (value *v, value *from, bool check_opti= mized) case DWARF_VALUE_IMPLICIT_POINTER: if (from !=3D nullptr) { - mark_value_bits_optimized_out (v, offset, this_size_bits); + v->mark_bits_optimized_out (offset, this_size_bits); break; } =20 @@ -424,7 +424,7 @@ rw_pieced_value (value *v, value *from, bool check_opti= mized) 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; =20 default: @@ -960,7 +960,7 @@ dwarf_expr_context::fetch_result (struct type *type, st= ruct type *subobj_type, =20 retval =3D 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, fra= me_info_ptr frame, { free_values.free_to_mark (); retval =3D 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 =3D=3D NO_ENTRY_VALUE_ERROR) @@ -1609,7 +1609,7 @@ dwarf2_locexpr_baton_eval (const struct dwarf2_locexp= r_baton *dlbaton, throw; } =20 - if (value_optimized_out (result)) + if (result->optimized_out ()) return 0; =20 if (VALUE_LVAL (result) =3D=3D lval_memory) @@ -1709,7 +1709,7 @@ dwarf2_evaluate_property (const struct dynamic_prop *= prop, val =3D 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 =3D value_as_address (val); return true; diff --git a/gdb/f-valprint.c b/gdb/f-valprint.c index 824a303fdc4..e96892947af 100644 --- a/gdb/f-valprint.c +++ b/gdb/f-valprint.c @@ -269,11 +269,11 @@ public: struct value *e_val =3D value_from_component (m_val, elt_type, elt_off); struct value *e_prev =3D value_from_component (m_val, elt_type, elt_off_prev); - repeated =3D ((value_entirely_available (e_prev) - && value_entirely_available (e_val) + repeated =3D ((e_prev->entirely_available () + && e_val->entirely_available () && e_prev->contents_eq (e_val)) - || (value_entirely_unavailable (e_prev) - && value_entirely_unavailable (e_val))); + || (e_prev->entirely_unavailable () + && e_val->entirely_unavailable ())); } =20 if (repeated) @@ -376,11 +376,11 @@ private: struct value *e_val1 =3D value_from_component (val, type, offset1); struct value *e_val2 =3D value_from_component (val, type, offset2); =20 - return ((value_entirely_available (e_val1) - && value_entirely_available (e_val2) + return ((e_val1->entirely_available () + && e_val2->entirely_available () && e_val1->contents_eq (e_val2)) - || (value_entirely_unavailable (e_val1) - && value_entirely_unavailable (e_val2))); + || (e_val1->entirely_unavailable () + && e_val2->entirely_unavailable ())); } } =20 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, fra= me_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 =3D gdbarch_value_from_register (gdbarch, type, regnum, null_frame= _id); read_frame_register_value (value, frame); =20 - 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 628b18d6708..bf9b055878a 100644 --- a/gdb/frame.c +++ b/gdb/frame.c @@ -1189,8 +1189,8 @@ frame_register_unwind (frame_info_ptr next_frame, int= regnum, =20 gdb_assert (value !=3D NULL); =20 - *optimizedp =3D value_optimized_out (value); - *unavailablep =3D !value_entirely_available (value); + *optimizedp =3D value->optimized_out (); + *unavailablep =3D !value->entirely_available (); *lvalp =3D VALUE_LVAL (value); *addrp =3D value->address (); if (*lvalp =3D=3D lval_register) @@ -1289,7 +1289,7 @@ frame_unwind_register_value (frame_info_ptr next_fram= e, int regnum) string_file debug_file; =20 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_f= rame, int regnum) =20 gdb_assert (value !=3D NULL); =20 - 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) =20 gdb_assert (value !=3D NULL); =20 - 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, i= nt regnum, { struct value *regval =3D get_frame_register_value (frame, regnum); =20 - if (!value_optimized_out (regval) - && value_entirely_available (regval)) + if (!regval->optimized_out () + && regval->entirely_available ()) { struct gdbarch *gdbarch =3D get_frame_arch (frame); enum bfd_endian byte_order =3D gdbarch_byte_order (gdbarch); @@ -1537,8 +1537,8 @@ get_frame_register_bytes (frame_info_ptr frame, int r= egnum, =3D frame_unwind_register_value (frame_info_ptr (frame->next), regnum); gdb_assert (value !=3D NULL); - *optimizedp =3D value_optimized_out (value); - *unavailablep =3D !value_entirely_available (value); + *optimizedp =3D value->optimized_out (); + *unavailablep =3D !value->entirely_available (); =20 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 =3D type->field (i).loc_bitpos () / 8; field_length =3D field_type->length (); =20 - 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")); =20 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 (); =20 /* 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; =20 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) =20 return gdbscm_wrap ([=3D] { - return scm_from_bool (value_optimized_out (v_smob->value)); + return scm_from_bool (v_smob->value->optimized_out ()); }); } =20 diff --git a/gdb/i386-tdep.c b/gdb/i386-tdep.c index ed61ee1a9b3..c8c7a1e6e45 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 =3D regcache->raw_read (fpnum, raw_buf); if (status !=3D 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 =3D regcache->raw_read (I387_BND0R_REGNUM (tdep) + regnum, raw_buf); if (status !=3D REG_VALID) - mark_value_bytes_unavailable (result_value, 0, 16); + result_value->mark_bytes_unavailable (0, 16); else { enum bfd_endian byte_order =3D gdbarch_byte_order (target_gdbarch (= )); @@ -3426,7 +3426,7 @@ i386_pseudo_register_read_into_value (struct gdbarch = *gdbarch, /* Extract (always little endian). */ status =3D regcache->raw_read (tdep->k0_regnum + regnum, raw_buf); if (status !=3D 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 =3D regcache->raw_read (I387_XMM0_REGNUM (tdep) + regnum, raw_buf); if (status !=3D REG_VALID) - mark_value_bytes_unavailable (result_value, 0, 16); + result_value->mark_bytes_unavailable (0, 16); else memcpy (buf, raw_buf, 16); =20 @@ -3448,7 +3448,7 @@ i386_pseudo_register_read_into_value (struct gdbarch = *gdbarch, status =3D regcache->raw_read (tdep->ymm0h_regnum + regnum, raw_buf); if (status !=3D 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 !=3D REG_VALID) - mark_value_bytes_unavailable (result_value, 0, 16); + result_value->mark_bytes_unavailable (0, 16); else memcpy (buf, raw_buf, 16); =20 @@ -3468,7 +3468,7 @@ i386_pseudo_register_read_into_value (struct gdbarch = *gdbarch, - num_lower_zmm_regs, raw_buf); if (status !=3D 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 =3D regcache->raw_read (tdep->zmm0h_regnum + regnum, raw_buf); if (status !=3D 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 gdbarc= h *gdbarch, status =3D regcache->raw_read (I387_XMM0_REGNUM (tdep) + regnum, raw_buf); if (status !=3D 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 =3D regcache->raw_read (tdep->ymm0h_regnum + regnum, raw_buf); if (status !=3D 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 gdbarc= h *gdbarch, status =3D regcache->raw_read (I387_XMM16_REGNUM (tdep) + regnum, raw_buf); if (status !=3D 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 =3D regcache->raw_read (tdep->ymm16h_regnum + regnum, raw_buf); if (status !=3D 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 =3D regcache->raw_read (gpnum, raw_buf); if (status !=3D 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 =3D regcache->raw_read (gpnum % 4, raw_buf); if (status !=3D 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 >=3D 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 =3D (fpreg + 8 - top) % 8 + I387_ST0_REGNUM (tdep); regval =3D get_frame_register_value (frame, regnum); =20 - if (value_entirely_available (regval)) + if (regval->entirely_available ()) { const gdb_byte *raw =3D regval->contents ().data (); =20 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); =20 - print_raw_format =3D (value_entirely_available (val) - && !value_optimized_out (val)); + print_raw_format =3D (val->entirely_available () + && !val->optimized_out ()); =20 /* 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_inf= o *tp, b, VAR_DOMAIN); value =3D 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 =3D value_as_address (value); =20 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))); =20 if (skip_unavailable && arg->val !=3D 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; =20 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, in= t format, struct value *val =3D value_of_register (regnum, frame); struct value_print_options opts; =20 - if (skip_unavailable && !value_entirely_available (val)) + if (skip_unavailable && !val->entirely_available ()) return; =20 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_in= fo_ptr frame, =20 /* OK: get the data in raw format. */ value =3D 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 =3D val->type (); struct value_print_options opts; =20 - 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 8619e38aea4..0b3c2e00b4c 100644 --- a/gdb/printcmd.c +++ b/gdb/printcmd.c @@ -1280,8 +1280,8 @@ should_validate_memtags (struct value *value) =20 /* 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; =20 /* 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 (); =20 /* 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; =20 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 *clo= sure) =20 try { - opt =3D value_optimized_out (value); + opt =3D 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 *b= uf) =20 computed =3D 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 ()) =3D=3D REG_UNAVAILABLE) - mark_value_bytes_unavailable (result, 0, - result->type ()->length ()); + result->mark_bytes_unavailable (0, + result->type ()->length ()); =20 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 *gdbarc= h, return; } =20 - print_raw_format =3D (value_entirely_available (val) - && !value_optimized_out (val)); + print_raw_format =3D (val->entirely_available () + && !val->optimized_out ()); =20 if (regtype->code () =3D=3D TYPE_CODE_FLT || (regtype->code () =3D=3D 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_fram= e, int regnum) struct value *val; =20 val =3D frame_unwind_register_value (this_frame, S390_PSWA_REGNUM); - if (!value_optimized_out (val)) + if (!val->optimized_out ()) { LONGEST pswa =3D value_as_long (val); =20 @@ -2216,7 +2216,7 @@ s390_unwind_pseudo_register (frame_info_ptr this_fram= e, int regnum) struct value *val; =20 val =3D frame_unwind_register_value (this_frame, S390_PSWM_REGNUM); - if (!value_optimized_out (val)) + if (!val->optimized_out ()) { LONGEST pswm =3D value_as_long (val); =20 @@ -2235,7 +2235,7 @@ s390_unwind_pseudo_register (frame_info_ptr this_fram= e, int regnum) struct value *val; =20 val =3D frame_unwind_register_value (this_frame, S390_R0_REGNUM + re= g); - if (!value_optimized_out (val)) + if (!val->optimized_out ()) return value_cast (type, val); } =20 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 !=3D NULL && fp_opts.print_entry_values !=3D print_entry_values_no && (fp_opts.print_entry_values !=3D 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, } } =20 - if (entryval !=3D NULL && value_optimized_out (entryval)) + if (entryval !=3D NULL && entryval->optimized_out ()) entryval =3D NULL; =20 if (fp_opts.print_entry_values =3D=3D print_entry_values_compact @@ -672,7 +672,7 @@ read_frame_arg (const frame_print_options &fp_opts, if (fp_opts.print_entry_values =3D=3D print_entry_values_only || fp_opts.print_entry_values =3D=3D print_entry_values_both || (fp_opts.print_entry_values =3D=3D print_entry_values_preferred - && (!val || value_optimized_out (val)))) + && (!val || val->optimized_out ()))) { entryval =3D value::allocate_optimized_out (sym->type ()); entryval_error =3D NULL; @@ -681,7 +681,7 @@ read_frame_arg (const frame_print_options &fp_opts, if ((fp_opts.print_entry_values =3D=3D print_entry_values_compact || fp_opts.print_entry_values =3D=3D print_entry_values_if_needed || fp_opts.print_entry_values =3D=3D print_entry_values_preferred) - && (!val || value_optimized_out (val)) && entryval !=3D NULL) + && (!val || val->optimized_out ()) && entryval !=3D NULL) { val =3D NULL; val_error =3D NULL; @@ -1708,7 +1708,7 @@ info_frame_command_core (frame_info_ptr fi, bool sele= cted_frame_p) struct value *value =3D frame_unwind_register_value (fi, sp_regnum); gdb_assert (value !=3D NULL); =20 - if (!value_optimized_out (value) && value_entirely_available (value)) + if (!value->optimized_out () && value->entirely_available ()) { if (VALUE_LVAL (value) =3D=3D not_lval) { diff --git a/gdb/valarith.c b/gdb/valarith.c index e92b6672229..854d061aecc 100644 --- a/gdb/valarith.c +++ b/gdb/valarith.c @@ -188,10 +188,10 @@ value_subscript (struct value *array, LONGEST index) struct type *elt_type =3D check_typedef (tarray->target_type ()); LONGEST elt_size =3D type_length_units (elt_type); if (!array->lazy () - && !value_bytes_available (array, elt_size * index, elt_size)) + && !array->bytes_available (elt_size * index, elt_size)) { struct value *val =3D value::allocate (elt_type); - mark_value_bytes_unavailable (val, 0, elt_size); + val->mark_bytes_unavailable (0, elt_size); VALUE_LVAL (val) =3D lval_memory; val->set_address (array->address () + elt_size * index); return val; diff --git a/gdb/valops.c b/gdb/valops.c index aac32cc0917..b088a5d99ae 100644 --- a/gdb/valops.c +++ b/gdb/valops.c @@ -1066,9 +1066,9 @@ read_value_memory (struct value *val, LONGEST bit_off= set, if (status =3D=3D TARGET_XFER_OK) /* nothing */; else if (status =3D=3D 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 =3D=3D TARGET_XFER_EOF) memory_error (TARGET_XFER_E_IO, memaddr + xfered_total); else diff --git a/gdb/valprint.c b/gdb/valprint.c index ba62d3af41c..46d0aee1417 100644 --- a/gdb/valprint.c +++ b/gdb/valprint.c @@ -373,9 +373,8 @@ valprint_check_validity (struct ui_file *stream, && type->code () !=3D TYPE_CODE_STRUCT && type->code () !=3D 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; } =20 - 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_f= ile *stream, return 0; } =20 - 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_f= ile *stream, return 0; } =20 - 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, =20 /* 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); @@ -2017,8 +2016,8 @@ value_print_array_elements (struct value *val, struct= ui_file *stream, UINT_MAX (unlimited). */ if (options->repeat_count_threshold < UINT_MAX) { - bool unavailable =3D value_entirely_unavailable (element); - bool available =3D value_entirely_available (element); + bool unavailable =3D element->entirely_unavailable (); + bool available =3D element->entirely_available (); =20 while (rep1 < len) { @@ -2027,10 +2026,10 @@ value_print_array_elements (struct value *val, stru= ct ui_file *stream, rep1 * bit_stride, bit_stride); bool repeated =3D ((available - && value_entirely_available (rep_elt) + && rep_elt->entirely_available () && element->contents_eq (rep_elt)) || (unavailable - && value_entirely_unavailable (rep_elt))); + && rep_elt->entirely_unavailable ())); if (!repeated) break; ++reps; diff --git a/gdb/value.c b/gdb/value.c index b8a032ed30d..beda62d630f 100644 --- a/gdb/value.c +++ b/gdb/value.c @@ -169,23 +169,21 @@ value::arch () const } =20 int -value_bits_available (const struct value *value, - LONGEST offset, ULONGEST length) +value::bits_available (LONGEST offset, ULONGEST length) const { - gdb_assert (!value->m_lazy); + gdb_assert (!m_lazy); =20 /* Don't pretend we have anything available there in the history beyond the boundaries of the value recorded. It's not like inferior memory where there is actual stuff underneath. */ - ULONGEST val_len =3D TARGET_CHAR_BIT * value->enclosing_type ()->length = (); - return !((value->m_in_history + ULONGEST val_len =3D TARGET_CHAR_BIT * enclosing_type ()->length (); + return !((m_in_history && (offset < 0 || offset + length > val_len)) - || ranges_contain (value->m_unavailable, offset, length)); + || ranges_contain (m_unavailable, offset, length)); } =20 int -value_bytes_available (const struct value *value, - LONGEST offset, ULONGEST length) +value::bytes_available (LONGEST offset, ULONGEST length) const { ULONGEST sign =3D (1ULL << (sizeof (ULONGEST) * 8 - 1)) / TARGET_CHAR_BI= T; ULONGEST mask =3D (sign << 1) - 1; @@ -195,70 +193,52 @@ value_bytes_available (const struct value *value, || (length > 0 && (~offset & (offset + length - 1) & sign) !=3D 0)) error (_("Integer overflow in data location calculation")); =20 - return value_bits_available (value, - offset * TARGET_CHAR_BIT, - length * TARGET_CHAR_BIT); + return bits_available (offset * TARGET_CHAR_BIT, length * TARGET_CHAR_BI= T); } =20 int -value_bits_any_optimized_out (const struct value *value, int bit_offset, i= nt bit_length) +value::bits_any_optimized_out (int bit_offset, int bit_length) const { - gdb_assert (!value->m_lazy); + gdb_assert (!m_lazy); =20 - return ranges_contain (value->m_optimized_out, bit_offset, bit_length); + return ranges_contain (m_optimized_out, bit_offset, bit_length); } =20 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 (); =20 - if (value->m_unavailable.empty ()) + if (m_unavailable.empty ()) return 1; return 0; } =20 -/* 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. */ =20 -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 (); =20 if (ranges.size () =3D=3D 1) { const struct range &t =3D ranges[0]; =20 if (t.offset =3D=3D 0 - && t.length =3D=3D (TARGET_CHAR_BIT - * value->enclosing_type ()->length ())) + && t.length =3D=3D TARGET_CHAR_BIT * enclosing_type ()->length ()) return 1; } =20 return 0; } =20 -int -value_entirely_unavailable (struct value *value) -{ - return value_entirely_covered_by_range_vector (value, value->m_unavailab= le); -} - -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. */ =20 @@ -429,19 +409,16 @@ insert_into_bit_range_vector (std::vector *vec= torp, } =20 void -mark_value_bits_unavailable (struct value *value, - LONGEST offset, ULONGEST length) +value::mark_bits_unavailable (LONGEST offset, ULONGEST length) { - insert_into_bit_range_vector (&value->m_unavailable, offset, length); + insert_into_bit_range_vector (&m_unavailable, offset, length); } =20 void -mark_value_bytes_unavailable (struct value *value, - LONGEST offset, ULONGEST length) +value::mark_bytes_unavailable (LONGEST offset, ULONGEST 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); } =20 /* Find the first range in RANGES that overlaps the range defined by @@ -1012,7 +989,7 @@ value::allocate_optimized_out (struct type *type) { struct value *retval =3D value::allocate_lazy (type); =20 - mark_value_bytes_optimized_out (retval, 0, type->length ()); + retval->mark_bytes_optimized_out (0, type->length ()); retval->set_lazy (0); return retval; } @@ -1061,7 +1038,7 @@ value_actual_type (struct value *value, int resolve_s= imple_types, if (result->is_pointer_or_reference () && (check_typedef (result->target_type ())->code () =3D=3D TYPE_CODE_STRUCT) - && !value_optimized_out (value)) + && !value->optimized_out ()) { struct type *real_type; =20 @@ -1204,10 +1181,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)); =20 /* Copy the data. */ gdb::array_view dst_contents @@ -1247,9 +1223,9 @@ value_contents_copy_raw_bitwise (struct value *dst, L= ONGEST dst_bit_offset, turns out actually necessary. */ LONGEST dst_offset =3D dst_bit_offset / TARGET_CHAR_BIT; LONGEST length =3D 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)); =20 /* Copy the data. */ gdb::array_view dst_contents =3D dst->contents_all_raw (); @@ -1303,26 +1279,26 @@ value::contents_writeable () } =20 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) =3D=3D lval_memory) + if (VALUE_LVAL (this) =3D=3D lval_memory) return false; - else if (VALUE_LVAL (value) =3D=3D lval_computed) + else if (VALUE_LVAL (this) =3D=3D lval_computed) { - const struct lval_funcs *funcs =3D value->m_location.computed.funcs; + const struct lval_funcs *funcs =3D m_location.computed.funcs; =20 if (funcs->is_optimized_out !=3D nullptr) - return funcs->is_optimized_out (value); + return funcs->is_optimized_out (this); } =20 /* Fall back to fetching. */ try { - value->fetch_lazy (); + fetch_lazy (); } catch (const gdb_exception_error &ex) { @@ -1341,27 +1317,25 @@ value_optimized_out (struct value *value) } } =20 - return !value->m_optimized_out.empty (); + return !m_optimized_out.empty (); } =20 /* Mark contents of VALUE as optimized out, starting at OFFSET bytes, and the following LENGTH bytes. */ =20 void -mark_value_bytes_optimized_out (struct value *value, int offset, int lengt= h) +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); } =20 /* See value.h. */ =20 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); } =20 int @@ -1546,8 +1520,8 @@ value::copy () const val->m_limited_length =3D m_limited_length; =20 if (!val->lazy () - && !(value_entirely_optimized_out (val) - || value_entirely_unavailable (val))) + && !(val->entirely_optimized_out () + || val->entirely_unavailable ())) { ULONGEST length =3D val->m_limited_length; if (length =3D=3D 0) @@ -1721,8 +1695,8 @@ record_latest_value (struct value *val) =20 ULONGEST limit =3D val->m_limited_length; if (limit !=3D 0) - mark_value_bytes_unavailable (val, limit, - enclosing_type->length () - limit); + val->mark_bytes_unavailable (limit, + enclosing_type->length () - limit); =20 /* Mark the value as recorded in the history for the availability check.= */ val->m_in_history =3D true; @@ -3159,8 +3133,8 @@ unpack_value_field_as_long (struct type *type, const = gdb_byte *valaddr, gdb_assert (val !=3D NULL); =20 bit_offset =3D 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; =20 *result =3D unpack_bits_as_long (field_type, valaddr + embedded_offset, @@ -3905,7 +3879,7 @@ value::fetch_lazy_register () user_reg_map_regnum_to_name (gdbarch, regnum)); =20 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); @@ -4174,8 +4148,8 @@ test_value_copy () value_ref_ptr val =3D release_value (value::allocate_optimized_out (type= )); value_ref_ptr copy =3D release_value (val.get ()->copy ()); =20 - 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 ()); } =20 } /* namespace selftests */ diff --git a/gdb/value.h b/gdb/value.h index 6b0250c0e51..4ecaeb7c607 100644 --- a/gdb/value.h +++ b/gdb/value.h @@ -262,7 +262,6 @@ public: void set_lazy (int val) { m_lazy =3D val; } =20 - /* 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 @@ -479,6 +478,60 @@ public: drops to 0, it will be freed. */ void decref (); =20 + /* 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, ULONGEST 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, ULONGEST 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, ULONGEST length); + + /* Mark this value's content bits starting at OFFSET and extending + for LENGTH bits as unavailable. */ + void mark_bits_unavailable (LONGEST offset, ULONGEST 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); + =20 /* Type of value; either not an lval, or one of the various different possible kinds of lval. */ @@ -697,6 +750,11 @@ private: =20 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); }; =20 inline void @@ -793,34 +851,6 @@ struct lval_funcs =20 extern void error_value_optimized_out (void); =20 -/* 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, @@ -877,42 +907,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 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, ULONGEST 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, ULONGEST 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, ULONGEST 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, ULONGEST 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