From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from gproxy2-pub.mail.unifiedlayer.com (gproxy2-pub.mail.unifiedlayer.com [69.89.18.3]) by sourceware.org (Postfix) with ESMTPS id 417573858020 for ; Mon, 13 Feb 2023 03:15:28 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 417573858020 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=tromey.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=tromey.com Received: from cmgw11.mail.unifiedlayer.com (unknown [10.0.90.126]) by progateway4.mail.pro1.eigbox.com (Postfix) with ESMTP id AF5DF10047A4B for ; Mon, 13 Feb 2023 03:15:27 +0000 (UTC) Received: from box5379.bluehost.com ([162.241.216.53]) by cmsmtp with ESMTP id RPJPpJ4wVjkdRRPJPpCxhA; Mon, 13 Feb 2023 03:15:27 +0000 X-Authority-Reason: nr=8 X-Authority-Analysis: v=2.4 cv=LPqj/La9 c=1 sm=1 tr=0 ts=63e9ab4f a=ApxJNpeYhEAb1aAlGBBbmA==:117 a=ApxJNpeYhEAb1aAlGBBbmA==:17 a=dLZJa+xiwSxG16/P+YVxDGlgEgI=:19 a=IkcTkHD0fZMA:10:nop_charset_1 a=m04uMKEZRckA:10:nop_rcvd_month_year a=Qbun_eYptAEA:10:endurance_base64_authed_username_1 a=7d_E57ReAAAA:8 a=XqSF2npsncGvgfwPtBEA:9 a=QEXdDO2ut3YA:10:nop_charset_2 a=jhqOcbufqs7Y1TYCrUUU:22 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=tromey.com; s=default; h=Cc:To:In-Reply-To:References:Message-Id: Content-Transfer-Encoding:Content-Type:MIME-Version:Subject:Date:From:Sender: Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From:Resent-Sender :Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help:List-Unsubscribe: List-Subscribe:List-Post:List-Owner:List-Archive; bh=xE05SfEf+/aFAb5ATpkniXTo7v9PKd8V3ixQm+1wWHw=; b=nYViT7C6mJ3B8QZZqUBxx6cpz5 QFiOXugidSEIiWO/xLjJ00mM03qGJ69dqDqjV0SQXwViMlWsA7t7Ps1ABcxBiamE9IsZAAh3dNzw6 tua8Z4gwzsC9v/LtKhU5nfes6; Received: from 75-166-130-93.hlrn.qwest.net ([75.166.130.93]:37668 helo=[192.168.0.21]) by box5379.bluehost.com with esmtpsa (TLS1.2) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.95) (envelope-from ) id 1pRPJP-001AGJ-Dm; Sun, 12 Feb 2023 20:15:27 -0700 From: Tom Tromey Date: Sun, 12 Feb 2023 20:15:31 -0700 Subject: [PATCH v3 15/50] Turn value_lazy and set_value_lazy functions into methods MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit Message-Id: <20230209-submit-value-fixups-2023-v3-15-45e91a20c742@tromey.com> References: <20230209-submit-value-fixups-2023-v3-0-45e91a20c742@tromey.com> In-Reply-To: <20230209-submit-value-fixups-2023-v3-0-45e91a20c742@tromey.com> To: gdb-patches@sourceware.org Cc: Simon Marchi X-Mailer: b4 0.12.0 X-AntiAbuse: This header was added to track abuse, please include it with any abuse report X-AntiAbuse: Primary Hostname - box5379.bluehost.com X-AntiAbuse: Original Domain - sourceware.org X-AntiAbuse: Originator/Caller UID/GID - [47 12] / [47 12] X-AntiAbuse: Sender Address Domain - tromey.com X-BWhitelist: no X-Source-IP: 75.166.130.93 X-Source-L: No X-Exim-ID: 1pRPJP-001AGJ-Dm X-Source: X-Source-Args: X-Source-Dir: X-Source-Sender: 75-166-130-93.hlrn.qwest.net ([192.168.0.21]) [75.166.130.93]:37668 X-Source-Auth: tom+tromey.com X-Email-Count: 33 X-Source-Cap: ZWx5bnJvYmk7ZWx5bnJvYmk7Ym94NTM3OS5ibHVlaG9zdC5jb20= X-Local-Domain: yes X-Spam-Status: No, score=-3027.4 required=5.0 tests=BAYES_00,DKIM_SIGNED,DKIM_VALID,GIT_PATCH_0,JMQ_SPF_NEUTRAL,RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_PASS,TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org List-Id: This changes the value_lazy and set_value_lazy functions to be methods of value. Much of this patch was written by script. Approved-By: Simon Marchi --- gdb/ada-lang.c | 8 +++---- gdb/ada-valprint.c | 2 +- gdb/breakpoint.c | 4 ++-- gdb/c-varobj.c | 4 ++-- gdb/dwarf2/loc.c | 2 +- gdb/eval.c | 6 ++--- gdb/f-lang.c | 8 +++---- gdb/frame.c | 2 +- gdb/gnu-v2-abi.c | 4 ++-- gdb/guile/scm-pretty-print.c | 2 +- gdb/guile/scm-value.c | 4 ++-- gdb/ppc-linux-nat.c | 2 +- gdb/printcmd.c | 2 +- gdb/python/py-prettyprint.c | 2 +- gdb/python/py-value.c | 4 ++-- gdb/stack.c | 10 ++++----- gdb/valarith.c | 2 +- gdb/valops.c | 6 ++--- gdb/valprint.c | 2 +- gdb/value.c | 52 +++++++++++++++++--------------------------- gdb/value.h | 39 ++++++++++++++++++--------------- gdb/varobj.c | 16 +++++++------- 22 files changed, 87 insertions(+), 96 deletions(-) diff --git a/gdb/ada-lang.c b/gdb/ada-lang.c index baffea75657..05f8c3fd0da 100644 --- a/gdb/ada-lang.c +++ b/gdb/ada-lang.c @@ -557,7 +557,7 @@ coerce_unspec_val_to_type (struct value *val, struct type *type) if (value_optimized_out (val)) result = allocate_optimized_out_value (type); - else if (value_lazy (val) + else if (val->lazy () /* Be careful not to make a lazy not_lval value. */ || (VALUE_LVAL (val) != not_lval && type->length () > val->type ()->length ())) @@ -2810,7 +2810,7 @@ ada_value_primitive_packed_val (struct value *obj, const gdb_byte *valaddr, v = allocate_value (type); src = valaddr + offset; } - else if (VALUE_LVAL (obj) == lval_memory && value_lazy (obj)) + else if (VALUE_LVAL (obj) == lval_memory && obj->lazy ()) { int src_len = (bit_size + bit_offset + HOST_CHAR_BIT - 1) / 8; gdb_byte *buf; @@ -10852,7 +10852,7 @@ ada_var_msym_value_operation::evaluate_for_cast (struct type *expect_type, an address of the result of a cast (view conversion in Ada). */ if (VALUE_LVAL (val) == lval_memory) { - if (value_lazy (val)) + if (val->lazy ()) value_fetch_lazy (val); VALUE_LVAL (val) = not_lval; } @@ -10874,7 +10874,7 @@ ada_var_value_operation::evaluate_for_cast (struct type *expect_type, an address of the result of a cast (view conversion in Ada). */ if (VALUE_LVAL (val) == lval_memory) { - if (value_lazy (val)) + if (val->lazy ()) value_fetch_lazy (val); VALUE_LVAL (val) = not_lval; } diff --git a/gdb/ada-valprint.c b/gdb/ada-valprint.c index c1004b5f33c..64d7ac18b8c 100644 --- a/gdb/ada-valprint.c +++ b/gdb/ada-valprint.c @@ -982,7 +982,7 @@ ada_val_print_ref (struct type *type, const gdb_byte *valaddr, if (ada_is_tagged_type (deref_val->type (), 1)) deref_val = ada_tag_value_at_base_address (deref_val); - if (value_lazy (deref_val)) + if (deref_val->lazy ()) value_fetch_lazy (deref_val); common_val_print (deref_val, stream, recurse + 1, diff --git a/gdb/breakpoint.c b/gdb/breakpoint.c index b8490b053d7..0c36ec01d00 100644 --- a/gdb/breakpoint.c +++ b/gdb/breakpoint.c @@ -2076,7 +2076,7 @@ update_watchpoint (struct watchpoint *b, bool reparse) still lazy, that means an error occurred reading it; watch it anyway in case it becomes readable. */ if (VALUE_LVAL (v) == lval_memory - && (v == val_chain[0] || ! value_lazy (v))) + && (v == val_chain[0] || ! v->lazy ())) { struct type *vtype = check_typedef (v->type ()); @@ -10415,7 +10415,7 @@ can_use_hardware_watchpoint (const std::vector &vals) if (VALUE_LVAL (v) == lval_memory) { - if (v != head && value_lazy (v)) + if (v != head && v->lazy ()) /* A lazy memory lvalue in the chain is one that GDB never needed to fetch; we either just used its address (e.g., `a' in `a.b') or we never needed it at all (e.g., `a' diff --git a/gdb/c-varobj.c b/gdb/c-varobj.c index d517c798a6a..00094244ff1 100644 --- a/gdb/c-varobj.c +++ b/gdb/c-varobj.c @@ -506,14 +506,14 @@ c_value_of_variable (const struct varobj *var, } else { - if (var->not_fetched && value_lazy (var->value.get ())) + if (var->not_fetched && var->value.get ()->lazy ()) /* Frozen variable and no value yet. We don't implicitly fetch the value. MI response will use empty string for the value, which is OK. */ return std::string (); gdb_assert (varobj_value_is_changeable_p (var)); - gdb_assert (!value_lazy (var->value.get ())); + gdb_assert (!var->value.get ()->lazy ()); /* If the specified format is the current one, we can reuse print_value. */ diff --git a/gdb/dwarf2/loc.c b/gdb/dwarf2/loc.c index 4af4dfde090..e5b35b8aadb 100644 --- a/gdb/dwarf2/loc.c +++ b/gdb/dwarf2/loc.c @@ -1366,7 +1366,7 @@ value_of_dwarf_reg_entry (struct type *type, frame_info_ptr frame, memcpy (value_contents_raw (val).data (), value_contents_raw (outer_val).data (), checked_type->length ()); - set_value_lazy (val, 0); + val->set_lazy (0); return val; } diff --git a/gdb/eval.c b/gdb/eval.c index 87147593ed9..934ca4c7ea2 100644 --- a/gdb/eval.c +++ b/gdb/eval.c @@ -205,7 +205,7 @@ fetch_subexp_value (struct expression *exp, have a non-lazy previous value to compare with. */ if (result != NULL) { - if (!value_lazy (result)) + if (!result->lazy ()) *valp = result; else { @@ -2877,7 +2877,7 @@ var_msym_value_operation::evaluate_for_cast (struct type *to_type, /* Don't allow e.g. '&(int)var_with_no_debug_info'. */ if (VALUE_LVAL (val) == lval_memory) { - if (value_lazy (val)) + if (val->lazy ()) value_fetch_lazy (val); VALUE_LVAL (val) = not_lval; } @@ -2898,7 +2898,7 @@ var_value_operation::evaluate_for_cast (struct type *to_type, /* Don't allow e.g. '&(int)var_with_no_debug_info'. */ if (VALUE_LVAL (val) == lval_memory) { - if (value_lazy (val)) + if (val->lazy ()) value_fetch_lazy (val); VALUE_LVAL (val) = not_lval; } diff --git a/gdb/f-lang.c b/gdb/f-lang.c index bf2471a1e2c..d88e81c4a11 100644 --- a/gdb/f-lang.c +++ b/gdb/f-lang.c @@ -356,7 +356,7 @@ class fortran_array_repacker_impl m_base_offset (base_offset), m_val (val) { - gdb_assert (!value_lazy (val)); + gdb_assert (!val->lazy ()); } /* Extract an element of ELT_TYPE at offset (M_BASE_OFFSET + ELT_OFF) @@ -1441,7 +1441,7 @@ fortran_undetermined::value_subarray (value *array, /* Now copy the elements from the original ARRAY into the packed array value DEST. */ struct value *dest = allocate_value (repacked_array_type); - if (value_lazy (array) + if (array->lazy () || (total_offset + array_slice_type->length () > check_typedef (array->type ())->length ())) { @@ -1466,7 +1466,7 @@ fortran_undetermined::value_subarray (value *array, the requested slice is outside the values content range then just create a new lazy value pointing at the memory where the contents we're looking for exist. */ - if (value_lazy (array) + if (array->lazy () || (total_offset + array_slice_type->length () > check_typedef (array->type ())->length ())) array = value_at_lazy (array_slice_type, @@ -1476,7 +1476,7 @@ fortran_undetermined::value_subarray (value *array, (array_slice_type, value_contents (array).data () + total_offset, value_address (array) + total_offset); } - else if (!value_lazy (array)) + else if (!array->lazy ()) array = value_from_component (array, array_slice_type, total_offset); else error (_("cannot subscript arrays that are not in memory")); diff --git a/gdb/frame.c b/gdb/frame.c index 61a79231d7a..dd9d6bfd519 100644 --- a/gdb/frame.c +++ b/gdb/frame.c @@ -1306,7 +1306,7 @@ frame_unwind_register_value (frame_info_ptr next_frame, int regnum) else gdb_printf (&debug_file, " computed"); - if (value_lazy (value)) + if (value->lazy ()) gdb_printf (&debug_file, " lazy"); else { diff --git a/gdb/gnu-v2-abi.c b/gdb/gnu-v2-abi.c index 632b46f92de..76dc719719f 100644 --- a/gdb/gnu-v2-abi.c +++ b/gdb/gnu-v2-abi.c @@ -161,9 +161,9 @@ gnuv2_virtual_fn_field (struct value **arg1p, struct fn_field * f, int j, arg1->set_offset (arg1->offset () + value_as_long (value_field (entry, 0))); - if (!value_lazy (arg1)) + if (!arg1->lazy ()) { - set_value_lazy (arg1, 1); + arg1->set_lazy (1); value_fetch_lazy (arg1); } diff --git a/gdb/guile/scm-pretty-print.c b/gdb/guile/scm-pretty-print.c index 3e93f3523be..7a680c052d3 100644 --- a/gdb/guile/scm-pretty-print.c +++ b/gdb/guile/scm-pretty-print.c @@ -965,7 +965,7 @@ gdbscm_apply_val_pretty_printer (const struct extension_language_defn *extlang, enum ext_lang_rc result = EXT_LANG_RC_NOP; enum guile_string_repr_result print_result; - if (value_lazy (value)) + if (value->lazy ()) value_fetch_lazy (value); /* No pretty-printer support for unavailable values. */ diff --git a/gdb/guile/scm-value.c b/gdb/guile/scm-value.c index 0d9e15a7404..5b9a4cfb181 100644 --- a/gdb/guile/scm-value.c +++ b/gdb/guile/scm-value.c @@ -1233,7 +1233,7 @@ gdbscm_value_lazy_p (SCM self) = vlscm_get_value_smob_arg_unsafe (self, SCM_ARG1, FUNC_NAME); struct value *value = v_smob->value; - return scm_from_bool (value_lazy (value)); + return scm_from_bool (value->lazy ()); } /* (value-fetch-lazy! ) -> unspecified */ @@ -1247,7 +1247,7 @@ gdbscm_value_fetch_lazy_x (SCM self) return gdbscm_wrap ([=] { - if (value_lazy (value)) + if (value->lazy ()) value_fetch_lazy (value); return SCM_UNSPECIFIED; }); diff --git a/gdb/ppc-linux-nat.c b/gdb/ppc-linux-nat.c index a796364b413..d6d1d0fe1a2 100644 --- a/gdb/ppc-linux-nat.c +++ b/gdb/ppc-linux-nat.c @@ -2462,7 +2462,7 @@ ppc_linux_nat_target::num_memory_accesses (const std::vector /* A lazy memory lvalue is one that GDB never needed to fetch; we either just used its address (e.g., `a' in `a.b') or we never needed it at all (e.g., `a' in `a,b'). */ - if (!value_lazy (v)) + if (!v->lazy ()) found_memory_cnt++; } /* Other kinds of values are not fine. */ diff --git a/gdb/printcmd.c b/gdb/printcmd.c index a1ad281c957..9e77bf19211 100644 --- a/gdb/printcmd.c +++ b/gdb/printcmd.c @@ -1943,7 +1943,7 @@ x_command (const char *exp, int from_tty) as $__. If the last value has not been fetched from memory then don't fetch it now; instead mark it by voiding the $__ variable. */ - if (value_lazy (last_examine_value.get ())) + if (last_examine_value.get ()->lazy ()) clear_internalvar (lookup_internalvar ("__")); else set_internalvar (lookup_internalvar ("__"), last_examine_value.get ()); diff --git a/gdb/python/py-prettyprint.c b/gdb/python/py-prettyprint.c index 346395e564e..0bd54dab5c6 100644 --- a/gdb/python/py-prettyprint.c +++ b/gdb/python/py-prettyprint.c @@ -578,7 +578,7 @@ gdbpy_apply_val_pretty_printer (const struct extension_language_defn *extlang, struct gdbarch *gdbarch = type->arch (); enum gdbpy_string_repr_result print_result; - if (value_lazy (value)) + if (value->lazy ()) value_fetch_lazy (value); /* No pretty-printer support for unavailable values. */ diff --git a/gdb/python/py-value.c b/gdb/python/py-value.c index c748a87cfc9..0e3bc699819 100644 --- a/gdb/python/py-value.c +++ b/gdb/python/py-value.c @@ -1219,7 +1219,7 @@ valpy_get_is_lazy (PyObject *self, void *closure) try { - opt = value_lazy (value); + opt = value->lazy (); } catch (const gdb_exception &except) { @@ -1240,7 +1240,7 @@ valpy_fetch_lazy (PyObject *self, PyObject *args) try { - if (value_lazy (value)) + if (value->lazy ()) value_fetch_lazy (value); } catch (const gdb_exception &except) diff --git a/gdb/stack.c b/gdb/stack.c index 9e239ed4f67..5efe024c88e 100644 --- a/gdb/stack.c +++ b/gdb/stack.c @@ -580,9 +580,9 @@ read_frame_arg (const frame_print_options &fp_opts, { struct type *type = val->type (); - if (value_lazy (val)) + if (val->lazy ()) value_fetch_lazy (val); - if (value_lazy (entryval)) + if (entryval->lazy ()) value_fetch_lazy (entryval); if (value_contents_eq (val, 0, entryval, 0, type->length ())) @@ -599,12 +599,12 @@ read_frame_arg (const frame_print_options &fp_opts, struct type *type_deref; val_deref = coerce_ref (val); - if (value_lazy (val_deref)) + if (val_deref->lazy ()) value_fetch_lazy (val_deref); type_deref = val_deref->type (); entryval_deref = coerce_ref (entryval); - if (value_lazy (entryval_deref)) + if (entryval_deref->lazy ()) value_fetch_lazy (entryval_deref); /* If the reference addresses match but dereferenced @@ -2749,7 +2749,7 @@ return_command (const char *retval_exp, int from_tty) /* Make sure the value is fully evaluated. It may live in the stack frame we're about to pop. */ - if (value_lazy (return_value)) + if (return_value->lazy ()) value_fetch_lazy (return_value); if (thisfun != NULL) diff --git a/gdb/valarith.c b/gdb/valarith.c index ae81ea578fe..98ccbc76271 100644 --- a/gdb/valarith.c +++ b/gdb/valarith.c @@ -187,7 +187,7 @@ value_subscript (struct value *array, LONGEST index) Instead mock up a new one and give it the original address. */ struct type *elt_type = check_typedef (tarray->target_type ()); LONGEST elt_size = type_length_units (elt_type); - if (!value_lazy (array) + if (!array->lazy () && !value_bytes_available (array, elt_size * index, elt_size)) { struct value *val = allocate_value (elt_type); diff --git a/gdb/valops.c b/gdb/valops.c index 079b64dbbe6..1823b0bc1d6 100644 --- a/gdb/valops.c +++ b/gdb/valops.c @@ -1343,7 +1343,7 @@ value_assign (struct value *toval, struct value *fromval) information, but its contents are updated from FROMVAL. This implies the returned value is not lazy, even if TOVAL was. */ val = value_copy (toval); - set_value_lazy (val, 0); + val->set_lazy (0); copy (value_contents (fromval), value_contents_raw (val)); /* We copy over the enclosing type and pointed-to offset from FROMVAL @@ -1406,7 +1406,7 @@ address_of_variable (struct symbol *var, const struct block *b) val = value_of_variable (var, b); type = val->type (); - if ((VALUE_LVAL (val) == lval_memory && value_lazy (val)) + if ((VALUE_LVAL (val) == lval_memory && val->lazy ()) || type->code () == TYPE_CODE_FUNC) { CORE_ADDR addr = value_address (val); @@ -4078,7 +4078,7 @@ value_slice (struct value *array, int lowbound, int length) slice_range_type); slice_type->set_code (array_type->code ()); - if (VALUE_LVAL (array) == lval_memory && value_lazy (array)) + if (VALUE_LVAL (array) == lval_memory && array->lazy ()) slice = allocate_value_lazy (slice_type); else { diff --git a/gdb/valprint.c b/gdb/valprint.c index db718f3ff98..8a4147944fa 100644 --- a/gdb/valprint.c +++ b/gdb/valprint.c @@ -1043,7 +1043,7 @@ common_val_print (struct value *value, struct ui_file *stream, int recurse, get a fixed representation of our value. */ value = ada_to_fixed_value (value); - if (value_lazy (value)) + if (value->lazy ()) value_fetch_lazy (value); struct value_print_options local_opts = *options; diff --git a/gdb/value.c b/gdb/value.c index c56e0404471..cb169019028 100644 --- a/gdb/value.c +++ b/gdb/value.c @@ -1018,7 +1018,7 @@ allocate_optimized_out_value (struct type *type) struct value *retval = allocate_value_lazy (type); mark_value_bytes_optimized_out (retval, 0, type->length ()); - set_value_lazy (retval, 0); + retval->set_lazy (0); return retval; } @@ -1291,18 +1291,6 @@ value_contents_copy (struct value *dst, LONGEST dst_offset, value_contents_copy_raw (dst, dst_offset, src, src_offset, length); } -int -value_lazy (const struct value *value) -{ - return value->m_lazy; -} - -void -set_value_lazy (struct value *value, int val) -{ - value->m_lazy = val; -} - int value_stack (const struct value *value) { @@ -1607,7 +1595,7 @@ value_copy (const value *arg) val->m_parent = arg->m_parent; val->m_limited_length = arg->m_limited_length; - if (!value_lazy (val) + if (!val->lazy () && !(value_entirely_optimized_out (val) || value_entirely_unavailable (val))) { @@ -1740,7 +1728,7 @@ set_value_component_location (struct value *component, change to how values work in GDB. */ if (VALUE_LVAL (component) == lval_internalvar_component) { - gdb_assert (value_lazy (component)); + gdb_assert (component->lazy ()); VALUE_LVAL (component) = lval_memory; } else @@ -1764,7 +1752,7 @@ record_latest_value (struct value *val) In particular, "set $1 = 50" should not affect the variable from which the value was taken, and fast watchpoints should be able to assume that a value on the value history never changes. */ - if (value_lazy (val)) + if (val->lazy ()) { /* We know that this is a _huge_ array, any attempt to fetch this is going to cause GDB to throw an error. However, to allow @@ -2150,7 +2138,7 @@ value_of_internalvar (struct gdbarch *gdbarch, struct internalvar *var) case INTERNALVAR_VALUE: val = value_copy (var->u.value); - if (value_lazy (val)) + if (val->lazy ()) value_fetch_lazy (val); break; @@ -2290,7 +2278,7 @@ set_internalvar (struct internalvar *var, struct value *val) /* Force the value to be fetched from the target now, to avoid problems later when this internalvar is referenced and the target is gone or has changed. */ - if (value_lazy (copy)) + if (copy->lazy ()) value_fetch_lazy (copy); /* Release the value from the value chain to prevent it from being @@ -3003,7 +2991,7 @@ value_primitive_field (struct value *arg1, LONGEST offset, + offset + (bitpos - v->m_bitpos) / 8); v->set_parent (arg1); - if (!value_lazy (arg1)) + if (!arg1->lazy ()) value_fetch_lazy (v); } else if (fieldno < TYPE_N_BASECLASSES (arg_type)) @@ -3014,7 +3002,7 @@ value_primitive_field (struct value *arg1, LONGEST offset, LONGEST boffset; /* Lazy register values with offsets are not supported. */ - if (VALUE_LVAL (arg1) == lval_register && value_lazy (arg1)) + if (VALUE_LVAL (arg1) == lval_register && arg1->lazy ()) value_fetch_lazy (arg1); /* We special case virtual inheritance here because this @@ -3029,7 +3017,7 @@ value_primitive_field (struct value *arg1, LONGEST offset, else boffset = arg_type->field (fieldno).loc_bitpos () / 8; - if (value_lazy (arg1)) + if (arg1->lazy ()) v = allocate_value_lazy (arg1->enclosing_type ()); else { @@ -3059,10 +3047,10 @@ value_primitive_field (struct value *arg1, LONGEST offset, / (HOST_CHAR_BIT * unit_size)); /* Lazy register values with offsets are not supported. */ - if (VALUE_LVAL (arg1) == lval_register && value_lazy (arg1)) + if (VALUE_LVAL (arg1) == lval_register && arg1->lazy ()) value_fetch_lazy (arg1); - if (value_lazy (arg1)) + if (arg1->lazy ()) v = allocate_value_lazy (type); else { @@ -3664,7 +3652,7 @@ value_from_component (struct value *whole, struct type *type, LONGEST offset) { struct value *v; - if (VALUE_LVAL (whole) == lval_memory && value_lazy (whole)) + if (VALUE_LVAL (whole) == lval_memory && whole->lazy ()) v = allocate_value_lazy (type); else { @@ -3685,7 +3673,7 @@ struct value * value_from_component_bitsize (struct value *whole, struct type *type, LONGEST bit_offset, LONGEST bit_length) { - gdb_assert (!value_lazy (whole)); + gdb_assert (!whole->lazy ()); /* Preserve lvalue-ness if possible. This is needed to avoid array-printing failures (including crashes) when printing Ada @@ -3865,7 +3853,7 @@ value_fetch_lazy_bitfield (struct value *val) value have been fetched. */ struct value *parent = val->parent (); - if (value_lazy (parent)) + if (parent->lazy ()) value_fetch_lazy (parent); unpack_value_bitfield (val, val->bitpos (), val->bitsize (), @@ -3916,7 +3904,7 @@ value_fetch_lazy_register (struct value *val) refer to the entire register. */ gdb_assert (val->offset () == 0); - while (VALUE_LVAL (new_val) == lval_register && value_lazy (new_val)) + while (VALUE_LVAL (new_val) == lval_register && new_val->lazy ()) { struct frame_id next_frame_id = VALUE_NEXT_FRAME_ID (new_val); @@ -3952,19 +3940,19 @@ value_fetch_lazy_register (struct value *val) any case, it should always be an internal error to end up in this situation. */ if (VALUE_LVAL (new_val) == lval_register - && value_lazy (new_val) + && new_val->lazy () && VALUE_NEXT_FRAME_ID (new_val) == next_frame_id) internal_error (_("infinite loop while fetching a register")); } /* If it's still lazy (for instance, a saved register on the stack), fetch it. */ - if (value_lazy (new_val)) + if (new_val->lazy ()) value_fetch_lazy (new_val); /* Copy the contents and the unavailability/optimized-out meta-data from NEW_VAL to VAL. */ - set_value_lazy (val, 0); + val->set_lazy (0); value_contents_copy (val, val->embedded_offset (), new_val, new_val->embedded_offset (), type_length_units (type)); @@ -4031,7 +4019,7 @@ value_fetch_lazy_register (struct value *val) void value_fetch_lazy (struct value *val) { - gdb_assert (value_lazy (val)); + gdb_assert (val->lazy ()); allocate_value_contents (val, true); /* A value is either lazy, or fully fetched. The availability/validity is only established as we try to fetch a @@ -4054,7 +4042,7 @@ value_fetch_lazy (struct value *val) else internal_error (_("Unexpected lazy value type.")); - set_value_lazy (val, 0); + val->set_lazy (0); } /* Implementation of the convenience function $_isvoid. */ diff --git a/gdb/value.h b/gdb/value.h index d27ac7c5cf8..80946c0a0c9 100644 --- a/gdb/value.h +++ b/gdb/value.h @@ -227,6 +227,27 @@ struct value void set_embedded_offset (LONGEST val) { m_embedded_offset = val; } + /* If zero, contents of this value are in the contents field. If + nonzero, contents are in inferior. If the lval field is lval_memory, + the contents are in inferior memory at location.address plus offset. + The lval field may also be lval_register. + + WARNING: This field is used by the code which handles watchpoints + (see breakpoint.c) to decide whether a particular value can be + watched by hardware watchpoints. If the lazy flag is set for some + member of a value chain, it is assumed that this member of the + chain doesn't need to be watched as part of watching the value + itself. This is how GDB avoids watching the entire struct or array + when the user wants to watch a single struct member or array + element. If you ever change the way lazy flag is set and reset, be + sure to consider this use as well! */ + + int lazy () const + { return m_lazy; } + + void set_lazy (int val) + { m_lazy = val; } + /* If a value represents a C++ object, then the `type' field gives the object's compile-time type. If the object actually belongs to some @@ -547,24 +568,6 @@ extern const struct lval_funcs *value_computed_funcs (const struct value *); extern void *value_computed_closure (const struct value *value); -/* If zero, contents of this value are in the contents field. If - nonzero, contents are in inferior. If the lval field is lval_memory, - the contents are in inferior memory at location.address plus offset. - The lval field may also be lval_register. - - WARNING: This field is used by the code which handles watchpoints - (see breakpoint.c) to decide whether a particular value can be - watched by hardware watchpoints. If the lazy flag is set for some - member of a value chain, it is assumed that this member of the - chain doesn't need to be watched as part of watching the value - itself. This is how GDB avoids watching the entire struct or array - when the user wants to watch a single struct member or array - element. If you ever change the way lazy flag is set and reset, be - sure to consider this use as well! */ - -extern int value_lazy (const struct value *); -extern void set_value_lazy (struct value *value, int val); - extern int value_stack (const struct value *); extern void set_value_stack (struct value *value, int val); diff --git a/gdb/varobj.c b/gdb/varobj.c index fb846fd65c7..0e023c09cf8 100644 --- a/gdb/varobj.c +++ b/gdb/varobj.c @@ -504,7 +504,7 @@ varobj_set_display_format (struct varobj *var, } if (varobj_value_is_changeable_p (var) - && var->value != nullptr && !value_lazy (var->value.get ())) + && var->value != nullptr && !var->value.get ()->lazy ()) { var->print_value = varobj_value_get_print_value (var->value.get (), var->format, var); @@ -1007,7 +1007,7 @@ varobj_set_value (struct varobj *var, const char *expression) gdb_assert (varobj_value_is_changeable_p (var)); /* The value of a changeable variable object must not be lazy. */ - gdb_assert (!value_lazy (var->value.get ())); + gdb_assert (!var->value.get ()->lazy ()); /* Need to coerce the input. We want to check if the value of the variable object will be different @@ -1247,7 +1247,7 @@ install_new_value (struct varobj *var, struct value *value, bool initial) that is we'll be comparing values of this type, fetch the value now. Otherwise, on the next update the old value will be lazy, which means we've lost that old value. */ - if (need_to_fetch && value && value_lazy (value)) + if (need_to_fetch && value && value->lazy ()) { const struct varobj *parent = var->parent; bool frozen = var->frozen; @@ -1292,7 +1292,7 @@ install_new_value (struct varobj *var, struct value *value, bool initial) lazy -- if it is, the code above has decided that the value should not be fetched. */ std::string print_value; - if (value != NULL && !value_lazy (value) + if (value != NULL && !value->lazy () && var->dynamic->pretty_printer == NULL) print_value = varobj_value_get_print_value (value, var->format, var); @@ -1312,7 +1312,7 @@ install_new_value (struct varobj *var, struct value *value, bool initial) { /* Try to compare the values. That requires that both values are non-lazy. */ - if (var->not_fetched && value_lazy (var->value.get ())) + if (var->not_fetched && var->value.get ()->lazy ()) { /* This is a frozen varobj and the value was never read. Presumably, UI shows some "never read" indicator. @@ -1330,8 +1330,8 @@ install_new_value (struct varobj *var, struct value *value, bool initial) } else { - gdb_assert (!value_lazy (var->value.get ())); - gdb_assert (!value_lazy (value)); + gdb_assert (!var->value.get ()->lazy ()); + gdb_assert (!value->lazy ()); gdb_assert (!var->print_value.empty () && !print_value.empty ()); if (var->print_value != print_value) @@ -1351,7 +1351,7 @@ install_new_value (struct varobj *var, struct value *value, bool initial) /* We must always keep the new value, since children depend on it. */ var->value = value_holder; - if (value && value_lazy (value) && intentionally_not_fetched) + if (value && value->lazy () && intentionally_not_fetched) var->not_fetched = true; else var->not_fetched = false; -- 2.39.1