From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from omta34.uswest2.a.cloudfilter.net (omta34.uswest2.a.cloudfilter.net [35.89.44.33]) by sourceware.org (Postfix) with ESMTPS id AB64A3856DDA for ; Sun, 5 Nov 2023 18:11:34 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org AB64A3856DDA 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 AB64A3856DDA Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=35.89.44.33 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1699207899; cv=none; b=RgXFrZFW4SSVLN1jdZcv+01kg7wR1TRlHhoZU+PVRm7wR+eu+jTrzZHX1NdGm/T0vYE0NM8HTVZn+Roa7aJBG5fESnQTW8Cc0OqyNFCzeXkQX0/orQoJ9afC4FS36ZxTAJYm7ta/8X4phunbLuTLUnOc3cQNuMZu+NFBVPQcveg= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1699207899; c=relaxed/simple; bh=ULkYEtAmZDzvzoGwWfugzIiVnL5w/MpQu1lt09UxkO0=; h=DKIM-Signature:From:Date:Subject:MIME-Version:Message-Id:To; b=rwm6NAGANrWo+vsbH3dE1qxGUZ37nkaioK3mh+jGL6rahFnnK855DFoGaNjn45mLst6xWZpBVWUu9xsfTQOR+Ntmd4jyTSoduE0y39JvkvT9tJnA7xnNYsdDynvjirziPPN+Q0StHiHLKdKPutxmF8WpsuMsBG4TmOWKCtwIhng= ARC-Authentication-Results: i=1; server2.sourceware.org Received: from eig-obgw-6006a.ext.cloudfilter.net ([10.0.30.182]) by cmsmtp with ESMTPS id zgpCqHXl68Htezhawq8aBg; Sun, 05 Nov 2023 18:11:34 +0000 Received: from box5379.bluehost.com ([162.241.216.53]) by cmsmtp with ESMTPS id zhavquCMq1wVhzhavqoHh3; Sun, 05 Nov 2023 18:11:33 +0000 X-Authority-Analysis: v=2.4 cv=ANu0s8gj c=1 sm=1 tr=0 ts=6547dad5 a=ApxJNpeYhEAb1aAlGBBbmA==:117 a=ApxJNpeYhEAb1aAlGBBbmA==:17 a=OWjo9vPv0XrRhIrVQ50Ab3nP57M=:19 a=dLZJa+xiwSxG16/P+YVxDGlgEgI=:19 a=IkcTkHD0fZMA:10 a=BNY50KLci1gA: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=PbwNTN9Lly9O4VCnDwuO1/mj/Gb2LF7s1Pwog6xkFhQ=; b=kkICr5MHg8qsUIh2tAu6OqYzKq JNBYM6ekV21WWSY49VBMiLXXn93eYqVbcxcDl7eUHB8qoY/c5z7IK15X9+8npIcoSj4dYE2MPSX56 uv1hB3HA023L7THLoxMCcnDj4; Received: from 97-122-77-73.hlrn.qwest.net ([97.122.77.73]:51014 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 1qzhau-003Y66-3B for gdb-patches@sourceware.org; Sun, 05 Nov 2023 11:11:33 -0700 From: Tom Tromey Date: Sun, 05 Nov 2023 11:11:57 -0700 Subject: [PATCH v2 19/31] Change value_of_variable to take a block_symbol MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit Message-Id: <20231105-split-objfile-2023-bound-sym-october-v2-19-dbd2d158bbc3@tromey.com> References: <20231105-split-objfile-2023-bound-sym-october-v2-0-dbd2d158bbc3@tromey.com> In-Reply-To: <20231105-split-objfile-2023-bound-sym-october-v2-0-dbd2d158bbc3@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: 1qzhau-003Y66-3B 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]:51014 X-Source-Auth: tom+tromey.com X-Email-Count: 20 X-Org: HG=bhshared;ORG=bluehost; X-Source-Cap: ZWx5bnJvYmk7ZWx5bnJvYmk7Ym94NTM3OS5ibHVlaG9zdC5jb20= X-Local-Domain: yes X-CMAE-Envelope: MS4xfBjI+SbQQW7QsbynRibF/SmxhsD7DChkOw1f3wZaVUCi4KTV7z7I7FFJBll0fJPCaSBIEKSMJJ3fww/PLAeDXfq8AOa34Glz5JgFV6ZIyQvd4ylXc5mo MsBcELX6zJy35yjmxNbWyKe7mxGzOs0vUQDSITqj+qFEw77KgplrW7diUJ5B3gI/UepY/++QXnwgqfIpSrj494Rz8BmT6NKlgEQ= 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,T_SCC_BODY_TEXT_LINE 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 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 ef7864b6770..6beadad568a 100644 --- a/gdb/ada-lang.c +++ b/gdb/ada-lang.c @@ -11374,7 +11374,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); -- 2.41.0