From patchwork Sun Oct 29 23:23:39 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tom Tromey X-Patchwork-Id: 78713 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 EEB543875DE1 for ; Sun, 29 Oct 2023 23:24:44 +0000 (GMT) X-Original-To: gdb-patches@sourceware.org Delivered-To: gdb-patches@sourceware.org Received: from omta36.uswest2.a.cloudfilter.net (omta36.uswest2.a.cloudfilter.net [35.89.44.35]) by sourceware.org (Postfix) with ESMTPS id 976173861934 for ; Sun, 29 Oct 2023 23:23:10 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 976173861934 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 976173861934 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=35.89.44.35 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1698621797; cv=none; b=xjX6CkOVdtDr6M76+BkFExV2cgFNTKffj+a74n9QSProhO+Vr7CAhOMGzu/9233GoxCmVTSAXe5/yszGNRrTe/Pd7AaxRN2MIKOsJGfLXD24SVu8DpiIkuDTLP6nslJnFZNplzTn3juX/dHz5ax5Be+v9IZ+z5xsBba2RXRguZE= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1698621797; c=relaxed/simple; bh=acGl2LIXfvaYtWxTPv9AVEWbEVMUuEWgrqmCYKpJxLw=; h=DKIM-Signature:From:Date:Subject:MIME-Version:Message-Id:To; b=AxD0L3D+SlJVvyUMLlv8un4hO1ce8fwFt2EKAwT275+qDVX7Ieksj1RbbsnTQOrcbU3ZsHEwmixjbK4P246lg4NfEjx4leCIqcmApQffsVaQLisBVT7LCHlSsBZ+cyC3g24H8+reIKEphFGGCMRxn6nMzUPlCONHsQPWGFTMebA= ARC-Authentication-Results: i=1; server2.sourceware.org Received: from eig-obgw-5001a.ext.cloudfilter.net ([10.0.29.139]) by cmsmtp with ESMTPS id x5Odq0sJ6hqFdxF7dqZuU7; Sun, 29 Oct 2023 23:23:09 +0000 Received: from box5379.bluehost.com ([162.241.216.53]) by cmsmtp with ESMTPS id xF7cqy0IOkmEdxF7cqWc91; Sun, 29 Oct 2023 23:23:09 +0000 X-Authority-Analysis: v=2.4 cv=AsL9YcxP c=1 sm=1 tr=0 ts=653ee95d 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=WYKp5gSY-ysYaT8eYLwA: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=jWtCARlyQErimW8a4e/YPhT5t4wIsxA71uMQ8+X6r6k=; b=cft96/vWRkCtKi2gqzjDpAtkNL CcOvIiVs+BPSYMD4uU/9gRHoq5DiOdEQAXzfsCR/TNrOv/15ejO6q4+hUisqBRcJNoUDFEZOcYHGg TZB9wlYCOhYdEdqCNLup1Q6EP; 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 1qxF7c-0042zY-1D for gdb-patches@sourceware.org; Sun, 29 Oct 2023 17:23:08 -0600 From: Tom Tromey Date: Sun, 29 Oct 2023 17:23:39 -0600 Subject: [PATCH 18/30] Change value_of_variable to take a block_symbol MIME-Version: 1.0 Message-Id: <20231029-split-objfile-2023-bound-sym-october-v1-18-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: 1qxF7c-0042zY-1D 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: 19 X-Org: HG=bhshared;ORG=bluehost; X-Source-Cap: ZWx5bnJvYmk7ZWx5bnJvYmk7Ym94NTM3OS5ibHVlaG9zdC5jb20= X-Local-Domain: yes X-CMAE-Envelope: MS4xfJ7BMR0YRqCY6ze0vQkg6XOGkPhnIS4AzXUv9D9Ij2R/I4ecOMyEnItioHsbCILNcfzPaA0EOTWr9TQaCnyS0Z1xEF9nBqxUGKOyfYEjzLKXfh+xI1cL LAO2zPTj97nTq/WhYlF+ZKFn8IHEs8wzbMof06oHPMWB0GyUfQmi5ogUs3X0hKy8lb5CwOcB1QjMF1pGqlObIUv3A5ElPiO8nEM= X-Spam-Status: No, score=-3024.5 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, GIT_PATCH_0, JMQ_SPF_NEUTRAL, 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 changes value_of_variable to take a block_symbol and to call the new read_var_value overload. --- gdb/ada-lang.c | 2 +- gdb/dwarf2/loc.c | 2 +- gdb/eval.c | 17 +++++++---------- gdb/f-valprint.c | 4 ++-- gdb/python/py-type.c | 2 +- gdb/rust-lang.c | 2 +- gdb/valarith.c | 2 +- gdb/valops.c | 15 ++++++++------- gdb/value.c | 2 +- gdb/value.h | 6 ++---- 10 files changed, 25 insertions(+), 29 deletions(-) diff --git a/gdb/ada-lang.c b/gdb/ada-lang.c index 8f2fc5410d4..1f854940b36 100644 --- a/gdb/ada-lang.c +++ b/gdb/ada-lang.c @@ -11389,7 +11389,7 @@ get_var_value (const char *name, const char *err_msg) error (("%s"), err_msg); } - return value_of_variable (syms[0].symbol, syms[0].block); + return value_of_variable (syms[0]); } /* Value of integer variable named NAME in the current environment. diff --git a/gdb/dwarf2/loc.c b/gdb/dwarf2/loc.c index 17509f81464..fad32cfc27c 100644 --- a/gdb/dwarf2/loc.c +++ b/gdb/dwarf2/loc.c @@ -627,7 +627,7 @@ compute_var_value (const char *name) struct block_symbol sym = lookup_symbol (name, nullptr, VAR_DOMAIN, nullptr); if (sym.symbol != nullptr) - return value_of_variable (sym.symbol, sym.block); + return value_of_variable (sym); return nullptr; } diff --git a/gdb/eval.c b/gdb/eval.c index 0f5e3c18a05..5b40eed6799 100644 --- a/gdb/eval.c +++ b/gdb/eval.c @@ -532,7 +532,7 @@ evaluate_var_value (enum noside noside, block_symbol var) try { - ret = value_of_variable (var.symbol, var.block); + ret = value_of_variable (var); } catch (const gdb_exception_error &except) @@ -773,7 +773,7 @@ scope_operation::evaluate_funcall (struct type *expect_type, find_overload_match (arg_view, nullptr, NON_METHOD, nullptr, function, nullptr, &symp, nullptr, 1, noside); - callee = value_of_variable (symp.symbol, get_selected_block (0)); + callee = value_of_variable (symp); } return evaluate_subexp_do_call (exp, noside, callee, arg_view, @@ -2028,17 +2028,15 @@ eval_op_objc_msgcall (struct type *expect_type, struct expression *exp, addr = value_as_long (ret); if (addr) { - struct symbol *sym = NULL; - /* The address might point to a function descriptor; resolve it to the actual code address instead. */ addr = gdbarch_convert_from_func_ptr_addr (exp->gdbarch, addr, current_inferior ()->top_target ()); /* Is it a high_level symbol? */ - sym = find_pc_function (addr).symbol; - if (sym != NULL) - method = value_of_variable (sym, 0); + block_symbol sym = find_pc_function (addr); + if (sym.symbol != nullptr) + method = value_of_variable (sym); } /* If we found a method with symbol information, check to see @@ -2668,7 +2666,7 @@ var_value_operation::evaluate_for_address (struct expression *exp, return value::zero (type, not_lval); } else - return address_of_variable (var, std::get<0> (m_storage).block); + return address_of_variable (std::get<0> (m_storage)); } value * @@ -2681,8 +2679,7 @@ var_value_operation::evaluate_with_coercion (struct expression *exp, && !type->is_vector () && CAST_IS_CONVERSION (exp->language_defn)) { - struct value *val = address_of_variable (var, - std::get<0> (m_storage).block); + struct value *val = address_of_variable (std::get<0> (m_storage)); return value_cast (lookup_pointer_type (type->target_type ()), val); } return evaluate (nullptr, exp, noside); diff --git a/gdb/f-valprint.c b/gdb/f-valprint.c index 2b7dafc4de3..5cafb5137e0 100644 --- a/gdb/f-valprint.c +++ b/gdb/f-valprint.c @@ -556,7 +556,7 @@ f_language::value_print_inner (struct value *val, struct ui_file *stream, if (sym.symbol == nullptr) error (_("failed to find symbol for name list component %s"), field_name); - field = value_of_variable (sym.symbol, sym.block); + field = value_of_variable (sym); } else field = value_field (val, index); @@ -657,7 +657,7 @@ info_common_command_for_block (const struct block *block, const char *comname, try { - val = value_of_variable (common->contents[index], block); + val = value_of_variable ({ common->contents[index], block }); value_print (val, gdb_stdout, &opts); } diff --git a/gdb/python/py-type.c b/gdb/python/py-type.c index bfaa6d24d94..3c8b7f6c8b6 100644 --- a/gdb/python/py-type.c +++ b/gdb/python/py-type.c @@ -1065,7 +1065,7 @@ typy_template_argument (PyObject *self, PyObject *args) try { scoped_value_mark free_values; - struct value *val = value_of_variable (sym, block); + struct value *val = value_of_variable ({ sym, block }); result = value_to_value_object (val); } catch (const gdb_exception &except) diff --git a/gdb/rust-lang.c b/gdb/rust-lang.c index aa106b44bd9..841ca74137b 100644 --- a/gdb/rust-lang.c +++ b/gdb/rust-lang.c @@ -1574,7 +1574,7 @@ rust_structop::evaluate_funcall (struct type *expect_type, if (fn_type->field (0).type ()->code () == TYPE_CODE_PTR) args[0] = value_addr (args[0]); - value *function = address_of_variable (sym.symbol, block); + value *function = address_of_variable (sym); for (int i = 0; i < ops.size (); ++i) args[i + 1] = ops[i]->evaluate (nullptr, exp, noside); diff --git a/gdb/valarith.c b/gdb/valarith.c index 5f9ecdf912c..de77c757b04 100644 --- a/gdb/valarith.c +++ b/gdb/valarith.c @@ -355,7 +355,7 @@ value_user_defined_cpp_op (gdb::array_view args, char *oper, expect a reference as its first argument rather the explicit structure. */ args[0] = value_ind (args[0]); - return value_of_variable (symp.symbol, symp.block); + return value_of_variable (symp); } error (_("Could not find %s."), oper); diff --git a/gdb/valops.c b/gdb/valops.c index 9cb9a7147e2..07cc66b2a8d 100644 --- a/gdb/valops.c +++ b/gdb/valops.c @@ -130,7 +130,7 @@ find_function_in_inferior (const char *name, struct objfile **objf_p) if (objf_p) *objf_p = sym.symbol->objfile (); - return value_of_variable (sym.symbol, sym.block); + return value_of_variable (sym); } else { @@ -1383,26 +1383,27 @@ value_repeat (struct value *arg1, int count) } struct value * -value_of_variable (struct symbol *var, const struct block *b) +value_of_variable (block_symbol var) { frame_info_ptr frame = NULL; - if (symbol_read_needs_frame (var)) + if (symbol_read_needs_frame (var.symbol)) frame = get_selected_frame (_("No frame selected.")); - return read_var_value (var, b, frame); + return read_var_value (var, frame); } struct value * -address_of_variable (struct symbol *var, const struct block *b) +address_of_variable (block_symbol bvar) { + symbol *var = bvar.symbol; struct type *type = var->type (); struct value *val; /* Evaluate it first; if the result is a memory address, we're fine. Lazy evaluation pays off here. */ - val = value_of_variable (var, b); + val = value_of_variable (bvar); type = val->type (); if ((val->lval () == lval_memory && val->lazy ()) @@ -3830,7 +3831,7 @@ value_maybe_namespace_elt (const struct type *curtype, && (sym.symbol->aclass () == LOC_TYPEDEF)) result = value::allocate (sym.symbol->type ()); else - result = value_of_variable (sym.symbol, sym.block); + result = value_of_variable (sym); if (want_address) result = value_addr (result); diff --git a/gdb/value.c b/gdb/value.c index 17b7c53d052..4fd77b774f6 100644 --- a/gdb/value.c +++ b/gdb/value.c @@ -2897,7 +2897,7 @@ value_static_field (struct type *type, int fieldno) retval = value_at_lazy (field_type, msym.value_address ()); } else - retval = value_of_variable (sym.symbol, sym.block); + retval = value_of_variable (sym); break; } default: diff --git a/gdb/value.h b/gdb/value.h index 37c07a41205..7cb830110fc 100644 --- a/gdb/value.h +++ b/gdb/value.h @@ -1117,11 +1117,9 @@ extern struct value *value_from_register (struct type *type, int regnum, extern CORE_ADDR address_from_register (int regnum, frame_info_ptr frame); -extern struct value *value_of_variable (struct symbol *var, - const struct block *b); +extern struct value *value_of_variable (block_symbol var); -extern struct value *address_of_variable (struct symbol *var, - const struct block *b); +extern struct value *address_of_variable (block_symbol var); extern struct value *value_of_register (int regnum, frame_info_ptr frame);