From patchwork Sun Oct 29 23:23:33 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tom Tromey X-Patchwork-Id: 78707 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 D902838319EE for ; Sun, 29 Oct 2023 23:24:07 +0000 (GMT) X-Original-To: gdb-patches@sourceware.org Delivered-To: gdb-patches@sourceware.org Received: from omta034.useast.a.cloudfilter.net (omta034.useast.a.cloudfilter.net [44.202.169.33]) by sourceware.org (Postfix) with ESMTPS id 1495838618FA for ; Sun, 29 Oct 2023 23:23:09 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 1495838618FA Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=tromey.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=tromey.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 1495838618FA Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=44.202.169.33 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1698621792; cv=none; b=q83Xzy/xKeeKZXV0cSNArwz+5QQrQEtF3+dVJgR6vkkSn1F6KeAAdIh+DdPpdPrbNuCOuNCTA3Czi+T2YG5+B992UiRd16FjO7KTZcjB8OUsThK06PSpLH1pe9Dfmc4YBMeNKb5V2dWaa2Z+EyFa0X1HLYMCh44d6nfrpC0aCfY= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1698621792; c=relaxed/simple; bh=g9JbqdJ/76LdF+mVHrVA4nc9eSrhxftb/3IpLH+8MHg=; h=DKIM-Signature:From:Date:Subject:MIME-Version:Message-Id:To; b=riNNRG5O/qN4xlyTmLE+vf/w0IdiPPNn1dQPW7cOv04kpo3F8qellCjnIChFKlHZDS8RidnB2fC9T9EzuWqPdNLKKC9HWnlWvV0Ewgnq2PTKZM1BSpY25Y1D/O0VAO0/TdFFi8Q+zGSKqrIxwLFa6NRgFz01iQDurWJ7KZPON3E= ARC-Authentication-Results: i=1; server2.sourceware.org Received: from eig-obgw-6004a.ext.cloudfilter.net ([10.0.30.197]) by cmsmtp with ESMTPS id wrLlqblVwjtZ3xF7dqTyKE; Sun, 29 Oct 2023 23:23:09 +0000 Received: from box5379.bluehost.com ([162.241.216.53]) by cmsmtp with ESMTPS id xF7bqF6RywasUxF7cqq23Y; Sun, 29 Oct 2023 23:23:08 +0000 X-Authority-Analysis: v=2.4 cv=ZpP+lv3G c=1 sm=1 tr=0 ts=653ee95c a=ApxJNpeYhEAb1aAlGBBbmA==:117 a=ApxJNpeYhEAb1aAlGBBbmA==:17 a=OWjo9vPv0XrRhIrVQ50Ab3nP57M=:19 a=dLZJa+xiwSxG16/P+YVxDGlgEgI=:19 a=IkcTkHD0fZMA:10 a=bhdUkHdE2iEA:10 a=Qbun_eYptAEA:10 a=aqUAavmje40TS3ATxx8A:9 a=QEXdDO2ut3YA:10 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=jlwDAs0SNryrfiqGnL1YDM9RYM17xet2cxbI6izz6zQ=; b=S+rx+mZFubqGoLKeZdNbQfQrwV o/C21FQnmStAK/nyVw0BBdcLAbuarJ8f3pK6gVpvKpWjF33fT45m6s0/ASixyZ1NIuvS2XHnPNY+E AGxAdlr/F6zQm6nEQQ5+9BieS; Received: from 97-122-77-73.hlrn.qwest.net ([97.122.77.73]:56344 helo=[192.168.0.21]) by box5379.bluehost.com with esmtpsa (TLS1.2) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96.2) (envelope-from ) id 1qxF7b-0042zY-1v for gdb-patches@sourceware.org; Sun, 29 Oct 2023 17:23:07 -0600 From: Tom Tromey Date: Sun, 29 Oct 2023 17:23:33 -0600 Subject: [PATCH 12/30] Introduce read_var_value overload MIME-Version: 1.0 Message-Id: <20231029-split-objfile-2023-bound-sym-october-v1-12-612531df2734@tromey.com> References: <20231029-split-objfile-2023-bound-sym-october-v1-0-612531df2734@tromey.com> In-Reply-To: <20231029-split-objfile-2023-bound-sym-october-v1-0-612531df2734@tromey.com> To: gdb-patches@sourceware.org X-Mailer: b4 0.12.4 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: 97.122.77.73 X-Source-L: No X-Exim-ID: 1qxF7b-0042zY-1v X-Source: X-Source-Args: X-Source-Dir: X-Source-Sender: 97-122-77-73.hlrn.qwest.net ([192.168.0.21]) [97.122.77.73]:56344 X-Source-Auth: tom+tromey.com X-Email-Count: 13 X-Org: HG=bhshared;ORG=bluehost; X-Source-Cap: ZWx5bnJvYmk7ZWx5bnJvYmk7Ym94NTM3OS5ibHVlaG9zdC5jb20= X-Local-Domain: yes X-CMAE-Envelope: MS4xfArP58j66rClxdZgQfremzquKx0V4HA4xPrh4d72YhJ2j4G2XU5mJ+Kg2a2oAooBhwX5w0CI/8IFTk0eZSNCZWC6hM4XPfT/MkKgCNI04OP0CpPoK0cx NW6d9h8CV1XlEzvxHHabPgwRofqYwQ6plFJ2qa1FmaNu89R5T0+b/tBGLHf2mVs3EY8DrmM8XyRd2QuAvZ4EmXTtLdAVJ7g7e+E= X-Spam-Status: No, score=-3024.8 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, GIT_PATCH_0, JMQ_SPF_NEUTRAL, RCVD_IN_DNSWL_LOW, 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.30 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 This adds an overload of read_var_value that accepts a block_symbol. The next batch of patches concern rewriting gdb to use this overload, in the end allowing us to remove a use of value_address. --- gdb/compile/compile-c-symbols.c | 2 +- gdb/compile/compile-cplus-symbols.c | 2 +- gdb/findvar.c | 12 ++++++++++++ gdb/infrun.c | 2 +- gdb/valops.c | 26 ++++++++++++-------------- gdb/value.h | 3 +++ 6 files changed, 30 insertions(+), 17 deletions(-) diff --git a/gdb/compile/compile-c-symbols.c b/gdb/compile/compile-c-symbols.c index 2d49ead249e..40578bf36f4 100644 --- a/gdb/compile/compile-c-symbols.c +++ b/gdb/compile/compile-c-symbols.c @@ -155,7 +155,7 @@ convert_one_symbol (compile_c_instance *context, sym.symbol->print_name ()); } - val = read_var_value (sym.symbol, sym.block, frame); + val = read_var_value (sym, frame); if (val->lval () != lval_memory) error (_("Symbol \"%s\" cannot be used for compilation " "evaluation as its address has not been found."), diff --git a/gdb/compile/compile-cplus-symbols.c b/gdb/compile/compile-cplus-symbols.c index dec0260bf7a..1288225f08e 100644 --- a/gdb/compile/compile-cplus-symbols.c +++ b/gdb/compile/compile-cplus-symbols.c @@ -151,7 +151,7 @@ convert_one_symbol (compile_cplus_instance *instance, sym.symbol->print_name ()); } - val = read_var_value (sym.symbol, sym.block, frame); + val = read_var_value (sym, frame); if (val->lval () != lval_memory) error (_("Symbol \"%s\" cannot be used for compilation " "evaluation as its address has not been found."), diff --git a/gdb/findvar.c b/gdb/findvar.c index 4e992ecdcc7..909dca65532 100644 --- a/gdb/findvar.c +++ b/gdb/findvar.c @@ -794,6 +794,18 @@ read_var_value (struct symbol *var, const struct block *var_block, return lang->read_var_value (var, var_block, frame); } +/* Calls VAR's language read_var_value hook with the given arguments. */ + +struct value * +read_var_value (block_symbol var, frame_info_ptr frame) +{ + const struct language_defn *lang = language_def (var.symbol->language ()); + + gdb_assert (lang != NULL); + + return lang->read_var_value (var.symbol, var.block, frame); +} + /* Install default attributes for register values. */ struct value * diff --git a/gdb/infrun.c b/gdb/infrun.c index 4fde96800fb..a7cb02c958e 100644 --- a/gdb/infrun.c +++ b/gdb/infrun.c @@ -8311,7 +8311,7 @@ insert_exception_resume_breakpoint (struct thread_info *tp, vsym = lookup_symbol_search_name (sym->search_name (), b, VAR_DOMAIN); - value = read_var_value (vsym.symbol, vsym.block, frame); + value = read_var_value (vsym, frame); /* If the value was optimized out, revert to the old behavior. */ if (! value->optimized_out ()) { diff --git a/gdb/valops.c b/gdb/valops.c index 70851cd40b4..b7ed458a649 100644 --- a/gdb/valops.c +++ b/gdb/valops.c @@ -3711,17 +3711,16 @@ value_struct_elt_for_reference (struct type *domain, int offset, if (TYPE_FN_FIELD_STATIC_P (f, j)) { - struct symbol *s = - lookup_symbol (TYPE_FN_FIELD_PHYSNAME (f, j), - 0, VAR_DOMAIN, 0).symbol; + block_symbol s = lookup_symbol (TYPE_FN_FIELD_PHYSNAME (f, j), + 0, VAR_DOMAIN, 0); - if (s == NULL) - return NULL; + if (s.symbol == nullptr) + return nullptr; if (want_address) - return value_addr (read_var_value (s, 0, 0)); + return value_addr (read_var_value (s, 0)); else - return read_var_value (s, 0, 0); + return read_var_value (s, 0); } if (TYPE_FN_FIELD_VIRTUAL_P (f, j)) @@ -3742,14 +3741,13 @@ value_struct_elt_for_reference (struct type *domain, int offset, } else { - struct symbol *s = - lookup_symbol (TYPE_FN_FIELD_PHYSNAME (f, j), - 0, VAR_DOMAIN, 0).symbol; + block_symbol s = lookup_symbol (TYPE_FN_FIELD_PHYSNAME (f, j), + 0, VAR_DOMAIN, 0); - if (s == NULL) - return NULL; + if (s.symbol == nullptr) + return nullptr; - struct value *v = read_var_value (s, 0, 0); + struct value *v = read_var_value (s, 0); if (!want_address) result = v; else @@ -4000,7 +3998,7 @@ value_of_this (const struct language_defn *lang) error (_("current stack frame does not contain a variable named `%s'"), lang->name_of_this ()); - return read_var_value (sym.symbol, sym.block, frame); + return read_var_value (sym, frame); } /* Return the value of the local variable, if one exists. Return NULL diff --git a/gdb/value.h b/gdb/value.h index e4912717684..b683cbf5f90 100644 --- a/gdb/value.h +++ b/gdb/value.h @@ -1140,6 +1140,9 @@ extern struct value *read_var_value (struct symbol *var, const struct block *var_block, frame_info_ptr frame); +extern struct value *read_var_value (block_symbol var, + frame_info_ptr frame); + extern struct value *allocate_repeat_value (struct type *type, int count); extern struct value *value_mark (void);