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