From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from gproxy1-pub.mail.unifiedlayer.com (gproxy1-pub.mail.unifiedlayer.com [69.89.25.95]) by sourceware.org (Postfix) with ESMTPS id DAEAA388214C for ; Mon, 13 Feb 2023 03:54:10 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org DAEAA388214C 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 progateway3.mail.pro1.eigbox.com (Postfix) with ESMTP id 5CCF61004C007 for ; Mon, 13 Feb 2023 03:54:10 +0000 (UTC) Received: from box5379.bluehost.com ([162.241.216.53]) by cmsmtp with ESMTP id RPusphKK4Fh3zRPusp7O58; Mon, 13 Feb 2023 03:54:10 +0000 X-Authority-Reason: nr=8 X-Authority-Analysis: v=2.4 cv=QpabYX+d c=1 sm=1 tr=0 ts=63e9b462 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=hru6reSaOufj--x9yhkA: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=jwGNNXLW82qDnJdM6Z2ATwbQIzJzVZV+n6PP4HiDqaI=; b=FD46EcpN35cDQiiJEHeTzT+IjO Vo/oYQodOoxFGJ2NrkchCVeDpoc6rx1bW7W1nIPel9depyeipMt5C97zLek7nw0Ye/W5arGhzJJJi sPMSOJwy7+da0LerBUf9ipHOU; 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 1pRPJV-001AGJ-Bw for gdb-patches@sourceware.org; Sun, 12 Feb 2023 20:15:33 -0700 From: Tom Tromey Date: Sun, 12 Feb 2023 20:16:01 -0700 Subject: [PATCH v3 45/50] Turn record_latest_value into a method MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit Message-Id: <20230209-submit-value-fixups-2023-v3-45-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 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: 1pRPJV-001AGJ-Bw 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: 96 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: record_latest_value now access some internals of struct value, so turn it into a method. --- gdb/arc-tdep.c | 2 +- gdb/guile/scm-value.c | 2 +- gdb/infcmd.c | 2 +- gdb/printcmd.c | 2 +- gdb/python/py-value.c | 2 +- gdb/value.c | 30 +++++++++++++----------------- gdb/value.h | 5 +++-- 7 files changed, 21 insertions(+), 24 deletions(-) diff --git a/gdb/arc-tdep.c b/gdb/arc-tdep.c index bbdcb8d4ce6..bbf4846a8f8 100644 --- a/gdb/arc-tdep.c +++ b/gdb/arc-tdep.c @@ -2437,7 +2437,7 @@ dump_arc_instruction_command (const char *args, int from_tty) val = evaluate_expression (parse_expression (args).get ()); else val = access_value_history (0); - record_latest_value (val); + val->record_latest (); CORE_ADDR address = value_as_address (val); struct arc_instruction insn; diff --git a/gdb/guile/scm-value.c b/gdb/guile/scm-value.c index a0b7e6661b5..ac948dcd1a2 100644 --- a/gdb/guile/scm-value.c +++ b/gdb/guile/scm-value.c @@ -1330,7 +1330,7 @@ gdbscm_history_append_x (SCM value) = vlscm_get_value_smob_arg_unsafe (value, SCM_ARG1, FUNC_NAME); return gdbscm_wrap ([=] { - return scm_from_int (record_latest_value (v_smob->value)); + return scm_from_int (v_smob->value->record_latest ()); }); } diff --git a/gdb/infcmd.c b/gdb/infcmd.c index 3943a562590..a851fe1f8c8 100644 --- a/gdb/infcmd.c +++ b/gdb/infcmd.c @@ -1657,7 +1657,7 @@ finish_command_fsm::should_stop (struct thread_info *tp) rv->value = get_return_value (function, func); if (rv->value != nullptr) - rv->value_history_index = record_latest_value (rv->value); + rv->value_history_index = rv->value->record_latest (); } } else if (tp->control.stop_step) diff --git a/gdb/printcmd.c b/gdb/printcmd.c index 0b3c2e00b4c..58047c7bd02 100644 --- a/gdb/printcmd.c +++ b/gdb/printcmd.c @@ -1247,7 +1247,7 @@ print_value (value *val, const value_print_options &opts) need to load as many array elements as we plan to print. */ scoped_array_length_limiting limit_large_arrays (opts.print_max); - int histindex = record_latest_value (val); + int histindex = val->record_latest (); annotate_value_history_begin (histindex, val->type ()); diff --git a/gdb/python/py-value.c b/gdb/python/py-value.c index 658a9a3f18c..c61de577de1 100644 --- a/gdb/python/py-value.c +++ b/gdb/python/py-value.c @@ -1959,7 +1959,7 @@ gdbpy_add_history (PyObject *self, PyObject *args) try { - int idx = record_latest_value (value); + int idx = value->record_latest (); return gdb_py_object_from_longest (idx).release (); } catch (const gdb_exception &except) diff --git a/gdb/value.c b/gdb/value.c index 640053ddce5..a1ab853bcd1 100644 --- a/gdb/value.c +++ b/gdb/value.c @@ -1643,46 +1643,42 @@ value::set_component_location (const struct value *whole) Returns the absolute history index of the entry. */ int -record_latest_value (struct value *val) +value::record_latest () { - struct type *enclosing_type = val->enclosing_type (); - struct type *type = val->type (); - /* We don't want this value to have anything to do with the inferior anymore. 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 (val->lazy ()) + if (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 the array to still be displayed we fetch its contents up to `max_value_size' and mark anything beyond "unavailable" in the history. */ - if (type->code () == TYPE_CODE_ARRAY - && type->length () > max_value_size + if (m_type->code () == TYPE_CODE_ARRAY + && m_type->length () > max_value_size && array_length_limiting_element_count.has_value () - && enclosing_type == type - && calculate_limited_array_length (type) <= max_value_size) - val->m_limited_length = max_value_size; + && m_enclosing_type == m_type + && calculate_limited_array_length (m_type) <= max_value_size) + m_limited_length = max_value_size; - val->fetch_lazy (); + fetch_lazy (); } - ULONGEST limit = val->m_limited_length; + ULONGEST limit = m_limited_length; if (limit != 0) - val->mark_bytes_unavailable (limit, - enclosing_type->length () - limit); + mark_bytes_unavailable (limit, m_enclosing_type->length () - limit); /* Mark the value as recorded in the history for the availability check. */ - val->m_in_history = true; + m_in_history = true; /* We preserve VALUE_LVAL so that the user can find out where it was fetched from. This is a bit dubious, because then *&$1 does not just return $1 but the current contents of that location. c'est la vie... */ - val->set_modifiable (0); + set_modifiable (0); - value_history.push_back (release_value (val)); + value_history.push_back (release_value (this)); return value_history.size (); } diff --git a/gdb/value.h b/gdb/value.h index f35bfc7206c..225a3c851c4 100644 --- a/gdb/value.h +++ b/gdb/value.h @@ -605,6 +605,9 @@ struct value LONGEST bit_offset, LONGEST bit_length); + /* Record this value on the value history, and return its location + in the history. The value is removed from the value chain. */ + int record_latest (); /* Type of value; either not an lval, or one of the various different possible kinds of lval. */ @@ -1451,8 +1454,6 @@ extern int destructor_name_p (const char *name, struct type *type); extern value_ref_ptr release_value (struct value *val); -extern int record_latest_value (struct value *val); - extern void modify_field (struct type *type, gdb_byte *addr, LONGEST fieldval, LONGEST bitpos, LONGEST bitsize); -- 2.39.1